hono-takibi 0.5.0 → 0.5.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 (3) hide show
  1. package/README.md +6 -4
  2. package/dist/index.js +16 -11
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -10,7 +10,7 @@ npm install -D hono-takibi
10
10
 
11
11
  ## Migrate Legacy APIs to Hono
12
12
 
13
- **Hono Takibi** is an OpenAPI-to-Hono code generator, specifically developed to assist in migrating APIs from various programming languages to Hono. This tool automates the creation of type-safe Hono routes from your existing OpenAPI specifications, making it easier to transition from legacy systems (Ruby, Perl, PHP, etc.) to a modern Hono architecture.
13
+ **[Hono Takibi](https://www.npmjs.com/package/hono-takibi)** is an OpenAPI-to-Hono code generator, specifically developed to assist in migrating APIs from various programming languages to Hono. This tool automates the creation of type-safe Hono routes from your existing OpenAPI specifications, making it easier to transition from legacy systems (Ruby, Perl, PHP, etc.) to a modern Hono architecture.
14
14
 
15
15
  ## What Problem Does It Solve?
16
16
 
@@ -40,12 +40,14 @@ npx hono-takibi path/to/openapi.yaml -o path/to/output_hono.ts
40
40
  | -template | Controls the generation of application and handler files. When enabled, creates both the main application file and corresponding route handlers |
41
41
  | -test | Enables automatic generation of test files for your API endpoints. |
42
42
  | --basePath | Specifies the base URL path for your API endpoints. |
43
- | --isDev | Defines the environment variable used to determine development mode. Controls features like Swagger UI availability |
43
+ | --env | Defines the environment variable used to determine development mode. Controls features like Swagger UI availability |
44
+
45
+ > **⚠️** When using the `-template` option, you must specify a valid directory path. Ensure the directory exists before executing the command.
44
46
 
45
47
  ### Example
46
48
 
47
49
  ```bash
48
- npx hono-takibi openapi.yaml -o project/routes.ts -template -test --basePath /api --isDev process.env.NODE_ENV
50
+ npx hono-takibi openapi.yaml -o project/routes.ts -template -test --basePath api --env process.env.NODE_ENV
49
51
  ```
50
52
 
51
53
  ## Demo
@@ -562,4 +564,4 @@ Let's make this tool better together! 🔥
562
564
 
563
565
  ## License
564
566
 
565
- Distributed under the MIT License. See [LICENSE](https://github.com/nakita-Ypm/hono-takibi?tab=MIT-1-ov-file) for more information.
567
+ Distributed under the MIT License. See [LICENSE](https://github.com/nakita-Ypm/hono-takibi?tab=MIT-1-ov-file) for more information.z
package/dist/index.js CHANGED
@@ -61,17 +61,22 @@ async function main(dev = false, config = (0, config_1.getConfig)()) {
61
61
  node_fs_1.default.writeFileSync(output, formattedCode, { encoding: 'utf-8' });
62
62
  // 10. generate template code
63
63
  const template = args.includes('-template');
64
- // Test
65
- const test = args.includes('-test');
66
- // Environment file path
67
- const envIndex = args.indexOf('--env');
68
- const hasEnvEquals = envIndex !== -1 && args[envIndex + 1] === '=';
69
- const env = hasEnvEquals ? args[envIndex + 2] : undefined;
70
- // Base path
71
- const basePathIndex = args.indexOf('--base-path');
72
- const hasBasePathEquals = basePathIndex !== -1 && args[basePathIndex + 1] === '=';
73
- const basePath = hasBasePathEquals ? args[basePathIndex + 2] : undefined;
74
- if (template === true) {
64
+ const isSlash = output.includes('/');
65
+ if (!isSlash && template === true) {
66
+ console.warn("To use the '-template' option, you must specify a valid directory path. Ensure the directory exists before executing the command.");
67
+ return false;
68
+ }
69
+ if (template === true && isSlash) {
70
+ // Test
71
+ const test = args.includes('-test');
72
+ // Environment file path
73
+ const envIndex = args.indexOf('--env');
74
+ const hasEnvEquals = envIndex !== -1 && args[envIndex + 1] === '=';
75
+ const env = hasEnvEquals ? args[envIndex + 2] : undefined;
76
+ // Base path
77
+ const basePathIndex = args.indexOf('--base-path');
78
+ const hasBasePathEquals = basePathIndex !== -1 && args[basePathIndex + 1] === '=';
79
+ const basePath = hasBasePathEquals ? args[basePathIndex + 2] : undefined;
75
80
  // 10.1 generate app code
76
81
  const appCode = (0, app_1.generateApp)(openAPI, config, env, basePath);
77
82
  // 10.2 generate handler code
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "hono-takibi",
3
3
  "description": "Hono Takibi is a CLI tool that generates Hono routes from OpenAPI specifications.",
4
- "version": "0.5.0",
4
+ "version": "0.5.1",
5
5
  "license": "MIT",
6
6
  "keywords": [
7
7
  "hono",