@constructor-io/constructorio-connect-cli 1.17.0 → 1.18.1
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 +26 -1
- package/boilerplate-repo/README.md +1 -1
- package/dist/commands/execute.d.ts.map +1 -1
- package/dist/commands/execute.js +5 -1
- package/dist/commands/generate-fixture.d.ts +8 -0
- package/dist/commands/generate-fixture.d.ts.map +1 -1
- package/dist/commands/generate-fixture.js +92 -34
- package/dist/functions/execute-template.d.ts.map +1 -1
- package/dist/functions/execute-template.js +3 -1
- package/dist/helpers/extract-template-engine.d.ts +8 -0
- package/dist/helpers/extract-template-engine.d.ts.map +1 -0
- package/dist/helpers/extract-template-engine.js +32 -0
- package/dist/helpers/file-loaders.d.ts +1 -1
- package/dist/helpers/file-loaders.d.ts.map +1 -1
- package/dist/helpers/file-loaders.js +2 -2
- package/dist/http/send-template-execute-request.d.ts +3 -2
- package/dist/http/send-template-execute-request.d.ts.map +1 -1
- package/dist/http/send-template-execute-request.js +3 -2
- package/dist/prompt-data/get-template-files.d.ts.map +1 -1
- package/dist/prompt-data/get-template-files.js +6 -1
- package/dist/prompt-data/select-connections.d.ts +1 -1
- package/dist/prompt-data/select-connections.d.ts.map +1 -1
- package/dist/prompt-data/select-connections.js +7 -1
- package/dist/types.d.ts +3 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +7 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/oclif.manifest.json +75 -3
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -108,6 +108,10 @@ EXAMPLES
|
|
|
108
108
|
|
|
109
109
|
$ constructorio-connect-cli execute --template-path=item/item.jsonata
|
|
110
110
|
|
|
111
|
+
$ constructorio-connect-cli execute --template-path=item/item.js
|
|
112
|
+
|
|
113
|
+
$ constructorio-connect-cli execute --template-path=item/item.ts
|
|
114
|
+
|
|
111
115
|
$ constructorio-connect-cli execute --template-path=variation/variation.jsonata
|
|
112
116
|
|
|
113
117
|
$ constructorio-connect-cli execute --template-path=item_group/item_group.jsonata --fixture-path=item_group.json
|
|
@@ -124,7 +128,18 @@ This command will fetch one fixture from the server and save it into a specified
|
|
|
124
128
|
|
|
125
129
|
```
|
|
126
130
|
USAGE
|
|
127
|
-
$ constructorio-connect-cli generate-fixture
|
|
131
|
+
$ constructorio-connect-cli generate-fixture [--connection <value>] [--type
|
|
132
|
+
item|variation|item_group|external_data|mapping] [--filename <value>] [--item-id <value>] [--variation-id <value>]
|
|
133
|
+
[--replace-file]
|
|
134
|
+
|
|
135
|
+
FLAGS
|
|
136
|
+
--connection=<value> The connection to generate the fixture for
|
|
137
|
+
--filename=<value> The name of the fixture file to generate
|
|
138
|
+
--item-id=<value> The ID of the item to generate the fixture for
|
|
139
|
+
--replace-file Whether to replace the fixture file if it already exists without asking
|
|
140
|
+
--type=<option> The type of fixture to generate
|
|
141
|
+
<options: item|variation|item_group|external_data|mapping>
|
|
142
|
+
--variation-id=<value> The ID of the variation to generate the fixture for (only applicable when --type=variation)
|
|
128
143
|
|
|
129
144
|
DESCRIPTION
|
|
130
145
|
This command will fetch one fixture from the server and save it into a specified file. This fixture file will be an
|
|
@@ -136,6 +151,16 @@ DESCRIPTION
|
|
|
136
151
|
|
|
137
152
|
EXAMPLES
|
|
138
153
|
$ constructorio-connect-cli generate-fixture
|
|
154
|
+
|
|
155
|
+
$ constructorio-connect-cli generate-fixture --connection=my-connection-id --type=item --filename=my-fixture.json
|
|
156
|
+
|
|
157
|
+
$ constructorio-connect-cli generate-fixture --connection=my-connection-id --type=variation --filename=my-fixture.json
|
|
158
|
+
|
|
159
|
+
$ constructorio-connect-cli generate-fixture --connection=my-connection-id --type=variation --item-id=123456789 --variation-id=987654321 --filename=my-fixture.json
|
|
160
|
+
|
|
161
|
+
$ constructorio-connect-cli generate-fixture --connection=my-connection-id --type=variation --item-id=123456789 --filename=my-fixture.json
|
|
162
|
+
|
|
163
|
+
$ constructorio-connect-cli generate-fixture --connection=my-connection-id --type=variation --filename=my-fixture.json --replace-file
|
|
139
164
|
```
|
|
140
165
|
|
|
141
166
|
|
|
@@ -164,7 +164,7 @@ By running `npm run test`, Jest will search for all files with the `.test.js` or
|
|
|
164
164
|
in the project and execute the corresponding tests.
|
|
165
165
|
|
|
166
166
|
As a best practice, you should have at least one snapshot test to ensure the result of your template.
|
|
167
|
-
You
|
|
167
|
+
You can also add any logical tests to cover any rules you add to your templates,
|
|
168
168
|
such as "calculating the average price of your variations".
|
|
169
169
|
If you need to, you can update your snapshots with the `--updateSnapshot` flag.
|
|
170
170
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"execute.d.ts","sourceRoot":"","sources":["../../src/commands/execute.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"execute.d.ts","sourceRoot":"","sources":["../../src/commands/execute.ts"],"names":[],"mappings":"AA0BA,OAAO,EAAE,yBAAyB,EAAE,MAAM,uBAAuB,CAAC;AAElE,eAAO,MAAM,qBAAqB;;;;;CAKxB,CAAC;AAEX;;;GAGG;AACH,UAAU,iBAAiB;IACzB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,eAAe,CAAC,EAAE,IAAI,CAAC;CACxB;AAaD,qBAAa,OAAQ,SAAQ,yBAAyB;IACpD,MAAM,CAAC,KAAK;;;;;;MAoBV;IAEF,MAAM,CAAC,WAAW,SACkK;IAEpL,MAAM,CAAC,QAAQ,WASb;IAEF,KAAK,EAAE,iBAAiB,CAAM;IAExB,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;YAoCnB,UAAU;YA0BV,oBAAoB;YAqDpB,wBAAwB;YA2BxB,wBAAwB;CAevC"}
|
package/dist/commands/execute.js
CHANGED
|
@@ -4,6 +4,7 @@ exports.Execute = exports.executePromptMessages = void 0;
|
|
|
4
4
|
const core_1 = require("@oclif/core");
|
|
5
5
|
const errors_1 = require("@oclif/core/errors");
|
|
6
6
|
const file_loaders_1 = require("../helpers/file-loaders");
|
|
7
|
+
const extract_template_engine_1 = require("../helpers/extract-template-engine");
|
|
7
8
|
const get_connections_request_1 = require("../http/get-connections-request");
|
|
8
9
|
const send_template_execute_request_1 = require("../http/send-template-execute-request");
|
|
9
10
|
const filter_connections_by_template_1 = require("../prompt-data/filter-connections-by-template");
|
|
@@ -48,6 +49,8 @@ class Execute extends refresh_connections_1.RefreshConnectionsCommand {
|
|
|
48
49
|
static examples = [
|
|
49
50
|
"$ <%= config.bin %> execute",
|
|
50
51
|
"$ <%= config.bin %> execute --template-path=item/item.jsonata",
|
|
52
|
+
"$ <%= config.bin %> execute --template-path=item/item.js",
|
|
53
|
+
"$ <%= config.bin %> execute --template-path=item/item.ts",
|
|
51
54
|
"$ <%= config.bin %> execute --template-path=variation/variation.jsonata",
|
|
52
55
|
"$ <%= config.bin %> execute --template-path=item_group/item_group.jsonata --fixture-path=item_group.json",
|
|
53
56
|
"$ <%= config.bin %> execute --template-path=grouping/grouping.jsonata --connection-id=example-connection-id",
|
|
@@ -61,7 +64,7 @@ class Execute extends refresh_connections_1.RefreshConnectionsCommand {
|
|
|
61
64
|
return await (0, config_1.getRepositoryConfigFile)();
|
|
62
65
|
})();
|
|
63
66
|
const result = await (0, send_template_execute_request_1.sendTemplateExecuteRequest)({
|
|
64
|
-
template: (0, file_loaders_1.
|
|
67
|
+
template: (0, file_loaders_1.getTemplate)(templateInput.templatePath).toString(),
|
|
65
68
|
helpers: (await (0, template_source_code_1.getHelpersSourceCode)(config.helpers)) ?? "",
|
|
66
69
|
data: (0, file_loaders_1.getCatalogFixture)(templateInput.fixturePath),
|
|
67
70
|
external: templateInput.externalPath
|
|
@@ -70,6 +73,7 @@ class Execute extends refresh_connections_1.RefreshConnectionsCommand {
|
|
|
70
73
|
connectionId: templateInput.connectionId,
|
|
71
74
|
templateType: (0, extract_template_type_1.extractTemplateType)(templateInput.templatePath),
|
|
72
75
|
overrideDate: templateInput.overrideDate,
|
|
76
|
+
engine: (0, extract_template_engine_1.extractTemplateEngine)(templateInput.templatePath),
|
|
73
77
|
});
|
|
74
78
|
(0, render_template_result_1.renderTemplateResult)(result);
|
|
75
79
|
if (result.warnings.length > 0) {
|
|
@@ -1,6 +1,14 @@
|
|
|
1
1
|
import { RefreshConnectionsCommand } from "./refresh-connections";
|
|
2
2
|
export default class GenerateFixture extends RefreshConnectionsCommand {
|
|
3
3
|
static args: {};
|
|
4
|
+
static flags: {
|
|
5
|
+
connection: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
6
|
+
type: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
7
|
+
filename: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
8
|
+
"item-id": import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
9
|
+
"variation-id": import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
10
|
+
"replace-file": import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
11
|
+
};
|
|
4
12
|
static description: string;
|
|
5
13
|
static examples: string[];
|
|
6
14
|
runCommand(): Promise<any>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate-fixture.d.ts","sourceRoot":"","sources":["../../src/commands/generate-fixture.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,yBAAyB,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"generate-fixture.d.ts","sourceRoot":"","sources":["../../src/commands/generate-fixture.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,yBAAyB,EAAE,MAAM,uBAAuB,CAAC;AAiBlE,MAAM,CAAC,OAAO,OAAO,eAAgB,SAAQ,yBAAyB;IACpE,MAAM,CAAC,IAAI,KAAM;IAEjB,MAAM,CAAC,KAAK;;;;;;;MAyCV;IAEF,MAAM,CAAC,WAAW,SACsgB;IAExhB,MAAM,CAAC,QAAQ,WAOb;IAEI,UAAU,IAAI,OAAO,CAAC,GAAG,CAAC;IAuGhC,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM;CAU9C"}
|
|
@@ -19,6 +19,7 @@ const check_if_connection_needs_mapping_1 = require("../helpers/check-if-connect
|
|
|
19
19
|
const select_connections_1 = require("../prompt-data/select-connections");
|
|
20
20
|
const refresh_connections_1 = require("./refresh-connections");
|
|
21
21
|
const kleur_1 = __importDefault(require("kleur"));
|
|
22
|
+
const core_2 = require("@oclif/core");
|
|
22
23
|
const SUPPORTED_PARTNERS = [
|
|
23
24
|
"akeneo",
|
|
24
25
|
"commercetools",
|
|
@@ -32,10 +33,57 @@ const SUPPORTED_FIXTURE_TYPES = [
|
|
|
32
33
|
];
|
|
33
34
|
class GenerateFixture extends refresh_connections_1.RefreshConnectionsCommand {
|
|
34
35
|
static args = {};
|
|
36
|
+
static flags = {
|
|
37
|
+
connection: core_2.Flags.string({
|
|
38
|
+
description: "The connection to generate the fixture for",
|
|
39
|
+
required: false,
|
|
40
|
+
}),
|
|
41
|
+
type: core_2.Flags.string({
|
|
42
|
+
description: "The type of fixture to generate",
|
|
43
|
+
options: Object.values(types_1.CatalogFixtureType),
|
|
44
|
+
required: false,
|
|
45
|
+
}),
|
|
46
|
+
filename: core_2.Flags.string({
|
|
47
|
+
description: "The name of the fixture file to generate",
|
|
48
|
+
required: false,
|
|
49
|
+
}),
|
|
50
|
+
["item-id"]: core_2.Flags.string({
|
|
51
|
+
description: "The ID of the item to generate the fixture for",
|
|
52
|
+
required: false,
|
|
53
|
+
}),
|
|
54
|
+
["variation-id"]: core_2.Flags.string({
|
|
55
|
+
description: "The ID of the variation to generate the fixture for (only applicable when --type=variation)",
|
|
56
|
+
required: false,
|
|
57
|
+
relationships: [
|
|
58
|
+
{
|
|
59
|
+
type: "some",
|
|
60
|
+
flags: [
|
|
61
|
+
{
|
|
62
|
+
name: "type",
|
|
63
|
+
when: async (flags) => flags.type === "variation",
|
|
64
|
+
},
|
|
65
|
+
],
|
|
66
|
+
},
|
|
67
|
+
],
|
|
68
|
+
}),
|
|
69
|
+
["replace-file"]: core_2.Flags.boolean({
|
|
70
|
+
description: "Whether to replace the fixture file if it already exists without asking",
|
|
71
|
+
required: false,
|
|
72
|
+
default: false,
|
|
73
|
+
}),
|
|
74
|
+
};
|
|
35
75
|
static description = "This command will fetch one fixture from the server and save it into a specified file. This fixture file will be an example of how the data would be passed to the connector when executing the templates.\n You are expected to customize this file to match the data you expect to cover in a template execution (e.g. an item with stock, a variation with missing data), etc. Note that you can have multiple fixtures of the same type to cover different scenarios.\n Finally, if the file already exists you'll be prompted to overwrite it.";
|
|
36
|
-
static examples = [
|
|
76
|
+
static examples = [
|
|
77
|
+
"$ <%= config.bin %> generate-fixture",
|
|
78
|
+
"$ <%= config.bin %> generate-fixture --connection=my-connection-id --type=item --filename=my-fixture.json",
|
|
79
|
+
"$ <%= config.bin %> generate-fixture --connection=my-connection-id --type=variation --filename=my-fixture.json",
|
|
80
|
+
"$ <%= config.bin %> generate-fixture --connection=my-connection-id --type=variation --item-id=123456789 --variation-id=987654321 --filename=my-fixture.json",
|
|
81
|
+
"$ <%= config.bin %> generate-fixture --connection=my-connection-id --type=variation --item-id=123456789 --filename=my-fixture.json",
|
|
82
|
+
"$ <%= config.bin %> generate-fixture --connection=my-connection-id --type=variation --filename=my-fixture.json --replace-file",
|
|
83
|
+
];
|
|
37
84
|
async runCommand() {
|
|
38
|
-
const
|
|
85
|
+
const { flags } = await this.parse(GenerateFixture);
|
|
86
|
+
const connection = await (0, select_connections_1.selectConnections)("Choose the connection to generate the fixture for", flags.connection);
|
|
39
87
|
const choices = Object.keys(types_1.CatalogFixtureType).map((catalogFixtureType) => ({
|
|
40
88
|
name: catalogFixtureType,
|
|
41
89
|
value: Object(types_1.CatalogFixtureType)[catalogFixtureType],
|
|
@@ -44,34 +92,42 @@ class GenerateFixture extends refresh_connections_1.RefreshConnectionsCommand {
|
|
|
44
92
|
const index = choices.findIndex((choice) => choice.value === "mapping");
|
|
45
93
|
choices.splice(index, 1);
|
|
46
94
|
}
|
|
47
|
-
const type =
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
95
|
+
const type = flags.type ||
|
|
96
|
+
(await (0, render_prompt_1.renderPrompt)({
|
|
97
|
+
promptMessage: "Choose the type of fixture you want to generate",
|
|
98
|
+
choices,
|
|
99
|
+
}));
|
|
100
|
+
const filename = flags.filename ||
|
|
101
|
+
(await (0, prompts_1.input)({
|
|
102
|
+
message: "Enter the filename",
|
|
103
|
+
default: `${type}.json`,
|
|
104
|
+
}));
|
|
55
105
|
const filepath = this.getFixturePath(type, filename);
|
|
56
106
|
const shouldAskReplace = (0, file_exists_1.fileExists)(filepath, true);
|
|
57
107
|
if (shouldAskReplace) {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
(0,
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
108
|
+
if (flags["replace-file"]) {
|
|
109
|
+
core_1.ux.stdout(kleur_1.default.yellow("⚠️ WARNING!") +
|
|
110
|
+
kleur_1.default.gray(` The file ${filepath} already exists and will be replaced without asking because you provided the --replace-file flag.`));
|
|
111
|
+
}
|
|
112
|
+
else {
|
|
113
|
+
const shouldRefresh = await (0, prompts_1.confirm)({
|
|
114
|
+
message: `This fixture already exists. Do you want to refresh it?`,
|
|
115
|
+
default: false,
|
|
116
|
+
});
|
|
117
|
+
if (!shouldRefresh) {
|
|
118
|
+
(0, render_tip_1.renderTip)([
|
|
119
|
+
"Your file was not refreshed!",
|
|
120
|
+
"If you want to generate the fixture, please execute the command again",
|
|
121
|
+
]);
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
68
124
|
}
|
|
69
125
|
}
|
|
70
126
|
const canUseLiveFixture = SUPPORTED_PARTNERS.includes(connection.partner) &&
|
|
71
127
|
SUPPORTED_FIXTURE_TYPES.includes(type);
|
|
72
128
|
if (canUseLiveFixture) {
|
|
73
129
|
try {
|
|
74
|
-
const { data } = await getLiveFixtureData(connection, type);
|
|
130
|
+
const { data } = await getLiveFixtureData(connection, type, flags["item-id"], flags["variation-id"]);
|
|
75
131
|
await (0, fs_extra_1.outputFile)(filepath, JSON.stringify(data, null, 2));
|
|
76
132
|
core_1.ux.stdout(`🎉 ${type} live fixture generated at ${filepath}`);
|
|
77
133
|
return;
|
|
@@ -105,12 +161,12 @@ class GenerateFixture extends refresh_connections_1.RefreshConnectionsCommand {
|
|
|
105
161
|
}
|
|
106
162
|
}
|
|
107
163
|
exports.default = GenerateFixture;
|
|
108
|
-
async function getLiveFixtureData(connection, type) {
|
|
164
|
+
async function getLiveFixtureData(connection, type, argItemId, argVariationId) {
|
|
109
165
|
switch (connection.partner) {
|
|
110
166
|
case "shopify":
|
|
111
167
|
core_1.ux.stdout(kleur_1.default.yellow("TIP!") + kleur_1.default.gray(" Provide a sanitized Product ID"));
|
|
112
|
-
core_1.ux.stdout(kleur_1.default.gray("
|
|
113
|
-
core_1.ux.stdout(kleur_1.default.gray("
|
|
168
|
+
core_1.ux.stdout(kleur_1.default.gray(" 123456789"));
|
|
169
|
+
core_1.ux.stdout(kleur_1.default.gray(" (we also support full id strings: gid://shopify/Product/123456789)"));
|
|
114
170
|
break;
|
|
115
171
|
case "akeneo":
|
|
116
172
|
core_1.ux.stdout(kleur_1.default.yellow("TIP!") +
|
|
@@ -121,9 +177,10 @@ async function getLiveFixtureData(connection, type) {
|
|
|
121
177
|
kleur_1.default.gray(" Provide the standard Product ID, which can be found in the URL of the product in the Merchant Center"));
|
|
122
178
|
break;
|
|
123
179
|
}
|
|
124
|
-
const id =
|
|
125
|
-
|
|
126
|
-
|
|
180
|
+
const id = argItemId ||
|
|
181
|
+
(await (0, prompts_1.input)({
|
|
182
|
+
message: "Enter the ID of the item you want to generate the fixture for",
|
|
183
|
+
}));
|
|
127
184
|
try {
|
|
128
185
|
let data;
|
|
129
186
|
try {
|
|
@@ -149,13 +206,14 @@ async function getLiveFixtureData(connection, type) {
|
|
|
149
206
|
acc[variation.__id] = variation;
|
|
150
207
|
return acc;
|
|
151
208
|
}, {});
|
|
152
|
-
const variationId =
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
209
|
+
const variationId = argVariationId ||
|
|
210
|
+
(await (0, render_prompt_1.renderPrompt)({
|
|
211
|
+
promptMessage: "The item you selected has more than 1 variation. Please select the variation you want to generate the fixture for:",
|
|
212
|
+
choices: Object.keys(variationsById).map((variationId) => ({
|
|
213
|
+
name: variationId,
|
|
214
|
+
value: variationId,
|
|
215
|
+
})),
|
|
216
|
+
}));
|
|
159
217
|
const variationWithItem = Object.assign({}, variationsById[variationId], {
|
|
160
218
|
__item: data,
|
|
161
219
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"execute-template.d.ts","sourceRoot":"","sources":["../../src/functions/execute-template.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"execute-template.d.ts","sourceRoot":"","sources":["../../src/functions/execute-template.ts"],"names":[],"mappings":"AAYA,eAAO,MAAM,YAAY,qEAMf,CAAC;AAEX,MAAM,WAAW,mBAAmB;IAClC,IAAI,EAAE,CAAC,OAAO,YAAY,CAAC,CAAC,MAAM,CAAC,CAAC;IACpC,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAClC,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACnC,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,YAAY,CAAC,EAAE,IAAI,CAAC;CACrB;AAED;;;;;;;;;;;GAWG;AACH,wBAAsB,eAAe,CAAC,OAAO,EAAE,mBAAmB,gCAyBjE"}
|
|
@@ -9,6 +9,7 @@ const os_1 = __importDefault(require("os"));
|
|
|
9
9
|
const path_1 = __importDefault(require("path"));
|
|
10
10
|
const config_1 = require("../customer/config");
|
|
11
11
|
const template_source_code_1 = require("../customer/template-source-code");
|
|
12
|
+
const extract_template_engine_1 = require("../helpers/extract-template-engine");
|
|
12
13
|
const file_loaders_1 = require("../helpers/file-loaders");
|
|
13
14
|
const print_warnings_1 = require("../helpers/print-warnings");
|
|
14
15
|
const get_connections_request_1 = require("../http/get-connections-request");
|
|
@@ -37,7 +38,7 @@ async function executeTemplate(options) {
|
|
|
37
38
|
const connection = await getConnection(options);
|
|
38
39
|
const config = await (0, config_1.getRepositoryConfigFile)();
|
|
39
40
|
const result = await (0, send_template_execute_request_1.sendTemplateExecuteRequest)({
|
|
40
|
-
template: (0, file_loaders_1.
|
|
41
|
+
template: (0, file_loaders_1.getTemplate)(name).toString(),
|
|
41
42
|
helpers: (await (0, template_source_code_1.getHelpersSourceCode)(config.helpers)) ?? "",
|
|
42
43
|
connectionId: connection.id,
|
|
43
44
|
templateType: options.type,
|
|
@@ -45,6 +46,7 @@ async function executeTemplate(options) {
|
|
|
45
46
|
showLogs: false,
|
|
46
47
|
external,
|
|
47
48
|
overrideDate,
|
|
49
|
+
engine: (0, extract_template_engine_1.extractTemplateEngine)(name),
|
|
48
50
|
});
|
|
49
51
|
if (!result.success) {
|
|
50
52
|
throw new Error(`Error executing template: ${result.error.message}`);
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type TemplatePath, type TemplateExecutionEngine } from "../types";
|
|
2
|
+
/**
|
|
3
|
+
* Extracts the template execution engine from the file extension.
|
|
4
|
+
* Throws if the extension is not a supported engine.
|
|
5
|
+
* Falls back to "jsonata" for files without an extension.
|
|
6
|
+
*/
|
|
7
|
+
export declare function extractTemplateEngine(templatePath: TemplatePath): TemplateExecutionEngine;
|
|
8
|
+
//# sourceMappingURL=extract-template-engine.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"extract-template-engine.d.ts","sourceRoot":"","sources":["../../src/helpers/extract-template-engine.ts"],"names":[],"mappings":"AAIA,OAAO,EAEL,KAAK,YAAY,EACjB,KAAK,uBAAuB,EAC7B,MAAM,UAAU,CAAC;AAMlB;;;;GAIG;AACH,wBAAgB,qBAAqB,CACnC,YAAY,EAAE,YAAY,GACzB,uBAAuB,CAsBzB"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.extractTemplateEngine = extractTemplateEngine;
|
|
7
|
+
const path_1 = __importDefault(require("path"));
|
|
8
|
+
const errors_1 = require("@oclif/core/errors");
|
|
9
|
+
const types_1 = require("../types");
|
|
10
|
+
function isSupportedEngine(ext) {
|
|
11
|
+
return types_1.SupportedTemplateExecutionEngines.includes(ext);
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Extracts the template execution engine from the file extension.
|
|
15
|
+
* Throws if the extension is not a supported engine.
|
|
16
|
+
* Falls back to "jsonata" for files without an extension.
|
|
17
|
+
*/
|
|
18
|
+
function extractTemplateEngine(templatePath) {
|
|
19
|
+
const ext = path_1.default.extname(templatePath).slice(1);
|
|
20
|
+
const basename = path_1.default.basename(templatePath);
|
|
21
|
+
const isDotfile = !ext && basename.startsWith(".");
|
|
22
|
+
if (isDotfile) {
|
|
23
|
+
throw new errors_1.CLIError(`Dotfiles are not supported as template paths: "${templatePath}".`);
|
|
24
|
+
}
|
|
25
|
+
if (!ext) {
|
|
26
|
+
return "jsonata";
|
|
27
|
+
}
|
|
28
|
+
if (isSupportedEngine(ext)) {
|
|
29
|
+
return ext;
|
|
30
|
+
}
|
|
31
|
+
throw new errors_1.CLIError(`Unsupported template engine: "${ext}". Supported engines: ${types_1.SupportedTemplateExecutionEngines.join(", ")}`);
|
|
32
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import fs from "fs-extra";
|
|
2
2
|
export declare const getCatalogFixture: (name: string, options?: fs.JsonReadOptions) => any;
|
|
3
3
|
export declare const getExternalFixture: (name: string, options?: fs.JsonReadOptions) => any;
|
|
4
|
-
export declare const
|
|
4
|
+
export declare const getTemplate: (name: string, options?: BufferEncoding | (fs.ObjectEncodingOptions & {
|
|
5
5
|
flag?: string | undefined;
|
|
6
6
|
}) | null | undefined) => string | Buffer<ArrayBufferLike>;
|
|
7
7
|
export declare function createFileLoader<T, S extends any[]>({ prefix, fileLoader, suggestions, }: Args<T, S>): (name: string, ...args: S) => T;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"file-loaders.d.ts","sourceRoot":"","sources":["../../src/helpers/file-loaders.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,MAAM,UAAU,CAAC;AAI1B,eAAO,MAAM,iBAAiB,SAqBP,MAAM,sCAjB3B,CAAC;AAEH,eAAO,MAAM,kBAAkB,SAeR,MAAM,sCAX3B,CAAC;AAEH,eAAO,MAAM,
|
|
1
|
+
{"version":3,"file":"file-loaders.d.ts","sourceRoot":"","sources":["../../src/helpers/file-loaders.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,MAAM,UAAU,CAAC;AAI1B,eAAO,MAAM,iBAAiB,SAqBP,MAAM,sCAjB3B,CAAC;AAEH,eAAO,MAAM,kBAAkB,SAeR,MAAM,sCAX3B,CAAC;AAEH,eAAO,MAAM,WAAW,SASD,MAAM;;0DAN3B,CAAC;AAEH,wBAAgB,gBAAgB,CAAC,CAAC,EAAE,CAAC,SAAS,GAAG,EAAE,EAAE,EACnD,MAAM,EACN,UAAU,EACV,WAAgB,GACjB,EAAE,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,CAAC,KAAK,CAAC,CAkB9C;AAED,UAAU,IAAI,CAAC,CAAC,EAAE,CAAC,SAAS,GAAG,EAAE;IAC/B,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC;IAC9C,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;CACxB"}
|
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
6
|
+
exports.getTemplate = exports.getExternalFixture = exports.getCatalogFixture = void 0;
|
|
7
7
|
exports.createFileLoader = createFileLoader;
|
|
8
8
|
const path_1 = __importDefault(require("path"));
|
|
9
9
|
const errors_1 = require("@oclif/core/errors");
|
|
@@ -19,7 +19,7 @@ exports.getExternalFixture = createFileLoader({
|
|
|
19
19
|
fileLoader: fs_extra_1.default.readJSONSync,
|
|
20
20
|
suggestions: ["Ensure the file is a valid JSON file"],
|
|
21
21
|
});
|
|
22
|
-
exports.
|
|
22
|
+
exports.getTemplate = createFileLoader({
|
|
23
23
|
prefix: path_1.default.join("src", "templates"),
|
|
24
24
|
fileLoader: fs_extra_1.default.readFileSync,
|
|
25
25
|
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { type TemplateExecutionSuccessResponse, type TemplateExecutionErrorResponse } from "../types";
|
|
2
|
-
export declare function sendTemplateExecuteRequest({ template, helpers, data, external, connectionId, templateType, showLogs, overrideDate, }: Args): Promise<TemplateExecutionSuccessResponse | TemplateExecutionErrorResponse>;
|
|
1
|
+
import { type TemplateExecutionSuccessResponse, type TemplateExecutionErrorResponse, type TemplateExecutionEngine } from "../types";
|
|
2
|
+
export declare function sendTemplateExecuteRequest({ template, helpers, data, external, connectionId, templateType, showLogs, overrideDate, engine, }: Args): Promise<TemplateExecutionSuccessResponse | TemplateExecutionErrorResponse>;
|
|
3
3
|
interface Args {
|
|
4
4
|
template: string;
|
|
5
5
|
helpers: string;
|
|
@@ -9,6 +9,7 @@ interface Args {
|
|
|
9
9
|
templateType: string;
|
|
10
10
|
showLogs?: boolean;
|
|
11
11
|
overrideDate?: Date;
|
|
12
|
+
engine: TemplateExecutionEngine;
|
|
12
13
|
}
|
|
13
14
|
export {};
|
|
14
15
|
//# sourceMappingURL=send-template-execute-request.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"send-template-execute-request.d.ts","sourceRoot":"","sources":["../../src/http/send-template-execute-request.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,KAAK,gCAAgC,EACrC,KAAK,8BAA8B,
|
|
1
|
+
{"version":3,"file":"send-template-execute-request.d.ts","sourceRoot":"","sources":["../../src/http/send-template-execute-request.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,KAAK,gCAAgC,EACrC,KAAK,8BAA8B,EACnC,KAAK,uBAAuB,EAC7B,MAAM,UAAU,CAAC;AAIlB,wBAAsB,0BAA0B,CAAC,EAC/C,QAAQ,EACR,OAAO,EACP,IAAI,EACJ,QAAQ,EACR,YAAY,EACZ,YAAY,EACZ,QAAe,EACf,YAAY,EACZ,MAAM,GACP,EAAE,IAAI,GAAG,OAAO,CACf,gCAAgC,GAAG,8BAA8B,CAClE,CAgCA;AAED,UAAU,IAAI;IACZ,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,GAAG,CAAC;IACV,QAAQ,EAAE,GAAG,CAAC;IACd,YAAY,EAAE,MAAM,CAAC;IACrB,YAAY,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,YAAY,CAAC,EAAE,IAAI,CAAC;IACpB,MAAM,EAAE,uBAAuB,CAAC;CACjC"}
|
|
@@ -5,7 +5,7 @@ const axios_1 = require("axios");
|
|
|
5
5
|
const errors_1 = require("@oclif/core/errors");
|
|
6
6
|
const ux_action_1 = require("../helpers/ux-action");
|
|
7
7
|
const http_client_1 = require("./http-client");
|
|
8
|
-
async function sendTemplateExecuteRequest({ template, helpers, data, external, connectionId, templateType, showLogs = true, overrideDate, }) {
|
|
8
|
+
async function sendTemplateExecuteRequest({ template, helpers, data, external, connectionId, templateType, showLogs = true, overrideDate, engine, }) {
|
|
9
9
|
const client = await (0, http_client_1.getHttpClient)();
|
|
10
10
|
const httpRequest = async () => {
|
|
11
11
|
return (await client.patch("templates/standalone/execute", {
|
|
@@ -15,7 +15,8 @@ async function sendTemplateExecuteRequest({ template, helpers, data, external, c
|
|
|
15
15
|
external,
|
|
16
16
|
connection_id: connectionId,
|
|
17
17
|
template_type: templateType,
|
|
18
|
-
|
|
18
|
+
override_date: overrideDate?.toISOString(),
|
|
19
|
+
engine,
|
|
19
20
|
})).data;
|
|
20
21
|
};
|
|
21
22
|
try {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-template-files.d.ts","sourceRoot":"","sources":["../../src/prompt-data/get-template-files.ts"],"names":[],"mappings":"AAGA,OAAO,
|
|
1
|
+
{"version":3,"file":"get-template-files.d.ts","sourceRoot":"","sources":["../../src/prompt-data/get-template-files.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,KAAK,aAAa,EAEnB,MAAM,UAAU,CAAC;AAWlB;;GAEG;AACH,wBAAsB,gBAAgB,IAAI,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC,CAevE"}
|
|
@@ -6,14 +6,19 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.getTemplateFiles = getTemplateFiles;
|
|
7
7
|
const path_1 = __importDefault(require("path"));
|
|
8
8
|
const find_deep_files_1 = require("../helpers/find-deep-files");
|
|
9
|
+
const types_1 = require("../types");
|
|
9
10
|
const path_2 = require("../customer/path");
|
|
11
|
+
const TEMPLATE_EXTENSIONS = new Set(types_1.SupportedTemplateExecutionEngines.map((ext) => `.${ext}`));
|
|
12
|
+
function hasSupportedExtension(file) {
|
|
13
|
+
return TEMPLATE_EXTENSIONS.has(path_1.default.extname(file));
|
|
14
|
+
}
|
|
10
15
|
/**
|
|
11
16
|
* Get a prompt-ready list of template files in the user repository
|
|
12
17
|
*/
|
|
13
18
|
async function getTemplateFiles() {
|
|
14
19
|
const filePath = path_1.default.join("src", "templates");
|
|
15
20
|
const files = getTemplatePaths(filePath);
|
|
16
|
-
const filteredFiles = files.filter((file) => file
|
|
21
|
+
const filteredFiles = files.filter((file) => hasSupportedExtension(file) && !file.includes("helpers"));
|
|
17
22
|
return filteredFiles.map((file) => {
|
|
18
23
|
const relativePath = (0, path_2.cleanupPath)(file);
|
|
19
24
|
return {
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const selectConnections: (message?: string) => Promise<import("../types").Connection>;
|
|
1
|
+
export declare const selectConnections: (message?: string, selectedConnectionId?: string) => Promise<import("../types").Connection>;
|
|
2
2
|
//# sourceMappingURL=select-connections.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"select-connections.d.ts","sourceRoot":"","sources":["../../src/prompt-data/select-connections.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,iBAAiB,GAC5B,UAAS,MAAgC,
|
|
1
|
+
{"version":3,"file":"select-connections.d.ts","sourceRoot":"","sources":["../../src/prompt-data/select-connections.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,iBAAiB,GAC5B,UAAS,MAAgC,EACzC,uBAAuB,MAAM,2CAoC9B,CAAC"}
|
|
@@ -5,13 +5,19 @@ const get_connections_request_1 = require("../http/get-connections-request");
|
|
|
5
5
|
const ux_action_1 = require("../helpers/ux-action");
|
|
6
6
|
const get_connect_token_1 = require("../customer/get-connect-token");
|
|
7
7
|
const render_prompt_1 = require("../prompt-data/render-prompt");
|
|
8
|
-
const selectConnections = async (message = "Choose the connection") => {
|
|
8
|
+
const selectConnections = async (message = "Choose the connection", selectedConnectionId) => {
|
|
9
9
|
const connections = await (0, ux_action_1.uxAction)("📡 Reading your connections...", async () => {
|
|
10
10
|
return await (0, get_connections_request_1.getConnections)({ showLogs: true });
|
|
11
11
|
})();
|
|
12
12
|
// Load the connect token to ensure we can authenticate with Constructor.
|
|
13
13
|
// We do this here because the terminal output gets weird when there is a prompt during a ux action.
|
|
14
14
|
await (0, get_connect_token_1.getConnectToken)();
|
|
15
|
+
if (selectedConnectionId) {
|
|
16
|
+
const selectedConnection = connections.find((connection) => connection.id === selectedConnectionId);
|
|
17
|
+
if (selectedConnection) {
|
|
18
|
+
return selectedConnection;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
15
21
|
const connectionId = await (0, render_prompt_1.renderPrompt)({
|
|
16
22
|
promptMessage: message,
|
|
17
23
|
choices: connections.map((connection) => ({
|
package/dist/types.d.ts
CHANGED
|
@@ -65,6 +65,9 @@ export declare enum CatalogFixtureType {
|
|
|
65
65
|
MAPPING = "mapping"
|
|
66
66
|
}
|
|
67
67
|
export declare const TemplateTypes: readonly ["item", "variation", "item_group", "grouping", "mapping"];
|
|
68
|
+
/** The supported template execution engines. The backend uses these to determine how to evaluate a template. */
|
|
69
|
+
export declare const SupportedTemplateExecutionEngines: readonly ["jsonata", "js", "ts"];
|
|
70
|
+
export type TemplateExecutionEngine = (typeof SupportedTemplateExecutionEngines)[number];
|
|
68
71
|
/**
|
|
69
72
|
* The unix relative path of a given template.
|
|
70
73
|
* With NO prefixed "/" or "./".
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,MAAM;IACrB,OAAO,EAAE,MAAM,GAAG,SAAS,CAAC;IAC5B,Y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AAM,EAAE,GAAG,CAAC,CAAC;IAC1B,QAAQ,EAAE,wBAAwB,EAAE,CAAC;CACtC;AAED,MAAM,WAAW,8BAA8B;IAC7C,OAAO,EAAE,KAAK,CAAC;IACf,KAAK,EAAE,aAAa,CAAC;IACrB,QAAQ,EAAE,wBAAwB,EAAE,CAAC;CACtC;AAED,oBAAY,kBAAkB;IAC5B,IAAI,SAAS;IACb,SAAS,cAAc;IACvB,UAAU,eAAe;IACzB,aAAa,kBAAkB;IAC/B,OAAO,YAAY;CACpB;AAED,eAAO,MAAM,aAAa,qEAMhB,CAAC;AAEX,gHAAgH;AAChH,eAAO,MAAM,iCAAiC,kCAIpC,CAAC;AAEX,MAAM,MAAM,uBAAuB,GACjC,CAAC,OAAO,iCAAiC,CAAC,CAAC,MAAM,CAAC,CAAC;AAErD;;;;;;;GAOG;AACH,MAAM,MAAM,YAAY,GAAG,MAAM,CAAC;AAElC,MAAM,MAAM,YAAY,GAAG,CAAC,OAAO,aAAa,CAAC,CAAC,MAAM,CAAC,CAAC"}
|
package/dist/types.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.TemplateTypes = exports.CatalogFixtureType = void 0;
|
|
3
|
+
exports.SupportedTemplateExecutionEngines = exports.TemplateTypes = exports.CatalogFixtureType = void 0;
|
|
4
4
|
var CatalogFixtureType;
|
|
5
5
|
(function (CatalogFixtureType) {
|
|
6
6
|
CatalogFixtureType["ITEM"] = "item";
|
|
@@ -16,3 +16,9 @@ exports.TemplateTypes = [
|
|
|
16
16
|
"grouping",
|
|
17
17
|
"mapping",
|
|
18
18
|
];
|
|
19
|
+
/** The supported template execution engines. The backend uses these to determine how to evaluate a template. */
|
|
20
|
+
exports.SupportedTemplateExecutionEngines = [
|
|
21
|
+
"jsonata",
|
|
22
|
+
"js",
|
|
23
|
+
"ts",
|
|
24
|
+
];
|
package/dist/version.d.ts
CHANGED
package/dist/version.js
CHANGED
package/oclif.manifest.json
CHANGED
|
@@ -53,6 +53,8 @@
|
|
|
53
53
|
"examples": [
|
|
54
54
|
"$ <%= config.bin %> execute",
|
|
55
55
|
"$ <%= config.bin %> execute --template-path=item/item.jsonata",
|
|
56
|
+
"$ <%= config.bin %> execute --template-path=item/item.js",
|
|
57
|
+
"$ <%= config.bin %> execute --template-path=item/item.ts",
|
|
56
58
|
"$ <%= config.bin %> execute --template-path=variation/variation.jsonata",
|
|
57
59
|
"$ <%= config.bin %> execute --template-path=item_group/item_group.jsonata --fixture-path=item_group.json",
|
|
58
60
|
"$ <%= config.bin %> execute --template-path=grouping/grouping.jsonata --connection-id=example-connection-id",
|
|
@@ -115,9 +117,79 @@
|
|
|
115
117
|
"args": {},
|
|
116
118
|
"description": "This command will fetch one fixture from the server and save it into a specified file. This fixture file will be an example of how the data would be passed to the connector when executing the templates.\n You are expected to customize this file to match the data you expect to cover in a template execution (e.g. an item with stock, a variation with missing data), etc. Note that you can have multiple fixtures of the same type to cover different scenarios.\n Finally, if the file already exists you'll be prompted to overwrite it.",
|
|
117
119
|
"examples": [
|
|
118
|
-
"$ <%= config.bin %> generate-fixture"
|
|
120
|
+
"$ <%= config.bin %> generate-fixture",
|
|
121
|
+
"$ <%= config.bin %> generate-fixture --connection=my-connection-id --type=item --filename=my-fixture.json",
|
|
122
|
+
"$ <%= config.bin %> generate-fixture --connection=my-connection-id --type=variation --filename=my-fixture.json",
|
|
123
|
+
"$ <%= config.bin %> generate-fixture --connection=my-connection-id --type=variation --item-id=123456789 --variation-id=987654321 --filename=my-fixture.json",
|
|
124
|
+
"$ <%= config.bin %> generate-fixture --connection=my-connection-id --type=variation --item-id=123456789 --filename=my-fixture.json",
|
|
125
|
+
"$ <%= config.bin %> generate-fixture --connection=my-connection-id --type=variation --filename=my-fixture.json --replace-file"
|
|
119
126
|
],
|
|
120
|
-
"flags": {
|
|
127
|
+
"flags": {
|
|
128
|
+
"connection": {
|
|
129
|
+
"description": "The connection to generate the fixture for",
|
|
130
|
+
"name": "connection",
|
|
131
|
+
"required": false,
|
|
132
|
+
"hasDynamicHelp": false,
|
|
133
|
+
"multiple": false,
|
|
134
|
+
"type": "option"
|
|
135
|
+
},
|
|
136
|
+
"type": {
|
|
137
|
+
"description": "The type of fixture to generate",
|
|
138
|
+
"name": "type",
|
|
139
|
+
"required": false,
|
|
140
|
+
"hasDynamicHelp": false,
|
|
141
|
+
"multiple": false,
|
|
142
|
+
"options": [
|
|
143
|
+
"item",
|
|
144
|
+
"variation",
|
|
145
|
+
"item_group",
|
|
146
|
+
"external_data",
|
|
147
|
+
"mapping"
|
|
148
|
+
],
|
|
149
|
+
"type": "option"
|
|
150
|
+
},
|
|
151
|
+
"filename": {
|
|
152
|
+
"description": "The name of the fixture file to generate",
|
|
153
|
+
"name": "filename",
|
|
154
|
+
"required": false,
|
|
155
|
+
"hasDynamicHelp": false,
|
|
156
|
+
"multiple": false,
|
|
157
|
+
"type": "option"
|
|
158
|
+
},
|
|
159
|
+
"item-id": {
|
|
160
|
+
"description": "The ID of the item to generate the fixture for",
|
|
161
|
+
"name": "item-id",
|
|
162
|
+
"required": false,
|
|
163
|
+
"hasDynamicHelp": false,
|
|
164
|
+
"multiple": false,
|
|
165
|
+
"type": "option"
|
|
166
|
+
},
|
|
167
|
+
"variation-id": {
|
|
168
|
+
"description": "The ID of the variation to generate the fixture for (only applicable when --type=variation)",
|
|
169
|
+
"name": "variation-id",
|
|
170
|
+
"relationships": [
|
|
171
|
+
{
|
|
172
|
+
"type": "some",
|
|
173
|
+
"flags": [
|
|
174
|
+
{
|
|
175
|
+
"name": "type"
|
|
176
|
+
}
|
|
177
|
+
]
|
|
178
|
+
}
|
|
179
|
+
],
|
|
180
|
+
"required": false,
|
|
181
|
+
"hasDynamicHelp": false,
|
|
182
|
+
"multiple": false,
|
|
183
|
+
"type": "option"
|
|
184
|
+
},
|
|
185
|
+
"replace-file": {
|
|
186
|
+
"description": "Whether to replace the fixture file if it already exists without asking",
|
|
187
|
+
"name": "replace-file",
|
|
188
|
+
"required": false,
|
|
189
|
+
"allowNo": false,
|
|
190
|
+
"type": "boolean"
|
|
191
|
+
}
|
|
192
|
+
},
|
|
121
193
|
"hasDynamicHelp": false,
|
|
122
194
|
"hiddenAliases": [],
|
|
123
195
|
"id": "generate-fixture",
|
|
@@ -207,5 +279,5 @@
|
|
|
207
279
|
]
|
|
208
280
|
}
|
|
209
281
|
},
|
|
210
|
-
"version": "1.
|
|
282
|
+
"version": "1.18.1"
|
|
211
283
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@constructor-io/constructorio-connect-cli",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.18.1",
|
|
4
4
|
"description": "CLI tool to enable users to interface with the Constructor Connect Ecosystem",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -92,7 +92,7 @@
|
|
|
92
92
|
"globals": "^16.0.0",
|
|
93
93
|
"jest": "^29.7.0",
|
|
94
94
|
"license-checker": "^25.0.1",
|
|
95
|
-
"markdownlint-cli2": "^0.
|
|
95
|
+
"markdownlint-cli2": "^0.22.0",
|
|
96
96
|
"mock-fs": "^5.2.0",
|
|
97
97
|
"nock": "14.0.11",
|
|
98
98
|
"oclif": "^4.17.42",
|