create-routecraft 0.1.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.
package/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,66 @@
1
+ # create-routecraft
2
+
3
+ Scaffold a new RouteCraft project with best practices and example routes.
4
+
5
+ ## Usage
6
+
7
+ Create a new RouteCraft project interactively:
8
+
9
+ ```bash
10
+ npm create routecraft@latest
11
+ ```
12
+
13
+ or
14
+
15
+ ```bash
16
+ pnpm create routecraft
17
+ ```
18
+
19
+ or
20
+
21
+ ```bash
22
+ npx create-routecraft
23
+ ```
24
+
25
+ ## What's Included
26
+
27
+ The scaffolded project includes:
28
+
29
+ - āœ… Pre-configured TypeScript setup
30
+ - āœ… Example routes demonstrating key features
31
+ - āœ… Ready-to-use project structure
32
+ - āœ… Development dependencies configured
33
+ - āœ… ESLint and testing setup
34
+
35
+ ## Interactive Prompts
36
+
37
+ The CLI will guide you through:
38
+
39
+ 1. **Project name**: Choose a name for your project
40
+ 2. **Package manager**: Select npm, pnpm, or yarn
41
+ 3. **Template**: Pick from available starter templates
42
+
43
+ ## Next Steps
44
+
45
+ After creating your project:
46
+
47
+ ```bash
48
+ cd your-project-name
49
+ npm install
50
+ npm run dev
51
+ ```
52
+
53
+ ## Documentation
54
+
55
+ For more information about RouteCraft, visit [routecraft.dev](https://routecraft.dev).
56
+
57
+ ## License
58
+
59
+ Apache-2.0
60
+
61
+ ## Links
62
+
63
+ - [Documentation](https://routecraft.dev)
64
+ - [GitHub Repository](https://github.com/routecraftjs/routecraft)
65
+ - [Issue Tracker](https://github.com/routecraftjs/routecraft/issues)
66
+
@@ -0,0 +1 @@
1
+ #!/usr/bin/env node
package/dist/index.js ADDED
@@ -0,0 +1,85 @@
1
+ #!/usr/bin/env node
2
+ import {mkdir,writeFile,cp,rm,readFile,readdir,stat}from'fs/promises';import {resolve,join,dirname}from'path';import {fileURLToPath}from'url';import {existsSync,readFileSync}from'fs';import {execSync}from'child_process';import {confirm,select,input}from'@inquirer/prompts';import {tmpdir}from'os';function h(){try{let e=join(dirname(fileURLToPath(import.meta.url)),"../../routecraft/package.json");if(existsSync(e))return `^${JSON.parse(readFileSync(e,"utf-8")).version}`}catch{}return "latest"}var U={"package.json":{content:e=>JSON.stringify({name:e,version:"0.1.1",private:true,type:"module",scripts:{build:"tsc",start:"craft run dist/index.js",lint:"eslint ."},dependencies:{"@routecraft/routecraft":h()},devDependencies:{"@types/node":"^20.0.0",typescript:"^5.0.0",eslint:"^9.36.0","@eslint/js":"^9.36.0","typescript-eslint":"^8.44.1","@routecraft/eslint-plugin-routecraft":h(),"@routecraft/cli":h(),"pino-pretty":"^13.1.2"}},null,2)},"tsconfig.json":{content:JSON.stringify({compilerOptions:{target:"ES2022",module:"ESNext",moduleResolution:"bundler",outDir:"./dist",rootDir:".",allowSyntheticDefaultImports:true,esModuleInterop:true,allowJs:true,strict:true,skipLibCheck:true,isolatedModules:true,resolveJsonModule:true},include:["**/*.ts","**/*.js"],exclude:["node_modules","dist"]},null,2)},"eslint.config.mjs":{content:`import pluginJs from "@eslint/js";
3
+ import tseslint from "typescript-eslint";
4
+ import routecraftPlugin from "@routecraft/eslint-plugin-routecraft";
5
+
6
+ /** @type {import('eslint').Linter.Config[]} */
7
+ export default [
8
+ pluginJs.configs.recommended,
9
+ ...tseslint.configs.recommended,
10
+ {
11
+ files: ["routes/**/*.{ts,js}", "**/*.route.{ts,js}", "**/*.{ts,js}"],
12
+ plugins: { "@routecraft/routecraft": routecraftPlugin },
13
+ ...routecraftPlugin.configs.recommended,
14
+ },
15
+ ];
16
+ `},"craft.config.ts":{content:`import type { CraftConfig } from "@routecraft/routecraft";
17
+
18
+ const config: CraftConfig = {
19
+ };
20
+
21
+ export default config;`},".gitignore":{content:`node_modules/
22
+ dist/
23
+ .env
24
+ .env.local
25
+ .env.*.local
26
+ *.log
27
+ .DS_Store`},"index.ts":{content:e=>e?`export { default as craftConfig } from './craft.config.js';
28
+ import helloWorldRoute from './routes/hello-world.route.js';
29
+
30
+ // Export all routes as default for craft run
31
+ export default [helloWorldRoute];`:`export { default as craftConfig } from './craft.config.js';
32
+
33
+ // Export all routes as default for craft run
34
+ export default [];`}},F={"hello-world":{"routes/hello-world.route.ts":{content:`import { log, craft, simple, fetch, type FetchResult } from "@routecraft/routecraft";
35
+
36
+ export default craft()
37
+ .id("hello-world")
38
+ .from(simple({ userId: 1 }))
39
+ .enrich<FetchResult<{ name: string }>>(
40
+ fetch({
41
+ method: "GET",
42
+ url: (ex) =>
43
+ \`https://jsonplaceholder.typicode.com/users/\${ex.body.userId}\`,
44
+ }),
45
+ )
46
+ .transform((result) => \`Hello, \${result.body.name}!\`)
47
+ .to(log());`}}};function P(e){return e.startsWith("http://")||e.startsWith("https://")}async function O(e){try{let t=await readdir(e),r=t.includes("package.json"),n=t.some(a=>a.endsWith(".ts")||a.endsWith(".js")||a.endsWith(".mjs")||a.includes("route")),o=!1;for(let a of t){let s=join(e,a);if((await stat(s)).isDirectory()&&(await readdir(s)).some(p=>p.endsWith(".ts")||p.endsWith(".js")||p.endsWith(".mjs"))){o=!0;break}}if(!r&&!n&&!o)throw new Error("Downloaded content doesn't appear to be a valid RouteCraft project. Expected to find package.json or route files (.ts, .js, .mjs).");console.log("\u2705 Downloaded content validated successfully");}catch(t){throw new Error(`Content validation failed: ${t instanceof Error?t.message:t}`)}}async function N(e){let t=join(tmpdir(),`routecraft-example-${Date.now()}`);try{console.log(`\u{1F4E5} Downloading example from ${e}...`);let r=/^https?:\/\/github\.com\/([^/]+)\/([^/]+)(?:\/tree\/([^/]+)\/(.+))?$/,n=e.match(r);if(!n)throw new Error(`Invalid GitHub URL format: ${e}`);let[,o,a,s="main",i=""]=n,l=`https://github.com/${o}/${a}.git`;try{execSync(`git clone --depth 1 ${s?`--branch ${s}`:""} ${l} ${t}`,{stdio:"inherit"});}catch{throw new Error(`Failed to clone repository. Make sure the repository is public and accessible: ${l}`)}let p=i?join(t,i):t;if(!existsSync(p))throw new Error(`Path ${i} not found in repository`);return await O(p),p}catch(r){try{await rm(t,{recursive:!0,force:!0});}catch{}throw new Error(`Failed to download example from ${e}: ${r}`)}}async function D(){let e=process.argv.slice(2);(e.includes("--help")||e.includes("-h"))&&(j(),process.exit(0));let t=e[0];t||(console.error("\u274C Project name is required"),console.log("Usage: npm create routecraft@latest <project-name> [options]"),console.log("Or: npx create-routecraft <project-name> [options]"),console.log("Run with --help for more information"),process.exit(1));let r=e.slice(1),n={};for(let o=0;o<r.length;o++){let a=r[o];a==="--example"||a==="-e"?(n.example=r[o+1],o++):a==="--use-npm"?n.packageManager="npm":a==="--use-pnpm"?n.packageManager="pnpm":a==="--use-yarn"?n.packageManager="yarn":a==="--use-bun"?n.packageManager="bun":a==="--no-src-dir"?n.useSrcDir=false:a==="--skip-install"?n.skipInstall=true:a==="--no-git"?n.git=false:a==="--yes"||a==="-y"?n.yes=true:a==="--force"||a==="-f"?n.force=true:(a==="--help"||a==="-h")&&(j(),process.exit(0));}try{await J(t,n);}catch(o){console.error("\u274C Failed to create RouteCraft project:",o),process.exit(1);}}async function J(e,t={}){try{let r=await W(e,t),n=resolve(process.cwd(),r.projectName);await L(n,r.force),await G(n,r),r.git&&await H(n),r.skipInstall||await T(n,r.packageManager),console.log(`
48
+ \u{1F389} Successfully created RouteCraft project: ${r.projectName}
49
+
50
+ Next steps:
51
+ cd ${r.projectName}
52
+ ${r.skipInstall?`${f(r.packageManager)} install
53
+ `:""}${f(r.packageManager)} run build
54
+ ${f(r.packageManager)} run start
55
+
56
+ For more information, visit: https://routecraft.dev
57
+ `);}catch(r){console.error(`Failed to initialize project: ${r}`),process.exit(1);}}async function W(e,t={}){let r=t.yes===true;return {projectName:e||(r?"my-routecraft-app":await input({message:"What is your project named?",default:"my-routecraft-app",validate:o=>o.length>0||"Project name cannot be empty"})),example:t.example||(r?"none":await select({message:"Choose an example:",choices:[{name:"None - empty project",value:"none"},{name:"Hello World - basic example",value:"hello-world"},{name:"Custom URL (GitHub)",value:"custom-url"}],default:"none"}).then(async o=>o==="custom-url"?await input({message:"Enter GitHub URL:",validate:a=>P(a)?true:"Must be a valid GitHub URL"}):o)),packageManager:t.packageManager||(r?"npm":await select({message:"Package manager:",choices:[{name:"npm",value:"npm"},{name:"pnpm",value:"pnpm"},{name:"yarn",value:"yarn"},{name:"bun",value:"bun"}],default:"npm"})),useSrcDir:t.useSrcDir??(r?false:await confirm({message:"Use src directory:",default:false})),git:t.git??(r?true:await confirm({message:"Initialize git:",default:true})),skipInstall:t.skipInstall??(r?false:!await confirm({message:"Install dependencies now:",default:true})),force:t.force??false,yes:r}}async function L(e,t=false){if(existsSync(e))if(t)console.log(`\u26A0\uFE0F Overwriting existing directory: ${e}`);else throw new Error(`Directory "${e}" already exists. Use --force to overwrite.`);await mkdir(e,{recursive:true}),console.log(`Created project directory: ${e}`);}async function G(e,t){let r=t.useSrcDir?join(e,"src"):e;await mkdir(join(r,"routes"),{recursive:true}),await mkdir(join(r,"adapters"),{recursive:true}),await mkdir(join(r,"plugins"),{recursive:true});let n=U,o=t.example!=="none";for(let[a,s]of Object.entries(n)){let i=join(e,a);await mkdir(dirname(i),{recursive:true});let l;typeof s.content=="function"?a==="index.ts"?l=s.content(o):l=s.content(t.projectName):l=s.content,await writeFile(i,l),console.log(`Created file: ${a}`);}if(t.example!=="none")if(P(t.example)){let a=await N(t.example);try{await cp(a,r,{recursive:!0,force:!0,filter:s=>{let i=s.replace(a,"").replace(/^\//,"");return !i.includes("node_modules")&&!i.includes(".git")&&!i.includes("package-lock.json")&&!i.includes("yarn.lock")&&!i.includes("pnpm-lock.yaml")}}),console.log(`\u2705 Added example from ${t.example}`);}finally{try{await rm(a,{recursive:!0,force:!0});}catch{}}}else {let s=F[t.example];if(!s)throw new Error(`Unknown example: ${t.example}`);for(let[i,l]of Object.entries(s)){let p=join(r,i);await mkdir(dirname(p),{recursive:true}),await writeFile(p,l.content),console.log(`Created example file: ${i}`);}}if(t.useSrcDir){let a=join(e,"package.json"),s=JSON.parse(await readFile(a,"utf-8"));s.scripts={...s.scripts,build:"tsc",start:"craft run dist/src/index.js"},await writeFile(a,JSON.stringify(s,null,2));}console.log("Generated project structure");}async function H(e){try{execSync("git init",{cwd:e,stdio:"inherit"}),execSync("git add .",{cwd:e,stdio:"inherit"}),execSync('git commit -m "Initial commit"',{cwd:e,stdio:"inherit"}),console.log("Initialized git repository");}catch{console.warn("Failed to initialize git repository");}}async function T(e,t){let r=f(t);try{execSync(`${r} install`,{cwd:e,stdio:"inherit"}),console.log("Installed dependencies");}catch{console.warn(`Failed to install dependencies. Run "${r} install" manually.`);}}function f(e){switch(e){case "npm":return "npm";case "pnpm":return "pnpm";case "yarn":return "yarn";case "bun":return "bun";default:return "npm"}}function j(){console.log(`
58
+ Create a new RouteCraft project
59
+
60
+ Usage:
61
+ npm create routecraft@latest <project-name> [options]
62
+ npx create-routecraft <project-name> [options]
63
+
64
+ Options:
65
+ -e, --example <name|url> Example to include (none, hello-world) or GitHub URL
66
+ --use-npm Use npm as package manager
67
+ --use-pnpm Use pnpm as package manager
68
+ --use-yarn Use yarn as package manager
69
+ --use-bun Use bun as package manager
70
+ --no-src-dir Place project files at root instead of src/
71
+ --skip-install Skip installing dependencies
72
+ --no-git Skip git initialization
73
+ -y, --yes Skip interactive prompts and use defaults
74
+ -f, --force Overwrite existing directory
75
+ -h, --help Show this help message
76
+
77
+ Examples:
78
+ npm create routecraft@latest my-app
79
+ npm create routecraft@latest my-app --example hello-world --use-pnpm
80
+ npm create routecraft@latest my-app --yes --example hello-world
81
+ npx create-routecraft my-app --force
82
+ npm create routecraft@latest my-app --example https://github.com/user/repo
83
+ npm create routecraft@latest my-app --example https://github.com/user/repo/tree/main/examples/api
84
+ `);}D().catch(e=>{console.error("Unexpected error:",e),process.exit(1);});//# sourceMappingURL=index.js.map
85
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.ts"],"names":["getRoutecraftVersion","packagePath","join","dirname","fileURLToPath","existsSync","readFileSync","NODE_TEMPLATE","projectName","hasExample","EXAMPLES","isUrl","example","validateExampleContent","sourceDir","files","readdir","hasPackageJson","hasRouteFiles","file","hasRouteSubdirs","filePath","stat","f","error","downloadGitHubExample","url","tempDir","tmpdir","urlPattern","match","owner","repo","branch","subPath","repoUrl","execSync","rm","main","args","showHelp","remainingArgs","options","i","arg","initCommand","answers","getUserInput","projectDir","resolve","createProjectDirectory","generateProjectStructure","initializeGit","installDependencies","getPackageManagerCommand","skipPrompts","input","value","select","choice","confirm","force","mkdir","baseDir","template","fileConfig","fullPath","content","writeFile","tempExampleDir","cp","src","relativePath","packageJsonPath","packageJson","readFile","packageManager","command"],"mappings":";ySAwCA,SAASA,CAAAA,EAA+B,CACtC,GAAI,CAEF,IAAMC,EAAcC,IAAAA,CAClBC,OAAAA,CAAQC,cAAc,MAAA,CAAA,IAAA,CAAY,GAAG,CAAC,CAAA,CACtC,+BACF,EACA,GAAIC,UAAAA,CAAWJ,CAAW,CAAA,CAExB,OAAO,CAAA,CAAA,EADK,KAAK,KAAA,CAAMK,YAAAA,CAAaL,EAAa,OAAO,CAAC,EAC1C,OAAO,CAAA,CAE1B,MAAQ,CAER,CAGA,OAAO,QACT,CAYA,IAAMM,CAAAA,CAAgB,CACpB,eAAgB,CACd,OAAA,CAAUC,CAAAA,EACR,IAAA,CAAK,SAAA,CACH,CACE,KAAMA,CAAAA,CACN,OAAA,CAAS,QACT,OAAA,CAAS,IAAA,CACT,KAAM,QAAA,CACN,OAAA,CAAS,CACP,KAAA,CAAO,KAAA,CACP,MAAO,yBAAA,CACP,IAAA,CAAM,UACR,CAAA,CACA,YAAA,CAAc,CACZ,wBAAA,CAA0BR,CAAAA,EAC5B,CAAA,CACA,eAAA,CAAiB,CACf,cAAe,SAAA,CACf,UAAA,CAAY,SACZ,MAAA,CAAQ,SAAA,CAC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KAAA,CAAOd,GAAU,CACtB,OAAA,CAAQ,KAAA,CAAM,mBAAA,CAAqBA,CAAK,CAAA,CACxC,OAAA,CAAQ,IAAA,CAAK,CAAC,EAChB,CAAC,CAAA","file":"index.js","sourcesContent":["#!/usr/bin/env node\n\n/* eslint-disable no-console */\n\nimport { mkdir, writeFile, readFile, readdir, stat } from \"node:fs/promises\";\nimport { join, resolve, dirname } from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\nimport { existsSync, readFileSync } from \"node:fs\";\nimport { execSync } from \"node:child_process\";\nimport { input, select, confirm } from \"@inquirer/prompts\";\nimport { tmpdir } from \"node:os\";\nimport { cp, rm } from \"node:fs/promises\";\n\n/**\n * Package manager types\n */\ntype PackageManager = \"npm\" | \"pnpm\" | \"yarn\" | \"bun\";\n\n/**\n * Example types\n */\ntype ExampleType = string;\n\n/**\n * Project initialization options\n */\ninterface InitOptions {\n projectName?: string;\n example?: ExampleType;\n packageManager?: PackageManager;\n useSrcDir?: boolean;\n skipInstall?: boolean;\n git?: boolean;\n force?: boolean;\n yes?: boolean;\n}\n\n/**\n * Get the current version of @routecraft/routecraft from package.json\n */\nfunction getRoutecraftVersion(): string {\n try {\n // Try to read the package.json of the routecraft package\n const packagePath = join(\n dirname(fileURLToPath(import.meta.url)),\n \"../../routecraft/package.json\",\n );\n if (existsSync(packagePath)) {\n const pkg = JSON.parse(readFileSync(packagePath, \"utf-8\"));\n return `^${pkg.version}`;\n }\n } catch {\n // Fallback if we can't read the package.json\n }\n\n // Default fallback - use \"latest\" to always get the newest version\n return \"latest\";\n}\n\n/**\n * Template file configuration\n */\ninterface TemplateFileConfig {\n content: string | ((arg: string) => string) | ((arg: boolean) => string);\n}\n\n/**\n * Default project structure template for Node.js package managers\n */\nconst NODE_TEMPLATE = {\n \"package.json\": {\n content: (projectName: string) =>\n JSON.stringify(\n {\n name: projectName,\n version: \"0.1.1\",\n private: true,\n type: \"module\",\n scripts: {\n build: \"tsc\",\n start: \"craft run dist/index.js\",\n lint: \"eslint .\",\n },\n dependencies: {\n \"@routecraft/routecraft\": getRoutecraftVersion(),\n },\n devDependencies: {\n \"@types/node\": \"^20.0.0\",\n typescript: \"^5.0.0\",\n eslint: \"^9.36.0\",\n \"@eslint/js\": \"^9.36.0\",\n \"typescript-eslint\": \"^8.44.1\",\n \"@routecraft/eslint-plugin-routecraft\": getRoutecraftVersion(),\n \"@routecraft/cli\": getRoutecraftVersion(),\n \"pino-pretty\": \"^13.1.2\",\n },\n },\n null,\n 2,\n ),\n },\n \"tsconfig.json\": {\n content: JSON.stringify(\n {\n compilerOptions: {\n target: \"ES2022\",\n module: \"ESNext\",\n moduleResolution: \"bundler\",\n outDir: \"./dist\",\n rootDir: \".\",\n allowSyntheticDefaultImports: true,\n esModuleInterop: true,\n allowJs: true,\n strict: true,\n skipLibCheck: true,\n isolatedModules: true,\n resolveJsonModule: true,\n },\n include: [\"**/*.ts\", \"**/*.js\"],\n exclude: [\"node_modules\", \"dist\"],\n },\n null,\n 2,\n ),\n },\n \"eslint.config.mjs\": {\n content: `import pluginJs from \"@eslint/js\";\nimport tseslint from \"typescript-eslint\";\nimport routecraftPlugin from \"@routecraft/eslint-plugin-routecraft\";\n\n/** @type {import('eslint').Linter.Config[]} */\nexport default [\n pluginJs.configs.recommended,\n ...tseslint.configs.recommended,\n {\n files: [\"routes/**/*.{ts,js}\", \"**/*.route.{ts,js}\", \"**/*.{ts,js}\"],\n plugins: { \"@routecraft/routecraft\": routecraftPlugin },\n ...routecraftPlugin.configs.recommended,\n },\n];\n`,\n },\n \"craft.config.ts\": {\n content: `import type { CraftConfig } from \"@routecraft/routecraft\";\n\nconst config: CraftConfig = {\n};\n\nexport default config;`,\n },\n \".gitignore\": {\n content: `node_modules/\ndist/\n.env\n.env.local\n.env.*.local\n*.log\n.DS_Store`,\n },\n \"index.ts\": {\n content: (hasExample: boolean) =>\n hasExample\n ? `export { default as craftConfig } from './craft.config.js';\nimport helloWorldRoute from './routes/hello-world.route.js';\n\n// Export all routes as default for craft run\nexport default [helloWorldRoute];`\n : `export { default as craftConfig } from './craft.config.js';\n\n// Export all routes as default for craft run\nexport default [];`,\n },\n};\n\n/**\n * Example route templates for Node.js\n */\nconst EXAMPLES = {\n \"hello-world\": {\n \"routes/hello-world.route.ts\": {\n content: `import { log, craft, simple, fetch, type FetchResult } from \"@routecraft/routecraft\";\n\nexport default craft()\n .id(\"hello-world\")\n .from(simple({ userId: 1 }))\n .enrich<FetchResult<{ name: string }>>(\n fetch({\n method: \"GET\",\n url: (ex) =>\n \\`https://jsonplaceholder.typicode.com/users/\\${ex.body.userId}\\`,\n }),\n )\n .transform((result) => \\`Hello, \\${result.body.name}!\\`)\n .to(log());`,\n },\n },\n};\n\n/**\n * Check if an example string is a URL\n */\nfunction isUrl(example: string): boolean {\n return example.startsWith(\"http://\") || example.startsWith(\"https://\");\n}\n\n/**\n * Validate that the downloaded content contains expected RouteCraft project files\n * @param sourceDir Path to the source directory to validate\n */\nasync function validateExampleContent(sourceDir: string): Promise<void> {\n try {\n const files = await readdir(sourceDir);\n\n // Check for basic project structure indicators\n const hasPackageJson = files.includes(\"package.json\");\n const hasRouteFiles = files.some(\n (file) =>\n file.endsWith(\".ts\") ||\n file.endsWith(\".js\") ||\n file.endsWith(\".mjs\") ||\n file.includes(\"route\"),\n );\n\n // Check if there are subdirectories that might contain routes\n let hasRouteSubdirs = false;\n for (const file of files) {\n const filePath = join(sourceDir, file);\n const fileStat = await stat(filePath);\n if (fileStat.isDirectory()) {\n const subFiles = await readdir(filePath);\n if (\n subFiles.some(\n (f) => f.endsWith(\".ts\") || f.endsWith(\".js\") || f.endsWith(\".mjs\"),\n )\n ) {\n hasRouteSubdirs = true;\n break;\n }\n }\n }\n\n if (!hasPackageJson && !hasRouteFiles && !hasRouteSubdirs) {\n throw new Error(\n \"Downloaded content doesn't appear to be a valid RouteCraft project. \" +\n \"Expected to find package.json or route files (.ts, .js, .mjs).\",\n );\n }\n\n console.log(\"āœ… Downloaded content validated successfully\");\n } catch (error) {\n throw new Error(\n `Content validation failed: ${error instanceof Error ? error.message : error}`,\n );\n }\n}\n\n/**\n * Download and extract a GitHub example\n */\nasync function downloadGitHubExample(url: string): Promise<string> {\n const tempDir = join(tmpdir(), `routecraft-example-${Date.now()}`);\n\n try {\n console.log(`šŸ“„ Downloading example from ${url}...`);\n\n // For GitHub URLs, we'll use git clone for simplicity\n // Extract repo info from URL\n const urlPattern =\n /^https?:\\/\\/github\\.com\\/([^/]+)\\/([^/]+)(?:\\/tree\\/([^/]+)\\/(.+))?$/;\n const match = url.match(urlPattern);\n\n if (!match) {\n throw new Error(`Invalid GitHub URL format: ${url}`);\n }\n\n const [, owner, repo, branch = \"main\", subPath = \"\"] = match;\n const repoUrl = `https://github.com/${owner}/${repo}.git`;\n\n // Clone the repo (try with credentials if available, fallback to public access)\n try {\n execSync(\n `git clone --depth 1 ${branch ? `--branch ${branch}` : \"\"} ${repoUrl} ${tempDir}`,\n {\n stdio: \"inherit\",\n },\n );\n } catch {\n // If git clone fails, try a different approach or provide better error\n throw new Error(\n `Failed to clone repository. Make sure the repository is public and accessible: ${repoUrl}`,\n );\n }\n\n // If there's a subPath, use that subdirectory\n const sourceDir = subPath ? join(tempDir, subPath) : tempDir;\n\n if (!existsSync(sourceDir)) {\n throw new Error(`Path ${subPath} not found in repository`);\n }\n\n // Validate downloaded content structure\n await validateExampleContent(sourceDir);\n\n return sourceDir;\n } catch (error) {\n // Cleanup on error\n try {\n await rm(tempDir, { recursive: true, force: true });\n } catch {\n // Ignore cleanup errors\n }\n throw new Error(`Failed to download example from ${url}: ${error}`);\n }\n}\n\n/**\n * Main entry point for create-routecraft\n * This is called by npm create routecraft <project-name>\n */\nasync function main() {\n const args = process.argv.slice(2);\n\n // Check for help flag first\n if (args.includes(\"--help\") || args.includes(\"-h\")) {\n showHelp();\n process.exit(0);\n }\n\n // npm create passes the project name as the first argument\n const projectName = args[0];\n\n if (!projectName) {\n console.error(\"āŒ Project name is required\");\n console.log(\"Usage: npm create routecraft@latest <project-name> [options]\");\n console.log(\"Or: npx create-routecraft <project-name> [options]\");\n console.log(\"Run with --help for more information\");\n process.exit(1);\n }\n\n // Parse additional arguments\n const remainingArgs = args.slice(1);\n const options: Record<string, unknown> = {};\n\n // Simple argument parsing for common options\n for (let i = 0; i < remainingArgs.length; i++) {\n const arg = remainingArgs[i];\n\n if (arg === \"--example\" || arg === \"-e\") {\n options[\"example\"] = remainingArgs[i + 1];\n i++; // Skip next arg\n } else if (arg === \"--use-npm\") {\n options[\"packageManager\"] = \"npm\";\n } else if (arg === \"--use-pnpm\") {\n options[\"packageManager\"] = \"pnpm\";\n } else if (arg === \"--use-yarn\") {\n options[\"packageManager\"] = \"yarn\";\n } else if (arg === \"--use-bun\") {\n options[\"packageManager\"] = \"bun\";\n } else if (arg === \"--no-src-dir\") {\n options[\"useSrcDir\"] = false;\n } else if (arg === \"--skip-install\") {\n options[\"skipInstall\"] = true;\n } else if (arg === \"--no-git\") {\n options[\"git\"] = false;\n } else if (arg === \"--yes\" || arg === \"-y\") {\n options[\"yes\"] = true;\n } else if (arg === \"--force\" || arg === \"-f\") {\n options[\"force\"] = true;\n } else if (arg === \"--help\" || arg === \"-h\") {\n showHelp();\n process.exit(0);\n }\n }\n\n try {\n await initCommand(projectName, options);\n } catch (error) {\n console.error(\"āŒ Failed to create RouteCraft project:\", error);\n process.exit(1);\n }\n}\n\n/**\n * Initialize a new RouteCraft project\n */\nasync function initCommand(\n projectName?: string,\n options: Record<string, unknown> = {},\n) {\n try {\n // Interactive prompts if values not provided\n const answers = await getUserInput(projectName, options);\n\n // Create project directory\n const projectDir = resolve(process.cwd(), answers.projectName);\n await createProjectDirectory(projectDir, answers.force);\n\n // Generate project structure\n await generateProjectStructure(projectDir, answers);\n\n // Initialize git if requested\n if (answers.git) {\n await initializeGit(projectDir);\n }\n\n // Install dependencies if requested\n if (!answers.skipInstall) {\n await installDependencies(projectDir, answers.packageManager);\n }\n\n // Success message\n console.log(`\nšŸŽ‰ Successfully created RouteCraft project: ${answers.projectName}\n\nNext steps:\n cd ${answers.projectName}\n ${answers.skipInstall ? `${getPackageManagerCommand(answers.packageManager)} install\\n ` : \"\"}${getPackageManagerCommand(answers.packageManager)} run build\n ${getPackageManagerCommand(answers.packageManager)} run start\n\nFor more information, visit: https://routecraft.dev\n `);\n } catch (error) {\n console.error(`Failed to initialize project: ${error}`);\n process.exit(1);\n }\n}\n\n/**\n * Get user input through prompts or use provided options\n */\nasync function getUserInput(\n projectName?: string,\n options: Record<string, unknown> = {},\n): Promise<Required<InitOptions>> {\n const skipPrompts = options[\"yes\"] === true;\n\n const answers: Required<InitOptions> = {\n projectName:\n projectName ||\n (skipPrompts\n ? \"my-routecraft-app\"\n : await input({\n message: \"What is your project named?\",\n default: \"my-routecraft-app\",\n validate: (value: string) =>\n value.length > 0 || \"Project name cannot be empty\",\n })),\n\n example:\n (options[\"example\"] as ExampleType) ||\n (skipPrompts\n ? \"none\"\n : await select<string>({\n message: \"Choose an example:\",\n choices: [\n { name: \"None - empty project\", value: \"none\" },\n { name: \"Hello World - basic example\", value: \"hello-world\" },\n { name: \"Custom URL (GitHub)\", value: \"custom-url\" },\n ],\n default: \"none\",\n }).then(async (choice) => {\n if (choice === \"custom-url\") {\n return await input({\n message: \"Enter GitHub URL:\",\n validate: (value: string) => {\n if (isUrl(value)) return true;\n return \"Must be a valid GitHub URL\";\n },\n });\n }\n return choice;\n })),\n\n packageManager:\n (options[\"packageManager\"] as PackageManager) ||\n (skipPrompts\n ? \"npm\"\n : await select<PackageManager>({\n message: \"Package manager:\",\n choices: [\n { name: \"npm\", value: \"npm\" },\n { name: \"pnpm\", value: \"pnpm\" },\n { name: \"yarn\", value: \"yarn\" },\n { name: \"bun\", value: \"bun\" },\n ],\n default: \"npm\",\n })),\n\n useSrcDir:\n (options[\"useSrcDir\"] as boolean) ??\n (skipPrompts\n ? false\n : await confirm({\n message: \"Use src directory:\",\n default: false,\n })),\n\n git:\n (options[\"git\"] as boolean) ??\n (skipPrompts\n ? true\n : await confirm({\n message: \"Initialize git:\",\n default: true,\n })),\n\n skipInstall:\n (options[\"skipInstall\"] as boolean) ??\n (skipPrompts\n ? false\n : !(await confirm({\n message: \"Install dependencies now:\",\n default: true,\n }))),\n\n force: (options[\"force\"] as boolean) ?? false,\n\n yes: skipPrompts,\n };\n\n return answers;\n}\n\n/**\n * Create project directory\n */\nasync function createProjectDirectory(\n projectDir: string,\n force: boolean = false,\n) {\n if (existsSync(projectDir)) {\n if (!force) {\n throw new Error(\n `Directory \"${projectDir}\" already exists. Use --force to overwrite.`,\n );\n } else {\n console.log(`āš ļø Overwriting existing directory: ${projectDir}`);\n }\n }\n\n await mkdir(projectDir, { recursive: true });\n console.log(`Created project directory: ${projectDir}`);\n}\n\n/**\n * Generate project structure from template\n */\nasync function generateProjectStructure(\n projectDir: string,\n options: Required<InitOptions>,\n) {\n const baseDir = options.useSrcDir ? join(projectDir, \"src\") : projectDir;\n\n // Create base directories\n await mkdir(join(baseDir, \"routes\"), { recursive: true });\n await mkdir(join(baseDir, \"adapters\"), { recursive: true });\n await mkdir(join(baseDir, \"plugins\"), { recursive: true });\n\n // Generate template files\n const template = NODE_TEMPLATE as Record<string, TemplateFileConfig>;\n const hasExample = options.example !== \"none\";\n\n for (const [filePath, fileConfig] of Object.entries(template)) {\n const fullPath = join(projectDir, filePath);\n await mkdir(dirname(fullPath), { recursive: true });\n\n let content: string;\n if (typeof fileConfig.content === \"function\") {\n // Special handling for index.ts which needs hasExample parameter\n if (filePath === \"index.ts\") {\n content = (fileConfig.content as (arg: boolean) => string)(hasExample);\n } else {\n // Other files like package.json need projectName\n content = (fileConfig.content as (arg: string) => string)(\n options.projectName,\n );\n }\n } else {\n content = fileConfig.content;\n }\n\n await writeFile(fullPath, content);\n console.log(`Created file: ${filePath}`);\n }\n\n // Add example routes if requested\n if (options.example !== \"none\") {\n if (isUrl(options.example)) {\n // Handle GitHub URL examples\n const tempExampleDir = await downloadGitHubExample(options.example);\n try {\n // Copy all files from the downloaded example to the routes directory\n await cp(tempExampleDir, baseDir, {\n recursive: true,\n force: true,\n filter: (src) => {\n // Skip node_modules, .git, and other unwanted directories\n const relativePath = src\n .replace(tempExampleDir, \"\")\n .replace(/^\\//, \"\");\n return (\n !relativePath.includes(\"node_modules\") &&\n !relativePath.includes(\".git\") &&\n !relativePath.includes(\"package-lock.json\") &&\n !relativePath.includes(\"yarn.lock\") &&\n !relativePath.includes(\"pnpm-lock.yaml\")\n );\n },\n });\n console.log(`āœ… Added example from ${options.example}`);\n } finally {\n // Cleanup temp directory\n try {\n await rm(tempExampleDir, { recursive: true, force: true });\n } catch {\n // Ignore cleanup errors\n }\n }\n } else {\n // Handle built-in examples\n const examples = EXAMPLES;\n const example = examples[options.example as keyof typeof examples];\n if (!example) {\n throw new Error(`Unknown example: ${options.example}`);\n }\n for (const [filePath, fileConfig] of Object.entries(example)) {\n const fullPath = join(baseDir, filePath);\n await mkdir(dirname(fullPath), { recursive: true });\n await writeFile(fullPath, fileConfig.content);\n console.log(`Created example file: ${filePath}`);\n }\n }\n }\n\n // Update package.json scripts if using src directory\n if (options.useSrcDir) {\n const packageJsonPath = join(projectDir, \"package.json\");\n const packageJson = JSON.parse(await readFile(packageJsonPath, \"utf-8\"));\n packageJson.scripts = {\n ...packageJson.scripts,\n build: \"tsc\",\n start: \"craft run dist/src/index.js\",\n };\n await writeFile(packageJsonPath, JSON.stringify(packageJson, null, 2));\n }\n\n console.log(\"Generated project structure\");\n}\n\n/**\n * Initialize git repository\n */\nasync function initializeGit(projectDir: string) {\n try {\n execSync(\"git init\", { cwd: projectDir, stdio: \"inherit\" });\n execSync(\"git add .\", { cwd: projectDir, stdio: \"inherit\" });\n execSync('git commit -m \"Initial commit\"', {\n cwd: projectDir,\n stdio: \"inherit\",\n });\n console.log(\"Initialized git repository\");\n } catch {\n console.warn(\"Failed to initialize git repository\");\n }\n}\n\n/**\n * Install project dependencies\n */\nasync function installDependencies(\n projectDir: string,\n packageManager: PackageManager,\n) {\n const command = getPackageManagerCommand(packageManager);\n try {\n execSync(`${command} install`, { cwd: projectDir, stdio: \"inherit\" });\n console.log(\"Installed dependencies\");\n } catch {\n console.warn(\n `Failed to install dependencies. Run \"${command} install\" manually.`,\n );\n }\n}\n\n/**\n * Get package manager command\n */\nfunction getPackageManagerCommand(packageManager: PackageManager): string {\n switch (packageManager) {\n case \"npm\":\n return \"npm\";\n case \"pnpm\":\n return \"pnpm\";\n case \"yarn\":\n return \"yarn\";\n case \"bun\":\n return \"bun\";\n default:\n return \"npm\";\n }\n}\n\nfunction showHelp() {\n console.log(`\nCreate a new RouteCraft project\n\nUsage:\n npm create routecraft@latest <project-name> [options]\n npx create-routecraft <project-name> [options]\n\nOptions:\n -e, --example <name|url> Example to include (none, hello-world) or GitHub URL\n --use-npm Use npm as package manager\n --use-pnpm Use pnpm as package manager\n --use-yarn Use yarn as package manager\n --use-bun Use bun as package manager\n --no-src-dir Place project files at root instead of src/\n --skip-install Skip installing dependencies\n --no-git Skip git initialization\n -y, --yes Skip interactive prompts and use defaults\n -f, --force Overwrite existing directory\n -h, --help Show this help message\n\nExamples:\n npm create routecraft@latest my-app\n npm create routecraft@latest my-app --example hello-world --use-pnpm\n npm create routecraft@latest my-app --yes --example hello-world\n npx create-routecraft my-app --force\n npm create routecraft@latest my-app --example https://github.com/user/repo\n npm create routecraft@latest my-app --example https://github.com/user/repo/tree/main/examples/api\n`);\n}\n\n// Run the CLI\nmain().catch((error) => {\n console.error(\"Unexpected error:\", error);\n process.exit(1);\n});\n"]}
package/package.json ADDED
@@ -0,0 +1,34 @@
1
+ {
2
+ "name": "create-routecraft",
3
+ "version": "0.1.1",
4
+ "description": "Create a new RouteCraft project",
5
+ "type": "module",
6
+ "main": "./dist/index.js",
7
+ "bin": {
8
+ "create-routecraft": "./dist/index.js"
9
+ },
10
+ "files": [
11
+ "dist"
12
+ ],
13
+ "dependencies": {
14
+ "@inquirer/prompts": "^7.9.0"
15
+ },
16
+ "publishConfig": {
17
+ "access": "public"
18
+ },
19
+ "repository": "https://github.com/routecraftjs/routecraft",
20
+ "keywords": [
21
+ "routecraft",
22
+ "create-routecraft",
23
+ "cli",
24
+ "template",
25
+ "boilerplate"
26
+ ],
27
+ "author": "routecraftjs",
28
+ "license": "Apache-2.0",
29
+ "scripts": {
30
+ "build": "tsup src/index.ts --format esm --dts",
31
+ "test": "vitest",
32
+ "test:coverage": "vitest --coverage"
33
+ }
34
+ }