@contrail/flexplm 1.6.0 → 1.6.1-alpha.3701858

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.
@@ -3,6 +3,7 @@ interface UploadOptions {
3
3
  message?: string;
4
4
  branch?: string;
5
5
  skipGit: boolean;
6
+ updateConfig: boolean;
6
7
  }
7
8
  export declare class UploadCommand {
8
9
  static parseArgs(args: string[]): UploadOptions;
@@ -36,6 +36,7 @@ class UploadCommand {
36
36
  let message;
37
37
  let branch;
38
38
  let skipGit = false;
39
+ let updateConfig = false;
39
40
  for (let i = 0; i < args.length; i++) {
40
41
  const a = args[i];
41
42
  if (a === '-m') {
@@ -53,6 +54,9 @@ class UploadCommand {
53
54
  else if (a === '--skip-git' || a === '--skipGit') {
54
55
  skipGit = true;
55
56
  }
57
+ else if (a === '--update-config') {
58
+ updateConfig = true;
59
+ }
56
60
  else if (a.startsWith('-')) {
57
61
  throw new Error(`Unknown option: ${a}`);
58
62
  }
@@ -66,7 +70,7 @@ class UploadCommand {
66
70
  if (!filePath) {
67
71
  throw new Error('upload: missing <path.ts> argument');
68
72
  }
69
- return { filePath, message, branch, skipGit };
73
+ return { filePath, message, branch, skipGit, updateConfig };
70
74
  }
71
75
  static buildCommitMessage(userMessage, fileId) {
72
76
  const lines = userMessage.split(/\r?\n/);
@@ -219,10 +223,29 @@ class UploadCommand {
219
223
  fs.writeFileSync(responsePath, JSON.stringify(uploadedFile, null, 2), 'utf8');
220
224
  console.log(`Wrote response to ${responsePath}`);
221
225
  console.log(`FILE ID: ${uploadedFile.id}`);
222
- if (options.skipGit) {
223
- return;
226
+ if (!options.skipGit) {
227
+ await this.commitToGit([tsAbsPath, absPath], uploadedFile.id, options);
228
+ }
229
+ if (options.updateConfig) {
230
+ const appOrgs = await new sdk_1.Entities().get({
231
+ entityName: 'app-org',
232
+ criteria: { appId: app.id },
233
+ });
234
+ if (!appOrgs || appOrgs.length === 0) {
235
+ throw new Error(`Failed to set the file onto the app config for "${appIdentifier}" because it is not installed in org "${orgName}". Install it via the admin console before using --update-config. You can paste the uploaded file's ID into the app config without needing to re-run this command.`);
236
+ }
237
+ if (appOrgs.length > 1) {
238
+ throw new Error(`Failed to set the file onto the app config for "${appIdentifier}" in org "${orgName}" because ${appOrgs.length} installations were identified. Expected one. Please contact customer support for assistance.`);
239
+ }
240
+ const appOrg = appOrgs[0];
241
+ const nextAppConfig = { ...(appOrg.appConfig || {}), transformMapFile: uploadedFile.id };
242
+ await new sdk_1.Entities().update({
243
+ entityName: 'app-org',
244
+ id: appOrg.id,
245
+ object: { appConfig: nextAppConfig },
246
+ });
247
+ console.log(`Updated app-org ${appOrg.id}: appConfig.transformMapFile = ${uploadedFile.id}`);
224
248
  }
225
- await this.commitToGit([tsAbsPath, absPath], uploadedFile.id, options);
226
249
  }
227
250
  }
228
251
  exports.UploadCommand = UploadCommand;
@@ -14,6 +14,7 @@ describe('UploadCommand.parseArgs', () => {
14
14
  message: undefined,
15
15
  branch: undefined,
16
16
  skipGit: false,
17
+ updateConfig: false,
17
18
  });
18
19
  });
19
20
  it('parses -m commit message option', () => {
@@ -40,15 +41,21 @@ describe('UploadCommand.parseArgs', () => {
40
41
  message: 'msg',
41
42
  branch: 'br',
42
43
  skipGit: false,
44
+ updateConfig: false,
43
45
  });
44
46
  });
47
+ it('parses --update-config flag', () => {
48
+ const opts = upload_1.UploadCommand.parseArgs(['mapping.ts', '--update-config']);
49
+ expect(opts.updateConfig).toBe(true);
50
+ });
45
51
  it('parses all options together', () => {
46
- const opts = upload_1.UploadCommand.parseArgs(['mapping.ts', '-m', 'msg', '-b', 'br', '--skip-git']);
52
+ const opts = upload_1.UploadCommand.parseArgs(['mapping.ts', '-m', 'msg', '-b', 'br', '--skip-git', '--update-config']);
47
53
  expect(opts).toEqual({
48
54
  filePath: 'mapping.ts',
49
55
  message: 'msg',
50
56
  branch: 'br',
51
57
  skipGit: true,
58
+ updateConfig: true,
52
59
  });
53
60
  });
54
61
  it('throws when -m is missing its value', () => {
package/lib/cli/index.js CHANGED
@@ -16,6 +16,7 @@ Upload options:
16
16
  -m <message> Git commit message (prompted if omitted)
17
17
  -b <branch> Create a new git branch before committing
18
18
  --skip-git Skip the post-upload git commit (default: commit)
19
+ --update-config Patch the app-org appConfig.transformMapFile with the uploaded file ID without needing to paste into the admin console
19
20
 
20
21
  Environment (upload):
21
22
  CONTRAIL_CLI_EMAIL VibeIQ user email
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contrail/flexplm",
3
- "version": "1.6.0",
3
+ "version": "1.6.1-alpha.3701858",
4
4
  "description": "Library used for integration with flexplm.",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",