cushin-monorepo 3.0.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.
Files changed (103) hide show
  1. package/.changeset/README.md +8 -0
  2. package/.changeset/config.json +14 -0
  3. package/.claude/settings.local.json +44 -0
  4. package/CHANGELOG.md +93 -0
  5. package/LICENSE +0 -0
  6. package/README.md +482 -0
  7. package/biome.json +34 -0
  8. package/dist/cli.d.ts +1 -0
  9. package/dist/cli.js +1552 -0
  10. package/dist/cli.js.map +1 -0
  11. package/dist/config/index.d.ts +84 -0
  12. package/dist/config/index.js +69 -0
  13. package/dist/config/index.js.map +1 -0
  14. package/dist/config/schema.d.ts +43 -0
  15. package/dist/config/schema.js +14 -0
  16. package/dist/config/schema.js.map +1 -0
  17. package/dist/index.d.ts +27 -0
  18. package/dist/index.js +1666 -0
  19. package/dist/index.js.map +1 -0
  20. package/dist/runtime/client.d.ts +40 -0
  21. package/dist/runtime/client.js +260 -0
  22. package/dist/runtime/client.js.map +1 -0
  23. package/package.json +41 -0
  24. package/packages/api-codegen/CHANGELOG.md +86 -0
  25. package/packages/api-codegen/biome.json +34 -0
  26. package/packages/api-codegen/dist/cli.js +1038 -0
  27. package/packages/api-codegen/dist/cli.js.map +1 -0
  28. package/packages/api-codegen/dist/index.d.ts +103 -0
  29. package/packages/api-codegen/dist/index.js +1026 -0
  30. package/packages/api-codegen/dist/index.js.map +1 -0
  31. package/packages/api-codegen/node_modules/.bin/acorn +21 -0
  32. package/packages/api-codegen/node_modules/.bin/conventional-changelog +21 -0
  33. package/packages/api-codegen/node_modules/.bin/conventional-commits-parser +21 -0
  34. package/packages/api-codegen/node_modules/.bin/esbuild +21 -0
  35. package/packages/api-codegen/node_modules/.bin/eslint +21 -0
  36. package/packages/api-codegen/node_modules/.bin/jiti +21 -0
  37. package/packages/api-codegen/node_modules/.bin/next +21 -0
  38. package/packages/api-codegen/node_modules/.bin/tsc +21 -0
  39. package/packages/api-codegen/node_modules/.bin/tsserver +21 -0
  40. package/packages/api-codegen/node_modules/.bin/tsup +21 -0
  41. package/packages/api-codegen/node_modules/.bin/tsup-node +21 -0
  42. package/packages/api-codegen/node_modules/.bin/vitest +21 -0
  43. package/packages/api-codegen/package.json +88 -0
  44. package/packages/api-runtime/CHANGELOG.md +46 -0
  45. package/packages/api-runtime/README.md +95 -0
  46. package/packages/api-runtime/dist/chunk-3FFXWCVP.js +17 -0
  47. package/packages/api-runtime/dist/chunk-3FFXWCVP.js.map +1 -0
  48. package/packages/api-runtime/dist/chunk-EZ5P7OPH.js +267 -0
  49. package/packages/api-runtime/dist/chunk-EZ5P7OPH.js.map +1 -0
  50. package/packages/api-runtime/dist/client.d.ts +40 -0
  51. package/packages/api-runtime/dist/client.js +13 -0
  52. package/packages/api-runtime/dist/client.js.map +1 -0
  53. package/packages/api-runtime/dist/index.d.ts +3 -0
  54. package/packages/api-runtime/dist/index.js +21 -0
  55. package/packages/api-runtime/dist/index.js.map +1 -0
  56. package/packages/api-runtime/dist/schema.d.ts +45 -0
  57. package/packages/api-runtime/dist/schema.js +11 -0
  58. package/packages/api-runtime/dist/schema.js.map +1 -0
  59. package/packages/api-runtime/node_modules/.bin/esbuild +21 -0
  60. package/packages/api-runtime/node_modules/.bin/jiti +21 -0
  61. package/packages/api-runtime/node_modules/.bin/tsc +21 -0
  62. package/packages/api-runtime/node_modules/.bin/tsserver +21 -0
  63. package/packages/api-runtime/node_modules/.bin/tsup +21 -0
  64. package/packages/api-runtime/node_modules/.bin/tsup-node +21 -0
  65. package/packages/api-runtime/package.json +54 -0
  66. package/packages/cli/CHANGELOG.md +34 -0
  67. package/packages/cli/biome.json +34 -0
  68. package/packages/cli/dist/index.d.ts +27 -0
  69. package/packages/cli/dist/index.js +183 -0
  70. package/packages/cli/dist/index.js.map +1 -0
  71. package/packages/cli/node_modules/.bin/esbuild +21 -0
  72. package/packages/cli/node_modules/.bin/jiti +21 -0
  73. package/packages/cli/node_modules/.bin/tsc +21 -0
  74. package/packages/cli/node_modules/.bin/tsserver +21 -0
  75. package/packages/cli/node_modules/.bin/tsup +21 -0
  76. package/packages/cli/node_modules/.bin/tsup-node +21 -0
  77. package/packages/cli/package.json +47 -0
  78. package/pnpm-workspace.yaml +2 -0
  79. package/test-config.js +9 -0
  80. package/test-content-type-handling.mjs +100 -0
  81. package/test-endpoints-config.mjs +144 -0
  82. package/test-formdata-content-type-protection.mjs +127 -0
  83. package/test-formdata-runtime.mjs +127 -0
  84. package/test-full-integration.mjs +90 -0
  85. package/test-headers-formdata.mjs +97 -0
  86. package/test-headers-runtime.mjs +106 -0
  87. package/test-headers.mjs +79 -0
  88. package/test-internal-calls.mjs +57 -0
  89. package/test-ky-formdata.mjs +81 -0
  90. package/test-output/actions.ts +134 -0
  91. package/test-output/client.ts +81 -0
  92. package/test-output/hooks.ts +182 -0
  93. package/test-output/index.ts +9 -0
  94. package/test-output/prefetchs.ts +25 -0
  95. package/test-output/queries.ts +78 -0
  96. package/test-output/query-keys.ts +16 -0
  97. package/test-output/query-options.ts +38 -0
  98. package/test-output/server-client.ts +32 -0
  99. package/test-output/types.ts +61 -0
  100. package/test-real-endpoints.mjs +132 -0
  101. package/test-runtime-params.mjs +160 -0
  102. package/test-simple-config.mjs +71 -0
  103. package/tsconfig.base.json +29 -0
@@ -0,0 +1,21 @@
1
+ #!/bin/sh
2
+ basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
3
+
4
+ case `uname` in
5
+ *CYGWIN*|*MINGW*|*MSYS*)
6
+ if command -v cygpath > /dev/null 2>&1; then
7
+ basedir=`cygpath -w "$basedir"`
8
+ fi
9
+ ;;
10
+ esac
11
+
12
+ if [ -z "$NODE_PATH" ]; then
13
+ export NODE_PATH="/home/hash/work/node/codegen/node_modules/.pnpm/tsup@8.5.1_jiti@2.6.1_postcss@8.5.6_typescript@5.9.3/node_modules/tsup/dist/node_modules:/home/hash/work/node/codegen/node_modules/.pnpm/tsup@8.5.1_jiti@2.6.1_postcss@8.5.6_typescript@5.9.3/node_modules/tsup/node_modules:/home/hash/work/node/codegen/node_modules/.pnpm/tsup@8.5.1_jiti@2.6.1_postcss@8.5.6_typescript@5.9.3/node_modules:/home/hash/work/node/codegen/node_modules/.pnpm/node_modules"
14
+ else
15
+ export NODE_PATH="/home/hash/work/node/codegen/node_modules/.pnpm/tsup@8.5.1_jiti@2.6.1_postcss@8.5.6_typescript@5.9.3/node_modules/tsup/dist/node_modules:/home/hash/work/node/codegen/node_modules/.pnpm/tsup@8.5.1_jiti@2.6.1_postcss@8.5.6_typescript@5.9.3/node_modules/tsup/node_modules:/home/hash/work/node/codegen/node_modules/.pnpm/tsup@8.5.1_jiti@2.6.1_postcss@8.5.6_typescript@5.9.3/node_modules:/home/hash/work/node/codegen/node_modules/.pnpm/node_modules:$NODE_PATH"
16
+ fi
17
+ if [ -x "$basedir/node" ]; then
18
+ exec "$basedir/node" "$basedir/../tsup/dist/cli-default.js" "$@"
19
+ else
20
+ exec node "$basedir/../tsup/dist/cli-default.js" "$@"
21
+ fi
@@ -0,0 +1,21 @@
1
+ #!/bin/sh
2
+ basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
3
+
4
+ case `uname` in
5
+ *CYGWIN*|*MINGW*|*MSYS*)
6
+ if command -v cygpath > /dev/null 2>&1; then
7
+ basedir=`cygpath -w "$basedir"`
8
+ fi
9
+ ;;
10
+ esac
11
+
12
+ if [ -z "$NODE_PATH" ]; then
13
+ export NODE_PATH="/home/hash/work/node/codegen/node_modules/.pnpm/tsup@8.5.1_jiti@2.6.1_postcss@8.5.6_typescript@5.9.3/node_modules/tsup/dist/node_modules:/home/hash/work/node/codegen/node_modules/.pnpm/tsup@8.5.1_jiti@2.6.1_postcss@8.5.6_typescript@5.9.3/node_modules/tsup/node_modules:/home/hash/work/node/codegen/node_modules/.pnpm/tsup@8.5.1_jiti@2.6.1_postcss@8.5.6_typescript@5.9.3/node_modules:/home/hash/work/node/codegen/node_modules/.pnpm/node_modules"
14
+ else
15
+ export NODE_PATH="/home/hash/work/node/codegen/node_modules/.pnpm/tsup@8.5.1_jiti@2.6.1_postcss@8.5.6_typescript@5.9.3/node_modules/tsup/dist/node_modules:/home/hash/work/node/codegen/node_modules/.pnpm/tsup@8.5.1_jiti@2.6.1_postcss@8.5.6_typescript@5.9.3/node_modules/tsup/node_modules:/home/hash/work/node/codegen/node_modules/.pnpm/tsup@8.5.1_jiti@2.6.1_postcss@8.5.6_typescript@5.9.3/node_modules:/home/hash/work/node/codegen/node_modules/.pnpm/node_modules:$NODE_PATH"
16
+ fi
17
+ if [ -x "$basedir/node" ]; then
18
+ exec "$basedir/node" "$basedir/../tsup/dist/cli-node.js" "$@"
19
+ else
20
+ exec node "$basedir/../tsup/dist/cli-node.js" "$@"
21
+ fi
@@ -0,0 +1,54 @@
1
+ {
2
+ "name": "@cushin/api-runtime",
3
+ "version": "5.0.0",
4
+ "description": "Runtime utilities for Cushin API codegen - types, schemas, and HTTP client",
5
+ "type": "module",
6
+ "main": "./dist/index.js",
7
+ "types": "./dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "import": "./dist/index.js"
12
+ },
13
+ "./client": {
14
+ "types": "./dist/client.d.ts",
15
+ "import": "./dist/client.js"
16
+ },
17
+ "./schema": {
18
+ "types": "./dist/schema.d.ts",
19
+ "import": "./dist/schema.js"
20
+ }
21
+ },
22
+ "files": [
23
+ "dist",
24
+ "README.md"
25
+ ],
26
+ "scripts": {
27
+ "build": "tsup",
28
+ "dev": "tsup --watch",
29
+ "typecheck": "tsc --noEmit"
30
+ },
31
+ "keywords": [
32
+ "api",
33
+ "runtime",
34
+ "client",
35
+ "typescript",
36
+ "type-safe"
37
+ ],
38
+ "author": "Le Viet Hoang",
39
+ "license": "MIT",
40
+ "peerDependencies": {
41
+ "ky": "^1.0.0",
42
+ "zod": "^3.22.0"
43
+ },
44
+ "devDependencies": {
45
+ "@types/node": "^20.11.0",
46
+ "ky": "^1.2.0",
47
+ "tsup": "^8.0.0",
48
+ "typescript": "^5.3.0",
49
+ "zod": "^3.25.76"
50
+ },
51
+ "engines": {
52
+ "node": ">=18.0.0"
53
+ }
54
+ }
@@ -0,0 +1,34 @@
1
+ # @cushin/cli
2
+
3
+ ## 5.0.0
4
+
5
+ ### Major Changes
6
+
7
+ - 1ed968d: updae query generator
8
+ - update
9
+ - cd6c999: update header
10
+ - dcba1a9: update query generator
11
+ - 21f73d5: update
12
+ - 9f79e31: update query generator
13
+ - 5269d20: update
14
+ - 1ed968d: update
15
+ - 4b6b54d: update query generator
16
+
17
+ ## 4.0.0
18
+
19
+ ### Major Changes
20
+
21
+ - Update type
22
+
23
+ ## 3.0.0
24
+
25
+ ### Major Changes
26
+
27
+ - 57f43aa: Update index generator
28
+ - 8ad12d3: Update index generator
29
+
30
+ ## 2.0.0
31
+
32
+ ### Major Changes
33
+
34
+ - first comment
@@ -0,0 +1,34 @@
1
+ {
2
+ "$schema": "https://biomejs.dev/schemas/2.2.5/schema.json",
3
+ "vcs": {
4
+ "enabled": false,
5
+ "clientKind": "git",
6
+ "useIgnoreFile": false
7
+ },
8
+ "files": {
9
+ "ignoreUnknown": false
10
+ },
11
+ "formatter": {
12
+ "enabled": true,
13
+ "indentStyle": "space"
14
+ },
15
+ "linter": {
16
+ "enabled": true,
17
+ "rules": {
18
+ "recommended": true
19
+ }
20
+ },
21
+ "javascript": {
22
+ "formatter": {
23
+ "quoteStyle": "double"
24
+ }
25
+ },
26
+ "assist": {
27
+ "enabled": true,
28
+ "actions": {
29
+ "source": {
30
+ "organizeImports": "on"
31
+ }
32
+ }
33
+ }
34
+ }
@@ -0,0 +1,27 @@
1
+ import { Command } from 'commander';
2
+
3
+ interface GenerateCommandContext {
4
+ loadConfig: (configPath?: string) => Promise<any>;
5
+ validateConfig: (config: any) => void;
6
+ CodegenCore: any;
7
+ }
8
+ declare function setupGenerateCommand(program: Command, context: GenerateCommandContext): Command;
9
+
10
+ interface InitCommandContext {
11
+ generateConfigTemplate?: (provider: string) => string;
12
+ }
13
+ declare function setupInitCommand(program: Command, context?: InitCommandContext): Command;
14
+
15
+ interface ValidateCommandContext {
16
+ loadConfig: (configPath?: string) => Promise<any>;
17
+ validateConfig: (config: any) => void;
18
+ CodegenCore: any;
19
+ pathToFileURL?: (filePath: string) => URL;
20
+ }
21
+ declare function setupValidateCommand(program: Command, context: ValidateCommandContext): Command;
22
+
23
+ interface CLICommandContext {
24
+ }
25
+ declare function setupCLIProgram(program: Command, name?: string): Command;
26
+
27
+ export { type CLICommandContext, type GenerateCommandContext, type InitCommandContext, type ValidateCommandContext, setupCLIProgram, setupGenerateCommand, setupInitCommand, setupValidateCommand };
@@ -0,0 +1,183 @@
1
+ // src/commands/index.ts
2
+ import "commander";
3
+
4
+ // src/commands/generate.ts
5
+ import "commander";
6
+ import chalk from "chalk";
7
+ import ora from "ora";
8
+ import fs from "fs/promises";
9
+ function setupGenerateCommand(program, context) {
10
+ return program.command("generate").alias("gen").description("Generate API client code from configuration").option("-c, --config <path>", "Path to configuration file").option("-w, --watch", "Watch for changes and regenerate").action(async (options) => {
11
+ const spinner = ora("Loading configuration...").start();
12
+ try {
13
+ const config = await context.loadConfig(options.config);
14
+ if (!config) {
15
+ spinner.fail(
16
+ chalk.red(
17
+ "No configuration file found. Please create an api-codegen.config.js file."
18
+ )
19
+ );
20
+ process.exit(1);
21
+ }
22
+ spinner.text = "Validating configuration...";
23
+ context.validateConfig(config);
24
+ spinner.text = "Loading API endpoints...";
25
+ const codegen = new context.CodegenCore(config);
26
+ spinner.text = "Generating code...";
27
+ await codegen.execute();
28
+ spinner.succeed(
29
+ chalk.green(
30
+ `\u2728 Code generated successfully in ${chalk.cyan(config.outputDir)}`
31
+ )
32
+ );
33
+ console.log(chalk.dim("\nGenerated files:"));
34
+ const files = await fs.readdir(config.outputDir);
35
+ files.forEach((file) => {
36
+ console.log(chalk.dim(` \u2022 ${file}`));
37
+ });
38
+ if (options.watch) {
39
+ console.log(chalk.yellow("\n\u{1F440} Watching for changes..."));
40
+ spinner.info(chalk.dim("Watch mode not yet implemented"));
41
+ }
42
+ } catch (error) {
43
+ spinner.fail(chalk.red("Failed to generate code"));
44
+ console.error(
45
+ chalk.red("\n" + (error instanceof Error ? error.message : String(error)))
46
+ );
47
+ if (error instanceof Error && error.stack) {
48
+ console.error(chalk.dim(error.stack));
49
+ }
50
+ process.exit(1);
51
+ }
52
+ });
53
+ }
54
+
55
+ // src/commands/init.ts
56
+ import "commander";
57
+ import chalk2 from "chalk";
58
+ import ora2 from "ora";
59
+ import fs2 from "fs/promises";
60
+ import path from "path";
61
+ function setupInitCommand(program, context) {
62
+ return program.command("init").description("Initialize a new api-codegen configuration").option("-p, --provider <provider>", "Provider type (vite or nextjs)", "vite").action(async (options) => {
63
+ const spinner = ora2("Creating configuration file...").start();
64
+ try {
65
+ const configContent = context?.generateConfigTemplate?.(options.provider) || generateDefaultConfigTemplate(options.provider);
66
+ const configPath = path.join(process.cwd(), "api-codegen.config.js");
67
+ try {
68
+ await fs2.access(configPath);
69
+ spinner.warn(
70
+ chalk2.yellow(
71
+ "Configuration file already exists at api-codegen.config.js"
72
+ )
73
+ );
74
+ return;
75
+ } catch {
76
+ }
77
+ await fs2.writeFile(configPath, configContent, "utf-8");
78
+ spinner.succeed(
79
+ chalk2.green("\u2728 Configuration file created: api-codegen.config.js")
80
+ );
81
+ console.log(chalk2.dim("\nNext steps:"));
82
+ console.log(chalk2.dim(" 1. Update the endpoints path in the config"));
83
+ console.log(chalk2.dim(" 2. Run: npx @cushin/api-codegen generate"));
84
+ } catch (error) {
85
+ spinner.fail(chalk2.red("Failed to create configuration file"));
86
+ console.error(
87
+ chalk2.red("\n" + (error instanceof Error ? error.message : String(error)))
88
+ );
89
+ process.exit(1);
90
+ }
91
+ });
92
+ }
93
+ function generateDefaultConfigTemplate(provider) {
94
+ return `/** @type {import('@cushin/api-codegen').UserConfig} */
95
+ export default {
96
+ // Provider: 'vite' or 'nextjs'
97
+ provider: '${provider}',
98
+
99
+ // Path to your API endpoints configuration
100
+ endpoints: './lib/api/config/endpoints.ts',
101
+
102
+ // Output directory for generated files
103
+ output: './lib/api/generated',
104
+
105
+ // Base URL for API requests (optional, can be set at runtime)
106
+ baseUrl: process.env.VITE_API_URL || process.env.NEXT_PUBLIC_API_URL,
107
+
108
+ // Generation options
109
+ generateHooks: true,
110
+ generateClient: true,
111
+ ${provider === "nextjs" ? `generateServerActions: true,
112
+ generateServerQueries: true,` : ""}
113
+
114
+ // Advanced options
115
+ options: {
116
+ useClientDirective: true,
117
+ hookPrefix: 'use',
118
+ actionSuffix: 'Action',
119
+ },
120
+ };
121
+ `;
122
+ }
123
+
124
+ // src/commands/validate.ts
125
+ import "commander";
126
+ import chalk3 from "chalk";
127
+ import ora3 from "ora";
128
+ import path2 from "path";
129
+ function setupValidateCommand(program, context) {
130
+ return program.command("validate").description("Validate your API endpoints configuration").option("-c, --config <path>", "Path to configuration file").action(async (options) => {
131
+ const spinner = ora3("Loading configuration...").start();
132
+ try {
133
+ const config = await context.loadConfig(options.config);
134
+ if (!config) {
135
+ spinner.fail(chalk3.red("No configuration file found"));
136
+ process.exit(1);
137
+ }
138
+ spinner.text = "Validating configuration...";
139
+ context.validateConfig(config);
140
+ spinner.text = "Loading API endpoints...";
141
+ new context.CodegenCore(config);
142
+ const pathToFileURL = context.pathToFileURL || ((filePath) => new URL(`file://${path2.resolve(filePath)}`));
143
+ const apiConfigModule = await import(pathToFileURL(config.endpointsPath).href);
144
+ const apiConfig = apiConfigModule.apiConfig || apiConfigModule.default?.apiConfig || apiConfigModule.default;
145
+ if (!apiConfig || !apiConfig.endpoints) {
146
+ throw new Error("Invalid endpoints configuration");
147
+ }
148
+ const endpointCount = Object.keys(apiConfig.endpoints).length;
149
+ spinner.succeed(
150
+ chalk3.green(
151
+ `\u2728 Configuration is valid! Found ${endpointCount} endpoint${endpointCount === 1 ? "" : "s"}`
152
+ )
153
+ );
154
+ console.log(chalk3.dim("\nEndpoints:"));
155
+ Object.entries(apiConfig.endpoints).forEach(([name, endpoint]) => {
156
+ console.log(
157
+ chalk3.dim(
158
+ ` \u2022 ${chalk3.cyan(name)}: ${endpoint.method} ${endpoint.path}`
159
+ )
160
+ );
161
+ });
162
+ } catch (error) {
163
+ spinner.fail(chalk3.red("Validation failed"));
164
+ console.error(
165
+ chalk3.red("\n" + (error instanceof Error ? error.message : String(error)))
166
+ );
167
+ process.exit(1);
168
+ }
169
+ });
170
+ }
171
+
172
+ // src/commands/index.ts
173
+ function setupCLIProgram(program, name = "api-codegen") {
174
+ program.name(name).description("Generate type-safe API client code from endpoint definitions").version("1.1.1");
175
+ return program;
176
+ }
177
+ export {
178
+ setupCLIProgram,
179
+ setupGenerateCommand,
180
+ setupInitCommand,
181
+ setupValidateCommand
182
+ };
183
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/commands/index.ts","../src/commands/generate.ts","../src/commands/init.ts","../src/commands/validate.ts"],"sourcesContent":["import { Command } from 'commander';\n\nexport interface CLICommandContext {\n // This will be extended by packages that use the CLI\n}\n\nexport function setupCLIProgram(program: Command, name = 'api-codegen'): Command {\n program\n .name(name)\n .description('Generate type-safe API client code from endpoint definitions')\n .version('1.1.1');\n\n return program;\n}\n\nexport type { GenerateCommandContext } from './generate.js';\nexport type { InitCommandContext } from './init.js';\nexport type { ValidateCommandContext } from './validate.js';\n\nexport { setupGenerateCommand } from './generate.js';\nexport { setupInitCommand } from './init.js';\nexport { setupValidateCommand } from './validate.js';\n","import { Command } from 'commander';\nimport chalk from 'chalk';\nimport ora from 'ora';\nimport fs from 'fs/promises';\n\nexport interface GenerateCommandContext {\n loadConfig: (configPath?: string) => Promise<any>;\n validateConfig: (config: any) => void;\n CodegenCore: any;\n}\n\nexport function setupGenerateCommand(\n program: Command,\n context: GenerateCommandContext,\n): Command {\n return program\n .command('generate')\n .alias('gen')\n .description('Generate API client code from configuration')\n .option('-c, --config <path>', 'Path to configuration file')\n .option('-w, --watch', 'Watch for changes and regenerate')\n .action(async (options) => {\n const spinner = ora('Loading configuration...').start();\n\n try {\n // Load configuration\n const config = await context.loadConfig(options.config);\n\n if (!config) {\n spinner.fail(\n chalk.red(\n 'No configuration file found. Please create an api-codegen.config.js file.',\n ),\n );\n process.exit(1);\n }\n\n spinner.text = 'Validating configuration...';\n context.validateConfig(config);\n\n spinner.text = 'Loading API endpoints...';\n const codegen = new context.CodegenCore(config);\n\n spinner.text = 'Generating code...';\n await codegen.execute();\n\n spinner.succeed(\n chalk.green(\n `✨ Code generated successfully in ${chalk.cyan(config.outputDir)}`,\n ),\n );\n\n // Print generated files\n console.log(chalk.dim('\\nGenerated files:'));\n const files = await fs.readdir(config.outputDir);\n files.forEach((file) => {\n console.log(chalk.dim(` • ${file}`));\n });\n\n if (options.watch) {\n console.log(chalk.yellow('\\n👀 Watching for changes...'));\n // TODO: Implement watch mode\n spinner.info(chalk.dim('Watch mode not yet implemented'));\n }\n } catch (error) {\n spinner.fail(chalk.red('Failed to generate code'));\n console.error(\n chalk.red('\\n' + (error instanceof Error ? error.message : String(error))),\n );\n if (error instanceof Error && error.stack) {\n console.error(chalk.dim(error.stack));\n }\n process.exit(1);\n }\n });\n}\n","import { Command } from 'commander';\nimport chalk from 'chalk';\nimport ora from 'ora';\nimport fs from 'fs/promises';\nimport path from 'path';\n\nexport interface InitCommandContext {\n generateConfigTemplate?: (provider: string) => string;\n}\n\nexport function setupInitCommand(\n program: Command,\n context?: InitCommandContext,\n): Command {\n return program\n .command('init')\n .description('Initialize a new api-codegen configuration')\n .option('-p, --provider <provider>', 'Provider type (vite or nextjs)', 'vite')\n .action(async (options) => {\n const spinner = ora('Creating configuration file...').start();\n\n try {\n const configContent =\n context?.generateConfigTemplate?.(options.provider) ||\n generateDefaultConfigTemplate(options.provider);\n const configPath = path.join(process.cwd(), 'api-codegen.config.js');\n\n // Check if config already exists\n try {\n await fs.access(configPath);\n spinner.warn(\n chalk.yellow(\n 'Configuration file already exists at api-codegen.config.js',\n ),\n );\n return;\n } catch {\n // File doesn't exist, continue\n }\n\n await fs.writeFile(configPath, configContent, 'utf-8');\n\n spinner.succeed(\n chalk.green('✨ Configuration file created: api-codegen.config.js'),\n );\n\n console.log(chalk.dim('\\nNext steps:'));\n console.log(chalk.dim(' 1. Update the endpoints path in the config'));\n console.log(chalk.dim(' 2. Run: npx @cushin/api-codegen generate'));\n } catch (error) {\n spinner.fail(chalk.red('Failed to create configuration file'));\n console.error(\n chalk.red('\\n' + (error instanceof Error ? error.message : String(error))),\n );\n process.exit(1);\n }\n });\n}\n\nfunction generateDefaultConfigTemplate(provider: string): string {\n return `/** @type {import('@cushin/api-codegen').UserConfig} */\nexport default {\n // Provider: 'vite' or 'nextjs'\n provider: '${provider}',\n\n // Path to your API endpoints configuration\n endpoints: './lib/api/config/endpoints.ts',\n\n // Output directory for generated files\n output: './lib/api/generated',\n\n // Base URL for API requests (optional, can be set at runtime)\n baseUrl: process.env.VITE_API_URL || process.env.NEXT_PUBLIC_API_URL,\n\n // Generation options\n generateHooks: true,\n generateClient: true,\n ${provider === 'nextjs' ? `generateServerActions: true,\n generateServerQueries: true,` : ''}\n\n // Advanced options\n options: {\n useClientDirective: true,\n hookPrefix: 'use',\n actionSuffix: 'Action',\n },\n};\n`;\n}\n","import { Command } from 'commander';\nimport chalk from 'chalk';\nimport ora from 'ora';\nimport path from 'path';\n\nexport interface ValidateCommandContext {\n loadConfig: (configPath?: string) => Promise<any>;\n validateConfig: (config: any) => void;\n CodegenCore: any;\n pathToFileURL?: (filePath: string) => URL;\n}\n\nexport function setupValidateCommand(\n program: Command,\n context: ValidateCommandContext,\n): Command {\n return program\n .command('validate')\n .description('Validate your API endpoints configuration')\n .option('-c, --config <path>', 'Path to configuration file')\n .action(async (options) => {\n const spinner = ora('Loading configuration...').start();\n\n try {\n const config = await context.loadConfig(options.config);\n\n if (!config) {\n spinner.fail(chalk.red('No configuration file found'));\n process.exit(1);\n }\n\n spinner.text = 'Validating configuration...';\n context.validateConfig(config);\n\n spinner.text = 'Loading API endpoints...';\n\n new context.CodegenCore(config);\n\n // Just load to validate\n const pathToFileURL =\n context.pathToFileURL ||\n ((filePath: string) => new URL(`file://${path.resolve(filePath)}`));\n const apiConfigModule = await import(pathToFileURL(config.endpointsPath).href);\n const apiConfig =\n apiConfigModule.apiConfig ||\n apiConfigModule.default?.apiConfig ||\n apiConfigModule.default;\n\n if (!apiConfig || !apiConfig.endpoints) {\n throw new Error('Invalid endpoints configuration');\n }\n\n const endpointCount = Object.keys(apiConfig.endpoints).length;\n\n spinner.succeed(\n chalk.green(\n `✨ Configuration is valid! Found ${endpointCount} endpoint${endpointCount === 1 ? '' : 's'}`,\n ),\n );\n\n // Print endpoint summary\n console.log(chalk.dim('\\nEndpoints:'));\n Object.entries(apiConfig.endpoints).forEach(([name, endpoint]: [string, any]) => {\n console.log(\n chalk.dim(\n ` • ${chalk.cyan(name)}: ${endpoint.method} ${endpoint.path}`,\n ),\n );\n });\n } catch (error) {\n spinner.fail(chalk.red('Validation failed'));\n console.error(\n chalk.red('\\n' + (error instanceof Error ? error.message : String(error))),\n );\n process.exit(1);\n }\n });\n}\n"],"mappings":";AAAA,OAAwB;;;ACAxB,OAAwB;AACxB,OAAO,WAAW;AAClB,OAAO,SAAS;AAChB,OAAO,QAAQ;AAQR,SAAS,qBACd,SACA,SACS;AACT,SAAO,QACJ,QAAQ,UAAU,EAClB,MAAM,KAAK,EACX,YAAY,6CAA6C,EACzD,OAAO,uBAAuB,4BAA4B,EAC1D,OAAO,eAAe,kCAAkC,EACxD,OAAO,OAAO,YAAY;AACzB,UAAM,UAAU,IAAI,0BAA0B,EAAE,MAAM;AAEtD,QAAI;AAEF,YAAM,SAAS,MAAM,QAAQ,WAAW,QAAQ,MAAM;AAEtD,UAAI,CAAC,QAAQ;AACX,gBAAQ;AAAA,UACN,MAAM;AAAA,YACJ;AAAA,UACF;AAAA,QACF;AACA,gBAAQ,KAAK,CAAC;AAAA,MAChB;AAEA,cAAQ,OAAO;AACf,cAA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gBAAgB,SAAkB,OAAO,eAAwB;AAC/E,UACG,KAAK,IAAI,EACT,YAAY,8DAA8D,EAC1E,QAAQ,OAAO;AAElB,SAAO;AACT;","names":["chalk","ora","fs","chalk","ora","path"]}
@@ -0,0 +1,21 @@
1
+ #!/bin/sh
2
+ basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
3
+
4
+ case `uname` in
5
+ *CYGWIN*|*MINGW*|*MSYS*)
6
+ if command -v cygpath > /dev/null 2>&1; then
7
+ basedir=`cygpath -w "$basedir"`
8
+ fi
9
+ ;;
10
+ esac
11
+
12
+ if [ -z "$NODE_PATH" ]; then
13
+ export NODE_PATH="/home/hash/work/node/api-codegen/node_modules/.pnpm/esbuild@0.27.0/node_modules/esbuild/bin/node_modules:/home/hash/work/node/api-codegen/node_modules/.pnpm/esbuild@0.27.0/node_modules/esbuild/node_modules:/home/hash/work/node/api-codegen/node_modules/.pnpm/esbuild@0.27.0/node_modules:/home/hash/work/node/api-codegen/node_modules/.pnpm/node_modules"
14
+ else
15
+ export NODE_PATH="/home/hash/work/node/api-codegen/node_modules/.pnpm/esbuild@0.27.0/node_modules/esbuild/bin/node_modules:/home/hash/work/node/api-codegen/node_modules/.pnpm/esbuild@0.27.0/node_modules/esbuild/node_modules:/home/hash/work/node/api-codegen/node_modules/.pnpm/esbuild@0.27.0/node_modules:/home/hash/work/node/api-codegen/node_modules/.pnpm/node_modules:$NODE_PATH"
16
+ fi
17
+ if [ -x "$basedir/node" ]; then
18
+ exec "$basedir/node" "$basedir/../../../../node_modules/.pnpm/esbuild@0.27.0/node_modules/esbuild/bin/esbuild" "$@"
19
+ else
20
+ exec node "$basedir/../../../../node_modules/.pnpm/esbuild@0.27.0/node_modules/esbuild/bin/esbuild" "$@"
21
+ fi
@@ -0,0 +1,21 @@
1
+ #!/bin/sh
2
+ basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
3
+
4
+ case `uname` in
5
+ *CYGWIN*|*MINGW*|*MSYS*)
6
+ if command -v cygpath > /dev/null 2>&1; then
7
+ basedir=`cygpath -w "$basedir"`
8
+ fi
9
+ ;;
10
+ esac
11
+
12
+ if [ -z "$NODE_PATH" ]; then
13
+ export NODE_PATH="/home/hash/work/node/codegen/node_modules/.pnpm/jiti@2.6.1/node_modules/jiti/lib/node_modules:/home/hash/work/node/codegen/node_modules/.pnpm/jiti@2.6.1/node_modules/jiti/node_modules:/home/hash/work/node/codegen/node_modules/.pnpm/jiti@2.6.1/node_modules:/home/hash/work/node/codegen/node_modules/.pnpm/node_modules"
14
+ else
15
+ export NODE_PATH="/home/hash/work/node/codegen/node_modules/.pnpm/jiti@2.6.1/node_modules/jiti/lib/node_modules:/home/hash/work/node/codegen/node_modules/.pnpm/jiti@2.6.1/node_modules/jiti/node_modules:/home/hash/work/node/codegen/node_modules/.pnpm/jiti@2.6.1/node_modules:/home/hash/work/node/codegen/node_modules/.pnpm/node_modules:$NODE_PATH"
16
+ fi
17
+ if [ -x "$basedir/node" ]; then
18
+ exec "$basedir/node" "$basedir/../../../../node_modules/.pnpm/jiti@2.6.1/node_modules/jiti/lib/jiti-cli.mjs" "$@"
19
+ else
20
+ exec node "$basedir/../../../../node_modules/.pnpm/jiti@2.6.1/node_modules/jiti/lib/jiti-cli.mjs" "$@"
21
+ fi
@@ -0,0 +1,21 @@
1
+ #!/bin/sh
2
+ basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
3
+
4
+ case `uname` in
5
+ *CYGWIN*|*MINGW*|*MSYS*)
6
+ if command -v cygpath > /dev/null 2>&1; then
7
+ basedir=`cygpath -w "$basedir"`
8
+ fi
9
+ ;;
10
+ esac
11
+
12
+ if [ -z "$NODE_PATH" ]; then
13
+ export NODE_PATH="/home/hash/work/node/codegen/node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/bin/node_modules:/home/hash/work/node/codegen/node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/node_modules:/home/hash/work/node/codegen/node_modules/.pnpm/typescript@5.9.3/node_modules:/home/hash/work/node/codegen/node_modules/.pnpm/node_modules"
14
+ else
15
+ export NODE_PATH="/home/hash/work/node/codegen/node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/bin/node_modules:/home/hash/work/node/codegen/node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/node_modules:/home/hash/work/node/codegen/node_modules/.pnpm/typescript@5.9.3/node_modules:/home/hash/work/node/codegen/node_modules/.pnpm/node_modules:$NODE_PATH"
16
+ fi
17
+ if [ -x "$basedir/node" ]; then
18
+ exec "$basedir/node" "$basedir/../typescript/bin/tsc" "$@"
19
+ else
20
+ exec node "$basedir/../typescript/bin/tsc" "$@"
21
+ fi
@@ -0,0 +1,21 @@
1
+ #!/bin/sh
2
+ basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
3
+
4
+ case `uname` in
5
+ *CYGWIN*|*MINGW*|*MSYS*)
6
+ if command -v cygpath > /dev/null 2>&1; then
7
+ basedir=`cygpath -w "$basedir"`
8
+ fi
9
+ ;;
10
+ esac
11
+
12
+ if [ -z "$NODE_PATH" ]; then
13
+ export NODE_PATH="/home/hash/work/node/codegen/node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/bin/node_modules:/home/hash/work/node/codegen/node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/node_modules:/home/hash/work/node/codegen/node_modules/.pnpm/typescript@5.9.3/node_modules:/home/hash/work/node/codegen/node_modules/.pnpm/node_modules"
14
+ else
15
+ export NODE_PATH="/home/hash/work/node/codegen/node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/bin/node_modules:/home/hash/work/node/codegen/node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/node_modules:/home/hash/work/node/codegen/node_modules/.pnpm/typescript@5.9.3/node_modules:/home/hash/work/node/codegen/node_modules/.pnpm/node_modules:$NODE_PATH"
16
+ fi
17
+ if [ -x "$basedir/node" ]; then
18
+ exec "$basedir/node" "$basedir/../typescript/bin/tsserver" "$@"
19
+ else
20
+ exec node "$basedir/../typescript/bin/tsserver" "$@"
21
+ fi
@@ -0,0 +1,21 @@
1
+ #!/bin/sh
2
+ basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
3
+
4
+ case `uname` in
5
+ *CYGWIN*|*MINGW*|*MSYS*)
6
+ if command -v cygpath > /dev/null 2>&1; then
7
+ basedir=`cygpath -w "$basedir"`
8
+ fi
9
+ ;;
10
+ esac
11
+
12
+ if [ -z "$NODE_PATH" ]; then
13
+ export NODE_PATH="/home/hash/work/node/codegen/node_modules/.pnpm/tsup@8.5.1_jiti@2.6.1_postcss@8.5.6_typescript@5.9.3/node_modules/tsup/dist/node_modules:/home/hash/work/node/codegen/node_modules/.pnpm/tsup@8.5.1_jiti@2.6.1_postcss@8.5.6_typescript@5.9.3/node_modules/tsup/node_modules:/home/hash/work/node/codegen/node_modules/.pnpm/tsup@8.5.1_jiti@2.6.1_postcss@8.5.6_typescript@5.9.3/node_modules:/home/hash/work/node/codegen/node_modules/.pnpm/node_modules"
14
+ else
15
+ export NODE_PATH="/home/hash/work/node/codegen/node_modules/.pnpm/tsup@8.5.1_jiti@2.6.1_postcss@8.5.6_typescript@5.9.3/node_modules/tsup/dist/node_modules:/home/hash/work/node/codegen/node_modules/.pnpm/tsup@8.5.1_jiti@2.6.1_postcss@8.5.6_typescript@5.9.3/node_modules/tsup/node_modules:/home/hash/work/node/codegen/node_modules/.pnpm/tsup@8.5.1_jiti@2.6.1_postcss@8.5.6_typescript@5.9.3/node_modules:/home/hash/work/node/codegen/node_modules/.pnpm/node_modules:$NODE_PATH"
16
+ fi
17
+ if [ -x "$basedir/node" ]; then
18
+ exec "$basedir/node" "$basedir/../tsup/dist/cli-default.js" "$@"
19
+ else
20
+ exec node "$basedir/../tsup/dist/cli-default.js" "$@"
21
+ fi
@@ -0,0 +1,21 @@
1
+ #!/bin/sh
2
+ basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
3
+
4
+ case `uname` in
5
+ *CYGWIN*|*MINGW*|*MSYS*)
6
+ if command -v cygpath > /dev/null 2>&1; then
7
+ basedir=`cygpath -w "$basedir"`
8
+ fi
9
+ ;;
10
+ esac
11
+
12
+ if [ -z "$NODE_PATH" ]; then
13
+ export NODE_PATH="/home/hash/work/node/codegen/node_modules/.pnpm/tsup@8.5.1_jiti@2.6.1_postcss@8.5.6_typescript@5.9.3/node_modules/tsup/dist/node_modules:/home/hash/work/node/codegen/node_modules/.pnpm/tsup@8.5.1_jiti@2.6.1_postcss@8.5.6_typescript@5.9.3/node_modules/tsup/node_modules:/home/hash/work/node/codegen/node_modules/.pnpm/tsup@8.5.1_jiti@2.6.1_postcss@8.5.6_typescript@5.9.3/node_modules:/home/hash/work/node/codegen/node_modules/.pnpm/node_modules"
14
+ else
15
+ export NODE_PATH="/home/hash/work/node/codegen/node_modules/.pnpm/tsup@8.5.1_jiti@2.6.1_postcss@8.5.6_typescript@5.9.3/node_modules/tsup/dist/node_modules:/home/hash/work/node/codegen/node_modules/.pnpm/tsup@8.5.1_jiti@2.6.1_postcss@8.5.6_typescript@5.9.3/node_modules/tsup/node_modules:/home/hash/work/node/codegen/node_modules/.pnpm/tsup@8.5.1_jiti@2.6.1_postcss@8.5.6_typescript@5.9.3/node_modules:/home/hash/work/node/codegen/node_modules/.pnpm/node_modules:$NODE_PATH"
16
+ fi
17
+ if [ -x "$basedir/node" ]; then
18
+ exec "$basedir/node" "$basedir/../tsup/dist/cli-node.js" "$@"
19
+ else
20
+ exec node "$basedir/../tsup/dist/cli-node.js" "$@"
21
+ fi
@@ -0,0 +1,47 @@
1
+ {
2
+ "name": "@cushin/codegen-cli",
3
+ "version": "5.0.0",
4
+ "description": "Shared CLI utilities for Cushin code generators",
5
+ "type": "module",
6
+ "main": "./dist/index.js",
7
+ "types": "./dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "import": "./dist/index.js"
12
+ },
13
+ "./commands": {
14
+ "types": "./dist/commands/index.d.ts",
15
+ "import": "./dist/commands/index.js"
16
+ }
17
+ },
18
+ "files": [
19
+ "dist",
20
+ "README.md"
21
+ ],
22
+ "scripts": {
23
+ "build": "tsup",
24
+ "dev": "tsup --watch",
25
+ "typecheck": "tsc --noEmit"
26
+ },
27
+ "keywords": [
28
+ "cli",
29
+ "codegen",
30
+ "typescript"
31
+ ],
32
+ "author": "Le Viet Hoang",
33
+ "license": "MIT",
34
+ "dependencies": {
35
+ "chalk": "^5.3.0",
36
+ "commander": "^12.0.0",
37
+ "ora": "^8.0.0"
38
+ },
39
+ "devDependencies": {
40
+ "@types/node": "^20.11.0",
41
+ "typescript": "^5.3.0",
42
+ "tsup": "^8.0.0"
43
+ },
44
+ "engines": {
45
+ "node": ">=18.0.0"
46
+ }
47
+ }
@@ -0,0 +1,2 @@
1
+ packages:
2
+ - 'packages/*'
package/test-config.js ADDED
@@ -0,0 +1,9 @@
1
+ export default {
2
+ provider: 'nextjs',
3
+ endpoints: './test-real-endpoints.mjs',
4
+ output: './test-output',
5
+ generateClient: true,
6
+ generateHooks: true,
7
+ generateServerActions: true,
8
+ generateServerQueries: true,
9
+ };