@constructor-io/constructorio-connect-cli 1.5.1 → 1.5.3

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.
Files changed (34) hide show
  1. package/boilerplate-repo/test/templates/grouping/grouping.spec.mjs +1 -1
  2. package/boilerplate-repo/test/templates/item/item.spec.mjs +1 -1
  3. package/boilerplate-repo/test/templates/item_group/item_group.spec.mjs +1 -1
  4. package/boilerplate-repo/test/templates/mapping/mapping.spec.mjs +1 -1
  5. package/boilerplate-repo/test/templates/variation/variation.spec.mjs +1 -1
  6. package/dist/commands/execute.d.ts.map +1 -1
  7. package/dist/commands/generate-fixture.d.ts.map +1 -1
  8. package/dist/commands/generate-fixture.js +6 -2
  9. package/dist/commands/init.js +17 -7
  10. package/dist/customer/get-connect-token.js +17 -7
  11. package/dist/customer/path.d.ts.map +1 -1
  12. package/dist/customer/path.js +17 -4
  13. package/dist/functions/build-fixture.d.ts.map +1 -1
  14. package/dist/functions/build-fixture.js +5 -1
  15. package/dist/functions/execute-template.d.ts.map +1 -1
  16. package/dist/functions/execute-template.js +8 -2
  17. package/dist/helpers/build-config-file.d.ts +0 -7
  18. package/dist/helpers/build-config-file.d.ts.map +1 -1
  19. package/dist/helpers/build-config-file.js +17 -6
  20. package/dist/helpers/file-loaders.js +3 -3
  21. package/dist/http/http-client.js +17 -7
  22. package/dist/prompt-data/filter-connections-by-template.d.ts.map +1 -1
  23. package/dist/prompt-data/filter-connections-by-template.js +9 -3
  24. package/dist/prompt-data/get-candidate-fixtures.d.ts.map +1 -1
  25. package/dist/prompt-data/get-candidate-fixtures.js +3 -3
  26. package/dist/prompt-data/get-external-data-files.d.ts.map +1 -1
  27. package/dist/prompt-data/get-external-data-files.js +3 -2
  28. package/dist/prompt-data/get-template-files.d.ts.map +1 -1
  29. package/dist/prompt-data/get-template-files.js +9 -3
  30. package/dist/version.d.ts +1 -1
  31. package/dist/version.d.ts.map +1 -1
  32. package/dist/version.js +1 -1
  33. package/oclif.manifest.json +1 -1
  34. package/package.json +7 -6
@@ -4,7 +4,7 @@ import {
4
4
  } from "@constructor-io/constructorio-connect-cli";
5
5
 
6
6
  describe("grouping", () => {
7
- it("should match file snapshot", async () => {
7
+ it("should match inline snapshot", async () => {
8
8
  const result = await executeTemplate({
9
9
  type: "grouping",
10
10
  name: "grouping.jsonata",
@@ -4,7 +4,7 @@ import {
4
4
  } from "@constructor-io/constructorio-connect-cli";
5
5
 
6
6
  describe("item", () => {
7
- it("should match file snapshot", async () => {
7
+ it("should match inline snapshot", async () => {
8
8
  /**
9
9
  * Add a function `executeTemplate` which abstracts all the complexity from
10
10
  * running a template and gives you the result back.
@@ -4,7 +4,7 @@ import {
4
4
  } from "@constructor-io/constructorio-connect-cli";
5
5
 
6
6
  describe("item_group", () => {
7
- it("should match file snapshot", async () => {
7
+ it("should match inline snapshot", async () => {
8
8
  const result = await executeTemplate({
9
9
  type: "item_group",
10
10
  name: "item_group.jsonata",
@@ -4,7 +4,7 @@ import {
4
4
  } from "@constructor-io/constructorio-connect-cli";
5
5
 
6
6
  describe("mapping", () => {
7
- it("should match file snapshot", async () => {
7
+ it("should match inline snapshot", async () => {
8
8
  const result = await executeTemplate({
9
9
  type: "mapping",
10
10
  name: "mapping.jsonata",
@@ -4,7 +4,7 @@ import {
4
4
  } from "@constructor-io/constructorio-connect-cli";
5
5
 
6
6
  describe("variation", () => {
7
- it("should match file snapshot", async () => {
7
+ it("should match inline snapshot", async () => {
8
8
  const result = await executeTemplate({
9
9
  type: "variation",
10
10
  name: "variation.jsonata",
@@ -1 +1 @@
1
- {"version":3,"file":"execute.d.ts","sourceRoot":"","sources":["../../src/commands/execute.ts"],"names":[],"mappings":"AAAA,OAAO,EAAS,OAAO,EAAM,MAAM,aAAa,CAAC;AA6BjD,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;CAC/B;AAYD,qBAAa,OAAQ,SAAQ,OAAO;IAClC,MAAM,CAAC,KAAK;;;;;MAgBV;IAEF,MAAM,CAAC,WAAW,SACkK;IAEpL,MAAM,CAAC,QAAQ,WAOb;IAEF,KAAK,EAAE,iBAAiB,CAAM;IAExB,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;YAiCZ,UAAU;YAsBV,oBAAoB;YAgDpB,qBAAqB;YA0BrB,wBAAwB;CAevC"}
1
+ {"version":3,"file":"execute.d.ts","sourceRoot":"","sources":["../../src/commands/execute.ts"],"names":[],"mappings":"AAAA,OAAO,EAAS,OAAO,EAAM,MAAM,aAAa,CAAC;AA6BjD,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;CAC/B;AAYD,qBAAa,OAAQ,SAAQ,OAAO;IAClC,MAAM,CAAC,KAAK;;;;;MAgBV;IAEF,MAAM,CAAC,WAAW,SACkK;IAEpL,MAAM,CAAC,QAAQ,WAOb;IAEF,KAAK,EAAE,iBAAiB,CAAM;IAExB,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;YAiCZ,UAAU;YAsBV,oBAAoB;YA+CpB,qBAAqB;YA0BrB,wBAAwB;CAevC"}
@@ -1 +1 @@
1
- {"version":3,"file":"generate-fixture.d.ts","sourceRoot":"","sources":["../../src/commands/generate-fixture.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAM,MAAM,aAAa,CAAC;AAa1C,MAAM,CAAC,OAAO,OAAO,eAAgB,SAAQ,OAAO;IAClD,MAAM,CAAC,IAAI,KAAM;IAEjB,MAAM,CAAC,WAAW,SAIhB;IAEF,MAAM,CAAC,QAAQ,WAA4C;IAErD,GAAG,IAAI,OAAO,CAAC,GAAG,CAAC;IA6DzB,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM;CAK9C"}
1
+ {"version":3,"file":"generate-fixture.d.ts","sourceRoot":"","sources":["../../src/commands/generate-fixture.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAM,MAAM,aAAa,CAAC;AAa1C,MAAM,CAAC,OAAO,OAAO,eAAgB,SAAQ,OAAO;IAClD,MAAM,CAAC,IAAI,KAAM;IAEjB,MAAM,CAAC,WAAW,SAIhB;IAEF,MAAM,CAAC,QAAQ,WAA4C;IAErD,GAAG,IAAI,OAAO,CAAC,GAAG,CAAC;IA6DzB,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM;CAU9C"}
@@ -1,5 +1,9 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
+ const path_1 = __importDefault(require("path"));
3
7
  const core_1 = require("@oclif/core");
4
8
  const fs_extra_1 = require("fs-extra");
5
9
  const prompts_1 = require("@inquirer/prompts");
@@ -10,7 +14,7 @@ const types_1 = require("../types");
10
14
  const get_fixture_1 = require("../http/get-fixture");
11
15
  const get_connections_request_1 = require("../http/get-connections-request");
12
16
  const file_exists_1 = require("../helpers/file-exists");
13
- const path_1 = require("../customer/path");
17
+ const path_2 = require("../customer/path");
14
18
  class GenerateFixture extends core_1.Command {
15
19
  static args = {};
16
20
  static description = `
@@ -71,7 +75,7 @@ Finally, if the file already exists you'll be prompted to overwrite it.
71
75
  }
72
76
  }
73
77
  getFixturePath(type, filename) {
74
- return (0, path_1.getCustomerPath)(`src/fixtures/${type}/${filename.replace(/\.[^/.]+$/, "")}.json`);
78
+ return (0, path_2.getCustomerPath)(path_1.default.join("src", "fixtures", type, filename.replace(/\.[^/.]+$/, "") + ".json"));
75
79
  }
76
80
  }
77
81
  exports.default = GenerateFixture;
@@ -15,13 +15,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
15
15
  }) : function(o, v) {
16
16
  o["default"] = v;
17
17
  });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
25
35
  var __importDefault = (this && this.__importDefault) || function (mod) {
26
36
  return (mod && mod.__esModule) ? mod : { "default": mod };
27
37
  };
@@ -15,13 +15,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
15
15
  }) : function(o, v) {
16
16
  o["default"] = v;
17
17
  });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
25
35
  Object.defineProperty(exports, "__esModule", { value: true });
26
36
  exports.getConnectToken = void 0;
27
37
  exports.getConnectTokenStore = getConnectTokenStore;
@@ -1 +1 @@
1
- {"version":3,"file":"path.d.ts","sourceRoot":"","sources":["../../src/customer/path.ts"],"names":[],"mappings":"AAGA;;GAEG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,UAE3C;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,UAE3D;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,UAE1D;AAED;;;;;GAKG;AACH,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,UAE/D"}
1
+ {"version":3,"file":"path.d.ts","sourceRoot":"","sources":["../../src/customer/path.ts"],"names":[],"mappings":"AAIA;;GAEG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,UAE3C;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,UAI3D;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,UAI1D;AAED;;;;;GAKG;AACH,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,UAI/D"}
@@ -1,4 +1,7 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
6
  exports.getCustomerPath = getCustomerPath;
4
7
  exports.cleanupTemplatePath = cleanupTemplatePath;
@@ -6,6 +9,7 @@ exports.cleanupFixturePath = cleanupFixturePath;
6
9
  exports.cleanupExternalDataPath = cleanupExternalDataPath;
7
10
  /* eslint-disable @typescript-eslint/prefer-nullish-coalescing */
8
11
  const path_1 = require("path");
12
+ const os_1 = __importDefault(require("os"));
9
13
  /**
10
14
  * @returns The provided path prepended with the root directory.
11
15
  */
@@ -19,7 +23,7 @@ function getCustomerPath(path) {
19
23
  * be added later on when reading the files.
20
24
  */
21
25
  function cleanupTemplatePath(path) {
22
- return cleanupAbsolutePath(path).replace("/src/templates/", "");
26
+ return cleanupDelimiters(cleanupAbsolutePath(path).replace((0, path_1.join)("src", "templates"), ""));
23
27
  }
24
28
  /**
25
29
  * Cleans up the fixture path, removing the root directory and the 'src/fixtures' prefix.
@@ -28,7 +32,7 @@ function cleanupTemplatePath(path) {
28
32
  * be added later on when reading the files.
29
33
  */
30
34
  function cleanupFixturePath(path) {
31
- return cleanupAbsolutePath(path).replace("/src/fixtures/", "");
35
+ return cleanupDelimiters(cleanupAbsolutePath(path).replace((0, path_1.join)("src", "fixtures"), ""));
32
36
  }
33
37
  /**
34
38
  * Cleans up the external data path, removing the root directory and the 'src/external-data' prefix.
@@ -37,11 +41,20 @@ function cleanupFixturePath(path) {
37
41
  * be added later on when reading the files.
38
42
  */
39
43
  function cleanupExternalDataPath(path) {
40
- return cleanupAbsolutePath(path).replace("/src/external-data/", "");
44
+ return cleanupDelimiters(cleanupAbsolutePath(path).replace((0, path_1.join)("src", "external-data"), ""));
41
45
  }
42
46
  function cleanupAbsolutePath(path) {
43
47
  if (!path) {
44
48
  return "";
45
49
  }
46
- return path.replace(process.cwd(), "");
50
+ const replacedPath = path.replace(process.cwd(), "");
51
+ return cleanupDelimiters(replacedPath);
52
+ }
53
+ function cleanupDelimiters(path) {
54
+ const platformFileDelimiter = os_1.default.platform() === "win32" ? "\\" : "/";
55
+ let replacedPath = path.replace(process.cwd(), "");
56
+ if (replacedPath.startsWith(`${platformFileDelimiter}${platformFileDelimiter}`)) {
57
+ replacedPath = replacedPath.slice(2);
58
+ }
59
+ return replacedPath;
47
60
  }
@@ -1 +1 @@
1
- {"version":3,"file":"build-fixture.d.ts","sourceRoot":"","sources":["../../src/functions/build-fixture.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;GAUG;AACH,eAAO,MAAM,YAAY,SACjB,MAAM,QACN,MAAM,iBACE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,UAKtC,CAAC"}
1
+ {"version":3,"file":"build-fixture.d.ts","sourceRoot":"","sources":["../../src/functions/build-fixture.ts"],"names":[],"mappings":"AAMA;;;;;;;;;;GAUG;AACH,eAAO,MAAM,YAAY,SACjB,MAAM,QACN,MAAM,iBACE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,UAKtC,CAAC"}
@@ -1,6 +1,10 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
6
  exports.buildFixture = void 0;
7
+ const path_1 = __importDefault(require("path"));
4
8
  const remeda_1 = require("remeda");
5
9
  const file_loaders_1 = require("../helpers/file-loaders");
6
10
  /**
@@ -15,7 +19,7 @@ const file_loaders_1 = require("../helpers/file-loaders");
15
19
  * @returns Record<string, unknown> The fixture data
16
20
  */
17
21
  const buildFixture = (type, name, dataOverride = {}) => {
18
- const data = (0, file_loaders_1.getCatalogFixture)(`${type}/${name}`);
22
+ const data = (0, file_loaders_1.getCatalogFixture)(path_1.default.join(type, name));
19
23
  return (0, remeda_1.mergeDeep)(data, dataOverride);
20
24
  };
21
25
  exports.buildFixture = buildFixture;
@@ -1 +1 @@
1
- {"version":3,"file":"execute-template.d.ts","sourceRoot":"","sources":["../../src/functions/execute-template.ts"],"names":[],"mappings":"AASA,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,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACvC,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED;;;;;;;;;;;GAWG;AACH,wBAAsB,eAAe,CAAC,OAAO,EAAE,mBAAmB,gCAoBjE"}
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,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACvC,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED;;;;;;;;;;;GAWG;AACH,wBAAsB,eAAe,CAAC,OAAO,EAAE,mBAAmB,gCAoBjE"}
@@ -1,7 +1,12 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
6
  exports.TYPE_OPTIONS = void 0;
4
7
  exports.executeTemplate = executeTemplate;
8
+ const path_1 = __importDefault(require("path"));
9
+ const os_1 = __importDefault(require("os"));
5
10
  const send_template_execute_request_1 = require("../http/send-template-execute-request");
6
11
  const template_source_code_1 = require("../customer/template-source-code");
7
12
  const file_loaders_1 = require("../helpers/file-loaders");
@@ -56,8 +61,9 @@ function initializeOptions(options) {
56
61
  if (!options.name) {
57
62
  throw new Error("No name provided");
58
63
  }
59
- if (!options.name.includes("/")) {
60
- options.name = `${options.type}/${options.name}`;
64
+ const platformFileDelimiter = os_1.default.platform() === "win32" ? "\\" : "/";
65
+ if (!options.name.includes(platformFileDelimiter)) {
66
+ options.name = path_1.default.join(options.type, options.name);
61
67
  }
62
68
  if (!options.fixture) {
63
69
  options.fixture = {};
@@ -1,10 +1,3 @@
1
- /**
2
- * 1. Receive connections list, and transform it into the connections dictionary.
3
- * - Store only connectionId, name, and slug.
4
- * 2. Create the config object from a default config.
5
- * 3. Create a connections environments array by making a filtered array of connections for each environment.
6
- * 4. Map each object in the environments array to expand out
7
- */
8
1
  import { type ConnectionResponseDto } from "../http/get-connections-request";
9
2
  import { type Config, type ConnectionConfigDict } from "../types";
10
3
  export declare function buildConfigFromConnections(connections: ConnectionResponseDto[]): Config;
@@ -1 +1 @@
1
- {"version":3,"file":"build-config-file.d.ts","sourceRoot":"","sources":["../../src/helpers/build-config-file.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,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;AAkCD,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,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,13 +1,24 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
6
  exports.buildConfigFromConnections = buildConfigFromConnections;
4
7
  exports.buildConnectionsDictFromList = buildConnectionsDictFromList;
5
8
  exports.buildConfigString = buildConfigString;
9
+ /**
10
+ * 1. Receive connections list, and transform it into the connections dictionary.
11
+ * - Store only connectionId, name, and slug.
12
+ * 2. Create the config object from a default config.
13
+ * 3. Create a connections environments array by making a filtered array of connections for each environment.
14
+ * 4. Map each object in the environments array to expand out
15
+ */
16
+ const path_1 = __importDefault(require("path"));
6
17
  function buildConfigFromConnections(connections) {
7
18
  const environments = getUniqueConnectionEnvs(connections);
8
19
  return {
9
20
  template_repository_version: "1.0.0",
10
- helpers: "src/templates/helpers.jsonata",
21
+ helpers: path_1.default.join("src", "templates", "helpers.jsonata"),
11
22
  environments: buildTemplateEnvironments(environments, connections),
12
23
  };
13
24
  }
@@ -40,11 +51,11 @@ function buildTemplateEnvironments(environments, connections) {
40
51
  .filter((conn) => conn.environment === env)
41
52
  .map((conn) => conn.id),
42
53
  paths: {
43
- item: "src/templates/item/item.jsonata",
44
- variation: "src/templates/variation/variation.jsonata",
45
- item_group: "src/templates/item_group/item_group.jsonata",
46
- grouping: "src/templates/grouping/grouping.jsonata",
47
- mapping: "src/templates/mapping/mapping.jsonata",
54
+ item: path_1.default.join("src", "templates", "item", "item.jsonata"),
55
+ variation: path_1.default.join("src", "templates", "variation", "variation.jsonata"),
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"),
48
59
  },
49
60
  },
50
61
  ],
@@ -10,17 +10,17 @@ const errors_1 = require("@oclif/core/lib/errors");
10
10
  const fs_extra_1 = __importDefault(require("fs-extra"));
11
11
  const path_2 = require("../customer/path");
12
12
  exports.getCatalogFixture = createFileLoader({
13
- prefix: "src/fixtures",
13
+ prefix: path_1.default.join("src", "fixtures"),
14
14
  fileLoader: fs_extra_1.default.readJSONSync,
15
15
  suggestions: ["Ensure the file is a valid JSON file"],
16
16
  });
17
17
  exports.getExternalDataFixture = createFileLoader({
18
- prefix: "src/fixtures/external_data",
18
+ prefix: path_1.default.join("src", "fixtures", "external_data"),
19
19
  fileLoader: fs_extra_1.default.readJSONSync,
20
20
  suggestions: ["Ensure the file is a valid JSON file"],
21
21
  });
22
22
  exports.getJSONataTemplate = createFileLoader({
23
- prefix: "src/templates",
23
+ prefix: path_1.default.join("src", "templates"),
24
24
  fileLoader: fs_extra_1.default.readFileSync,
25
25
  });
26
26
  function createFileLoader({ prefix, fileLoader, suggestions = [], }) {
@@ -15,13 +15,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
15
15
  }) : function(o, v) {
16
16
  o["default"] = v;
17
17
  });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
25
35
  var __importDefault = (this && this.__importDefault) || function (mod) {
26
36
  return (mod && mod.__esModule) ? mod : { "default": mod };
27
37
  };
@@ -1 +1 @@
1
- {"version":3,"file":"filter-connections-by-template.d.ts","sourceRoot":"","sources":["../../src/prompt-data/filter-connections-by-template.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,qBAAqB,EAAE,MAAM,iCAAiC,CAAC;AAC7E,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,UAAU,CAAC;AAE9C;;;GAGG;AACH,wBAAsB,2BAA2B,CAC/C,YAAY,EAAE,MAAM,EACpB,WAAW,EAAE,qBAAqB,EAAE,GACnC,OAAO,CAAC,aAAa,CAAC,qBAAqB,CAAC,CAAC,CAmC/C"}
1
+ {"version":3,"file":"filter-connections-by-template.d.ts","sourceRoot":"","sources":["../../src/prompt-data/filter-connections-by-template.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,qBAAqB,EAAE,MAAM,iCAAiC,CAAC;AAC7E,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,UAAU,CAAC;AAE9C;;;GAGG;AACH,wBAAsB,2BAA2B,CAC/C,YAAY,EAAE,MAAM,EACpB,WAAW,EAAE,qBAAqB,EAAE,GACnC,OAAO,CAAC,aAAa,CAAC,qBAAqB,CAAC,CAAC,CA2C/C"}
@@ -12,13 +12,19 @@ const config_1 = require("../customer/config");
12
12
  */
13
13
  async function filterConnectionsByTemplate(templatePath, connections) {
14
14
  const config = await (0, config_1.getRepositoryConfigFile)();
15
- const fullPath = path_1.default.join("src/templates", templatePath);
15
+ const prefix = path_1.default.join("src", "templates");
16
+ let fullPath = templatePath;
17
+ if (!templatePath.startsWith(prefix)) {
18
+ fullPath = path_1.default.join(prefix, templatePath);
19
+ }
16
20
  // All connection ids that references this template
17
21
  const configConnectionIds = config.environments.reduce((connectionIds, environment) => {
18
22
  for (const templateConfig of environment.templates) {
19
- const templatePaths = Object.values(templateConfig.paths);
23
+ const templatePaths = Object.values(templateConfig.paths)
24
+ .map((filePath) => path_1.default.normalize(path_1.default.resolve(filePath)))
25
+ .map((filePath) => filePath.replace(/\\/g, "/")); // this is needed to check the path in all OS
20
26
  // environment doesn't even target this template
21
- if (!templatePaths.includes(fullPath)) {
27
+ if (!templatePaths.includes(path_1.default.resolve(fullPath).replace(/\\/g, "/"))) {
22
28
  continue;
23
29
  }
24
30
  for (const id of templateConfig.connection_ids) {
@@ -1 +1 @@
1
- {"version":3,"file":"get-candidate-fixtures.d.ts","sourceRoot":"","sources":["../../src/prompt-data/get-candidate-fixtures.ts"],"names":[],"mappings":"AAKA,OAAO,EAAoC,KAAK,aAAa,EAAE,MAAM,UAAU,CAAC;AAEhF,wBAAgB,oBAAoB,CAClC,YAAY,EAAE,MAAM,GACnB,aAAa,CAAC,MAAM,CAAC,CAkDvB"}
1
+ {"version":3,"file":"get-candidate-fixtures.d.ts","sourceRoot":"","sources":["../../src/prompt-data/get-candidate-fixtures.ts"],"names":[],"mappings":"AAKA,OAAO,EAAoC,KAAK,aAAa,EAAE,MAAM,UAAU,CAAC;AAEhF,wBAAgB,oBAAoB,CAClC,YAAY,EAAE,MAAM,GACnB,aAAa,CAAC,MAAM,CAAC,CAqDvB"}
@@ -25,7 +25,7 @@ function getCandidateFixtures(templatePath) {
25
25
  : templateType;
26
26
  let fixtureFullPaths;
27
27
  try {
28
- fixtureFullPaths = (0, find_deep_files_1.findDeepFiles)(`src/fixtures/${fixtureType}`);
28
+ fixtureFullPaths = (0, find_deep_files_1.findDeepFiles)(path_1.default.join("src", "fixtures", fixtureType));
29
29
  }
30
30
  catch (error) {
31
31
  if (error instanceof Error && error.message.includes("ENOENT")) {
@@ -41,7 +41,7 @@ function getCandidateFixtures(templatePath) {
41
41
  return fixtureFullPaths
42
42
  .filter((fixturePath) => path_1.default.extname(fixturePath) === ".json")
43
43
  .map((fixturePath) => {
44
- const fixtureRelativePath = path_1.default.relative("src/fixtures", fixturePath);
44
+ const fixtureRelativePath = path_1.default.relative(path_1.default.join("src", "fixtures"), fixturePath);
45
45
  return {
46
46
  name: fixtureRelativePath,
47
47
  value: fixtureRelativePath,
@@ -53,7 +53,7 @@ function getCandidateFixtures(templatePath) {
53
53
  */
54
54
  function extractTemplateType(templatePath) {
55
55
  for (const type of types_1.TemplateTypes) {
56
- if (templatePath.includes(`${type}/`)) {
56
+ if (templatePath.includes(path_1.default.join(`${type}/`))) {
57
57
  return type;
58
58
  }
59
59
  }
@@ -1 +1 @@
1
- {"version":3,"file":"get-external-data-files.d.ts","sourceRoot":"","sources":["../../src/prompt-data/get-external-data-files.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,UAAU,CAAC;AAE9C,wBAAgB,oBAAoB,IAAI,aAAa,CAAC,MAAM,CAAC,CAkB5D"}
1
+ {"version":3,"file":"get-external-data-files.d.ts","sourceRoot":"","sources":["../../src/prompt-data/get-external-data-files.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,UAAU,CAAC;AAE9C,wBAAgB,oBAAoB,IAAI,aAAa,CAAC,MAAM,CAAC,CAmB5D"}
@@ -8,10 +8,11 @@ const path_1 = __importDefault(require("path"));
8
8
  const find_deep_files_1 = require("../helpers/find-deep-files");
9
9
  function getExternalDataFiles() {
10
10
  try {
11
- return (0, find_deep_files_1.findDeepFiles)("src/fixtures/external_data")
11
+ const filePath = path_1.default.join("src", "fixtures", "external_data");
12
+ return (0, find_deep_files_1.findDeepFiles)(filePath)
12
13
  .filter((file) => path_1.default.extname(file) === ".json")
13
14
  .map((file) => {
14
- const relativePath = path_1.default.relative("src/fixtures/external_data", file);
15
+ const relativePath = path_1.default.relative(filePath, file);
15
16
  return {
16
17
  name: relativePath,
17
18
  value: relativePath,
@@ -1 +1 @@
1
- {"version":3,"file":"get-template-files.d.ts","sourceRoot":"","sources":["../../src/prompt-data/get-template-files.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,UAAU,CAAC;AAE9C;;GAEG;AACH,wBAAsB,gBAAgB,IAAI,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC,CAWvE"}
1
+ {"version":3,"file":"get-template-files.d.ts","sourceRoot":"","sources":["../../src/prompt-data/get-template-files.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,UAAU,CAAC;AAE9C;;GAEG;AACH,wBAAsB,gBAAgB,IAAI,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC,CAavE"}
@@ -1,16 +1,22 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
6
  exports.getTemplateFiles = getTemplateFiles;
7
+ const path_1 = __importDefault(require("path"));
4
8
  const find_deep_files_1 = require("../helpers/find-deep-files");
5
9
  /**
6
10
  * Get a prompt-ready list of template files in the user repository
7
11
  */
8
12
  async function getTemplateFiles() {
9
- const files = getTemplatePaths("src/templates");
13
+ const filePath = path_1.default.join("src", "templates");
14
+ const files = getTemplatePaths(filePath);
10
15
  const filteredFiles = files.filter((file) => file.endsWith(".jsonata") && !file.includes("helpers"));
16
+ const filePathSlash = path_1.default.join(filePath, " ").trim(); // needed to add a space to the end to avoid removing the last slash
11
17
  return filteredFiles.map((file) => ({
12
- name: file.replace("src/templates/", ""),
13
- value: file.replace("src/templates/", ""),
18
+ name: file.replace(filePathSlash, ""),
19
+ value: file.replace(filePathSlash, ""),
14
20
  }));
15
21
  }
16
22
  /**
package/dist/version.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- declare const _default: "1.5.1";
1
+ declare const _default: "1.5.3";
2
2
  export default _default;
3
3
  //# sourceMappingURL=version.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":";AAAA,wBAAuB"}
1
+ {"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":"wBAAe,OAAO;AAAtB,wBAAuB"}
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.1';
3
+ exports.default = '1.5.3';
@@ -148,5 +148,5 @@
148
148
  ]
149
149
  }
150
150
  },
151
- "version": "1.5.1"
151
+ "version": "1.5.3"
152
152
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@constructor-io/constructorio-connect-cli",
3
- "version": "1.5.1",
3
+ "version": "1.5.3",
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",
@@ -23,11 +23,11 @@
23
23
  "build": "tsc --project tsconfig.production.json",
24
24
  "prebuild": "shx rm -rf dist",
25
25
  "type-check": "tsc --noemit",
26
- "test": "TZ=UTC node --trace-warnings node_modules/.bin/jest",
27
- "test:verbose": "TZ=UTC VERBOSE=true jest",
28
- "test:debug": "TZ=UTC node --inspect-brk -r ts-node/register node_modules/.bin/jest --runInBand",
29
- "test:watch": "TZ=UTC jest --watch",
30
- "test:cov": "TZ=UTC jest --coverage",
26
+ "test": "cross-env TZ=UTC node --trace-warnings node_modules/.bin/jest",
27
+ "test:verbose": "cross-env TZ=UTC VERBOSE=true jest",
28
+ "test:debug": "cross-env TZ=UTC node --inspect-brk -r ts-node/register node_modules/.bin/jest --runInBand",
29
+ "test:watch": "cross-env TZ=UTC jest --watch",
30
+ "test:cov": "cross-env TZ=UTC jest --coverage",
31
31
  "lint": "eslint \"{src,apps,libs,test}/**/*.ts\"",
32
32
  "lint:fix": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix",
33
33
  "license-check": "license-checker --production --onlyAllow 'Apache-2.0;BSD-3-Clause;BSD-2-Clause;ISC;MIT;0BSD'",
@@ -79,6 +79,7 @@
79
79
  "@types/fs-extra": "^11.0.4",
80
80
  "@types/jest": "^29.5.12",
81
81
  "@types/mock-fs": "^4.13.4",
82
+ "cross-env": "^7.0.3",
82
83
  "eslint": "^8.57.0",
83
84
  "eslint-config-prettier": "^9.1.0",
84
85
  "eslint-config-standard-with-typescript": "^43.0.1",