forked from alibaba/lowcode-engine
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathset-repo.js
More file actions
45 lines (42 loc) · 1.54 KB
/
set-repo.js
File metadata and controls
45 lines (42 loc) · 1.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#!/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}`);
}
}
})();