@constructor-io/constructorio-connect-cli 1.12.2 → 1.12.4

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 (43) hide show
  1. package/dist/commands/execute.d.ts +1 -5
  2. package/dist/commands/execute.d.ts.map +1 -1
  3. package/dist/commands/execute.js +16 -25
  4. package/dist/commands/generate-fixture.js +2 -2
  5. package/dist/commands/refresh-connections-command.d.ts +9 -0
  6. package/dist/commands/refresh-connections-command.d.ts.map +1 -1
  7. package/dist/commands/refresh-connections-command.js +22 -1
  8. package/dist/customer/config.js +2 -2
  9. package/dist/customer/get-connect-token.d.ts.map +1 -1
  10. package/dist/customer/path.d.ts +17 -18
  11. package/dist/customer/path.d.ts.map +1 -1
  12. package/dist/customer/path.js +41 -41
  13. package/dist/customer/template-source-code.js +1 -1
  14. package/dist/functions/build-fixture.d.ts.map +1 -1
  15. package/dist/helpers/extract-template-type.d.ts +6 -0
  16. package/dist/helpers/extract-template-type.d.ts.map +1 -0
  17. package/dist/helpers/extract-template-type.js +23 -0
  18. package/dist/helpers/file-exists.d.ts.map +1 -1
  19. package/dist/helpers/file-exists.js +4 -2
  20. package/dist/helpers/file-loaders.d.ts.map +1 -1
  21. package/dist/helpers/file-loaders.js +4 -4
  22. package/dist/helpers/find-deep-files.d.ts.map +1 -1
  23. package/dist/helpers/find-deep-files.js +3 -2
  24. package/dist/helpers/prepend-file-sync.d.ts +7 -0
  25. package/dist/helpers/prepend-file-sync.d.ts.map +1 -0
  26. package/dist/helpers/prepend-file-sync.js +54 -0
  27. package/dist/helpers/refresh-connections-list.js +2 -2
  28. package/dist/helpers/ux-action.d.ts.map +1 -1
  29. package/dist/prompt-data/filter-connections-by-template.d.ts +2 -2
  30. package/dist/prompt-data/filter-connections-by-template.d.ts.map +1 -1
  31. package/dist/prompt-data/filter-connections-by-template.js +3 -13
  32. package/dist/prompt-data/get-candidate-fixtures.d.ts +5 -2
  33. package/dist/prompt-data/get-candidate-fixtures.d.ts.map +1 -1
  34. package/dist/prompt-data/get-candidate-fixtures.js +7 -23
  35. package/dist/prompt-data/get-template-files.d.ts.map +1 -1
  36. package/dist/prompt-data/get-template-files.js +8 -5
  37. package/dist/prompt-data/select-connections.d.ts.map +1 -1
  38. package/dist/types.d.ts +9 -0
  39. package/dist/types.d.ts.map +1 -1
  40. package/dist/version.d.ts +1 -1
  41. package/dist/version.js +1 -1
  42. package/oclif.manifest.json +1 -1
  43. package/package.json +1 -1
@@ -26,13 +26,9 @@ export declare class Execute extends RefreshConnectionsCommand {
26
26
  static examples: string[];
27
27
  input: ExecuteInputFlags;
28
28
  runCommand(): Promise<void>;
29
- /**
30
- * Returns the template type, which is always equal to the folder name of the template path.
31
- */
32
- private getTemplateType;
33
29
  private parseFlags;
34
30
  private getTemplateExecInput;
35
- private calculateConnectionId;
31
+ private validateAndGetConnection;
36
32
  private getConnectionForTemplate;
37
33
  }
38
34
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"execute.d.ts","sourceRoot":"","sources":["../../src/commands/execute.ts"],"names":[],"mappings":"AAgCA,OAAO,EAAE,yBAAyB,EAAE,MAAM,+BAA+B,CAAC;AAE1E,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,yBAAyB;IACpD,MAAM,CAAC,KAAK;;;;;MAgBV;IAEF,MAAM,CAAC,WAAW,SACkK;IAEpL,MAAM,CAAC,QAAQ,WAOb;IAEF,KAAK,EAAE,iBAAiB,CAAM;IAExB,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAkCjC;;OAEG;IACH,OAAO,CAAC,eAAe;YAKT,UAAU;YAsBV,oBAAoB;YA+CpB,qBAAqB;YA0BrB,wBAAwB;CAevC"}
1
+ {"version":3,"file":"execute.d.ts","sourceRoot":"","sources":["../../src/commands/execute.ts"],"names":[],"mappings":"AA4BA,OAAO,EAAE,yBAAyB,EAAE,MAAM,+BAA+B,CAAC;AAE1E,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,yBAAyB;IACpD,MAAM,CAAC,KAAK;;;;;MAgBV;IAEF,MAAM,CAAC,WAAW,SACkK;IAEpL,MAAM,CAAC,QAAQ,WAOb;IAEF,KAAK,EAAE,iBAAiB,CAAM;IAExB,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;YAkCnB,UAAU;YAsBV,oBAAoB;YAoDpB,wBAAwB;YA2BxB,wBAAwB;CAevC"}
@@ -1,18 +1,9 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
3
  exports.Execute = exports.executePromptMessages = void 0;
7
- const os_1 = __importDefault(require("os"));
8
4
  const core_1 = require("@oclif/core");
9
5
  const errors_1 = require("@oclif/core/lib/errors");
10
- const config_1 = require("../customer/config");
11
- const path_1 = require("../customer/path");
12
- const template_source_code_1 = require("../customer/template-source-code");
13
6
  const file_loaders_1 = require("../helpers/file-loaders");
14
- const print_warnings_1 = require("../helpers/print-warnings");
15
- const ux_action_1 = require("../helpers/ux-action");
16
7
  const get_connections_request_1 = require("../http/get-connections-request");
17
8
  const send_template_execute_request_1 = require("../http/send-template-execute-request");
18
9
  const filter_connections_by_template_1 = require("../prompt-data/filter-connections-by-template");
@@ -22,6 +13,12 @@ const get_template_files_1 = require("../prompt-data/get-template-files");
22
13
  const render_prompt_1 = require("../prompt-data/render-prompt");
23
14
  const render_repeat_input_1 = require("../rendering/render-repeat-input");
24
15
  const render_template_result_1 = require("../rendering/render-template-result");
16
+ const path_1 = require("../customer/path");
17
+ const config_1 = require("../customer/config");
18
+ const template_source_code_1 = require("../customer/template-source-code");
19
+ const ux_action_1 = require("../helpers/ux-action");
20
+ const print_warnings_1 = require("../helpers/print-warnings");
21
+ const extract_template_type_1 = require("../helpers/extract-template-type");
25
22
  const refresh_connections_command_1 = require("./refresh-connections-command");
26
23
  exports.executePromptMessages = {
27
24
  template: "Select a template to execute",
@@ -68,7 +65,7 @@ class Execute extends refresh_connections_command_1.RefreshConnectionsCommand {
68
65
  ? (0, file_loaders_1.getExternalDataFixture)(templateInput.externalDataPath)
69
66
  : {},
70
67
  connectionId: templateInput.connectionId,
71
- templateType: this.getTemplateType(templateInput.templatePath),
68
+ templateType: (0, extract_template_type_1.extractTemplateType)(templateInput.templatePath),
72
69
  });
73
70
  (0, render_template_result_1.renderTemplateResult)(result);
74
71
  if (result.warnings.length > 0) {
@@ -84,23 +81,16 @@ class Execute extends refresh_connections_command_1.RefreshConnectionsCommand {
84
81
  (0, render_repeat_input_1.renderRepeatInput)(this, this.input);
85
82
  }
86
83
  }
87
- /**
88
- * Returns the template type, which is always equal to the folder name of the template path.
89
- */
90
- getTemplateType(templatePath) {
91
- const platformFileDelimiter = os_1.default.platform() === "win32" ? "\\" : "/";
92
- return templatePath.split(platformFileDelimiter)?.[0];
93
- }
94
84
  async parseFlags() {
95
85
  const { flags } = await this.parse(Execute);
96
86
  if (flags["template-path"]) {
97
- this.input["template-path"] = (0, path_1.cleanupTemplatePath)(flags["template-path"]);
87
+ this.input["template-path"] = (0, path_1.cleanupPath)(flags["template-path"]);
98
88
  }
99
89
  if (flags["fixture-path"]) {
100
- this.input["fixture-path"] = (0, path_1.cleanupFixturePath)(flags["fixture-path"]);
90
+ this.input["fixture-path"] = (0, path_1.cleanupPath)(flags["fixture-path"]);
101
91
  }
102
92
  if (flags["external-data-path"]) {
103
- this.input["external-data-path"] = (0, path_1.cleanupExternalDataPath)(flags["external-data-path"]);
93
+ this.input["external-data-path"] = (0, path_1.cleanupPath)(flags["external-data-path"]);
104
94
  }
105
95
  if (flags["connection-id"]) {
106
96
  this.input["connection-id"] = flags["connection-id"];
@@ -112,9 +102,8 @@ class Execute extends refresh_connections_command_1.RefreshConnectionsCommand {
112
102
  });
113
103
  await this.parseFlags();
114
104
  if (!this.input["template-path"]) {
115
- const choices = await (0, get_template_files_1.getTemplateFiles)();
116
105
  this.input["template-path"] = await (0, render_prompt_1.renderPrompt)({
117
- choices,
106
+ choices: await (0, get_template_files_1.getTemplateFiles)(),
118
107
  promptMessage: exports.executePromptMessages.template,
119
108
  emptyMessage: "No templates found",
120
109
  });
@@ -136,7 +125,10 @@ class Execute extends refresh_connections_command_1.RefreshConnectionsCommand {
136
125
  });
137
126
  }
138
127
  }
139
- const connectionId = await this.calculateConnectionId(allConnections, this.input["template-path"]);
128
+ const connectionId = await this.validateAndGetConnection(allConnections, this.input["template-path"]);
129
+ // Let's make sure to re-set the input value since the user might
130
+ // have just chosen one
131
+ this.input["connection-id"] = connectionId;
140
132
  return {
141
133
  templatePath: this.input["template-path"],
142
134
  fixturePath: this.input["fixture-path"],
@@ -144,7 +136,7 @@ class Execute extends refresh_connections_command_1.RefreshConnectionsCommand {
144
136
  connectionId,
145
137
  };
146
138
  }
147
- async calculateConnectionId(allConnections, templatePath) {
139
+ async validateAndGetConnection(allConnections, templatePath) {
148
140
  let connection = allConnections.find((c) => c.id === this.input["connection-id"]);
149
141
  if (this.input["connection-id"] && !connection) {
150
142
  throw new errors_1.CLIError(`Connection with ID ${this.input["connection-id"]} not found`, {
@@ -153,7 +145,6 @@ class Execute extends refresh_connections_command_1.RefreshConnectionsCommand {
153
145
  }
154
146
  if (!connection) {
155
147
  connection = await this.getConnectionForTemplate(templatePath, allConnections);
156
- this.input["connection-id"] = connection.id;
157
148
  }
158
149
  return connection.id;
159
150
  }
@@ -12,10 +12,10 @@ const file_exists_1 = require("../helpers/file-exists");
12
12
  const ux_action_1 = require("../helpers/ux-action");
13
13
  const get_fixture_1 = require("../http/get-fixture");
14
14
  const render_prompt_1 = require("../prompt-data/render-prompt");
15
- const select_connections_1 = require("../prompt-data/select-connections");
16
15
  const render_tip_1 = require("../rendering/render-tip");
17
16
  const types_1 = require("../types");
18
17
  const check_if_connection_needs_mapping_1 = require("../helpers/check-if-connection-needs-mapping");
18
+ const select_connections_1 = require("../prompt-data/select-connections");
19
19
  const refresh_connections_command_1 = require("./refresh-connections-command");
20
20
  class GenerateFixture extends refresh_connections_command_1.RefreshConnectionsCommand {
21
21
  static args = {};
@@ -73,7 +73,7 @@ Finally, if the file already exists you'll be prompted to overwrite it.
73
73
  }
74
74
  }
75
75
  getFixturePath(type, filename) {
76
- return (0, path_2.getCustomerPath)(path_1.default.join("src", "fixtures", type, filename.replace(/\.[^/.]+$/, "") + ".json"));
76
+ return (0, path_2.getCustomerOSSpecificPath)(path_1.default.join("src", "fixtures", type, filename.replace(/\.[^/.]+$/, "") + ".json"));
77
77
  }
78
78
  }
79
79
  exports.default = GenerateFixture;
@@ -2,5 +2,14 @@ import { Command } from "@oclif/core";
2
2
  export declare abstract class RefreshConnectionsCommand extends Command {
3
3
  abstract runCommand(): Promise<any>;
4
4
  run(): Promise<any>;
5
+ /**
6
+ * Checks if the connections list should be automatically refreshed if
7
+ * 1) IS_CI environment variable is not true; and
8
+ * 2) AUTO_REFRESH_CONNECTIONS environment variable set to "true", true,
9
+ * or if it is undefined (in which case it will be set to true).
10
+ *
11
+ * @returns {boolean} - true if the connections list should be refreshed, false otherwise.
12
+ */
13
+ private shouldAutoRefreshConnections;
5
14
  }
6
15
  //# sourceMappingURL=refresh-connections-command.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"refresh-connections-command.d.ts","sourceRoot":"","sources":["../../src/commands/refresh-connections-command.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAItC,8BAAsB,yBAA0B,SAAQ,OAAO;IAC7D,QAAQ,CAAC,UAAU,IAAI,OAAO,CAAC,GAAG,CAAC;IAE7B,GAAG,IAAI,OAAO,CAAC,GAAG,CAAC;CAM1B"}
1
+ {"version":3,"file":"refresh-connections-command.d.ts","sourceRoot":"","sources":["../../src/commands/refresh-connections-command.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAKtC,8BAAsB,yBAA0B,SAAQ,OAAO;IAC7D,QAAQ,CAAC,UAAU,IAAI,OAAO,CAAC,GAAG,CAAC;IAE7B,GAAG,IAAI,OAAO,CAAC,GAAG,CAAC;IAOzB;;;;;;;OAOG;IACH,OAAO,CAAC,4BAA4B;CAerC"}
@@ -3,12 +3,33 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.RefreshConnectionsCommand = void 0;
4
4
  const core_1 = require("@oclif/core");
5
5
  const refresh_connections_list_1 = require("../helpers/refresh-connections-list");
6
+ const prepend_file_sync_1 = require("../helpers/prepend-file-sync");
6
7
  class RefreshConnectionsCommand extends core_1.Command {
7
8
  async run() {
8
- if (!process.env.IS_CI && process.env.AUTO_REFRESH_CONNECTIONS) {
9
+ if (this.shouldAutoRefreshConnections()) {
9
10
  await (0, refresh_connections_list_1.refreshConnectionsList)();
10
11
  }
11
12
  return await this.runCommand();
12
13
  }
14
+ /**
15
+ * Checks if the connections list should be automatically refreshed if
16
+ * 1) IS_CI environment variable is not true; and
17
+ * 2) AUTO_REFRESH_CONNECTIONS environment variable set to "true", true,
18
+ * or if it is undefined (in which case it will be set to true).
19
+ *
20
+ * @returns {boolean} - true if the connections list should be refreshed, false otherwise.
21
+ */
22
+ shouldAutoRefreshConnections() {
23
+ if (process.env.IS_CI === "true") {
24
+ return false;
25
+ }
26
+ if (process.env.AUTO_REFRESH_CONNECTIONS === undefined) {
27
+ (0, prepend_file_sync_1.prependFileSync)(".env", `AUTO_REFRESH_CONNECTIONS=true\n`);
28
+ // Manually set it to true otherwise any access to it within
29
+ // the same process will be outdated (will still return undefined)
30
+ process.env.AUTO_REFRESH_CONNECTIONS = "true";
31
+ }
32
+ return process.env.AUTO_REFRESH_CONNECTIONS === "true";
33
+ }
13
34
  }
14
35
  exports.RefreshConnectionsCommand = RefreshConnectionsCommand;
@@ -47,7 +47,7 @@ const path_1 = require("./path");
47
47
  * If the file is not found, it throws a CLIError with a message indicating the expected path.
48
48
  */
49
49
  async function getRepositoryConfigFile() {
50
- const configPath = (0, path_1.getCustomerPath)("connectrc.js");
50
+ const configPath = (0, path_1.getCustomerOSSpecificPath)("connectrc.js");
51
51
  try {
52
52
  return require(configPath);
53
53
  }
@@ -81,7 +81,7 @@ pointing to the correct connectrc.js directory.`,
81
81
  * @returns The connections object and the content of the connectrc.js file in {@link RawConfigContent}
82
82
  */
83
83
  async function getRepositoryConnectionsAndConfig() {
84
- const configPath = (0, path_1.getCustomerPath)("connectrc.js");
84
+ const configPath = (0, path_1.getCustomerOSSpecificPath)("connectrc.js");
85
85
  const fileContent = await readRawConfigFile(configPath);
86
86
  // Get the connections object from the content of the connectrc.js file
87
87
  const configMatch = fileContent.match(/const\s+connections\s*=\s*({[\s\S]*?});/);
@@ -1 +1 @@
1
- {"version":3,"file":"get-connect-token.d.ts","sourceRoot":"","sources":["../../src/customer/get-connect-token.ts"],"names":[],"mappings":"AASA;;;;;;;;;;;GAWG;AACH,wBAAgB,oBAAoB,eAIvB,OAAO,KACf,OAAO,CAAC,MAAM,CAAC,CAyCnB;AAED,eAAO,MAAM,eAAe,aA5Cf,OAAO,KACf,OAAO,CAAC,MAAM,CA2CkC,CAAC"}
1
+ {"version":3,"file":"get-connect-token.d.ts","sourceRoot":"","sources":["../../src/customer/get-connect-token.ts"],"names":[],"mappings":"AASA;;;;;;;;;;;GAWG;AACH,wBAAgB,oBAAoB,KAIhC,UAAS,OAAc,KACtB,OAAO,CAAC,MAAM,CAAC,CAyCnB;AAED,eAAO,MAAM,eAAe,aA5Cf,OAAO,KACf,OAAO,CAAC,MAAM,CA2CkC,CAAC"}
@@ -1,26 +1,25 @@
1
1
  /**
2
- * @returns The provided path prepended with the root directory.
3
- */
4
- export declare function getCustomerPath(path: string): string;
5
- /**
6
- * Cleans up the template path, removing the root directory and the 'src/templates' prefix.
2
+ * @returns The provided path prepended with the root directory - in the user's OS path pattern.
7
3
  *
8
- * This is needed to support the use of absolute paths in the templates, since those will
9
- * be added later on when reading the files.
4
+ * E.g. Unix: /path/to/file
5
+ * E.g. Windows: C:\path\to\file
10
6
  */
11
- export declare function cleanupTemplatePath(path: string | undefined): string;
7
+ export declare function getCustomerOSSpecificPath(path: string): string;
12
8
  /**
13
- * Cleans up the fixture path, removing the root directory and the 'src/fixtures' prefix.
9
+ * Receives either a relative or absolute path for a given template file.
14
10
  *
15
- * This is needed to support the use of absolute paths in the templates, since those will
16
- * be added later on when reading the files.
17
- */
18
- export declare function cleanupFixturePath(path: string | undefined): string;
19
- /**
20
- * Cleans up the external data path, removing the root directory and the 'src/external-data' prefix.
11
+ * Unix
12
+ * - src/templates/variation/variation.jsonata
13
+ * - ./src/templates/variation/variation.jsonata
14
+ * - /usr/username/templates-folder/src/templates/variation/variation.jsonata
15
+ *
16
+ * Windows
17
+ * - src\templates\variation\variation.jsonata
18
+ * - .\src\templates\variation\variation.jsonata
19
+ * - C:\users\username\templates-folder\src\templates\variation\variation.jsonata
21
20
  *
22
- * This is needed to support the use of absolute paths in the templates, since those will
23
- * be added later on when reading the files.
21
+ * And returns a relative unix path WITHOUT its type prefix (e.g "src/templates"), like so:
22
+ * - variation/variation.jsonata
24
23
  */
25
- export declare function cleanupExternalDataPath(path: string | undefined): string;
24
+ export declare function cleanupPath(filePath: string | undefined): string;
26
25
  //# sourceMappingURL=path.d.ts.map
@@ -1 +1 @@
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
+ {"version":3,"file":"path.d.ts","sourceRoot":"","sources":["../../src/customer/path.ts"],"names":[],"mappings":"AAGA;;;;;GAKG;AACH,wBAAgB,yBAAyB,CAAC,IAAI,EAAE,MAAM,UAErD;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,WAAW,CAAC,QAAQ,EAAE,MAAM,GAAG,SAAS,UAiCvD"}
@@ -1,59 +1,59 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.getCustomerPath = getCustomerPath;
7
- exports.cleanupTemplatePath = cleanupTemplatePath;
8
- exports.cleanupFixturePath = cleanupFixturePath;
9
- exports.cleanupExternalDataPath = cleanupExternalDataPath;
3
+ exports.getCustomerOSSpecificPath = getCustomerOSSpecificPath;
4
+ exports.cleanupPath = cleanupPath;
10
5
  /* eslint-disable @typescript-eslint/prefer-nullish-coalescing */
11
6
  const path_1 = require("path");
12
- const os_1 = __importDefault(require("os"));
13
7
  /**
14
- * @returns The provided path prepended with the root directory.
8
+ * @returns The provided path prepended with the root directory - in the user's OS path pattern.
9
+ *
10
+ * E.g. Unix: /path/to/file
11
+ * E.g. Windows: C:\path\to\file
15
12
  */
16
- function getCustomerPath(path) {
13
+ function getCustomerOSSpecificPath(path) {
17
14
  return (0, path_1.join)(process.cwd(), process.env.REPOSITORY_ROOT_DIRECTORY || "", path);
18
15
  }
19
16
  /**
20
- * Cleans up the template path, removing the root directory and the 'src/templates' prefix.
17
+ * Receives either a relative or absolute path for a given template file.
21
18
  *
22
- * This is needed to support the use of absolute paths in the templates, since those will
23
- * be added later on when reading the files.
24
- */
25
- function cleanupTemplatePath(path) {
26
- return cleanupDelimiters(cleanupAbsolutePath(path).replace((0, path_1.join)("src", "templates"), ""));
27
- }
28
- /**
29
- * Cleans up the fixture path, removing the root directory and the 'src/fixtures' prefix.
19
+ * Unix
20
+ * - src/templates/variation/variation.jsonata
21
+ * - ./src/templates/variation/variation.jsonata
22
+ * - /usr/username/templates-folder/src/templates/variation/variation.jsonata
30
23
  *
31
- * This is needed to support the use of absolute paths in the templates, since those will
32
- * be added later on when reading the files.
33
- */
34
- function cleanupFixturePath(path) {
35
- return cleanupDelimiters(cleanupAbsolutePath(path).replace((0, path_1.join)("src", "fixtures"), ""));
36
- }
37
- /**
38
- * Cleans up the external data path, removing the root directory and the 'src/external-data' prefix.
24
+ * Windows
25
+ * - src\templates\variation\variation.jsonata
26
+ * - .\src\templates\variation\variation.jsonata
27
+ * - C:\users\username\templates-folder\src\templates\variation\variation.jsonata
39
28
  *
40
- * This is needed to support the use of absolute paths in the templates, since those will
41
- * be added later on when reading the files.
29
+ * And returns a relative unix path WITHOUT its type prefix (e.g "src/templates"), like so:
30
+ * - variation/variation.jsonata
42
31
  */
43
- function cleanupExternalDataPath(path) {
44
- return cleanupDelimiters(cleanupAbsolutePath(path).replace((0, path_1.join)("src", "external-data"), ""));
45
- }
46
- function cleanupAbsolutePath(path) {
47
- if (!path) {
32
+ function cleanupPath(filePath) {
33
+ if (!filePath) {
48
34
  return "";
49
35
  }
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}`)) {
36
+ /**
37
+ * E.g /src/templates/variation/variation.jsonata
38
+ * E.g ./src/templates/variation/variation.jsonata
39
+ * E.g src/templates/variation/variation.jsonata
40
+ */
41
+ const relativePath = filePath
42
+ .replace(process.cwd(), "") //
43
+ .replace(/\\/g, "/");
44
+ /**
45
+ * E.g variation/variation.jsonata
46
+ * E.g /variation/variation.jsonata
47
+ * E.g ./variation/variation.jsonata
48
+ */
49
+ let replacedPath = relativePath
50
+ .replace("src/templates/", "")
51
+ .replace("src/fixtures/", "")
52
+ .replace("src/external-data/", "");
53
+ if (replacedPath.startsWith("/")) {
54
+ replacedPath = replacedPath.slice(1);
55
+ }
56
+ if (replacedPath.startsWith("./")) {
57
57
  replacedPath = replacedPath.slice(2);
58
58
  }
59
59
  return replacedPath;
@@ -13,7 +13,7 @@ async function loadSourceCode(path) {
13
13
  return undefined;
14
14
  }
15
15
  try {
16
- return await (0, promises_1.readFile)((0, path_1.getCustomerPath)(path), "utf-8");
16
+ return await (0, promises_1.readFile)((0, path_1.getCustomerOSSpecificPath)(path), "utf-8");
17
17
  }
18
18
  catch (error) {
19
19
  throw new errors_1.CLIError(`Could not load "${path}" file. Please check your connectrc.js file.`);
@@ -1 +1 @@
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
+ {"version":3,"file":"build-fixture.d.ts","sourceRoot":"","sources":["../../src/functions/build-fixture.ts"],"names":[],"mappings":"AAMA;;;;;;;;;;GAUG;AACH,eAAO,MAAM,YAAY,GACvB,MAAM,MAAM,EACZ,MAAM,MAAM,EACZ,eAAc,MAAM,CAAC,MAAM,EAAE,OAAO,CAAM,UAK3C,CAAC"}
@@ -0,0 +1,6 @@
1
+ import { type TemplatePath, type TemplateType } from "../types";
2
+ /**
3
+ * Checks for any nested folder that matches a known template type.
4
+ */
5
+ export declare function extractTemplateType(templatePath: TemplatePath): TemplateType;
6
+ //# sourceMappingURL=extract-template-type.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"extract-template-type.d.ts","sourceRoot":"","sources":["../../src/helpers/extract-template-type.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,YAAY,EAAE,KAAK,YAAY,EAAiB,MAAM,UAAU,CAAC;AAE/E;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,YAAY,EAAE,YAAY,GAAG,YAAY,CAkB5E"}
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.extractTemplateType = extractTemplateType;
4
+ const errors_1 = require("@oclif/core/lib/errors");
5
+ const types_1 = require("../types");
6
+ /**
7
+ * Checks for any nested folder that matches a known template type.
8
+ */
9
+ function extractTemplateType(templatePath) {
10
+ for (const type of types_1.TemplateTypes) {
11
+ if (templatePath.includes(`${type}/`)) {
12
+ return type;
13
+ }
14
+ }
15
+ throw new errors_1.CLIError(`Couldn't find the template type by looking at its path: ${templatePath}`, {
16
+ suggestions: [
17
+ "Check that the template file path is correct",
18
+ "Check that your templates are in the correctly named directory for their type (e.g. 'item.jsonata' in the 'templates/item' directory",
19
+ "Check that you are using a valid template type: " +
20
+ types_1.TemplateTypes.join(", "),
21
+ ],
22
+ });
23
+ }
@@ -1 +1 @@
1
- {"version":3,"file":"file-exists.d.ts","sourceRoot":"","sources":["../../src/helpers/file-exists.ts"],"names":[],"mappings":"AAIA;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,QAAQ,EAAE,MAAM,EAAE,cAAc,UAAQ,GAAG,OAAO,CAO5E"}
1
+ {"version":3,"file":"file-exists.d.ts","sourceRoot":"","sources":["../../src/helpers/file-exists.ts"],"names":[],"mappings":"AAIA;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,QAAQ,EAAE,MAAM,EAAE,cAAc,UAAQ,GAAG,OAAO,CAU5E"}
@@ -9,9 +9,11 @@ const path_1 = require("../customer/path");
9
9
  * @returns boolean
10
10
  */
11
11
  function fileExists(filepath, isCustomerPath = false) {
12
- const fullpath = isCustomerPath ? filepath : (0, path_1.getCustomerPath)(filepath);
12
+ const fullPath = isCustomerPath
13
+ ? filepath
14
+ : (0, path_1.getCustomerOSSpecificPath)(filepath);
13
15
  try {
14
- return (0, fs_extra_1.existsSync)(fullpath);
16
+ return (0, fs_extra_1.existsSync)(fullPath);
15
17
  }
16
18
  catch {
17
19
  return false;
@@ -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,sBAAsB,SAeZ,MAAM,sCAX3B,CAAC;AAEH,eAAO,MAAM,kBAAkB,SASR,MAAM;;yCAN3B,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,CAc9C;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"}
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,sBAAsB,SAeZ,MAAM,sCAX3B,CAAC;AAEH,eAAO,MAAM,kBAAkB,SASR,MAAM;;yCAN3B,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"}
@@ -24,13 +24,13 @@ exports.getJSONataTemplate = createFileLoader({
24
24
  fileLoader: fs_extra_1.default.readFileSync,
25
25
  });
26
26
  function createFileLoader({ prefix, fileLoader, suggestions = [], }) {
27
- return function (name, ...args) {
28
- const filePath = (0, path_2.getCustomerPath)(path_1.default.join(prefix, name));
27
+ return function (filename, ...args) {
28
+ const absolutePath = (0, path_2.getCustomerOSSpecificPath)(path_1.default.join(prefix, filename));
29
29
  try {
30
- return fileLoader(filePath, ...args);
30
+ return fileLoader(absolutePath, ...args);
31
31
  }
32
32
  catch (error) {
33
- throw new errors_1.CLIError(`Error while loading ${filePath}: ${error.message}`, {
33
+ throw new errors_1.CLIError(`Error while loading ${absolutePath}: ${error.message}`, {
34
34
  suggestions: [
35
35
  "Ensure the file exists and is named correctly",
36
36
  ...suggestions,
@@ -1 +1 @@
1
- {"version":3,"file":"find-deep-files.d.ts","sourceRoot":"","sources":["../../src/helpers/find-deep-files.ts"],"names":[],"mappings":"AAMA;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,EAAE,CAWnD"}
1
+ {"version":3,"file":"find-deep-files.d.ts","sourceRoot":"","sources":["../../src/helpers/find-deep-files.ts"],"names":[],"mappings":"AAMA;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,EAAE,CAanD"}
@@ -13,10 +13,11 @@ const path_2 = require("../customer/path");
13
13
  * @returns All files in the given directory, including in subdirectories
14
14
  */
15
15
  function findDeepFiles(dir) {
16
- const files = fs_extra_1.default.readdirSync((0, path_2.getCustomerPath)(dir));
16
+ const files = fs_extra_1.default.readdirSync((0, path_2.getCustomerOSSpecificPath)(dir));
17
17
  return files.reduce((files, currentPath) => {
18
18
  const fullPath = path_1.default.join(dir, currentPath);
19
- if (fs_extra_1.default.statSync((0, path_2.getCustomerPath)(fullPath)).isDirectory()) {
19
+ const resolvedPath = (0, path_2.getCustomerOSSpecificPath)(fullPath);
20
+ if (fs_extra_1.default.statSync(resolvedPath).isDirectory()) {
20
21
  return [...files, ...findDeepFiles(fullPath)];
21
22
  }
22
23
  else {
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Makes use of fs.readFileSync and fs.writeFileSync to prepend data to a file synchronously.
3
+ * @param filePath - The path to the file to which data will be prepended.
4
+ * @param newData - The data to prepend to the file.
5
+ */
6
+ export declare function prependFileSync(filePath: string, newData: string): void;
7
+ //# sourceMappingURL=prepend-file-sync.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prepend-file-sync.d.ts","sourceRoot":"","sources":["../../src/helpers/prepend-file-sync.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI,CAUvE"}
@@ -0,0 +1,54 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
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
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.prependFileSync = prependFileSync;
37
+ const fs = __importStar(require("fs-extra"));
38
+ /**
39
+ * Makes use of fs.readFileSync and fs.writeFileSync to prepend data to a file synchronously.
40
+ * @param filePath - The path to the file to which data will be prepended.
41
+ * @param newData - The data to prepend to the file.
42
+ */
43
+ function prependFileSync(filePath, newData) {
44
+ try {
45
+ const existingData = fs.readFileSync(filePath, "utf8");
46
+ fs.writeFileSync(filePath, newData + existingData);
47
+ }
48
+ catch (error) {
49
+ if (error instanceof Error && error.message?.includes("ENOENT")) {
50
+ // If the file does not exist, create it with the new data
51
+ fs.writeFileSync(filePath, newData);
52
+ }
53
+ }
54
+ }
@@ -37,9 +37,9 @@ exports.refreshConnectionsList = refreshConnectionsList;
37
37
  const fs = __importStar(require("fs/promises"));
38
38
  const cli_ux_1 = require("@oclif/core/lib/cli-ux");
39
39
  const config_1 = require("../customer/config");
40
- const path_1 = require("../customer/path");
41
40
  const get_connections_request_1 = require("../http/get-connections-request");
42
41
  const render_prompt_1 = require("../prompt-data/render-prompt");
42
+ const path_1 = require("../customer/path");
43
43
  const build_config_file_1 = require("./build-config-file");
44
44
  const should_update_connections_list_1 = require("./should-update-connections-list");
45
45
  const ux_action_1 = require("./ux-action");
@@ -86,7 +86,7 @@ async function checkConfigFileState() {
86
86
  }
87
87
  async function updateConfigFile() {
88
88
  const formattedConnections = await fetchNewConnections();
89
- const rcPath = (0, path_1.getCustomerPath)("connectrc.js");
89
+ const rcPath = (0, path_1.getCustomerOSSpecificPath)("connectrc.js");
90
90
  const { fileContent } = await (0, config_1.getRepositoryConnectionsAndConfig)();
91
91
  if (!fileContent) {
92
92
  return;
@@ -1 +1 @@
1
- {"version":3,"file":"ux-action.d.ts","sourceRoot":"","sources":["../../src/helpers/ux-action.ts"],"names":[],"mappings":"AAEA,wBAAgB,QAAQ,CAAC,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,EACxD,KAAK,EAAE,MAAM,EACb,IAAI,EAAE,CAAC,aAEmB,UAAU,CAAC,CAAC,CAAC,KAAG,UAAU,CAAC,CAAC,CAAC,CA0BxD"}
1
+ {"version":3,"file":"ux-action.d.ts","sourceRoot":"","sources":["../../src/helpers/ux-action.ts"],"names":[],"mappings":"AAEA,wBAAgB,QAAQ,CAAC,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,EACxD,KAAK,EAAE,MAAM,EACb,IAAI,EAAE,CAAC,IAEU,GAAG,MAAM,UAAU,CAAC,CAAC,CAAC,KAAG,UAAU,CAAC,CAAC,CAAC,CA0BxD"}
@@ -1,8 +1,8 @@
1
+ import { type TemplatePath, type PromptChoices } from "../types";
1
2
  import { type ConnectionResponseDto } from "../http/get-connections-request";
2
- import { type PromptChoices } from "../types";
3
3
  /**
4
4
  * Returns all connections that are associated with a template by checking
5
5
  * the config file.
6
6
  */
7
- export declare function filterConnectionsByTemplate(templatePath: string, connections: ConnectionResponseDto[]): Promise<PromptChoices<ConnectionResponseDto>>;
7
+ export declare function filterConnectionsByTemplate(templatePath: TemplatePath, connections: ConnectionResponseDto[]): Promise<PromptChoices<ConnectionResponseDto>>;
8
8
  //# sourceMappingURL=filter-connections-by-template.d.ts.map
@@ -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,CA2C/C"}
1
+ {"version":3,"file":"filter-connections-by-template.d.ts","sourceRoot":"","sources":["../../src/prompt-data/filter-connections-by-template.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,YAAY,EAAE,KAAK,aAAa,EAAE,MAAM,UAAU,CAAC;AACjE,OAAO,EAAE,KAAK,qBAAqB,EAAE,MAAM,iCAAiC,CAAC;AAG7E;;;GAGG;AACH,wBAAsB,2BAA2B,CAC/C,YAAY,EAAE,YAAY,EAC1B,WAAW,EAAE,qBAAqB,EAAE,GACnC,OAAO,CAAC,aAAa,CAAC,qBAAqB,CAAC,CAAC,CAoC/C"}
@@ -1,30 +1,20 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
3
  exports.filterConnectionsByTemplate = filterConnectionsByTemplate;
7
- const path_1 = __importDefault(require("path"));
8
4
  const config_1 = require("../customer/config");
5
+ const path_1 = require("../customer/path");
9
6
  /**
10
7
  * Returns all connections that are associated with a template by checking
11
8
  * the config file.
12
9
  */
13
10
  async function filterConnectionsByTemplate(templatePath, connections) {
14
11
  const config = await (0, config_1.getRepositoryConfigFile)();
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
- }
20
12
  // All connection ids that references this template
21
13
  const configConnectionIds = config.environments.reduce((connectionIds, environment) => {
22
14
  for (const templateConfig of environment.templates) {
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
15
+ const templatePaths = Object.values(templateConfig.paths).map((filePath) => (0, path_1.cleanupPath)(filePath));
26
16
  // environment doesn't even target this template
27
- if (!templatePaths.includes(path_1.default.resolve(fullPath).replace(/\\/g, "/"))) {
17
+ if (!templatePaths.includes(templatePath)) {
28
18
  continue;
29
19
  }
30
20
  for (const id of templateConfig.connection_ids) {
@@ -1,3 +1,6 @@
1
- import { type PromptChoices } from "../types";
2
- export declare function getCandidateFixtures(templatePath: string): PromptChoices<string>;
1
+ import { type PromptChoices, type TemplatePath } from "../types";
2
+ /**
3
+ * @returns The CLEANED fixtures paths as prompt choices
4
+ */
5
+ export declare function getCandidateFixtures(templatePath: TemplatePath): PromptChoices<string>;
3
6
  //# sourceMappingURL=get-candidate-fixtures.d.ts.map
@@ -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,CAqDvB"}
1
+ {"version":3,"file":"get-candidate-fixtures.d.ts","sourceRoot":"","sources":["../../src/prompt-data/get-candidate-fixtures.ts"],"names":[],"mappings":"AAKA,OAAO,EAEL,KAAK,aAAa,EAClB,KAAK,YAAY,EAClB,MAAM,UAAU,CAAC;AAIlB;;GAEG;AACH,wBAAgB,oBAAoB,CAClC,YAAY,EAAE,YAAY,GACzB,aAAa,CAAC,MAAM,CAAC,CAqCvB"}
@@ -7,19 +7,13 @@ exports.getCandidateFixtures = getCandidateFixtures;
7
7
  const path_1 = __importDefault(require("path"));
8
8
  const errors_1 = require("@oclif/core/lib/errors");
9
9
  const find_deep_files_1 = require("../helpers/find-deep-files");
10
- const types_1 = require("../types");
10
+ const extract_template_type_1 = require("../helpers/extract-template-type");
11
+ const path_2 = require("../customer/path");
12
+ /**
13
+ * @returns The CLEANED fixtures paths as prompt choices
14
+ */
11
15
  function getCandidateFixtures(templatePath) {
12
- const templateType = extractTemplateType(templatePath);
13
- if (!templateType) {
14
- throw new errors_1.CLIError(`Couldn't find the template type by looking at its path: ${templatePath}`, {
15
- suggestions: [
16
- "Check that the template file path is correct",
17
- "Check that your templates are in the correctly named directory for their type (e.g. 'item.jsonata' in the 'templates/item' directory",
18
- "Check that you are using a valid template type: " +
19
- types_1.TemplateTypes.join(", "),
20
- ],
21
- });
22
- }
16
+ const templateType = (0, extract_template_type_1.extractTemplateType)(templatePath);
23
17
  const fixtureType = templateType === "grouping"
24
18
  ? "variation" //
25
19
  : templateType;
@@ -41,20 +35,10 @@ function getCandidateFixtures(templatePath) {
41
35
  return fixtureFullPaths
42
36
  .filter((fixturePath) => path_1.default.extname(fixturePath) === ".json")
43
37
  .map((fixturePath) => {
44
- const fixtureRelativePath = path_1.default.relative(path_1.default.join("src", "fixtures"), fixturePath);
38
+ const fixtureRelativePath = (0, path_2.cleanupPath)(fixturePath);
45
39
  return {
46
40
  name: fixtureRelativePath,
47
41
  value: fixtureRelativePath,
48
42
  };
49
43
  });
50
44
  }
51
- /**
52
- * Checks for any nested folder that matches a known template type.
53
- */
54
- function extractTemplateType(templatePath) {
55
- for (const type of types_1.TemplateTypes) {
56
- if (templatePath.includes(path_1.default.join(`${type}/`))) {
57
- return type;
58
- }
59
- }
60
- }
@@ -1 +1 @@
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
+ {"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;AAG9C;;GAEG;AACH,wBAAsB,gBAAgB,IAAI,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC,CAgBvE"}
@@ -6,6 +6,7 @@ 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 path_2 = require("../customer/path");
9
10
  /**
10
11
  * Get a prompt-ready list of template files in the user repository
11
12
  */
@@ -13,11 +14,13 @@ async function getTemplateFiles() {
13
14
  const filePath = path_1.default.join("src", "templates");
14
15
  const files = getTemplatePaths(filePath);
15
16
  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
17
- return filteredFiles.map((file) => ({
18
- name: file.replace(filePathSlash, ""),
19
- value: file.replace(filePathSlash, ""),
20
- }));
17
+ return filteredFiles.map((file) => {
18
+ const relativePath = (0, path_2.cleanupPath)(file);
19
+ return {
20
+ name: relativePath,
21
+ value: relativePath,
22
+ };
23
+ });
21
24
  }
22
25
  /**
23
26
  * @param typePath The full type path. E.g.
@@ -1 +1 @@
1
- {"version":3,"file":"select-connections.d.ts","sourceRoot":"","sources":["../../src/prompt-data/select-connections.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,iBAAiB,aACnB,MAAM,6EA2BhB,CAAC"}
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,6EA2B1C,CAAC"}
package/dist/types.d.ts CHANGED
@@ -49,6 +49,15 @@ export declare enum CatalogFixtureType {
49
49
  MAPPING = "mapping"
50
50
  }
51
51
  export declare const TemplateTypes: readonly ["item", "variation", "item_group", "grouping", "mapping"];
52
+ /**
53
+ * The unix relative path of a given template.
54
+ * With NO prefixed "/" or "./".
55
+ *
56
+ * E.g
57
+ * - staging/item/en_CA/item.jsonata
58
+ * - variation/variation.jsonata
59
+ */
60
+ export type TemplatePath = string;
52
61
  export type TemplateType = (typeof TemplateTypes)[number];
53
62
  export {};
54
63
  //# sourceMappingURL=types.d.ts.map
@@ -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,YAAY,EAAE,KAAK,CAAC;QAClB,WAAW,EAAE,MAAM,CAAC;QACpB,SAAS,EAAE,KAAK,CAAC;YACf,KAAK,EAAE,OAAO,CAAC,MAAM,CAAC,YAAY,EAAE,MAAM,CAAC,CAAC,CAAC;YAC7C,cAAc,EAAE,MAAM,EAAE,CAAC;SAC1B,CAAC,CAAC;KACJ,CAAC,CAAC;CACJ;AAED,MAAM,WAAW,iBAAiB;IAChC,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,MAAM,oBAAoB,GAAG,MAAM,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAAC;AAErE,MAAM,MAAM,aAAa,CAAC,CAAC,IAAI,KAAK,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,CAAC,CAAA;CAAE,CAAC,CAAC;AAEjE,UAAU,aAAa;IACrB,IAAI,EAAE,gBAAgB,CAAC;IACvB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;CACpB;AACD,MAAM,WAAW,wBAAwB;IACvC,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,OAAO,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,gCAAgC;IAC/C,OAAO,EAAE,IAAI,CAAC;IACd,IAAI,EAAE,MAAM,CAAC,MAAM,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,MAAM,MAAM,YAAY,GAAG,CAAC,OAAO,aAAa,CAAC,CAAC,MAAM,CAAC,CAAC"}
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,YAAY,EAAE,KAAK,CAAC;QAClB,WAAW,EAAE,MAAM,CAAC;QACpB,SAAS,EAAE,KAAK,CAAC;YACf,KAAK,EAAE,OAAO,CAAC,MAAM,CAAC,YAAY,EAAE,MAAM,CAAC,CAAC,CAAC;YAC7C,cAAc,EAAE,MAAM,EAAE,CAAC;SAC1B,CAAC,CAAC;KACJ,CAAC,CAAC;CACJ;AAED,MAAM,WAAW,iBAAiB;IAChC,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,MAAM,oBAAoB,GAAG,MAAM,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAAC;AAErE,MAAM,MAAM,aAAa,CAAC,CAAC,IAAI,KAAK,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,CAAC,CAAA;CAAE,CAAC,CAAC;AAEjE,UAAU,aAAa;IACrB,IAAI,EAAE,gBAAgB,CAAC;IACvB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;CACpB;AACD,MAAM,WAAW,wBAAwB;IACvC,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,OAAO,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,gCAAgC;IAC/C,OAAO,EAAE,IAAI,CAAC;IACd,IAAI,EAAE,MAAM,CAAC,MAAM,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;;;;;;;GAOG;AACH,MAAM,MAAM,YAAY,GAAG,MAAM,CAAC;AAElC,MAAM,MAAM,YAAY,GAAG,CAAC,OAAO,aAAa,CAAC,CAAC,MAAM,CAAC,CAAC"}
package/dist/version.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- declare const _default: "1.12.2";
1
+ declare const _default: "1.12.4";
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.12.2';
3
+ exports.default = '1.12.4';
@@ -190,5 +190,5 @@
190
190
  ]
191
191
  }
192
192
  },
193
- "version": "1.12.2"
193
+ "version": "1.12.4"
194
194
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@constructor-io/constructorio-connect-cli",
3
- "version": "1.12.2",
3
+ "version": "1.12.4",
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",