tsbundle/ts/tsbundle.cli.ts

56 lines
1.5 KiB
TypeScript
Raw Permalink Normal View History

2022-03-15 23:21:05 +00:00
import * as plugins from './plugins.js';
2022-03-14 15:32:12 +00:00
import { TsBundle } from './tsbundle.class.tsbundle.js';
2022-03-18 14:46:11 +00:00
import { HtmlHandler } from './mod_html/index.js';
2022-03-14 15:32:12 +00:00
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-08-03 17:43:18 +00:00
tsBundleCli.standardCommand().subscribe(async (argvArg) => {
2019-06-16 15:02:38 +00:00
const tsbundle = new TsBundle();
2022-03-15 23:21:05 +00:00
await tsbundle.build(process.cwd(), argvArg.from, argvArg.to, argvArg);
return;
2019-06-16 15:02:38 +00:00
});
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();
2022-03-15 23:21:05 +00:00
await tsbundle.build(
process.cwd(),
'./ts_web/index.ts',
'./dist_bundle/bundle.js',
argvArg
);
2020-03-09 14:36:55 +00:00
});
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();
2022-03-18 14:46:11 +00:00
const htmlHandler = new HtmlHandler();
2022-03-15 23:21:05 +00:00
await tsbundle.build(
process.cwd(),
'./ts/index.ts',
'./dist_bundle/bundle.js',
argvArg
);
2020-05-25 16:29:22 +00:00
});
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();
2022-03-18 14:46:11 +00:00
const htmlHandler = new HtmlHandler();
2022-03-15 23:21:05 +00:00
await tsbundle.build(
process.cwd(),
'./ts_web/index.ts',
'./dist_serve/bundle.js',
argvArg
);
2022-07-24 13:51:55 +00:00
const htmlFiles = await plugins.smartfile.fs.listFiles('./html', /\.html/);
for (const htmlFile of htmlFiles) {
await htmlHandler.processHtml({
from: `./html/${htmlFile}`,
to: `./dist_serve/${htmlFile}`,
minify: true,
});
}
2020-03-14 22:40:09 +00:00
});
2019-06-16 15:02:38 +00:00
tsBundleCli.startParse();
};