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/);
|
2024-07-21 15:33:21 +00:00
|
|
|
// lets make sure shared is always transpiled first
|
|
|
|
const indexShared = tsFolders.indexOf('ts_shared');
|
|
|
|
if (indexShared > -1) {
|
|
|
|
tsFolders.splice(indexShared, 1);
|
|
|
|
tsFolders.unshift('ts_interfaces');
|
|
|
|
}
|
|
|
|
|
2024-05-13 23:20:49 +00:00
|
|
|
|
|
|
|
// lets make sure interfaces are always transpiled first
|
2024-07-21 15:33:21 +00:00
|
|
|
const indexInterfaces = tsFolders.indexOf('ts_interfaces');
|
|
|
|
if (indexInterfaces > -1) {
|
|
|
|
tsFolders.splice(indexInterfaces, 1);
|
2024-05-13 23:20:49 +00:00
|
|
|
tsFolders.unshift('ts_interfaces');
|
|
|
|
}
|
2024-05-10 13:55:25 +00:00
|
|
|
const compilationCommandObject: { [key: string]: string } = {};
|
2024-07-21 15:33:21 +00:00
|
|
|
console.log(`compiling in this order:`);
|
|
|
|
console.log(tsFolders);
|
2024-05-10 13:55:25 +00:00
|
|
|
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();
|
|
|
|
};
|