-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
75 lines (66 loc) · 1.86 KB
/
Copy pathindex.js
File metadata and controls
75 lines (66 loc) · 1.86 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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
const { runner } = require('hygen');
const Logger = require('hygen/dist/logger');
const fs = require('fs');
const path = require('path');
const defaultTemplates = path.join(__dirname, 'templates');
const execa = require('execa');
const packageJson = require('./package.json');
if (['--version', '-v'].includes(process.argv[2])) {
console.log(packageJson.version);
process.exit(0);
}
function showHelp() {
console.log(`Kodegen v${packageJson.version}\n`);
console.log('Available actions:');
console.log('monorepo: monorepo add-package, monorepo add-service, monorepo init');
console.log('repo: repo init');
console.log(`
Examples:
npx kodegen monorepo init
In monorepo root:
- npx kodegen monorepo add-package
- npx kodegen monorepo add-service
npx kodegen repo init
For more information, visit:
https://github.com/rosen-bridge/kodegen
`);
process.exit(0);
}
if (
process.argv.length <= 2 ||
process.argv.includes('-h') ||
process.argv.includes('--help')
) {
showHelp();
}
(async () => {
try {
await runner(process.argv.slice(2), {
templates: defaultTemplates,
cwd: process.cwd(),
logger: new Logger.default(console.log.bind(console)),
createPrompter: () => require('enquirer'),
exec: (action, body) => {
const opts = body && body.length > 0 ? { input: body } : {};
return execa(action, undefined, { shell: true });
},
debug: true,
helpers: {
rootHasEslint: (() => {
const configFiles = [
'eslint.config.js',
'eslint.config.mjs',
'.eslintrc.js',
'.eslintrc.cjs',
'.eslintrc.json',
'.eslintrc.yaml',
'.eslintrc.yml',
];
return configFiles.some(file => fs.existsSync(path.join(process.cwd(), file)));
})(),
},
});
} catch (err) {
showHelp();
}
})();