@contrail/cli 2.2.2 → 2.2.3
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 +1 -1
- package/dist/commands/app/create.js +1 -0
- package/dist/commands/app/version/major.js +1 -1
- package/dist/commands/app/version/minor.js +1 -1
- package/dist/commands/app/version/patch.js +1 -1
- package/dist/helpers/app/app-config-validators.d.ts +7 -0
- package/dist/helpers/app/app-config-validators.js +49 -0
- package/dist/helpers/app/app-config-validators.spec.d.ts +1 -0
- package/dist/helpers/app/app-config-validators.spec.js +67 -0
- package/dist/helpers/app/app-deployer.js +1 -0
- package/dist/helpers/app/load-app-config.d.ts +3 -1
- package/dist/helpers/app/load-app-config.js +5 -1
- package/dist/templates/typescript/app.yml +1 -1
- package/oclif.manifest.json +1 -1
- package/package.json +1 -1
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/2.2.
|
|
20
|
+
@contrail/cli/2.2.3 darwin-arm64 node-v18.13.0
|
|
21
21
|
$ contrail --help [COMMAND]
|
|
22
22
|
USAGE
|
|
23
23
|
$ contrail COMMAND
|
|
@@ -14,7 +14,7 @@ class AppMajorVersionUpgrade extends basecommand_1.BaseCommand {
|
|
|
14
14
|
async run() {
|
|
15
15
|
let appDeclaration;
|
|
16
16
|
try {
|
|
17
|
-
appDeclaration = (0, load_app_config_1.loadAppConfig)();
|
|
17
|
+
appDeclaration = (0, load_app_config_1.loadAppConfig)({ skipValidation: true });
|
|
18
18
|
}
|
|
19
19
|
catch (e) {
|
|
20
20
|
logger_1.default.error(`Application Load Configuration Failed: ${e}`);
|
|
@@ -14,7 +14,7 @@ class AppMinorVersionUpgrade extends basecommand_1.BaseCommand {
|
|
|
14
14
|
async run() {
|
|
15
15
|
let appDeclaration;
|
|
16
16
|
try {
|
|
17
|
-
appDeclaration = (0, load_app_config_1.loadAppConfig)();
|
|
17
|
+
appDeclaration = (0, load_app_config_1.loadAppConfig)({ skipValidation: true });
|
|
18
18
|
}
|
|
19
19
|
catch (e) {
|
|
20
20
|
logger_1.default.error(`Application Load Configuration Failed: ${e}`);
|
|
@@ -14,7 +14,7 @@ class AppPatchVersionUpgrade extends basecommand_1.BaseCommand {
|
|
|
14
14
|
async run() {
|
|
15
15
|
let appDeclaration;
|
|
16
16
|
try {
|
|
17
|
-
appDeclaration = (0, load_app_config_1.loadAppConfig)();
|
|
17
|
+
appDeclaration = (0, load_app_config_1.loadAppConfig)({ skipValidation: true });
|
|
18
18
|
}
|
|
19
19
|
catch (e) {
|
|
20
20
|
logger_1.default.error(`Application Load Configuration Failed: ${e}`);
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { AppDeclaration } from '../../interfaces';
|
|
2
|
+
export interface AppConfigValidationError {
|
|
3
|
+
error: string;
|
|
4
|
+
}
|
|
5
|
+
export declare function validateAppConfig(appConfig: AppDeclaration): void;
|
|
6
|
+
export declare function appVersionValidator(appDeclaration: AppDeclaration): AppConfigValidationError;
|
|
7
|
+
export declare function visibilityValidator(appDeclaration: AppDeclaration): AppConfigValidationError;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.visibilityValidator = exports.appVersionValidator = exports.validateAppConfig = void 0;
|
|
4
|
+
const VALIDATORS = [appVersionValidator, visibilityValidator];
|
|
5
|
+
function validateAppConfig(appConfig) {
|
|
6
|
+
const errors = [];
|
|
7
|
+
for (const validator of VALIDATORS) {
|
|
8
|
+
const error = validator(appConfig);
|
|
9
|
+
if (error) {
|
|
10
|
+
errors.push(error);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
if (errors.length) {
|
|
14
|
+
throw new Error(`Invalid app config: \n ${errors.map((x) => x.error).join('\n')}`);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
exports.validateAppConfig = validateAppConfig;
|
|
18
|
+
function appVersionValidator(appDeclaration) {
|
|
19
|
+
if (!appDeclaration.version) {
|
|
20
|
+
return {
|
|
21
|
+
error: 'Missing "version" field". Semantic App Version looks like "1.0.0". Use "contrail app version [patch|minor|major]" to update the app version.',
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
if (typeof appDeclaration.version !== 'string') {
|
|
25
|
+
return {
|
|
26
|
+
error: '"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.',
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
const parts = appDeclaration.version.split('.');
|
|
30
|
+
if (parts.length !== 3) {
|
|
31
|
+
return {
|
|
32
|
+
error: 'Invalid app version. Semantic App Version looks like "1.0.0". Use "contrail app version [patch|minor|major]" to update the app version.',
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
exports.appVersionValidator = appVersionValidator;
|
|
37
|
+
function visibilityValidator(appDeclaration) {
|
|
38
|
+
if (!['public', 'private'].includes(appDeclaration.visibility)) {
|
|
39
|
+
return {
|
|
40
|
+
error: 'Invalid visibility. Visibility must be "public" or "private".',
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
if (appDeclaration.visibility === 'private' && appDeclaration.hidden !== true) {
|
|
44
|
+
return {
|
|
45
|
+
error: 'Apps can not be private and hidden.',
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
exports.visibilityValidator = visibilityValidator;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const app_config_validators_1 = require("./app-config-validators");
|
|
4
|
+
describe('appVersionValidator', () => {
|
|
5
|
+
it('should return an error if "version" field is missing', () => {
|
|
6
|
+
const appDeclaration = {};
|
|
7
|
+
const expectedError = {
|
|
8
|
+
error: 'Missing "version" field". Semantic App Version looks like "1.0.0". Use "contrail app version [patch|minor|major]" to update the app version.',
|
|
9
|
+
};
|
|
10
|
+
const validationResult = (0, app_config_validators_1.appVersionValidator)(appDeclaration);
|
|
11
|
+
expect(validationResult).toEqual(expectedError);
|
|
12
|
+
});
|
|
13
|
+
it('should return an error if app version is invalid', () => {
|
|
14
|
+
const appDeclaration = {
|
|
15
|
+
version: 'invalidVersion',
|
|
16
|
+
};
|
|
17
|
+
const expectedError = {
|
|
18
|
+
error: 'Invalid app version. Semantic App Version looks like "1.0.0". Use "contrail app version [patch|minor|major]" to update the app version.',
|
|
19
|
+
};
|
|
20
|
+
const validationResult = (0, app_config_validators_1.appVersionValidator)(appDeclaration);
|
|
21
|
+
expect(validationResult).toEqual(expectedError);
|
|
22
|
+
});
|
|
23
|
+
it('should not return an error if app version is valid', () => {
|
|
24
|
+
const appDeclaration = {
|
|
25
|
+
version: '1.0.0',
|
|
26
|
+
};
|
|
27
|
+
const validationResult = (0, app_config_validators_1.appVersionValidator)(appDeclaration);
|
|
28
|
+
expect(validationResult).toBeUndefined();
|
|
29
|
+
});
|
|
30
|
+
it('should gracefully handle bad versions', () => {
|
|
31
|
+
const appDeclaration = {
|
|
32
|
+
version: '1',
|
|
33
|
+
};
|
|
34
|
+
const validationResult = (0, app_config_validators_1.appVersionValidator)(appDeclaration);
|
|
35
|
+
expect(validationResult.error).toEqual('Invalid app version. Semantic App Version looks like "1.0.0". Use "contrail app version [patch|minor|major]" to update the app version.');
|
|
36
|
+
});
|
|
37
|
+
});
|
|
38
|
+
it('should return an error if "version" field is not a string', () => {
|
|
39
|
+
const appDeclaration = {
|
|
40
|
+
version: 123,
|
|
41
|
+
};
|
|
42
|
+
const expectedError = {
|
|
43
|
+
error: '"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.',
|
|
44
|
+
};
|
|
45
|
+
const validationResult = (0, app_config_validators_1.appVersionValidator)(appDeclaration);
|
|
46
|
+
expect(validationResult).toEqual(expectedError);
|
|
47
|
+
});
|
|
48
|
+
it('should return an error if "version" field is empty', () => {
|
|
49
|
+
const appDeclaration = {
|
|
50
|
+
version: '',
|
|
51
|
+
};
|
|
52
|
+
const expectedError = {
|
|
53
|
+
error: 'Missing "version" field". Semantic App Version looks like "1.0.0". Use "contrail app version [patch|minor|major]" to update the app version.',
|
|
54
|
+
};
|
|
55
|
+
const validationResult = (0, app_config_validators_1.appVersionValidator)(appDeclaration);
|
|
56
|
+
expect(validationResult).toEqual(expectedError);
|
|
57
|
+
});
|
|
58
|
+
it('should return an error if app version has invalid format', () => {
|
|
59
|
+
const appDeclaration = {
|
|
60
|
+
version: '1.0',
|
|
61
|
+
};
|
|
62
|
+
const expectedError = {
|
|
63
|
+
error: 'Invalid app version. Semantic App Version looks like "1.0.0". Use "contrail app version [patch|minor|major]" to update the app version.',
|
|
64
|
+
};
|
|
65
|
+
const validationResult = (0, app_config_validators_1.appVersionValidator)(appDeclaration);
|
|
66
|
+
expect(validationResult).toEqual(expectedError);
|
|
67
|
+
});
|
|
@@ -61,6 +61,7 @@ class AppDeployer {
|
|
|
61
61
|
const newApp = {
|
|
62
62
|
identifier: appDeclaration.appIdentifier,
|
|
63
63
|
name: appDeclaration.appName,
|
|
64
|
+
version: appDeclaration.version,
|
|
64
65
|
public: appDeclaration.visibility === 'public',
|
|
65
66
|
hidden: appDeclaration.hidden,
|
|
66
67
|
description: appDeclaration.appDescription,
|
|
@@ -5,10 +5,14 @@ const tslib_1 = require("tslib");
|
|
|
5
5
|
const path = tslib_1.__importStar(require("path"));
|
|
6
6
|
const fs_1 = tslib_1.__importDefault(require("fs"));
|
|
7
7
|
const js_yaml_1 = tslib_1.__importDefault(require("js-yaml"));
|
|
8
|
-
|
|
8
|
+
const app_config_validators_1 = require("./app-config-validators");
|
|
9
|
+
function loadAppConfig(config = { skipValidation: false }) {
|
|
9
10
|
const TARGET_DIR = process.cwd();
|
|
10
11
|
try {
|
|
11
12
|
const doc = js_yaml_1.default.load(fs_1.default.readFileSync(path.resolve(path.join(TARGET_DIR, 'app.yml')), 'utf8'));
|
|
13
|
+
if (!(config === null || config === void 0 ? void 0 : config.skipValidation)) {
|
|
14
|
+
(0, app_config_validators_1.validateAppConfig)(doc);
|
|
15
|
+
}
|
|
12
16
|
return doc;
|
|
13
17
|
}
|
|
14
18
|
catch (e) {
|
|
@@ -4,7 +4,7 @@ appDescription: "APP_DESCRIPTION_STUB" # Give your app a description
|
|
|
4
4
|
visibility: private # This should be private unless you want to develop an app for all VibeIQ customers to use
|
|
5
5
|
hidden: false # can be used with a public app to prevent it from showing on the marketplace, but still installable by other orgs
|
|
6
6
|
publisher: "Your company name" # Your company name, used for public apps
|
|
7
|
-
version: 1.0.0
|
|
7
|
+
version: "1.0.0"
|
|
8
8
|
|
|
9
9
|
# Properties you can configure when you install the app.
|
|
10
10
|
# These property values will be available to all of your actions when they run
|
package/oclif.manifest.json
CHANGED