2024-05-10 13:55:25 +00:00
|
|
|
import * as plugins from './plugins.js';
|
|
|
|
import * as paths from './paths.js';
|
2022-03-12 18:05:46 +00:00
|
|
|
import * as tsbuild from './tsbuild.exports.js';
|
2018-12-05 22:29:01 +00:00
|
|
|
|
2020-04-30 09:02:43 +00:00
|
|
|
export const runCli = async () => {
|
|
|
|
const tsbuildCli = new plugins.smartcli.Smartcli();
|
2018-12-05 22:29:01 +00:00
|
|
|
|
2020-04-30 09:02:43 +00:00
|
|
|
/**
|
|
|
|
* the standard task compiles anything in ts/ directory to dist directory
|
|
|
|
*/
|
2022-08-03 17:34:51 +00:00
|
|
|
tsbuildCli.standardCommand().subscribe(async (argvArg) => {
|
2018-12-05 22:29:01 +00:00
|
|
|
tsbuild.compileGlobStringObject(
|
|
|
|
{
|
2020-04-30 09:02:43 +00:00
|
|
|
'./ts/**/*.ts': './dist_ts',
|
2018-12-05 22:29:01 +00:00
|
|
|
},
|
|
|
|
{},
|
|
|
|
process.cwd(),
|
|
|
|
argvArg
|
|
|
|
);
|
2020-04-30 09:02:43 +00:00
|
|
|
});
|
2018-12-05 22:32:27 +00:00
|
|
|
|
2020-04-30 09:02:43 +00:00
|
|
|
/**
|
|
|
|
* the custom command compiles any customDir to dist_customDir
|
|
|
|
*/
|
|
|
|
tsbuildCli.addCommand('custom').subscribe(async (argvArg) => {
|
|
|
|
const listedDirectories = argvArg._;
|
2024-05-10 13:55:25 +00:00
|
|
|
listedDirectories.shift(); // removes the first element that is "custom"
|
2020-04-30 09:02:43 +00:00
|
|
|
const compilationCommandObject: { [key: string]: string } = {};
|
|
|
|
for (const directory of listedDirectories) {
|
|
|
|
compilationCommandObject[`./${directory}/**/*.ts`] = `./dist_${directory}`;
|
|
|
|
}
|
|
|
|
await tsbuild.compileGlobStringObject(compilationCommandObject, {}, process.cwd(), argvArg);
|
|
|
|
});
|
2020-03-09 15:14:06 +00:00
|
|
|
|
2024-05-10 13:55:25 +00:00
|
|
|
/**
|
|
|
|
* the custom command compiles any customDir to dist_customDir
|
|
|
|
*/
|
|
|
|
tsbuildCli.addCommand('tsfolders').subscribe(async (argvArg) => {
|
2024-05-13 23:20:49 +00:00
|
|
|
const tsFolders = await plugins.smartfile.fs.listFolders(paths.cwd, /^ts/);
|
|
|
|
|
|
|
|
// lets make sure interfaces are always transpiled first
|
|
|
|
const index = tsFolders.indexOf('ts_interfaces');
|
|
|
|
if (index > -1) {
|
|
|
|
tsFolders.splice(index, 1);
|
|
|
|
tsFolders.unshift('ts_interfaces');
|
|
|
|
}
|
2024-05-10 13:55:25 +00:00
|
|
|
const compilationCommandObject: { [key: string]: string } = {};
|
|
|
|
for (const tsFolder of tsFolders) {
|
|
|
|
compilationCommandObject[`./${tsFolder}/**/*.ts`] = `./dist_${tsFolder}`;
|
|
|
|
}
|
|
|
|
await tsbuild.compileGlobStringObject(compilationCommandObject, {}, process.cwd(), argvArg);
|
2020-04-30 09:02:43 +00:00
|
|
|
});
|
2019-01-27 01:42:58 +00:00
|
|
|
|
2024-05-10 14:52:43 +00:00
|
|
|
/**
|
|
|
|
* the custom command compiles any customDir to dist_customDir
|
|
|
|
*/
|
|
|
|
tsbuildCli.addCommand('interfaces').subscribe(async (argvArg) => {
|
2024-05-13 23:20:49 +00:00
|
|
|
const tsFolders = ['ts_interfaces'];
|
2024-05-10 14:52:43 +00:00
|
|
|
const compilationCommandObject: { [key: string]: string } = {};
|
|
|
|
for (const tsFolder of tsFolders) {
|
|
|
|
compilationCommandObject[`./${tsFolder}/**/*.ts`] = `./dist_${tsFolder}`;
|
|
|
|
}
|
|
|
|
await tsbuild.compileGlobStringObject(compilationCommandObject, {}, process.cwd(), argvArg);
|
|
|
|
});
|
|
|
|
|
2020-04-30 09:02:43 +00:00
|
|
|
tsbuildCli.startParse();
|
|
|
|
};
|