tsbundle/ts/tsbundle.cli.ts

110 lines
3.0 KiB
TypeScript
Raw Normal View History

2022-03-14 15:32:12 +00:00
import * as plugins from './tsbundle.plugins.js';
import { TsBundle } from './tsbundle.class.tsbundle.js';
import { HtmlHandler } from './tsbundle.htmlhandler.js';
import { logger } from './tsbundle.logging.js';
2019-06-16 15:02:38 +00:00
export const runCli = async () => {
const tsBundleCli = new plugins.smartcli.Smartcli();
2022-03-14 15:32:12 +00:00
tsBundleCli.standardTask().subscribe(async (argvArg) => {
2019-06-16 15:02:38 +00:00
const tsbundle = new TsBundle();
2020-03-14 22:40:09 +00:00
// const htmlHandler = new HtmlHandler();
2019-06-16 15:02:38 +00:00
switch (true) {
2019-07-17 10:22:24 +00:00
case argvArg.production || process.env.CI:
2022-03-15 12:01:18 +00:00
await tsbundle.buildProduction(process.cwd(), argvArg.from, argvArg.to, 'rollup', argvArg);
2020-03-14 22:40:09 +00:00
// await htmlHandler.minifyHtml();
2019-06-16 15:02:38 +00:00
break;
case argvArg.test:
2019-06-17 05:06:56 +00:00
default:
2022-03-15 12:01:18 +00:00
await tsbundle.buildTest(process.cwd(), argvArg.from, argvArg.to, 'rollup', argvArg);
2020-03-14 22:40:09 +00:00
// await htmlHandler.copyHtml();
2019-06-16 15:02:38 +00:00
return;
}
});
2022-03-14 15:32:12 +00:00
tsBundleCli.addCommand('element').subscribe(async (argvArg) => {
2020-03-09 14:36:55 +00:00
const tsbundle = new TsBundle();
// const htmlHandler = new HtmlHandler();
switch (true) {
case argvArg.production || process.env.CI:
2022-03-14 15:32:12 +00:00
await tsbundle.buildProduction(
process.cwd(),
'./ts_web/index.ts',
2022-03-15 12:01:18 +00:00
'./dist_bundle/bundle.js',
'rollup',
argvArg
2022-03-14 15:32:12 +00:00
);
2020-03-09 14:36:55 +00:00
// await htmlHandler.minifyHtml();
break;
case argvArg.test:
default:
2022-03-14 15:32:12 +00:00
await tsbundle.buildTest(
process.cwd(),
'./ts_web/index.ts',
'./dist_bundle/bundle.js',
2022-03-15 12:01:18 +00:00
'rollup',
argvArg
2022-03-14 15:32:12 +00:00
);
2020-03-09 14:36:55 +00:00
// await htmlHandler.copyHtml();
return;
}
});
2022-03-14 15:32:12 +00:00
tsBundleCli.addCommand('npm').subscribe(async (argvArg) => {
2020-05-25 16:29:22 +00:00
const tsbundle = new TsBundle();
// const htmlHandler = new HtmlHandler();
switch (true) {
case argvArg.production || process.env.CI:
2022-03-15 12:01:18 +00:00
await tsbundle.buildProduction(
process.cwd(),
'./ts/index.ts',
'./dist_bundle/bundle.js',
'rollup',
argvArg
);
2020-05-25 16:29:22 +00:00
// await htmlHandler.minifyHtml();
break;
case argvArg.test:
default:
2022-03-14 15:32:12 +00:00
await tsbundle.buildTest(
process.cwd(),
'./ts/index.ts',
'./dist_bundle/bundle.js',
2022-03-15 12:01:18 +00:00
'rollup',
argvArg
2022-03-14 15:32:12 +00:00
);
2020-05-25 16:29:22 +00:00
// await htmlHandler.copyHtml();
return;
}
});
2022-03-14 15:32:12 +00:00
tsBundleCli.addCommand('website').subscribe(async (argvArg) => {
2020-03-14 22:40:09 +00:00
const tsbundle = new TsBundle();
const htmlHandler = new HtmlHandler();
switch (true) {
case argvArg.production || process.env.CI:
2022-03-14 15:32:12 +00:00
await tsbundle.buildProduction(
process.cwd(),
'./ts_web/index.ts',
2022-03-15 12:01:18 +00:00
'./dist_serve/bundle.js',
'rollup',
argvArg
2022-03-14 15:32:12 +00:00
);
2020-03-14 22:40:09 +00:00
await htmlHandler.minifyHtml();
break;
case argvArg.test:
default:
2022-03-14 15:32:12 +00:00
await tsbundle.buildTest(
process.cwd(),
'./ts_web/index.ts',
'./dist_serve/bundle.js',
2022-03-15 12:01:18 +00:00
'rollup',
argvArg
2022-03-14 15:32:12 +00:00
);
2020-03-14 22:40:09 +00:00
await htmlHandler.copyHtml();
return;
}
});
2019-06-16 15:02:38 +00:00
tsBundleCli.startParse();
};