@contrail/cli 2.4.0-alpha → 2.4.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.
- package/README.md +5 -2
- package/dist/auth/login.d.ts +1 -1
- package/dist/auth/login.js +14 -10
- package/dist/basecommand.js +4 -2
- package/dist/commands/app/create.d.ts +4 -0
- package/dist/commands/app/create.js +3 -0
- package/dist/commands/app/install.d.ts +2 -0
- package/dist/commands/app/install.js +1 -0
- package/dist/helpers/app/app-template-parsers.d.ts +2 -2
- package/dist/helpers/app/app-template-parsers.js +12 -8
- package/dist/interfaces.d.ts +4 -2
- package/dist/templates/typescript/src/actions/logItem.ts +1 -1
- package/oclif.manifest.json +48 -2
- package/package.json +3 -3
- package/dist/auth/auth.d.ts +0 -9
- package/dist/auth/auth.js +0 -7
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.4.0
|
|
20
|
+
@contrail/cli/2.4.0 darwin-arm64 node-v21.7.1
|
|
21
21
|
$ contrail --help [COMMAND]
|
|
22
22
|
USAGE
|
|
23
23
|
$ contrail COMMAND
|
|
@@ -174,10 +174,13 @@ Install an app from the marketplace
|
|
|
174
174
|
|
|
175
175
|
```
|
|
176
176
|
USAGE
|
|
177
|
-
$ contrail app install [-i <value>] [-w]
|
|
177
|
+
$ contrail app install [-l error|warn|info|debug] [-e] [-i <value>] [-w]
|
|
178
178
|
|
|
179
179
|
FLAGS
|
|
180
|
+
-e, --alwaysConfirmEnv The Environment variables
|
|
180
181
|
-i, --appIdentifier=<value> The identifier of the app to install
|
|
182
|
+
-l, --logLevel=<option> The Log Level
|
|
183
|
+
<options: error|warn|info|debug>
|
|
181
184
|
-w, --installWorkflowTemplates "Install the app's accompanying workflows"
|
|
182
185
|
|
|
183
186
|
DESCRIPTION
|
package/dist/auth/login.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { AuthContext } from '
|
|
1
|
+
import { AuthContext } from '@contrail/sdk';
|
|
2
2
|
export declare function authUser(): Promise<AuthContext>;
|
package/dist/auth/login.js
CHANGED
|
@@ -5,7 +5,6 @@ const tslib_1 = require("tslib");
|
|
|
5
5
|
const amazon_cognito_identity_js_1 = require("amazon-cognito-identity-js");
|
|
6
6
|
const inquirer_1 = tslib_1.__importDefault(require("inquirer"));
|
|
7
7
|
const sdk_1 = require("@contrail/sdk");
|
|
8
|
-
const auth_1 = require("./auth");
|
|
9
8
|
const config_1 = require("../helpers/config/config");
|
|
10
9
|
const logger_1 = tslib_1.__importDefault(require("../logger"));
|
|
11
10
|
const CONFIGURATION = {
|
|
@@ -17,12 +16,12 @@ async function authUser() {
|
|
|
17
16
|
const config = await (0, config_1.getConfig)();
|
|
18
17
|
if (config && config.apiUserToken && config.apiGateway && config.orgSlug) {
|
|
19
18
|
logger_1.default.debug('populating auth config from fs config...');
|
|
20
|
-
|
|
19
|
+
const authConfig = {
|
|
21
20
|
apiUserToken: config.apiUserToken,
|
|
22
21
|
apiGateway: config.apiGateway,
|
|
23
22
|
orgSlug: config.orgSlug,
|
|
24
23
|
};
|
|
25
|
-
(0, sdk_1.setConfig)(
|
|
24
|
+
(0, sdk_1.setConfig)(authConfig);
|
|
26
25
|
try {
|
|
27
26
|
return await refreshCurrentUserOrg();
|
|
28
27
|
}
|
|
@@ -96,7 +95,6 @@ exports.authUser = authUser;
|
|
|
96
95
|
async function setAuthContext(user, params) {
|
|
97
96
|
const config = await (0, config_1.getConfig)();
|
|
98
97
|
let apiGateway;
|
|
99
|
-
logger_1.default.info(config.environments);
|
|
100
98
|
if (config.environments) {
|
|
101
99
|
const questions = [];
|
|
102
100
|
questions.push({
|
|
@@ -113,26 +111,32 @@ async function setAuthContext(user, params) {
|
|
|
113
111
|
apiGateway = 'https://api.vibeiq.com/prod/api';
|
|
114
112
|
}
|
|
115
113
|
// Set Auth Config
|
|
116
|
-
|
|
114
|
+
const authConfig = {
|
|
117
115
|
apiUserToken: user.idToken.jwtToken,
|
|
118
116
|
apiGateway,
|
|
119
117
|
orgSlug: params.orgSlug,
|
|
120
118
|
};
|
|
121
119
|
// SET SDK CONFIG
|
|
122
|
-
(0, sdk_1.setConfig)(
|
|
120
|
+
(0, sdk_1.setConfig)(authConfig);
|
|
123
121
|
return refreshCurrentUserOrg();
|
|
124
122
|
}
|
|
125
123
|
async function refreshCurrentUserOrg() {
|
|
126
124
|
logger_1.default.debug('refreshing current user org...');
|
|
127
125
|
const currentUser = await (0, sdk_1.getCurrentUser)();
|
|
126
|
+
const sdkConfig = await (0, sdk_1.getConfig)();
|
|
128
127
|
if (!currentUser) {
|
|
129
128
|
throw Error('Could not get current user');
|
|
130
129
|
}
|
|
131
|
-
const org = currentUser.orgs.find((o) => o.orgSlug ===
|
|
130
|
+
const org = currentUser.orgs.find((o) => o.orgSlug === sdkConfig.orgSlug);
|
|
132
131
|
if (org) {
|
|
133
|
-
|
|
132
|
+
sdkConfig.orgId = org.orgId || org.id;
|
|
134
133
|
}
|
|
135
134
|
// cache config in the fs
|
|
136
|
-
await (0, config_1.storeConfig)(
|
|
137
|
-
return
|
|
135
|
+
await (0, config_1.storeConfig)(sdkConfig);
|
|
136
|
+
return {
|
|
137
|
+
apiUserToken: sdkConfig.apiUserToken,
|
|
138
|
+
apiGateway: sdkConfig.apiGateway,
|
|
139
|
+
orgSlug: sdkConfig.orgSlug,
|
|
140
|
+
orgId: sdkConfig.orgId,
|
|
141
|
+
};
|
|
138
142
|
}
|
package/dist/basecommand.js
CHANGED
|
@@ -6,8 +6,8 @@ const core_1 = require("@oclif/core");
|
|
|
6
6
|
const logger_1 = tslib_1.__importDefault(require("./logger"));
|
|
7
7
|
const inquirer_1 = tslib_1.__importDefault(require("inquirer"));
|
|
8
8
|
const config_1 = require("./helpers/config/config");
|
|
9
|
-
const auth_1 = require("@contrail/sdk/lib/auth/auth");
|
|
10
9
|
const lodash_1 = tslib_1.__importDefault(require("lodash"));
|
|
10
|
+
const sdk_1 = require("@contrail/sdk");
|
|
11
11
|
class BaseCommand extends core_1.Command {
|
|
12
12
|
static description = 'Global Flags';
|
|
13
13
|
skipConfirmEnv = false;
|
|
@@ -69,7 +69,9 @@ class BaseCommand extends core_1.Command {
|
|
|
69
69
|
});
|
|
70
70
|
const { confirm } = await inquirer_1.default.prompt(questions);
|
|
71
71
|
if (confirm === 'no') {
|
|
72
|
-
|
|
72
|
+
const emptyAuthConfig = { orgSlug: '', apiGateway: '' };
|
|
73
|
+
(0, sdk_1.setConfig)(emptyAuthConfig);
|
|
74
|
+
await (0, config_1.storeConfig)(emptyAuthConfig);
|
|
73
75
|
}
|
|
74
76
|
}
|
|
75
77
|
}
|
|
@@ -2,5 +2,9 @@ import { BaseCommand } from '../../basecommand';
|
|
|
2
2
|
export default class CreateApp extends BaseCommand {
|
|
3
3
|
static description: string;
|
|
4
4
|
static examples: string[];
|
|
5
|
+
static baseFlags: {
|
|
6
|
+
logLevel: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
7
|
+
alwaysConfirmEnv: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
8
|
+
};
|
|
5
9
|
run(): Promise<void>;
|
|
6
10
|
}
|
|
@@ -13,6 +13,9 @@ class CreateApp extends basecommand_1.BaseCommand {
|
|
|
13
13
|
`$ contrail app create
|
|
14
14
|
`,
|
|
15
15
|
];
|
|
16
|
+
static baseFlags = {
|
|
17
|
+
...basecommand_1.BaseCommand.baseFlags,
|
|
18
|
+
};
|
|
16
19
|
async run() {
|
|
17
20
|
await (0, login_1.authUser)();
|
|
18
21
|
const currentUser = await (0, sdk_1.getCurrentUser)();
|
|
@@ -6,6 +6,8 @@ export default class InstallApp extends BaseCommand {
|
|
|
6
6
|
static flags: {
|
|
7
7
|
appIdentifier: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
8
8
|
installWorkflowTemplates: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
9
|
+
logLevel: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
10
|
+
alwaysConfirmEnv: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
9
11
|
};
|
|
10
12
|
run(): Promise<void>;
|
|
11
13
|
}
|
|
@@ -20,6 +20,7 @@ class InstallApp extends basecommand_1.BaseCommand {
|
|
|
20
20
|
// variable argument length
|
|
21
21
|
static strict = true;
|
|
22
22
|
static flags = {
|
|
23
|
+
...basecommand_1.BaseCommand.baseFlags,
|
|
23
24
|
appIdentifier: core_1.Flags.string({
|
|
24
25
|
char: 'i',
|
|
25
26
|
description: 'The identifier of the app to install',
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ExternalLink } from '@contrail/entity-types';
|
|
2
|
-
import { AppDeclaration,
|
|
2
|
+
import { AppDeclaration, ConfigPropertyElements, CreateAppAccessGrantDTO, TriggerKeyDefinition } from '../../interfaces';
|
|
3
3
|
export declare class TriggerKeyDefinitionParser {
|
|
4
4
|
static buildTriggersArray(appDeclaration: AppDeclaration): Array<TriggerKeyDefinition>;
|
|
5
5
|
}
|
|
@@ -10,5 +10,5 @@ export declare class ExternalLinkParser {
|
|
|
10
10
|
static validateAndGetExternalLinks(externalLinks: ExternalLink[]): ExternalLink[];
|
|
11
11
|
}
|
|
12
12
|
export declare class AccessGrantsParser {
|
|
13
|
-
static buildAccessGrants(appDeclaration: AppDeclaration): Promise<
|
|
13
|
+
static buildAccessGrants(appDeclaration: AppDeclaration): Promise<CreateAppAccessGrantDTO[]>;
|
|
14
14
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.AccessGrantsParser = exports.ExternalLinkParser = exports.ConfigPropertiesParser = exports.TriggerKeyDefinitionParser = void 0;
|
|
4
|
-
const interfaces_1 = require("../../interfaces");
|
|
5
4
|
const sdk_1 = require("@contrail/sdk");
|
|
5
|
+
const interfaces_1 = require("../../interfaces");
|
|
6
6
|
class TriggerKeyDefinitionParser {
|
|
7
7
|
static buildTriggersArray(appDeclaration) {
|
|
8
8
|
const triggers = [];
|
|
@@ -79,19 +79,23 @@ class AccessGrantsParser {
|
|
|
79
79
|
static async buildAccessGrants(appDeclaration) {
|
|
80
80
|
const accessGrants = [];
|
|
81
81
|
const currentUser = await (0, sdk_1.getCurrentUser)();
|
|
82
|
-
|
|
82
|
+
const config = (0, sdk_1.getConfig)();
|
|
83
|
+
let currentOrgId = config.orgId;
|
|
83
84
|
if (!currentOrgId) {
|
|
84
|
-
let currentOrg = currentUser.orgs.find((o) => o.orgSlug ===
|
|
85
|
+
let currentOrg = currentUser.orgs.find((o) => o.orgSlug === config.orgSlug);
|
|
85
86
|
currentOrgId = currentOrg.orgId;
|
|
86
87
|
}
|
|
87
|
-
const orgs = await new sdk_1.Entities().get({
|
|
88
|
-
entityName: 'org',
|
|
89
|
-
});
|
|
90
88
|
for (const accessGrant of appDeclaration.accessGrants) {
|
|
91
|
-
const recipientOrg = orgs.find((o) => o.
|
|
89
|
+
const recipientOrg = currentUser.orgs.find((o) => o.orgSlug === accessGrant.orgSlug);
|
|
90
|
+
if (!recipientOrg) {
|
|
91
|
+
throw new Error(`You don't have access to the ${accessGrant.orgSlug} organization`);
|
|
92
|
+
}
|
|
93
|
+
if (recipientOrg.role !== 'ADMIN') {
|
|
94
|
+
throw new Error(`Only administrators of the ${accessGrant.orgSlug} organization can share the app`);
|
|
95
|
+
}
|
|
92
96
|
const grant = {
|
|
93
97
|
issuerReference: `org:${currentOrgId}`,
|
|
94
|
-
recipientReference: `org:${recipientOrg.
|
|
98
|
+
recipientReference: `org:${recipientOrg.orgId}`,
|
|
95
99
|
scope: interfaces_1.AppAccessGrantScope.install,
|
|
96
100
|
};
|
|
97
101
|
accessGrants.push(grant);
|
package/dist/interfaces.d.ts
CHANGED
|
@@ -32,11 +32,13 @@ export interface AccessGrantConfiguration {
|
|
|
32
32
|
orgSlug: string;
|
|
33
33
|
permissions: AppAccessPermission[];
|
|
34
34
|
}
|
|
35
|
-
export
|
|
35
|
+
export type CreateAppAccessGrantDTO = {
|
|
36
36
|
issuerReference: string;
|
|
37
37
|
recipientReference: string;
|
|
38
|
-
appId?: string;
|
|
39
38
|
scope: AppAccessGrantScope;
|
|
39
|
+
};
|
|
40
|
+
export interface AppAccessGrant extends CreateAppAccessGrantDTO {
|
|
41
|
+
appId: string;
|
|
40
42
|
}
|
|
41
43
|
export declare enum AppAccessGrantScope {
|
|
42
44
|
install = "INSTALL"
|
package/oclif.manifest.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "2.4.0
|
|
2
|
+
"version": "2.4.0",
|
|
3
3
|
"commands": {
|
|
4
4
|
"app:create": {
|
|
5
5
|
"id": "app:create",
|
|
@@ -13,7 +13,31 @@
|
|
|
13
13
|
"$ contrail app create\n"
|
|
14
14
|
],
|
|
15
15
|
"flags": {},
|
|
16
|
-
"args": {}
|
|
16
|
+
"args": {},
|
|
17
|
+
"baseFlags": {
|
|
18
|
+
"logLevel": {
|
|
19
|
+
"description": "The Log Level",
|
|
20
|
+
"required": false,
|
|
21
|
+
"char": "l",
|
|
22
|
+
"options": [
|
|
23
|
+
"error",
|
|
24
|
+
"warn",
|
|
25
|
+
"info",
|
|
26
|
+
"debug"
|
|
27
|
+
],
|
|
28
|
+
"input": [],
|
|
29
|
+
"multiple": false,
|
|
30
|
+
"type": "option"
|
|
31
|
+
},
|
|
32
|
+
"alwaysConfirmEnv": {
|
|
33
|
+
"description": "The Environment variables",
|
|
34
|
+
"required": false,
|
|
35
|
+
"char": "e",
|
|
36
|
+
"default": true,
|
|
37
|
+
"allowNo": false,
|
|
38
|
+
"type": "boolean"
|
|
39
|
+
}
|
|
40
|
+
}
|
|
17
41
|
},
|
|
18
42
|
"app:delete": {
|
|
19
43
|
"id": "app:delete",
|
|
@@ -78,6 +102,28 @@
|
|
|
78
102
|
"$ contrail app install --appIdentifier @VibeIQ/Flex-PLM-Connector\n"
|
|
79
103
|
],
|
|
80
104
|
"flags": {
|
|
105
|
+
"logLevel": {
|
|
106
|
+
"name": "logLevel",
|
|
107
|
+
"type": "option",
|
|
108
|
+
"char": "l",
|
|
109
|
+
"description": "The Log Level",
|
|
110
|
+
"required": false,
|
|
111
|
+
"multiple": false,
|
|
112
|
+
"options": [
|
|
113
|
+
"error",
|
|
114
|
+
"warn",
|
|
115
|
+
"info",
|
|
116
|
+
"debug"
|
|
117
|
+
]
|
|
118
|
+
},
|
|
119
|
+
"alwaysConfirmEnv": {
|
|
120
|
+
"name": "alwaysConfirmEnv",
|
|
121
|
+
"type": "boolean",
|
|
122
|
+
"char": "e",
|
|
123
|
+
"description": "The Environment variables",
|
|
124
|
+
"required": false,
|
|
125
|
+
"allowNo": false
|
|
126
|
+
},
|
|
81
127
|
"appIdentifier": {
|
|
82
128
|
"name": "appIdentifier",
|
|
83
129
|
"type": "option",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contrail/cli",
|
|
3
|
-
"version": "2.4.0
|
|
3
|
+
"version": "2.4.0",
|
|
4
4
|
"description": "VibeIQ's Contrail Platform CLI.",
|
|
5
5
|
"bin": {
|
|
6
6
|
"contrail-cli": "./bin/run",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
],
|
|
24
24
|
"dependencies": {
|
|
25
25
|
"@contrail/entity-types": "^1.1.17",
|
|
26
|
-
"@contrail/sdk": "
|
|
26
|
+
"@contrail/sdk": "1.4",
|
|
27
27
|
"@contrail/types": "^3.0.48",
|
|
28
28
|
"@contrail/util": "^1.0.41",
|
|
29
29
|
"@oclif/core": "^2",
|
|
@@ -139,4 +139,4 @@
|
|
|
139
139
|
"coverageDirectory": "../coverage",
|
|
140
140
|
"testEnvironment": "node"
|
|
141
141
|
}
|
|
142
|
-
}
|
|
142
|
+
}
|
package/dist/auth/auth.d.ts
DELETED