@contrail/cli 2.4.0-alpha-0.1 → 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 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-alpha-0.1 darwin-arm64 node-v21.7.1
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
@@ -1,2 +1,2 @@
1
- import { AuthContext } from './auth';
1
+ import { AuthContext } from '@contrail/sdk';
2
2
  export declare function authUser(): Promise<AuthContext>;
@@ -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 = {
@@ -15,15 +14,14 @@ const CONFIGURATION = {
15
14
  async function authUser() {
16
15
  logger_1.default.debug('authorizing user...');
17
16
  const config = await (0, config_1.getConfig)();
18
- console.log('config', config);
19
17
  if (config && config.apiUserToken && config.apiGateway && config.orgSlug) {
20
18
  logger_1.default.debug('populating auth config from fs config...');
21
- auth_1.Auth.config = {
19
+ const authConfig = {
22
20
  apiUserToken: config.apiUserToken,
23
21
  apiGateway: config.apiGateway,
24
22
  orgSlug: config.orgSlug,
25
23
  };
26
- (0, sdk_1.setConfig)(auth_1.Auth.config);
24
+ (0, sdk_1.setConfig)(authConfig);
27
25
  try {
28
26
  return await refreshCurrentUserOrg();
29
27
  }
@@ -97,7 +95,6 @@ exports.authUser = authUser;
97
95
  async function setAuthContext(user, params) {
98
96
  const config = await (0, config_1.getConfig)();
99
97
  let apiGateway;
100
- logger_1.default.info(config.environments);
101
98
  if (config.environments) {
102
99
  const questions = [];
103
100
  questions.push({
@@ -114,26 +111,32 @@ async function setAuthContext(user, params) {
114
111
  apiGateway = 'https://api.vibeiq.com/prod/api';
115
112
  }
116
113
  // Set Auth Config
117
- auth_1.Auth.config = {
114
+ const authConfig = {
118
115
  apiUserToken: user.idToken.jwtToken,
119
116
  apiGateway,
120
117
  orgSlug: params.orgSlug,
121
118
  };
122
119
  // SET SDK CONFIG
123
- (0, sdk_1.setConfig)(auth_1.Auth.config);
120
+ (0, sdk_1.setConfig)(authConfig);
124
121
  return refreshCurrentUserOrg();
125
122
  }
126
123
  async function refreshCurrentUserOrg() {
127
124
  logger_1.default.debug('refreshing current user org...');
128
125
  const currentUser = await (0, sdk_1.getCurrentUser)();
126
+ const sdkConfig = await (0, sdk_1.getConfig)();
129
127
  if (!currentUser) {
130
128
  throw Error('Could not get current user');
131
129
  }
132
- const org = currentUser.orgs.find((o) => o.orgSlug === auth_1.Auth.config.orgSlug);
130
+ const org = currentUser.orgs.find((o) => o.orgSlug === sdkConfig.orgSlug);
133
131
  if (org) {
134
- auth_1.Auth.config.orgId = org.orgId || org.id;
132
+ sdkConfig.orgId = org.orgId || org.id;
135
133
  }
136
134
  // cache config in the fs
137
- await (0, config_1.storeConfig)(Object.assign({}, auth_1.Auth.config));
138
- return Object.assign({}, auth_1.Auth.config);
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
+ };
139
142
  }
@@ -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
- await (0, config_1.storeConfig)(Object.assign({ orgSlug: '', apiGateway: '' }, auth_1.Auth.config));
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, TriggerKeyDefinition, ConfigPropertyElements, CreateAppAccessGrantDTO } from '../../interfaces';
2
+ import { AppDeclaration, ConfigPropertyElements, CreateAppAccessGrantDTO, TriggerKeyDefinition } from '../../interfaces';
3
3
  export declare class TriggerKeyDefinitionParser {
4
4
  static buildTriggersArray(appDeclaration: AppDeclaration): Array<TriggerKeyDefinition>;
5
5
  }
@@ -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,9 +79,10 @@ class AccessGrantsParser {
79
79
  static async buildAccessGrants(appDeclaration) {
80
80
  const accessGrants = [];
81
81
  const currentUser = await (0, sdk_1.getCurrentUser)();
82
- let currentOrgId = sdk_1.Auth.config.orgId;
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 === sdk_1.Auth.config.orgSlug);
85
+ let currentOrg = currentUser.orgs.find((o) => o.orgSlug === config.orgSlug);
85
86
  currentOrgId = currentOrg.orgId;
86
87
  }
87
88
  for (const accessGrant of appDeclaration.accessGrants) {
@@ -17,7 +17,7 @@ export class LogItemAction implements AppAction {
17
17
  entityName: 'item',
18
18
  id: event.id,
19
19
  });
20
- console.log('Got item: ', item);
20
+ console.log('Got item: ', JSON.stringify(item, null, 2));
21
21
 
22
22
  return {
23
23
  output: {
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "2.4.0-alpha-0.1",
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-alpha-0.1",
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": "^1.3.12",
26
+ "@contrail/sdk": "1.4",
27
27
  "@contrail/types": "^3.0.48",
28
28
  "@contrail/util": "^1.0.41",
29
29
  "@oclif/core": "^2",
@@ -37,7 +37,6 @@
37
37
  "axios": "^1.3.5",
38
38
  "chalk": "^4.0.0",
39
39
  "command-line-usage": "^6.1.1",
40
- "csv-parse": "^5.5.6",
41
40
  "csvtojson": "^2.0.10",
42
41
  "esm": "^3.2.25",
43
42
  "execa": "^5.0.0",
@@ -1,9 +0,0 @@
1
- export interface AuthContext {
2
- apiUserToken: string;
3
- apiGateway?: string;
4
- orgSlug?: string;
5
- orgId?: string;
6
- }
7
- export declare class Auth {
8
- static config: AuthContext;
9
- }
package/dist/auth/auth.js DELETED
@@ -1,7 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Auth = void 0;
4
- class Auth {
5
- static config;
6
- }
7
- exports.Auth = Auth;