@contrail/cli 3.7.0-alpha.51db987 → 3.7.0-alpha.67dab99
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 +3 -3
- package/dist/commands/app/publish.js +1 -1
- package/dist/helpers/app/app-config-validators.js +3 -3
- package/dist/helpers/app/app-config-validators.spec.js +18 -0
- package/dist/helpers/app/app-deployer.d.ts +1 -0
- package/dist/helpers/app/app-deployer.js +38 -0
- package/dist/helpers/app/upgrade-version.spec.js +3 -0
- package/oclif.manifest.json +2 -2
- 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/3.7.0-alpha.
|
|
20
|
+
@contrail/cli/3.7.0-alpha.67dab99 linux-x64 node-v24.22.2
|
|
21
21
|
$ contrail --help [COMMAND]
|
|
22
22
|
USAGE
|
|
23
23
|
$ contrail COMMAND
|
|
@@ -264,7 +264,7 @@ EXAMPLES
|
|
|
264
264
|
|
|
265
265
|
## `contrail app publish`
|
|
266
266
|
|
|
267
|
-
Publish the app to the marketplace. This visibility of your app depends on the app.yml configuration ("visibility" property)
|
|
267
|
+
Publish the app to the marketplace. This visibility of your app depends on the app.yml configuration ("visibility" property). A prerelease version (e.g. "1.4.0-alpha.1") is published without becoming the latest version of the app.
|
|
268
268
|
|
|
269
269
|
```
|
|
270
270
|
USAGE
|
|
@@ -282,7 +282,7 @@ FLAGS
|
|
|
282
282
|
|
|
283
283
|
DESCRIPTION
|
|
284
284
|
Publish the app to the marketplace. This visibility of your app depends on the app.yml configuration ("visibility"
|
|
285
|
-
property)
|
|
285
|
+
property). A prerelease version (e.g. "1.4.0-alpha.1") is published without becoming the latest version of the app.
|
|
286
286
|
|
|
287
287
|
EXAMPLES
|
|
288
288
|
$ contrail app publish
|
|
@@ -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 prerelease 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
|
`,
|
|
@@ -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
10
|
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
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 prerelease. Use "contrail app version [patch|minor|major]" 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
|
-
|
|
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,24 @@ 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 prerelease', () => {
|
|
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 a version part is not a number', () => {
|
|
44
|
+
const appDeclaration = {
|
|
45
|
+
version: '1.0.x',
|
|
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
|
+
});
|
|
36
54
|
it('should gracefully handle bad versions', () => {
|
|
37
55
|
const appDeclaration = {
|
|
38
56
|
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 prerelease 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,39 @@ 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
|
+
// A prerelease is published as a version of its own. The app record and its latest version stay as they are,
|
|
155
|
+
// so orgs on a stable version are not offered the prerelease as an update.
|
|
156
|
+
async publishPrereleaseVersion(appDeclaration, existingApp) {
|
|
157
|
+
const appCodePackage = await createNodePackage(appDeclaration.appIdentifier, this.debug, this.dryRun);
|
|
158
|
+
if (this.dryRun) {
|
|
159
|
+
logger_1.default.info('Dry run, not creating app version');
|
|
160
|
+
return {};
|
|
161
|
+
}
|
|
162
|
+
const appVersion = await new sdk_1.Entities().create({
|
|
163
|
+
entityName: 'app-version',
|
|
164
|
+
object: {
|
|
165
|
+
appId: existingApp.id,
|
|
166
|
+
semver: appDeclaration.version,
|
|
167
|
+
eventWorkflowTriggerKeyMapping: appDeclaration.eventWorkflowTriggerKeyMapping,
|
|
168
|
+
configProperties: appDeclaration.appConfiguration
|
|
169
|
+
? app_template_parsers_1.ConfigPropertiesParser.getConfigProperties(appDeclaration.appConfiguration)
|
|
170
|
+
: undefined,
|
|
171
|
+
triggerKeyDefinitions: appDeclaration.triggers
|
|
172
|
+
? app_template_parsers_1.TriggerKeyDefinitionParser.buildTriggersArray(appDeclaration)
|
|
173
|
+
: undefined,
|
|
174
|
+
externalLinks: appDeclaration.externalLinks
|
|
175
|
+
? app_template_parsers_1.ExternalLinkParser.validateAndGetExternalLinks(appDeclaration.externalLinks)
|
|
176
|
+
: [],
|
|
177
|
+
appCodePackageId: appCodePackage.id,
|
|
178
|
+
frameworkVersion: 2,
|
|
179
|
+
nodeRuntime: appDeclaration.nodeRuntime ?? existingApp.nodeRuntime,
|
|
180
|
+
},
|
|
181
|
+
});
|
|
182
|
+
logger_1.default.info(`${chalk_1.default.yellow.bold('APP')} Published prerelease version: ${appVersion.semver}`);
|
|
183
|
+
// The actions, extensions and workflow templates deployed next attach to latestAppVersionId,
|
|
184
|
+
// so it carries the version just published.
|
|
185
|
+
return { ...existingApp, latestAppVersionId: appVersion.id };
|
|
186
|
+
}
|
|
149
187
|
async remove(appDeclaration) {
|
|
150
188
|
let app = await this.getExistingApp(appDeclaration);
|
|
151
189
|
if (app) {
|
|
@@ -25,6 +25,9 @@ describe('upgradeVersion', () => {
|
|
|
25
25
|
const expectedVersion = semver_1.default.inc(currentVersion, releaseType);
|
|
26
26
|
expect(upgradedVersion).toBe(expectedVersion);
|
|
27
27
|
});
|
|
28
|
+
it('should upgrade a prerelease to its stable version', () => {
|
|
29
|
+
expect((0, upgrade_version_1.upgradeVersion)('1.4.0-alpha.1', 'patch')).toBe('1.4.0');
|
|
30
|
+
});
|
|
28
31
|
it('should throw an error for an invalid semantic version input', () => {
|
|
29
32
|
const currentVersion = 'invalidVersion';
|
|
30
33
|
const releaseType = 'patch';
|
package/oclif.manifest.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "3.7.0-alpha.
|
|
2
|
+
"version": "3.7.0-alpha.67dab99",
|
|
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 prerelease 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",
|