diff --git a/scripts/build.js b/scripts/build.js new file mode 100644 index 000000000..8e3aad054 --- /dev/null +++ b/scripts/build.js @@ -0,0 +1,30 @@ +import { resolve } from 'node:path'; +import { existsSync } from 'node:fs'; +import { readdir } from 'node:fs/promises'; +import { argv } from 'node:process'; +import { URL } from 'node:url' +import minimist from 'minimist'; +import { execa } from 'execa'; + +const args = minimist(argv.slice(2)); +const targets = args['_'][0].split(','); +const formatArgs = args['format']; +const prod = args['prod'] || args['p']; + +const packagesUrl = new URL('../packages', import.meta.url); + +async function run() { + const packageDirs = await readdir(packagesUrl.pathname); + const targetPackages = packageDirs + .filter((dir) => targets.includes(dir)) + .filter((dir) => existsSync(resolve(packagesUrl.pathname, dir))); + + await execa('pnpm', ['--filter', `@alilc/lowcode-${targetPackages[0]}`, 'build:target'], { + stdio: 'inherit', + env: { + FORMATS: !prod ? formatArgs : undefined, + }, + }); +} + +run(); diff --git a/scripts/dev.mjs b/scripts/dev.mjs deleted file mode 100644 index e69de29bb..000000000 diff --git a/scripts/rollup-dts.mjs b/scripts/rollup-dts.js similarity index 90% rename from scripts/rollup-dts.mjs rename to scripts/rollup-dts.js index eafee351a..24a5477b1 100644 --- a/scripts/rollup-dts.mjs +++ b/scripts/rollup-dts.js @@ -1,15 +1,17 @@ import { join } from 'node:path'; import { existsSync, readdirSync } from 'node:fs'; +import { env, exit } from 'node:process' +import * as console from 'node:console' import { Extractor, ExtractorConfig } from '@microsoft/api-extractor'; import { rimraf } from 'rimraf'; -const libPath = process.env.PWD; +const libPath = env.PWD; const packages = readdirSync(join(libPath, 'temp/packages')); const typeTempIndexPath = join(libPath, 'temp/packages', packages[0], 'src/index.d.ts'); if (!existsSync(typeTempIndexPath)) { console.error('🚨类型入口路径错误'); - process.exit(1); + exit(1); } async function run() { @@ -36,7 +38,7 @@ async function run() { '🚨类型声明文件生成失败:' + +`\n\t${extractorResult.errorCount} errors``\n\tand ${extractorResult.warningCount} warnings`, ); - process.exit(1); + exit(1); } } diff --git a/scripts/set-repo.js b/scripts/set-repo.js deleted file mode 100644 index 9bae66d05..000000000 --- a/scripts/set-repo.js +++ /dev/null @@ -1,45 +0,0 @@ -#!/usr/bin/env node - -const path = require('path'); -const fs = require('fs-extra'); - -(async () => { - const root = path.join(__dirname, '../'); - const workspaces = ['modules', 'packages']; - for (const workspace of workspaces) { - const pkgDir = path.join(root, workspace); - const pkgs = await fs.readdir(pkgDir); - for (const pkg of pkgs) { - if (pkg.charAt(0) === '.') continue; - if (!(await fs.statSync(path.join(pkgDir, pkg))).isDirectory()) continue; - await setRepo({ - workspace, - pkgDir, - pkg, - }); - } - } - - async function setRepo(opts) { - const pkgDir = path.join(opts.pkgDir, opts.pkg); - const pkgPkgJSONPath = path.join(pkgDir, 'package.json'); - if (!fs.existsSync(pkgPkgJSONPath)) { - console.log(`${opts.pkg} exists`); - } else { - const pkgPkgJSON = require(pkgPkgJSONPath); - fs.writeJSONSync( - pkgPkgJSONPath, - Object.assign(pkgPkgJSON, { - repository: { - type: 'http', - url: `https://github.com/alibaba/lowcode-engine/tree/main/${opts.workspace}/${opts.pkg}`, - }, - bugs: 'https://github.com/alibaba/lowcode-engine/issues', - homepage: 'https://github.com/alibaba/lowcode-engine/#readme', - }), - { spaces: ' ' }, - ); - console.log(`[Write] ${opts.pkg}`); - } - } -})(); diff --git a/scripts/sync-oss.js b/scripts/sync-oss.js index 2108e676d..24749334f 100644 --- a/scripts/sync-oss.js +++ b/scripts/sync-oss.js @@ -1,7 +1,11 @@ #!/usr/bin/env node -const http = require('http'); -const package = require('../packages/engine/package.json'); -const { version, name } = package; +import { request } from 'node:http'; +import packageJson from '../packages/engine/package.json'; +import * as console from 'node:console'; +import { Buffer } from 'node:buffer' + +const { version, name } = packageJson; + const options = { method: 'PUT', hostname: 'uipaas-node.alibaba-inc.com', @@ -29,7 +33,7 @@ const onResponse = function (res) { }); }; -const req = http.request(options, onResponse); +const req = request(options, onResponse); const postData = JSON.stringify({ packages: [