@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/cli.mjs
CHANGED
|
@@ -1530,7 +1530,7 @@ var SHARED_COMMAND_CLI_OPTIONS = [
|
|
|
1530
1530
|
|
|
1531
1531
|
// package.json
|
|
1532
1532
|
var package_default = {
|
|
1533
|
-
version: "0.52.
|
|
1533
|
+
version: "0.52.7"};
|
|
1534
1534
|
|
|
1535
1535
|
// src/telemetry/builders.ts
|
|
1536
1536
|
function createCliBaseEvent(context = {}) {
|
|
@@ -3020,12 +3020,6 @@ async function storeClientCredentials({
|
|
|
3020
3020
|
await deleteKeychainSecret(existingEntry);
|
|
3021
3021
|
}
|
|
3022
3022
|
}
|
|
3023
|
-
function credentialsNameExists({
|
|
3024
|
-
name,
|
|
3025
|
-
baseUrl: baseUrl2
|
|
3026
|
-
}) {
|
|
3027
|
-
return !!findEntry(readRegistry(), name, normalizeBaseUrl(baseUrl2));
|
|
3028
|
-
}
|
|
3029
3023
|
async function getStoredClientCredentials(options) {
|
|
3030
3024
|
const entry = options?.name ? findEntry(readRegistry(), options.name, normalizeBaseUrl(options.baseUrl)) : getActiveCredentials(options);
|
|
3031
3025
|
if (!entry) return void 0;
|
|
@@ -3461,8 +3455,11 @@ function emitAuthLogout(onEvent) {
|
|
|
3461
3455
|
timestamp: Date.now()
|
|
3462
3456
|
});
|
|
3463
3457
|
}
|
|
3464
|
-
function
|
|
3465
|
-
|
|
3458
|
+
function getStatusCode(err) {
|
|
3459
|
+
if (typeof err === "object" && err !== null && "statusCode" in err) {
|
|
3460
|
+
return err.statusCode;
|
|
3461
|
+
}
|
|
3462
|
+
return void 0;
|
|
3466
3463
|
}
|
|
3467
3464
|
async function revokeCredentials({
|
|
3468
3465
|
api: api2,
|
|
@@ -3478,7 +3475,14 @@ async function revokeCredentials({
|
|
|
3478
3475
|
{ authRequired: true, requiredScopes: ["credentials"] }
|
|
3479
3476
|
);
|
|
3480
3477
|
} catch (err) {
|
|
3481
|
-
|
|
3478
|
+
const status = getStatusCode(err);
|
|
3479
|
+
if (status === 404) return;
|
|
3480
|
+
if (status === 401) {
|
|
3481
|
+
console.warn(
|
|
3482
|
+
"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`."
|
|
3483
|
+
);
|
|
3484
|
+
return;
|
|
3485
|
+
}
|
|
3482
3486
|
throw err;
|
|
3483
3487
|
}
|
|
3484
3488
|
}
|
|
@@ -3838,14 +3842,24 @@ async function resolveCredentialsBaseUrl(context) {
|
|
|
3838
3842
|
const resolvedCredentials = "resolvedCredentials" in context ? context.resolvedCredentials : await context.resolveCredentials?.();
|
|
3839
3843
|
return getBaseUrlFromResolvedCredentials(resolvedCredentials) ?? getBaseUrlFromOptionsCredentials(context.options?.credentials) ?? context.options?.baseUrl;
|
|
3840
3844
|
}
|
|
3845
|
+
|
|
3846
|
+
// src/utils/non-interactive.ts
|
|
3847
|
+
function resolveNonInteractive(options) {
|
|
3848
|
+
return (options.nonInteractive ?? options.skipPrompts) === true || !process.stdin.isTTY || !process.stdout.isTTY;
|
|
3849
|
+
}
|
|
3841
3850
|
var LoginSchema = z.object({
|
|
3842
3851
|
timeout: z.string().optional().describe("Login timeout in seconds (default: 300)"),
|
|
3843
3852
|
useApprovals: z.boolean().optional().describe(
|
|
3844
3853
|
"Require approvals for actions performed with these credentials"
|
|
3845
3854
|
),
|
|
3846
|
-
|
|
3855
|
+
nonInteractive: z.boolean().optional().describe(
|
|
3847
3856
|
"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."
|
|
3848
|
-
)
|
|
3857
|
+
),
|
|
3858
|
+
/** @deprecated Use `nonInteractive` instead. */
|
|
3859
|
+
skipPrompts: z.boolean().optional().meta({
|
|
3860
|
+
deprecated: true,
|
|
3861
|
+
deprecationMessage: "Use --non-interactive instead."
|
|
3862
|
+
})
|
|
3849
3863
|
}).describe("Log in to Zapier to access your account");
|
|
3850
3864
|
|
|
3851
3865
|
// src/plugins/login/index.ts
|
|
@@ -3860,8 +3874,8 @@ function toPkceCredentials(credentials2) {
|
|
|
3860
3874
|
}
|
|
3861
3875
|
return void 0;
|
|
3862
3876
|
}
|
|
3863
|
-
async function confirmRevokeAndRelogin(activeCredentials,
|
|
3864
|
-
if (
|
|
3877
|
+
async function confirmRevokeAndRelogin(activeCredentials, nonInteractive) {
|
|
3878
|
+
if (nonInteractive) {
|
|
3865
3879
|
throw new ZapierCliValidationError(
|
|
3866
3880
|
`Already logged in as "${activeCredentials.name}". Run \`logout\` first or use an interactive terminal to re-authenticate.`
|
|
3867
3881
|
);
|
|
@@ -3882,8 +3896,8 @@ Log out and log in again?`,
|
|
|
3882
3896
|
}
|
|
3883
3897
|
return true;
|
|
3884
3898
|
}
|
|
3885
|
-
async function confirmJwtMigration(
|
|
3886
|
-
if (
|
|
3899
|
+
async function confirmJwtMigration(nonInteractive) {
|
|
3900
|
+
if (nonInteractive) {
|
|
3887
3901
|
throw new ZapierCliValidationError(
|
|
3888
3902
|
"Legacy JWT login detected. Run `logout` first or use an interactive terminal to migrate to client credentials."
|
|
3889
3903
|
);
|
|
@@ -3902,8 +3916,8 @@ async function confirmJwtMigration(skipPrompts) {
|
|
|
3902
3916
|
}
|
|
3903
3917
|
return true;
|
|
3904
3918
|
}
|
|
3905
|
-
async function confirmLocalLoginReset(
|
|
3906
|
-
if (
|
|
3919
|
+
async function confirmLocalLoginReset(nonInteractive) {
|
|
3920
|
+
if (nonInteractive) {
|
|
3907
3921
|
throw new ZapierCliValidationError(
|
|
3908
3922
|
"Login cleanup failed and cannot be reset without confirmation. Re-run with an interactive terminal."
|
|
3909
3923
|
);
|
|
@@ -3929,14 +3943,9 @@ function parseTimeoutSeconds(timeout) {
|
|
|
3929
3943
|
}
|
|
3930
3944
|
return timeoutSeconds;
|
|
3931
3945
|
}
|
|
3932
|
-
async function promptCredentialsName(email,
|
|
3946
|
+
async function promptCredentialsName(email, nonInteractive) {
|
|
3933
3947
|
const fallback = `${email}@${hostname()}`;
|
|
3934
|
-
if (
|
|
3935
|
-
if (credentialsNameExists({ name: fallback, baseUrl: baseUrl2 })) {
|
|
3936
|
-
throw new ZapierCliValidationError(
|
|
3937
|
-
`Credentials named "${fallback}" already exist. Run \`logout\` first or use an interactive terminal to choose a different name.`
|
|
3938
|
-
);
|
|
3939
|
-
}
|
|
3948
|
+
if (nonInteractive) {
|
|
3940
3949
|
return fallback;
|
|
3941
3950
|
}
|
|
3942
3951
|
const { credentialName } = await inquirer.prompt([
|
|
@@ -3947,9 +3956,6 @@ async function promptCredentialsName(email, skipPrompts, baseUrl2) {
|
|
|
3947
3956
|
default: fallback,
|
|
3948
3957
|
validate: (input) => {
|
|
3949
3958
|
if (!input.trim()) return "Name cannot be empty";
|
|
3950
|
-
if (credentialsNameExists({ name: input.trim(), baseUrl: baseUrl2 })) {
|
|
3951
|
-
return `Credentials named "${input.trim()}" already exist. Please provide a different name.`;
|
|
3952
|
-
}
|
|
3953
3959
|
return true;
|
|
3954
3960
|
}
|
|
3955
3961
|
}
|
|
@@ -3993,7 +3999,7 @@ var loginPlugin = definePlugin(
|
|
|
3993
3999
|
supportsJsonOutput: false,
|
|
3994
4000
|
handler: async ({ sdk: sdk2, options }) => {
|
|
3995
4001
|
const timeoutSeconds = parseTimeoutSeconds(options.timeout);
|
|
3996
|
-
const
|
|
4002
|
+
const nonInteractive = resolveNonInteractive(options);
|
|
3997
4003
|
const resolvedCredentials = await sdk2.context.resolveCredentials();
|
|
3998
4004
|
const pkceCredentials = toPkceCredentials(resolvedCredentials);
|
|
3999
4005
|
const credentialsBaseUrl2 = await resolveCredentialsBaseUrl({
|
|
@@ -4004,7 +4010,7 @@ var loginPlugin = definePlugin(
|
|
|
4004
4010
|
baseUrl: credentialsBaseUrl2
|
|
4005
4011
|
});
|
|
4006
4012
|
if (activeCredentials) {
|
|
4007
|
-
if (!await confirmRevokeAndRelogin(activeCredentials,
|
|
4013
|
+
if (!await confirmRevokeAndRelogin(activeCredentials, nonInteractive))
|
|
4008
4014
|
return;
|
|
4009
4015
|
try {
|
|
4010
4016
|
await revokeCredentials({
|
|
@@ -4012,14 +4018,14 @@ var loginPlugin = definePlugin(
|
|
|
4012
4018
|
credentials: activeCredentials
|
|
4013
4019
|
});
|
|
4014
4020
|
} catch {
|
|
4015
|
-
if (!await confirmLocalLoginReset(
|
|
4021
|
+
if (!await confirmLocalLoginReset(nonInteractive)) return;
|
|
4016
4022
|
await deleteStoredClientCredentials({
|
|
4017
4023
|
name: activeCredentials.name,
|
|
4018
4024
|
baseUrl: activeCredentials.baseUrl
|
|
4019
4025
|
});
|
|
4020
4026
|
}
|
|
4021
4027
|
} else if (hasLegacyJwtConfig()) {
|
|
4022
|
-
if (!await confirmJwtMigration(
|
|
4028
|
+
if (!await confirmJwtMigration(nonInteractive)) return;
|
|
4023
4029
|
}
|
|
4024
4030
|
const { accessToken } = await runOauthFlow({
|
|
4025
4031
|
timeoutMs: timeoutSeconds * 1e3,
|
|
@@ -4037,8 +4043,7 @@ var loginPlugin = definePlugin(
|
|
|
4037
4043
|
);
|
|
4038
4044
|
const credentialName = await promptCredentialsName(
|
|
4039
4045
|
profile.email,
|
|
4040
|
-
|
|
4041
|
-
credentialsBaseUrl2
|
|
4046
|
+
nonInteractive
|
|
4042
4047
|
);
|
|
4043
4048
|
const useApprovals = options.useApprovals === true;
|
|
4044
4049
|
await setupClientCredentials({
|
|
@@ -4078,20 +4083,6 @@ var logoutPlugin = definePlugin(
|
|
|
4078
4083
|
console.log("\u2705 Successfully logged out");
|
|
4079
4084
|
return;
|
|
4080
4085
|
}
|
|
4081
|
-
const { confirmed } = await inquirer.prompt([
|
|
4082
|
-
{
|
|
4083
|
-
type: "confirm",
|
|
4084
|
-
name: "confirmed",
|
|
4085
|
-
message: `Logging out will delete credentials "${activeCredentials.name}".
|
|
4086
|
-
This may interrupt other Zapier SDK or CLI sessions using them.
|
|
4087
|
-
Do you want to continue?`,
|
|
4088
|
-
default: true
|
|
4089
|
-
}
|
|
4090
|
-
]);
|
|
4091
|
-
if (!confirmed) {
|
|
4092
|
-
console.log("Logout cancelled.");
|
|
4093
|
-
return;
|
|
4094
|
-
}
|
|
4095
4086
|
await revokeCredentials({
|
|
4096
4087
|
api: sdk2.context.api,
|
|
4097
4088
|
credentials: activeCredentials,
|
|
@@ -5651,7 +5642,12 @@ var cliOverridesPlugin = definePlugin(
|
|
|
5651
5642
|
var TEMPLATES = ["basic"];
|
|
5652
5643
|
var InitSchema = z.object({
|
|
5653
5644
|
projectName: z.string().min(1).describe("Name of the project directory to create"),
|
|
5654
|
-
|
|
5645
|
+
nonInteractive: z.boolean().optional().describe("Skip all interactive prompts and accept all defaults"),
|
|
5646
|
+
/** @deprecated Use `nonInteractive` instead. */
|
|
5647
|
+
skipPrompts: z.boolean().optional().meta({
|
|
5648
|
+
deprecated: true,
|
|
5649
|
+
deprecationMessage: "Use --non-interactive instead."
|
|
5650
|
+
})
|
|
5655
5651
|
}).describe(
|
|
5656
5652
|
"Create a new Zapier SDK project in a new directory with starter files"
|
|
5657
5653
|
);
|
|
@@ -5746,9 +5742,9 @@ function createExec({ cwd }) {
|
|
|
5746
5742
|
async function promptYesNo({
|
|
5747
5743
|
message,
|
|
5748
5744
|
defaultValue,
|
|
5749
|
-
|
|
5745
|
+
nonInteractive
|
|
5750
5746
|
}) {
|
|
5751
|
-
if (
|
|
5747
|
+
if (nonInteractive) return defaultValue;
|
|
5752
5748
|
const { answer } = await inquirer.prompt([
|
|
5753
5749
|
{ type: "confirm", name: "answer", message, default: defaultValue }
|
|
5754
5750
|
]);
|
|
@@ -5896,14 +5892,14 @@ async function runStep({
|
|
|
5896
5892
|
step,
|
|
5897
5893
|
stepNumber,
|
|
5898
5894
|
totalSteps,
|
|
5899
|
-
|
|
5895
|
+
nonInteractive,
|
|
5900
5896
|
displayHooks
|
|
5901
5897
|
}) {
|
|
5902
5898
|
if (step.askConfirmation) {
|
|
5903
5899
|
const should = await promptYesNo({
|
|
5904
5900
|
message: step.description,
|
|
5905
5901
|
defaultValue: true,
|
|
5906
|
-
|
|
5902
|
+
nonInteractive
|
|
5907
5903
|
});
|
|
5908
5904
|
if (!should) return false;
|
|
5909
5905
|
}
|
|
@@ -5912,7 +5908,7 @@ async function runStep({
|
|
|
5912
5908
|
stepNumber,
|
|
5913
5909
|
totalSteps,
|
|
5914
5910
|
command: step.command,
|
|
5915
|
-
|
|
5911
|
+
nonInteractive
|
|
5916
5912
|
});
|
|
5917
5913
|
try {
|
|
5918
5914
|
await step.run();
|
|
@@ -6013,11 +6009,11 @@ function createConsoleDisplayHooks() {
|
|
|
6013
6009
|
stepNumber,
|
|
6014
6010
|
totalSteps,
|
|
6015
6011
|
command,
|
|
6016
|
-
|
|
6012
|
+
nonInteractive
|
|
6017
6013
|
}) => {
|
|
6018
6014
|
const progressMessage = `${description}...`;
|
|
6019
6015
|
const stepCounter = chalk.dim(`${stepNumber}/${totalSteps}`);
|
|
6020
|
-
if (
|
|
6016
|
+
if (nonInteractive) {
|
|
6021
6017
|
console.log(
|
|
6022
6018
|
"\n" + chalk.bold(`\u276F ${progressMessage}`) + " " + stepCounter + "\n"
|
|
6023
6019
|
);
|
|
@@ -6093,7 +6089,8 @@ var initPlugin = definePlugin(
|
|
|
6093
6089
|
inputSchema: InitSchema,
|
|
6094
6090
|
supportsJsonOutput: false,
|
|
6095
6091
|
handler: async ({ options }) => {
|
|
6096
|
-
const { projectName: rawName
|
|
6092
|
+
const { projectName: rawName } = options;
|
|
6093
|
+
const nonInteractive = resolveNonInteractive(options);
|
|
6097
6094
|
const cwd = process.cwd();
|
|
6098
6095
|
const { projectName, projectDir } = validateInitOptions({ rawName, cwd });
|
|
6099
6096
|
const displayHooks = createConsoleDisplayHooks();
|
|
@@ -6119,7 +6116,7 @@ var initPlugin = definePlugin(
|
|
|
6119
6116
|
step,
|
|
6120
6117
|
stepNumber: i + 1,
|
|
6121
6118
|
totalSteps: steps.length,
|
|
6122
|
-
|
|
6119
|
+
nonInteractive,
|
|
6123
6120
|
displayHooks
|
|
6124
6121
|
})
|
|
6125
6122
|
);
|
|
@@ -6614,7 +6611,7 @@ var watchTriggerInboxCliPlugin = definePlugin(
|
|
|
6614
6611
|
// package.json with { type: 'json' }
|
|
6615
6612
|
var package_default2 = {
|
|
6616
6613
|
name: "@zapier/zapier-sdk-cli",
|
|
6617
|
-
version: "0.52.
|
|
6614
|
+
version: "0.52.7"};
|
|
6618
6615
|
|
|
6619
6616
|
// src/sdk.ts
|
|
6620
6617
|
injectCliLogin(login_exports);
|
package/dist/experimental.cjs
CHANGED
|
@@ -411,12 +411,6 @@ async function storeClientCredentials({
|
|
|
411
411
|
await deleteKeychainSecret(existingEntry);
|
|
412
412
|
}
|
|
413
413
|
}
|
|
414
|
-
function credentialsNameExists({
|
|
415
|
-
name,
|
|
416
|
-
baseUrl
|
|
417
|
-
}) {
|
|
418
|
-
return !!findEntry(readRegistry(), name, normalizeBaseUrl(baseUrl));
|
|
419
|
-
}
|
|
420
414
|
async function getStoredClientCredentials(options) {
|
|
421
415
|
const entry = options?.name ? findEntry(readRegistry(), options.name, normalizeBaseUrl(options.baseUrl)) : getActiveCredentials(options);
|
|
422
416
|
if (!entry) return void 0;
|
|
@@ -852,8 +846,11 @@ function emitAuthLogout(onEvent) {
|
|
|
852
846
|
timestamp: Date.now()
|
|
853
847
|
});
|
|
854
848
|
}
|
|
855
|
-
function
|
|
856
|
-
|
|
849
|
+
function getStatusCode(err) {
|
|
850
|
+
if (typeof err === "object" && err !== null && "statusCode" in err) {
|
|
851
|
+
return err.statusCode;
|
|
852
|
+
}
|
|
853
|
+
return void 0;
|
|
857
854
|
}
|
|
858
855
|
async function revokeCredentials({
|
|
859
856
|
api: api2,
|
|
@@ -869,7 +866,14 @@ async function revokeCredentials({
|
|
|
869
866
|
{ authRequired: true, requiredScopes: ["credentials"] }
|
|
870
867
|
);
|
|
871
868
|
} catch (err) {
|
|
872
|
-
|
|
869
|
+
const status = getStatusCode(err);
|
|
870
|
+
if (status === 404) return;
|
|
871
|
+
if (status === 401) {
|
|
872
|
+
console.warn(
|
|
873
|
+
"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`."
|
|
874
|
+
);
|
|
875
|
+
return;
|
|
876
|
+
}
|
|
873
877
|
throw err;
|
|
874
878
|
}
|
|
875
879
|
}
|
|
@@ -1257,14 +1261,24 @@ async function resolveCredentialsBaseUrl(context) {
|
|
|
1257
1261
|
const resolvedCredentials = "resolvedCredentials" in context ? context.resolvedCredentials : await context.resolveCredentials?.();
|
|
1258
1262
|
return getBaseUrlFromResolvedCredentials(resolvedCredentials) ?? getBaseUrlFromOptionsCredentials(context.options?.credentials) ?? context.options?.baseUrl;
|
|
1259
1263
|
}
|
|
1264
|
+
|
|
1265
|
+
// src/utils/non-interactive.ts
|
|
1266
|
+
function resolveNonInteractive(options) {
|
|
1267
|
+
return (options.nonInteractive ?? options.skipPrompts) === true || !process.stdin.isTTY || !process.stdout.isTTY;
|
|
1268
|
+
}
|
|
1260
1269
|
var LoginSchema = zod.z.object({
|
|
1261
1270
|
timeout: zod.z.string().optional().describe("Login timeout in seconds (default: 300)"),
|
|
1262
1271
|
useApprovals: zod.z.boolean().optional().describe(
|
|
1263
1272
|
"Require approvals for actions performed with these credentials"
|
|
1264
1273
|
),
|
|
1265
|
-
|
|
1274
|
+
nonInteractive: zod.z.boolean().optional().describe(
|
|
1266
1275
|
"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."
|
|
1267
|
-
)
|
|
1276
|
+
),
|
|
1277
|
+
/** @deprecated Use `nonInteractive` instead. */
|
|
1278
|
+
skipPrompts: zod.z.boolean().optional().meta({
|
|
1279
|
+
deprecated: true,
|
|
1280
|
+
deprecationMessage: "Use --non-interactive instead."
|
|
1281
|
+
})
|
|
1268
1282
|
}).describe("Log in to Zapier to access your account");
|
|
1269
1283
|
|
|
1270
1284
|
// src/plugins/login/index.ts
|
|
@@ -1279,8 +1293,8 @@ function toPkceCredentials(credentials) {
|
|
|
1279
1293
|
}
|
|
1280
1294
|
return void 0;
|
|
1281
1295
|
}
|
|
1282
|
-
async function confirmRevokeAndRelogin(activeCredentials,
|
|
1283
|
-
if (
|
|
1296
|
+
async function confirmRevokeAndRelogin(activeCredentials, nonInteractive) {
|
|
1297
|
+
if (nonInteractive) {
|
|
1284
1298
|
throw new ZapierCliValidationError(
|
|
1285
1299
|
`Already logged in as "${activeCredentials.name}". Run \`logout\` first or use an interactive terminal to re-authenticate.`
|
|
1286
1300
|
);
|
|
@@ -1301,8 +1315,8 @@ Log out and log in again?`,
|
|
|
1301
1315
|
}
|
|
1302
1316
|
return true;
|
|
1303
1317
|
}
|
|
1304
|
-
async function confirmJwtMigration(
|
|
1305
|
-
if (
|
|
1318
|
+
async function confirmJwtMigration(nonInteractive) {
|
|
1319
|
+
if (nonInteractive) {
|
|
1306
1320
|
throw new ZapierCliValidationError(
|
|
1307
1321
|
"Legacy JWT login detected. Run `logout` first or use an interactive terminal to migrate to client credentials."
|
|
1308
1322
|
);
|
|
@@ -1321,8 +1335,8 @@ async function confirmJwtMigration(skipPrompts) {
|
|
|
1321
1335
|
}
|
|
1322
1336
|
return true;
|
|
1323
1337
|
}
|
|
1324
|
-
async function confirmLocalLoginReset(
|
|
1325
|
-
if (
|
|
1338
|
+
async function confirmLocalLoginReset(nonInteractive) {
|
|
1339
|
+
if (nonInteractive) {
|
|
1326
1340
|
throw new ZapierCliValidationError(
|
|
1327
1341
|
"Login cleanup failed and cannot be reset without confirmation. Re-run with an interactive terminal."
|
|
1328
1342
|
);
|
|
@@ -1348,14 +1362,9 @@ function parseTimeoutSeconds(timeout) {
|
|
|
1348
1362
|
}
|
|
1349
1363
|
return timeoutSeconds;
|
|
1350
1364
|
}
|
|
1351
|
-
async function promptCredentialsName(email,
|
|
1365
|
+
async function promptCredentialsName(email, nonInteractive) {
|
|
1352
1366
|
const fallback = `${email}@${os.hostname()}`;
|
|
1353
|
-
if (
|
|
1354
|
-
if (credentialsNameExists({ name: fallback, baseUrl })) {
|
|
1355
|
-
throw new ZapierCliValidationError(
|
|
1356
|
-
`Credentials named "${fallback}" already exist. Run \`logout\` first or use an interactive terminal to choose a different name.`
|
|
1357
|
-
);
|
|
1358
|
-
}
|
|
1367
|
+
if (nonInteractive) {
|
|
1359
1368
|
return fallback;
|
|
1360
1369
|
}
|
|
1361
1370
|
const { credentialName } = await inquirer__default.default.prompt([
|
|
@@ -1366,9 +1375,6 @@ async function promptCredentialsName(email, skipPrompts, baseUrl) {
|
|
|
1366
1375
|
default: fallback,
|
|
1367
1376
|
validate: (input) => {
|
|
1368
1377
|
if (!input.trim()) return "Name cannot be empty";
|
|
1369
|
-
if (credentialsNameExists({ name: input.trim(), baseUrl })) {
|
|
1370
|
-
return `Credentials named "${input.trim()}" already exist. Please provide a different name.`;
|
|
1371
|
-
}
|
|
1372
1378
|
return true;
|
|
1373
1379
|
}
|
|
1374
1380
|
}
|
|
@@ -1412,7 +1418,7 @@ var loginPlugin = zapierSdk.definePlugin(
|
|
|
1412
1418
|
supportsJsonOutput: false,
|
|
1413
1419
|
handler: async ({ sdk: sdk2, options }) => {
|
|
1414
1420
|
const timeoutSeconds = parseTimeoutSeconds(options.timeout);
|
|
1415
|
-
const
|
|
1421
|
+
const nonInteractive = resolveNonInteractive(options);
|
|
1416
1422
|
const resolvedCredentials = await sdk2.context.resolveCredentials();
|
|
1417
1423
|
const pkceCredentials = toPkceCredentials(resolvedCredentials);
|
|
1418
1424
|
const credentialsBaseUrl = await resolveCredentialsBaseUrl({
|
|
@@ -1423,7 +1429,7 @@ var loginPlugin = zapierSdk.definePlugin(
|
|
|
1423
1429
|
baseUrl: credentialsBaseUrl
|
|
1424
1430
|
});
|
|
1425
1431
|
if (activeCredentials) {
|
|
1426
|
-
if (!await confirmRevokeAndRelogin(activeCredentials,
|
|
1432
|
+
if (!await confirmRevokeAndRelogin(activeCredentials, nonInteractive))
|
|
1427
1433
|
return;
|
|
1428
1434
|
try {
|
|
1429
1435
|
await revokeCredentials({
|
|
@@ -1431,14 +1437,14 @@ var loginPlugin = zapierSdk.definePlugin(
|
|
|
1431
1437
|
credentials: activeCredentials
|
|
1432
1438
|
});
|
|
1433
1439
|
} catch {
|
|
1434
|
-
if (!await confirmLocalLoginReset(
|
|
1440
|
+
if (!await confirmLocalLoginReset(nonInteractive)) return;
|
|
1435
1441
|
await deleteStoredClientCredentials({
|
|
1436
1442
|
name: activeCredentials.name,
|
|
1437
1443
|
baseUrl: activeCredentials.baseUrl
|
|
1438
1444
|
});
|
|
1439
1445
|
}
|
|
1440
1446
|
} else if (hasLegacyJwtConfig()) {
|
|
1441
|
-
if (!await confirmJwtMigration(
|
|
1447
|
+
if (!await confirmJwtMigration(nonInteractive)) return;
|
|
1442
1448
|
}
|
|
1443
1449
|
const { accessToken } = await runOauthFlow({
|
|
1444
1450
|
timeoutMs: timeoutSeconds * 1e3,
|
|
@@ -1456,8 +1462,7 @@ var loginPlugin = zapierSdk.definePlugin(
|
|
|
1456
1462
|
);
|
|
1457
1463
|
const credentialName = await promptCredentialsName(
|
|
1458
1464
|
profile.email,
|
|
1459
|
-
|
|
1460
|
-
credentialsBaseUrl
|
|
1465
|
+
nonInteractive
|
|
1461
1466
|
);
|
|
1462
1467
|
const useApprovals = options.useApprovals === true;
|
|
1463
1468
|
await setupClientCredentials({
|
|
@@ -1497,20 +1502,6 @@ var logoutPlugin = zapierSdk.definePlugin(
|
|
|
1497
1502
|
console.log("\u2705 Successfully logged out");
|
|
1498
1503
|
return;
|
|
1499
1504
|
}
|
|
1500
|
-
const { confirmed } = await inquirer__default.default.prompt([
|
|
1501
|
-
{
|
|
1502
|
-
type: "confirm",
|
|
1503
|
-
name: "confirmed",
|
|
1504
|
-
message: `Logging out will delete credentials "${activeCredentials.name}".
|
|
1505
|
-
This may interrupt other Zapier SDK or CLI sessions using them.
|
|
1506
|
-
Do you want to continue?`,
|
|
1507
|
-
default: true
|
|
1508
|
-
}
|
|
1509
|
-
]);
|
|
1510
|
-
if (!confirmed) {
|
|
1511
|
-
console.log("Logout cancelled.");
|
|
1512
|
-
return;
|
|
1513
|
-
}
|
|
1514
1505
|
await revokeCredentials({
|
|
1515
1506
|
api: sdk2.context.api,
|
|
1516
1507
|
credentials: activeCredentials,
|
|
@@ -3070,7 +3061,12 @@ var cliOverridesPlugin = zapierSdk.definePlugin(
|
|
|
3070
3061
|
var TEMPLATES = ["basic"];
|
|
3071
3062
|
var InitSchema = zod.z.object({
|
|
3072
3063
|
projectName: zod.z.string().min(1).describe("Name of the project directory to create"),
|
|
3073
|
-
|
|
3064
|
+
nonInteractive: zod.z.boolean().optional().describe("Skip all interactive prompts and accept all defaults"),
|
|
3065
|
+
/** @deprecated Use `nonInteractive` instead. */
|
|
3066
|
+
skipPrompts: zod.z.boolean().optional().meta({
|
|
3067
|
+
deprecated: true,
|
|
3068
|
+
deprecationMessage: "Use --non-interactive instead."
|
|
3069
|
+
})
|
|
3074
3070
|
}).describe(
|
|
3075
3071
|
"Create a new Zapier SDK project in a new directory with starter files"
|
|
3076
3072
|
);
|
|
@@ -3138,9 +3134,9 @@ function createExec({ cwd }) {
|
|
|
3138
3134
|
async function promptYesNo({
|
|
3139
3135
|
message,
|
|
3140
3136
|
defaultValue,
|
|
3141
|
-
|
|
3137
|
+
nonInteractive
|
|
3142
3138
|
}) {
|
|
3143
|
-
if (
|
|
3139
|
+
if (nonInteractive) return defaultValue;
|
|
3144
3140
|
const { answer } = await inquirer__default.default.prompt([
|
|
3145
3141
|
{ type: "confirm", name: "answer", message, default: defaultValue }
|
|
3146
3142
|
]);
|
|
@@ -3288,14 +3284,14 @@ async function runStep({
|
|
|
3288
3284
|
step,
|
|
3289
3285
|
stepNumber,
|
|
3290
3286
|
totalSteps,
|
|
3291
|
-
|
|
3287
|
+
nonInteractive,
|
|
3292
3288
|
displayHooks
|
|
3293
3289
|
}) {
|
|
3294
3290
|
if (step.askConfirmation) {
|
|
3295
3291
|
const should = await promptYesNo({
|
|
3296
3292
|
message: step.description,
|
|
3297
3293
|
defaultValue: true,
|
|
3298
|
-
|
|
3294
|
+
nonInteractive
|
|
3299
3295
|
});
|
|
3300
3296
|
if (!should) return false;
|
|
3301
3297
|
}
|
|
@@ -3304,7 +3300,7 @@ async function runStep({
|
|
|
3304
3300
|
stepNumber,
|
|
3305
3301
|
totalSteps,
|
|
3306
3302
|
command: step.command,
|
|
3307
|
-
|
|
3303
|
+
nonInteractive
|
|
3308
3304
|
});
|
|
3309
3305
|
try {
|
|
3310
3306
|
await step.run();
|
|
@@ -3405,11 +3401,11 @@ function createConsoleDisplayHooks() {
|
|
|
3405
3401
|
stepNumber,
|
|
3406
3402
|
totalSteps,
|
|
3407
3403
|
command,
|
|
3408
|
-
|
|
3404
|
+
nonInteractive
|
|
3409
3405
|
}) => {
|
|
3410
3406
|
const progressMessage = `${description}...`;
|
|
3411
3407
|
const stepCounter = chalk3__default.default.dim(`${stepNumber}/${totalSteps}`);
|
|
3412
|
-
if (
|
|
3408
|
+
if (nonInteractive) {
|
|
3413
3409
|
console.log(
|
|
3414
3410
|
"\n" + chalk3__default.default.bold(`\u276F ${progressMessage}`) + " " + stepCounter + "\n"
|
|
3415
3411
|
);
|
|
@@ -3485,7 +3481,8 @@ var initPlugin = zapierSdk.definePlugin(
|
|
|
3485
3481
|
inputSchema: InitSchema,
|
|
3486
3482
|
supportsJsonOutput: false,
|
|
3487
3483
|
handler: async ({ options }) => {
|
|
3488
|
-
const { projectName: rawName
|
|
3484
|
+
const { projectName: rawName } = options;
|
|
3485
|
+
const nonInteractive = resolveNonInteractive(options);
|
|
3489
3486
|
const cwd = process.cwd();
|
|
3490
3487
|
const { projectName, projectDir } = validateInitOptions({ rawName, cwd });
|
|
3491
3488
|
const displayHooks = createConsoleDisplayHooks();
|
|
@@ -3511,7 +3508,7 @@ var initPlugin = zapierSdk.definePlugin(
|
|
|
3511
3508
|
step,
|
|
3512
3509
|
stepNumber: i + 1,
|
|
3513
3510
|
totalSteps: steps.length,
|
|
3514
|
-
|
|
3511
|
+
nonInteractive,
|
|
3515
3512
|
displayHooks
|
|
3516
3513
|
})
|
|
3517
3514
|
);
|
|
@@ -4016,7 +4013,7 @@ var watchTriggerInboxCliPlugin = zapierSdk.definePlugin(
|
|
|
4016
4013
|
// package.json with { type: 'json' }
|
|
4017
4014
|
var package_default = {
|
|
4018
4015
|
name: "@zapier/zapier-sdk-cli",
|
|
4019
|
-
version: "0.52.
|
|
4016
|
+
version: "0.52.7"};
|
|
4020
4017
|
|
|
4021
4018
|
// src/experimental.ts
|
|
4022
4019
|
experimental.injectCliLogin(login_exports);
|