@zapier/zapier-sdk-cli 0.6.3 → 0.6.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.
- package/CHANGELOG.md +9 -0
- package/README.md +115 -12
- package/bin/{zapier-sdk.js → zapier-sdk.mjs} +1 -1
- package/dist/cli.cjs +1711 -0
- package/dist/cli.d.mts +1 -0
- package/dist/cli.d.ts +1 -0
- package/dist/{cli.js → cli.mjs} +204 -456
- package/dist/index.cjs +770 -0
- package/dist/index.d.mts +12 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.mjs +739 -0
- package/dist/package.json +67 -0
- package/dist/src/cli.js +8 -14
- package/dist/src/index.d.ts +1 -0
- package/dist/src/index.js +1 -1
- package/dist/src/plugins/bundleCode/index.d.ts +15 -0
- package/dist/src/{commands/bundle-code → plugins/bundleCode}/index.js +19 -1
- package/dist/src/{commands/bundle-code → plugins/bundleCode}/schemas.d.ts +8 -8
- package/dist/src/{commands/bundle-code → plugins/bundleCode}/schemas.js +4 -4
- package/dist/src/plugins/generateTypes/index.d.ts +21 -0
- package/dist/src/{commands/generate-types → plugins/generateTypes}/index.js +18 -0
- package/dist/src/{commands/generate-types → plugins/generateTypes}/schemas.d.ts +0 -3
- package/dist/src/{commands/generate-types → plugins/generateTypes}/schemas.js +1 -2
- package/dist/src/plugins/getConfigPath/index.d.ts +15 -0
- package/dist/src/plugins/getConfigPath/index.js +19 -0
- package/dist/src/plugins/getConfigPath/schemas.d.ts +3 -0
- package/dist/src/plugins/getConfigPath/schemas.js +5 -0
- package/dist/src/plugins/index.d.ts +6 -0
- package/dist/src/plugins/index.js +6 -0
- package/dist/src/plugins/login/index.d.ts +15 -0
- package/dist/src/plugins/login/index.js +26 -0
- package/dist/src/plugins/login/schemas.d.ts +9 -0
- package/dist/src/plugins/login/schemas.js +10 -0
- package/dist/src/plugins/logout/index.d.ts +15 -0
- package/dist/src/plugins/logout/index.js +18 -0
- package/dist/src/plugins/logout/schemas.d.ts +3 -0
- package/dist/src/plugins/logout/schemas.js +5 -0
- package/dist/src/plugins/mcp/index.d.ts +15 -0
- package/dist/src/plugins/mcp/index.js +24 -0
- package/dist/src/plugins/mcp/schemas.d.ts +9 -0
- package/dist/src/plugins/mcp/schemas.js +10 -0
- package/dist/src/sdk.d.ts +9 -0
- package/dist/src/sdk.js +22 -0
- package/dist/src/utils/cli-generator.js +4 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +19 -8
- package/src/cli.ts +8 -21
- package/src/index.ts +2 -0
- package/src/{commands/bundle-code → plugins/bundleCode}/index.ts +39 -2
- package/src/{commands/bundle-code → plugins/bundleCode}/schemas.ts +4 -4
- package/src/{commands/generate-types → plugins/generateTypes}/index.ts +56 -3
- package/src/{commands/generate-types → plugins/generateTypes}/schemas.ts +0 -4
- package/src/plugins/getConfigPath/index.ts +42 -0
- package/src/plugins/getConfigPath/schemas.ts +8 -0
- package/src/plugins/index.ts +6 -0
- package/src/plugins/login/index.ts +48 -0
- package/src/plugins/login/schemas.ts +13 -0
- package/src/plugins/logout/index.ts +37 -0
- package/src/plugins/logout/schemas.ts +8 -0
- package/src/plugins/mcp/index.ts +43 -0
- package/src/plugins/mcp/schemas.ts +13 -0
- package/src/sdk.ts +43 -0
- package/src/utils/cli-generator.ts +5 -0
- package/tsconfig.build.json +15 -3
- package/tsconfig.json +2 -2
- package/tsup.config.ts +10 -4
- package/bin/zsdk.js +0 -4
- package/dist/index.js +0 -0
- package/dist/src/commands/bundle-code/cli.d.ts +0 -2
- package/dist/src/commands/bundle-code/cli.js +0 -77
- package/dist/src/commands/bundle-code/index.d.ts +0 -5
- package/dist/src/commands/configPath.d.ts +0 -2
- package/dist/src/commands/configPath.js +0 -9
- package/dist/src/commands/generate-types/cli.d.ts +0 -2
- package/dist/src/commands/generate-types/cli.js +0 -84
- package/dist/src/commands/generate-types/index.d.ts +0 -8
- package/dist/src/commands/index.d.ts +0 -6
- package/dist/src/commands/index.js +0 -6
- package/dist/src/commands/login.d.ts +0 -2
- package/dist/src/commands/login.js +0 -25
- package/dist/src/commands/logout.d.ts +0 -2
- package/dist/src/commands/logout.js +0 -16
- package/dist/src/commands/mcp.d.ts +0 -2
- package/dist/src/commands/mcp.js +0 -11
- package/src/commands/bundle-code/cli.ts +0 -118
- package/src/commands/configPath.ts +0 -10
- package/src/commands/generate-types/cli.ts +0 -126
- package/src/commands/index.ts +0 -6
- package/src/commands/login.ts +0 -34
- package/src/commands/logout.ts +0 -19
- package/src/commands/mcp.ts +0 -14
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
import { Command } from "commander";
|
|
2
|
-
import { BundleCodeSchema } from "./schemas";
|
|
3
|
-
import { bundleCode } from "./index";
|
|
4
|
-
import chalk from "chalk";
|
|
5
|
-
import { analyzeZodSchema, convertCliArgsToSdkParams, } from "../../utils/cli-generator-utils";
|
|
6
|
-
export function createBundleCodeCommand() {
|
|
7
|
-
const parameters = analyzeZodSchema(BundleCodeSchema);
|
|
8
|
-
const description = BundleCodeSchema.description ||
|
|
9
|
-
"Bundle TypeScript code into executable JavaScript";
|
|
10
|
-
const command = new Command("bundle-code").description(description);
|
|
11
|
-
// Add parameters to command using same logic as CLI generator
|
|
12
|
-
parameters.forEach((param) => {
|
|
13
|
-
// Convert camelCase to kebab-case for CLI display
|
|
14
|
-
const kebabName = param.name.replace(/([A-Z])/g, "-$1").toLowerCase();
|
|
15
|
-
if (param.hasResolver && param.required) {
|
|
16
|
-
// Required parameters with resolvers become optional positional arguments (resolver handles prompting)
|
|
17
|
-
command.argument(`[${kebabName}]`, param.description || `${kebabName} parameter`);
|
|
18
|
-
}
|
|
19
|
-
else if (param.required) {
|
|
20
|
-
// Required parameters without resolvers become required positional arguments
|
|
21
|
-
command.argument(`<${kebabName}>`, param.description || `${kebabName} parameter`);
|
|
22
|
-
}
|
|
23
|
-
else if (param.isPositional) {
|
|
24
|
-
// Optional parameters marked as positional become optional positional arguments
|
|
25
|
-
command.argument(`[${kebabName}]`, param.description || `${kebabName} parameter`);
|
|
26
|
-
}
|
|
27
|
-
else {
|
|
28
|
-
// Optional parameters become flags (whether they have resolvers or not)
|
|
29
|
-
const flags = [`--${kebabName}`];
|
|
30
|
-
if (param.type === "boolean") {
|
|
31
|
-
command.option(flags.join(", "), param.description);
|
|
32
|
-
}
|
|
33
|
-
else {
|
|
34
|
-
const flagSignature = flags.join(", ") + ` <${param.type}>`;
|
|
35
|
-
command.option(flagSignature, param.description || "", param.default);
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
});
|
|
39
|
-
// Add formatting options like other commands
|
|
40
|
-
command.option("--json", "Output raw JSON instead of formatted results");
|
|
41
|
-
command.action(async (...args) => {
|
|
42
|
-
try {
|
|
43
|
-
// The last argument is always the command object with parsed options
|
|
44
|
-
const commandObj = args[args.length - 1];
|
|
45
|
-
const options = commandObj.opts();
|
|
46
|
-
// Convert CLI args to SDK method parameters
|
|
47
|
-
const rawParams = convertCliArgsToSdkParams(parameters, args.slice(0, -1), options);
|
|
48
|
-
// No parameter resolution needed for bundle-code since it doesn't use SDK
|
|
49
|
-
if (!rawParams.input) {
|
|
50
|
-
throw new Error("Input file path is required");
|
|
51
|
-
}
|
|
52
|
-
console.log(chalk.blue(`📦 Bundling ${rawParams.input}...`));
|
|
53
|
-
// Call our implementation
|
|
54
|
-
const result = await bundleCode(rawParams);
|
|
55
|
-
if (options.json) {
|
|
56
|
-
console.log(JSON.stringify({ result }, null, 2));
|
|
57
|
-
}
|
|
58
|
-
else if (rawParams.output && !rawParams.string) {
|
|
59
|
-
console.log(chalk.green("✅ Bundle created successfully!"));
|
|
60
|
-
console.log(chalk.gray(`Output written to: ${rawParams.output}`));
|
|
61
|
-
}
|
|
62
|
-
else if (rawParams.string) {
|
|
63
|
-
console.log(chalk.green("✅ Bundle generated as string!"));
|
|
64
|
-
console.log("\n" + result);
|
|
65
|
-
}
|
|
66
|
-
else {
|
|
67
|
-
console.log(chalk.green("✅ Bundle completed!"));
|
|
68
|
-
console.log("\n" + result);
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
catch (error) {
|
|
72
|
-
console.error(chalk.red("Error:"), error instanceof Error ? error.message : "Unknown error");
|
|
73
|
-
process.exit(1);
|
|
74
|
-
}
|
|
75
|
-
});
|
|
76
|
-
return command;
|
|
77
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { Command } from "commander";
|
|
2
|
-
import { getConfigPath } from "@zapier/zapier-sdk-cli-login";
|
|
3
|
-
export function createConfigPathCommand() {
|
|
4
|
-
return new Command("get-config-path")
|
|
5
|
-
.description("Show the path to the configuration file")
|
|
6
|
-
.action(async () => {
|
|
7
|
-
console.log(`Configuration file: ${getConfigPath()}`);
|
|
8
|
-
});
|
|
9
|
-
}
|
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
import { Command } from "commander";
|
|
2
|
-
import { createZapierSdk } from "@zapier/zapier-sdk";
|
|
3
|
-
import { GenerateTypesSchema } from "./schemas";
|
|
4
|
-
import { generateTypes } from "./index";
|
|
5
|
-
import chalk from "chalk";
|
|
6
|
-
import { SchemaParameterResolver } from "../../utils/parameter-resolver";
|
|
7
|
-
import { analyzeZodSchema, convertCliArgsToSdkParams, } from "../../utils/cli-generator-utils";
|
|
8
|
-
export function createGenerateTypesCommand() {
|
|
9
|
-
const parameters = analyzeZodSchema(GenerateTypesSchema);
|
|
10
|
-
const description = GenerateTypesSchema.description ||
|
|
11
|
-
"Generate TypeScript SDK types for a specific app";
|
|
12
|
-
const command = new Command("generate-types").description(description);
|
|
13
|
-
// Add parameters to command using same logic as CLI generator
|
|
14
|
-
parameters.forEach((param) => {
|
|
15
|
-
// Convert camelCase to kebab-case for CLI display
|
|
16
|
-
const kebabName = param.name.replace(/([A-Z])/g, "-$1").toLowerCase();
|
|
17
|
-
if (param.hasResolver && param.required) {
|
|
18
|
-
// Required parameters with resolvers become optional positional arguments (resolver handles prompting)
|
|
19
|
-
command.argument(`[${kebabName}]`, param.description || `${kebabName} parameter`);
|
|
20
|
-
}
|
|
21
|
-
else if (param.required) {
|
|
22
|
-
// Required parameters without resolvers become required positional arguments
|
|
23
|
-
command.argument(`<${kebabName}>`, param.description || `${kebabName} parameter`);
|
|
24
|
-
}
|
|
25
|
-
else if (param.isPositional) {
|
|
26
|
-
// Optional parameters marked as positional become optional positional arguments
|
|
27
|
-
command.argument(`[${kebabName}]`, param.description || `${kebabName} parameter`);
|
|
28
|
-
}
|
|
29
|
-
else {
|
|
30
|
-
// Optional parameters become flags (whether they have resolvers or not)
|
|
31
|
-
const flags = [`--${kebabName}`];
|
|
32
|
-
if (param.type === "boolean") {
|
|
33
|
-
command.option(flags.join(", "), param.description);
|
|
34
|
-
}
|
|
35
|
-
else {
|
|
36
|
-
const flagSignature = flags.join(", ") + ` <${param.type}>`;
|
|
37
|
-
command.option(flagSignature, param.description || "", param.default);
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
});
|
|
41
|
-
// Add formatting options like other commands
|
|
42
|
-
command.option("--json", "Output raw JSON instead of formatted results");
|
|
43
|
-
command.action(async (...args) => {
|
|
44
|
-
try {
|
|
45
|
-
// The last argument is always the command object with parsed options
|
|
46
|
-
const commandObj = args[args.length - 1];
|
|
47
|
-
const options = commandObj.opts();
|
|
48
|
-
// Convert CLI args to SDK method parameters
|
|
49
|
-
const rawParams = convertCliArgsToSdkParams(parameters, args.slice(0, -1), options);
|
|
50
|
-
// Create SDK instance with manifest path if provided
|
|
51
|
-
const sdk = createZapierSdk({
|
|
52
|
-
manifestPath: rawParams.lockFilePath,
|
|
53
|
-
});
|
|
54
|
-
// Resolve missing parameters interactively using schema metadata
|
|
55
|
-
const resolver = new SchemaParameterResolver();
|
|
56
|
-
const resolvedParams = await resolver.resolveParameters(GenerateTypesSchema, rawParams, sdk);
|
|
57
|
-
const params = resolvedParams;
|
|
58
|
-
console.log(chalk.blue(`🔧 Generating TypeScript types for ${params.appKey}...`));
|
|
59
|
-
// Call our implementation
|
|
60
|
-
const generateTypesParams = {
|
|
61
|
-
appKey: params.appKey,
|
|
62
|
-
debug: params.debug ?? false,
|
|
63
|
-
authenticationId: params.authenticationId,
|
|
64
|
-
output: params.output,
|
|
65
|
-
sdk,
|
|
66
|
-
};
|
|
67
|
-
const result = await generateTypes(generateTypesParams);
|
|
68
|
-
if (options.json) {
|
|
69
|
-
console.log(JSON.stringify({ result }, null, 2));
|
|
70
|
-
}
|
|
71
|
-
else {
|
|
72
|
-
const output = params.output ||
|
|
73
|
-
`./types/${params.appKey}.d.ts`;
|
|
74
|
-
console.log(chalk.green("✅ TypeScript types generated successfully!"));
|
|
75
|
-
console.log(chalk.gray(`Output written to: ${output}`));
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
catch (error) {
|
|
79
|
-
console.error(chalk.red("Error:"), error instanceof Error ? error.message : "Unknown error");
|
|
80
|
-
process.exit(1);
|
|
81
|
-
}
|
|
82
|
-
});
|
|
83
|
-
return command;
|
|
84
|
-
}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import type { createZapierSdk } from "@zapier/zapier-sdk";
|
|
2
|
-
import type { GenerateTypesOptions } from "./schemas";
|
|
3
|
-
/**
|
|
4
|
-
* Generate TypeScript types for a specific app (CLI version)
|
|
5
|
-
*/
|
|
6
|
-
export declare function generateTypes(options: GenerateTypesOptions & {
|
|
7
|
-
sdk: ReturnType<typeof createZapierSdk>;
|
|
8
|
-
}): Promise<string>;
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
export { createLoginCommand } from "./login";
|
|
2
|
-
export { createLogoutCommand } from "./logout";
|
|
3
|
-
export { createConfigPathCommand } from "./configPath";
|
|
4
|
-
export { createGenerateTypesCommand } from "./generate-types/cli";
|
|
5
|
-
export { createBundleCodeCommand } from "./bundle-code/cli";
|
|
6
|
-
export { createMcpCommand } from "./mcp";
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
export { createLoginCommand } from "./login";
|
|
2
|
-
export { createLogoutCommand } from "./logout";
|
|
3
|
-
export { createConfigPathCommand } from "./configPath";
|
|
4
|
-
export { createGenerateTypesCommand } from "./generate-types/cli";
|
|
5
|
-
export { createBundleCodeCommand } from "./bundle-code/cli";
|
|
6
|
-
export { createMcpCommand } from "./mcp";
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { Command } from "commander";
|
|
2
|
-
import login from "../utils/auth/login";
|
|
3
|
-
import { getLoggedInUser } from "@zapier/zapier-sdk-cli-login";
|
|
4
|
-
export function createLoginCommand() {
|
|
5
|
-
return new Command("login")
|
|
6
|
-
.description("Log in to Zapier to access your account")
|
|
7
|
-
.option("--timeout <seconds>", "Login timeout in seconds (default: 300)", "300")
|
|
8
|
-
.action(async (options) => {
|
|
9
|
-
try {
|
|
10
|
-
const timeoutSeconds = parseInt(options.timeout, 10);
|
|
11
|
-
if (isNaN(timeoutSeconds) || timeoutSeconds <= 0) {
|
|
12
|
-
throw new Error("Timeout must be a positive number");
|
|
13
|
-
}
|
|
14
|
-
await login(timeoutSeconds * 1000); // Convert to milliseconds
|
|
15
|
-
const user = await getLoggedInUser();
|
|
16
|
-
console.log(`✅ Successfully logged in as ${user.email}`);
|
|
17
|
-
// Force immediate exit to prevent hanging (especially in development with tsx)
|
|
18
|
-
setTimeout(() => process.exit(0), 100);
|
|
19
|
-
}
|
|
20
|
-
catch (error) {
|
|
21
|
-
console.error("❌ Login failed:", error instanceof Error ? error.message : "Unknown error");
|
|
22
|
-
process.exit(1);
|
|
23
|
-
}
|
|
24
|
-
});
|
|
25
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { Command } from "commander";
|
|
2
|
-
import { logout } from "@zapier/zapier-sdk-cli-login";
|
|
3
|
-
export function createLogoutCommand() {
|
|
4
|
-
return new Command("logout")
|
|
5
|
-
.description("Log out of your Zapier account")
|
|
6
|
-
.action(async () => {
|
|
7
|
-
try {
|
|
8
|
-
logout();
|
|
9
|
-
console.log("✅ Successfully logged out");
|
|
10
|
-
}
|
|
11
|
-
catch (error) {
|
|
12
|
-
console.error("❌ Logout failed:", error instanceof Error ? error.message : "Unknown error");
|
|
13
|
-
process.exit(1);
|
|
14
|
-
}
|
|
15
|
-
});
|
|
16
|
-
}
|
package/dist/src/commands/mcp.js
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { Command } from "commander";
|
|
2
|
-
import { startMcpServerAsProcess } from "@zapier/zapier-sdk-mcp";
|
|
3
|
-
export function createMcpCommand() {
|
|
4
|
-
const command = new Command("mcp");
|
|
5
|
-
command
|
|
6
|
-
.description("Start MCP server for Zapier SDK")
|
|
7
|
-
.option("--debug", "Enable debug logging")
|
|
8
|
-
.option("--port <port>", "Port to listen on (for future HTTP transport)")
|
|
9
|
-
.action(startMcpServerAsProcess);
|
|
10
|
-
return command;
|
|
11
|
-
}
|
|
@@ -1,118 +0,0 @@
|
|
|
1
|
-
import { Command } from "commander";
|
|
2
|
-
import { BundleCodeSchema } from "./schemas";
|
|
3
|
-
import { bundleCode } from "./index";
|
|
4
|
-
import chalk from "chalk";
|
|
5
|
-
import {
|
|
6
|
-
analyzeZodSchema,
|
|
7
|
-
convertCliArgsToSdkParams,
|
|
8
|
-
} from "../../utils/cli-generator-utils";
|
|
9
|
-
|
|
10
|
-
export function createBundleCodeCommand(): Command {
|
|
11
|
-
const parameters = analyzeZodSchema(BundleCodeSchema);
|
|
12
|
-
const description =
|
|
13
|
-
BundleCodeSchema.description ||
|
|
14
|
-
"Bundle TypeScript code into executable JavaScript";
|
|
15
|
-
|
|
16
|
-
const command = new Command("bundle-code").description(description);
|
|
17
|
-
|
|
18
|
-
// Add parameters to command using same logic as CLI generator
|
|
19
|
-
parameters.forEach((param) => {
|
|
20
|
-
// Convert camelCase to kebab-case for CLI display
|
|
21
|
-
const kebabName = param.name.replace(/([A-Z])/g, "-$1").toLowerCase();
|
|
22
|
-
|
|
23
|
-
if (param.hasResolver && param.required) {
|
|
24
|
-
// Required parameters with resolvers become optional positional arguments (resolver handles prompting)
|
|
25
|
-
command.argument(
|
|
26
|
-
`[${kebabName}]`,
|
|
27
|
-
param.description || `${kebabName} parameter`,
|
|
28
|
-
);
|
|
29
|
-
} else if (param.required) {
|
|
30
|
-
// Required parameters without resolvers become required positional arguments
|
|
31
|
-
command.argument(
|
|
32
|
-
`<${kebabName}>`,
|
|
33
|
-
param.description || `${kebabName} parameter`,
|
|
34
|
-
);
|
|
35
|
-
} else if (param.isPositional) {
|
|
36
|
-
// Optional parameters marked as positional become optional positional arguments
|
|
37
|
-
command.argument(
|
|
38
|
-
`[${kebabName}]`,
|
|
39
|
-
param.description || `${kebabName} parameter`,
|
|
40
|
-
);
|
|
41
|
-
} else {
|
|
42
|
-
// Optional parameters become flags (whether they have resolvers or not)
|
|
43
|
-
const flags = [`--${kebabName}`];
|
|
44
|
-
|
|
45
|
-
if (param.type === "boolean") {
|
|
46
|
-
command.option(flags.join(", "), param.description);
|
|
47
|
-
} else {
|
|
48
|
-
const flagSignature = flags.join(", ") + ` <${param.type}>`;
|
|
49
|
-
command.option(
|
|
50
|
-
flagSignature,
|
|
51
|
-
param.description || "",
|
|
52
|
-
param.default as string | boolean | string[] | undefined,
|
|
53
|
-
);
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
// Add formatting options like other commands
|
|
59
|
-
command.option("--json", "Output raw JSON instead of formatted results");
|
|
60
|
-
|
|
61
|
-
command.action(async (...args: unknown[]) => {
|
|
62
|
-
try {
|
|
63
|
-
// The last argument is always the command object with parsed options
|
|
64
|
-
const commandObj = args[args.length - 1] as {
|
|
65
|
-
opts(): Record<string, unknown>;
|
|
66
|
-
};
|
|
67
|
-
const options = commandObj.opts();
|
|
68
|
-
|
|
69
|
-
// Convert CLI args to SDK method parameters
|
|
70
|
-
const rawParams = convertCliArgsToSdkParams(
|
|
71
|
-
parameters,
|
|
72
|
-
args.slice(0, -1),
|
|
73
|
-
options,
|
|
74
|
-
);
|
|
75
|
-
|
|
76
|
-
// No parameter resolution needed for bundle-code since it doesn't use SDK
|
|
77
|
-
|
|
78
|
-
if (!rawParams.input) {
|
|
79
|
-
throw new Error("Input file path is required");
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
console.log(chalk.blue(`📦 Bundling ${rawParams.input}...`));
|
|
83
|
-
|
|
84
|
-
// Call our implementation
|
|
85
|
-
const result = await bundleCode(
|
|
86
|
-
rawParams as {
|
|
87
|
-
string: boolean;
|
|
88
|
-
input: string;
|
|
89
|
-
minify: boolean;
|
|
90
|
-
target: string;
|
|
91
|
-
cjs: boolean;
|
|
92
|
-
output?: string | undefined;
|
|
93
|
-
},
|
|
94
|
-
);
|
|
95
|
-
|
|
96
|
-
if (options.json) {
|
|
97
|
-
console.log(JSON.stringify({ result }, null, 2));
|
|
98
|
-
} else if (rawParams.output && !rawParams.string) {
|
|
99
|
-
console.log(chalk.green("✅ Bundle created successfully!"));
|
|
100
|
-
console.log(chalk.gray(`Output written to: ${rawParams.output}`));
|
|
101
|
-
} else if (rawParams.string) {
|
|
102
|
-
console.log(chalk.green("✅ Bundle generated as string!"));
|
|
103
|
-
console.log("\n" + result);
|
|
104
|
-
} else {
|
|
105
|
-
console.log(chalk.green("✅ Bundle completed!"));
|
|
106
|
-
console.log("\n" + result);
|
|
107
|
-
}
|
|
108
|
-
} catch (error) {
|
|
109
|
-
console.error(
|
|
110
|
-
chalk.red("Error:"),
|
|
111
|
-
error instanceof Error ? error.message : "Unknown error",
|
|
112
|
-
);
|
|
113
|
-
process.exit(1);
|
|
114
|
-
}
|
|
115
|
-
});
|
|
116
|
-
|
|
117
|
-
return command;
|
|
118
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { Command } from "commander";
|
|
2
|
-
import { getConfigPath } from "@zapier/zapier-sdk-cli-login";
|
|
3
|
-
|
|
4
|
-
export function createConfigPathCommand(): Command {
|
|
5
|
-
return new Command("get-config-path")
|
|
6
|
-
.description("Show the path to the configuration file")
|
|
7
|
-
.action(async () => {
|
|
8
|
-
console.log(`Configuration file: ${getConfigPath()}`);
|
|
9
|
-
});
|
|
10
|
-
}
|
|
@@ -1,126 +0,0 @@
|
|
|
1
|
-
import { Command } from "commander";
|
|
2
|
-
import { createZapierSdk } from "@zapier/zapier-sdk";
|
|
3
|
-
import { GenerateTypesSchema } from "./schemas";
|
|
4
|
-
import { generateTypes } from "./index";
|
|
5
|
-
import chalk from "chalk";
|
|
6
|
-
import { SchemaParameterResolver } from "../../utils/parameter-resolver";
|
|
7
|
-
import {
|
|
8
|
-
analyzeZodSchema,
|
|
9
|
-
convertCliArgsToSdkParams,
|
|
10
|
-
} from "../../utils/cli-generator-utils";
|
|
11
|
-
|
|
12
|
-
export function createGenerateTypesCommand(): Command {
|
|
13
|
-
const parameters = analyzeZodSchema(GenerateTypesSchema);
|
|
14
|
-
const description =
|
|
15
|
-
GenerateTypesSchema.description ||
|
|
16
|
-
"Generate TypeScript SDK types for a specific app";
|
|
17
|
-
|
|
18
|
-
const command = new Command("generate-types").description(description);
|
|
19
|
-
|
|
20
|
-
// Add parameters to command using same logic as CLI generator
|
|
21
|
-
parameters.forEach((param) => {
|
|
22
|
-
// Convert camelCase to kebab-case for CLI display
|
|
23
|
-
const kebabName = param.name.replace(/([A-Z])/g, "-$1").toLowerCase();
|
|
24
|
-
|
|
25
|
-
if (param.hasResolver && param.required) {
|
|
26
|
-
// Required parameters with resolvers become optional positional arguments (resolver handles prompting)
|
|
27
|
-
command.argument(
|
|
28
|
-
`[${kebabName}]`,
|
|
29
|
-
param.description || `${kebabName} parameter`,
|
|
30
|
-
);
|
|
31
|
-
} else if (param.required) {
|
|
32
|
-
// Required parameters without resolvers become required positional arguments
|
|
33
|
-
command.argument(
|
|
34
|
-
`<${kebabName}>`,
|
|
35
|
-
param.description || `${kebabName} parameter`,
|
|
36
|
-
);
|
|
37
|
-
} else if (param.isPositional) {
|
|
38
|
-
// Optional parameters marked as positional become optional positional arguments
|
|
39
|
-
command.argument(
|
|
40
|
-
`[${kebabName}]`,
|
|
41
|
-
param.description || `${kebabName} parameter`,
|
|
42
|
-
);
|
|
43
|
-
} else {
|
|
44
|
-
// Optional parameters become flags (whether they have resolvers or not)
|
|
45
|
-
const flags = [`--${kebabName}`];
|
|
46
|
-
|
|
47
|
-
if (param.type === "boolean") {
|
|
48
|
-
command.option(flags.join(", "), param.description);
|
|
49
|
-
} else {
|
|
50
|
-
const flagSignature = flags.join(", ") + ` <${param.type}>`;
|
|
51
|
-
command.option(
|
|
52
|
-
flagSignature,
|
|
53
|
-
param.description || "",
|
|
54
|
-
param.default as string | boolean | string[] | undefined,
|
|
55
|
-
);
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
// Add formatting options like other commands
|
|
61
|
-
command.option("--json", "Output raw JSON instead of formatted results");
|
|
62
|
-
|
|
63
|
-
command.action(async (...args: unknown[]) => {
|
|
64
|
-
try {
|
|
65
|
-
// The last argument is always the command object with parsed options
|
|
66
|
-
const commandObj = args[args.length - 1] as {
|
|
67
|
-
opts(): Record<string, unknown>;
|
|
68
|
-
};
|
|
69
|
-
const options = commandObj.opts();
|
|
70
|
-
|
|
71
|
-
// Convert CLI args to SDK method parameters
|
|
72
|
-
const rawParams = convertCliArgsToSdkParams(
|
|
73
|
-
parameters,
|
|
74
|
-
args.slice(0, -1),
|
|
75
|
-
options,
|
|
76
|
-
);
|
|
77
|
-
|
|
78
|
-
// Create SDK instance with manifest path if provided
|
|
79
|
-
const sdk = createZapierSdk({
|
|
80
|
-
manifestPath: rawParams.lockFilePath as string | undefined,
|
|
81
|
-
});
|
|
82
|
-
// Resolve missing parameters interactively using schema metadata
|
|
83
|
-
const resolver = new SchemaParameterResolver();
|
|
84
|
-
const resolvedParams = await resolver.resolveParameters(
|
|
85
|
-
GenerateTypesSchema,
|
|
86
|
-
rawParams,
|
|
87
|
-
sdk,
|
|
88
|
-
);
|
|
89
|
-
|
|
90
|
-
const params = resolvedParams as Record<string, unknown>;
|
|
91
|
-
console.log(
|
|
92
|
-
chalk.blue(
|
|
93
|
-
`🔧 Generating TypeScript types for ${params.appKey as string}...`,
|
|
94
|
-
),
|
|
95
|
-
);
|
|
96
|
-
|
|
97
|
-
// Call our implementation
|
|
98
|
-
const generateTypesParams = {
|
|
99
|
-
appKey: params.appKey as string,
|
|
100
|
-
debug: (params.debug as boolean) ?? false,
|
|
101
|
-
authenticationId: params.authenticationId as number | undefined,
|
|
102
|
-
output: params.output as string | undefined,
|
|
103
|
-
sdk,
|
|
104
|
-
};
|
|
105
|
-
const result = await generateTypes(generateTypesParams);
|
|
106
|
-
|
|
107
|
-
if (options.json) {
|
|
108
|
-
console.log(JSON.stringify({ result }, null, 2));
|
|
109
|
-
} else {
|
|
110
|
-
const output =
|
|
111
|
-
(params.output as string) ||
|
|
112
|
-
`./types/${params.appKey as string}.d.ts`;
|
|
113
|
-
console.log(chalk.green("✅ TypeScript types generated successfully!"));
|
|
114
|
-
console.log(chalk.gray(`Output written to: ${output}`));
|
|
115
|
-
}
|
|
116
|
-
} catch (error) {
|
|
117
|
-
console.error(
|
|
118
|
-
chalk.red("Error:"),
|
|
119
|
-
error instanceof Error ? error.message : "Unknown error",
|
|
120
|
-
);
|
|
121
|
-
process.exit(1);
|
|
122
|
-
}
|
|
123
|
-
});
|
|
124
|
-
|
|
125
|
-
return command;
|
|
126
|
-
}
|
package/src/commands/index.ts
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
export { createLoginCommand } from "./login";
|
|
2
|
-
export { createLogoutCommand } from "./logout";
|
|
3
|
-
export { createConfigPathCommand } from "./configPath";
|
|
4
|
-
export { createGenerateTypesCommand } from "./generate-types/cli";
|
|
5
|
-
export { createBundleCodeCommand } from "./bundle-code/cli";
|
|
6
|
-
export { createMcpCommand } from "./mcp";
|
package/src/commands/login.ts
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { Command } from "commander";
|
|
2
|
-
import login from "../utils/auth/login";
|
|
3
|
-
import { getLoggedInUser } from "@zapier/zapier-sdk-cli-login";
|
|
4
|
-
|
|
5
|
-
export function createLoginCommand(): Command {
|
|
6
|
-
return new Command("login")
|
|
7
|
-
.description("Log in to Zapier to access your account")
|
|
8
|
-
.option(
|
|
9
|
-
"--timeout <seconds>",
|
|
10
|
-
"Login timeout in seconds (default: 300)",
|
|
11
|
-
"300",
|
|
12
|
-
)
|
|
13
|
-
.action(async (options) => {
|
|
14
|
-
try {
|
|
15
|
-
const timeoutSeconds = parseInt(options.timeout, 10);
|
|
16
|
-
if (isNaN(timeoutSeconds) || timeoutSeconds <= 0) {
|
|
17
|
-
throw new Error("Timeout must be a positive number");
|
|
18
|
-
}
|
|
19
|
-
await login(timeoutSeconds * 1000); // Convert to milliseconds
|
|
20
|
-
const user = await getLoggedInUser();
|
|
21
|
-
|
|
22
|
-
console.log(`✅ Successfully logged in as ${user.email}`);
|
|
23
|
-
|
|
24
|
-
// Force immediate exit to prevent hanging (especially in development with tsx)
|
|
25
|
-
setTimeout(() => process.exit(0), 100);
|
|
26
|
-
} catch (error) {
|
|
27
|
-
console.error(
|
|
28
|
-
"❌ Login failed:",
|
|
29
|
-
error instanceof Error ? error.message : "Unknown error",
|
|
30
|
-
);
|
|
31
|
-
process.exit(1);
|
|
32
|
-
}
|
|
33
|
-
});
|
|
34
|
-
}
|
package/src/commands/logout.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { Command } from "commander";
|
|
2
|
-
import { logout } from "@zapier/zapier-sdk-cli-login";
|
|
3
|
-
|
|
4
|
-
export function createLogoutCommand(): Command {
|
|
5
|
-
return new Command("logout")
|
|
6
|
-
.description("Log out of your Zapier account")
|
|
7
|
-
.action(async () => {
|
|
8
|
-
try {
|
|
9
|
-
logout();
|
|
10
|
-
console.log("✅ Successfully logged out");
|
|
11
|
-
} catch (error) {
|
|
12
|
-
console.error(
|
|
13
|
-
"❌ Logout failed:",
|
|
14
|
-
error instanceof Error ? error.message : "Unknown error",
|
|
15
|
-
);
|
|
16
|
-
process.exit(1);
|
|
17
|
-
}
|
|
18
|
-
});
|
|
19
|
-
}
|
package/src/commands/mcp.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { Command } from "commander";
|
|
2
|
-
import { startMcpServerAsProcess } from "@zapier/zapier-sdk-mcp";
|
|
3
|
-
|
|
4
|
-
export function createMcpCommand(): Command {
|
|
5
|
-
const command = new Command("mcp");
|
|
6
|
-
|
|
7
|
-
command
|
|
8
|
-
.description("Start MCP server for Zapier SDK")
|
|
9
|
-
.option("--debug", "Enable debug logging")
|
|
10
|
-
.option("--port <port>", "Port to listen on (for future HTTP transport)")
|
|
11
|
-
.action(startMcpServerAsProcess);
|
|
12
|
-
|
|
13
|
-
return command;
|
|
14
|
-
}
|