rapidkit 0.27.5 → 0.28.0
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 +90 -59
- package/dist/autopilot-release-AITKKEK7.js +7 -0
- package/dist/chunk-2FIX2MDC.js +1 -0
- package/dist/{chunk-ZAZJEYYT.js → chunk-7OGOVP5U.js} +2 -2
- package/dist/chunk-AC6KIKII.js +5 -0
- package/dist/chunk-BFCIY2QK.js +33 -0
- package/dist/chunk-TXJX4GUZ.js +3 -0
- package/dist/chunk-VKLL63TL.js +1 -0
- package/dist/{create-4NQKTQ3C.js → create-TWGGH5XC.js} +8 -8
- package/dist/{demo-kit-HMJZ3A3M.js → demo-kit-KTRITRWH.js} +1 -1
- package/dist/doctor-DDIR7LBO.js +50 -0
- package/dist/{gofiber-standard-JDPREQCP.js → gofiber-standard-TFPNBIMS.js} +1 -1
- package/dist/{gogin-standard-DCERHHVB.js → gogin-standard-7UJ2OBYL.js} +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +88 -87
- package/dist/{pythonRapidkitExec-GPPHN3L4.js → pythonRapidkitExec-4MP62M5R.js} +1 -1
- package/dist/{springboot-standard-AGTOOTNT.js → springboot-standard-H6GYMH3P.js} +1 -1
- package/dist/{workspace-776YW7I6.js → workspace-YKWUI37R.js} +45 -45
- package/dist/workspace-run-OFT4T3NU.js +1 -0
- package/package.json +5 -1
- package/dist/chunk-Q7ULIFQA.js +0 -5
- package/dist/chunk-RWV2GNJJ.js +0 -33
- package/dist/doctor-BGVPFJ5U.js +0 -47
- package/dist/package.json +0 -138
- package/dist/workspace-run-7EGSG2UO.js +0 -3
package/dist/package.json
DELETED
|
@@ -1,138 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "rapidkit",
|
|
3
|
-
"version": "0.27.5",
|
|
4
|
-
"type": "module",
|
|
5
|
-
"description": "Official CLI for RapidKit, an open-source workspace platform that standardizes how teams build, scale, and deploy backend services.",
|
|
6
|
-
"keywords": [
|
|
7
|
-
"rapidkit",
|
|
8
|
-
"workspai",
|
|
9
|
-
"ai",
|
|
10
|
-
"cli",
|
|
11
|
-
"create",
|
|
12
|
-
"fastapi",
|
|
13
|
-
"nestjs",
|
|
14
|
-
"springboot",
|
|
15
|
-
"spring",
|
|
16
|
-
"gofiber",
|
|
17
|
-
"gogin",
|
|
18
|
-
"backend",
|
|
19
|
-
"microservices",
|
|
20
|
-
"generator",
|
|
21
|
-
"scaffold"
|
|
22
|
-
],
|
|
23
|
-
"author": "RapidKit Team",
|
|
24
|
-
"license": "MIT",
|
|
25
|
-
"repository": {
|
|
26
|
-
"type": "git",
|
|
27
|
-
"url": "git+https://github.com/getrapidkit/rapidkit-npm.git"
|
|
28
|
-
},
|
|
29
|
-
"bin": {
|
|
30
|
-
"rapidkit": "dist/index.js"
|
|
31
|
-
},
|
|
32
|
-
"files": [
|
|
33
|
-
"dist",
|
|
34
|
-
"scripts/enforce-package-manager.cjs"
|
|
35
|
-
],
|
|
36
|
-
"scripts": {
|
|
37
|
-
"preinstall": "node scripts/enforce-package-manager.cjs",
|
|
38
|
-
"sync-kits": "bash scripts/sync-kits.sh",
|
|
39
|
-
"build": "tsup",
|
|
40
|
-
"build:watch": "tsup --watch",
|
|
41
|
-
"dev": "tsup --watch",
|
|
42
|
-
"dev:local": "npm run build && npm link",
|
|
43
|
-
"install:local": "npm unlink -g rapidkit && npm run build && npm link",
|
|
44
|
-
"uninstall:local": "npm unlink -g rapidkit",
|
|
45
|
-
"prepare": "husky",
|
|
46
|
-
"test:e2e:first-install": "bash scripts/e2e-first-install.sh",
|
|
47
|
-
"test:e2e:user-first-install": "bash scripts/e2e-user-first-install.sh",
|
|
48
|
-
"test": "vitest run",
|
|
49
|
-
"test:drift": "RAPIDKIT_DRIFT_GUARD=1 vitest run src/__tests__/drift-guard.test.ts",
|
|
50
|
-
"sync:parity-snapshot": "node scripts/sync-import-stack-parity-snapshot.mjs",
|
|
51
|
-
"check:parity-snapshot": "node scripts/sync-import-stack-parity-snapshot.mjs --check",
|
|
52
|
-
"test:parity-contract": "npm run sync:parity-snapshot -- --npm-only && vitest run src/__tests__/contracts/import-stack-parity.snapshot.test.ts",
|
|
53
|
-
"test:watch": "vitest",
|
|
54
|
-
"test:coverage": "vitest run --coverage",
|
|
55
|
-
"test:prepare-embeddings": "npx tsx scripts/generate-mock-embeddings.ts",
|
|
56
|
-
"test:e2e": "vitest run src/__tests__/e2e.test.ts",
|
|
57
|
-
"test:scenarios": "bash scripts/scenario-matrix-local.sh",
|
|
58
|
-
"test:scenarios:full": "RAPIDKIT_SCENARIO_FULL_BOOTSTRAP=1 bash scripts/scenario-matrix-local.sh",
|
|
59
|
-
"test:scenarios:docker": "bash scripts/scenario-matrix.sh",
|
|
60
|
-
"lint": "eslint src --ext .ts",
|
|
61
|
-
"lint:fix": "eslint src --ext .ts --fix",
|
|
62
|
-
"format": "prettier --write \"src/**/*.ts\"",
|
|
63
|
-
"format:check": "prettier --check \"src/**/*.ts\"",
|
|
64
|
-
"typecheck": "tsc --noEmit",
|
|
65
|
-
"validate": "npm run typecheck && npm run lint && npm run format:check && npm test",
|
|
66
|
-
"security": "npm audit --audit-level=moderate",
|
|
67
|
-
"security:fix": "npm audit fix",
|
|
68
|
-
"metrics": "npx tsx scripts/metrics.ts",
|
|
69
|
-
"validate:docs-examples": "node scripts/validate-doc-examples.mjs",
|
|
70
|
-
"check:markdown-links": "node scripts/check-markdown-links.mjs",
|
|
71
|
-
"check:docs-drift": "node scripts/docs-drift-guard.mjs",
|
|
72
|
-
"smoke:readme": "node scripts/smoke-readme-commands.mjs",
|
|
73
|
-
"validate:docs": "npm run check:markdown-links && npm run check:docs-drift && npm run validate:docs-examples && npm run smoke:readme",
|
|
74
|
-
"sync:contracts": "node scripts/sync-contracts.mjs",
|
|
75
|
-
"check:contracts": "node scripts/sync-contracts.mjs --check",
|
|
76
|
-
"bundle-size": "npm run build && du -sh dist/ && ls -lh dist/",
|
|
77
|
-
"analyze": "npm run build && node scripts/analyze-dist.mjs",
|
|
78
|
-
"size-check": "npm run build && size-limit",
|
|
79
|
-
"bench": "npx tsx scripts/benchmarks.ts",
|
|
80
|
-
"quality": "npm run typecheck && npm run lint && npm run format:check && npm test && npm run size-check",
|
|
81
|
-
"act-matrix": "act -P ubuntu-latest=ghcr.io/catthehacker/ubuntu:act-22.04 -P macos-latest=ghcr.io/catthehacker/ubuntu:act-22.04 -P windows-latest=ghcr.io/catthehacker/ubuntu:act-22.04 --pull=false -j build-test-matrix",
|
|
82
|
-
"release:dry": "bash scripts/release.sh --no-publish --yes --allow-dirty",
|
|
83
|
-
"release:patch": "bash scripts/release.sh patch",
|
|
84
|
-
"release:minor": "bash scripts/release.sh minor",
|
|
85
|
-
"release:major": "bash scripts/release.sh major"
|
|
86
|
-
},
|
|
87
|
-
"dependencies": {
|
|
88
|
-
"chalk": "^5.3.0",
|
|
89
|
-
"cli-progress": "^3.12.0",
|
|
90
|
-
"commander": "^12.1.0",
|
|
91
|
-
"execa": "^9.3.1",
|
|
92
|
-
"fs-extra": "^11.2.0",
|
|
93
|
-
"inquirer": "^13.2.2",
|
|
94
|
-
"nunjucks": "^3.2.4",
|
|
95
|
-
"openai": "^6.22.0",
|
|
96
|
-
"ora": "^8.0.1",
|
|
97
|
-
"validate-npm-package-name": "^5.0.1"
|
|
98
|
-
},
|
|
99
|
-
"devDependencies": {
|
|
100
|
-
"@eslint/eslintrc": "^3.3.3",
|
|
101
|
-
"@size-limit/preset-big-lib": "^12.0.0",
|
|
102
|
-
"@types/cli-progress": "^3.11.6",
|
|
103
|
-
"@types/fs-extra": "^11.0.4",
|
|
104
|
-
"@types/inquirer": "^9.0.7",
|
|
105
|
-
"@types/node": "^20.14.0",
|
|
106
|
-
"@types/nunjucks": "^3.2.6",
|
|
107
|
-
"@types/validate-npm-package-name": "^4.0.2",
|
|
108
|
-
"@typescript-eslint/eslint-plugin": "^8.46.2",
|
|
109
|
-
"@typescript-eslint/parser": "^8.46.2",
|
|
110
|
-
"@vitest/coverage-v8": "^4.0.15",
|
|
111
|
-
"@vitest/ui": "^4.0.15",
|
|
112
|
-
"eslint": "^9.39.2",
|
|
113
|
-
"husky": "^9.1.7",
|
|
114
|
-
"lint-staged": "^15.5.2",
|
|
115
|
-
"prettier": "^3.6.2",
|
|
116
|
-
"size-limit": "^12.0.0",
|
|
117
|
-
"tsup": "^8.5.0",
|
|
118
|
-
"typescript": "^5.5.0",
|
|
119
|
-
"vite-bundle-visualizer": "^1.2.1",
|
|
120
|
-
"vitest": "^4.0.15"
|
|
121
|
-
},
|
|
122
|
-
"optionalDependencies": {
|
|
123
|
-
"@rollup/rollup-win32-x64-msvc": "*"
|
|
124
|
-
},
|
|
125
|
-
"engines": {
|
|
126
|
-
"node": ">=20.19.6"
|
|
127
|
-
},
|
|
128
|
-
"lint-staged": {
|
|
129
|
-
"*.ts": [
|
|
130
|
-
"eslint --fix",
|
|
131
|
-
"prettier --write"
|
|
132
|
-
]
|
|
133
|
-
},
|
|
134
|
-
"overrides": {
|
|
135
|
-
"minimatch": "^10.2.1"
|
|
136
|
-
},
|
|
137
|
-
"packageManager": "npm@10.8.2"
|
|
138
|
-
}
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import {e,d,a,b}from'./chunk-TYC54P7X.js';import v from'fs';import m from'path';import R from'chalk';import {execa}from'execa';var ue={"python-fastapi":{runtime:"python",framework:"FastAPI",markers:["pyproject.toml","fastapi"],commands:{init:"python -m pip install -e .",test:"pytest",build:"python -m build",start:"uvicorn main:app --reload"},errorPatterns:{setup:["ModuleNotFoundError","No module named","pip: command not found"],"test-failure":["FAILED","ERROR","test session started"],dependency:["ImportError","missing.*dependency"],runtime:["TypeError","AttributeError","ValueError"],timeout:["timeout","Timeout","timed out"],unknown:[]},healthCheck:{stage:"start",type:"http",value:"http://localhost:8000/docs"},validation:{command:"python -m pip list | grep fastapi",error:"FastAPI not installed"}},"python-django":{runtime:"python",framework:"Django",markers:["manage.py","django"],commands:{init:"python manage.py migrate",test:"python manage.py test",build:"python manage.py collectstatic --noinput",start:"python manage.py runserver 0.0.0.0:8000"},errorPatterns:{setup:["ModuleNotFoundError","ProgrammingError.*migrate"],"test-failure":["FAILED","ERROR","Ran.*test"],dependency:["ImportError","missing.*dependency"],runtime:["DatabaseError","ImproperlyConfigured"],timeout:["timeout","Timeout"],unknown:[]},healthCheck:{stage:"start",type:"port",value:8e3},dependencies:["init"]},"node-nestjs":{runtime:"node",framework:"NestJS",markers:["package.json","@nestjs/core"],commands:{init:"npm install",test:"npm run test",build:"npm run build",start:"npm run start"},errorPatterns:{setup:["npm ERR!","ENOENT","not found"],"test-failure":["Tests.*failed","FAIL","fail.*test"],dependency:["Cannot find module","ERR_MODULE_NOT_FOUND"],runtime:["TypeError","Error: ","ReferenceError"],timeout:["timeout","TIMEOUT"],unknown:[]},healthCheck:{stage:"start",type:"port",value:3e3}},"node-express":{runtime:"node",framework:"Express",markers:["package.json","express"],commands:{init:"npm install",test:"npm run test",build:"npm run build",start:"npm start"},errorPatterns:{setup:["npm ERR!","ENOENT"],"test-failure":["failed","FAIL"],dependency:["Cannot find module"],runtime:["Error","TypeError"],timeout:["timeout"],unknown:[]}},"go-fiber":{runtime:"go",framework:"Fiber",markers:["go.mod","fiber"],commands:{init:"go mod download && go mod tidy",test:"go test ./...",build:"go build -o app .",start:"./app"},errorPatterns:{setup:["go: .*not found","cannot find","go mod tidy"],"test-failure":["FAIL","--- FAIL"],dependency:["missing.*module"],runtime:["panic","fatal","Error"],timeout:["timeout","context deadline"],unknown:[]},dependencies:["init"]},"go-gin":{runtime:"go",framework:"Gin",markers:["go.mod","gin-gonic"],commands:{init:"go mod download && go mod tidy",test:"go test ./...",build:"go build -o app .",start:"./app"},errorPatterns:{setup:["go: .*not found"],"test-failure":["FAIL"],dependency:["missing.*module"],runtime:["panic"],timeout:["timeout"],unknown:[]}},"java-springboot":{runtime:"java",framework:"Spring Boot",markers:["pom.xml","build.gradle","spring-boot"],commands:{init:"mvn dependency:go-offline",test:"mvn test",build:"mvn package -DskipTests",start:"mvn spring-boot:run"},errorPatterns:{setup:["\\[ERROR\\]","BUILD FAILURE","missing dependencies"],"test-failure":["\\[ERROR\\] Tests run:","BUILD FAILURE"],dependency:["missing.*dependency"],runtime:["Exception","Error","NullPointerException"],timeout:["timeout","Timeout"],unknown:[]},healthCheck:{stage:"start",type:"port",value:8080}},"php-laravel":{runtime:"php",framework:"Laravel",markers:["composer.json","artisan","app/Models"],commands:{init:"composer install && php artisan migrate:fresh --seed",test:"php artisan test",build:"php artisan config:cache && php artisan route:cache && php artisan view:cache",start:"php artisan serve --host=0.0.0.0 --port=8000"},errorPatterns:{setup:["Composer.*lock","Fatal error","Class.*not found"],"test-failure":["FAILED","Tests.*failed"],dependency:["Class.*not found","require.*failed"],runtime:["Fatal error","Exception","Error"],timeout:["timeout","Timeout"],unknown:[]},healthCheck:{stage:"start",type:"port",value:8e3},dependencies:["init"]},"php-symfony":{runtime:"php",framework:"Symfony",markers:["composer.json","symfony.lock","bin/console"],commands:{init:"composer install && php bin/console doctrine:database:create",test:"php bin/phpunit",build:"php bin/console cache:clear --env=prod",start:"symfony serve --no-tls"},errorPatterns:{setup:["Composer.*error","Fatal error"],"test-failure":["FAILED","failure"],dependency:["Class.*not found"],runtime:["Fatal error","Exception"],timeout:["timeout"],unknown:[]},dependencies:["init"]},"rust-actix":{runtime:"rust",framework:"Actix-web",markers:["Cargo.toml","actix"],commands:{init:"cargo fetch",test:"cargo test",build:"cargo build --release",start:"cargo run --release"},errorPatterns:{setup:["error: .*could not find","failed.*download"],"test-failure":["test result:","FAILED"],dependency:["can.t find.*crate"],runtime:["error\\[E","thread.*panicked"],timeout:["timeout"],unknown:[]},validation:{command:"cargo --version",error:"Rust/Cargo not installed"}},"rust-axum":{runtime:"rust",framework:"Axum",markers:["Cargo.toml","axum"],commands:{init:"cargo fetch",test:"cargo test",build:"cargo build --release",start:"cargo run --release"},errorPatterns:{setup:["error: .*could not find"],"test-failure":["test result:","FAILED"],dependency:["can.t find.*crate"],runtime:["error\\[E"],timeout:["timeout"],unknown:[]}},"rust-rocket":{runtime:"rust",framework:"Rocket",markers:["Cargo.toml","rocket"],commands:{init:"cargo fetch",test:"cargo test",build:"cargo build --release",start:"cargo run --release"},errorPatterns:{setup:["error: .*could not find"],"test-failure":["FAILED"],dependency:["can.t find"],runtime:["error\\[E"],timeout:["timeout"],unknown:[]}},"dotnet-aspnetcore":{runtime:"dotnet",framework:"ASP.NET Core",markers:[".csproj",".sln","Program.cs"],commands:{init:"dotnet restore",test:"dotnet test",build:"dotnet build -c Release",start:"dotnet run"},errorPatterns:{setup:["error CS","CSPROJ.*not found","NuGet.*restore"],"test-failure":["Failed:.*test","FAILED"],dependency:["error NU1101"],runtime:["error CS","Exception"],timeout:["timeout"],unknown:[]},healthCheck:{stage:"start",type:"port",value:5e3}},"elixir-phoenix":{runtime:"elixir",framework:"Phoenix",markers:["mix.exs","phoenix"],commands:{init:"mix setup",test:"mix test",build:"mix compile --all-warnings",start:"mix phx.server"},errorPatterns:{setup:["\\*\\* \\(.*Error\\)","Mix.InstallError"],"test-failure":["\\d+\\sfailed","FAILED"],dependency:["dependencies are not available"],runtime:["\\*\\* \\(","RuntimeError"],timeout:["timeout"],unknown:[]},healthCheck:{stage:"start",type:"port",value:4e3},dependencies:["init"]},"ruby-rails":{runtime:"ruby",framework:"Rails",markers:["Gemfile","config/application.rb","bin/rails"],commands:{init:"bundle install && rails db:prepare",test:"rails test",build:"rails assets:precompile",start:"rails server --binding=0.0.0.0 --port=3000"},errorPatterns:{setup:["Bundler::.*Error","Gem::.*Error"],"test-failure":["failures,","error,","FAILED"],dependency:["Could not find.*gem"],runtime:["Error","Exception","NoMethodError"],timeout:["timeout"],unknown:[]},healthCheck:{stage:"start",type:"port",value:3e3},dependencies:["init"]},"ruby-sinatra":{runtime:"ruby",framework:"Sinatra",markers:["Gemfile","app.rb","sinatra"],commands:{init:"bundle install",test:"rspec",build:`echo "Sinatra apps don't require build"`,start:"ruby app.rb"},errorPatterns:{setup:["Bundler.*Error","Gem.*Error"],"test-failure":["failure","FAILED"],dependency:["Could not find.*gem"],runtime:["Error","NoMethodError"],timeout:["timeout"],unknown:[]}}},ce={init:{python:["pip install -e .","poetry install","pip install -r requirements.txt"],node:["npm install","pnpm install","yarn install"],go:["go mod download && go mod tidy","go get ./..."],java:["mvn dependency:go-offline","gradle dependencies"],php:["composer install"],rust:["cargo fetch"],dotnet:["dotnet restore"],elixir:["mix deps.get"],ruby:["bundle install"],"jvm-generic":["mvn dependency:go-offline","gradle dependencies"],unknown:[]},test:{python:["pytest","python -m unittest","python -m pytest"],node:["npm test","npm run test"],go:["go test ./...","make test"],java:["mvn test","gradle test"],php:["php artisan test","phpunit","pest"],rust:["cargo test"],dotnet:["dotnet test"],elixir:["mix test"],ruby:["rspec","ruby -m minitest"],"jvm-generic":["mvn test","gradle test"],unknown:[]},build:{python:["python -m build","python setup.py build"],node:["npm run build"],go:["go build -o app .","go build ./..."],java:["mvn package -DskipTests","gradle build -x test"],php:['echo "PHP build: typically no build step"'],rust:["cargo build --release"],dotnet:["dotnet build -c Release"],elixir:["mix compile"],ruby:["gem build *.gemspec"],"jvm-generic":["mvn package -DskipTests","gradle build"],unknown:[]},start:{python:["python app.py","python main.py","uvicorn main:app --reload"],node:["npm start","node index.js","node src/index.js"],go:["./app","go run main.go","go run ./..."],java:["mvn spring-boot:run","gradle bootRun","java -jar target/*.jar"],php:["php -S 0.0.0.0:8000","php artisan serve"],rust:["cargo run --release","./target/release/app"],dotnet:["dotnet run"],elixir:["mix phx.server","iex -S mix"],ruby:["rails server","ruby app.rb","bundle exec puma"],"jvm-generic":["java -jar *.jar","gradle run"],unknown:[]}};function z(e,r,t){if(r){let n=r.trim().toLowerCase().replace(/[_.\s]+/g,"-"),c=a(r),s=`${e}-${c==="gofiber"?"fiber":c==="gogin"?"gin":c==="dotnet"?"aspnetcore":c!=="unknown"?c:n==="fiber"?"fiber":n==="aspnetcore"||n==="asp-net-core"?"aspnetcore":n}`,o=ue[s];if(o&&o.commands[t])return o.commands[t]}let a$1=ce[t]?.[e]??[];return a$1.length>0?a$1[0]:void 0}function de(e){let r=d(e).map(t=>t==="python"?"python":t==="node"||t==="bun"?"node":t==="go"?"go":t==="java"?"java":t==="php"?"php":t==="rust"?"rust":t==="dotnet"?"dotnet":t==="elixir"?"elixir":t==="ruby"?"ruby":t==="clojure"||t==="scala"||t==="kotlin"?"jvm-generic":null).filter(t=>t!==null).filter((t,a,n)=>n.indexOf(t)===a);return {primary:r.length>0?r[0]:"unknown",secondary:r.slice(1)}}function q(e){return de(e).primary}function Y(e,r){if(!e)return "unknown";r||(r={setup:["ModuleNotFoundError","npm ERR!","error:","not found"],"test-failure":["FAILED","FAIL","failed"],dependency:["cannot find module","import.*error"],runtime:["Exception","Error:","panic","TypeError"],timeout:["timeout","Timeout","deadline exceeded"],unknown:[]});for(let[t,a]of Object.entries(r))for(let n of a)if(new RegExp(n,"i").test(e))return t;return "unknown"}async function Q(e){let r=e.split(/[&|;]\s*/)[0].trim().split(/\s+/)[0];if(["echo","cd","pwd","test","true","false","exit"].includes(r))return {valid:true};try{let a=process.platform==="win32"?"where":"which";if((await execa(a,[r],{reject:false})).exitCode===0)return {valid:true}}catch{}return {valid:false,reason:`Command '${r}' not found or not executable`}}function X(e,r,t){return r?t&&typeof r[t]=="string"?r[t]:typeof r.default=="string"?r.default:e:e}var le=new Set(["init","test","build","start"]),me=new Set([".git","node_modules",".rapidkit",".venv","dist","build","coverage","htmlcov"]);async function O(e){try{return await v.promises.access(e,v.constants.F_OK),true}catch{return false}}async function pe(e){let r=await v.promises.readFile(e,"utf-8");return JSON.parse(r)}async function fe(e,r){await v.promises.mkdir(m.dirname(e),{recursive:true}),await v.promises.writeFile(e,`${JSON.stringify(r,null,2)}
|
|
2
|
-
`,"utf-8");}function M(e){return e.replace(/\\/g,"/")}async function ge(e){let r=new Set,t=m.resolve(e);async function a(n){let c;try{c=await v.promises.readdir(n,{withFileTypes:true});}catch{return}if(await O(m.join(n,".rapidkit","context.json"))||await O(m.join(n,".rapidkit","project.json"))){r.add(m.resolve(n));return}if(m.resolve(n)!==t&&d(n).length>0){r.add(m.resolve(n));return}for(let i of c){if(!i.isDirectory()||me.has(i.name))continue;let s=m.join(n,i.name);await a(s);}}return await a(m.resolve(e)),[...r].sort((n,c)=>n.localeCompare(c))}async function ye(e,r,t){let a=await execa("git",["diff","--name-only",`${t}...HEAD`],{cwd:e,reject:false});if(a.exitCode!==0)return new Set(r);let n=a.stdout.split(/\r?\n/).map(i=>i.trim()).filter(i=>i.length>0).map(i=>M(i));if(n.length===0)return new Set;let c=new Set;for(let i of r){let s=M(m.relative(e,i));if(!s||s===".")continue;let o=`${s}/`;n.some(p=>p===s||p.startsWith(o))&&c.add(i);}return c}async function he(e,r,t){let a=m.join(e,".rapidkit","workspace-dependency-graph.json");if(!await O(a))return {expanded:t,graphStatus:"missing",expansionDepth:0};let n;try{n=await pe(a);}catch{return {expanded:t,graphStatus:"invalid",expansionDepth:0}}let c=new Set(r.map(g=>m.resolve(g))),i=new Map;if(!n||typeof n!="object"||Array.isArray(n))return {expanded:t,graphStatus:"invalid",expansionDepth:0};let s=Array.isArray(n.projects)?n.projects:[];for(let g of s){if(!g||typeof g!="object"||Array.isArray(g))continue;let h=g,b=typeof h.path=="string"?h.path:"",l=m.resolve(e,b);if(!c.has(l))continue;let y=Array.isArray(h.dependsOn)?h.dependsOn.filter(E=>typeof E=="string"):[];for(let E of y){let C=m.resolve(e,E);c.has(C)&&(i.has(C)||i.set(C,new Set),i.get(C)?.add(l));}}let o=new Set(t),p=[...o],k=0;for(;p.length>0;){let g=p.shift();if(!g)continue;let h=i.get(g);if(h)for(let b of h)o.has(b)||(o.add(b),p.push(b),k+=1);}return {expanded:o,graphStatus:"loaded",expansionDepth:k}}async function ke(e,r){if(typeof r=="boolean")return r;let t=m.join(e,".rapidkit","policies.yml");if(!await O(t))return true;let a="";try{a=await v.promises.readFile(t,"utf-8");}catch{return true}let n=a.match(/^[\t ]*rules\.enforce_workspace_run_gates:\s*(true|false)\s*(?:#.*)?$/m);return n?n[1]==="true":true}async function N(e,r){let t=process.argv[1];if(!t)return {exitCode:1,stdout:"",stderr:"RapidKit entrypoint is unavailable for nested workspace-run execution."};let a=await execa(process.execPath,[t,...e],{cwd:r,reject:false,env:{...process.env,RAPIDKIT_WORKSPACE_RUN_CHILD:"1"}});return {exitCode:Number(a.exitCode??1),stdout:a.stdout,stderr:a.stderr}}function we(e){return e==="node"||e==="go"||e==="java"||e==="python"}function be(){return process.env.VITEST==="true"||process.env.VITEST==="1"||process.env.NODE_ENV==="test"}async function xe(e){let r=process.cwd();try{process.chdir(e);let{handleInitCommand:t}=await import('./index.js');return {exitCode:await t(["init"]),stdout:"",stderr:""}}finally{process.chdir(r);}}async function Re(e$1){let r=s=>{let o=b(s);return o==="node"||o==="bun"?"node":o==="python"?"python":o==="go"?"go":o==="java"?"java":o==="php"?"php":o==="ruby"?"ruby":o==="rust"?"rust":o==="dotnet"?"dotnet":o==="elixir"?"elixir":o==="clojure"||o==="scala"||o==="kotlin"?"jvm-generic":q(e$1)},t=s=>{if(!s)return;let o=a(s);if(new Set(["fastapi","django","flask","nestjs","express","fastify","koa","gofiber","gogin","echo","springboot","laravel","symfony","rails","sinatra","dotnet","actix","axum","rocket","phoenix"]).has(o))return o},a$1=m.join(e$1,".rapidkit","context.json");if(v.existsSync(a$1))try{let s=JSON.parse(v.readFileSync(a$1,"utf-8"));if(typeof s.runtime=="string"){let o={};if(s.commands&&typeof s.commands=="object")for(let[p,k]of Object.entries(s.commands))typeof k=="string"&&(o[p]=k);return {runtime:r(s.runtime),framework:t(typeof s.framework=="string"?s.framework:void 0),commandOverrides:Object.keys(o).length>0?o:void 0,environment:typeof s.environment=="string"?s.environment:void 0}}}catch{}let n=e(e$1),c=r(n.runtime),i=t(n.key);return {runtime:c,framework:i}}async function ve(e,r,t,a,n,c){let i=!n?.[r]&&we(t),s;if(n&&n[r]?s=n[r]:i?s=`rapidkit ${r}`:s=z(t,a,r),!s)return {exitCode:127,command:`<stage not supported for ${t}>`,message:`No stage command found for runtime '${t}' and framework '${a||"unknown"}'`,errorCategory:"runtime"};let o=X(s,n,c);if(!o)return {exitCode:127,command:s,message:"Failed to resolve stage command",errorCategory:"runtime"};if(!i){let l=await Q(o);if(!l.valid)return {exitCode:127,command:o,message:l.reason||"Command not available",errorCategory:"setup"}}let p=0,k="",g="",h;try{let l=i?r==="init"&&be()?await xe(e):await N([r],e):await execa(o,[],{cwd:e,reject:false,shell:true});if(p=Number(l.exitCode??0),k=l.stdout,g=l.stderr,p!==0){let y=`${k}
|
|
3
|
-
${g}`;h=Y(y);}}catch(l){return {exitCode:1,command:o,message:l instanceof Error?l.message:"Command execution failed",errorCategory:"runtime"}}return {exitCode:p,command:o,errorCategory:h,healthStatus:void 0,message:p!==0?`Stage failed with exit code ${p}`:void 0}}function Z(e){try{return JSON.parse(e)}catch{return null}}async function Ee(e){let r=[],t=await N(["doctor","workspace","--json"],e);if(t.exitCode!==0)r.push({gate:"doctor-workspace",status:"fail",summary:"doctor workspace command failed"});else {let c=Z(t.stdout)?.healthScore,i=Number(c?.errors??0);Number.isFinite(i)&&i>0?r.push({gate:"doctor-workspace",status:"fail",summary:`doctor workspace reports ${i} error(s)`}):r.push({gate:"doctor-workspace",status:"pass",summary:"doctor workspace passed"});}let a=await N(["readiness","--json"],e);if(a.exitCode!==0)r.push({gate:"readiness",status:"fail",summary:"readiness command failed"});else {let n=Z(a.stdout),c=String(n?.overallStatus??"").toLowerCase();c==="fail"?r.push({gate:"readiness",status:"fail",summary:"readiness overall status is fail"}):c==="warn"?r.push({gate:"readiness",status:"warn",summary:"readiness overall status is warn"}):r.push({gate:"readiness",status:"pass",summary:"readiness overall status is pass"});}return r}function Ce(e){return le.has(e)}function Se(e,r){let t=Math.max(1,Math.min(4,r)),a=Number(e??t);return Number.isFinite(a)?Math.max(1,Math.min(16,Math.trunc(a))):t}async function Be(e){if(!Ce(e.stage))throw new Error(`Unsupported workspace run stage: ${e.stage}`);let r=Date.now(),t=m.resolve(e.workspacePath),a=await ge(t),n=e.affected===true,c=e.blastRadius===true,i=e.since?.trim()||"HEAD~1",s=n?await ye(t,a,i):new Set(a),o,p="not-applicable",k=0,g="all";if(n&&c){let u=await he(t,a,s);o=u.expanded,p=u.graphStatus,k=u.expansionDepth,g="affected+blast-radius";}else n?(o=s,g="affected"):(o=s,g="all");let h=e.stage==="init"?false:await ke(t,e.enforceGates),b=h?await Ee(t):[{gate:"doctor-workspace",status:"skipped",summary:"workspace run gates disabled"},{gate:"readiness",status:"skipped",summary:"workspace run gates disabled"}],l=b.find(u=>u.status==="fail"),y=a.filter(u=>o.has(u)),E=e.continueOnError===true,C=e.parallel===true,W=Se(e.maxWorkers,y.length),T=y.length,$=0;e.json||console.log(R.gray(`Workspace run (${e.stage}) started: ${T} target(s), ${C?`parallel x${W}`:"sequential"}`));let S=new Map;for(let u of a)S.set(u,{path:u,relativePath:M(m.relative(t,u)),selected:o.has(u),affected:o.has(u),status:(o.has(u),"skipped"),exitCode:null,durationMs:0,reason:o.has(u)?void 0:"not affected",framework:void 0,runtimeDetected:void 0,executionCommand:void 0});if(l)for(let u of y){let f=S.get(u);f&&(f.status="skipped",f.reason=`blocked by ${l.gate}`);}else {let u=async f=>{let d=S.get(f);if(!d)return;let P=M(m.relative(t,f));e.json||console.log(R.gray(`\u23F3 [${$}/${T}] ${e.stage} ${P}`)),d.selected=true,d.affected=true;let j=Date.now(),{runtime:w,framework:x,commandOverrides:te,environment:re}=await Re(f);d.runtimeDetected=w,d.framework=x;let F=await ve(f,e.stage,w,x,te,re);if(d.executionCommand=F.command,d.errorCategory=F.errorCategory,d.healthStatus=F.healthStatus,d.durationMs=Date.now()-j,d.exitCode=F.exitCode,F.exitCode===0?(d.status="passed",d.reason=void 0):(d.status="failed",d.reason=F.message||"stage command failed",d.errorMessage=F.message),$+=1,!e.json){let ne=T>0?Math.round($/T*100):100,oe=d.status==="passed"?R.green("\u2705"):R.red("\u274C");console.log(R.gray(`${oe} [${$}/${T}] (${ne}%) ${P} ${d.durationMs}ms`));}};if(C&&y.length>1){let f=0,d=false,P=new Array(W).fill(null).map(async()=>{for(;f<y.length;){if(d&&!E)return;let j=f;f+=1;let w=y[j];await u(w),S.get(w)?.status==="failed"&&(d=true);}});if(await Promise.all(P),!E&&d){let j=false;for(let w of y){let x=S.get(w);if(x){if(x.status==="failed"){j=true;continue}j&&x.status==="skipped"&&(x.reason=x.reason||"stopped after failure");}}}}else for(let f of y){await u(f);let d=S.get(f);if(!E&&d?.status==="failed"){let P=y.slice(y.indexOf(f)+1);for(let j of P){let w=S.get(j);w&&(w.status="skipped",w.reason="stopped after failure");}break}}}let A=[];for(let u of a){let f=S.get(u);f&&A.push(f);}let B=A.filter(u=>u.status==="passed").length,L=A.filter(u=>u.status==="failed").length,_=A.filter(u=>u.status==="skipped").length,H=e.strict===true,ee=L>0||H&&b.some(u=>u.status!=="pass")?1:0,V={schemaVersion:"1.0",workspacePath:t,stage:e.stage,generatedAt:new Date().toISOString(),durationMs:Date.now()-r,options:{affected:n,blastRadius:c,since:n?i:null,parallel:C,maxWorkers:W,continueOnError:E,strict:H,enforceGates:h},selection:{mode:g,since:n?i:null,graphStatus:p,expansionDepth:k},gates:{enforced:h,results:b,blocked:!!l,blockingGate:l?.gate},summary:{projectCount:a.length,selectedCount:y.length,passed:B,failed:L,skipped:_,exitCode:ee},projects:A},J=m.join(t,".rapidkit","reports","workspace-run-last.json");return await fe(J,V),e.json||(l&&(console.log(R.red(`\u274C Workspace run blocked by ${l.gate}`)),console.log(R.gray(` ${l.summary}`))),console.log(R.cyan(`Workspace run (${e.stage}) => passed: ${B}, failed: ${L}, skipped: ${_}`)),console.log(R.gray(`Report: ${J}`))),V}export{Be as runWorkspaceStage};
|