@zapier/zapier-sdk-cli 0.52.5 → 0.52.7
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 +29 -0
- package/README.md +136 -12
- package/dist/cli.cjs +56 -59
- package/dist/cli.mjs +56 -59
- package/dist/experimental.cjs +55 -58
- package/dist/experimental.mjs +55 -58
- package/dist/index.cjs +56 -59
- package/dist/index.mjs +56 -59
- package/dist/package.json +1 -1
- package/dist/src/login/credentials-revoke.js +13 -6
- package/dist/src/login/credentials-store.d.ts +0 -4
- package/dist/src/login/credentials-store.js +0 -3
- package/dist/src/plugins/init/display.js +2 -2
- package/dist/src/plugins/init/index.d.ts +1 -0
- package/dist/src/plugins/init/index.js +4 -2
- package/dist/src/plugins/init/schemas.d.ts +1 -0
- package/dist/src/plugins/init/schemas.js +6 -1
- package/dist/src/plugins/init/steps.d.ts +2 -2
- package/dist/src/plugins/init/steps.js +3 -3
- package/dist/src/plugins/init/types.d.ts +1 -1
- package/dist/src/plugins/init/utils.d.ts +2 -2
- package/dist/src/plugins/init/utils.js +2 -2
- package/dist/src/plugins/login/index.d.ts +1 -0
- package/dist/src/plugins/login/index.js +15 -22
- package/dist/src/plugins/login/schemas.d.ts +1 -0
- package/dist/src/plugins/login/schemas.js +6 -1
- package/dist/src/plugins/logout/index.js +0 -15
- package/dist/src/plugins/logout/schemas.d.ts +0 -1
- package/dist/src/plugins/logout/schemas.js +0 -1
- package/dist/src/utils/non-interactive.d.ts +13 -0
- package/dist/src/utils/non-interactive.js +14 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +3 -3
package/dist/experimental.mjs
CHANGED
|
@@ -375,12 +375,6 @@ async function storeClientCredentials({
|
|
|
375
375
|
await deleteKeychainSecret(existingEntry);
|
|
376
376
|
}
|
|
377
377
|
}
|
|
378
|
-
function credentialsNameExists({
|
|
379
|
-
name,
|
|
380
|
-
baseUrl
|
|
381
|
-
}) {
|
|
382
|
-
return !!findEntry(readRegistry(), name, normalizeBaseUrl(baseUrl));
|
|
383
|
-
}
|
|
384
378
|
async function getStoredClientCredentials(options) {
|
|
385
379
|
const entry = options?.name ? findEntry(readRegistry(), options.name, normalizeBaseUrl(options.baseUrl)) : getActiveCredentials(options);
|
|
386
380
|
if (!entry) return void 0;
|
|
@@ -816,8 +810,11 @@ function emitAuthLogout(onEvent) {
|
|
|
816
810
|
timestamp: Date.now()
|
|
817
811
|
});
|
|
818
812
|
}
|
|
819
|
-
function
|
|
820
|
-
|
|
813
|
+
function getStatusCode(err) {
|
|
814
|
+
if (typeof err === "object" && err !== null && "statusCode" in err) {
|
|
815
|
+
return err.statusCode;
|
|
816
|
+
}
|
|
817
|
+
return void 0;
|
|
821
818
|
}
|
|
822
819
|
async function revokeCredentials({
|
|
823
820
|
api: api2,
|
|
@@ -833,7 +830,14 @@ async function revokeCredentials({
|
|
|
833
830
|
{ authRequired: true, requiredScopes: ["credentials"] }
|
|
834
831
|
);
|
|
835
832
|
} catch (err) {
|
|
836
|
-
|
|
833
|
+
const status = getStatusCode(err);
|
|
834
|
+
if (status === 404) return;
|
|
835
|
+
if (status === 401) {
|
|
836
|
+
console.warn(
|
|
837
|
+
"Could not revoke credentials on the server (unauthorized). Local state will be cleared, but the credential may still be active. Verify or revoke via `list-client-credentials` or `delete-client-credentials`."
|
|
838
|
+
);
|
|
839
|
+
return;
|
|
840
|
+
}
|
|
837
841
|
throw err;
|
|
838
842
|
}
|
|
839
843
|
}
|
|
@@ -1221,14 +1225,24 @@ async function resolveCredentialsBaseUrl(context) {
|
|
|
1221
1225
|
const resolvedCredentials = "resolvedCredentials" in context ? context.resolvedCredentials : await context.resolveCredentials?.();
|
|
1222
1226
|
return getBaseUrlFromResolvedCredentials(resolvedCredentials) ?? getBaseUrlFromOptionsCredentials(context.options?.credentials) ?? context.options?.baseUrl;
|
|
1223
1227
|
}
|
|
1228
|
+
|
|
1229
|
+
// src/utils/non-interactive.ts
|
|
1230
|
+
function resolveNonInteractive(options) {
|
|
1231
|
+
return (options.nonInteractive ?? options.skipPrompts) === true || !process.stdin.isTTY || !process.stdout.isTTY;
|
|
1232
|
+
}
|
|
1224
1233
|
var LoginSchema = z.object({
|
|
1225
1234
|
timeout: z.string().optional().describe("Login timeout in seconds (default: 300)"),
|
|
1226
1235
|
useApprovals: z.boolean().optional().describe(
|
|
1227
1236
|
"Require approvals for actions performed with these credentials"
|
|
1228
1237
|
),
|
|
1229
|
-
|
|
1238
|
+
nonInteractive: z.boolean().optional().describe(
|
|
1230
1239
|
"Skip interactive prompts. Uses defaults where possible; errors instead of prompting when input is required. Useful in CI, piped output, or environments where TTY detection is unreliable."
|
|
1231
|
-
)
|
|
1240
|
+
),
|
|
1241
|
+
/** @deprecated Use `nonInteractive` instead. */
|
|
1242
|
+
skipPrompts: z.boolean().optional().meta({
|
|
1243
|
+
deprecated: true,
|
|
1244
|
+
deprecationMessage: "Use --non-interactive instead."
|
|
1245
|
+
})
|
|
1232
1246
|
}).describe("Log in to Zapier to access your account");
|
|
1233
1247
|
|
|
1234
1248
|
// src/plugins/login/index.ts
|
|
@@ -1243,8 +1257,8 @@ function toPkceCredentials(credentials) {
|
|
|
1243
1257
|
}
|
|
1244
1258
|
return void 0;
|
|
1245
1259
|
}
|
|
1246
|
-
async function confirmRevokeAndRelogin(activeCredentials,
|
|
1247
|
-
if (
|
|
1260
|
+
async function confirmRevokeAndRelogin(activeCredentials, nonInteractive) {
|
|
1261
|
+
if (nonInteractive) {
|
|
1248
1262
|
throw new ZapierCliValidationError(
|
|
1249
1263
|
`Already logged in as "${activeCredentials.name}". Run \`logout\` first or use an interactive terminal to re-authenticate.`
|
|
1250
1264
|
);
|
|
@@ -1265,8 +1279,8 @@ Log out and log in again?`,
|
|
|
1265
1279
|
}
|
|
1266
1280
|
return true;
|
|
1267
1281
|
}
|
|
1268
|
-
async function confirmJwtMigration(
|
|
1269
|
-
if (
|
|
1282
|
+
async function confirmJwtMigration(nonInteractive) {
|
|
1283
|
+
if (nonInteractive) {
|
|
1270
1284
|
throw new ZapierCliValidationError(
|
|
1271
1285
|
"Legacy JWT login detected. Run `logout` first or use an interactive terminal to migrate to client credentials."
|
|
1272
1286
|
);
|
|
@@ -1285,8 +1299,8 @@ async function confirmJwtMigration(skipPrompts) {
|
|
|
1285
1299
|
}
|
|
1286
1300
|
return true;
|
|
1287
1301
|
}
|
|
1288
|
-
async function confirmLocalLoginReset(
|
|
1289
|
-
if (
|
|
1302
|
+
async function confirmLocalLoginReset(nonInteractive) {
|
|
1303
|
+
if (nonInteractive) {
|
|
1290
1304
|
throw new ZapierCliValidationError(
|
|
1291
1305
|
"Login cleanup failed and cannot be reset without confirmation. Re-run with an interactive terminal."
|
|
1292
1306
|
);
|
|
@@ -1312,14 +1326,9 @@ function parseTimeoutSeconds(timeout) {
|
|
|
1312
1326
|
}
|
|
1313
1327
|
return timeoutSeconds;
|
|
1314
1328
|
}
|
|
1315
|
-
async function promptCredentialsName(email,
|
|
1329
|
+
async function promptCredentialsName(email, nonInteractive) {
|
|
1316
1330
|
const fallback = `${email}@${hostname()}`;
|
|
1317
|
-
if (
|
|
1318
|
-
if (credentialsNameExists({ name: fallback, baseUrl })) {
|
|
1319
|
-
throw new ZapierCliValidationError(
|
|
1320
|
-
`Credentials named "${fallback}" already exist. Run \`logout\` first or use an interactive terminal to choose a different name.`
|
|
1321
|
-
);
|
|
1322
|
-
}
|
|
1331
|
+
if (nonInteractive) {
|
|
1323
1332
|
return fallback;
|
|
1324
1333
|
}
|
|
1325
1334
|
const { credentialName } = await inquirer.prompt([
|
|
@@ -1330,9 +1339,6 @@ async function promptCredentialsName(email, skipPrompts, baseUrl) {
|
|
|
1330
1339
|
default: fallback,
|
|
1331
1340
|
validate: (input) => {
|
|
1332
1341
|
if (!input.trim()) return "Name cannot be empty";
|
|
1333
|
-
if (credentialsNameExists({ name: input.trim(), baseUrl })) {
|
|
1334
|
-
return `Credentials named "${input.trim()}" already exist. Please provide a different name.`;
|
|
1335
|
-
}
|
|
1336
1342
|
return true;
|
|
1337
1343
|
}
|
|
1338
1344
|
}
|
|
@@ -1376,7 +1382,7 @@ var loginPlugin = definePlugin(
|
|
|
1376
1382
|
supportsJsonOutput: false,
|
|
1377
1383
|
handler: async ({ sdk: sdk2, options }) => {
|
|
1378
1384
|
const timeoutSeconds = parseTimeoutSeconds(options.timeout);
|
|
1379
|
-
const
|
|
1385
|
+
const nonInteractive = resolveNonInteractive(options);
|
|
1380
1386
|
const resolvedCredentials = await sdk2.context.resolveCredentials();
|
|
1381
1387
|
const pkceCredentials = toPkceCredentials(resolvedCredentials);
|
|
1382
1388
|
const credentialsBaseUrl = await resolveCredentialsBaseUrl({
|
|
@@ -1387,7 +1393,7 @@ var loginPlugin = definePlugin(
|
|
|
1387
1393
|
baseUrl: credentialsBaseUrl
|
|
1388
1394
|
});
|
|
1389
1395
|
if (activeCredentials) {
|
|
1390
|
-
if (!await confirmRevokeAndRelogin(activeCredentials,
|
|
1396
|
+
if (!await confirmRevokeAndRelogin(activeCredentials, nonInteractive))
|
|
1391
1397
|
return;
|
|
1392
1398
|
try {
|
|
1393
1399
|
await revokeCredentials({
|
|
@@ -1395,14 +1401,14 @@ var loginPlugin = definePlugin(
|
|
|
1395
1401
|
credentials: activeCredentials
|
|
1396
1402
|
});
|
|
1397
1403
|
} catch {
|
|
1398
|
-
if (!await confirmLocalLoginReset(
|
|
1404
|
+
if (!await confirmLocalLoginReset(nonInteractive)) return;
|
|
1399
1405
|
await deleteStoredClientCredentials({
|
|
1400
1406
|
name: activeCredentials.name,
|
|
1401
1407
|
baseUrl: activeCredentials.baseUrl
|
|
1402
1408
|
});
|
|
1403
1409
|
}
|
|
1404
1410
|
} else if (hasLegacyJwtConfig()) {
|
|
1405
|
-
if (!await confirmJwtMigration(
|
|
1411
|
+
if (!await confirmJwtMigration(nonInteractive)) return;
|
|
1406
1412
|
}
|
|
1407
1413
|
const { accessToken } = await runOauthFlow({
|
|
1408
1414
|
timeoutMs: timeoutSeconds * 1e3,
|
|
@@ -1420,8 +1426,7 @@ var loginPlugin = definePlugin(
|
|
|
1420
1426
|
);
|
|
1421
1427
|
const credentialName = await promptCredentialsName(
|
|
1422
1428
|
profile.email,
|
|
1423
|
-
|
|
1424
|
-
credentialsBaseUrl
|
|
1429
|
+
nonInteractive
|
|
1425
1430
|
);
|
|
1426
1431
|
const useApprovals = options.useApprovals === true;
|
|
1427
1432
|
await setupClientCredentials({
|
|
@@ -1461,20 +1466,6 @@ var logoutPlugin = definePlugin(
|
|
|
1461
1466
|
console.log("\u2705 Successfully logged out");
|
|
1462
1467
|
return;
|
|
1463
1468
|
}
|
|
1464
|
-
const { confirmed } = await inquirer.prompt([
|
|
1465
|
-
{
|
|
1466
|
-
type: "confirm",
|
|
1467
|
-
name: "confirmed",
|
|
1468
|
-
message: `Logging out will delete credentials "${activeCredentials.name}".
|
|
1469
|
-
This may interrupt other Zapier SDK or CLI sessions using them.
|
|
1470
|
-
Do you want to continue?`,
|
|
1471
|
-
default: true
|
|
1472
|
-
}
|
|
1473
|
-
]);
|
|
1474
|
-
if (!confirmed) {
|
|
1475
|
-
console.log("Logout cancelled.");
|
|
1476
|
-
return;
|
|
1477
|
-
}
|
|
1478
1469
|
await revokeCredentials({
|
|
1479
1470
|
api: sdk2.context.api,
|
|
1480
1471
|
credentials: activeCredentials,
|
|
@@ -3034,7 +3025,12 @@ var cliOverridesPlugin = definePlugin(
|
|
|
3034
3025
|
var TEMPLATES = ["basic"];
|
|
3035
3026
|
var InitSchema = z.object({
|
|
3036
3027
|
projectName: z.string().min(1).describe("Name of the project directory to create"),
|
|
3037
|
-
|
|
3028
|
+
nonInteractive: z.boolean().optional().describe("Skip all interactive prompts and accept all defaults"),
|
|
3029
|
+
/** @deprecated Use `nonInteractive` instead. */
|
|
3030
|
+
skipPrompts: z.boolean().optional().meta({
|
|
3031
|
+
deprecated: true,
|
|
3032
|
+
deprecationMessage: "Use --non-interactive instead."
|
|
3033
|
+
})
|
|
3038
3034
|
}).describe(
|
|
3039
3035
|
"Create a new Zapier SDK project in a new directory with starter files"
|
|
3040
3036
|
);
|
|
@@ -3102,9 +3098,9 @@ function createExec({ cwd }) {
|
|
|
3102
3098
|
async function promptYesNo({
|
|
3103
3099
|
message,
|
|
3104
3100
|
defaultValue,
|
|
3105
|
-
|
|
3101
|
+
nonInteractive
|
|
3106
3102
|
}) {
|
|
3107
|
-
if (
|
|
3103
|
+
if (nonInteractive) return defaultValue;
|
|
3108
3104
|
const { answer } = await inquirer.prompt([
|
|
3109
3105
|
{ type: "confirm", name: "answer", message, default: defaultValue }
|
|
3110
3106
|
]);
|
|
@@ -3252,14 +3248,14 @@ async function runStep({
|
|
|
3252
3248
|
step,
|
|
3253
3249
|
stepNumber,
|
|
3254
3250
|
totalSteps,
|
|
3255
|
-
|
|
3251
|
+
nonInteractive,
|
|
3256
3252
|
displayHooks
|
|
3257
3253
|
}) {
|
|
3258
3254
|
if (step.askConfirmation) {
|
|
3259
3255
|
const should = await promptYesNo({
|
|
3260
3256
|
message: step.description,
|
|
3261
3257
|
defaultValue: true,
|
|
3262
|
-
|
|
3258
|
+
nonInteractive
|
|
3263
3259
|
});
|
|
3264
3260
|
if (!should) return false;
|
|
3265
3261
|
}
|
|
@@ -3268,7 +3264,7 @@ async function runStep({
|
|
|
3268
3264
|
stepNumber,
|
|
3269
3265
|
totalSteps,
|
|
3270
3266
|
command: step.command,
|
|
3271
|
-
|
|
3267
|
+
nonInteractive
|
|
3272
3268
|
});
|
|
3273
3269
|
try {
|
|
3274
3270
|
await step.run();
|
|
@@ -3369,11 +3365,11 @@ function createConsoleDisplayHooks() {
|
|
|
3369
3365
|
stepNumber,
|
|
3370
3366
|
totalSteps,
|
|
3371
3367
|
command,
|
|
3372
|
-
|
|
3368
|
+
nonInteractive
|
|
3373
3369
|
}) => {
|
|
3374
3370
|
const progressMessage = `${description}...`;
|
|
3375
3371
|
const stepCounter = chalk3.dim(`${stepNumber}/${totalSteps}`);
|
|
3376
|
-
if (
|
|
3372
|
+
if (nonInteractive) {
|
|
3377
3373
|
console.log(
|
|
3378
3374
|
"\n" + chalk3.bold(`\u276F ${progressMessage}`) + " " + stepCounter + "\n"
|
|
3379
3375
|
);
|
|
@@ -3449,7 +3445,8 @@ var initPlugin = definePlugin(
|
|
|
3449
3445
|
inputSchema: InitSchema,
|
|
3450
3446
|
supportsJsonOutput: false,
|
|
3451
3447
|
handler: async ({ options }) => {
|
|
3452
|
-
const { projectName: rawName
|
|
3448
|
+
const { projectName: rawName } = options;
|
|
3449
|
+
const nonInteractive = resolveNonInteractive(options);
|
|
3453
3450
|
const cwd = process.cwd();
|
|
3454
3451
|
const { projectName, projectDir } = validateInitOptions({ rawName, cwd });
|
|
3455
3452
|
const displayHooks = createConsoleDisplayHooks();
|
|
@@ -3475,7 +3472,7 @@ var initPlugin = definePlugin(
|
|
|
3475
3472
|
step,
|
|
3476
3473
|
stepNumber: i + 1,
|
|
3477
3474
|
totalSteps: steps.length,
|
|
3478
|
-
|
|
3475
|
+
nonInteractive,
|
|
3479
3476
|
displayHooks
|
|
3480
3477
|
})
|
|
3481
3478
|
);
|
|
@@ -3980,7 +3977,7 @@ var watchTriggerInboxCliPlugin = definePlugin(
|
|
|
3980
3977
|
// package.json with { type: 'json' }
|
|
3981
3978
|
var package_default = {
|
|
3982
3979
|
name: "@zapier/zapier-sdk-cli",
|
|
3983
|
-
version: "0.52.
|
|
3980
|
+
version: "0.52.7"};
|
|
3984
3981
|
|
|
3985
3982
|
// src/experimental.ts
|
|
3986
3983
|
injectCliLogin(login_exports);
|
package/dist/index.cjs
CHANGED
|
@@ -410,12 +410,6 @@ async function storeClientCredentials({
|
|
|
410
410
|
await deleteKeychainSecret(existingEntry);
|
|
411
411
|
}
|
|
412
412
|
}
|
|
413
|
-
function credentialsNameExists({
|
|
414
|
-
name,
|
|
415
|
-
baseUrl
|
|
416
|
-
}) {
|
|
417
|
-
return !!findEntry(readRegistry(), name, normalizeBaseUrl(baseUrl));
|
|
418
|
-
}
|
|
419
413
|
async function getStoredClientCredentials(options) {
|
|
420
414
|
const entry = options?.name ? findEntry(readRegistry(), options.name, normalizeBaseUrl(options.baseUrl)) : getActiveCredentials(options);
|
|
421
415
|
if (!entry) return void 0;
|
|
@@ -851,8 +845,11 @@ function emitAuthLogout(onEvent) {
|
|
|
851
845
|
timestamp: Date.now()
|
|
852
846
|
});
|
|
853
847
|
}
|
|
854
|
-
function
|
|
855
|
-
|
|
848
|
+
function getStatusCode(err) {
|
|
849
|
+
if (typeof err === "object" && err !== null && "statusCode" in err) {
|
|
850
|
+
return err.statusCode;
|
|
851
|
+
}
|
|
852
|
+
return void 0;
|
|
856
853
|
}
|
|
857
854
|
async function revokeCredentials({
|
|
858
855
|
api: api2,
|
|
@@ -868,7 +865,14 @@ async function revokeCredentials({
|
|
|
868
865
|
{ authRequired: true, requiredScopes: ["credentials"] }
|
|
869
866
|
);
|
|
870
867
|
} catch (err) {
|
|
871
|
-
|
|
868
|
+
const status = getStatusCode(err);
|
|
869
|
+
if (status === 404) return;
|
|
870
|
+
if (status === 401) {
|
|
871
|
+
console.warn(
|
|
872
|
+
"Could not revoke credentials on the server (unauthorized). Local state will be cleared, but the credential may still be active. Verify or revoke via `list-client-credentials` or `delete-client-credentials`."
|
|
873
|
+
);
|
|
874
|
+
return;
|
|
875
|
+
}
|
|
872
876
|
throw err;
|
|
873
877
|
}
|
|
874
878
|
}
|
|
@@ -1256,14 +1260,24 @@ async function resolveCredentialsBaseUrl(context) {
|
|
|
1256
1260
|
const resolvedCredentials = "resolvedCredentials" in context ? context.resolvedCredentials : await context.resolveCredentials?.();
|
|
1257
1261
|
return getBaseUrlFromResolvedCredentials(resolvedCredentials) ?? getBaseUrlFromOptionsCredentials(context.options?.credentials) ?? context.options?.baseUrl;
|
|
1258
1262
|
}
|
|
1263
|
+
|
|
1264
|
+
// src/utils/non-interactive.ts
|
|
1265
|
+
function resolveNonInteractive(options) {
|
|
1266
|
+
return (options.nonInteractive ?? options.skipPrompts) === true || !process.stdin.isTTY || !process.stdout.isTTY;
|
|
1267
|
+
}
|
|
1259
1268
|
var LoginSchema = zod.z.object({
|
|
1260
1269
|
timeout: zod.z.string().optional().describe("Login timeout in seconds (default: 300)"),
|
|
1261
1270
|
useApprovals: zod.z.boolean().optional().describe(
|
|
1262
1271
|
"Require approvals for actions performed with these credentials"
|
|
1263
1272
|
),
|
|
1264
|
-
|
|
1273
|
+
nonInteractive: zod.z.boolean().optional().describe(
|
|
1265
1274
|
"Skip interactive prompts. Uses defaults where possible; errors instead of prompting when input is required. Useful in CI, piped output, or environments where TTY detection is unreliable."
|
|
1266
|
-
)
|
|
1275
|
+
),
|
|
1276
|
+
/** @deprecated Use `nonInteractive` instead. */
|
|
1277
|
+
skipPrompts: zod.z.boolean().optional().meta({
|
|
1278
|
+
deprecated: true,
|
|
1279
|
+
deprecationMessage: "Use --non-interactive instead."
|
|
1280
|
+
})
|
|
1267
1281
|
}).describe("Log in to Zapier to access your account");
|
|
1268
1282
|
|
|
1269
1283
|
// src/plugins/login/index.ts
|
|
@@ -1278,8 +1292,8 @@ function toPkceCredentials(credentials) {
|
|
|
1278
1292
|
}
|
|
1279
1293
|
return void 0;
|
|
1280
1294
|
}
|
|
1281
|
-
async function confirmRevokeAndRelogin(activeCredentials,
|
|
1282
|
-
if (
|
|
1295
|
+
async function confirmRevokeAndRelogin(activeCredentials, nonInteractive) {
|
|
1296
|
+
if (nonInteractive) {
|
|
1283
1297
|
throw new ZapierCliValidationError(
|
|
1284
1298
|
`Already logged in as "${activeCredentials.name}". Run \`logout\` first or use an interactive terminal to re-authenticate.`
|
|
1285
1299
|
);
|
|
@@ -1300,8 +1314,8 @@ Log out and log in again?`,
|
|
|
1300
1314
|
}
|
|
1301
1315
|
return true;
|
|
1302
1316
|
}
|
|
1303
|
-
async function confirmJwtMigration(
|
|
1304
|
-
if (
|
|
1317
|
+
async function confirmJwtMigration(nonInteractive) {
|
|
1318
|
+
if (nonInteractive) {
|
|
1305
1319
|
throw new ZapierCliValidationError(
|
|
1306
1320
|
"Legacy JWT login detected. Run `logout` first or use an interactive terminal to migrate to client credentials."
|
|
1307
1321
|
);
|
|
@@ -1320,8 +1334,8 @@ async function confirmJwtMigration(skipPrompts) {
|
|
|
1320
1334
|
}
|
|
1321
1335
|
return true;
|
|
1322
1336
|
}
|
|
1323
|
-
async function confirmLocalLoginReset(
|
|
1324
|
-
if (
|
|
1337
|
+
async function confirmLocalLoginReset(nonInteractive) {
|
|
1338
|
+
if (nonInteractive) {
|
|
1325
1339
|
throw new ZapierCliValidationError(
|
|
1326
1340
|
"Login cleanup failed and cannot be reset without confirmation. Re-run with an interactive terminal."
|
|
1327
1341
|
);
|
|
@@ -1347,14 +1361,9 @@ function parseTimeoutSeconds(timeout) {
|
|
|
1347
1361
|
}
|
|
1348
1362
|
return timeoutSeconds;
|
|
1349
1363
|
}
|
|
1350
|
-
async function promptCredentialsName(email,
|
|
1364
|
+
async function promptCredentialsName(email, nonInteractive) {
|
|
1351
1365
|
const fallback = `${email}@${os.hostname()}`;
|
|
1352
|
-
if (
|
|
1353
|
-
if (credentialsNameExists({ name: fallback, baseUrl })) {
|
|
1354
|
-
throw new ZapierCliValidationError(
|
|
1355
|
-
`Credentials named "${fallback}" already exist. Run \`logout\` first or use an interactive terminal to choose a different name.`
|
|
1356
|
-
);
|
|
1357
|
-
}
|
|
1366
|
+
if (nonInteractive) {
|
|
1358
1367
|
return fallback;
|
|
1359
1368
|
}
|
|
1360
1369
|
const { credentialName } = await inquirer__default.default.prompt([
|
|
@@ -1365,9 +1374,6 @@ async function promptCredentialsName(email, skipPrompts, baseUrl) {
|
|
|
1365
1374
|
default: fallback,
|
|
1366
1375
|
validate: (input) => {
|
|
1367
1376
|
if (!input.trim()) return "Name cannot be empty";
|
|
1368
|
-
if (credentialsNameExists({ name: input.trim(), baseUrl })) {
|
|
1369
|
-
return `Credentials named "${input.trim()}" already exist. Please provide a different name.`;
|
|
1370
|
-
}
|
|
1371
1377
|
return true;
|
|
1372
1378
|
}
|
|
1373
1379
|
}
|
|
@@ -1411,7 +1417,7 @@ var loginPlugin = zapierSdk.definePlugin(
|
|
|
1411
1417
|
supportsJsonOutput: false,
|
|
1412
1418
|
handler: async ({ sdk: sdk2, options }) => {
|
|
1413
1419
|
const timeoutSeconds = parseTimeoutSeconds(options.timeout);
|
|
1414
|
-
const
|
|
1420
|
+
const nonInteractive = resolveNonInteractive(options);
|
|
1415
1421
|
const resolvedCredentials = await sdk2.context.resolveCredentials();
|
|
1416
1422
|
const pkceCredentials = toPkceCredentials(resolvedCredentials);
|
|
1417
1423
|
const credentialsBaseUrl = await resolveCredentialsBaseUrl({
|
|
@@ -1422,7 +1428,7 @@ var loginPlugin = zapierSdk.definePlugin(
|
|
|
1422
1428
|
baseUrl: credentialsBaseUrl
|
|
1423
1429
|
});
|
|
1424
1430
|
if (activeCredentials) {
|
|
1425
|
-
if (!await confirmRevokeAndRelogin(activeCredentials,
|
|
1431
|
+
if (!await confirmRevokeAndRelogin(activeCredentials, nonInteractive))
|
|
1426
1432
|
return;
|
|
1427
1433
|
try {
|
|
1428
1434
|
await revokeCredentials({
|
|
@@ -1430,14 +1436,14 @@ var loginPlugin = zapierSdk.definePlugin(
|
|
|
1430
1436
|
credentials: activeCredentials
|
|
1431
1437
|
});
|
|
1432
1438
|
} catch {
|
|
1433
|
-
if (!await confirmLocalLoginReset(
|
|
1439
|
+
if (!await confirmLocalLoginReset(nonInteractive)) return;
|
|
1434
1440
|
await deleteStoredClientCredentials({
|
|
1435
1441
|
name: activeCredentials.name,
|
|
1436
1442
|
baseUrl: activeCredentials.baseUrl
|
|
1437
1443
|
});
|
|
1438
1444
|
}
|
|
1439
1445
|
} else if (hasLegacyJwtConfig()) {
|
|
1440
|
-
if (!await confirmJwtMigration(
|
|
1446
|
+
if (!await confirmJwtMigration(nonInteractive)) return;
|
|
1441
1447
|
}
|
|
1442
1448
|
const { accessToken } = await runOauthFlow({
|
|
1443
1449
|
timeoutMs: timeoutSeconds * 1e3,
|
|
@@ -1455,8 +1461,7 @@ var loginPlugin = zapierSdk.definePlugin(
|
|
|
1455
1461
|
);
|
|
1456
1462
|
const credentialName = await promptCredentialsName(
|
|
1457
1463
|
profile.email,
|
|
1458
|
-
|
|
1459
|
-
credentialsBaseUrl
|
|
1464
|
+
nonInteractive
|
|
1460
1465
|
);
|
|
1461
1466
|
const useApprovals = options.useApprovals === true;
|
|
1462
1467
|
await setupClientCredentials({
|
|
@@ -1496,20 +1501,6 @@ var logoutPlugin = zapierSdk.definePlugin(
|
|
|
1496
1501
|
console.log("\u2705 Successfully logged out");
|
|
1497
1502
|
return;
|
|
1498
1503
|
}
|
|
1499
|
-
const { confirmed } = await inquirer__default.default.prompt([
|
|
1500
|
-
{
|
|
1501
|
-
type: "confirm",
|
|
1502
|
-
name: "confirmed",
|
|
1503
|
-
message: `Logging out will delete credentials "${activeCredentials.name}".
|
|
1504
|
-
This may interrupt other Zapier SDK or CLI sessions using them.
|
|
1505
|
-
Do you want to continue?`,
|
|
1506
|
-
default: true
|
|
1507
|
-
}
|
|
1508
|
-
]);
|
|
1509
|
-
if (!confirmed) {
|
|
1510
|
-
console.log("Logout cancelled.");
|
|
1511
|
-
return;
|
|
1512
|
-
}
|
|
1513
1504
|
await revokeCredentials({
|
|
1514
1505
|
api: sdk2.context.api,
|
|
1515
1506
|
credentials: activeCredentials,
|
|
@@ -3069,7 +3060,12 @@ var cliOverridesPlugin = zapierSdk.definePlugin(
|
|
|
3069
3060
|
var TEMPLATES = ["basic"];
|
|
3070
3061
|
var InitSchema = zod.z.object({
|
|
3071
3062
|
projectName: zod.z.string().min(1).describe("Name of the project directory to create"),
|
|
3072
|
-
|
|
3063
|
+
nonInteractive: zod.z.boolean().optional().describe("Skip all interactive prompts and accept all defaults"),
|
|
3064
|
+
/** @deprecated Use `nonInteractive` instead. */
|
|
3065
|
+
skipPrompts: zod.z.boolean().optional().meta({
|
|
3066
|
+
deprecated: true,
|
|
3067
|
+
deprecationMessage: "Use --non-interactive instead."
|
|
3068
|
+
})
|
|
3073
3069
|
}).describe(
|
|
3074
3070
|
"Create a new Zapier SDK project in a new directory with starter files"
|
|
3075
3071
|
);
|
|
@@ -3137,9 +3133,9 @@ function createExec({ cwd }) {
|
|
|
3137
3133
|
async function promptYesNo({
|
|
3138
3134
|
message,
|
|
3139
3135
|
defaultValue,
|
|
3140
|
-
|
|
3136
|
+
nonInteractive
|
|
3141
3137
|
}) {
|
|
3142
|
-
if (
|
|
3138
|
+
if (nonInteractive) return defaultValue;
|
|
3143
3139
|
const { answer } = await inquirer__default.default.prompt([
|
|
3144
3140
|
{ type: "confirm", name: "answer", message, default: defaultValue }
|
|
3145
3141
|
]);
|
|
@@ -3287,14 +3283,14 @@ async function runStep({
|
|
|
3287
3283
|
step,
|
|
3288
3284
|
stepNumber,
|
|
3289
3285
|
totalSteps,
|
|
3290
|
-
|
|
3286
|
+
nonInteractive,
|
|
3291
3287
|
displayHooks
|
|
3292
3288
|
}) {
|
|
3293
3289
|
if (step.askConfirmation) {
|
|
3294
3290
|
const should = await promptYesNo({
|
|
3295
3291
|
message: step.description,
|
|
3296
3292
|
defaultValue: true,
|
|
3297
|
-
|
|
3293
|
+
nonInteractive
|
|
3298
3294
|
});
|
|
3299
3295
|
if (!should) return false;
|
|
3300
3296
|
}
|
|
@@ -3303,7 +3299,7 @@ async function runStep({
|
|
|
3303
3299
|
stepNumber,
|
|
3304
3300
|
totalSteps,
|
|
3305
3301
|
command: step.command,
|
|
3306
|
-
|
|
3302
|
+
nonInteractive
|
|
3307
3303
|
});
|
|
3308
3304
|
try {
|
|
3309
3305
|
await step.run();
|
|
@@ -3404,11 +3400,11 @@ function createConsoleDisplayHooks() {
|
|
|
3404
3400
|
stepNumber,
|
|
3405
3401
|
totalSteps,
|
|
3406
3402
|
command,
|
|
3407
|
-
|
|
3403
|
+
nonInteractive
|
|
3408
3404
|
}) => {
|
|
3409
3405
|
const progressMessage = `${description}...`;
|
|
3410
3406
|
const stepCounter = chalk3__default.default.dim(`${stepNumber}/${totalSteps}`);
|
|
3411
|
-
if (
|
|
3407
|
+
if (nonInteractive) {
|
|
3412
3408
|
console.log(
|
|
3413
3409
|
"\n" + chalk3__default.default.bold(`\u276F ${progressMessage}`) + " " + stepCounter + "\n"
|
|
3414
3410
|
);
|
|
@@ -3484,7 +3480,8 @@ var initPlugin = zapierSdk.definePlugin(
|
|
|
3484
3480
|
inputSchema: InitSchema,
|
|
3485
3481
|
supportsJsonOutput: false,
|
|
3486
3482
|
handler: async ({ options }) => {
|
|
3487
|
-
const { projectName: rawName
|
|
3483
|
+
const { projectName: rawName } = options;
|
|
3484
|
+
const nonInteractive = resolveNonInteractive(options);
|
|
3488
3485
|
const cwd = process.cwd();
|
|
3489
3486
|
const { projectName, projectDir } = validateInitOptions({ rawName, cwd });
|
|
3490
3487
|
const displayHooks = createConsoleDisplayHooks();
|
|
@@ -3510,7 +3507,7 @@ var initPlugin = zapierSdk.definePlugin(
|
|
|
3510
3507
|
step,
|
|
3511
3508
|
stepNumber: i + 1,
|
|
3512
3509
|
totalSteps: steps.length,
|
|
3513
|
-
|
|
3510
|
+
nonInteractive,
|
|
3514
3511
|
displayHooks
|
|
3515
3512
|
})
|
|
3516
3513
|
);
|
|
@@ -4015,7 +4012,7 @@ zapierSdk.definePlugin(
|
|
|
4015
4012
|
// package.json with { type: 'json' }
|
|
4016
4013
|
var package_default = {
|
|
4017
4014
|
name: "@zapier/zapier-sdk-cli",
|
|
4018
|
-
version: "0.52.
|
|
4015
|
+
version: "0.52.7"};
|
|
4019
4016
|
|
|
4020
4017
|
// src/sdk.ts
|
|
4021
4018
|
zapierSdk.injectCliLogin(login_exports);
|
|
@@ -4043,7 +4040,7 @@ function createZapierCliSdk(options = {}) {
|
|
|
4043
4040
|
|
|
4044
4041
|
// package.json
|
|
4045
4042
|
var package_default2 = {
|
|
4046
|
-
version: "0.52.
|
|
4043
|
+
version: "0.52.7"};
|
|
4047
4044
|
|
|
4048
4045
|
// src/telemetry/builders.ts
|
|
4049
4046
|
function createCliBaseEvent(context = {}) {
|