@contrail/cli 3.6.0-alpha-8-alpha.2ab4f80 → 3.6.0-alpha-8-alpha.694fd70
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 +1 -1
- package/dist/auth/login.js +3 -2
- package/dist/basecommand.js +2 -2
- package/dist/commands/entities/create.d.ts +0 -1
- package/dist/commands/entities/create.js +4 -8
- package/dist/commands/entities/create.spec.js +0 -4
- package/dist/commands/entities/delete.d.ts +0 -1
- package/dist/commands/entities/delete.js +2 -5
- package/dist/commands/entities/get.d.ts +0 -1
- package/dist/commands/entities/get.js +1 -4
- package/dist/commands/entities/update.d.ts +0 -1
- package/dist/commands/entities/update.js +1 -4
- package/dist/common.d.ts +0 -1
- package/dist/common.js +1 -6
- package/dist/helpers/entities/assortment-items.d.ts +2 -4
- package/dist/helpers/entities/assortment-items.js +1 -4
- package/dist/helpers/file-helpers.js +2 -2
- package/oclif.manifest.json +1 -1
- 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.6.0-alpha-8-alpha.
|
|
20
|
+
@contrail/cli/3.6.0-alpha-8-alpha.694fd70 linux-x64 node-v24.21.0
|
|
21
21
|
$ contrail --help [COMMAND]
|
|
22
22
|
USAGE
|
|
23
23
|
$ contrail COMMAND
|
package/dist/auth/login.js
CHANGED
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.getVersionFromPackageJson = exports.authUser = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const amazon_cognito_identity_js_1 = require("amazon-cognito-identity-js");
|
|
6
|
+
const inquirer_1 = tslib_1.__importDefault(require("inquirer"));
|
|
6
7
|
const sdk_1 = require("@contrail/sdk");
|
|
7
8
|
const config_1 = require("../helpers/config/config");
|
|
8
9
|
const logger_1 = tslib_1.__importDefault(require("../logger"));
|
|
@@ -62,7 +63,7 @@ exports.authUser = authUser;
|
|
|
62
63
|
async function getOrgSlug(config) {
|
|
63
64
|
const orgSlug = config?.orgSlug || process.env.CONTRAIL_CLI_ORG_SLUG;
|
|
64
65
|
if (!orgSlug) {
|
|
65
|
-
const answers = await
|
|
66
|
+
const answers = await inquirer_1.default.prompt([
|
|
66
67
|
{
|
|
67
68
|
type: 'input',
|
|
68
69
|
name: 'orgSlug',
|
|
@@ -105,7 +106,7 @@ async function authenticateWithUsernamePassword(config) {
|
|
|
105
106
|
message: 'Password',
|
|
106
107
|
});
|
|
107
108
|
}
|
|
108
|
-
const answers = await
|
|
109
|
+
const answers = await inquirer_1.default.prompt(questions);
|
|
109
110
|
const params = {
|
|
110
111
|
email: process.env.CONTRAIL_CLI_EMAIL || answers.email,
|
|
111
112
|
password: process.env.CONTRAIL_CLI_PASSWORD || answers.password,
|
package/dist/basecommand.js
CHANGED
|
@@ -3,8 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.BaseCommand = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const core_1 = require("@oclif/core");
|
|
6
|
-
const common_1 = require("./common");
|
|
7
6
|
const logger_1 = tslib_1.__importDefault(require("./logger"));
|
|
7
|
+
const inquirer_1 = tslib_1.__importDefault(require("inquirer"));
|
|
8
8
|
const config_1 = require("./helpers/config/config");
|
|
9
9
|
const lodash_1 = require("lodash");
|
|
10
10
|
const login_1 = require("./auth/login");
|
|
@@ -73,7 +73,7 @@ class BaseCommand extends core_1.Command {
|
|
|
73
73
|
choices: ['yes', 'no'],
|
|
74
74
|
default: 'no',
|
|
75
75
|
});
|
|
76
|
-
const { confirm } = await
|
|
76
|
+
const { confirm } = await inquirer_1.default.prompt(questions);
|
|
77
77
|
if (confirm === 'no') {
|
|
78
78
|
logger_1.default.info('Please use `contrail config use` command to choose the configuration or `contrail config set --environment=prod` to set different environment.');
|
|
79
79
|
this.exit(1);
|
|
@@ -23,7 +23,6 @@ export default class CreateEntity extends BaseCommand {
|
|
|
23
23
|
path: import("@oclif/core/lib/interfaces/parser").Arg<string, Record<string, unknown>>;
|
|
24
24
|
};
|
|
25
25
|
static strict: boolean;
|
|
26
|
-
init(): Promise<void>;
|
|
27
26
|
run(): Promise<void>;
|
|
28
27
|
}
|
|
29
28
|
export type CreateSummary = {
|
|
@@ -218,11 +218,8 @@ class CreateEntity extends basecommand_1.BaseCommand {
|
|
|
218
218
|
}),
|
|
219
219
|
};
|
|
220
220
|
static strict = false;
|
|
221
|
-
async init() {
|
|
222
|
-
(0, common_1.routeConsoleLogToStderr)();
|
|
223
|
-
await super.init();
|
|
224
|
-
}
|
|
225
221
|
async run() {
|
|
222
|
+
(0, common_1.routeConsoleLogToStderr)();
|
|
226
223
|
await (0, login_1.authUser)();
|
|
227
224
|
const { flags, argv, args } = await this.parse(CreateEntity);
|
|
228
225
|
const { count, dryRun: isDryRun, inputFile: inputFilename, outputFile: outputFilename, generateValues: shouldGenerateMissingValues, readableIds: shouldUseReadableIds, skipHydrateRelationships, suffix, apiVersion, } = flags;
|
|
@@ -374,6 +371,8 @@ function createEntityWithPopulatedValues(type, typeReferencesCache, objectRefere
|
|
|
374
371
|
// Handle property specifications
|
|
375
372
|
for (const [propertySlug, specifiedValue] of propertySpecificationBySlug.entries()) {
|
|
376
373
|
const correspondingProperty = type.typeProperties.find((prop) => getPropertySlug(prop) === propertySlug);
|
|
374
|
+
// slug= means unset; on create there is nothing to unset, so skip it.
|
|
375
|
+
// slug='""' is the empty string and is written like any other value.
|
|
377
376
|
if (specifiedValue === undefined) {
|
|
378
377
|
continue;
|
|
379
378
|
}
|
|
@@ -524,9 +523,6 @@ function generateRandomDateString() {
|
|
|
524
523
|
return new Date().toISOString();
|
|
525
524
|
}
|
|
526
525
|
function castValueToPropertyType(value, propertyType) {
|
|
527
|
-
if (Array.isArray(value) && propertyType !== types_1.PropertyType.MultiSelect) {
|
|
528
|
-
return value.map((element) => castValueToPropertyType(element, propertyType));
|
|
529
|
-
}
|
|
530
526
|
switch (propertyType) {
|
|
531
527
|
case types_1.PropertyType.Boolean:
|
|
532
528
|
return value.toString().toLowerCase() === 'true';
|
|
@@ -559,7 +555,7 @@ async function createEntity(entityName, entity, routing = {}) {
|
|
|
559
555
|
const skipHydrateRelationships = SHOULD_SKIP_HYDRATE_RELATIONSHIPS;
|
|
560
556
|
const { suffix, apiVersion } = routing;
|
|
561
557
|
if (entityName === 'assortment-item' && !suffix)
|
|
562
|
-
return (0, entities_1.createAssortmentItem)(entity, { skipHydrateRelationships
|
|
558
|
+
return (0, entities_1.createAssortmentItem)(entity, { skipHydrateRelationships }); // special case
|
|
563
559
|
const response = await client.create({
|
|
564
560
|
entityName,
|
|
565
561
|
object: entity,
|
|
@@ -532,10 +532,6 @@ describe('castValueToPropertyType array coercion', () => {
|
|
|
532
532
|
expect(consoleError).toHaveBeenCalledWith(expect.stringContaining('slug=option slug=family'));
|
|
533
533
|
consoleError.mockRestore();
|
|
534
534
|
});
|
|
535
|
-
it('should cast each element of a repeated-key array on scalar property types', () => {
|
|
536
|
-
expect((0, create_1.castValueToPropertyType)(['1', '2'], types_1.PropertyType.Number)).toEqual([1, 2]);
|
|
537
|
-
expect((0, create_1.castValueToPropertyType)(['true', 'false'], types_1.PropertyType.Boolean)).toEqual([true, false]);
|
|
538
|
-
});
|
|
539
535
|
it('should keep commas literal on string properties without warning', () => {
|
|
540
536
|
const consoleError = jest.spyOn(console, 'error').mockImplementation(() => undefined);
|
|
541
537
|
expect((0, create_1.castValueToPropertyType)('my,name', types_1.PropertyType.String)).toBe('my,name');
|
|
@@ -51,11 +51,8 @@ class DeleteEntity extends basecommand_1.BaseCommand {
|
|
|
51
51
|
}),
|
|
52
52
|
};
|
|
53
53
|
static strict = false;
|
|
54
|
-
async init() {
|
|
55
|
-
(0, common_1.routeConsoleLogToStderr)();
|
|
56
|
-
await super.init();
|
|
57
|
-
}
|
|
58
54
|
async run() {
|
|
55
|
+
(0, common_1.routeConsoleLogToStderr)();
|
|
59
56
|
await (0, login_1.authUser)();
|
|
60
57
|
const { args, flags, argv } = await this.parse(DeleteEntity);
|
|
61
58
|
const { entityName } = args;
|
|
@@ -117,7 +114,7 @@ async function deleteEntityByIds(entityName, ids, routing = {}) {
|
|
|
117
114
|
}
|
|
118
115
|
deletedIds.push(id);
|
|
119
116
|
}, (error) => {
|
|
120
|
-
if (error.message
|
|
117
|
+
if (error.message.includes('not found')) {
|
|
121
118
|
notFoundIds.push(id);
|
|
122
119
|
}
|
|
123
120
|
else {
|
|
@@ -83,11 +83,8 @@ class GetEntity extends basecommand_1.BaseCommand {
|
|
|
83
83
|
}),
|
|
84
84
|
};
|
|
85
85
|
static strict = false;
|
|
86
|
-
async init() {
|
|
87
|
-
(0, common_1.routeConsoleLogToStderr)();
|
|
88
|
-
await super.init();
|
|
89
|
-
}
|
|
90
86
|
async run() {
|
|
87
|
+
(0, common_1.routeConsoleLogToStderr)();
|
|
91
88
|
await (0, login_1.authUser)();
|
|
92
89
|
const { args, flags, argv } = await this.parse(GetEntity);
|
|
93
90
|
const { typePath } = args;
|
|
@@ -16,7 +16,6 @@ export default class UpdateEntity extends BaseCommand {
|
|
|
16
16
|
ids: import("@oclif/core/lib/interfaces/parser").Arg<string, Record<string, unknown>>;
|
|
17
17
|
};
|
|
18
18
|
static strict: boolean;
|
|
19
|
-
init(): Promise<void>;
|
|
20
19
|
run(): Promise<void>;
|
|
21
20
|
}
|
|
22
21
|
export type UpdateSummary = {
|
|
@@ -57,11 +57,8 @@ class UpdateEntity extends basecommand_1.BaseCommand {
|
|
|
57
57
|
}),
|
|
58
58
|
};
|
|
59
59
|
static strict = false;
|
|
60
|
-
async init() {
|
|
61
|
-
(0, common_1.routeConsoleLogToStderr)();
|
|
62
|
-
await super.init();
|
|
63
|
-
}
|
|
64
60
|
async run() {
|
|
61
|
+
(0, common_1.routeConsoleLogToStderr)();
|
|
65
62
|
await (0, login_1.authUser)();
|
|
66
63
|
const { args, argv } = await this.parse(UpdateEntity);
|
|
67
64
|
const { entityName } = args;
|
package/dist/common.d.ts
CHANGED
|
@@ -4,4 +4,3 @@ export declare function delay(ms: number): Promise<NodeJS.Timeout>;
|
|
|
4
4
|
export declare function removeSlash(string: string): string;
|
|
5
5
|
export declare function routeConsoleLogToStderr(): void;
|
|
6
6
|
export declare function sdkErrorMessage(reason: any): string;
|
|
7
|
-
export declare const promptOnStderr: any;
|
package/dist/common.js
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const inquirer_1 = tslib_1.__importDefault(require("inquirer"));
|
|
3
|
+
exports.sdkErrorMessage = exports.routeConsoleLogToStderr = exports.removeSlash = exports.delay = exports.getSeparatorByPlatform = void 0;
|
|
6
4
|
function getSeparatorByPlatform() {
|
|
7
5
|
const isWin = process.platform === 'win32';
|
|
8
6
|
const separator = isWin ? '\\' : '/';
|
|
@@ -30,6 +28,3 @@ function sdkErrorMessage(reason) {
|
|
|
30
28
|
return reason?.message || reason?.details || String(reason);
|
|
31
29
|
}
|
|
32
30
|
exports.sdkErrorMessage = sdkErrorMessage;
|
|
33
|
-
// inquirer renders prompt UI to its output stream directly, bypassing the
|
|
34
|
-
// console.log redirect; stdout must stay data-only
|
|
35
|
-
exports.promptOnStderr = inquirer_1.default.createPromptModule({ output: process.stderr });
|
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
import { Item } from '@contrail/entity-types';
|
|
2
|
-
import { API_VERSION } from '@contrail/sdk';
|
|
3
2
|
export declare function throwIfInvalidAssortmentId(assortmentId: string): Promise<void>;
|
|
4
3
|
export declare function createAssortmentItem(assortmentItem: {
|
|
5
4
|
assortmentId: string;
|
|
6
5
|
itemId: string;
|
|
7
6
|
[key: string]: any;
|
|
8
|
-
},
|
|
9
|
-
skipHydrateRelationships
|
|
10
|
-
apiVersion?: API_VERSION;
|
|
7
|
+
}, { skipHydrateRelationships }?: {
|
|
8
|
+
skipHydrateRelationships: boolean;
|
|
11
9
|
}): Promise<any>;
|
|
12
10
|
export declare function findItemsNotInAssortment(assortmentId: string, count?: number): Promise<Item[]>;
|
|
@@ -15,17 +15,15 @@ async function doesAssortmentExistById(id) {
|
|
|
15
15
|
const assortment = await client.get({ entityName: 'assortment', id });
|
|
16
16
|
return !!assortment;
|
|
17
17
|
}
|
|
18
|
-
async function createAssortmentItem(assortmentItem,
|
|
18
|
+
async function createAssortmentItem(assortmentItem, { skipHydrateRelationships } = { skipHydrateRelationships: false }) {
|
|
19
19
|
const client = new sdk_1.Entities();
|
|
20
20
|
const { assortmentId, itemId } = assortmentItem;
|
|
21
|
-
const { skipHydrateRelationships = false, apiVersion } = options;
|
|
22
21
|
// add item to assortment
|
|
23
22
|
await client.create({
|
|
24
23
|
entityName: 'assortment',
|
|
25
24
|
id: assortmentId,
|
|
26
25
|
relation: 'items',
|
|
27
26
|
object: { itemIds: [itemId] },
|
|
28
|
-
apiVersion,
|
|
29
27
|
});
|
|
30
28
|
// Update assortment item with properties
|
|
31
29
|
const updated = await client.update({
|
|
@@ -33,7 +31,6 @@ async function createAssortmentItem(assortmentItem, options = {}) {
|
|
|
33
31
|
id: `${assortmentId}:${itemId}`,
|
|
34
32
|
object: assortmentItem,
|
|
35
33
|
skipHydrateRelationships,
|
|
36
|
-
apiVersion,
|
|
37
34
|
});
|
|
38
35
|
return updated;
|
|
39
36
|
}
|
|
@@ -3,8 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.loadData = exports.saveData = exports.parseFileAsJsonArray = exports.parseCSVData = exports.safeFileOverwrite = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const path = tslib_1.__importStar(require("path"));
|
|
6
|
-
const common_1 = require("../common");
|
|
7
6
|
const fs_1 = tslib_1.__importDefault(require("fs"));
|
|
7
|
+
const inquirer_1 = tslib_1.__importDefault(require("inquirer"));
|
|
8
8
|
const js_yaml_1 = tslib_1.__importDefault(require("js-yaml"));
|
|
9
9
|
const logger_1 = tslib_1.__importDefault(require("../logger"));
|
|
10
10
|
const sync_1 = require("csv-parse/sync");
|
|
@@ -15,7 +15,7 @@ async function safeFileOverwrite(fileLocation, overwrite) {
|
|
|
15
15
|
logger_1.default.info(`overwriting ${fileLocation}`);
|
|
16
16
|
return true;
|
|
17
17
|
}
|
|
18
|
-
const answers = await
|
|
18
|
+
const answers = await inquirer_1.default.prompt([
|
|
19
19
|
{
|
|
20
20
|
type: 'confirm',
|
|
21
21
|
name: 'shouldOverwrite',
|
package/oclif.manifest.json
CHANGED