@contrail/cli 3.7.0 → 3.8.0-alpha.30d4e88

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/README.md CHANGED
@@ -17,7 +17,7 @@ $ npm install -g @contrail/cli
17
17
  $ contrail COMMAND
18
18
  running command...
19
19
  $ contrail (--version)
20
- @contrail/cli/3.7.0 linux-x64 node-v24.22.2
20
+ @contrail/cli/3.8.0-alpha.30d4e88 linux-x64 node-v24.22.3
21
21
  $ contrail --help [COMMAND]
22
22
  USAGE
23
23
  $ contrail COMMAND
@@ -45,6 +45,10 @@ To get instructions on how to set up autocomplete for your shell, run `contrail
45
45
  * [`contrail app version major`](#contrail-app-version-major)
46
46
  * [`contrail app version minor`](#contrail-app-version-minor)
47
47
  * [`contrail app version patch`](#contrail-app-version-patch)
48
+ * [`contrail app version premajor`](#contrail-app-version-premajor)
49
+ * [`contrail app version preminor`](#contrail-app-version-preminor)
50
+ * [`contrail app version prepatch`](#contrail-app-version-prepatch)
51
+ * [`contrail app version prerelease`](#contrail-app-version-prerelease)
48
52
  * [`contrail autocomplete [SHELL]`](#contrail-autocomplete-shell)
49
53
  * [`contrail config create`](#contrail-config-create)
50
54
  * [`contrail config describe [NAME]`](#contrail-config-describe-name)
@@ -264,7 +268,7 @@ EXAMPLES
264
268
 
265
269
  ## `contrail app publish`
266
270
 
267
- Publish the app to the marketplace. This visibility of your app depends on the app.yml configuration ("visibility" property)
271
+ Publish the app to the marketplace. This visibility of your app depends on the app.yml configuration ("visibility" property). A pre-release version (e.g. "1.4.0-alpha.1") is published without becoming the latest version of the app.
268
272
 
269
273
  ```
270
274
  USAGE
@@ -282,7 +286,7 @@ FLAGS
282
286
 
283
287
  DESCRIPTION
284
288
  Publish the app to the marketplace. This visibility of your app depends on the app.yml configuration ("visibility"
285
- property)
289
+ property). A pre-release version (e.g. "1.4.0-alpha.1") is published without becoming the latest version of the app.
286
290
 
287
291
  EXAMPLES
288
292
  $ contrail app publish
@@ -397,6 +401,91 @@ EXAMPLES
397
401
  $ contrail app version patch
398
402
  ```
399
403
 
404
+ ## `contrail app version premajor`
405
+
406
+ Start an alpha pre-release of the next major app version (1.2.3 to 2.0.0-alpha.0).
407
+
408
+ ```
409
+ USAGE
410
+ $ contrail app version premajor [-l error|warn|info|debug] [-e true|false]
411
+
412
+ FLAGS
413
+ -e, --alwaysConfirmEnv=<option> [default: true] The Environment variables
414
+ <options: true|false>
415
+ -l, --logLevel=<option> The Log Level
416
+ <options: error|warn|info|debug>
417
+
418
+ DESCRIPTION
419
+ Start an alpha pre-release of the next major app version (1.2.3 to 2.0.0-alpha.0).
420
+
421
+ EXAMPLES
422
+ $ contrail app version premajor
423
+ ```
424
+
425
+ ## `contrail app version preminor`
426
+
427
+ Start an alpha pre-release of the next minor app version (1.2.3 to 1.3.0-alpha.0).
428
+
429
+ ```
430
+ USAGE
431
+ $ contrail app version preminor [-l error|warn|info|debug] [-e true|false]
432
+
433
+ FLAGS
434
+ -e, --alwaysConfirmEnv=<option> [default: true] The Environment variables
435
+ <options: true|false>
436
+ -l, --logLevel=<option> The Log Level
437
+ <options: error|warn|info|debug>
438
+
439
+ DESCRIPTION
440
+ Start an alpha pre-release of the next minor app version (1.2.3 to 1.3.0-alpha.0).
441
+
442
+ EXAMPLES
443
+ $ contrail app version preminor
444
+ ```
445
+
446
+ ## `contrail app version prepatch`
447
+
448
+ Start an alpha pre-release of the next patch app version (1.2.3 to 1.2.4-alpha.0).
449
+
450
+ ```
451
+ USAGE
452
+ $ contrail app version prepatch [-l error|warn|info|debug] [-e true|false]
453
+
454
+ FLAGS
455
+ -e, --alwaysConfirmEnv=<option> [default: true] The Environment variables
456
+ <options: true|false>
457
+ -l, --logLevel=<option> The Log Level
458
+ <options: error|warn|info|debug>
459
+
460
+ DESCRIPTION
461
+ Start an alpha pre-release of the next patch app version (1.2.3 to 1.2.4-alpha.0).
462
+
463
+ EXAMPLES
464
+ $ contrail app version prepatch
465
+ ```
466
+
467
+ ## `contrail app version prerelease`
468
+
469
+ Upgrade the Pre-release app version. A stable version becomes the first alpha of the next patch (1.2.3 to 1.2.4-alpha.0). A pre-release version gets its number bumped (1.2.4-alpha.0 to 1.2.4-alpha.1).
470
+
471
+ ```
472
+ USAGE
473
+ $ contrail app version prerelease [-l error|warn|info|debug] [-e true|false]
474
+
475
+ FLAGS
476
+ -e, --alwaysConfirmEnv=<option> [default: true] The Environment variables
477
+ <options: true|false>
478
+ -l, --logLevel=<option> The Log Level
479
+ <options: error|warn|info|debug>
480
+
481
+ DESCRIPTION
482
+ Upgrade the Pre-release app version. A stable version becomes the first alpha of the next patch (1.2.3 to
483
+ 1.2.4-alpha.0). A pre-release version gets its number bumped (1.2.4-alpha.0 to 1.2.4-alpha.1).
484
+
485
+ EXAMPLES
486
+ $ contrail app version prerelease
487
+ ```
488
+
400
489
  ## `contrail autocomplete [SHELL]`
401
490
 
402
491
  display autocomplete installation instructions
@@ -11,7 +11,7 @@ const upgrade_1 = require("./upgrade");
11
11
  const basecommand_1 = require("../../basecommand");
12
12
  const logger_1 = tslib_1.__importDefault(require("../../logger"));
13
13
  class PublishApp extends basecommand_1.BaseCommand {
14
- static description = 'Publish the app to the marketplace. This visibility of your app depends on the app.yml configuration ("visibility" property)';
14
+ static description = 'Publish the app to the marketplace. This visibility of your app depends on the app.yml configuration ("visibility" property). A pre-release version (e.g. "1.4.0-alpha.1") is published without becoming the latest version of the app.';
15
15
  static examples = [
16
16
  `$ contrail app publish
17
17
  `,
@@ -0,0 +1,11 @@
1
+ import { BaseCommand } from '../../../basecommand';
2
+ export default class AppPremajorVersionUpgrade extends BaseCommand {
3
+ skipConfirmEnv: boolean;
4
+ static description: string;
5
+ static examples: string[];
6
+ static flags: {
7
+ alwaysConfirmEnv: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
8
+ logLevel: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
9
+ };
10
+ run(): Promise<void>;
11
+ }
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ const load_app_config_1 = require("../../../helpers/app/load-app-config");
5
+ const basecommand_1 = require("../../../basecommand");
6
+ const logger_1 = tslib_1.__importDefault(require("../../../logger"));
7
+ const update_app_config_1 = require("../../../helpers/app/update-app-config");
8
+ const upgrade_version_1 = require("../../../helpers/app/upgrade-version");
9
+ class AppPremajorVersionUpgrade extends basecommand_1.BaseCommand {
10
+ skipConfirmEnv = true;
11
+ static description = 'Start an alpha pre-release of the next major app version (1.2.3 to 2.0.0-alpha.0).';
12
+ static examples = [
13
+ `$ contrail app version premajor
14
+ `,
15
+ ];
16
+ static flags = {
17
+ ...basecommand_1.BaseCommand.baseFlags,
18
+ };
19
+ async run() {
20
+ try {
21
+ const appDeclaration = (0, load_app_config_1.loadAppConfig)({ skipValidation: true });
22
+ logger_1.default.info(`Upgrading Pre-major Version for ${appDeclaration.version}`);
23
+ const version = (0, upgrade_version_1.upgradeVersion)(appDeclaration.version, 'premajor');
24
+ (0, update_app_config_1.updateAppConfig)({ ...appDeclaration, version });
25
+ logger_1.default.info(`Pre-major Version Upgraded to ${version}`);
26
+ }
27
+ catch (e) {
28
+ logger_1.default.error(`Application Pre-major Version Upgrade Failed: ${e}`);
29
+ }
30
+ }
31
+ }
32
+ exports.default = AppPremajorVersionUpgrade;
@@ -0,0 +1,11 @@
1
+ import { BaseCommand } from '../../../basecommand';
2
+ export default class AppPreminorVersionUpgrade extends BaseCommand {
3
+ skipConfirmEnv: boolean;
4
+ static description: string;
5
+ static examples: string[];
6
+ static flags: {
7
+ alwaysConfirmEnv: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
8
+ logLevel: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
9
+ };
10
+ run(): Promise<void>;
11
+ }
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ const load_app_config_1 = require("../../../helpers/app/load-app-config");
5
+ const basecommand_1 = require("../../../basecommand");
6
+ const logger_1 = tslib_1.__importDefault(require("../../../logger"));
7
+ const update_app_config_1 = require("../../../helpers/app/update-app-config");
8
+ const upgrade_version_1 = require("../../../helpers/app/upgrade-version");
9
+ class AppPreminorVersionUpgrade extends basecommand_1.BaseCommand {
10
+ skipConfirmEnv = true;
11
+ static description = 'Start an alpha pre-release of the next minor app version (1.2.3 to 1.3.0-alpha.0).';
12
+ static examples = [
13
+ `$ contrail app version preminor
14
+ `,
15
+ ];
16
+ static flags = {
17
+ ...basecommand_1.BaseCommand.baseFlags,
18
+ };
19
+ async run() {
20
+ try {
21
+ const appDeclaration = (0, load_app_config_1.loadAppConfig)({ skipValidation: true });
22
+ logger_1.default.info(`Upgrading Pre-minor Version for ${appDeclaration.version}`);
23
+ const version = (0, upgrade_version_1.upgradeVersion)(appDeclaration.version, 'preminor');
24
+ (0, update_app_config_1.updateAppConfig)({ ...appDeclaration, version });
25
+ logger_1.default.info(`Pre-minor Version Upgraded to ${version}`);
26
+ }
27
+ catch (e) {
28
+ logger_1.default.error(`Application Pre-minor Version Upgrade Failed: ${e}`);
29
+ }
30
+ }
31
+ }
32
+ exports.default = AppPreminorVersionUpgrade;
@@ -0,0 +1,11 @@
1
+ import { BaseCommand } from '../../../basecommand';
2
+ export default class AppPrepatchVersionUpgrade extends BaseCommand {
3
+ skipConfirmEnv: boolean;
4
+ static description: string;
5
+ static examples: string[];
6
+ static flags: {
7
+ alwaysConfirmEnv: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
8
+ logLevel: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
9
+ };
10
+ run(): Promise<void>;
11
+ }
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ const load_app_config_1 = require("../../../helpers/app/load-app-config");
5
+ const basecommand_1 = require("../../../basecommand");
6
+ const logger_1 = tslib_1.__importDefault(require("../../../logger"));
7
+ const update_app_config_1 = require("../../../helpers/app/update-app-config");
8
+ const upgrade_version_1 = require("../../../helpers/app/upgrade-version");
9
+ class AppPrepatchVersionUpgrade extends basecommand_1.BaseCommand {
10
+ skipConfirmEnv = true;
11
+ static description = 'Start an alpha pre-release of the next patch app version (1.2.3 to 1.2.4-alpha.0).';
12
+ static examples = [
13
+ `$ contrail app version prepatch
14
+ `,
15
+ ];
16
+ static flags = {
17
+ ...basecommand_1.BaseCommand.baseFlags,
18
+ };
19
+ async run() {
20
+ try {
21
+ const appDeclaration = (0, load_app_config_1.loadAppConfig)({ skipValidation: true });
22
+ logger_1.default.info(`Upgrading Pre-patch Version for ${appDeclaration.version}`);
23
+ const version = (0, upgrade_version_1.upgradeVersion)(appDeclaration.version, 'prepatch');
24
+ (0, update_app_config_1.updateAppConfig)({ ...appDeclaration, version });
25
+ logger_1.default.info(`Pre-patch Version Upgraded to ${version}`);
26
+ }
27
+ catch (e) {
28
+ logger_1.default.error(`Application Pre-patch Version Upgrade Failed: ${e}`);
29
+ }
30
+ }
31
+ }
32
+ exports.default = AppPrepatchVersionUpgrade;
@@ -0,0 +1,11 @@
1
+ import { BaseCommand } from '../../../basecommand';
2
+ export default class AppPrereleaseVersionUpgrade extends BaseCommand {
3
+ skipConfirmEnv: boolean;
4
+ static description: string;
5
+ static examples: string[];
6
+ static flags: {
7
+ alwaysConfirmEnv: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
8
+ logLevel: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
9
+ };
10
+ run(): Promise<void>;
11
+ }
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ const load_app_config_1 = require("../../../helpers/app/load-app-config");
5
+ const basecommand_1 = require("../../../basecommand");
6
+ const logger_1 = tslib_1.__importDefault(require("../../../logger"));
7
+ const update_app_config_1 = require("../../../helpers/app/update-app-config");
8
+ const upgrade_version_1 = require("../../../helpers/app/upgrade-version");
9
+ class AppPrereleaseVersionUpgrade extends basecommand_1.BaseCommand {
10
+ skipConfirmEnv = true;
11
+ static description = 'Upgrade the Pre-release app version. A stable version becomes the first alpha of the next patch (1.2.3 to 1.2.4-alpha.0). A pre-release version gets its number bumped (1.2.4-alpha.0 to 1.2.4-alpha.1).';
12
+ static examples = [
13
+ `$ contrail app version prerelease
14
+ `,
15
+ ];
16
+ static flags = {
17
+ ...basecommand_1.BaseCommand.baseFlags,
18
+ };
19
+ async run() {
20
+ try {
21
+ const appDeclaration = (0, load_app_config_1.loadAppConfig)({ skipValidation: true });
22
+ logger_1.default.info(`Upgrading Pre-release Version for ${appDeclaration.version}`);
23
+ const version = (0, upgrade_version_1.upgradeVersion)(appDeclaration.version, 'prerelease');
24
+ (0, update_app_config_1.updateAppConfig)({ ...appDeclaration, version });
25
+ logger_1.default.info(`Pre-release Version Upgraded to ${version}`);
26
+ }
27
+ catch (e) {
28
+ logger_1.default.error(`Application Pre-release Version Upgrade Failed: ${e}`);
29
+ }
30
+ }
31
+ }
32
+ exports.default = AppPrereleaseVersionUpgrade;
@@ -2,13 +2,14 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.validateAccessGrants = exports.visibilityValidator = exports.appVersionValidator = exports.validateAppConfig = exports.ERROR_MESSAGES = void 0;
4
4
  const tslib_1 = require("tslib");
5
+ const semver_1 = tslib_1.__importDefault(require("semver"));
5
6
  const interfaces_1 = require("../../interfaces");
6
7
  const logger_1 = tslib_1.__importDefault(require("../../logger"));
7
8
  const VALIDATORS = [appVersionValidator, visibilityValidator, validateAccessGrants];
8
9
  exports.ERROR_MESSAGES = {
9
- missingVersionField: 'Missing "version" field". Semantic App Version looks like "1.0.0". Use "contrail app version [patch|minor|major]" to update the app version.',
10
+ missingVersionField: 'Missing "version" field". Semantic App Version looks like "1.0.0". Use "contrail app version [patch|minor|major|prerelease]" to update the app version.',
10
11
  invalidVersionField: '"version" field is not a string. Expecting a version like "1.0.0". Manually update the "version" field to be a string in the app.yml file.',
11
- invalidAppVersion: 'Invalid app version. Semantic App Version looks like "1.0.0". Use "contrail app version [patch|minor|major]" to update the app version.',
12
+ invalidAppVersion: 'Invalid app version. Semantic App Version looks like "1.0.0", or "1.0.0-alpha.1" for a pre-release. Use "contrail app version [patch|minor|major|prerelease]" to update the app version.',
12
13
  accessGrantsArray: 'accessGrants must be an array.',
13
14
  invalidOrgSlug: 'Invalid or missing orgSlug in one of the accessGrants objects.',
14
15
  emptyPermissionsArray: 'Permissions must be a non-empty array in one of the accessGrants objects.',
@@ -45,8 +46,7 @@ function appVersionValidator(appDeclaration) {
45
46
  errors.push(exports.ERROR_MESSAGES.invalidVersionField);
46
47
  return { errors, warnings };
47
48
  }
48
- const parts = appDeclaration.version.split('.');
49
- if (parts.length !== 3) {
49
+ if (semver_1.default.valid(appDeclaration.version) !== appDeclaration.version) {
50
50
  errors.push(exports.ERROR_MESSAGES.invalidAppVersion);
51
51
  }
52
52
  return { errors, warnings };
@@ -33,6 +33,35 @@ describe('appVersionValidator', () => {
33
33
  const validationResult = (0, app_config_validators_1.appVersionValidator)(appDeclaration);
34
34
  expect(validationResult).toEqual(validResult);
35
35
  });
36
+ it('should not return an error if app version is a pre-release', () => {
37
+ const appDeclaration = {
38
+ version: '1.4.0-alpha.1',
39
+ };
40
+ const validationResult = (0, app_config_validators_1.appVersionValidator)(appDeclaration);
41
+ expect(validationResult).toEqual(validResult);
42
+ });
43
+ it('should return an error if app version has build metadata', () => {
44
+ const appDeclaration = {
45
+ version: '1.4.0+build123',
46
+ };
47
+ const expectedError = {
48
+ errors: [app_config_validators_1.ERROR_MESSAGES.invalidAppVersion],
49
+ warnings: [],
50
+ };
51
+ const validationResult = (0, app_config_validators_1.appVersionValidator)(appDeclaration);
52
+ expect(validationResult).toEqual(expectedError);
53
+ });
54
+ it('should return an error if a version part is not a number', () => {
55
+ const appDeclaration = {
56
+ version: '1.0.x',
57
+ };
58
+ const expectedError = {
59
+ errors: [app_config_validators_1.ERROR_MESSAGES.invalidAppVersion],
60
+ warnings: [],
61
+ };
62
+ const validationResult = (0, app_config_validators_1.appVersionValidator)(appDeclaration);
63
+ expect(validationResult).toEqual(expectedError);
64
+ });
36
65
  it('should gracefully handle bad versions', () => {
37
66
  const appDeclaration = {
38
67
  version: '1',
@@ -7,6 +7,7 @@ export declare class AppDeployer {
7
7
  getExistingApp(appDeclaration: AppDeclaration): Promise<App>;
8
8
  private createNewApp;
9
9
  updateExistingApp(appDeclaration: AppDeclaration, existingApp: any): Promise<App>;
10
+ private publishPrereleaseVersion;
10
11
  remove(appDeclaration: AppDeclaration): Promise<void>;
11
12
  }
12
13
  export declare function createNodePackage(appIdentifier: string, debug: boolean, dryRun: boolean): Promise<AppCodePackage>;
@@ -15,6 +15,7 @@ const child_process_1 = tslib_1.__importDefault(require("child_process"));
15
15
  const fs_1 = tslib_1.__importDefault(require("fs"));
16
16
  const extensions_deployer_1 = require("./extensions-deployer");
17
17
  const metadata_extractor_1 = require("./metadata-extractor");
18
+ const semver_1 = tslib_1.__importDefault(require("semver"));
18
19
  class AppDeployer {
19
20
  debug;
20
21
  dryRun;
@@ -29,6 +30,10 @@ class AppDeployer {
29
30
  logger_1.default.info(`${chalk_1.default.yellow.bold('APP')} Creating new app.`);
30
31
  app = await this.createNewApp(appDeclaration);
31
32
  }
33
+ else if (semver_1.default.prerelease(appDeclaration.version)) {
34
+ logger_1.default.info(`${chalk_1.default.yellow.bold('APP')} Publishing pre-release version.`);
35
+ app = await this.publishPrereleaseVersion(appDeclaration, app);
36
+ }
32
37
  else {
33
38
  logger_1.default.info(`${chalk_1.default.yellow.bold('APP')} Updating existing app.`);
34
39
  app = await this.updateExistingApp(appDeclaration, app);
@@ -146,6 +151,36 @@ class AppDeployer {
146
151
  logger_1.default.info(`${chalk_1.default.yellow.bold('APP')} Updated app: ${app.name}`);
147
152
  return app;
148
153
  }
154
+ async publishPrereleaseVersion(appDeclaration, existingApp) {
155
+ const externalLinks = appDeclaration.externalLinks
156
+ ? app_template_parsers_1.ExternalLinkParser.validateAndGetExternalLinks(appDeclaration.externalLinks)
157
+ : [];
158
+ const appCodePackage = await createNodePackage(appDeclaration.appIdentifier, this.debug, this.dryRun);
159
+ if (this.dryRun) {
160
+ logger_1.default.info('Dry run, not creating app version');
161
+ return {};
162
+ }
163
+ const appVersion = await new sdk_1.Entities().create({
164
+ entityName: 'app-version',
165
+ object: {
166
+ appId: existingApp.id,
167
+ semver: appDeclaration.version,
168
+ eventWorkflowTriggerKeyMapping: appDeclaration.eventWorkflowTriggerKeyMapping,
169
+ configProperties: appDeclaration.appConfiguration
170
+ ? app_template_parsers_1.ConfigPropertiesParser.getConfigProperties(appDeclaration.appConfiguration)
171
+ : undefined,
172
+ triggerKeyDefinitions: appDeclaration.triggers
173
+ ? app_template_parsers_1.TriggerKeyDefinitionParser.buildTriggersArray(appDeclaration)
174
+ : undefined,
175
+ externalLinks,
176
+ appCodePackageId: appCodePackage.id,
177
+ frameworkVersion: 2,
178
+ nodeRuntime: appDeclaration.nodeRuntime ?? existingApp.nodeRuntime,
179
+ },
180
+ });
181
+ logger_1.default.info(`${chalk_1.default.yellow.bold('APP')} Published pre-release version: ${appVersion.semver}`);
182
+ return { ...existingApp, latestAppVersionId: appVersion.id };
183
+ }
149
184
  async remove(appDeclaration) {
150
185
  let app = await this.getExistingApp(appDeclaration);
151
186
  if (app) {
@@ -53,7 +53,10 @@ class ExternalLinkParser {
53
53
  }
54
54
  for (const link of externalLinks) {
55
55
  if (!link.name || typeof link.name !== 'string') {
56
- throw new Error('externalLinks must have a url property (string)');
56
+ throw new Error('externalLinks must have a name property (string)');
57
+ }
58
+ if (!link.label || typeof link.label !== 'string') {
59
+ throw new Error('externalLinks must have a label property (string)');
57
60
  }
58
61
  if (!link.link || typeof link.link !== 'string') {
59
62
  throw new Error('externalLinks must have a link property (string)');
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const app_template_parsers_1 = require("./app-template-parsers");
4
+ describe('ExternalLinkParser', () => {
5
+ const externalLink = { name: 'docs', label: 'Docs', link: 'https://example.com' };
6
+ it('should return the external links when each has a name, label and link', () => {
7
+ expect(app_template_parsers_1.ExternalLinkParser.validateAndGetExternalLinks([externalLink])).toEqual([externalLink]);
8
+ });
9
+ it('should throw if an external link has no label', () => {
10
+ expect(() => app_template_parsers_1.ExternalLinkParser.validateAndGetExternalLinks([{ ...externalLink, label: undefined }])).toThrow('externalLinks must have a label property (string)');
11
+ });
12
+ it('should throw if an external link has no name', () => {
13
+ expect(() => app_template_parsers_1.ExternalLinkParser.validateAndGetExternalLinks([{ ...externalLink, name: undefined }])).toThrow('externalLinks must have a name property (string)');
14
+ });
15
+ });
@@ -3,7 +3,13 @@ import semver from 'semver';
3
3
  * Upgrades a semantic version based on a specified release type.
4
4
  *
5
5
  * @param {string} currentVersion - The current semantic version string.
6
- * @param {semver.ReleaseType} type - The type of release ('major', 'minor', 'patch').
6
+ * @param {semver.ReleaseType} type - The type of release ('major', 'minor', 'patch', 'premajor',
7
+ * 'preminor', 'prepatch', 'prerelease').
8
+ * 'prerelease' starts an alpha (1.2.3 becomes 1.2.4-alpha.0) or bumps the existing pre-release tag
9
+ * (1.2.4-alpha.0 becomes 1.2.4-alpha.1).
10
+ * 'premajor', 'preminor' and 'prepatch' always start the first alpha of the next major, minor or
11
+ * patch version (1.2.3 becomes 2.0.0-alpha.0, 1.3.0-alpha.0 or 1.2.4-alpha.0). The results match
12
+ * `npm version <type> --preid=alpha`.
7
13
  * @returns {string} The upgraded semantic version.
8
14
  * @throws {Error} If the provided currentVersion is not a valid semantic version.
9
15
  *
@@ -7,7 +7,13 @@ const semver_1 = tslib_1.__importDefault(require("semver"));
7
7
  * Upgrades a semantic version based on a specified release type.
8
8
  *
9
9
  * @param {string} currentVersion - The current semantic version string.
10
- * @param {semver.ReleaseType} type - The type of release ('major', 'minor', 'patch').
10
+ * @param {semver.ReleaseType} type - The type of release ('major', 'minor', 'patch', 'premajor',
11
+ * 'preminor', 'prepatch', 'prerelease').
12
+ * 'prerelease' starts an alpha (1.2.3 becomes 1.2.4-alpha.0) or bumps the existing pre-release tag
13
+ * (1.2.4-alpha.0 becomes 1.2.4-alpha.1).
14
+ * 'premajor', 'preminor' and 'prepatch' always start the first alpha of the next major, minor or
15
+ * patch version (1.2.3 becomes 2.0.0-alpha.0, 1.3.0-alpha.0 or 1.2.4-alpha.0). The results match
16
+ * `npm version <type> --preid=alpha`.
11
17
  * @returns {string} The upgraded semantic version.
12
18
  * @throws {Error} If the provided currentVersion is not a valid semantic version.
13
19
  *
@@ -19,16 +25,13 @@ const semver_1 = tslib_1.__importDefault(require("semver"));
19
25
  */
20
26
  function upgradeVersion(currentVersion, type) {
21
27
  try {
22
- const paddedVersion = currentVersion
23
- .toString()
24
- .split('.')
25
- .concat(new Array(3).fill(0).map(String))
26
- .slice(0, 3)
27
- .join('.');
28
+ const version = currentVersion.toString();
29
+ const paddedVersion = semver_1.default.valid(version) ??
30
+ version.split('.').concat(new Array(3).fill(0).map(String)).slice(0, 3).join('.');
28
31
  if (!semver_1.default.valid(paddedVersion)) {
29
32
  throw new Error('Invalid version string');
30
33
  }
31
- return semver_1.default.inc(paddedVersion, type);
34
+ return semver_1.default.inc(paddedVersion, type, type === 'prerelease' && semver_1.default.prerelease(paddedVersion) ? undefined : 'alpha');
32
35
  }
33
36
  catch (e) {
34
37
  throw new Error(`ERROR PARSING YAML: ${e}`);
@@ -25,6 +25,32 @@ describe('upgradeVersion', () => {
25
25
  const expectedVersion = semver_1.default.inc(currentVersion, releaseType);
26
26
  expect(upgradedVersion).toBe(expectedVersion);
27
27
  });
28
+ it('should start an alpha pre-release of the next patch from a stable version', () => {
29
+ expect((0, upgrade_version_1.upgradeVersion)('1.3.0', 'prerelease')).toBe('1.3.1-alpha.0');
30
+ });
31
+ it('should bump the number of an existing pre-release', () => {
32
+ expect((0, upgrade_version_1.upgradeVersion)('1.4.0-alpha.1', 'prerelease')).toBe('1.4.0-alpha.2');
33
+ });
34
+ it('should keep the existing pre-release tag when it is not alpha', () => {
35
+ expect((0, upgrade_version_1.upgradeVersion)('1.4.0-beta.1', 'prerelease')).toBe('1.4.0-beta.2');
36
+ });
37
+ it.each([
38
+ ['premajor', '1.2.3', '2.0.0-alpha.0'],
39
+ ['preminor', '1.2.3', '1.3.0-alpha.0'],
40
+ ['prepatch', '1.2.3', '1.2.4-alpha.0'],
41
+ ['premajor', '1.2.4-alpha.1', '2.0.0-alpha.0'],
42
+ ['preminor', '1.2.4-alpha.1', '1.3.0-alpha.0'],
43
+ ['prepatch', '1.2.4-alpha.1', '1.2.5-alpha.0'],
44
+ ['premajor', '2.0.0-beta.1', '3.0.0-alpha.0'],
45
+ ])('should apply %s to %s the way npm version does', (type, current, expected) => {
46
+ expect((0, upgrade_version_1.upgradeVersion)(current, type)).toBe(expected);
47
+ });
48
+ it('should pad a short version before upgrading it', () => {
49
+ expect((0, upgrade_version_1.upgradeVersion)('1.2', 'patch')).toBe('1.2.1');
50
+ });
51
+ it('should upgrade a pre-release to its stable version', () => {
52
+ expect((0, upgrade_version_1.upgradeVersion)('1.4.0-alpha.1', 'patch')).toBe('1.4.0');
53
+ });
28
54
  it('should throw an error for an invalid semantic version input', () => {
29
55
  const currentVersion = 'invalidVersion';
30
56
  const releaseType = 'patch';
@@ -151,6 +151,7 @@ export interface App {
151
151
  configProperties?: ConfigProperty[];
152
152
  triggerKeyDefinitions?: TriggerKeyDefinition[];
153
153
  latestAppVersionId?: string;
154
+ nodeRuntime?: NodeRuntime;
154
155
  }
155
156
  export interface AppOrg {
156
157
  id: string;
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "3.7.0",
2
+ "version": "3.8.0-alpha.30d4e88",
3
3
  "commands": {
4
4
  "login": {
5
5
  "id": "login",
@@ -286,7 +286,7 @@
286
286
  },
287
287
  "app:publish": {
288
288
  "id": "app:publish",
289
- "description": "Publish the app to the marketplace. This visibility of your app depends on the app.yml configuration (\"visibility\" property)",
289
+ "description": "Publish the app to the marketplace. This visibility of your app depends on the app.yml configuration (\"visibility\" property). A pre-release version (e.g. \"1.4.0-alpha.1\") is published without becoming the latest version of the app.",
290
290
  "strict": true,
291
291
  "pluginName": "@contrail/cli",
292
292
  "pluginAlias": "@contrail/cli",
@@ -4009,6 +4009,174 @@
4009
4009
  },
4010
4010
  "args": {}
4011
4011
  },
4012
+ "app:version:premajor": {
4013
+ "id": "app:version:premajor",
4014
+ "description": "Start an alpha pre-release of the next major app version (1.2.3 to 2.0.0-alpha.0).",
4015
+ "strict": true,
4016
+ "pluginName": "@contrail/cli",
4017
+ "pluginAlias": "@contrail/cli",
4018
+ "pluginType": "core",
4019
+ "aliases": [],
4020
+ "examples": [
4021
+ "$ contrail app version premajor\n"
4022
+ ],
4023
+ "flags": {
4024
+ "logLevel": {
4025
+ "name": "logLevel",
4026
+ "type": "option",
4027
+ "char": "l",
4028
+ "description": "The Log Level",
4029
+ "required": false,
4030
+ "multiple": false,
4031
+ "options": [
4032
+ "error",
4033
+ "warn",
4034
+ "info",
4035
+ "debug"
4036
+ ]
4037
+ },
4038
+ "alwaysConfirmEnv": {
4039
+ "name": "alwaysConfirmEnv",
4040
+ "type": "option",
4041
+ "char": "e",
4042
+ "description": "The Environment variables",
4043
+ "required": false,
4044
+ "multiple": false,
4045
+ "options": [
4046
+ "true",
4047
+ "false"
4048
+ ],
4049
+ "default": "true"
4050
+ }
4051
+ },
4052
+ "args": {}
4053
+ },
4054
+ "app:version:preminor": {
4055
+ "id": "app:version:preminor",
4056
+ "description": "Start an alpha pre-release of the next minor app version (1.2.3 to 1.3.0-alpha.0).",
4057
+ "strict": true,
4058
+ "pluginName": "@contrail/cli",
4059
+ "pluginAlias": "@contrail/cli",
4060
+ "pluginType": "core",
4061
+ "aliases": [],
4062
+ "examples": [
4063
+ "$ contrail app version preminor\n"
4064
+ ],
4065
+ "flags": {
4066
+ "logLevel": {
4067
+ "name": "logLevel",
4068
+ "type": "option",
4069
+ "char": "l",
4070
+ "description": "The Log Level",
4071
+ "required": false,
4072
+ "multiple": false,
4073
+ "options": [
4074
+ "error",
4075
+ "warn",
4076
+ "info",
4077
+ "debug"
4078
+ ]
4079
+ },
4080
+ "alwaysConfirmEnv": {
4081
+ "name": "alwaysConfirmEnv",
4082
+ "type": "option",
4083
+ "char": "e",
4084
+ "description": "The Environment variables",
4085
+ "required": false,
4086
+ "multiple": false,
4087
+ "options": [
4088
+ "true",
4089
+ "false"
4090
+ ],
4091
+ "default": "true"
4092
+ }
4093
+ },
4094
+ "args": {}
4095
+ },
4096
+ "app:version:prepatch": {
4097
+ "id": "app:version:prepatch",
4098
+ "description": "Start an alpha pre-release of the next patch app version (1.2.3 to 1.2.4-alpha.0).",
4099
+ "strict": true,
4100
+ "pluginName": "@contrail/cli",
4101
+ "pluginAlias": "@contrail/cli",
4102
+ "pluginType": "core",
4103
+ "aliases": [],
4104
+ "examples": [
4105
+ "$ contrail app version prepatch\n"
4106
+ ],
4107
+ "flags": {
4108
+ "logLevel": {
4109
+ "name": "logLevel",
4110
+ "type": "option",
4111
+ "char": "l",
4112
+ "description": "The Log Level",
4113
+ "required": false,
4114
+ "multiple": false,
4115
+ "options": [
4116
+ "error",
4117
+ "warn",
4118
+ "info",
4119
+ "debug"
4120
+ ]
4121
+ },
4122
+ "alwaysConfirmEnv": {
4123
+ "name": "alwaysConfirmEnv",
4124
+ "type": "option",
4125
+ "char": "e",
4126
+ "description": "The Environment variables",
4127
+ "required": false,
4128
+ "multiple": false,
4129
+ "options": [
4130
+ "true",
4131
+ "false"
4132
+ ],
4133
+ "default": "true"
4134
+ }
4135
+ },
4136
+ "args": {}
4137
+ },
4138
+ "app:version:prerelease": {
4139
+ "id": "app:version:prerelease",
4140
+ "description": "Upgrade the Pre-release app version. A stable version becomes the first alpha of the next patch (1.2.3 to 1.2.4-alpha.0). A pre-release version gets its number bumped (1.2.4-alpha.0 to 1.2.4-alpha.1).",
4141
+ "strict": true,
4142
+ "pluginName": "@contrail/cli",
4143
+ "pluginAlias": "@contrail/cli",
4144
+ "pluginType": "core",
4145
+ "aliases": [],
4146
+ "examples": [
4147
+ "$ contrail app version prerelease\n"
4148
+ ],
4149
+ "flags": {
4150
+ "logLevel": {
4151
+ "name": "logLevel",
4152
+ "type": "option",
4153
+ "char": "l",
4154
+ "description": "The Log Level",
4155
+ "required": false,
4156
+ "multiple": false,
4157
+ "options": [
4158
+ "error",
4159
+ "warn",
4160
+ "info",
4161
+ "debug"
4162
+ ]
4163
+ },
4164
+ "alwaysConfirmEnv": {
4165
+ "name": "alwaysConfirmEnv",
4166
+ "type": "option",
4167
+ "char": "e",
4168
+ "description": "The Environment variables",
4169
+ "required": false,
4170
+ "multiple": false,
4171
+ "options": [
4172
+ "true",
4173
+ "false"
4174
+ ],
4175
+ "default": "true"
4176
+ }
4177
+ },
4178
+ "args": {}
4179
+ },
4012
4180
  "app:extension:deployment:list": {
4013
4181
  "id": "app:extension:deployment:list",
4014
4182
  "description": "List extension deployments",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contrail/cli",
3
- "version": "3.7.0",
3
+ "version": "3.8.0-alpha.30d4e88",
4
4
  "description": "VibeIQ's Contrail Platform CLI.",
5
5
  "bin": {
6
6
  "contrail-cli": "./bin/run",