vona-cli-set-api 1.1.165 → 1.1.167

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -24,9 +24,9 @@ import chalk from 'chalk';
24
24
  import { spawn } from 'node:child_process';
25
25
  import nodemon from 'nodemon';
26
26
  import { catchError, combineApiPathControllerAndActionRaw, replaceTemplate } from '@cabloy/utils';
27
+ import fs, { readFileSync } from 'node:fs';
27
28
  import { getOnionScenesMeta, getOnionMetasMeta, relativeNameToCapitalize } from '@cabloy/module-info';
28
29
  import { toUpperCaseFirstChar, stringToCapitalize, replaceTemplate as replaceTemplate$1 } from '@cabloy/word-utils';
29
- import fs from 'node:fs';
30
30
  import gogocode from 'gogocode';
31
31
 
32
32
  function getEnvMeta(configMeta) {
@@ -944,13 +944,6 @@ class CliBinDev extends BeanCliBase {
944
944
  console.log('App restarted due to: ', files);
945
945
  });
946
946
  });
947
- // await this.helper.spawnExe({
948
- // cmd: 'node',
949
- // args: ['--experimental-transform-types', '--loader=ts-node/esm', '.vona/bootstrap.ts'],
950
- // options: {
951
- // cwd: projectPath,
952
- // },
953
- // });
954
947
  }
955
948
  }
956
949
 
@@ -1049,6 +1042,27 @@ class CliBinPlay extends BeanCliBase {
1049
1042
  }
1050
1043
  }
1051
1044
 
1045
+ async function runTestChild(args, projectPath) {
1046
+ const child = spawn(process.execPath, args, {
1047
+ cwd: projectPath,
1048
+ stdio: 'inherit'
1049
+ });
1050
+ const onInterrupt = () => child.kill('SIGINT');
1051
+ const onTerminate = () => child.kill('SIGTERM');
1052
+ process.on('SIGINT', onInterrupt);
1053
+ process.on('SIGTERM', onTerminate);
1054
+ try {
1055
+ await new Promise((resolve, reject) => {
1056
+ child.once('error', reject);
1057
+ child.once('close', (code, signal) => {
1058
+ if (code === 0) resolve();else reject(new Error(`Test child exited: ${signal ?? code}`));
1059
+ });
1060
+ });
1061
+ } finally {
1062
+ process.off('SIGINT', onInterrupt);
1063
+ process.off('SIGTERM', onTerminate);
1064
+ }
1065
+ }
1052
1066
  class CliBinTest extends BeanCliBase {
1053
1067
  async execute() {
1054
1068
  const {
@@ -1114,13 +1128,7 @@ class CliBinTest extends BeanCliBase {
1114
1128
  }
1115
1129
  args = args.concat([getImportEsm(resolveVonaLocalPaths(projectPath, 'test').generatedDir), testFile, projectPath, (!!argv.coverage).toString(), patterns.join(',')]);
1116
1130
  // args = args.concat(['--experimental-transform-types', getImportEsm(), testFile, projectPath, (!!argv.coverage).toString(), patterns.join(',')]);
1117
- await this.helper.spawnExe({
1118
- cmd: 'node',
1119
- args,
1120
- options: {
1121
- cwd: projectPath
1122
- }
1123
- });
1131
+ await runTestChild(args, projectPath);
1124
1132
  }
1125
1133
  async _outputCoverageReportViewer(projectPath) {
1126
1134
  // lcovCliFile
@@ -1165,6 +1173,48 @@ class CliBinTest extends BeanCliBase {
1165
1173
  }
1166
1174
  }
1167
1175
 
1176
+ function resolveTypeScriptCompiler(compiler, projectPath) {
1177
+ const packageName = compiler === 'native' ? '@typescript/native' : 'typescript';
1178
+ const require = createRequire(path.resolve(projectPath, 'package.json'));
1179
+ let manifestPath;
1180
+ try {
1181
+ manifestPath = require.resolve(`${packageName}/package.json`);
1182
+ } catch (cause) {
1183
+ throw new Error(`Cannot resolve ${packageName}. Install the ${compiler === 'native' ? 'native TypeScript alias (npm:typescript@7.0.2)' : 'TypeScript package'} in the project or its repository root.`, {
1184
+ cause
1185
+ });
1186
+ }
1187
+ const manifest = JSON.parse(readFileSync(manifestPath, 'utf8'));
1188
+ if (typeof manifest.bin?.tsc !== 'string') {
1189
+ throw new TypeError(`${packageName} does not declare a tsc executable.`);
1190
+ }
1191
+ return path.resolve(path.dirname(manifestPath), manifest.bin.tsc);
1192
+ }
1193
+ async function runTypeScript(compiler, args, {
1194
+ projectPath,
1195
+ cwd = projectPath
1196
+ }) {
1197
+ const executable = resolveTypeScriptCompiler(compiler, projectPath);
1198
+ await new Promise((resolve, reject) => {
1199
+ const child = spawn(process.execPath, [executable, ...args], {
1200
+ cwd,
1201
+ stdio: 'inherit',
1202
+ shell: false
1203
+ });
1204
+ child.once('error', reject);
1205
+ child.once('close', (code, signal) => {
1206
+ if (code === 0) {
1207
+ resolve();
1208
+ } else {
1209
+ reject(Object.assign(new Error(`TypeScript (${compiler}) failed: ${signal ? `signal ${signal}` : `exit code ${code}`}`), {
1210
+ exitCode: code ?? 1,
1211
+ signal
1212
+ }));
1213
+ }
1214
+ });
1215
+ });
1216
+ }
1217
+
1168
1218
  class CliBinTsc extends BeanCliBase {
1169
1219
  async execute() {
1170
1220
  const {
@@ -1174,9 +1224,17 @@ class CliBinTsc extends BeanCliBase {
1174
1224
  await super.execute();
1175
1225
  const projectPath = argv.projectPath;
1176
1226
  const force = argv.force;
1177
- await this._tsc(projectPath, force);
1227
+ await this._tsc(projectPath, force, argv.compiler ?? 'typescript', argv.builders);
1178
1228
  }
1179
- async _tsc(projectPath, force) {
1229
+ async _tsc(projectPath, force, compiler = 'typescript', builders) {
1230
+ if (builders !== undefined) {
1231
+ if (!Number.isSafeInteger(builders) || builders < 1) {
1232
+ throw new Error('--builders must be a positive safe integer');
1233
+ }
1234
+ if (compiler !== 'native') {
1235
+ throw new Error('--builders requires --compiler=native');
1236
+ }
1237
+ }
1180
1238
  const suiteNames = Object.keys(this.modulesMeta.suites).filter(suiteName => !this.modulesMeta.suites[suiteName].info.node_modules);
1181
1239
  const modulesArray = this.modulesMeta.modulesArray.filter(item => !item.suite && !item.info.node_modules);
1182
1240
  // count
@@ -1191,28 +1249,37 @@ class CliBinTsc extends BeanCliBase {
1191
1249
  if (force) {
1192
1250
  tscArgs.push('--force');
1193
1251
  }
1252
+ if (builders !== undefined) {
1253
+ tscArgs.push('--builders', String(builders));
1254
+ }
1255
+ const check = async cwd => {
1256
+ if (compiler === 'native') {
1257
+ await runTypeScript(compiler, tscArgs, {
1258
+ projectPath,
1259
+ cwd
1260
+ });
1261
+ } else {
1262
+ await this.helper.processHelper.tsc(tscArgs, {
1263
+ cwd
1264
+ });
1265
+ }
1266
+ };
1194
1267
  // tsc: project
1195
1268
  // eslint-disable-next-line
1196
1269
  console.log(`===> ${++counter}/${count} project`);
1197
- await this.helper.processHelper.tsc(tscArgs, {
1198
- cwd: projectPath
1199
- });
1270
+ await check(projectPath);
1200
1271
  // suites
1201
1272
  for (const key of suiteNames) {
1202
1273
  const suite = this.modulesMeta.suites[key];
1203
1274
  // eslint-disable-next-line
1204
1275
  console.log(`===> ${++counter}/${count} suite: ${suite.info.originalName}`);
1205
- await this.helper.processHelper.tsc(tscArgs, {
1206
- cwd: suite.root
1207
- });
1276
+ await check(suite.root);
1208
1277
  }
1209
1278
  // modules
1210
1279
  for (const module of modulesArray) {
1211
1280
  // eslint-disable-next-line
1212
1281
  console.log(`===> ${++counter}/${count} module: ${module.info.originalName}`);
1213
- await this.helper.processHelper.tsc(tscArgs, {
1214
- cwd: module.root
1215
- });
1282
+ await check(module.root);
1216
1283
  }
1217
1284
  // end
1218
1285
  const timeEnd = Date.now();
@@ -3664,9 +3731,18 @@ var binTsc = {
3664
3731
  info: {
3665
3732
  version: '5.0.0',
3666
3733
  title: 'Cli: Bin: Tsc',
3667
- usage: 'npm run vona :bin:tsc -- [--force]'
3734
+ usage: 'npm run vona :bin:tsc -- [--force] [--compiler=typescript|native] [--builders=]'
3668
3735
  },
3669
3736
  options: {
3737
+ compiler: {
3738
+ description: 'TypeScript compiler (native requires @typescript/native in the project or repository root)',
3739
+ type: 'string',
3740
+ choices: ['typescript', 'native']
3741
+ },
3742
+ builders: {
3743
+ description: 'Maximum number of projects to build concurrently (native only)',
3744
+ type: 'number'
3745
+ },
3670
3746
  force: {
3671
3747
  description: 'force',
3672
3748
  type: 'boolean'
@@ -7,6 +7,7 @@ declare module '@cabloy/cli' {
7
7
  flavor?: VonaMetaFlavor;
8
8
  }
9
9
  }
10
+ export declare function runTestChild(args: string[], projectPath: string): Promise<void>;
10
11
  export declare class CliBinTest extends BeanCliBase {
11
12
  execute(): Promise<void>;
12
13
  _test(projectPath: string): Promise<void>;
@@ -1,10 +1,13 @@
1
1
  import { BeanCliBase } from '@cabloy/cli';
2
+ import type { TypeScriptCompiler } from '../typescriptRunner.ts';
2
3
  declare module '@cabloy/cli' {
3
4
  interface ICommandArgv {
4
5
  force: boolean;
6
+ compiler: TypeScriptCompiler;
7
+ builders: number;
5
8
  }
6
9
  }
7
10
  export declare class CliBinTsc extends BeanCliBase {
8
11
  execute(): Promise<void>;
9
- _tsc(projectPath: string, force: boolean): Promise<void>;
12
+ _tsc(projectPath: string, force: boolean, compiler?: TypeScriptCompiler, builders?: number): Promise<void>;
10
13
  }
@@ -6,6 +6,15 @@ declare const _default: {
6
6
  usage: string;
7
7
  };
8
8
  options: {
9
+ compiler: {
10
+ description: string;
11
+ type: string;
12
+ choices: string[];
13
+ };
14
+ builders: {
15
+ description: string;
16
+ type: string;
17
+ };
9
18
  force: {
10
19
  description: string;
11
20
  type: string;
@@ -164,6 +164,15 @@ export declare const commands: {
164
164
  usage: string;
165
165
  };
166
166
  options: {
167
+ compiler: {
168
+ description: string;
169
+ type: string;
170
+ choices: string[];
171
+ };
172
+ builders: {
173
+ description: string;
174
+ type: string;
175
+ };
167
176
  force: {
168
177
  description: string;
169
178
  type: string;
@@ -0,0 +1,6 @@
1
+ export type TypeScriptCompiler = 'native' | 'typescript';
2
+ export declare function resolveTypeScriptCompiler(compiler: TypeScriptCompiler, projectPath: string): string;
3
+ export declare function runTypeScript(compiler: TypeScriptCompiler, args: string[], { projectPath, cwd }: {
4
+ projectPath: string;
5
+ cwd?: string;
6
+ }): Promise<void>;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "vona-cli-set-api",
3
- "version": "1.1.165",
4
- "gitHead": "c4185c759d9e8933a078182614a83fd43031659f",
3
+ "version": "1.1.167",
4
+ "gitHead": "b63e6a7b56aa7d6aaa935e98149e43cf7e68d706",
5
5
  "description": "vona cli-set-api",
6
6
  "keywords": [
7
7
  "framework",
@@ -45,7 +45,7 @@
45
45
  "@babel/plugin-proposal-decorators": "^7.29.0",
46
46
  "@babel/plugin-transform-class-properties": "^7.28.6",
47
47
  "@babel/plugin-transform-typescript": "^7.28.6",
48
- "@cabloy/cli": "^3.1.29",
48
+ "@cabloy/cli": "^3.1.30",
49
49
  "@cabloy/dotenv": "^1.2.9",
50
50
  "@cabloy/extend": "^3.2.8",
51
51
  "@cabloy/module-glob": "^5.3.18",
@@ -61,6 +61,7 @@
61
61
  "@rollup/plugin-replace": "^6.0.3",
62
62
  "@rollup/plugin-terser": "^1.0.0",
63
63
  "@rollup/plugin-typescript": "^12.3.0",
64
+ "@swc-node/register": "^1.12.1",
64
65
  "babel-plugin-transform-typescript-metadata": "^0.3.2",
65
66
  "babel-plugin-vona-bean-module": "^1.1.9",
66
67
  "chalk": "^3.0.0",
@@ -74,10 +75,9 @@
74
75
  "randomatic": "^3.1.1",
75
76
  "rimraf": "^6.1.3",
76
77
  "rollup": "^4.60.1",
77
- "ts-node-maintained": "^10.9.6",
78
78
  "urllib": "^4.9.0",
79
79
  "uuid": "^11.1.0",
80
- "vona-core": "^5.1.49",
80
+ "vona-core": "^5.1.50",
81
81
  "why-is-node-running": "^3.2.2",
82
82
  "yargs-parser": "^22.0.0"
83
83
  }
@@ -1,4 +1,4 @@
1
1
  import { register } from 'node:module';
2
2
  import { pathToFileURL } from 'node:url';
3
3
 
4
- register('ts-node-maintained/esm', pathToFileURL('./'));
4
+ register('@swc-node/register/esm', pathToFileURL('./'));
@@ -12,8 +12,5 @@
12
12
  "src/backend/typing"
13
13
  ],
14
14
  "exclude": [],
15
- "ts-node": {
16
- "swc": true
17
- },
18
15
  "references": []
19
16
  }
@@ -12,9 +12,6 @@
12
12
  "src/backend/typing"
13
13
  ],
14
14
  "exclude": [],
15
- "ts-node": {
16
- "swc": true
17
- },
18
15
  "references": [
19
16
  {
20
17
  "path": "packages-utils/compose"