2022-12-04 15:52:49 +08:00
|
|
|
import log from 'loglevel';
|
2025-12-13 13:41:55 +08:00
|
|
|
import updateNotifier from 'update-notifier';
|
|
|
|
|
import packageJson from '../package.json';
|
2023-06-22 14:36:02 +08:00
|
|
|
import BuilderProvider from './builders/BuilderProvider';
|
2023-06-23 13:15:49 +08:00
|
|
|
import handleInputOptions from './options/index';
|
2025-12-12 20:18:22 +08:00
|
|
|
import { getCliProgram } from './helpers/cli-program';
|
2023-06-23 13:15:49 +08:00
|
|
|
import { PakeCliOptions } from './types';
|
2022-11-22 00:24:06 +08:00
|
|
|
|
2025-12-12 20:18:22 +08:00
|
|
|
const program = getCliProgram();
|
2025-08-05 19:53:58 +08:00
|
|
|
|
2025-12-13 13:41:55 +08:00
|
|
|
async function checkUpdateTips() {
|
|
|
|
|
updateNotifier({ pkg: packageJson, updateCheckInterval: 1000 * 60 }).notify({
|
|
|
|
|
isGlobal: true,
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2025-12-12 20:18:22 +08:00
|
|
|
program.action(async (url: string, options: PakeCliOptions) => {
|
|
|
|
|
await checkUpdateTips();
|
2025-08-05 19:53:58 +08:00
|
|
|
|
2025-12-12 20:18:22 +08:00
|
|
|
if (!url) {
|
|
|
|
|
program.help({
|
|
|
|
|
error: false,
|
|
|
|
|
});
|
|
|
|
|
return;
|
|
|
|
|
}
|
2022-12-04 15:52:49 +08:00
|
|
|
|
2025-12-12 20:18:22 +08:00
|
|
|
log.setDefaultLevel('info');
|
|
|
|
|
log.setLevel('info');
|
|
|
|
|
if (options.debug) {
|
|
|
|
|
log.setLevel('debug');
|
|
|
|
|
}
|
2022-12-04 15:52:49 +08:00
|
|
|
|
2025-12-12 20:18:22 +08:00
|
|
|
const appOptions = await handleInputOptions(options, url);
|
2022-11-22 00:24:06 +08:00
|
|
|
|
2025-12-12 20:18:22 +08:00
|
|
|
const builder = BuilderProvider.create(appOptions);
|
|
|
|
|
await builder.prepare();
|
|
|
|
|
await builder.build(url);
|
|
|
|
|
});
|
2022-11-22 00:24:06 +08:00
|
|
|
|
|
|
|
|
program.parse();
|