vona-cli-set-api 1.1.164 → 1.1.166

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
@@ -15,11 +15,11 @@ import { rollup } from 'rollup';
15
15
  import compileTemplate from 'lodash/template.js';
16
16
  import { createRequire } from 'node:module';
17
17
  import { pathToFileURL, fileURLToPath } from 'node:url';
18
- import { resolveTestRunId, TEST_RUN_ID_ENV, getTestAppName, resolveVonaLocalPaths, assertTestRunOwner, beanFullNameFromOnionName } from 'vona-core';
19
18
  import * as dotenv from '@cabloy/dotenv';
20
19
  import { getEnvFiles } from '@cabloy/dotenv';
21
20
  import { glob } from '@cabloy/module-glob';
22
21
  import os from 'node:os';
22
+ import { resolveTestRunId, TEST_RUN_ID_ENV, getTestAppName, requiresFreshTestResources, resolveVonaLocalPaths, assertTestRunOwner, beanFullNameFromOnionName } from 'vona-core';
23
23
  import chalk from 'chalk';
24
24
  import { spawn } from 'node:child_process';
25
25
  import nodemon from 'nodemon';
@@ -178,9 +178,29 @@ function resolveTemplatePath(file) {
178
178
  return fileURLToPath(url);
179
179
  }
180
180
 
181
+ function validateGenerationPaths(configMeta, configOptions) {
182
+ const strict = requiresFreshTestResources();
183
+ if (strict && configMeta.mode !== 'test') {
184
+ throw new Error('Strict generation requires test mode');
185
+ }
186
+ const paths = resolveVonaLocalPaths(configOptions.appDir, configMeta.mode);
187
+ if (strict && !paths.runId) {
188
+ throw new Error('Strict generation requires an isolated test run');
189
+ }
190
+ if (paths.runId) {
191
+ if (configOptions.runtimeDir !== paths.generatedDir) {
192
+ throw new Error('Isolated test generated directory does not match its run ID');
193
+ }
194
+ assertTestRunOwner(paths.dataRoot, paths.runId);
195
+ assertTestRunOwner(paths.generatedRoot, paths.runId);
196
+ }
197
+ return strict;
198
+ }
199
+
181
200
  // import { generateZod } from './generateZod.ts';
182
201
 
183
202
  async function generateEntryFiles(configMeta, configOptions, modulesMeta, env) {
203
+ const strict = validateGenerationPaths(configMeta, configOptions);
184
204
  // config
185
205
  await __generateConfig();
186
206
  // modules meta
@@ -265,7 +285,8 @@ async function generateEntryFiles(configMeta, configOptions, modulesMeta, env) {
265
285
  });
266
286
  }
267
287
  async function __generateEnvJson() {
268
- const contentDest = `export default ${JSON.stringify(env, null, 2)} as unknown as NodeJS.ProcessEnv;\n`;
288
+ // Strict generation retains the selected app.meta.env surface, never its resolved values.
289
+ const contentDest = strict ? `const keys = ${JSON.stringify(Object.keys(env).filter(key => env[key] !== undefined))};\nexport default Object.fromEntries(keys.filter(key => process.env[key] !== undefined).map(key => [key, process.env[key]])) as NodeJS.ProcessEnv;\n` : `export default ${JSON.stringify(env, null, 2)} as unknown as NodeJS.ProcessEnv;\n`;
269
290
  // output
270
291
  const fileDest = path.join(configOptions.appDir, configOptions.runtimeDir, 'env.ts');
271
292
  fse.ensureFileSync(fileDest);
@@ -274,14 +295,7 @@ async function generateEntryFiles(configMeta, configOptions, modulesMeta, env) {
274
295
  }
275
296
 
276
297
  async function generateVonaMeta(configMeta, configOptions) {
277
- const paths = resolveVonaLocalPaths(configOptions.appDir, configMeta.mode);
278
- if (paths.runId) {
279
- if (configOptions.runtimeDir !== paths.generatedDir) {
280
- throw new Error('Isolated test generated directory does not match its run ID');
281
- }
282
- assertTestRunOwner(paths.dataRoot, paths.runId);
283
- assertTestRunOwner(paths.generatedRoot, paths.runId);
284
- }
298
+ validateGenerationPaths(configMeta, configOptions);
285
299
  // config utils
286
300
  const configUtils = createConfigUtils(configMeta, configOptions);
287
301
  // env
@@ -833,7 +847,11 @@ class CliBinDev extends BeanCliBase {
833
847
  flavor,
834
848
  mode
835
849
  };
850
+ const strict = requiresFreshTestResources();
836
851
  const paths = resolveVonaLocalPaths(projectPath, mode);
852
+ if (strict && (mode !== 'test' || !paths.runId)) {
853
+ throw new Error('Strict generation requires an isolated test run in test mode');
854
+ }
837
855
  const configOptions = {
838
856
  appDir: projectPath,
839
857
  runtimeDir: paths.generatedDir,
@@ -841,10 +859,11 @@ class CliBinDev extends BeanCliBase {
841
859
  };
842
860
  try {
843
861
  const {
862
+ env,
844
863
  modulesMeta
845
864
  } = await generateVonaMeta(configMeta, configOptions);
846
865
  if (mode === 'test') {
847
- await this._runTest(projectPath);
866
+ if (strict) await this._runTest(projectPath, env);else await this._runTest(projectPath);
848
867
  } else {
849
868
  await this._run(projectPath, modulesMeta);
850
869
  }
@@ -852,11 +871,21 @@ class CliBinDev extends BeanCliBase {
852
871
  if (!paths.runId) await rimraf(paths.generatedRoot);
853
872
  }
854
873
  }
855
- async _runTest(projectPath) {
874
+ async _runTest(projectPath, resolvedEnv) {
875
+ const strict = requiresFreshTestResources();
876
+ if (strict && !resolvedEnv) {
877
+ throw new Error('Strict generation requires resolved environment handoff');
878
+ }
856
879
  const generatedDir = resolveVonaLocalPaths(projectPath, 'test').generatedDir;
857
880
  const child = spawn(process.execPath, [getImportEsm(generatedDir), `${generatedDir}/bootstrap.ts`], {
858
881
  cwd: projectPath,
859
- stdio: 'inherit'
882
+ stdio: 'inherit',
883
+ ...(strict ? {
884
+ env: {
885
+ ...process.env,
886
+ ...resolvedEnv
887
+ }
888
+ } : {})
860
889
  });
861
890
  const forwardSignal = signal => child.kill(signal);
862
891
  const onInterrupt = () => forwardSignal('SIGINT');
@@ -13,6 +13,6 @@ declare module '@cabloy/cli' {
13
13
  export declare class CliBinDev extends BeanCliBase {
14
14
  execute(): Promise<void>;
15
15
  _dev(projectPath: string): Promise<void>;
16
- _runTest(projectPath: string): Promise<void>;
16
+ _runTest(projectPath: string, resolvedEnv?: NodeJS.ProcessEnv): Promise<void>;
17
17
  _run(projectPath: string, _modulesMeta: Awaited<ReturnType<typeof glob>>): Promise<unknown>;
18
18
  }
@@ -0,0 +1,3 @@
1
+ import type { VonaConfigMeta } from '@cabloy/module-info';
2
+ import type { VonaBinConfigOptions } from './types.ts';
3
+ export declare function validateGenerationPaths(configMeta: VonaConfigMeta, configOptions: VonaBinConfigOptions): boolean;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "vona-cli-set-api",
3
- "version": "1.1.164",
4
- "gitHead": "d658b653ccdc3a1856d71a932ff7a2c005005293",
3
+ "version": "1.1.166",
4
+ "gitHead": "c703cb481fdf9d50a4f3eb3971e7b7c20a79619d",
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",
@@ -77,7 +77,7 @@
77
77
  "ts-node-maintained": "^10.9.6",
78
78
  "urllib": "^4.9.0",
79
79
  "uuid": "^11.1.0",
80
- "vona-core": "^5.1.48",
80
+ "vona-core": "^5.1.50",
81
81
  "why-is-node-running": "^3.2.2",
82
82
  "yargs-parser": "^22.0.0"
83
83
  }