@corva/create-app 0.121.0 → 0.122.0

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.
@@ -11,6 +11,8 @@ import { silentOption } from '../options/silent.js';
11
11
  import { ensureBumpVersion } from '../helpers/cli-version.js';
12
12
  import { ERROR_ICON } from '../constants/messages.js';
13
13
  import { appKeyOption } from '../options/app-key.js';
14
+ import { zipFileNameOption } from '../options/zip-file-name.js';
15
+ import { logger } from '../helpers/logger.js';
14
16
 
15
17
  export const releaseCommand = new Command('release')
16
18
  .description('Release app')
@@ -35,7 +37,7 @@ export const releaseCommand = new Command('release')
35
37
  'If package version is already taken - remove the previously published package and upload a new one',
36
38
  ).default(false),
37
39
  )
38
- // .addOption(new Option('--zip-file-name [string]', 'Prebuilt zip file name in dir'))
40
+ .addOption(zipFileNameOption)
39
41
  .addOption(new Option('--author [string]', 'Author name for the audit'))
40
42
  .action(async (dirName, patterns, options) => {
41
43
  // if author is present in CLI, save it to process.env
@@ -43,7 +45,20 @@ export const releaseCommand = new Command('release')
43
45
  process.env.githubUsername = options.author;
44
46
  }
45
47
 
46
- options.bumpVersion = await ensureBumpVersion(options.bumpVersion);
48
+ // Only the zip flow bumps the version, and a prebuilt archive skips it — nothing to prompt for.
49
+ if (options.zipFileName) {
50
+ if (options.bumpVersion && options.bumpVersion !== 'skip') {
51
+ logger.log(
52
+ `⚠️ ${chalk.yellow(
53
+ `--bump-version=${options.bumpVersion} is ignored with --zip-file-name: the version inside ${options.zipFileName} is used as is.`,
54
+ )}`,
55
+ );
56
+ }
57
+
58
+ options.bumpVersion = 'skip';
59
+ } else {
60
+ options.bumpVersion = await ensureBumpVersion(options.bumpVersion);
61
+ }
47
62
 
48
63
  await runFlow(RELEASE_FLOW, {
49
64
  dirName: getRealWorkingDir(dirName, options),
package/lib/flow.js CHANGED
@@ -29,6 +29,12 @@ export const runFlow = async (flow, context, indent = '') => {
29
29
 
30
30
  const runSteps = async (steps = [], context = {}, indent = '') => {
31
31
  for (const step of steps) {
32
+ if (typeof step.skip === 'function' && step.skip(context)) {
33
+ debug('Skipping %s', step.name || step.message);
34
+
35
+ continue;
36
+ }
37
+
32
38
  if (step.name) {
33
39
  const result = await runFlow(step, context, indent);
34
40
 
@@ -8,6 +8,7 @@ import { ADD_LABEL_STEP } from './steps/release/add-label.js';
8
8
  import { ADD_NOTES_STEP } from './steps/release/add-notes.js';
9
9
  import { PUBLISH_PACKAGE_STEP } from './steps/release/publish.js';
10
10
  import { RELEASE_PREPARE_DATA_STEP } from './steps/release/prepare-data.js';
11
+ import { RESOLVE_PREBUILT_ZIP_STEP } from './steps/release/resolve-prebuilt-zip.js';
11
12
 
12
13
  export const RELEASE_FLOW = {
13
14
  name: 'release',
@@ -15,6 +16,9 @@ export const RELEASE_FLOW = {
15
16
  PREPARE_FLOW,
16
17
  SETUP_API_CLIENT_STEP,
17
18
  RELEASE_PREPARE_DATA_STEP,
19
+ // With --zip-file-name the archive already exists, so the zip flow is skipped entirely. That
20
+ // also lets runtimes the zip flow has no file list for (e.g. `provided.*`) be released.
21
+ RESOLVE_PREBUILT_ZIP_STEP,
18
22
  ZIP_SIMPLE_FLOW,
19
23
  UPLOAD_ZIP_TO_CORVA_STEP,
20
24
  WAIT_FOR_BUILD_FINISH_STEP,
@@ -0,0 +1,35 @@
1
+ import { promises as fs } from 'node:fs';
2
+ import { resolve } from 'node:path';
3
+
4
+ import { StepError } from '../../lib/step-error.js';
5
+
6
+ /**
7
+ * Handles `--zip-file-name`: the caller has already built the package archive, so this records it
8
+ * as the archive to upload and marks the zip flow as a no-op.
9
+ */
10
+ export const RESOLVE_PREBUILT_ZIP_STEP = {
11
+ message: 'Resolving prebuilt archive...',
12
+ fn: async ({ dirName, options }) => {
13
+ const { zipFileName } = options;
14
+
15
+ if (!zipFileName) {
16
+ return {};
17
+ }
18
+
19
+ const zipPath = resolve(dirName, zipFileName);
20
+
21
+ try {
22
+ await fs.access(zipPath);
23
+ } catch {
24
+ throw new StepError(`Prebuilt archive ${zipFileName} not found in ${dirName}`);
25
+ }
26
+
27
+ return {
28
+ zipFileName,
29
+ skipZip: true,
30
+ // The archive belongs to the caller. Neither flag reaches the context today; this is defensive.
31
+ removeOnSuccess: false,
32
+ removeOnFail: false,
33
+ };
34
+ },
35
+ };
@@ -2,5 +2,7 @@ import { ZIP_STEPS } from './steps/zip.js';
2
2
 
3
3
  export const ZIP_SIMPLE_FLOW = {
4
4
  name: 'zip (simple)',
5
+ // Set by RESOLVE_PREBUILT_ZIP_STEP when --zip-file-name names an existing archive.
6
+ skip: ({ skipZip }) => Boolean(skipZip),
5
7
  steps: ZIP_STEPS,
6
8
  };
@@ -0,0 +1,18 @@
1
+ import { InvalidArgumentError, Option } from 'commander';
2
+
3
+ const flags = '--zip-file-name <string>';
4
+ const description =
5
+ 'Upload an already-built .zip from the project directory instead of zipping it here. ' +
6
+ 'The archive belongs to the caller and is never deleted after upload.';
7
+
8
+ // An unset CI variable arrives as `--zip-file-name=`, and commander 9 takes the next token as the
9
+ // value even when it is another flag — neither should pass for an archive name.
10
+ function argParser(value) {
11
+ if (typeof value !== 'string' || !value.trim() || value.startsWith('-')) {
12
+ throw new InvalidArgumentError('Expected a file name, e.g. --zip-file-name=package.zip.');
13
+ }
14
+
15
+ return value;
16
+ }
17
+
18
+ export const zipFileNameOption = new Option(flags, description).argParser(argParser);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@corva/create-app",
3
- "version": "0.121.0",
3
+ "version": "0.122.0",
4
4
  "private": false,
5
5
  "description": "Create an app to use it in CORVA.AI",
6
6
  "keywords": [