mirror of
https://github.com/alibaba/lowcode-engine.git
synced 2025-12-11 18:42:56 +00:00
ci: add build script
This commit is contained in:
parent
01985a0f56
commit
5206715a5c
30
scripts/build.js
Normal file
30
scripts/build.js
Normal file
@ -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();
|
||||||
@ -1,15 +1,17 @@
|
|||||||
import { join } from 'node:path';
|
import { join } from 'node:path';
|
||||||
import { existsSync, readdirSync } from 'node:fs';
|
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 { Extractor, ExtractorConfig } from '@microsoft/api-extractor';
|
||||||
import { rimraf } from 'rimraf';
|
import { rimraf } from 'rimraf';
|
||||||
|
|
||||||
const libPath = process.env.PWD;
|
const libPath = env.PWD;
|
||||||
const packages = readdirSync(join(libPath, 'temp/packages'));
|
const packages = readdirSync(join(libPath, 'temp/packages'));
|
||||||
const typeTempIndexPath = join(libPath, 'temp/packages', packages[0], 'src/index.d.ts');
|
const typeTempIndexPath = join(libPath, 'temp/packages', packages[0], 'src/index.d.ts');
|
||||||
|
|
||||||
if (!existsSync(typeTempIndexPath)) {
|
if (!existsSync(typeTempIndexPath)) {
|
||||||
console.error('🚨类型入口路径错误');
|
console.error('🚨类型入口路径错误');
|
||||||
process.exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function run() {
|
async function run() {
|
||||||
@ -36,7 +38,7 @@ async function run() {
|
|||||||
'🚨类型声明文件生成失败:' +
|
'🚨类型声明文件生成失败:' +
|
||||||
+`\n\t${extractorResult.errorCount} errors``\n\tand ${extractorResult.warningCount} warnings`,
|
+`\n\t${extractorResult.errorCount} errors``\n\tand ${extractorResult.warningCount} warnings`,
|
||||||
);
|
);
|
||||||
process.exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -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}`);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})();
|
|
||||||
@ -1,7 +1,11 @@
|
|||||||
#!/usr/bin/env node
|
#!/usr/bin/env node
|
||||||
const http = require('http');
|
import { request } from 'node:http';
|
||||||
const package = require('../packages/engine/package.json');
|
import packageJson from '../packages/engine/package.json';
|
||||||
const { version, name } = package;
|
import * as console from 'node:console';
|
||||||
|
import { Buffer } from 'node:buffer'
|
||||||
|
|
||||||
|
const { version, name } = packageJson;
|
||||||
|
|
||||||
const options = {
|
const options = {
|
||||||
method: 'PUT',
|
method: 'PUT',
|
||||||
hostname: 'uipaas-node.alibaba-inc.com',
|
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({
|
const postData = JSON.stringify({
|
||||||
packages: [
|
packages: [
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user