rapidkit 0.25.1 → 0.25.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/README.md +22 -0
- package/dist/{chunk-3MJ2BD56.js → chunk-CD534JH4.js} +3 -3
- package/dist/{create-PELQEDCF.js → create-UUKDMKMT.js} +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +171 -168
- package/dist/package.json +1 -1
- package/dist/{workspace-PIBFBNRA.js → workspace-M2Y2ZVTK.js} +32 -11
- package/package.json +1 -1
package/dist/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {c}from'./chunk-N64Z3XVF.js';import {j}from'./chunk-Z5LKRG57.js';import {promises}from'fs';import d from'path';import r from'chalk';import w from'ora';import {execa}from'execa';function
|
|
1
|
+
import {c}from'./chunk-N64Z3XVF.js';import {j}from'./chunk-Z5LKRG57.js';import {promises}from'fs';import d from'path';import r from'chalk';import w from'ora';import {execa}from'execa';function f(e){let t=d.resolve(e);return process.platform==="win32"?t.toLowerCase():t}function S(e){let t=f(e.path),i=Array.isArray(e.projects)?e.projects:[],a=[],o=new Set;for(let s of i){if(!s||typeof s.name!="string"||typeof s.path!="string")continue;let n=f(s.path);o.has(n)||(o.add(n),a.push({name:s.name,path:n}));}return {name:e.name,path:t,mode:e.mode,projects:a}}function v(e){let t=[],i=new Set;for(let a of e.workspaces||[]){if(!a||typeof a.name!="string"||typeof a.path!="string")continue;let o=S(a);i.has(o.path)||(i.add(o.path),t.push(o));}return {workspaces:t}}async function N(e,t){try{let i=f(e),a=j(),o=d.join(a,"workspaces.json");await promises.mkdir(a,{recursive:true});let s={workspaces:[]};try{let p=await promises.readFile(o,"utf8"),m=JSON.parse(p);m&&Array.isArray(m.workspaces)&&(s=v(m));}catch{}s.workspaces.some(p=>p.path===i)||(s.workspaces.push({name:t,path:i,mode:"full",projects:[]}),await promises.writeFile(o,JSON.stringify(s,null,2)));}catch{console.warn(r.gray("Note: Could not register workspace in shared registry"));}}async function J(e,t=false){try{let i=f(e),a=j(),o=d.join(a,"workspaces.json"),s={workspaces:[]};try{let c=await promises.readFile(o,"utf8"),g=JSON.parse(c);g&&Array.isArray(g.workspaces)&&(s=v(g));}catch{t||console.log("\u26A0\uFE0F Workspace registry not found");return}let n=s.workspaces.find(c=>c.path===i);if(!n){t||console.log("\u26A0\uFE0F Workspace not registered in registry");return}Array.isArray(n.projects)||(n.projects=[]);let p=await promises.readdir(e,{withFileTypes:true}),m=0,h=0;for(let c of p)if(c.isDirectory()&&!c.name.startsWith(".")){let g=f(d.join(e,c.name)),R=d.join(g,".rapidkit","context.json"),j=d.join(g,".rapidkit","project.json");try{let k=false;try{await promises.access(R),k=true;}catch{await promises.access(j),k=true;}k&&(n.projects.some(_=>_.path===g||_.name===c.name)?h++:(n.projects.push({name:c.name,path:g}),m++,t||console.log(`\u2714 Added: ${c.name}`)));}catch{}}m>0?(await promises.writeFile(o,JSON.stringify(s,null,2)),t||console.log(`
|
|
2
2
|
\u2705 Synced ${m} project(s) to registry`)):t||console.log(`
|
|
3
|
-
\u2705 All projects already registered (${h} found)`);}catch(i){t||console.error("\u274C Failed to sync projects:",i.message);}}async function
|
|
3
|
+
\u2705 All projects already registered (${h} found)`);}catch(i){t||console.error("\u274C Failed to sync projects:",i.message);}}async function K(e,t,i){try{let a=f(e),o=f(i),s=j(),n=d.join(s,"workspaces.json"),p={workspaces:[]};try{let c=await promises.readFile(n,"utf8"),g=JSON.parse(c);g&&Array.isArray(g.workspaces)&&(p=v(g));}catch{return}let m=p.workspaces.find(c=>c.path===a);if(!m)return;Array.isArray(m.projects)||(m.projects=[]),m.projects.some(c=>c.path===o||c.name===t)||(m.projects.push({name:t,path:o}),await promises.writeFile(n,JSON.stringify(p,null,2)));}catch{}}async function G(e,t){let i=w("Creating RapidKit workspace...").start();try{await promises.mkdir(e,{recursive:true}),await promises.mkdir(d.join(e,".rapidkit"),{recursive:true});let a={workspace_name:t.name,author:t.author,rapidkit_version:c(),created_at:new Date().toISOString(),type:"workspace"};await promises.writeFile(d.join(e,".rapidkit","config.json"),JSON.stringify(a,null,2));let o=E();await promises.writeFile(d.join(e,"rapidkit"),o),await promises.chmod(d.join(e,"rapidkit"),493);let s=L();await promises.writeFile(d.join(e,"rapidkit.cmd"),s);let n=b(t.name);if(await promises.writeFile(d.join(e,"README.md"),n),await promises.writeFile(d.join(e,".gitignore"),`# RapidKit workspace
|
|
4
4
|
.env
|
|
5
5
|
.env.*
|
|
6
6
|
!.env.example
|
|
@@ -15,12 +15,13 @@ Thumbs.db
|
|
|
15
15
|
|
|
16
16
|
# Logs
|
|
17
17
|
*.log
|
|
18
|
-
`),await promises.writeFile(d.join(e,".rapidkit-workspace"),JSON.stringify({signature:"RAPIDKIT_WORKSPACE",createdBy:"rapidkit-npm",version:c(),createdAt:new Date().toISOString(),name:t.name},null,2)),await
|
|
18
|
+
`),await promises.writeFile(d.join(e,".rapidkit-workspace"),JSON.stringify({signature:"RAPIDKIT_WORKSPACE",createdBy:"rapidkit-npm",version:c(),createdAt:new Date().toISOString(),name:t.name},null,2)),await I(e),i.succeed("Workspace created!"),!t.skipGit){let m=w("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}),m.succeed("Git repository initialized");}catch{m.warn("Could not initialize git repository");}}await N(e,t.name),console.log(`
|
|
19
19
|
${r.green("\u2728 RapidKit workspace created successfully!")}
|
|
20
20
|
|
|
21
21
|
${r.bold("\u{1F4C2} Workspace structure:")}
|
|
22
22
|
${e}/
|
|
23
23
|
\u251C\u2500\u2500 rapidkit # Local CLI wrapper
|
|
24
|
+
\u251C\u2500\u2500 rapidkit.cmd # Windows local CLI wrapper
|
|
24
25
|
\u251C\u2500\u2500 .rapidkit/ # Workspace configuration
|
|
25
26
|
\u2502 \u251C\u2500\u2500 config.json # Workspace settings
|
|
26
27
|
\u2502 \u2514\u2500\u2500 templates/ # Project templates
|
|
@@ -43,7 +44,7 @@ ${r.bold("\u{1F4DA} Commands:")}
|
|
|
43
44
|
npx rapidkit dev Start dev server
|
|
44
45
|
npx rapidkit help Show all commands
|
|
45
46
|
|
|
46
|
-
${r.gray("Alternative: ./rapidkit dev, make dev")}
|
|
47
|
+
${r.gray("Alternative: ./rapidkit dev (Windows: .\\rapidkit.cmd dev), make dev")}
|
|
47
48
|
${r.gray("\u{1F4A1} Tip: Install globally (npm i -g rapidkit) to use without npx")}
|
|
48
49
|
`);}catch(a){throw i.fail("Failed to create workspace"),a}}function E(){return `#!/usr/bin/env bash
|
|
49
50
|
#
|
|
@@ -393,7 +394,27 @@ main() {
|
|
|
393
394
|
}
|
|
394
395
|
|
|
395
396
|
main "$@"
|
|
396
|
-
`}function
|
|
397
|
+
`}function L(){return `@echo off
|
|
398
|
+
setlocal enabledelayedexpansion
|
|
399
|
+
|
|
400
|
+
set "SCRIPT_DIR=%~dp0"
|
|
401
|
+
|
|
402
|
+
where sh >nul 2>nul
|
|
403
|
+
if %ERRORLEVEL%==0 (
|
|
404
|
+
sh "%SCRIPT_DIR%rapidkit" %*
|
|
405
|
+
exit /b %ERRORLEVEL%
|
|
406
|
+
)
|
|
407
|
+
|
|
408
|
+
where bash >nul 2>nul
|
|
409
|
+
if %ERRORLEVEL%==0 (
|
|
410
|
+
bash "%SCRIPT_DIR%rapidkit" %*
|
|
411
|
+
exit /b %ERRORLEVEL%
|
|
412
|
+
)
|
|
413
|
+
|
|
414
|
+
echo [RapidKit] No sh/bash found. Falling back to npx rapidkit.
|
|
415
|
+
npx rapidkit %*
|
|
416
|
+
exit /b %ERRORLEVEL%
|
|
417
|
+
`}function b(e){return `# ${e}
|
|
397
418
|
|
|
398
419
|
RapidKit workspace for building API projects.
|
|
399
420
|
|
|
@@ -441,7 +462,7 @@ npx rapidkit dev # Start dev server
|
|
|
441
462
|
|
|
442
463
|
- [RapidKit Documentation](https://rapidkit.dev)
|
|
443
464
|
- [GitHub Repository](https://github.com/Baziar/rapidkit)
|
|
444
|
-
`}async function
|
|
465
|
+
`}async function I(e){let{fileURLToPath:t}=await import('url'),i=t(import.meta.url),a=d.dirname(i),o=d.resolve(a,".."),s=d.join(o,"templates","kits"),n=d.join(e,".rapidkit","templates"),{default:p}=await import('fs-extra');await p.copy(s,n);let m=d.join(o,"templates","generator.js"),h=d.join(e,".rapidkit","generator.js");await p.copy(m,h);}async function Y(e,t){let i=t.template==="fastapi",a=i?"FastAPI":"NestJS",o=w(`Creating ${a} project...`).start();try{let{fileURLToPath:s}=await import('url'),n=s(import.meta.url),p=d.dirname(n),m=d.resolve(p,".."),h=i?"fastapi-standard":"nestjs-standard",c$1=d.join(m,"templates","kits",h);await promises.mkdir(e,{recursive:true});let g={project_name:i?t.name.replace(/-/g,"_").toLowerCase():t.name.replace(/_/g,"-").toLowerCase(),author:t.author,description:t.description||`${a} application generated with RapidKit`,app_version:"0.1.0",license:"MIT",package_manager:t.package_manager||"npm",created_at:new Date().toISOString(),rapidkit_version:c()};await x(c$1,e,g);let R=i?`# Python
|
|
445
466
|
__pycache__/
|
|
446
467
|
*.py[cod]
|
|
447
468
|
*$py.class
|
|
@@ -509,7 +530,7 @@ Thumbs.db
|
|
|
509
530
|
|
|
510
531
|
# Coverage
|
|
511
532
|
coverage/
|
|
512
|
-
`;if(await promises.writeFile(d.join(e,".gitignore"),
|
|
533
|
+
`;if(await promises.writeFile(d.join(e,".gitignore"),R),o.succeed(`${a} project created!`),!t.skipGit){let k=w("Initializing git repository...").start();try{await execa("git",["init"],{cwd:e}),await execa("git",["add","."],{cwd:e}),await execa("git",["commit","-m",`Initial commit: ${a} project via RapidKit`],{cwd:e}),k.succeed("Git repository initialized");}catch{k.warn("Could not initialize git repository");}}if(!t.skipInstall&&!i){let k=t.package_manager||"npm",C=w(`Installing dependencies with ${k}...`).start();try{await execa(k,["install"],{cwd:e}),C.succeed("Dependencies installed");}catch{C.warn(`Could not install dependencies. Run '${k} install' manually.`);}}let j=d.basename(e);console.log(i?`
|
|
513
534
|
${r.green("\u2728 FastAPI project created successfully!")}
|
|
514
535
|
|
|
515
536
|
${r.bold("\u{1F4C2} Project structure:")}
|
|
@@ -575,16 +596,16 @@ ${r.bold("\u{1F310} API endpoints:")}
|
|
|
575
596
|
http://localhost:8000/examples/notes # Example API
|
|
576
597
|
|
|
577
598
|
${r.gray("\u{1F4A1} Tip: Install globally (npm i -g rapidkit) to use without npx")}
|
|
578
|
-
`);}catch(
|
|
599
|
+
`);}catch(s){throw o.fail(`Failed to create ${a} project`),s}}async function x(e,t,i){let a=await promises.readdir(e,{withFileTypes:true});for(let o of a){let s=d.join(e,o.name),n=o.name.replace(/\.j2$/,""),p=d.join(t,n);if(o.isDirectory())await promises.mkdir(p,{recursive:true}),await x(s,p,i);else {let m=await promises.readFile(s,"utf-8");o.name.endsWith(".j2")&&(m=D(m,i)),await promises.writeFile(p,m),(n==="rapidkit"||n==="activate"||n.endsWith(".py")&&p.includes(".rapidkit"))&&await promises.chmod(p,493);}}}function D(e,t){let i=e;for(let[a,o]of Object.entries(t)){let s=new RegExp(`\\{\\{\\s*${a}\\s*\\}\\}`,"g");i=i.replace(s,String(o));let n=new RegExp(`\\{\\{\\s*${a}\\s*\\|\\s*replace\\s*\\(\\s*['"]([^'"]+)['"]\\s*,\\s*['"]([^'"]*)['"]\\s*\\)\\s*\\}\\}`,"g");i=i.replace(n,(h,c,g)=>String(o).replace(new RegExp(c,"g"),g));let p=new RegExp(`\\{\\{\\s*${a}\\s*\\|\\s*lower\\s*\\}\\}`,"g");i=i.replace(p,String(o).toLowerCase());let m=new RegExp(`\\{\\{\\s*${a}\\s*\\|\\s*replace\\s*\\(\\s*['"]([^'"]+)['"]\\s*,\\s*['"]([^'"]*)['"]\\s*\\)\\s*\\|\\s*lower\\s*\\}\\}`,"g");i=i.replace(m,(h,c,g)=>String(o).replace(new RegExp(c,"g"),g).toLowerCase());}return i}async function V(){let e=j(),t=d.join(e,"workspaces.json");if(!await promises.stat(t).catch(()=>null)){console.log(r.yellow(`
|
|
579
600
|
\u26A0\uFE0F No workspaces registered yet.
|
|
580
601
|
`)),console.log(r.gray(`Create a workspace with: npx rapidkit <workspace-name>
|
|
581
602
|
`));return}try{let i=await promises.readFile(t,"utf8"),a=JSON.parse(i);if(!a||typeof a!="object"||!Array.isArray(a.workspaces)){console.log(r.yellow(`
|
|
582
603
|
\u26A0\uFE0F Workspace registry is invalid; resetting to empty state.
|
|
583
|
-
`)),await promises.writeFile(t,JSON.stringify({workspaces:[]},null,2));return}let o=v(a),
|
|
604
|
+
`)),await promises.writeFile(t,JSON.stringify({workspaces:[]},null,2));return}let o=v(a),s=[],n=0;for(let c of o.workspaces)await promises.stat(c.path).catch(()=>null)?s.push(c):n+=1;let p={workspaces:s},m=JSON.stringify(a),h=JSON.stringify(p);if(m!==h&&await promises.writeFile(t,JSON.stringify(p,null,2)),!p.workspaces||p.workspaces.length===0){console.log(r.yellow(`
|
|
584
605
|
\u26A0\uFE0F No workspaces registered yet.
|
|
585
606
|
`)),n>0&&console.log(r.gray(`Cleaned ${n} stale workspace entr${n===1?"y":"ies"}.
|
|
586
607
|
`));return}console.log(r.bold(`
|
|
587
608
|
\u{1F4E6} Registered RapidKit Workspaces:
|
|
588
|
-
`));for(let
|
|
609
|
+
`));for(let c of p.workspaces)console.log(r.cyan(` ${c.name}`)),console.log(r.gray(` Path: ${c.path}`)),console.log(r.gray(` Projects: ${c.projects?.length||0}`)),console.log();n>0&&console.log(r.gray(`Cleaned ${n} stale workspace entr${n===1?"y":"ies"}.`)),console.log(r.gray(`Total: ${p.workspaces.length} workspace(s)
|
|
589
610
|
`));}catch(i){console.error(r.red(`
|
|
590
|
-
\u274C Failed to read workspace registry`)),console.error(r.gray(String(i)));}}export{
|
|
611
|
+
\u274C Failed to read workspace registry`)),console.error(r.gray(String(i)));}}export{Y as createProject,G as createWorkspace,V as listWorkspaces,K as registerProjectInWorkspace,N as registerWorkspace,J as syncWorkspaceProjects};
|
package/package.json
CHANGED