rapidkit 0.16.0 → 0.16.3
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/dist/index.js +70 -63
- package/dist/package.json +2 -1
- package/package.json +2 -1
package/dist/index.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import
|
|
3
|
-
[${t}/${i}]`),l.white(r));}},y=new
|
|
4
|
-
\u26A0\uFE0F Update available: ${
|
|
5
|
-
`))):y.debug("You are using the latest version");}catch{y.debug("Could not check for updates");}}function
|
|
2
|
+
import h from'path';import {fileURLToPath}from'url';import l from'chalk';import {execa}from'execa';import {createRequire}from'module';import*as P from'fs-extra';import ie,{promises}from'fs';import le from'ora';import*as L from'os';import L__default from'os';import {Command,Option}from'commander';import Se from'inquirer';import {spawn}from'child_process';import $t from'validate-npm-package-name';import Qt from'nunjucks';var ut=Object.defineProperty;var oe=(e,t)=>()=>(e&&(t=e(e=0)),t);var Ke=(e,t)=>{for(var i in t)ut(e,i,{get:t[i],enumerable:true});};var w=oe(()=>{});var je,y,ne=oe(()=>{w();je=class{debugEnabled=false;setDebug(t){this.debugEnabled=t;}debug(t,...i){this.debugEnabled&&console.log(l.gray(`[DEBUG] ${t}`),...i);}info(t,...i){console.log(l.blue(t),...i);}success(t,...i){console.log(l.green(t),...i);}warn(t,...i){console.log(l.yellow(t),...i);}error(t,...i){console.error(l.red(t),...i);}step(t,i,r){console.log(l.cyan(`
|
|
3
|
+
[${t}/${i}]`),l.white(r));}},y=new je;});async function We(){try{y.debug("Checking for updates...");let{stdout:e}=await execa("npm",["view",ht,"version"],{timeout:3e3}),t=e.trim();t&&t!==$e?(console.log(l.yellow(`
|
|
4
|
+
\u26A0\uFE0F Update available: ${$e} \u2192 ${t}`)),console.log(l.cyan(`Run: npm install -g rapidkit@latest
|
|
5
|
+
`))):y.debug("You are using the latest version");}catch{y.debug("Could not check for updates");}}function F(){return $e}var ht,yt,wt,$e,ae=oe(()=>{w();ne();ht="rapidkit",yt=createRequire(import.meta.url),wt=yt("../package.json"),$e=wt?.version??"0.0.0";});var Xe={};Ke(Xe,{createNpmWorkspaceMarker:()=>Ee,isValidWorkspaceMarker:()=>Ft,readWorkspaceMarker:()=>Ce,updateWorkspaceMetadata:()=>Ot,writeWorkspaceMarker:()=>fe});async function Ce(e){let t=h.join(e,".rapidkit-workspace");try{if(await P.pathExists(t))return await P.readJson(t)}catch{return null}return null}async function fe(e,t){let i=h.join(e,".rapidkit-workspace"),r=await Ce(e);r?.metadata&&(t.metadata={...r.metadata,...t.metadata}),await P.outputFile(i,JSON.stringify(t,null,2)+`
|
|
6
|
+
`,"utf-8");}async function Ot(e,t){let i=await Ce(e);return i?(i.metadata={...i.metadata,...t,vscode:t.vscode?{...i.metadata?.vscode,...t.vscode}:i.metadata?.vscode,npm:t.npm?{...i.metadata?.npm,...t.npm}:i.metadata?.npm,python:t.python?{...i.metadata?.python,...t.python}:i.metadata?.python},await fe(e,i),true):false}function Ee(e,t,i){return {signature:"RAPIDKIT_WORKSPACE",createdBy:"rapidkit-npm",version:t,createdAt:new Date().toISOString(),name:e,metadata:{npm:{packageVersion:t,installMethod:i,lastUsedAt:new Date().toISOString()}}}}function Ft(e){if(!e||typeof e!="object")return false;let t=e;return t.signature==="RAPIDKIT_WORKSPACE"&&typeof t.createdBy=="string"&&typeof t.version=="string"&&typeof t.createdAt=="string"&&typeof t.name=="string"}var Ie=oe(()=>{w();});var V={};Ke(V,{createProject:()=>Ut,createWorkspace:()=>Wt,listWorkspaces:()=>Ht,registerProjectInWorkspace:()=>Mt,registerWorkspace:()=>Qe,syncWorkspaceProjects:()=>Kt});async function Qe(e,t){try{let i=process.env.XDG_CONFIG_HOME||process.env.APPDATA||h.join(L__default.homedir(),".config"),r=process.platform==="win32"?h.join(i,"rapidkit"):h.join(L__default.homedir(),".rapidkit"),n=h.join(r,"workspaces.json");await promises.mkdir(r,{recursive:!0});let o={workspaces:[]};try{let a=await promises.readFile(n,"utf8"),c=JSON.parse(a);c&&Array.isArray(c.workspaces)&&(o=c);}catch{}o.workspaces.some(a=>a.path===e)||(o.workspaces.push({name:t,path:e,mode:"full",projects:[]}),await promises.writeFile(n,JSON.stringify(o,null,2)));}catch{console.warn(l.gray("Note: Could not register workspace in shared registry"));}}async function Kt(e,t=false){try{let i=process.env.XDG_CONFIG_HOME||process.env.APPDATA||h.join(L__default.homedir(),".config"),r=process.platform==="win32"?h.join(i,"rapidkit"):h.join(L__default.homedir(),".rapidkit"),n=h.join(r,"workspaces.json"),o={workspaces:[]};try{let d=await promises.readFile(n,"utf8"),m=JSON.parse(d);m&&Array.isArray(m.workspaces)&&(o=m);}catch{t||console.log("\u26A0\uFE0F Workspace registry not found");return}let s=o.workspaces.find(d=>d.path===e);if(!s){t||console.log("\u26A0\uFE0F Workspace not registered in registry");return}Array.isArray(s.projects)||(s.projects=[]);let a=await promises.readdir(e,{withFileTypes:!0}),c=0,p=0;for(let d of a)if(d.isDirectory()&&!d.name.startsWith(".")){let m=h.join(e,d.name),j=h.join(m,".rapidkit","context.json"),R=h.join(m,".rapidkit","project.json");try{let f=!1;try{await promises.access(j),f=!0;}catch{await promises.access(R),f=!0;}f&&(s.projects.some(B=>B.path===m||B.name===d.name)?p++:(s.projects.push({name:d.name,path:m}),c++,t||console.log(`\u2714 Added: ${d.name}`)));}catch{}}c>0?(await promises.writeFile(n,JSON.stringify(o,null,2)),t||console.log(`
|
|
6
7
|
\u2705 Synced ${c} project(s) to registry`)):t||console.log(`
|
|
7
|
-
\u2705 All projects already registered (${p} found)`);}catch(i){t||console.error("\u274C Failed to sync projects:",i.message);}}async function
|
|
8
|
+
\u2705 All projects already registered (${p} found)`);}catch(i){t||console.error("\u274C Failed to sync projects:",i.message);}}async function Mt(e,t,i){try{let r=process.env.XDG_CONFIG_HOME||process.env.APPDATA||h.join(L__default.homedir(),".config"),n=process.platform==="win32"?h.join(r,"rapidkit"):h.join(L__default.homedir(),".rapidkit"),o=h.join(n,"workspaces.json");console.log(`[REGISTRY DEBUG] Registry file: ${o}`);let s={workspaces:[]};try{let p=await promises.readFile(o,"utf8"),d=JSON.parse(p);d&&Array.isArray(d.workspaces)&&(s=d),console.log(`[REGISTRY DEBUG] Registry loaded, ${s.workspaces.length} workspaces`);}catch{console.log("[REGISTRY DEBUG] Registry doesn't exist, returning");return}let a=s.workspaces.find(p=>p.path===e);if(!a){console.log("[REGISTRY DEBUG] Workspace not found in registry, returning");return}console.log(`[REGISTRY DEBUG] Workspace found: ${a.name}`),Array.isArray(a.projects)||(a.projects=[]),a.projects.some(p=>p.path===i||p.name===t)?console.log("[REGISTRY DEBUG] Project already exists in registry"):(console.log("[REGISTRY DEBUG] Adding project to registry"),a.projects.push({name:t,path:i}),await promises.writeFile(o,JSON.stringify(s,null,2)),console.log("[REGISTRY DEBUG] Registry updated successfully"));}catch(r){console.log(`[REGISTRY DEBUG] Error: ${r}`);}}async function Wt(e,t){let i=le("Creating RapidKit workspace...").start();try{await promises.mkdir(e,{recursive:!0}),await promises.mkdir(h.join(e,".rapidkit"),{recursive:!0});let r={workspace_name:t.name,author:t.author,rapidkit_version:F(),created_at:new Date().toISOString(),type:"workspace"};await promises.writeFile(h.join(e,".rapidkit","config.json"),JSON.stringify(r,null,2));let n=Lt();await promises.writeFile(h.join(e,"rapidkit"),n),await promises.chmod(h.join(e,"rapidkit"),493);let o=Vt(t.name);if(await promises.writeFile(h.join(e,"README.md"),o),await promises.writeFile(h.join(e,".gitignore"),`# RapidKit workspace
|
|
8
9
|
.env
|
|
9
10
|
.env.*
|
|
10
11
|
!.env.example
|
|
@@ -19,7 +20,7 @@ Thumbs.db
|
|
|
19
20
|
|
|
20
21
|
# Logs
|
|
21
22
|
*.log
|
|
22
|
-
`),await promises.writeFile(
|
|
23
|
+
`),await promises.writeFile(h.join(e,".rapidkit-workspace"),JSON.stringify({signature:"RAPIDKIT_WORKSPACE",createdBy:"rapidkit-npm",version:F(),createdAt:new Date().toISOString(),name:t.name},null,2)),await Gt(e),i.succeed("Workspace created!"),!t.skipGit){let a=le("Initializing git repository...").start();try{await execa("git",["init"],{cwd:e}),await execa("git",["add","."],{cwd:e}),await execa("git",["commit","-m","Initial commit: RapidKit workspace"],{cwd:e}),a.succeed("Git repository initialized");}catch{a.warn("Could not initialize git repository");}}await Qe(e,t.name),console.log(`
|
|
23
24
|
${l.green("\u2728 RapidKit workspace created successfully!")}
|
|
24
25
|
|
|
25
26
|
${l.bold("\u{1F4C2} Workspace structure:")}
|
|
@@ -49,7 +50,7 @@ ${l.bold("\u{1F4DA} Commands:")}
|
|
|
49
50
|
|
|
50
51
|
${l.gray("Alternative: ./rapidkit dev, make dev")}
|
|
51
52
|
${l.gray("\u{1F4A1} Tip: Install globally (npm i -g rapidkit) to use without npx")}
|
|
52
|
-
`);}catch(r){throw i.fail("Failed to create workspace"),r}}function
|
|
53
|
+
`);}catch(r){throw i.fail("Failed to create workspace"),r}}function Lt(){return `#!/usr/bin/env bash
|
|
53
54
|
#
|
|
54
55
|
# RapidKit CLI - Local workspace commands
|
|
55
56
|
# This script provides rapidkit commands within the workspace
|
|
@@ -385,7 +386,7 @@ main() {
|
|
|
385
386
|
print_help
|
|
386
387
|
;;
|
|
387
388
|
version|-v|--version)
|
|
388
|
-
echo "RapidKit CLI (npm workspace) v${
|
|
389
|
+
echo "RapidKit CLI (npm workspace) v${F()}"
|
|
389
390
|
;;
|
|
390
391
|
*)
|
|
391
392
|
echo -e "\${RED}\u274C Unknown command: $cmd\${NC}"
|
|
@@ -397,7 +398,7 @@ main() {
|
|
|
397
398
|
}
|
|
398
399
|
|
|
399
400
|
main "$@"
|
|
400
|
-
`}function
|
|
401
|
+
`}function Vt(e){return `# ${e}
|
|
401
402
|
|
|
402
403
|
RapidKit workspace for building API projects.
|
|
403
404
|
|
|
@@ -445,7 +446,7 @@ npx rapidkit dev # Start dev server
|
|
|
445
446
|
|
|
446
447
|
- [RapidKit Documentation](https://rapidkit.dev)
|
|
447
448
|
- [GitHub Repository](https://github.com/Baziar/rapidkit)
|
|
448
|
-
`}async function
|
|
449
|
+
`}async function Gt(e){let{fileURLToPath:t}=await import('url'),i=t(import.meta.url),r=h.dirname(i),n=h.resolve(r,".."),o=h.join(n,"templates","kits"),s=h.join(e,".rapidkit","templates"),{default:a}=await import('fs-extra');await a.copy(o,s);let c=h.join(n,"templates","generator.js"),p=h.join(e,".rapidkit","generator.js");await a.copy(c,p);}async function Ut(e,t){let i=t.template==="fastapi",r=i?"FastAPI":"NestJS",n=le(`Creating ${r} project...`).start();try{let{fileURLToPath:o}=await import('url'),s=o(import.meta.url),a=h.dirname(s),c=h.resolve(a,".."),p=i?"fastapi-standard":"nestjs-standard",d=h.join(c,"templates","kits",p);await promises.mkdir(e,{recursive:!0});let m={project_name:i?t.name.replace(/-/g,"_").toLowerCase():t.name.replace(/_/g,"-").toLowerCase(),author:t.author,description:t.description||`${r} application generated with RapidKit`,app_version:"0.1.0",license:"MIT",package_manager:t.package_manager||"npm",created_at:new Date().toISOString(),rapidkit_version:F()};await Ze(d,e,m);let j=i?`# Python
|
|
449
450
|
__pycache__/
|
|
450
451
|
*.py[cod]
|
|
451
452
|
*$py.class
|
|
@@ -513,7 +514,7 @@ Thumbs.db
|
|
|
513
514
|
|
|
514
515
|
# Coverage
|
|
515
516
|
coverage/
|
|
516
|
-
`;if(await promises.writeFile(
|
|
517
|
+
`;if(await promises.writeFile(h.join(e,".gitignore"),j),n.succeed(`${r} project created!`),!t.skipGit){let f=le("Initializing git repository...").start();try{await execa("git",["init"],{cwd:e}),await execa("git",["add","."],{cwd:e}),await execa("git",["commit","-m",`Initial commit: ${r} project via RapidKit`],{cwd:e}),f.succeed("Git repository initialized");}catch{f.warn("Could not initialize git repository");}}if(!t.skipInstall&&!i){let f=t.package_manager||"npm",_=le(`Installing dependencies with ${f}...`).start();try{await execa(f,["install"],{cwd:e}),_.succeed("Dependencies installed");}catch{_.warn(`Could not install dependencies. Run '${f} install' manually.`);}}let R=h.basename(e);console.log(i?`
|
|
517
518
|
${l.green("\u2728 FastAPI project created successfully!")}
|
|
518
519
|
|
|
519
520
|
${l.bold("\u{1F4C2} Project structure:")}
|
|
@@ -529,7 +530,7 @@ ${e}/
|
|
|
529
530
|
\u2514\u2500\u2500 README.md
|
|
530
531
|
|
|
531
532
|
${l.bold("\u{1F680} Get started:")}
|
|
532
|
-
${l.cyan(`cd ${
|
|
533
|
+
${l.cyan(`cd ${R}`)}
|
|
533
534
|
${l.cyan("npx rapidkit init")} ${l.gray("# Install dependencies")}
|
|
534
535
|
${l.cyan("npx rapidkit dev")} ${l.gray("# Start dev server")}
|
|
535
536
|
|
|
@@ -559,7 +560,7 @@ ${e}/
|
|
|
559
560
|
\u2514\u2500\u2500 README.md
|
|
560
561
|
|
|
561
562
|
${l.bold("\u{1F680} Get started:")}
|
|
562
|
-
${l.cyan(`cd ${
|
|
563
|
+
${l.cyan(`cd ${R}`)}
|
|
563
564
|
${t.skipInstall?l.cyan("npx rapidkit init")+l.gray(" # npm install")+`
|
|
564
565
|
`:""}${l.cyan("cp .env.example .env")}
|
|
565
566
|
${l.cyan("npx rapidkit dev")} ${l.gray("# Start dev server")}
|
|
@@ -579,7 +580,7 @@ ${l.bold("\u{1F310} API endpoints:")}
|
|
|
579
580
|
http://localhost:8000/examples/notes # Example API
|
|
580
581
|
|
|
581
582
|
${l.gray("\u{1F4A1} Tip: Install globally (npm i -g rapidkit) to use without npx")}
|
|
582
|
-
`);}catch(o){throw n.fail(`Failed to create ${r} project`),o}}async function
|
|
583
|
+
`);}catch(o){throw n.fail(`Failed to create ${r} project`),o}}async function Ze(e,t,i){let r=await promises.readdir(e,{withFileTypes:true});for(let n of r){let o=h.join(e,n.name),s=n.name.replace(/\.j2$/,""),a=h.join(t,s);if(n.isDirectory())await promises.mkdir(a,{recursive:true}),await Ze(o,a,i);else {let c=await promises.readFile(o,"utf-8");n.name.endsWith(".j2")&&(c=Bt(c,i)),await promises.writeFile(a,c),(s==="rapidkit"||s==="activate"||s.endsWith(".py")&&a.includes(".rapidkit"))&&await promises.chmod(a,493);}}}function Bt(e,t){let i=e;for(let[r,n]of Object.entries(t)){let o=new RegExp(`\\{\\{\\s*${r}\\s*\\}\\}`,"g");i=i.replace(o,String(n));let s=new RegExp(`\\{\\{\\s*${r}\\s*\\|\\s*replace\\s*\\(\\s*['"]([^'"]+)['"]\\s*,\\s*['"]([^'"]*)['"]\\s*\\)\\s*\\}\\}`,"g");i=i.replace(s,(p,d,m)=>String(n).replace(new RegExp(d,"g"),m));let a=new RegExp(`\\{\\{\\s*${r}\\s*\\|\\s*lower\\s*\\}\\}`,"g");i=i.replace(a,String(n).toLowerCase());let c=new RegExp(`\\{\\{\\s*${r}\\s*\\|\\s*replace\\s*\\(\\s*['"]([^'"]+)['"]\\s*,\\s*['"]([^'"]*)['"]\\s*\\)\\s*\\|\\s*lower\\s*\\}\\}`,"g");i=i.replace(c,(p,d,m)=>String(n).replace(new RegExp(d,"g"),m).toLowerCase());}return i}async function Ht(){let e=process.env.XDG_CONFIG_HOME||process.env.APPDATA||h.join(L__default.homedir(),".config"),t=process.platform==="win32"?h.join(e,"rapidkit"):h.join(L__default.homedir(),".rapidkit"),i=h.join(t,"workspaces.json");if(!await promises.stat(i).catch(()=>null)){console.log(l.yellow(`
|
|
583
584
|
\u26A0\uFE0F No workspaces registered yet.
|
|
584
585
|
`)),console.log(l.gray(`Create a workspace with: npx rapidkit <workspace-name>
|
|
585
586
|
`));return}try{let r=await promises.readFile(i,"utf8"),n=JSON.parse(r);if(!n.workspaces||n.workspaces.length===0){console.log(l.yellow(`
|
|
@@ -588,32 +589,33 @@ ${l.gray("\u{1F4A1} Tip: Install globally (npm i -g rapidkit) to use without npx
|
|
|
588
589
|
\u{1F4E6} Registered RapidKit Workspaces:
|
|
589
590
|
`));for(let o of n.workspaces)console.log(l.cyan(` ${o.name}`)),console.log(l.gray(` Path: ${o.path}`)),console.log(l.gray(` Projects: ${o.projects?.length||0}`)),await promises.stat(o.path).catch(()=>null)||console.log(l.red(" \u26A0\uFE0F Path not found")),console.log();console.log(l.gray(`Total: ${n.workspaces.length} workspace(s)
|
|
590
591
|
`));}catch(r){console.error(l.red(`
|
|
591
|
-
\u274C Failed to read workspace registry`)),console.error(l.gray(String(r)));}}var
|
|
592
|
+
\u274C Failed to read workspace registry`)),console.error(l.gray(String(r)));}}var G=oe(()=>{w();ae();});w();ne();ae();w();ne();var jt=".rapidkitrc.json";async function se(){let e=h.join(L__default.homedir(),jt);try{let t=await promises.readFile(e,"utf-8"),i=JSON.parse(t);return y.debug(`Loaded config from ${e}`),i}catch{return y.debug("No user config found, using defaults"),{}}}function ue(e){return process.env.RAPIDKIT_DEV_PATH||e.testRapidKitPath||void 0}w();w();var D=class extends Error{constructor(i,r,n){super(i);this.code=r;this.details=n;this.name="RapidKitError",Error.captureStackTrace(this,this.constructor);}},X=class extends D{constructor(t,i){let r=i?`Python ${t}+ required, found ${i}`:`Python ${t}+ not found`;super(r,"PYTHON_NOT_FOUND","Please install Python from https://www.python.org/downloads/");}},ce=class extends D{constructor(){super("Poetry is not installed","POETRY_NOT_FOUND","Install Poetry from https://python-poetry.org/docs/#installation");}},pe=class extends D{constructor(){super("pipx is not installed","PIPX_NOT_FOUND","Install pipx from https://pypa.github.io/pipx/installation/");}},ge=class extends D{constructor(t){super(`Directory "${t}" already exists`,"DIRECTORY_EXISTS","Please choose a different name or remove the existing directory");}},W=class extends D{constructor(t,i){super(`Invalid project name: "${t}"`,"INVALID_PROJECT_NAME",i);}},T=class extends D{constructor(t,i){let r=`Installation failed at: ${t}`,n=`${i.message}
|
|
592
593
|
|
|
593
594
|
Troubleshooting:
|
|
594
595
|
- Check your internet connection
|
|
595
596
|
- Verify Python/Poetry installation
|
|
596
|
-
- Try running with --debug flag for more details`;super(r,"INSTALLATION_ERROR",n);}},
|
|
597
|
+
- Try running with --debug flag for more details`;super(r,"INSTALLATION_ERROR",n);}},Q=class extends D{constructor(){super("RapidKit Python package is not yet available on PyPI","RAPIDKIT_NOT_AVAILABLE",`Available options:
|
|
597
598
|
1. Install Python 3.10+ and retry the same command
|
|
598
599
|
2. Use the core workflow: npx rapidkit create workspace <name>
|
|
599
600
|
3. Offline fallback (limited): npx rapidkit create project fastapi.standard <name> --output .
|
|
600
601
|
|
|
601
|
-
Legacy: set RAPIDKIT_SHOW_LEGACY=1 to reveal template-mode flags in help.`);}};function
|
|
602
|
-
`);};try{i("probing interpreter-specific rapidkit script");let n=((await execa(e,["-c","import sysconfig, os; print(os.path.join(sysconfig.get_path('scripts'), 'rapidkit'))"],{reject:!1,stdio:"pipe",timeout:2e3})).stdout??"").toString().trim();if(i(`script path: ${n}`),n)try{if(await
|
|
602
|
+
Legacy: set RAPIDKIT_SHOW_LEGACY=1 to reveal template-mode flags in help.`);}};function Le(e){let t=$t(e);if(!t.validForNewPackages){let r=t.errors||[],n=t.warnings||[],o=[...r,...n];throw new W(e,`NPM validation failed: ${o.join(", ")}`)}if(!/^[a-z][a-z0-9_-]*$/.test(e))throw new W(e,"Must start with a lowercase letter and contain only lowercase letters, numbers, hyphens, and underscores");if(["test","tests","src","dist","build","lib","python","pip","poetry","node","npm","rapidkit","rapidkit"].includes(e.toLowerCase()))throw new W(e,`"${e}" is a reserved name. Please choose a different name.`);if(e.length<2)throw new W(e,"Name must be at least 2 characters long");if(e.length>214)throw new W(e,"Name must be less than 214 characters");return true}w();function _t(e){return typeof e=="object"&&e!==null}async function bt(e,t,i,r=8e3){try{let n=await execa(e,t,{cwd:i,timeout:r,reject:!1,stdio:"pipe"});return {ok:n.exitCode===0,exitCode:n.exitCode,stdout:n.stdout,stderr:n.stderr}}catch(n){return {ok:false,exitCode:void 0,stdout:"",stderr:n instanceof Error?n.message:String(n)}}}async function Pt(e,t){let i=["-m","rapidkit",...e],r=["python3","python"];for(let n of r){let o=await bt(n,i,t?.cwd,t?.timeoutMs);if(!o.ok)continue;let s=(o.stdout??"").trim();try{let a=JSON.parse(s);return _t(a)?{ok:!0,command:n,exitCode:o.exitCode,stdout:o.stdout,stderr:o.stderr,data:a}:{ok:!1,command:n,exitCode:o.exitCode,stdout:o.stdout,stderr:o.stderr}}catch{return {ok:false,command:n,exitCode:o.exitCode,stdout:o.stdout,stderr:o.stderr}}}return {ok:false}}async function Ve(e,t){let i=await Pt(["project","detect","--path",e,"--json"],t);return !i.ok||!i.data||i.data.schema_version!==1?{ok:false,command:i.command,exitCode:i.exitCode,stdout:i.stdout,stderr:i.stderr}:i}w();var Z=class extends Error{code;constructor(t,i){super(i),this.code=t;}};function He(e){return e instanceof Z?e.code==="PYTHON_NOT_FOUND"?"RapidKit (npm) could not find Python (python3/python) on your PATH.\nInstall Python 3.10+ and ensure `python3` is available, then retry.\nTip: if you are inside a RapidKit project, use the local ./rapidkit launcher.":`RapidKit (npm) bridge error: ${e.message}`:`RapidKit (npm) failed to run the Python core engine: ${e instanceof Error?e.message:String(e)}`}function Et(){let e=process.env.RAPIDKIT_CORE_PYTHON_PACKAGE;return e&&e.trim()?e.trim():"rapidkit-core"}function Je(){let e=process.env.XDG_CACHE_HOME;return e&&e.trim()?e:h.join(L__default.homedir(),".cache")}function Re(){return h.join(Je(),"rapidkit","npm-bridge","venv")}function Ge(e){return process.platform==="win32"?h.join(e,"Scripts","python.exe"):h.join(e,"bin","python")}function Ue(e){return process.platform==="win32"?h.join(e,"Scripts","rapidkit.exe"):h.join(e,"bin","rapidkit")}function It(){return h.join(Je(),"rapidkit","npm-bridge","core-commands.json")}async function St(e){let t=!!process.env.RAPIDKIT_DEBUG,i=r=>{t&&process.stderr.write(`[DEBUG] tryRapidkit(${e}): ${r}
|
|
603
|
+
`);};try{i("probing interpreter-specific rapidkit script");let n=((await execa(e,["-c","import sysconfig, os; print(os.path.join(sysconfig.get_path('scripts'), 'rapidkit'))"],{reject:!1,stdio:"pipe",timeout:2e3})).stdout??"").toString().trim();if(i(`script path: ${n}`),n)try{if(await P.pathExists(n)){i(`found script at ${n}; invoking --version --json`);let o=await execa(n,["--version","--json"],{reject:!1,stdio:"pipe",timeout:4e3});if(i(`script exitCode=${o.exitCode}`),o.exitCode===0){let s=(o.stdout??"").toString().trim();try{let a=JSON.parse(s),c=!!a&&typeof a=="object"&&a!==null&&"version"in a;if(i(`script JSON parse ok=${c}`),c)return !0}catch{i("script output not valid JSON");}}}}catch(o){i(`interpreter-specific script probe failed: ${String(o)}`);}}catch(r){i(`interpreter-specific script probe error: ${String(r)}`);}try{i('probing importlib.find_spec("rapidkit")');let r=await execa(e,["-c","import importlib.util; print(1 if importlib.util.find_spec('rapidkit') else 0)"],{reject:!1,stdio:"pipe",timeout:2e3});if(i(`import probe exitCode=${r.exitCode} stdout=${(r.stdout??"").toString().trim()}`),r.exitCode===0&&(r.stdout??"").toString().trim()==="1")return !0}catch(r){i(`import probe error: ${String(r)}`);}try{i("probing python -m rapidkit");let r=await execa(e,["-m","rapidkit","--version","--json"],{reject:!1,stdio:"pipe",timeout:8e3});if(i(`-m probe exitCode=${r.exitCode}`),r.exitCode===0)return !0}catch(r){i(`-m probe error: ${String(r)}`);}try{i("probing PATH for rapidkit executables");let r=(process.env.PATH??"").split(h.delimiter).filter(Boolean);for(let n of r){let o=h.join(n,process.platform==="win32"?"rapidkit.exe":"rapidkit");try{if(await P.pathExists(o)){i(`found candidate on PATH: ${o}; invoking --version --json`);let s=await execa(o,["--version","--json"],{reject:!1,stdio:"pipe",timeout:4e3});if(i(`candidate exitCode=${s.exitCode}`),s.exitCode===0){let a=(s.stdout??"").toString().trim();try{let c=JSON.parse(a);if(c&&typeof c=="object"&&c!==null&&"version"in c)return !0}catch{i("candidate output not valid JSON, skipping");}}}}catch(s){i(`error probing candidate ${o}: ${String(s)}`);}}return i("no valid rapidkit found on PATH"),!1}catch(r){return i(`PATH probe error: ${String(r)}`),false}}async function _e(e){let t=(e??"").toString().trim();if(!t)return false;try{let i=JSON.parse(t);return !!i&&typeof i=="object"&&i!==null&&"version"in i}catch{return false}}async function At(e){let t=process.platform==="win32",i=t?h.join(".venv","Scripts","rapidkit.exe"):h.join(".venv","bin","rapidkit"),r=t?h.join(".venv","Scripts","python.exe"):h.join(".venv","bin","python"),n=e;for(let o=0;o<25;o+=1){let s=h.join(n,i);if(await P.pathExists(s)){let p=await execa(s,["--version","--json"],{reject:false,stdio:"pipe",timeout:1500,cwd:n});if(p.exitCode===0&&await _e(p.stdout))return {cmd:s,baseArgs:[]}}let a=h.join(n,r);if(await P.pathExists(a)){let p=await execa(a,["-m","rapidkit","--version","--json"],{reject:false,stdio:"pipe",timeout:1500,cwd:n});if(p.exitCode===0&&await _e(p.stdout))return {cmd:a,baseArgs:["-m","rapidkit"]}}let c=h.dirname(n);if(c===n)break;n=c;}return null}async function Nt(e){if(e&&e.trim())try{let o=await At(e);if(o)return o}catch{}let t=await de();if(t.kind==="venv"){let o=Re(),s=Ue(o);return await P.pathExists(s)?{cmd:s,baseArgs:[]}:{cmd:t.pythonPath,baseArgs:["-m","rapidkit"]}}try{if((await execa(t.cmd,["-m","rapidkit","--version","--json"],{reject:!1,stdio:"pipe",timeout:4e3})).exitCode===0)return {cmd:t.cmd,baseArgs:["-m","rapidkit"]}}catch{}try{let s=((await execa(t.cmd,["-c","import sysconfig, os; print(os.path.join(sysconfig.get_path('scripts'), 'rapidkit'))"],{reject:!1,stdio:"pipe",timeout:2e3})).stdout??"").toString().trim();if(s&&await P.pathExists(s))try{let a=await execa(s,["--version","--json"],{reject:!1,stdio:"pipe",timeout:4e3});if(a.exitCode===0&&await _e(a.stdout))return {cmd:s,baseArgs:[]}}catch{}}catch{}let i=Re(),r=await be(t.cmd),n=Ue(i);return await P.pathExists(n)?{cmd:n,baseArgs:[]}:{cmd:r,baseArgs:["-m","rapidkit"]}}async function Be(){for(let e of ["python3","python"])try{return await execa(e,["--version"],{reject:!1,stdio:"pipe",timeout:2e3}),e}catch{}return null}async function be(e){let t=Re(),i=Ge(t);if(await P.pathExists(i))try{let o=await execa(i,["-c","import importlib.util; print(1 if importlib.util.find_spec('rapidkit') else 0)"],{reject:!1,stdio:"pipe",timeout:2e3});if(o.exitCode===0&&(o.stdout??"").toString().trim()==="1")return i;await P.remove(t);}catch{await P.remove(t);}let r={...process.env,PIP_DISABLE_PIP_VERSION_CHECK:"1",PIP_NO_PYTHON_VERSION_WARNING:"1"},n=async(o,s)=>{let a=await execa(o,s,{reject:false,stdio:["ignore","pipe","inherit"],env:r});if(a.exitCode===0)return;let c=(a.stdout??"").toString(),p=(a.stderr??"").toString(),d=[c,p].filter(Boolean).join(`
|
|
603
604
|
`),m=d?`${o} ${s.join(" ")}
|
|
604
|
-
${d}`:`${o} ${s.join(" ")}`;throw new Error(m)};try{await
|
|
605
|
-
|
|
606
|
-
|
|
605
|
+
${d}`:`${o} ${s.join(" ")}`;throw new Error(m)};try{await P.ensureDir(h.dirname(t)),await n(e,["-m","venv",t]);let o=Ge(t);if((await execa(o,["-m","pip","--version"],{reject:!1,stdio:"pipe",timeout:2e3})).exitCode!==0&&(await execa(o,["-m","ensurepip","--default-pip"],{reject:!1,stdio:["ignore","pipe","inherit"],env:r})).exitCode!==0)throw new Error(`Failed to install pip in virtual environment.
|
|
606
|
+
Your Python installation may be missing the ensurepip module.
|
|
607
|
+
On Debian/Ubuntu, install: sudo apt install python3-venv python3-pip`);return process.env.RAPIDKIT_BRIDGE_UPGRADE_PIP==="1"&&await n(o,["-m","pip","install","-U","pip"]),await n(o,["-m","pip","install","-U",Et()]),o}catch(o){throw new Z("BRIDGE_VENV_BOOTSTRAP_FAILED",He(o))}}async function de(){if(process.env.RAPIDKIT_BRIDGE_FORCE_VENV==="1"){let i=await Be();if(!i)throw new Z("PYTHON_NOT_FOUND","No Python interpreter found (python3/python).");return {kind:"venv",pythonPath:await be(i)}}for(let i of ["python3","python"])if(await St(i))return {kind:"system",cmd:i};let e=await Be();if(!e)throw new Z("PYTHON_NOT_FOUND","No Python interpreter found (python3/python).");return {kind:"venv",pythonPath:await be(e)}}async function K(e,t){try{let i=await Nt(t?.cwd),r=i.cmd,n=[...i.baseArgs,...e],o=await execa(r,n,{cwd:t?.cwd,env:{...process.env,...t?.env},reject:!1,stdio:"inherit"});return typeof o.exitCode=="number"?o.exitCode:1}catch(i){return process.stderr.write(`${He(i)}
|
|
608
|
+
`),1}}async function Dt(){let e=It();if(!await P.pathExists(e))return null;try{let t=await P.readJson(e);if(t&&t.schema_version===1&&Array.isArray(t.commands))return t}catch{}return null}async function Ye(){let t=Date.now(),i=await Dt();return !i||t-i.fetched_at>=864e5||!i.commands?.length?null:new Set(i.commands)}w();var Tt=["version","project","create","init","dev","start","build","test","lint","format","add","list","info","upgrade","diff","doctor","license","reconcile","rollback","uninstall","checkpoint","optimize","snapshot","frameworks","modules","merge"],ze=new Set(Tt);w();ne();ae();w();function Pe(){return process.platform==="win32"?"python":"python3"}Ie();async function tt(e,t,i){let r=Ee(t,F(),i);await fe(e,r);}async function it(e){await P.outputFile(h.join(e,".gitignore"),`.venv/
|
|
607
609
|
__pycache__/
|
|
608
610
|
*.pyc
|
|
609
611
|
.env
|
|
610
612
|
.rapidkit-workspace/
|
|
611
613
|
|
|
612
|
-
`,"utf-8");}function
|
|
614
|
+
`,"utf-8");}function me(){let e=h.join(L.homedir(),".local","bin"),i=(process.env.PATH||"").split(h.delimiter).filter(Boolean);i.includes(e)||(process.env.PATH=[e,...i].join(h.delimiter));}async function rt(e,t){me(),e.start("Checking pipx installation");try{return await execa("pipx",["--version"]),e.succeed("pipx found"),{kind:"binary"}}catch{}let i=Pe();try{return await execa(i,["-m","pipx","--version"]),e.succeed("pipx found"),{kind:"python-module",pythonCmd:i}}catch{}if(t)throw new pe;let{installPipx:r}=await Se.prompt([{type:"confirm",name:"installPipx",message:"pipx is not installed. Install it now (user install via python -m pip)?",default:true}]);if(!r)throw new pe;e.start("Installing pipx (user install)");try{try{await execa(i,["-m","pip","install","--user","--upgrade","pip"]);}catch{}await execa(i,["-m","pip","install","--user","--upgrade","pipx"]);}catch(n){let o=n,s=String(o?.stderr||o?.shortMessage||o?.message||"");throw new T("Install pipx with python -m pip",n instanceof Error?n:new Error(s))}e.succeed("pipx installed"),me();try{return await execa(i,["-m","pipx","--version"]),{kind:"python-module",pythonCmd:i}}catch(n){let o=n,s=String(o?.stderr||o?.shortMessage||o?.message||"pipx not runnable after install");throw new T("Verify pipx after install",new Error(`${s}
|
|
613
615
|
|
|
614
|
-
Try reopening your terminal or run: python3 -m pipx ensurepath`))}}async function
|
|
616
|
+
Try reopening your terminal or run: python3 -m pipx ensurepath`))}}async function he(e,t){return e.kind==="binary"?execa("pipx",t):execa(e.pythonCmd,["-m","pipx",...t])}async function Jt(e,t){me(),e.start("Checking Poetry installation");try{await execa("poetry",["--version"]),e.succeed("Poetry found");return}catch{}if(t)throw new ce;let{installPoetry:i}=await Se.prompt([{type:"confirm",name:"installPoetry",message:"Poetry is not installed. Install it now using pipx?",default:true}]);if(!i)throw new ce;let r=await rt(e,t);e.start("Installing Poetry with pipx");try{await he(r,["install","poetry"]);}catch(n){let o=n,s=String(o?.stderr||o?.shortMessage||o?.message||"");if(/already\s+installed|already\s+seems\s+to\s+be\s+installed|exists/i.test(s))try{await he(r,["upgrade","poetry"]);}catch{}else throw new T("Install Poetry with pipx",n instanceof Error?n:new Error(s))}e.succeed("Poetry installed"),me();try{await execa("poetry",["--version"]);}catch(n){let o=n,s=String(o?.stderr||o?.shortMessage||o?.message||"Poetry not found on PATH");throw new T("Verify Poetry after pipx install",new Error(`${s}
|
|
615
617
|
|
|
616
|
-
Poetry may be installed but not on PATH yet. Try reopening your terminal or run: pipx ensurepath`))}}function
|
|
618
|
+
Poetry may be installed but not on PATH yet. Try reopening your terminal or run: pipx ensurepath`))}}function Yt(e){let t=e==="poetry";return `#!/usr/bin/env sh
|
|
617
619
|
set -eu
|
|
618
620
|
|
|
619
621
|
SCRIPT_DIR=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)
|
|
@@ -632,7 +634,7 @@ echo "- If you used venv: ensure .venv exists (or re-run the installer)." 1>&2
|
|
|
632
634
|
${t?`echo "- If you used Poetry: run 'poetry install' and retry, or activate the env." 1>&2
|
|
633
635
|
`:""}echo "Tip: you can also run: ./.venv/bin/rapidkit --help" 1>&2
|
|
634
636
|
exit 1
|
|
635
|
-
`}function
|
|
637
|
+
`}function zt(e){return `@echo off
|
|
636
638
|
setlocal
|
|
637
639
|
|
|
638
640
|
set "SCRIPT_DIR=%~dp0"
|
|
@@ -651,22 +653,22 @@ if %ERRORLEVEL%==0 if exist "%SCRIPT_DIR%\\pyproject.toml" (
|
|
|
651
653
|
`:""}echo RapidKit launcher could not find a local Python CLI. 1>&2
|
|
652
654
|
echo Tip: run .venv\\Scripts\\rapidkit.exe --help 1>&2
|
|
653
655
|
exit /b 1
|
|
654
|
-
`}async function
|
|
656
|
+
`}async function ot(e,t){await P.outputFile(h.join(e,"rapidkit"),Yt(t),{encoding:"utf-8",mode:493}),await P.outputFile(h.join(e,"rapidkit.cmd"),zt(t),"utf-8");}async function nt(e,t){let{skipGit:i=false,testMode:r=false,demoMode:n=false,dryRun:o=false,yes:s=false,userConfig:a={},installMethod:c}=t,p=e||"rapidkit",d=h.resolve(process.cwd(),p);if(await P.pathExists(d))throw new ge(p);if(o){await Xt(d,p,n,a);return}if(n){await qt(d,p,i);return}let m=s?{pythonVersion:a.pythonVersion||"3.10",installMethod:c||a.defaultInstallMethod||"poetry"}:await Se.prompt([{type:"list",name:"pythonVersion",message:"Select Python version for RapidKit:",choices:["3.10","3.11","3.12"],default:a.pythonVersion||"3.10"},{type:"list",name:"installMethod",message:"How would you like to install RapidKit?",choices:[{name:"\u{1F3AF} Poetry (Recommended - includes virtual env)",value:"poetry"},{name:"\u{1F4E6} pip with venv (Standard)",value:"venv"},{name:"\u{1F527} pipx (Global isolated install)",value:"pipx"}],default:a.defaultInstallMethod||"poetry"}]);y.step(1,3,"Setting up RapidKit environment");let j=le("Creating directory").start();try{if(await P.ensureDir(d),j.succeed("Directory created"),await tt(d,p,m.installMethod),await it(d),m.installMethod==="poetry"?await at(d,m.pythonVersion,j,r,a,s):m.installMethod==="venv"?await st(d,m.pythonVersion,j,r,a):await ct(d,j,r,a,s),await ot(d,m.installMethod),await pt(d,m.installMethod),j.succeed("RapidKit environment ready!"),!t.skipGit){j.start("Initializing git repository");try{await execa("git",["init"],{cwd:d}),await execa("git",["add","."],{cwd:d}),await execa("git",["commit","-m","Initial commit: RapidKit environment"],{cwd:d}),j.succeed("Git repository initialized");}catch{j.warn("Could not initialize git repository");}}try{let{registerWorkspace:R}=await Promise.resolve().then(()=>(G(),V));await R(d,p);}catch{console.warn(l.gray("Note: Could not register workspace in shared registry"));}if(console.log(l.green(`
|
|
655
657
|
\u2728 RapidKit environment created successfully!
|
|
656
658
|
`)),console.log(l.cyan("\u{1F4C2} Location:"),l.white(d)),console.log(l.cyan(`\u{1F680} Get started:
|
|
657
|
-
`)),console.log(l.white(` cd ${p}`)),m.installMethod==="poetry"){let
|
|
659
|
+
`)),console.log(l.white(` cd ${p}`)),m.installMethod==="poetry"){let R="source $(poetry env info --path)/bin/activate";try{me();let{stdout:f}=await execa("poetry",["--version"]),_=f.match(/Poetry.*?(\d+)\.(\d+)/);_&&(parseInt(_[1])>=2?R="source $(poetry env info --path)/bin/activate":R="poetry shell");}catch{}console.log(l.white(` ${R} # Or: poetry run rapidkit`)),console.log(l.white(" rapidkit create # Interactive mode")),console.log(l.white(" cd <project-name> && rapidkit init && rapidkit dev"));}else m.installMethod==="venv"?(console.log(l.white(" source .venv/bin/activate # On Windows: .venv\\Scripts\\activate")),console.log(l.white(" rapidkit create # Interactive mode")),console.log(l.white(" cd <project-name> && rapidkit init && rapidkit dev"))):(console.log(l.white(" rapidkit create # Interactive mode")),console.log(l.white(" cd <project-name> && rapidkit init && rapidkit dev")));console.log(l.white(`
|
|
658
660
|
\u{1F4A1} For more information, check the README.md file.`)),console.log(l.cyan(`
|
|
659
661
|
\u{1F4DA} RapidKit commands:`)),console.log(l.white(" rapidkit create - Create a new project (interactive)")),console.log(l.white(" rapidkit dev - Run development server")),console.log(l.white(" rapidkit add module <name> - Add a module (e.g., settings)")),console.log(l.white(" rapidkit list - List available kits")),console.log(l.white(" rapidkit modules - List available modules")),console.log(l.white(` rapidkit --help - Show all commands
|
|
660
|
-
`));}catch(
|
|
661
|
-
\u274C Error:`)
|
|
662
|
-
package-mode = false`);await promises.writeFile(s,c,"utf-8"),i.succeed("Poetry project initialized"),i.start("Configuring Poetry to create in-project virtualenv");try{await execa("poetry",["config","virtualenvs.in-project","true"],{cwd:e}),i.succeed("Poetry configured");}catch{i.warn("Could not configure Poetry virtualenvs.in-project");}if(i.start("Installing RapidKit"),r){let p=ue(n||{});if(!p)throw new T("Test mode installation",new Error("No local RapidKit path configured. Set RAPIDKIT_DEV_PATH environment variable."));y.debug(`Installing from local path: ${p}`),i.text="Installing RapidKit from local path (test mode)",await execa("poetry",["add",p],{cwd:e});}else {i.text="Installing RapidKit from PyPI";try{await execa("poetry",["add","rapidkit-core"],{cwd:e});}catch{throw new
|
|
662
|
+
`));}catch(R){j.fail("Failed to create RapidKit environment"),console.error(l.red(`
|
|
663
|
+
\u274C Error:`),R);try{await P.remove(d);}catch{}throw R}}async function at(e,t,i,r,n,o=false){await Jt(i,o),i.start("Initializing Poetry project"),await execa("poetry",["init","--no-interaction","--python",`^${t}`],{cwd:e});let s=h.join(e,"pyproject.toml"),c=(await promises.readFile(s,"utf-8")).replace("[tool.poetry]",`[tool.poetry]
|
|
664
|
+
package-mode = false`);await promises.writeFile(s,c,"utf-8"),i.succeed("Poetry project initialized"),i.start("Configuring Poetry to create in-project virtualenv");try{await execa("poetry",["config","virtualenvs.in-project","true"],{cwd:e}),i.succeed("Poetry configured");}catch{i.warn("Could not configure Poetry virtualenvs.in-project");}if(i.start("Installing RapidKit"),r){let p=ue(n||{});if(!p)throw new T("Test mode installation",new Error("No local RapidKit path configured. Set RAPIDKIT_DEV_PATH environment variable."));y.debug(`Installing from local path: ${p}`),i.text="Installing RapidKit from local path (test mode)",await execa("poetry",["add",p],{cwd:e});}else {i.text="Installing RapidKit from PyPI";try{await execa("poetry",["add","rapidkit-core"],{cwd:e});}catch{throw new Q}}i.succeed("RapidKit installed");}async function st(e,t,i,r,n){i.start(`Checking Python ${t}`);let o=Pe();try{let{stdout:a}=await execa(o,["--version"]),c=a.match(/Python (\d+\.\d+)/)?.[1];if(c&&parseFloat(c)<parseFloat(t))throw new X(t,c);i.succeed(`Python ${c} found`);}catch(a){throw a instanceof X?a:new X(t)}i.start("Creating virtual environment");try{await execa(o,["-m","venv",".venv"],{cwd:e}),i.succeed("Virtual environment created");}catch(a){if(i.fail("Failed to create virtual environment"),(p=>typeof p=="object"&&p!==null&&"stdout"in p&&typeof p.stdout=="string")(a)&&a.stdout.includes("ensurepip is not")){let p=a.stdout.match(/apt install (python[\d.]+-venv)/),d=p?p[1]:"python3-venv";throw new T("Python venv module not available",new Error(`Virtual environment creation failed.
|
|
663
665
|
|
|
664
666
|
On Debian/Ubuntu systems, install the venv package:
|
|
665
667
|
sudo apt install ${d}
|
|
666
668
|
|
|
667
669
|
Or use Poetry instead (recommended):
|
|
668
|
-
npx rapidkit ${
|
|
669
|
-
`,"utf-8");}async function
|
|
670
|
+
npx rapidkit ${h.basename(e)} --yes`))}throw new T("Virtual environment creation",a instanceof Error?a:new Error(String(a)))}i.start("Installing RapidKit");let s=h.join(e,".venv",process.platform==="win32"?"Scripts":"bin",process.platform==="win32"?"python.exe":"python");if(await execa(s,["-m","pip","install","--upgrade","pip"],{cwd:e}),r){let a=ue(n||{});if(!a)throw new T("Test mode installation",new Error("No local RapidKit path configured. Set RAPIDKIT_DEV_PATH environment variable."));y.debug(`Installing from local path: ${a}`),i.text="Installing RapidKit from local path (test mode)",await execa(s,["-m","pip","install","-e",a],{cwd:e});}else {i.text="Installing RapidKit from PyPI";try{await execa(s,["-m","pip","install","rapidkit-core"],{cwd:e});}catch{throw new Q}}i.succeed("RapidKit installed");}async function ct(e,t,i,r,n=false){let o=await rt(t,n);if(t.start("Installing RapidKit globally with pipx"),i){let s=ue(r||{});if(!s)throw new T("Test mode installation",new Error("No local RapidKit path configured. Set RAPIDKIT_DEV_PATH environment variable."));y.debug(`Installing from local path: ${s}`),t.text="Installing RapidKit from local path (test mode)",await he(o,["install","-e",s]);}else {t.text="Installing RapidKit from PyPI";try{await he(o,["install","rapidkit-core"]);}catch{throw new Q}}t.succeed("RapidKit installed globally"),await P.outputFile(h.join(e,".rapidkit-global"),`RapidKit installed globally with pipx
|
|
671
|
+
`,"utf-8");}async function Y(e,t){let{skipGit:i=false,testMode:r=false,userConfig:n={},yes:o=false,installMethod:s,pythonVersion:a="3.10"}=t||{},c=s||n.defaultInstallMethod||"poetry";await tt(e,h.basename(e),c),await it(e);let p=le("Registering workspace").start();try{c==="poetry"?await at(e,a,p,r,n,o):c==="venv"?await st(e,a,p,r,n):await ct(e,p,r,n,o),await ot(e,c),await pt(e,c),p.succeed("Workspace registered");try{let{registerWorkspace:d}=await Promise.resolve().then(()=>(G(),V));await d(e,h.basename(e));}catch{}if(!i){p.start("Initializing git repository");try{await execa("git",["init"],{cwd:e}),await execa("git",["add","."],{cwd:e}),await execa("git",["commit","-m","Initial commit: RapidKit workspace"],{cwd:e}),p.succeed("Git repository initialized");}catch{p.warn("Could not initialize git repository");}}}catch(d){throw p.fail("Failed to register workspace"),d}}async function pt(e,t){let n=`# RapidKit Workspace
|
|
670
672
|
|
|
671
673
|
This directory contains a RapidKit development environment.
|
|
672
674
|
|
|
@@ -777,7 +779,7 @@ If you encounter issues:
|
|
|
777
779
|
2. Check RapidKit installation: \`rapidkit --version\`
|
|
778
780
|
3. Run diagnostics: \`rapidkit doctor\`
|
|
779
781
|
4. Visit RapidKit documentation or GitHub issues
|
|
780
|
-
`;await promises.writeFile(
|
|
782
|
+
`;await promises.writeFile(h.join(e,"README.md"),n,"utf-8");}async function qt(e,t,i){let r=le("Creating demo workspace").start();try{await P.ensureDir(e),r.succeed("Directory created"),r.start("Setting up demo kit generator");let n=JSON.stringify({name:`${t}-workspace`,version:"1.0.0",private:!0,description:"RapidKit demo workspace",scripts:{generate:"node generate-demo.js"}},null,2);await promises.writeFile(h.join(e,"package.json"),n,"utf-8"),await promises.writeFile(h.join(e,"generate-demo.js"),`#!/usr/bin/env node
|
|
781
783
|
/**
|
|
782
784
|
* Demo Kit Generator - Create FastAPI demo projects
|
|
783
785
|
*
|
|
@@ -1173,7 +1175,7 @@ venv/
|
|
|
1173
1175
|
}
|
|
1174
1176
|
|
|
1175
1177
|
main().catch(console.error);
|
|
1176
|
-
`,"utf-8");try{await execa("chmod",["+x",
|
|
1178
|
+
`,"utf-8");try{await execa("chmod",["+x",h.join(e,"generate-demo.js")]);}catch{}let s=`# RapidKit Demo Workspace
|
|
1177
1179
|
|
|
1178
1180
|
Welcome to your RapidKit demo workspace! This environment lets you generate FastAPI demo projects using bundled RapidKit templates, without needing to install Python RapidKit.
|
|
1179
1181
|
|
|
@@ -1260,7 +1262,7 @@ ${t}/
|
|
|
1260
1262
|
---
|
|
1261
1263
|
|
|
1262
1264
|
**Generated with RapidKit** | [GitHub](https://github.com/getrapidkit/rapidkit-npm)
|
|
1263
|
-
`;if(await promises.writeFile(
|
|
1265
|
+
`;if(await promises.writeFile(h.join(e,"README.md"),s,"utf-8"),r.succeed("Demo workspace setup complete"),!i){r.start("Initializing git repository");try{await execa("git",["init"],{cwd:e}),await P.outputFile(h.join(e,".gitignore"),`# Dependencies
|
|
1264
1266
|
node_modules/
|
|
1265
1267
|
|
|
1266
1268
|
# Generated projects
|
|
@@ -1276,7 +1278,7 @@ __pycache__/
|
|
|
1276
1278
|
`,"utf-8"),await execa("git",["add","."],{cwd:e}),await execa("git",["commit","-m","Initial commit: Demo workspace"],{cwd:e}),r.succeed("Git repository initialized");}catch{r.warn("Could not initialize git repository");}}console.log(l.green(`
|
|
1277
1279
|
\u2728 Demo workspace created successfully!
|
|
1278
1280
|
`)),console.log(l.cyan("\u{1F4C2} Location:"),l.white(e)),console.log(l.cyan(`\u{1F680} Get started:
|
|
1279
|
-
`)),console.log(l.white(` cd ${t}`)),console.log(l.white(" node generate-demo.js my-api")),console.log(l.white(" cd my-api")),console.log(l.white(" rapidkit init")),console.log(l.white(" rapidkit dev")),console.log(),console.log(l.yellow("\u{1F4A1} Note:"),"This is a demo workspace. For full RapidKit features:"),console.log(l.cyan(" pipx install rapidkit")),console.log();}catch(n){throw r.fail("Failed to create demo workspace"),n}}async function
|
|
1281
|
+
`)),console.log(l.white(` cd ${t}`)),console.log(l.white(" node generate-demo.js my-api")),console.log(l.white(" cd my-api")),console.log(l.white(" rapidkit init")),console.log(l.white(" rapidkit dev")),console.log(),console.log(l.yellow("\u{1F4A1} Note:"),"This is a demo workspace. For full RapidKit features:"),console.log(l.cyan(" pipx install rapidkit")),console.log();}catch(n){throw r.fail("Failed to create demo workspace"),n}}async function Xt(e,t,i,r){console.log(l.cyan(`
|
|
1280
1282
|
\u{1F50D} Dry-run mode - showing what would be created:
|
|
1281
1283
|
`)),console.log(l.white("\u{1F4C2} Project path:"),e),console.log(l.white("\u{1F4E6} Project type:"),i?"Demo workspace":"Full RapidKit environment"),i?(console.log(l.white(`
|
|
1282
1284
|
\u{1F4DD} Files to create:`)),console.log(l.gray(" - package.json")),console.log(l.gray(" - generate-demo.js (project generator)")),console.log(l.gray(" - README.md")),console.log(l.gray(" - .gitignore")),console.log(l.white(`
|
|
@@ -1285,7 +1287,7 @@ __pycache__/
|
|
|
1285
1287
|
\u{1F4DD} Files to create:`)),console.log(l.gray(" - pyproject.toml (Poetry) or .venv/ (venv)")),console.log(l.gray(" - README.md")),console.log(l.gray(" - .gitignore")),console.log(l.white(`
|
|
1286
1288
|
\u{1F3AF} Next steps after creation:`)),console.log(l.gray(" 1. Install RapidKit Python package")),console.log(l.gray(" 2. Create projects with rapidkit CLI")),console.log(l.gray(" 3. Add modules and customize"))),console.log(l.white(`
|
|
1287
1289
|
\u{1F4A1} To proceed with actual creation, run without --dry-run flag
|
|
1288
|
-
`));}w();
|
|
1290
|
+
`));}w();ae();var ei=fileURLToPath(import.meta.url),ti=h.dirname(ei);async function dt(e,t){let r=(t.template||"fastapi")==="fastapi",n=r?"FastAPI":"NestJS",o=le(`Generating ${n} project...`).start();try{let s=h.resolve(ti,".."),a=r?"fastapi-standard":"nestjs-standard",c=h.join(s,"templates","kits",a),p=Qt.configure(c,{autoescape:!1,trimBlocks:!0,lstripBlocks:!0}),d={project_name:t.project_name,author:t.author||"RapidKit User",description:t.description||(r?"FastAPI service generated with RapidKit":"NestJS application generated with RapidKit"),app_version:t.app_version||"0.1.0",license:t.license||"MIT",package_manager:t.package_manager||"npm",created_at:new Date().toISOString(),rapidkit_version:F()},m;r?m=["src/main.py.j2","src/__init__.py.j2","src/cli.py.j2","src/routing/__init__.py.j2","src/routing/health.py.j2","src/modules/__init__.py.j2","tests/__init__.py.j2","README.md.j2","pyproject.toml.j2","Makefile.j2",".rapidkit/__init__.py.j2",".rapidkit/project.json.j2",".rapidkit/cli.py.j2",".rapidkit/rapidkit.j2",".rapidkit/activate.j2","rapidkit.j2","rapidkit.cmd.j2"]:m=["src/main.ts.j2","src/app.module.ts.j2","src/app.controller.ts.j2","src/app.service.ts.j2","src/config/configuration.ts.j2","src/config/validation.ts.j2","src/config/index.ts.j2","src/modules/index.ts.j2","src/examples/examples.module.ts.j2","src/examples/examples.controller.ts.j2","src/examples/examples.service.ts.j2","src/examples/dto/create-note.dto.ts.j2","test/app.controller.spec.ts.j2","test/examples.controller.spec.ts.j2","test/app.e2e-spec.ts.j2","test/jest-e2e.json.j2","package.json.j2","tsconfig.json.j2","tsconfig.build.json.j2","nest-cli.json.j2","jest.config.ts.j2",".eslintrc.js.j2",".prettierrc.j2",".nvmrc.j2",".node-version.j2",".env.example.j2","README.md.j2",".rapidkit/project.json.j2",".rapidkit/rapidkit.j2",".rapidkit/rapidkit.cmd.j2",".rapidkit/activate.j2","rapidkit.j2","rapidkit.cmd.j2"];for(let f of m){let _=h.join(c,f);try{await promises.access(_);}catch{continue}let B=await promises.readFile(_,"utf-8"),ve=p.renderString(B,d),re=f.replace(/\.j2$/,""),xe=h.join(e,re);await promises.mkdir(h.dirname(xe),{recursive:!0}),await promises.writeFile(xe,ve),(re.endsWith(".rapidkit/rapidkit")||re.endsWith(".rapidkit/cli.py")||re.endsWith(".rapidkit/activate")||re==="rapidkit")&&await promises.chmod(xe,493);}if(r){let f=h.join(c,".rapidkit","context.json"),_=h.join(e,".rapidkit","context.json");try{await promises.mkdir(h.join(e,".rapidkit"),{recursive:!0}),await promises.copyFile(f,_);}catch{await promises.mkdir(h.join(e,".rapidkit"),{recursive:!0});let ve=t.engine||"pip";await promises.writeFile(_,JSON.stringify({engine:ve,created_by:"rapidkit-npm-fallback"},null,2));}}let j=r?`# Python
|
|
1289
1291
|
__pycache__/
|
|
1290
1292
|
*.py[cod]
|
|
1291
1293
|
*$py.class
|
|
@@ -1353,7 +1355,12 @@ Thumbs.db
|
|
|
1353
1355
|
|
|
1354
1356
|
# Coverage
|
|
1355
1357
|
coverage/
|
|
1356
|
-
`;if(await promises.writeFile(
|
|
1358
|
+
`;if(await promises.writeFile(h.join(e,".gitignore"),j),o.succeed(`${n} project generated!`),!t.skipGit){let f=le("Initializing git repository...").start();try{await execa("git",["init"],{cwd:e}),await execa("git",["add","."],{cwd:e}),await execa("git",["commit","-m",`Initial commit: ${n} project via RapidKit`],{cwd:e}),f.succeed("Git repository initialized");}catch{f.warn("Could not initialize git repository");}}if(!r&&!t.skipInstall){let f=t.package_manager||"npm",_=le(`Installing dependencies with ${f}...`).start();try{await execa(f,f==="yarn"?["install"]:f==="pnpm"?["install"]:["install"],{cwd:e}),_.succeed("Dependencies installed");}catch{_.warn(`Could not install dependencies. Run '${f} install' manually.`);}}let R=h.basename(e);console.log(`
|
|
1359
|
+
${l.yellow("\u26A0\uFE0F Limited offline mode:")} This project was created using basic templates.
|
|
1360
|
+
${l.gray("For full kit features, install Python 3.10+ and rapidkit-core:")}
|
|
1361
|
+
${l.cyan(" sudo apt install python3 python3-pip python3-venv")}
|
|
1362
|
+
${l.cyan(" pip install rapidkit-core")}
|
|
1363
|
+
`),console.log(r?`
|
|
1357
1364
|
${l.green("\u2728 FastAPI project created successfully!")}
|
|
1358
1365
|
|
|
1359
1366
|
${l.bold("\u{1F4C2} Project structure:")}
|
|
@@ -1369,7 +1376,7 @@ ${e}/
|
|
|
1369
1376
|
\u2514\u2500\u2500 README.md
|
|
1370
1377
|
|
|
1371
1378
|
${l.bold("\u{1F680} Get started:")}
|
|
1372
|
-
${l.cyan(`cd ${
|
|
1379
|
+
${l.cyan(`cd ${R}`)}
|
|
1373
1380
|
${l.cyan("npx rapidkit init")} ${l.gray("# Install dependencies")}
|
|
1374
1381
|
${l.cyan("npx rapidkit dev")} ${l.gray("# Start dev server")}
|
|
1375
1382
|
|
|
@@ -1399,7 +1406,7 @@ ${e}/
|
|
|
1399
1406
|
\u2514\u2500\u2500 README.md
|
|
1400
1407
|
|
|
1401
1408
|
${l.bold("\u{1F680} Get started:")}
|
|
1402
|
-
${l.cyan(`cd ${
|
|
1409
|
+
${l.cyan(`cd ${R}`)}
|
|
1403
1410
|
${l.cyan("npx rapidkit init")} ${l.gray("# Install dependencies")}
|
|
1404
1411
|
${l.cyan("cp .env.example .env")}
|
|
1405
1412
|
${l.cyan("npx rapidkit dev")} ${l.gray("# Start dev server")}
|
|
@@ -1420,22 +1427,22 @@ ${l.bold("\u{1F310} API endpoints:")}
|
|
|
1420
1427
|
|
|
1421
1428
|
${l.gray("Alternative: npm run start:dev, ./rapidkit dev")}
|
|
1422
1429
|
${l.gray("\u{1F4A1} Tip: Install globally (npm i -g rapidkit) to use without npx")}
|
|
1423
|
-
`);}catch(s){throw o.fail(`Failed to generate ${n} project`),s}}function
|
|
1430
|
+
`);}catch(s){throw o.fail(`Failed to generate ${n} project`),s}}function De(e){if(!e||typeof e!="object")return null;let t=e.code;return t==="PYTHON_NOT_FOUND"||t==="BRIDGE_VENV_BOOTSTRAP_FAILED"?t:null}function ri(e){let t=e.trim().toLowerCase();return t?t.startsWith("fastapi")?"fastapi":t.startsWith("nestjs")?"nestjs":null:null}function oi(e,t){let i=e.indexOf(t);if(i>=0&&i+1<e.length)return e[i+1];let r=e.find(n=>n.startsWith(`${t}=`));if(r)return r.slice(t.length+1)}async function Te(e,t){if(e.includes("--json"))return process.stderr.write("RapidKit (npm) offline fallback does not support --json for `create` commands.\nInstall Python 3.10+ and retry the same command.\n"),1;if(e[0]!=="create")return 1;if(e[1]!=="project")return process.stderr.write(`RapidKit (npm) could not run the Python core engine for \`create\`.
|
|
1424
1431
|
Reason: ${t}.
|
|
1425
1432
|
Install Python 3.10+ to use the interactive wizard and full kit catalog.
|
|
1426
1433
|
`),1;let n=e[2],o=e[3];if(!n||!o)return process.stderr.write(`Usage: rapidkit create project <kit> <name> [--output <dir>]
|
|
1427
1434
|
Tip: offline fallback supports only fastapi* and nestjs* kits.
|
|
1428
|
-
`),1;let s=
|
|
1435
|
+
`),1;let s=ri(n);if(!s)return process.stderr.write(`RapidKit (npm) could not run the Python core engine to create this kit.
|
|
1429
1436
|
Reason: ${t}.
|
|
1430
1437
|
Requested kit: ${n}
|
|
1431
1438
|
Offline fallback only supports: fastapi.standard, nestjs.standard (and their shorthands).
|
|
1432
1439
|
Install Python 3.10+ to access all kits.
|
|
1433
|
-
`),1;let a=
|
|
1434
|
-
`),1;await
|
|
1435
|
-
`),1}}async function
|
|
1436
|
-
`),1)}}if(e[0]==="create"&&e[1]!=="project")try{await
|
|
1437
|
-
`),1)}return await
|
|
1438
|
-
`),1)}}var
|
|
1440
|
+
`),1;let a=oi(e,"--output")||process.cwd(),c=h.resolve(a,o),p=e.includes("--skip-git")||e.includes("--no-git"),d=e.includes("--skip-install");try{if(await P.ensureDir(h.dirname(c)),await P.pathExists(c))return process.stderr.write(`\u274C Directory "${c}" already exists
|
|
1441
|
+
`),1;let m="pip",j=we(process.cwd());if(j)try{let{readWorkspaceMarker:R}=await Promise.resolve().then(()=>(Ie(),Xe)),f=await R(j);f?.metadata?.npm?.installMethod&&(m=f.metadata.npm.installMethod,console.log(`[DEBUG] Detected workspace engine: ${m}`));}catch(R){console.log("[DEBUG] Failed to read workspace marker:",R);}else console.log("[DEBUG] No workspace found, using default engine: pip");if(await P.ensureDir(c),await dt(c,{project_name:o,template:s,skipGit:p,skipInstall:d,engine:m}),j){let{syncWorkspaceProjects:R}=await Promise.resolve().then(()=>(G(),V));await R(j,!0);}return 0}catch(m){return process.stderr.write(`RapidKit (npm) offline fallback failed: ${m?.message??m}
|
|
1442
|
+
`),1}}async function ni(e){let t=new Set(["--yes","-y","--skip-git","--skip-install","--debug","--dry-run","--no-update-check","--create-workspace","--no-workspace"]);try{if(e[0]==="create"&&e[1]==="project"){let i=e.includes("--create-workspace"),r=e.includes("--no-workspace"),n=e.includes("--yes")||e.includes("-y"),o=e.includes("--skip-git")||e.includes("--no-git");if(!!!Fe(process.cwd())){if(i)await Y(process.cwd(),{skipGit:o,yes:n,userConfig:await se()});else if(!r)if(n)await Y(process.cwd(),{skipGit:o,yes:!0,userConfig:await se()});else {let{createWs:c}=await Se.prompt([{type:"confirm",name:"createWs",message:"This project will be created outside a RapidKit workspace. Create and register a workspace here?",default:!0}]);c&&await Y(process.cwd(),{skipGit:o,yes:!1,userConfig:await se()});}}let a=e.filter(c=>{let p=c.split("=")[0];return !t.has(c)&&!t.has(p)});try{await de();let c=await K(a,{cwd:process.cwd()});if(c===0){let p=we(process.cwd());if(p){let{syncWorkspaceProjects:d}=await Promise.resolve().then(()=>(G(),V));await d(p,!0);}}return c}catch(c){let p=De(c);return p?await Te(a,p):(process.stderr.write(`RapidKit (npm) failed to run the Python core engine: ${c?.message??c}
|
|
1443
|
+
`),1)}}if(e[0]==="create"&&e[1]!=="project")try{await de();let i=await K(e,{cwd:process.cwd()});if(i===0){let r=we(process.cwd());if(r){let{syncWorkspaceProjects:n}=await Promise.resolve().then(()=>(G(),V));await n(r,!0);}}return i}catch(i){let r=De(i);return r?await Te(e,r):(process.stderr.write(`RapidKit (npm) failed to run the Python core engine: ${i?.message??i}
|
|
1444
|
+
`),1)}return await de(),await K(e,{cwd:process.cwd()})}catch(i){let r=De(i);return r?await Te(e,r):(process.stderr.write(`RapidKit (npm) failed to run the Python core engine: ${i?.message??i}
|
|
1445
|
+
`),1)}}var mt=["init","dev","start","build","test","lint","format","create","help","--help","-h"];function ai(e){let t=e;for(;;){let i=h.join(t,".rapidkit","context.json");if(ie.existsSync(i))return i;let r=h.dirname(t);if(r===t)break;t=r;}return null}function Fe(e){let t=e;for(;;){let i=h.join(t,".rapidkit-workspace");if(ie.existsSync(i))return i;let r=h.dirname(t);if(r===t)break;t=r;}return null}function we(e){let t=e;for(;;){let i=h.join(t,".rapidkit-workspace");if(ie.existsSync(i))return t;let r=h.dirname(t);if(r===t)break;t=r;}return null}async function si(){let e=process.cwd(),t=process.argv.slice(2);if(t[0]==="create")return false;try{let c=t[0],p=!c||c==="--help"||c==="-h"||c==="help";if(Fe(e)&&p){let m=await K(c?["--help"]:[],{cwd:e});process.exit(m);}}catch{}try{let c=t[0],p=c==="shell"&&t[1]==="activate",d=c==="create",m=await Ve(e,{cwd:e,timeoutMs:1200});if(m.ok&&m.data?.isRapidkitProject&&m.data.engine==="python"&&!p&&!d){let j=await K(process.argv.slice(2),{cwd:e});process.exit(j);}}catch{}let i=ai(e),r=process.platform==="win32",n=r?[h.join(e,"rapidkit.cmd"),h.join(e,"rapidkit"),h.join(e,".rapidkit","rapidkit.cmd"),h.join(e,".rapidkit","rapidkit")]:[h.join(e,"rapidkit"),h.join(e,".rapidkit","rapidkit")],o=null;for(let c of n)if(await P.pathExists(c)){o=c;break}let s=t[0],a=s==="create";if(o&&s&&mt.includes(s)&&!a){y.debug(`Delegating to local CLI: ${o} ${t.join(" ")}`);let c=spawn(o,t,{stdio:"inherit",cwd:e,shell:r});return c.on("close",p=>{process.exit(p??0);}),c.on("error",p=>{y.error(`Failed to run local rapidkit: ${p.message}`),process.exit(1);}),true}if(i&&await P.pathExists(i))try{if((await P.readJson(i)).engine==="pip"){let p=t[0],m=process.platform==="win32"?[h.join(e,"rapidkit.cmd"),h.join(e,"rapidkit"),h.join(e,".rapidkit","rapidkit.cmd"),h.join(e,".rapidkit","rapidkit")]:[h.join(e,"rapidkit"),h.join(e,".rapidkit","rapidkit")],j=null;for(let f of m)if(await P.pathExists(f)){j=f;break}if(j&&p&&mt.includes(p)){y.debug(`Delegating to local CLI (early detection): ${j} ${t.join(" ")}`);let f=spawn(j,t,{stdio:"inherit",cwd:e});return f.on("close",_=>process.exit(_??0)),f.on("error",_=>{y.error(`Failed to run local rapidkit: ${_.message}`),process.exit(1);}),!0}if(p==="shell"&&t[1]==="activate"){let f=`# RapidKit: activation snippet - eval "$(rapidkit shell activate)"
|
|
1439
1446
|
VENV='.venv'
|
|
1440
1447
|
if [ -f "$VENV/bin/activate" ]; then
|
|
1441
1448
|
. "$VENV/bin/activate"
|
|
@@ -1446,35 +1453,35 @@ export RAPIDKIT_PROJECT_ROOT="$(pwd)"
|
|
|
1446
1453
|
export PATH="$(pwd)/.rapidkit:$(pwd):$PATH"
|
|
1447
1454
|
`;console.log(l.green.bold(`
|
|
1448
1455
|
\u2705 Activation snippet \u2014 run the following to activate this project in your current shell:
|
|
1449
|
-
`)),console.log(
|
|
1456
|
+
`)),console.log(f),console.log(l.gray(`
|
|
1450
1457
|
\u{1F4A1} After activation you can run: rapidkit dev
|
|
1451
|
-
`)),process.exit(0);}let
|
|
1458
|
+
`)),process.exit(0);}let R=await K(t,{cwd:e});process.exit(R);}}catch{}return false}var U=null,ke=false,q=new Command;async function pi(e){if(e.length===0)return false;let t=e[0],i=e[1];if(t==="shell"&&i==="activate"||t==="workspace")return false;if(e.includes("--tui"))return true;if(t==="--help"||t==="-h"||t==="help"||t==="--version"||t==="-V"||e.includes("--template")||e.includes("-t"))return false;let r=new Set(["--yes","-y","--skip-git","--skip-install","--debug","--dry-run","--no-update-check","--create-workspace","--no-workspace"]);if(e.some(o=>r.has(o)))return false;let n=await Ye();return n?n.has(t):!!(ze.has(t)||e.length>1)}q.name("rapidkit").description("Create RapidKit workspaces and projects").version(F());q.addHelpText("beforeAll",`RapidKit
|
|
1452
1459
|
|
|
1453
1460
|
Global CLI
|
|
1454
1461
|
Create RapidKit workspaces and projects
|
|
1455
1462
|
|
|
1456
1463
|
Global Engine Commands
|
|
1457
1464
|
Access engine-level commands when inside a RapidKit workspace or via the core bridge
|
|
1458
|
-
`);
|
|
1465
|
+
`);q.addHelpText("afterAll",`
|
|
1459
1466
|
Project Commands
|
|
1460
1467
|
rapidkit create
|
|
1461
1468
|
rapidkit init
|
|
1462
1469
|
rapidkit dev
|
|
1463
1470
|
|
|
1464
1471
|
Use "rapidkit help <command>" for more information.
|
|
1465
|
-
`);
|
|
1472
|
+
`);q.argument("[name]","Name of the workspace or project directory").addOption(new Option("-t, --template <template>","Legacy: create a project with template (fastapi, nestjs) instead of a workspace").hideHelp()).option("-y, --yes","Skip prompts and use defaults").addOption(new Option("--skip-git","Skip git initialization").hideHelp()).addOption(new Option("--skip-install","Legacy: skip installing dependencies (template mode)").hideHelp()).option("--debug","Enable debug logging").addOption(new Option("--dry-run","Show what would be created without creating it").hideHelp()).addOption(new Option("--install-method <method>","Installation method: poetry, venv, or pipx").choices(["poetry","venv","pipx"]).hideHelp()).addOption(new Option("--create-workspace","When creating a project outside a workspace: create and register a workspace in the current directory").hideHelp()).addOption(new Option("--no-workspace","When creating a project outside a workspace: do not create a workspace").hideHelp()).option("--no-update-check","Skip checking for updates").action(async(e,t)=>{try{t.debug&&(y.setDebug(!0),y.debug("Debug mode enabled"));let i=await se();y.debug("User config loaded",i),t.updateCheck!==!1&&await We(),console.log(l.blue.bold(`
|
|
1466
1473
|
\u{1F680} Welcome to RapidKit!
|
|
1467
|
-
`)),e||(
|
|
1474
|
+
`)),e||(di(),process.exit(0));try{Le(e);}catch(o){throw o instanceof D&&(y.error(`
|
|
1468
1475
|
\u274C ${o.message}`),o.details&&y.warn(`\u{1F4A1} ${o.details}
|
|
1469
|
-
`),process.exit(1)),o}let r=
|
|
1476
|
+
`),process.exit(1)),o}let r=h.resolve(process.cwd(),e);U=r,await P.pathExists(r)&&(y.error(`
|
|
1470
1477
|
\u274C Directory "${e}" already exists`),console.log(l.cyan(`
|
|
1471
1478
|
\u{1F4A1} Choose a different name or delete the existing directory.
|
|
1472
1479
|
`)),process.exit(1));let n=!!t.template;if(t.dryRun){console.log(l.cyan(`
|
|
1473
1480
|
\u{1F50D} Dry-run mode - showing what would be created:
|
|
1474
|
-
`)),console.log(l.white("\u{1F4C2} Path:"),r),console.log(l.white("\u{1F4E6} Type:"),n?`Project (${t.template})`:"Workspace"),console.log();return}if(!t.yes&&!n?await
|
|
1475
|
-
`)),n){let o=String(t.template||"").trim(),s=o.toLowerCase(),a=s==="fastapi"?"fastapi.standard":s==="nestjs"?"nestjs.standard":o;if(!!!
|
|
1481
|
+
`)),console.log(l.white("\u{1F4C2} Path:"),r),console.log(l.white("\u{1F4E6} Type:"),n?`Project (${t.template})`:"Workspace"),console.log();return}if(!t.yes&&!n?await Se.prompt([{type:"input",name:"author",message:"Author name:",default:process.env.USER||"RapidKit User"}]):t.yes&&console.log(l.gray(`Using default values (--yes flag)
|
|
1482
|
+
`)),n){let o=String(t.template||"").trim(),s=o.toLowerCase(),a=s==="fastapi"?"fastapi.standard":s==="nestjs"?"nestjs.standard":o;if(!!!Fe(process.cwd())){if(t.createWorkspace)await Y(process.cwd(),{skipGit:t.skipGit,yes:t.yes,userConfig:i});else if(!t.noWorkspace)if(t.yes)await Y(process.cwd(),{skipGit:t.skipGit,yes:!0,userConfig:i});else {let{createWs:m}=await Se.prompt([{type:"confirm",name:"createWs",message:"This project will be created outside a RapidKit workspace. Create and register a workspace here?",default:!0}]);m&&await Y(process.cwd(),{skipGit:t.skipGit,yes:!1,userConfig:i});}}let p=["create","project",a,e,"--output",process.cwd(),"--install-essentials"],d=await K(p,{cwd:process.cwd()});if(d!==0&&process.exit(d),!t.skipInstall){let m=await K(["init",r],{cwd:process.cwd()});m!==0&&process.exit(m);}}else await nt(e,{skipGit:t.skipGit,dryRun:t.dryRun,yes:t.yes,userConfig:i,installMethod:t.installMethod});}catch(i){i instanceof D?(y.error(`
|
|
1476
1483
|
\u274C ${i.message}`),i.details&&y.warn(`\u{1F4A1} ${i.details}`),y.debug("Error code:",i.code)):(y.error(`
|
|
1477
|
-
\u274C An unexpected error occurred:`),console.error(i)),process.exit(1);}finally{
|
|
1484
|
+
\u274C An unexpected error occurred:`),console.error(i)),process.exit(1);}finally{U=null;}});q.command("shell <action>").description("Shell helpers (activate virtualenv in current shell)").action(async e=>{e!=="activate"&&(console.log(l.red(`Unknown shell command: ${e}`)),process.exit(1));let t=process.cwd();function i(s){let a=s;for(;;){let c=h.join(a,".rapidkit","context.json");if(ie.existsSync(c))return c;let p=h.dirname(a);if(p===a)break;a=p;}return null}let r=i(t);function n(s){let a=s;for(;;){let c=h.join(a,".venv"),p=h.join(a,".rapidkit","activate");if(ie.existsSync(p)||ie.existsSync(c))return {venv:c,activateFile:p};let d=h.dirname(a);if(d===a)break;a=d;}return null}let o=n(t);if(!r&&!o&&(console.log(l.red("No RapidKit project found to activate")),process.exit(1)),o){let s=`# RapidKit: activation snippet - eval "$(rapidkit shell activate)"
|
|
1478
1485
|
VENV='.venv'
|
|
1479
1486
|
if [ -f "$VENV/bin/activate" ]; then
|
|
1480
1487
|
. "$VENV/bin/activate"
|
|
@@ -1487,7 +1494,7 @@ export PATH="$(pwd)/.rapidkit:$(pwd):$PATH"
|
|
|
1487
1494
|
\u2705 Activation snippet \u2014 run the following to activate this project in your current shell:
|
|
1488
1495
|
`)),console.log(s),console.log(l.gray(`
|
|
1489
1496
|
\u{1F4A1} After activation you can run: rapidkit dev
|
|
1490
|
-
`)),process.exit(0);}try{(await
|
|
1497
|
+
`)),process.exit(0);}try{(await P.readJson(r)).engine!=="pip"&&(console.log(l.yellow("This project is not a pip-based RapidKit project.")),process.exit(1)),console.log(`# RapidKit: activation snippet - eval "$(rapidkit shell activate)"
|
|
1491
1498
|
VENV='.venv'
|
|
1492
1499
|
if [ -f "$VENV/bin/activate" ]; then
|
|
1493
1500
|
. "$VENV/bin/activate"
|
|
@@ -1505,13 +1512,13 @@ elif [ -f "$VENV/bin/activate.fish" ]; then
|
|
|
1505
1512
|
fi
|
|
1506
1513
|
export RAPIDKIT_PROJECT_ROOT="$(pwd)"
|
|
1507
1514
|
export PATH="$(pwd):$PATH"
|
|
1508
|
-
`),process.exit(0);}});
|
|
1515
|
+
`),process.exit(0);}});q.command("workspace <action>").description("Manage RapidKit workspaces (list, sync)").action(async e=>{if(e==="list"){let{listWorkspaces:t}=await Promise.resolve().then(()=>(G(),V));await t();}else if(e==="sync"){let t=we(process.cwd());t||(console.log(l.red("\u274C Not inside a RapidKit workspace")),console.log(l.gray("\u{1F4A1} Run this command from within a workspace directory")),process.exit(1));let{syncWorkspaceProjects:i}=await Promise.resolve().then(()=>(G(),V));console.log(l.cyan(`\u{1F4C2} Scanning workspace: ${h.basename(t)}`)),await i(t);}else console.log(l.red(`Unknown workspace action: ${e}`)),console.log(l.gray("Available: list, sync")),process.exit(1);});function di(){console.log(l.white(`Usage:
|
|
1509
1516
|
`)),console.log(l.cyan(" npx rapidkit <workspace-name> [options]")),console.log(l.cyan(` npx rapidkit create <...>
|
|
1510
1517
|
`)),console.log(l.bold("Recommended workflow:")),console.log(l.cyan(" npx rapidkit my-workspace")),console.log(l.cyan(" cd my-workspace")),console.log(l.cyan(" npx rapidkit create project fastapi.standard my-api --output .")),console.log(l.cyan(" cd my-api")),console.log(l.cyan(` npx rapidkit init && npx rapidkit dev
|
|
1511
1518
|
`)),console.log(l.bold("Options (workspace creation):")),console.log(l.gray(" -y, --yes Skip prompts and use defaults")),console.log(l.gray(" --skip-git Skip git initialization")),console.log(l.gray(" --debug Enable debug logging")),console.log(l.gray(" --dry-run Show what would be created")),console.log(l.gray(" --create-workspace When creating a project outside a workspace: create and register a workspace in the current directory")),console.log(l.gray(" --no-workspace When creating a project outside a workspace: do not create a workspace")),console.log(l.gray(` --no-update-check Skip checking for updates
|
|
1512
1519
|
`)),console.log(l.gray(`Tip: set RAPIDKIT_SHOW_LEGACY=1 to show legacy template flags in help.
|
|
1513
|
-
`));}process.on("SIGINT",async()=>{if(!
|
|
1520
|
+
`));}process.on("SIGINT",async()=>{if(!ke){if(ke=true,console.log(l.yellow(`
|
|
1514
1521
|
|
|
1515
|
-
\u26A0\uFE0F Interrupted by user`)),
|
|
1516
|
-
`),t[0]==="create"){let r=await
|
|
1517
|
-
`),i){let r=await
|
|
1522
|
+
\u26A0\uFE0F Interrupted by user`)),U&&await P.pathExists(U)){console.log(l.gray("Cleaning up partial installation..."));try{await P.remove(U),console.log(l.green("\u2713 Cleanup complete"));}catch(e){y.debug("Cleanup failed:",e);}}process.exit(130);}});process.on("SIGTERM",async()=>{if(!ke){if(ke=true,y.debug("Received SIGTERM"),U&&await P.pathExists(U))try{await P.remove(U);}catch(e){y.debug("Cleanup failed:",e);}process.exit(143);}});si().then(async e=>{if(!e){let t=process.argv.slice(2);if(process.env.RAPIDKIT_NPM_DEBUG_ARGS==="1"&&process.stderr.write(`[rapidkit-npm] argv=${JSON.stringify(t)}
|
|
1523
|
+
`),t[0]==="create"){let r=await ni(t);process.exit(r);}let i=await pi(t);if(process.env.RAPIDKIT_NPM_DEBUG_ARGS==="1"&&process.stderr.write(`[rapidkit-npm] shouldForwardToCore=${i}
|
|
1524
|
+
`),i){let r=await K(t,{cwd:process.cwd()});process.exit(r);}q.parse();}});export{ni as handleCreateOrFallback};
|
package/dist/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rapidkit",
|
|
3
|
-
"version": "0.16.
|
|
3
|
+
"version": "0.16.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Create RapidKit projects with a single command - The official CLI for RapidKit framework",
|
|
6
6
|
"keywords": [
|
|
@@ -27,6 +27,7 @@
|
|
|
27
27
|
"dist"
|
|
28
28
|
],
|
|
29
29
|
"scripts": {
|
|
30
|
+
"sync-kits": "bash scripts/sync-kits.sh",
|
|
30
31
|
"build": "tsup",
|
|
31
32
|
"build:watch": "tsup --watch",
|
|
32
33
|
"dev": "tsup --watch",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rapidkit",
|
|
3
|
-
"version": "0.16.
|
|
3
|
+
"version": "0.16.3",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Create RapidKit projects with a single command - The official CLI for RapidKit framework",
|
|
6
6
|
"keywords": [
|
|
@@ -27,6 +27,7 @@
|
|
|
27
27
|
"dist"
|
|
28
28
|
],
|
|
29
29
|
"scripts": {
|
|
30
|
+
"sync-kits": "bash scripts/sync-kits.sh",
|
|
30
31
|
"build": "tsup",
|
|
31
32
|
"build:watch": "tsup --watch",
|
|
32
33
|
"dev": "tsup --watch",
|