@constructor-io/constructorio-connect-cli 1.5.3 → 1.6.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.
@@ -10,7 +10,7 @@ export default class Init extends Command {
10
10
  private initGitRepoAndCommit;
11
11
  private updateRepo;
12
12
  private generateRepositoryFiles;
13
- static createNewRepository(newDir: string): void;
13
+ static createNewRepository(newDir: string, shouldCreateMappingTemplates: boolean): void;
14
14
  private static replacePackageName;
15
15
  private static replaceConfigValues;
16
16
  private printSuccessfulInitMessage;
@@ -1 +1 @@
1
- {"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../src/commands/init.ts"],"names":[],"mappings":"AAMA,OAAO,EAAQ,OAAO,EAAM,MAAM,aAAa,CAAC;AAyBhD,MAAM,CAAC,OAAO,OAAO,IAAK,SAAQ,OAAO;IACvC,MAAM,CAAC,WAAW,SAA4D;IAE9E,MAAM,CAAC,QAAQ,WAGb;IAEF,MAAM,CAAC,IAAI;;MAKT;IAEW,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;YA+BnB,UAAU;IAmBxB,OAAO,CAAC,oBAAoB;YAUd,UAAU;YAsBV,uBAAuB;WAwBvB,mBAAmB,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;IAKvD,OAAO,CAAC,MAAM,CAAC,kBAAkB;IAWjC,OAAO,CAAC,MAAM,CAAC,mBAAmB;IAuBlC,OAAO,CAAC,0BAA0B;CA4BnC"}
1
+ {"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../src/commands/init.ts"],"names":[],"mappings":"AAMA,OAAO,EAAQ,OAAO,EAAM,MAAM,aAAa,CAAC;AAyBhD,MAAM,CAAC,OAAO,OAAO,IAAK,SAAQ,OAAO;IACvC,MAAM,CAAC,WAAW,SAA4D;IAE9E,MAAM,CAAC,QAAQ,WAGb;IAEF,MAAM,CAAC,IAAI;;MAKT;IAEW,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;YA+BnB,UAAU;IAmBxB,OAAO,CAAC,oBAAoB;YAUd,UAAU;YAsBV,uBAAuB;WA+BvB,mBAAmB,CAC/B,MAAM,EAAE,MAAM,EACd,4BAA4B,EAAE,OAAO,GACpC,IAAI;IAcP,OAAO,CAAC,MAAM,CAAC,kBAAkB;IAWjC,OAAO,CAAC,MAAM,CAAC,mBAAmB;IAuBlC,OAAO,CAAC,0BAA0B;CA4BnC"}
@@ -129,10 +129,11 @@ class Init extends core_1.Command {
129
129
  async generateRepositoryFiles(args) {
130
130
  core_1.ux.log("\n");
131
131
  const connections = await (0, get_connections_request_1.getConnections)({ showLogs: true });
132
+ const shouldCreateMappingTemplates = connections.some((connection) => connection.partner === "omni");
132
133
  const connectionsDict = (0, build_config_file_1.buildConnectionsDictFromList)(connections);
133
- const config = (0, build_config_file_1.buildConfigFromConnections)(connections);
134
+ const config = (0, build_config_file_1.buildConfigFromConnections)(connections, shouldCreateMappingTemplates);
134
135
  (0, ux_action_1.uxAction)("🚀 Creating new Constructor.io Connect CLI repository", () => {
135
- Init.createNewRepository(args.repoPath);
136
+ Init.createNewRepository(args.repoPath, shouldCreateMappingTemplates);
136
137
  Init.replacePackageName(args.repoName, args.repoPath);
137
138
  })();
138
139
  (0, ux_action_1.uxAction)("📦 Installing dependencies", () => {
@@ -142,9 +143,17 @@ class Init extends core_1.Command {
142
143
  })();
143
144
  Init.replaceConfigValues(config, connectionsDict, args.repoPath);
144
145
  }
145
- static createNewRepository(newDir) {
146
+ static createNewRepository(newDir, shouldCreateMappingTemplates) {
146
147
  const repoDir = path.join(__dirname, BOILERPLATE_REPO_PATH);
147
- fs_extra_1.default.copySync(repoDir, newDir);
148
+ fs_extra_1.default.copySync(repoDir, newDir, {
149
+ filter: (file) => {
150
+ if (shouldCreateMappingTemplates) {
151
+ return true;
152
+ }
153
+ // Exclude mapping templates if the user doesn't have an Omni connector connection
154
+ return !file.includes("mapping");
155
+ },
156
+ });
148
157
  }
149
158
  static replacePackageName(name, repoPath) {
150
159
  const packageJsonPath = path.join(repoPath, "package.json");
@@ -1,6 +1,6 @@
1
1
  import { type ConnectionResponseDto } from "../http/get-connections-request";
2
2
  import { type Config, type ConnectionConfigDict } from "../types";
3
- export declare function buildConfigFromConnections(connections: ConnectionResponseDto[]): Config;
3
+ export declare function buildConfigFromConnections(connections: ConnectionResponseDto[], shouldCreateMappingTemplates: boolean): Config;
4
4
  export declare function buildConnectionsDictFromList(connections: ConnectionResponseDto[]): ConnectionConfigDict;
5
5
  export declare function buildConfigString(config: Config, connections: ConnectionConfigDict): string;
6
6
  //# sourceMappingURL=build-config-file.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"build-config-file.d.ts","sourceRoot":"","sources":["../../src/helpers/build-config-file.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,KAAK,qBAAqB,EAAE,MAAM,iCAAiC,CAAC;AAC7E,OAAO,EAAE,KAAK,MAAM,EAAE,KAAK,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAElE,wBAAgB,0BAA0B,CACxC,WAAW,EAAE,qBAAqB,EAAE,GACnC,MAAM,CAQR;AAED,wBAAgB,4BAA4B,CAC1C,WAAW,EAAE,qBAAqB,EAAE,wBAYrC;AAsDD,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,oBAAoB,GAChC,MAAM,CAmBR"}
1
+ {"version":3,"file":"build-config-file.d.ts","sourceRoot":"","sources":["../../src/helpers/build-config-file.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,KAAK,qBAAqB,EAAE,MAAM,iCAAiC,CAAC;AAC7E,OAAO,EAAE,KAAK,MAAM,EAAE,KAAK,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAElE,wBAAgB,0BAA0B,CACxC,WAAW,EAAE,qBAAqB,EAAE,EACpC,4BAA4B,EAAE,OAAO,GACpC,MAAM,CAYR;AAED,wBAAgB,4BAA4B,CAC1C,WAAW,EAAE,qBAAqB,EAAE,wBAYrC;AAmDD,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,oBAAoB,GAChC,MAAM,CAmBR"}
@@ -14,12 +14,12 @@ exports.buildConfigString = buildConfigString;
14
14
  * 4. Map each object in the environments array to expand out
15
15
  */
16
16
  const path_1 = __importDefault(require("path"));
17
- function buildConfigFromConnections(connections) {
17
+ function buildConfigFromConnections(connections, shouldCreateMappingTemplates) {
18
18
  const environments = getUniqueConnectionEnvs(connections);
19
19
  return {
20
20
  template_repository_version: "1.0.0",
21
21
  helpers: path_1.default.join("src", "templates", "helpers.jsonata"),
22
- environments: buildTemplateEnvironments(environments, connections),
22
+ environments: buildTemplateEnvironments(environments, connections, shouldCreateMappingTemplates),
23
23
  };
24
24
  }
25
25
  function buildConnectionsDictFromList(connections) {
@@ -41,7 +41,7 @@ function getUniqueConnectionEnvs(connections) {
41
41
  return envs;
42
42
  }, []);
43
43
  }
44
- function buildTemplateEnvironments(environments, connections) {
44
+ function buildTemplateEnvironments(environments, connections, shouldCreateMappingTemplates) {
45
45
  return environments.map((env) => {
46
46
  return {
47
47
  environment: env,
@@ -54,8 +54,9 @@ function buildTemplateEnvironments(environments, connections) {
54
54
  item: path_1.default.join("src", "templates", "item", "item.jsonata"),
55
55
  variation: path_1.default.join("src", "templates", "variation", "variation.jsonata"),
56
56
  item_group: path_1.default.join("src", "templates", "item_group", "item_group.jsonata"),
57
- grouping: path_1.default.join("src", "templates", "grouping", "grouping.jsonata"),
58
- mapping: path_1.default.join("src", "templates", "mapping", "mapping.jsonata"),
57
+ ...(shouldCreateMappingTemplates && {
58
+ mapping: path_1.default.join("src", "templates", "mapping", "mapping.jsonata"),
59
+ }),
59
60
  },
60
61
  },
61
62
  ],
package/dist/version.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- declare const _default: "1.5.3";
1
+ declare const _default: "1.6.0";
2
2
  export default _default;
3
3
  //# sourceMappingURL=version.d.ts.map
package/dist/version.js CHANGED
@@ -1,3 +1,3 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.default = '1.5.3';
3
+ exports.default = '1.6.0';
@@ -148,5 +148,5 @@
148
148
  ]
149
149
  }
150
150
  },
151
- "version": "1.5.3"
151
+ "version": "1.6.0"
152
152
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@constructor-io/constructorio-connect-cli",
3
- "version": "1.5.3",
3
+ "version": "1.6.0",
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",
@@ -1,37 +0,0 @@
1
- /*
2
- This template enables you to group variations together as items.
3
- It'll use the variation data and expect you to return the item structure, just like in the item template.
4
-
5
- When you use this template, a new item will be created for each unique ID that you return from this template,
6
- but any additional items returned with the same ID will be ignored.
7
-
8
- When creating new items, the base item information of the variation will be merged with the template result,
9
- effectively filling in fields that you don't return from the template.
10
-
11
- For example, suppose that you use the following logic to calculate the ID:
12
-
13
- ```
14
- {
15
- "id": $join([targetData.product_id, targetData.color])
16
- }
17
- ```
18
-
19
- Let's assume that you have an item with 3 variations, containing the respective data:
20
-
21
- 1. product_id: 1, color: red, size: S
22
- 2. product_id: 1, color: red, size: M
23
- 3. product_id: 1, color: blue, size: S
24
-
25
- The template will create 2 items:
26
-
27
- 1. id: 1-red
28
- 2. id: 1-blue
29
-
30
- And you can return any extra item field on the template to customize the item structure,
31
- allowing you to add any other pieces of information to the newly created items.
32
- */
33
-
34
- {
35
- "id": targetData.id,
36
- "item_name": targetData.name
37
- }
@@ -1,26 +0,0 @@
1
- import {
2
- executeTemplate,
3
- buildFixture,
4
- } from "@constructor-io/constructorio-connect-cli";
5
-
6
- describe("grouping", () => {
7
- it("should match inline snapshot", async () => {
8
- const result = await executeTemplate({
9
- type: "grouping",
10
- name: "grouping.jsonata",
11
- fixture: buildFixture("variation", "variation.json", {
12
- name: "New Variation Name",
13
- }),
14
- });
15
-
16
- // Alternatively, you can also store the snapshot in a file to reduce clutter.
17
- // expect(result).toMatchSnapshot();
18
-
19
- expect(result).toMatchInlineSnapshot(`
20
- {
21
- "id": "42-red",
22
- "item_name": "New Variation Name",
23
- }
24
- `);
25
- });
26
- });