@zapier/zapier-sdk-cli 0.13.16 → 0.14.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/dist/cli.cjs +296 -20
- package/dist/cli.mjs +296 -22
- package/dist/index.cjs +29 -5
- package/dist/index.mjs +30 -6
- package/dist/package.json +4 -1
- package/dist/src/cli.js +32 -2
- package/dist/src/plugins/login/index.js +0 -2
- package/dist/src/utils/auth/login.js +3 -2
- package/dist/src/utils/cli-generator.js +10 -2
- package/dist/src/utils/errors.d.ts +16 -0
- package/dist/src/utils/errors.js +19 -0
- package/dist/src/utils/log.d.ts +1 -0
- package/dist/src/utils/log.js +5 -0
- package/dist/src/utils/package-manager-detector.d.ts +16 -0
- package/dist/src/utils/package-manager-detector.js +77 -0
- package/dist/src/utils/parameter-resolver.js +6 -5
- package/dist/src/utils/spinner.js +9 -1
- package/dist/src/utils/version-checker.d.ts +17 -0
- package/dist/src/utils/version-checker.js +154 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +4 -1
- package/src/cli.ts +34 -2
- package/src/plugins/login/index.ts +0 -3
- package/src/utils/auth/login.ts +7 -3
- package/src/utils/cli-generator.ts +15 -2
- package/src/utils/errors.ts +26 -0
- package/src/utils/log.ts +5 -0
- package/src/utils/package-manager-detector.ts +83 -0
- package/src/utils/parameter-resolver.ts +6 -5
- package/src/utils/spinner.ts +8 -1
- package/src/utils/version-checker.test.ts +199 -0
- package/src/utils/version-checker.ts +236 -0
package/CHANGELOG.md
CHANGED
package/dist/cli.cjs
CHANGED
|
@@ -19,6 +19,9 @@ var fs = require('fs');
|
|
|
19
19
|
var path = require('path');
|
|
20
20
|
var promises = require('fs/promises');
|
|
21
21
|
var ts = require('typescript');
|
|
22
|
+
var packageJsonLib = require('package-json');
|
|
23
|
+
var Conf = require('conf');
|
|
24
|
+
var isInstalledGlobally = require('is-installed-globally');
|
|
22
25
|
|
|
23
26
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
24
27
|
|
|
@@ -51,7 +54,30 @@ var ora__default = /*#__PURE__*/_interopDefault(ora);
|
|
|
51
54
|
var fs__namespace = /*#__PURE__*/_interopNamespace(fs);
|
|
52
55
|
var path__namespace = /*#__PURE__*/_interopNamespace(path);
|
|
53
56
|
var ts__namespace = /*#__PURE__*/_interopNamespace(ts);
|
|
57
|
+
var packageJsonLib__default = /*#__PURE__*/_interopDefault(packageJsonLib);
|
|
58
|
+
var Conf__default = /*#__PURE__*/_interopDefault(Conf);
|
|
59
|
+
var isInstalledGlobally__default = /*#__PURE__*/_interopDefault(isInstalledGlobally);
|
|
54
60
|
|
|
61
|
+
var ZapierCliError = class extends zapierSdk.ZapierError {
|
|
62
|
+
};
|
|
63
|
+
var ZapierCliUserCancellationError = class extends ZapierCliError {
|
|
64
|
+
constructor(message = "Operation cancelled by user") {
|
|
65
|
+
super(message);
|
|
66
|
+
this.name = "ZapierCliUserCancellationError";
|
|
67
|
+
this.code = "ZAPIER_CLI_USER_CANCELLATION";
|
|
68
|
+
this.exitCode = 0;
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
var ZapierCliExitError = class extends ZapierCliError {
|
|
72
|
+
constructor(message, exitCode = 1) {
|
|
73
|
+
super(message);
|
|
74
|
+
this.name = "ZapierCliExitError";
|
|
75
|
+
this.code = "ZAPIER_CLI_EXIT";
|
|
76
|
+
this.exitCode = exitCode;
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
// src/utils/parameter-resolver.ts
|
|
55
81
|
function getLocalResolutionOrder(paramName, resolvers, resolved = /* @__PURE__ */ new Set()) {
|
|
56
82
|
const resolver = resolvers[paramName];
|
|
57
83
|
if (!resolver || resolver.type === "static") {
|
|
@@ -158,7 +184,7 @@ var SchemaParameterResolver = class {
|
|
|
158
184
|
} catch (error) {
|
|
159
185
|
if (this.isUserCancellation(error)) {
|
|
160
186
|
console.log(chalk3__default.default.yellow("\n\nOperation cancelled by user"));
|
|
161
|
-
|
|
187
|
+
throw new ZapierCliUserCancellationError();
|
|
162
188
|
}
|
|
163
189
|
throw error;
|
|
164
190
|
}
|
|
@@ -196,7 +222,7 @@ var SchemaParameterResolver = class {
|
|
|
196
222
|
} catch (error) {
|
|
197
223
|
if (this.isUserCancellation(error)) {
|
|
198
224
|
console.log(chalk3__default.default.yellow("\n\nOperation cancelled by user"));
|
|
199
|
-
|
|
225
|
+
throw new ZapierCliUserCancellationError();
|
|
200
226
|
}
|
|
201
227
|
throw error;
|
|
202
228
|
}
|
|
@@ -231,7 +257,7 @@ var SchemaParameterResolver = class {
|
|
|
231
257
|
} catch (error) {
|
|
232
258
|
if (this.isUserCancellation(error)) {
|
|
233
259
|
console.log(chalk3__default.default.yellow("\n\nOperation cancelled by user"));
|
|
234
|
-
|
|
260
|
+
throw new ZapierCliUserCancellationError();
|
|
235
261
|
}
|
|
236
262
|
throw error;
|
|
237
263
|
}
|
|
@@ -485,7 +511,7 @@ Optional fields${pathContext}:`));
|
|
|
485
511
|
} catch (error) {
|
|
486
512
|
if (this.isUserCancellation(error)) {
|
|
487
513
|
console.log(chalk3__default.default.yellow("\n\nOperation cancelled by user"));
|
|
488
|
-
|
|
514
|
+
throw new ZapierCliUserCancellationError();
|
|
489
515
|
}
|
|
490
516
|
throw error;
|
|
491
517
|
}
|
|
@@ -550,7 +576,7 @@ Optional fields${pathContext}:`));
|
|
|
550
576
|
} catch (error) {
|
|
551
577
|
if (this.isUserCancellation(error)) {
|
|
552
578
|
console.log(chalk3__default.default.yellow("\n\nOperation cancelled by user"));
|
|
553
|
-
|
|
579
|
+
throw new ZapierCliUserCancellationError();
|
|
554
580
|
}
|
|
555
581
|
throw error;
|
|
556
582
|
}
|
|
@@ -773,8 +799,8 @@ function generateCliCommands(program2, sdk2) {
|
|
|
773
799
|
return;
|
|
774
800
|
}
|
|
775
801
|
const cliCommandName = methodNameToCliCommand(fnInfo.name);
|
|
776
|
-
const
|
|
777
|
-
addCommand(program2, cliCommandName,
|
|
802
|
+
const config2 = createCommandConfig(cliCommandName, fnInfo, sdk2);
|
|
803
|
+
addCommand(program2, cliCommandName, config2);
|
|
778
804
|
});
|
|
779
805
|
program2.configureHelp({
|
|
780
806
|
formatHelp: (cmd, helper) => {
|
|
@@ -916,17 +942,28 @@ function createCommandConfig(cliCommandName, functionInfo, sdk2) {
|
|
|
916
942
|
console.error(
|
|
917
943
|
"\n" + chalk3__default.default.dim(`Use --help to see available options`)
|
|
918
944
|
);
|
|
945
|
+
throw new ZapierCliExitError("Validation failed", 1);
|
|
919
946
|
} catch {
|
|
920
|
-
console.error(
|
|
947
|
+
console.error(
|
|
948
|
+
chalk3__default.default.red("Error:"),
|
|
949
|
+
error instanceof Error ? error.message : String(error)
|
|
950
|
+
);
|
|
951
|
+
throw new ZapierCliExitError(
|
|
952
|
+
error instanceof Error ? error.message : String(error),
|
|
953
|
+
1
|
|
954
|
+
);
|
|
921
955
|
}
|
|
956
|
+
} else if (error instanceof ZapierCliError) {
|
|
957
|
+
throw error;
|
|
922
958
|
} else if (error instanceof zapierSdk.ZapierError) {
|
|
923
959
|
const formattedMessage = zapierSdk.formatErrorMessage(error);
|
|
924
960
|
console.error(chalk3__default.default.red("\u274C Error:"), formattedMessage);
|
|
961
|
+
throw new ZapierCliExitError(formattedMessage, 1);
|
|
925
962
|
} else {
|
|
926
963
|
const errorMessage = error instanceof Error ? error.message : "Unknown error";
|
|
927
964
|
console.error(chalk3__default.default.red("\u274C Error:"), errorMessage);
|
|
965
|
+
throw new ZapierCliExitError(errorMessage, 1);
|
|
928
966
|
}
|
|
929
|
-
process.exit(1);
|
|
930
967
|
}
|
|
931
968
|
};
|
|
932
969
|
return {
|
|
@@ -935,10 +972,10 @@ function createCommandConfig(cliCommandName, functionInfo, sdk2) {
|
|
|
935
972
|
handler
|
|
936
973
|
};
|
|
937
974
|
}
|
|
938
|
-
function addCommand(program2, commandName,
|
|
939
|
-
const command = program2.command(commandName).description(
|
|
975
|
+
function addCommand(program2, commandName, config2) {
|
|
976
|
+
const command = program2.command(commandName).description(config2.description);
|
|
940
977
|
let hasPositionalArray = false;
|
|
941
|
-
|
|
978
|
+
config2.parameters.forEach((param) => {
|
|
942
979
|
const kebabName = param.name.replace(/([A-Z])/g, "-$1").toLowerCase();
|
|
943
980
|
if (param.hasResolver && param.required) {
|
|
944
981
|
command.argument(
|
|
@@ -990,7 +1027,7 @@ function addCommand(program2, commandName, config) {
|
|
|
990
1027
|
}
|
|
991
1028
|
});
|
|
992
1029
|
command.option("--json", "Output raw JSON instead of formatted results");
|
|
993
|
-
command.action(
|
|
1030
|
+
command.action(config2.handler);
|
|
994
1031
|
}
|
|
995
1032
|
function convertCliArgsToSdkParams(parameters, positionalArgs, options) {
|
|
996
1033
|
const sdkParams = {};
|
|
@@ -1200,7 +1237,11 @@ var spinPromise = async (promise, text) => {
|
|
|
1200
1237
|
spinner.succeed();
|
|
1201
1238
|
return result;
|
|
1202
1239
|
} catch (error) {
|
|
1203
|
-
|
|
1240
|
+
if (error instanceof ZapierCliUserCancellationError) {
|
|
1241
|
+
spinner.stop();
|
|
1242
|
+
} else {
|
|
1243
|
+
spinner.fail();
|
|
1244
|
+
}
|
|
1204
1245
|
throw error;
|
|
1205
1246
|
}
|
|
1206
1247
|
};
|
|
@@ -1216,6 +1257,11 @@ var log = {
|
|
|
1216
1257
|
},
|
|
1217
1258
|
warn: (message, ...args) => {
|
|
1218
1259
|
console.log(chalk3__default.default.yellow("\u26A0"), message, ...args);
|
|
1260
|
+
},
|
|
1261
|
+
debug: (message, ...args) => {
|
|
1262
|
+
if (process.env.DEBUG === "true" || process.argv.includes("--debug")) {
|
|
1263
|
+
console.log(chalk3__default.default.gray("\u{1F41B}"), message, ...args);
|
|
1264
|
+
}
|
|
1219
1265
|
}
|
|
1220
1266
|
};
|
|
1221
1267
|
var log_default = log;
|
|
@@ -1318,7 +1364,11 @@ var login = async ({
|
|
|
1318
1364
|
const availablePort = await findAvailablePort();
|
|
1319
1365
|
const redirectUri = `http://localhost:${availablePort}/oauth`;
|
|
1320
1366
|
log_default.info(`Using port ${availablePort} for OAuth callback`);
|
|
1321
|
-
const {
|
|
1367
|
+
const {
|
|
1368
|
+
promise: promisedCode,
|
|
1369
|
+
resolve: setCode,
|
|
1370
|
+
reject: rejectCode
|
|
1371
|
+
} = getCallablePromise_default();
|
|
1322
1372
|
const app = express__default.default();
|
|
1323
1373
|
app.get("/oauth", (req, res) => {
|
|
1324
1374
|
setCode(String(req.query.code));
|
|
@@ -1334,7 +1384,7 @@ var login = async ({
|
|
|
1334
1384
|
const cleanup = () => {
|
|
1335
1385
|
server.close();
|
|
1336
1386
|
log_default.info("\n\u274C Login cancelled by user");
|
|
1337
|
-
|
|
1387
|
+
rejectCode(new ZapierCliUserCancellationError());
|
|
1338
1388
|
};
|
|
1339
1389
|
process.on("SIGINT", cleanup);
|
|
1340
1390
|
process.on("SIGTERM", cleanup);
|
|
@@ -1410,7 +1460,7 @@ var LoginSchema = zod.z.object({
|
|
|
1410
1460
|
|
|
1411
1461
|
// package.json
|
|
1412
1462
|
var package_default = {
|
|
1413
|
-
version: "0.
|
|
1463
|
+
version: "0.14.1"};
|
|
1414
1464
|
|
|
1415
1465
|
// src/telemetry/builders.ts
|
|
1416
1466
|
function createCliBaseEvent(context = {}) {
|
|
@@ -1482,7 +1532,6 @@ var loginWithSdk = zapierSdk.createFunction(
|
|
|
1482
1532
|
});
|
|
1483
1533
|
const user = await zapierSdkCliLogin.getLoggedInUser();
|
|
1484
1534
|
console.log(`\u2705 Successfully logged in as ${user.email}`);
|
|
1485
|
-
setTimeout(() => process.exit(0), 100);
|
|
1486
1535
|
}
|
|
1487
1536
|
);
|
|
1488
1537
|
var loginPlugin = ({ context }) => {
|
|
@@ -2682,7 +2731,213 @@ function createZapierCliSdk(options = {}) {
|
|
|
2682
2731
|
|
|
2683
2732
|
// package.json with { type: 'json' }
|
|
2684
2733
|
var package_default2 = {
|
|
2685
|
-
|
|
2734
|
+
name: "@zapier/zapier-sdk-cli",
|
|
2735
|
+
version: "0.14.1"};
|
|
2736
|
+
function detectPackageManager(cwd = process.cwd()) {
|
|
2737
|
+
const ua = process.env.npm_config_user_agent;
|
|
2738
|
+
if (ua) {
|
|
2739
|
+
if (ua.includes("yarn")) return { name: "yarn", source: "runtime" };
|
|
2740
|
+
if (ua.includes("pnpm")) return { name: "pnpm", source: "runtime" };
|
|
2741
|
+
if (ua.includes("bun")) return { name: "bun", source: "runtime" };
|
|
2742
|
+
if (ua.includes("npm")) return { name: "npm", source: "runtime" };
|
|
2743
|
+
}
|
|
2744
|
+
const files = [
|
|
2745
|
+
["pnpm-lock.yaml", "pnpm"],
|
|
2746
|
+
["yarn.lock", "yarn"],
|
|
2747
|
+
["bun.lockb", "bun"],
|
|
2748
|
+
["package-lock.json", "npm"]
|
|
2749
|
+
];
|
|
2750
|
+
for (const [file, name] of files) {
|
|
2751
|
+
if (fs.existsSync(path.join(cwd, file))) {
|
|
2752
|
+
return { name, source: "lockfile" };
|
|
2753
|
+
}
|
|
2754
|
+
}
|
|
2755
|
+
return { name: "unknown", source: "fallback" };
|
|
2756
|
+
}
|
|
2757
|
+
function getUpdateCommand(packageName) {
|
|
2758
|
+
const pm = detectPackageManager();
|
|
2759
|
+
const isGlobal = isInstalledGlobally__default.default;
|
|
2760
|
+
if (isGlobal) {
|
|
2761
|
+
switch (pm.name) {
|
|
2762
|
+
case "yarn":
|
|
2763
|
+
return `yarn global upgrade ${packageName}@latest`;
|
|
2764
|
+
case "pnpm":
|
|
2765
|
+
return `pnpm update -g ${packageName}@latest`;
|
|
2766
|
+
case "bun":
|
|
2767
|
+
return `bun update -g ${packageName}@latest`;
|
|
2768
|
+
case "npm":
|
|
2769
|
+
return `npm update -g ${packageName}@latest`;
|
|
2770
|
+
case "unknown":
|
|
2771
|
+
return `npm update -g ${packageName}@latest`;
|
|
2772
|
+
}
|
|
2773
|
+
} else {
|
|
2774
|
+
switch (pm.name) {
|
|
2775
|
+
case "yarn":
|
|
2776
|
+
return `yarn upgrade ${packageName}@latest`;
|
|
2777
|
+
case "pnpm":
|
|
2778
|
+
return `pnpm update ${packageName}@latest`;
|
|
2779
|
+
case "bun":
|
|
2780
|
+
return `bun update ${packageName}@latest`;
|
|
2781
|
+
case "npm":
|
|
2782
|
+
return `npm update ${packageName}@latest`;
|
|
2783
|
+
case "unknown":
|
|
2784
|
+
return `npm update ${packageName}@latest`;
|
|
2785
|
+
}
|
|
2786
|
+
}
|
|
2787
|
+
}
|
|
2788
|
+
|
|
2789
|
+
// src/utils/version-checker.ts
|
|
2790
|
+
var config = null;
|
|
2791
|
+
function getConfig() {
|
|
2792
|
+
if (!config) {
|
|
2793
|
+
config = new Conf__default.default({ projectName: "zapier-sdk-cli" });
|
|
2794
|
+
}
|
|
2795
|
+
return config;
|
|
2796
|
+
}
|
|
2797
|
+
var ONE_DAY_MS = 24 * 60 * 60 * 1e3;
|
|
2798
|
+
var CACHE_RESET_INTERVAL_MS = (() => {
|
|
2799
|
+
const { ZAPIER_SDK_UPDATE_CHECK_INTERVAL_MS = `${ONE_DAY_MS}` } = process.env;
|
|
2800
|
+
const interval = parseInt(ZAPIER_SDK_UPDATE_CHECK_INTERVAL_MS);
|
|
2801
|
+
if (isNaN(interval) || interval < 0) {
|
|
2802
|
+
return -1;
|
|
2803
|
+
}
|
|
2804
|
+
return interval;
|
|
2805
|
+
})();
|
|
2806
|
+
function getVersionCache() {
|
|
2807
|
+
try {
|
|
2808
|
+
const cache = getConfig().get("version_cache");
|
|
2809
|
+
const now = Date.now();
|
|
2810
|
+
if (!cache || !cache.last_reset_timestamp || now - cache.last_reset_timestamp >= CACHE_RESET_INTERVAL_MS) {
|
|
2811
|
+
const newCache = {
|
|
2812
|
+
last_reset_timestamp: now,
|
|
2813
|
+
packages: {}
|
|
2814
|
+
};
|
|
2815
|
+
getConfig().set("version_cache", newCache);
|
|
2816
|
+
return newCache;
|
|
2817
|
+
}
|
|
2818
|
+
return cache;
|
|
2819
|
+
} catch (error) {
|
|
2820
|
+
log_default.debug(`Failed to read version cache: ${error}`);
|
|
2821
|
+
return {
|
|
2822
|
+
last_reset_timestamp: Date.now(),
|
|
2823
|
+
packages: {}
|
|
2824
|
+
};
|
|
2825
|
+
}
|
|
2826
|
+
}
|
|
2827
|
+
function setCachedPackageInfo(packageName, version, info) {
|
|
2828
|
+
try {
|
|
2829
|
+
const cache = getVersionCache();
|
|
2830
|
+
if (!cache.packages[packageName]) {
|
|
2831
|
+
cache.packages[packageName] = {};
|
|
2832
|
+
}
|
|
2833
|
+
cache.packages[packageName][version] = info;
|
|
2834
|
+
getConfig().set("version_cache", cache);
|
|
2835
|
+
} catch (error) {
|
|
2836
|
+
log_default.debug(`Failed to cache package info: ${error}`);
|
|
2837
|
+
}
|
|
2838
|
+
}
|
|
2839
|
+
function getCachedPackageInfo(packageName, version) {
|
|
2840
|
+
try {
|
|
2841
|
+
const cache = getVersionCache();
|
|
2842
|
+
return cache.packages[packageName]?.[version];
|
|
2843
|
+
} catch (error) {
|
|
2844
|
+
log_default.debug(`Failed to get cached package info: ${error}`);
|
|
2845
|
+
return void 0;
|
|
2846
|
+
}
|
|
2847
|
+
}
|
|
2848
|
+
async function fetchCachedPackageInfo(packageName, version) {
|
|
2849
|
+
const cacheKey = version || "latest";
|
|
2850
|
+
let cachedInfo = getCachedPackageInfo(packageName, cacheKey);
|
|
2851
|
+
if (cachedInfo) {
|
|
2852
|
+
return cachedInfo;
|
|
2853
|
+
}
|
|
2854
|
+
const packageInfo = await packageJsonLib__default.default(packageName, {
|
|
2855
|
+
version,
|
|
2856
|
+
fullMetadata: true
|
|
2857
|
+
});
|
|
2858
|
+
const info = {
|
|
2859
|
+
version: packageInfo.version,
|
|
2860
|
+
deprecated: packageInfo.deprecated,
|
|
2861
|
+
fetched_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
2862
|
+
};
|
|
2863
|
+
setCachedPackageInfo(packageName, cacheKey, info);
|
|
2864
|
+
return info;
|
|
2865
|
+
}
|
|
2866
|
+
async function checkForUpdates({
|
|
2867
|
+
packageName,
|
|
2868
|
+
currentVersion
|
|
2869
|
+
}) {
|
|
2870
|
+
try {
|
|
2871
|
+
const latestPackageInfo = await fetchCachedPackageInfo(packageName);
|
|
2872
|
+
const latestVersion = latestPackageInfo.version;
|
|
2873
|
+
const hasUpdate = currentVersion !== latestVersion;
|
|
2874
|
+
let currentPackageInfo;
|
|
2875
|
+
try {
|
|
2876
|
+
currentPackageInfo = await fetchCachedPackageInfo(
|
|
2877
|
+
packageName,
|
|
2878
|
+
currentVersion
|
|
2879
|
+
);
|
|
2880
|
+
} catch (error) {
|
|
2881
|
+
log_default.debug(`Failed to check deprecation for current version: ${error}`);
|
|
2882
|
+
currentPackageInfo = latestPackageInfo;
|
|
2883
|
+
}
|
|
2884
|
+
const isDeprecated = Boolean(currentPackageInfo.deprecated);
|
|
2885
|
+
const deprecationMessage = isDeprecated ? String(currentPackageInfo.deprecated) : void 0;
|
|
2886
|
+
return {
|
|
2887
|
+
hasUpdate,
|
|
2888
|
+
latestVersion,
|
|
2889
|
+
currentVersion,
|
|
2890
|
+
isDeprecated,
|
|
2891
|
+
deprecationMessage
|
|
2892
|
+
};
|
|
2893
|
+
} catch (error) {
|
|
2894
|
+
log_default.debug(`Failed to check for updates: ${error}`);
|
|
2895
|
+
return {
|
|
2896
|
+
hasUpdate: false,
|
|
2897
|
+
currentVersion,
|
|
2898
|
+
isDeprecated: false
|
|
2899
|
+
};
|
|
2900
|
+
}
|
|
2901
|
+
}
|
|
2902
|
+
function displayUpdateNotification(versionInfo, packageName) {
|
|
2903
|
+
if (versionInfo.isDeprecated) {
|
|
2904
|
+
console.error();
|
|
2905
|
+
console.error(
|
|
2906
|
+
chalk3__default.default.red.bold("\u26A0\uFE0F DEPRECATION WARNING") + chalk3__default.default.red(
|
|
2907
|
+
` - ${packageName} v${versionInfo.currentVersion} is deprecated.`
|
|
2908
|
+
)
|
|
2909
|
+
);
|
|
2910
|
+
if (versionInfo.deprecationMessage) {
|
|
2911
|
+
console.error(chalk3__default.default.red(` ${versionInfo.deprecationMessage}`));
|
|
2912
|
+
}
|
|
2913
|
+
console.error(chalk3__default.default.red(` Please update to the latest version.`));
|
|
2914
|
+
console.error();
|
|
2915
|
+
}
|
|
2916
|
+
if (versionInfo.hasUpdate) {
|
|
2917
|
+
console.log();
|
|
2918
|
+
console.log(
|
|
2919
|
+
chalk3__default.default.yellow.bold("\u{1F4E6} Update available!") + chalk3__default.default.yellow(
|
|
2920
|
+
` ${packageName} v${versionInfo.currentVersion} \u2192 v${versionInfo.latestVersion}`
|
|
2921
|
+
)
|
|
2922
|
+
);
|
|
2923
|
+
console.log(
|
|
2924
|
+
chalk3__default.default.yellow(
|
|
2925
|
+
` Run ${chalk3__default.default.bold(getUpdateCommand(packageName))} to update.`
|
|
2926
|
+
)
|
|
2927
|
+
);
|
|
2928
|
+
console.log();
|
|
2929
|
+
}
|
|
2930
|
+
}
|
|
2931
|
+
async function checkAndNotifyUpdates({
|
|
2932
|
+
packageName,
|
|
2933
|
+
currentVersion
|
|
2934
|
+
}) {
|
|
2935
|
+
if (CACHE_RESET_INTERVAL_MS < 0) {
|
|
2936
|
+
return;
|
|
2937
|
+
}
|
|
2938
|
+
const versionInfo = await checkForUpdates({ packageName, currentVersion });
|
|
2939
|
+
displayUpdateNotification(versionInfo, packageName);
|
|
2940
|
+
}
|
|
2686
2941
|
|
|
2687
2942
|
// src/cli.ts
|
|
2688
2943
|
var program = new commander.Command();
|
|
@@ -2710,4 +2965,25 @@ var sdk = createZapierCliSdk({
|
|
|
2710
2965
|
trackingBaseUrl
|
|
2711
2966
|
});
|
|
2712
2967
|
generateCliCommands(program, sdk);
|
|
2713
|
-
program.
|
|
2968
|
+
program.exitOverride();
|
|
2969
|
+
(async () => {
|
|
2970
|
+
let exitCode = 0;
|
|
2971
|
+
const versionCheckPromise = checkAndNotifyUpdates({
|
|
2972
|
+
packageName: package_default2.name,
|
|
2973
|
+
currentVersion: package_default2.version
|
|
2974
|
+
});
|
|
2975
|
+
try {
|
|
2976
|
+
await program.parseAsync();
|
|
2977
|
+
} catch (error) {
|
|
2978
|
+
if (error instanceof ZapierCliError) {
|
|
2979
|
+
exitCode = error.exitCode;
|
|
2980
|
+
} else if (error instanceof commander.CommanderError) {
|
|
2981
|
+
exitCode = error.exitCode;
|
|
2982
|
+
} else {
|
|
2983
|
+
console.error("Unexpected error:", error);
|
|
2984
|
+
exitCode = 1;
|
|
2985
|
+
}
|
|
2986
|
+
}
|
|
2987
|
+
await versionCheckPromise;
|
|
2988
|
+
process.exit(exitCode);
|
|
2989
|
+
})();
|