@contrail/cli 3.6.0-alpha-8-alpha.ec2a2fe → 3.6.0-alpha-8-alpha.6cc8e2a

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/3.6.0-alpha-8-alpha.ec2a2fe linux-x64 node-v24.22.2
20
+ @contrail/cli/3.6.0-alpha-8-alpha.6cc8e2a linux-x64 node-v24.22.2
21
21
  $ contrail --help [COMMAND]
22
22
  USAGE
23
23
  $ contrail COMMAND
@@ -59,7 +59,7 @@ class DeleteEntity extends basecommand_1.BaseCommand {
59
59
  await (0, login_1.authUser)();
60
60
  const { args, flags, argv } = await this.parse(DeleteEntity);
61
61
  const { entityName } = args;
62
- const idParsedAsFlag = (0, common_1.findIdParsedAsFlag)(process.argv);
62
+ const idParsedAsFlag = (0, common_1.findIdParsedAsFlag)(process.argv, 'il');
63
63
  if (idParsedAsFlag) {
64
64
  this.error(`${idParsedAsFlag} starts with a hyphen, so it is read as flags rather than an id. Pass it after -- instead, or use an input file (-i).`);
65
65
  }
@@ -94,7 +94,7 @@ class GetEntity extends basecommand_1.BaseCommand {
94
94
  await (0, login_1.authUser)();
95
95
  const { args, flags, argv } = await this.parse(GetEntity);
96
96
  const { entityName } = args;
97
- const idParsedAsFlag = (0, common_1.findIdParsedAsFlag)(process.argv);
97
+ const idParsedAsFlag = (0, common_1.findIdParsedAsFlag)(process.argv, 'loprst');
98
98
  if (idParsedAsFlag) {
99
99
  this.error(`${idParsedAsFlag} starts with a hyphen, so it is read as flags rather than an id. Pass it after -- instead, or use an input file (-i).`);
100
100
  }
@@ -67,7 +67,7 @@ class UpdateEntity extends basecommand_1.BaseCommand {
67
67
  await (0, login_1.authUser)();
68
68
  const { args, argv } = await this.parse(UpdateEntity);
69
69
  const { entityName } = args;
70
- const idParsedAsFlag = (0, common_1.findIdParsedAsFlag)(process.argv);
70
+ const idParsedAsFlag = (0, common_1.findIdParsedAsFlag)(process.argv, 'il');
71
71
  if (idParsedAsFlag) {
72
72
  this.error(`${idParsedAsFlag} starts with a hyphen, so it is read as flags rather than an id. Pass it after -- instead, or use an input file (-i).`);
73
73
  }
package/dist/common.d.ts CHANGED
@@ -10,4 +10,4 @@ export declare const promptOnStderr: any;
10
10
  * which can silently switch on a boolean flag and shift the remaining arguments.
11
11
  * Platform ids are long enough to tell apart from a cluster of short flags.
12
12
  */
13
- export declare function findIdParsedAsFlag(argv: string[]): string | undefined;
13
+ export declare function findIdParsedAsFlag(argv: string[], shortFlagsTakingValues?: string): string | undefined;
package/dist/common.js CHANGED
@@ -38,9 +38,17 @@ exports.promptOnStderr = inquirer_1.default.createPromptModule({ output: process
38
38
  * which can silently switch on a boolean flag and shift the remaining arguments.
39
39
  * Platform ids are long enough to tell apart from a cluster of short flags.
40
40
  */
41
- function findIdParsedAsFlag(argv) {
41
+ function findIdParsedAsFlag(argv, shortFlagsTakingValues = '') {
42
42
  const separator = argv.indexOf('--');
43
43
  const beforeSeparator = separator === -1 ? argv : argv.slice(0, separator);
44
- return beforeSeparator.find((token) => /^-[A-Za-z0-9_-]{8,}$/.test(token));
44
+ return beforeSeparator.find((token) => {
45
+ // a long flag could never have been a short-flag cluster, and oclif rejects
46
+ // an unknown one itself
47
+ if (token.startsWith('--') || !/^-[A-Za-z0-9_-]{8,}$/.test(token)) {
48
+ return false;
49
+ }
50
+ // oclif reads -rvalue as a flag with an attached value
51
+ return !shortFlagsTakingValues.includes(token[1]);
52
+ });
45
53
  }
46
54
  exports.findIdParsedAsFlag = findIdParsedAsFlag;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const common_1 = require("./common");
4
+ describe('findIdParsedAsFlag', () => {
5
+ const GET_SHORT_FLAGS_WITH_VALUES = 'loprst';
6
+ it('should find an id that a short flag cluster would swallow', () => {
7
+ expect((0, common_1.findIdParsedAsFlag)(['delete', 'item', '-d3YBdV-d8PXI88U'])).toBe('-d3YBdV-d8PXI88U');
8
+ });
9
+ it('should ignore long flags, whatever their length', () => {
10
+ const longFlags = [
11
+ '--paginated',
12
+ '--inputFile',
13
+ '--outputFile',
14
+ '--relations',
15
+ '--propertySlugs',
16
+ '--skipHydrateRelationships',
17
+ '--alwaysConfirmEnv',
18
+ '--apiVersion',
19
+ '--logLevel',
20
+ '--dryRun',
21
+ '--suffix',
22
+ ];
23
+ longFlags.forEach((flag) => {
24
+ expect((0, common_1.findIdParsedAsFlag)(['get', 'color', flag])).toBeUndefined();
25
+ });
26
+ });
27
+ it('should ignore a short flag carrying an attached value', () => {
28
+ expect((0, common_1.findIdParsedAsFlag)(['get', 'color', '-rprojectItems'], GET_SHORT_FLAGS_WITH_VALUES)).toBeUndefined();
29
+ expect((0, common_1.findIdParsedAsFlag)(['get', 'color', '-ooutput12345'], GET_SHORT_FLAGS_WITH_VALUES)).toBeUndefined();
30
+ });
31
+ it('should still flag an id whose first character is not a value-taking flag', () => {
32
+ expect((0, common_1.findIdParsedAsFlag)(['get', 'color', '-d3YBdV-d8PX'], GET_SHORT_FLAGS_WITH_VALUES)).toBe('-d3YBdV-d8PX');
33
+ });
34
+ it('should ignore everything after the -- separator', () => {
35
+ expect((0, common_1.findIdParsedAsFlag)(['get', 'color', '--', '-nJkS_UQjgRHrENJ'])).toBeUndefined();
36
+ });
37
+ it('should ignore short flag clusters and ordinary arguments', () => {
38
+ expect((0, common_1.findIdParsedAsFlag)(['get', 'color', '-dS', '-t', '5', 'someId'])).toBeUndefined();
39
+ });
40
+ });
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "3.6.0-alpha-8-alpha.ec2a2fe",
2
+ "version": "3.6.0-alpha-8-alpha.6cc8e2a",
3
3
  "commands": {
4
4
  "app:create": {
5
5
  "id": "app:create",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contrail/cli",
3
- "version": "3.6.0-alpha-8-alpha.ec2a2fe",
3
+ "version": "3.6.0-alpha-8-alpha.6cc8e2a",
4
4
  "description": "VibeIQ's Contrail Platform CLI.",
5
5
  "bin": {
6
6
  "contrail-cli": "./bin/run",