Skip to content

Commit 5206715

Browse files
committed
ci: add build script
1 parent 01985a0 commit 5206715

5 files changed

Lines changed: 43 additions & 52 deletions

File tree

scripts/build.js

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import { resolve } from 'node:path';
2+
import { existsSync } from 'node:fs';
3+
import { readdir } from 'node:fs/promises';
4+
import { argv } from 'node:process';
5+
import { URL } from 'node:url'
6+
import minimist from 'minimist';
7+
import { execa } from 'execa';
8+
9+
const args = minimist(argv.slice(2));
10+
const targets = args['_'][0].split(',');
11+
const formatArgs = args['format'];
12+
const prod = args['prod'] || args['p'];
13+
14+
const packagesUrl = new URL('../packages', import.meta.url);
15+
16+
async function run() {
17+
const packageDirs = await readdir(packagesUrl.pathname);
18+
const targetPackages = packageDirs
19+
.filter((dir) => targets.includes(dir))
20+
.filter((dir) => existsSync(resolve(packagesUrl.pathname, dir)));
21+
22+
await execa('pnpm', ['--filter', `@alilc/lowcode-${targetPackages[0]}`, 'build:target'], {
23+
stdio: 'inherit',
24+
env: {
25+
FORMATS: !prod ? formatArgs : undefined,
26+
},
27+
});
28+
}
29+
30+
run();

scripts/dev.mjs

Whitespace-only changes.
Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
11
import { join } from 'node:path';
22
import { existsSync, readdirSync } from 'node:fs';
3+
import { env, exit } from 'node:process'
4+
import * as console from 'node:console'
35
import { Extractor, ExtractorConfig } from '@microsoft/api-extractor';
46
import { rimraf } from 'rimraf';
57

6-
const libPath = process.env.PWD;
8+
const libPath = env.PWD;
79
const packages = readdirSync(join(libPath, 'temp/packages'));
810
const typeTempIndexPath = join(libPath, 'temp/packages', packages[0], 'src/index.d.ts');
911

1012
if (!existsSync(typeTempIndexPath)) {
1113
console.error('🚨类型入口路径错误');
12-
process.exit(1);
14+
exit(1);
1315
}
1416

1517
async function run() {
@@ -36,7 +38,7 @@ async function run() {
3638
'🚨类型声明文件生成失败:' +
3739
+`\n\t${extractorResult.errorCount} errors``\n\tand ${extractorResult.warningCount} warnings`,
3840
);
39-
process.exit(1);
41+
exit(1);
4042
}
4143
}
4244

scripts/set-repo.js

Lines changed: 0 additions & 45 deletions
This file was deleted.

scripts/sync-oss.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
#!/usr/bin/env node
2-
const http = require('http');
3-
const package = require('../packages/engine/package.json');
4-
const { version, name } = package;
2+
import { request } from 'node:http';
3+
import packageJson from '../packages/engine/package.json';
4+
import * as console from 'node:console';
5+
import { Buffer } from 'node:buffer'
6+
7+
const { version, name } = packageJson;
8+
59
const options = {
610
method: 'PUT',
711
hostname: 'uipaas-node.alibaba-inc.com',
@@ -29,7 +33,7 @@ const onResponse = function (res) {
2933
});
3034
};
3135

32-
const req = http.request(options, onResponse);
36+
const req = request(options, onResponse);
3337

3438
const postData = JSON.stringify({
3539
packages: [

0 commit comments

Comments
 (0)