@constructor-io/constructorio-connect-cli 1.12.1 → 1.12.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.
@@ -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;YA8BnB,UAAU;IAmBxB,OAAO,CAAC,oBAAoB;YAUd,UAAU;YAsBV,uBAAuB;WA6BvB,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"}
1
+ {"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../src/commands/init.ts"],"names":[],"mappings":"AAMA,OAAO,EAAQ,OAAO,EAAM,MAAM,aAAa,CAAC;AA0BhD,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;YAyCnB,UAAU;IAmBxB,OAAO,CAAC,oBAAoB;YAUd,UAAU;YAsBV,uBAAuB;WA6BvB,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"}
@@ -49,6 +49,7 @@ const ux_action_1 = require("../helpers/ux-action");
49
49
  const get_connect_token_1 = require("../customer/get-connect-token");
50
50
  const render_tip_1 = require("../rendering/render-tip");
51
51
  const is_git_repo_initialized_1 = require("../helpers/is-git-repo-initialized");
52
+ const is_git_installed_1 = require("../helpers/is-git-installed");
52
53
  const BOILERPLATE_REPO_PATH = "../../boilerplate-repo";
53
54
  /**
54
55
  * This ensures that the path will be fixed in Windows, since we're using `path.join()` to build the path.
@@ -73,6 +74,11 @@ class Init extends core_1.Command {
73
74
  const { args } = await this.parse(Init);
74
75
  const repoPath = path.join(process.cwd(), args.name);
75
76
  core_1.ux.info([`👋 Welcome to the ${kleur_1.default.bold("Constructor.io Connect CLI")}!\n`].join("\n"));
77
+ const hasGit = (0, is_git_installed_1.isGitInstalled)();
78
+ if (!hasGit) {
79
+ core_1.ux.log(kleur_1.default.red("⚠️ Git is not installed"), kleur_1.default.bold("Please install Git and try again."), kleur_1.default.dim("\nYou can download it from:"), kleur_1.default.blue("https://git-scm.com/downloads"));
80
+ return;
81
+ }
76
82
  const connectAuthToken = await (0, get_connect_token_1.getConnectToken)(false);
77
83
  const newDirExists = fs_extra_1.default.existsSync(repoPath);
78
84
  if (!newDirExists) {
@@ -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;
@@ -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 +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,15 @@
1
+ /**
2
+ * Check if Git is installed
3
+ *
4
+ * This function attempts to run the 'git --version' command.
5
+ * It will return true if the command succeeds, indicating Git is installed.
6
+ * It will return false if the command fails for any reason (including Git not being in PATH,
7
+ * not installed, or any other error).
8
+ *
9
+ * This implementation works across different operating systems (Windows, macOS, Linux)
10
+ * as it simply relies on the command execution succeeding or failing.
11
+ *
12
+ * @returns true if Git is installed, false otherwise
13
+ */
14
+ export declare function isGitInstalled(): boolean;
15
+ //# sourceMappingURL=is-git-installed.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"is-git-installed.d.ts","sourceRoot":"","sources":["../../src/helpers/is-git-installed.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;GAYG;AACH,wBAAgB,cAAc,IAAI,OAAO,CAOxC"}
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isGitInstalled = isGitInstalled;
4
+ const child_process_1 = require("child_process");
5
+ // const envWithoutGit = { ...process.env, PATH: "" }; // for manually triggering the error pass this in as the second argument to execSync
6
+ /**
7
+ * Check if Git is installed
8
+ *
9
+ * This function attempts to run the 'git --version' command.
10
+ * It will return true if the command succeeds, indicating Git is installed.
11
+ * It will return false if the command fails for any reason (including Git not being in PATH,
12
+ * not installed, or any other error).
13
+ *
14
+ * This implementation works across different operating systems (Windows, macOS, Linux)
15
+ * as it simply relies on the command execution succeeding or failing.
16
+ *
17
+ * @returns true if Git is installed, false otherwise
18
+ */
19
+ function isGitInstalled() {
20
+ try {
21
+ (0, child_process_1.execSync)("git --version");
22
+ return true;
23
+ }
24
+ catch (error) {
25
+ return false;
26
+ }
27
+ }
@@ -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
+ }
@@ -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 +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/version.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- declare const _default: "1.12.1";
1
+ declare const _default: "1.12.3";
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.1';
3
+ exports.default = '1.12.3';
@@ -190,5 +190,5 @@
190
190
  ]
191
191
  }
192
192
  },
193
- "version": "1.12.1"
193
+ "version": "1.12.3"
194
194
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@constructor-io/constructorio-connect-cli",
3
- "version": "1.12.1",
3
+ "version": "1.12.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",