rapidkit 0.25.5 → 0.25.7

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.
@@ -0,0 +1,5 @@
1
+ import {a}from'./chunk-VM2TOHNX.js';import {execa}from'execa';import l from'chalk';import {createRequire}from'module';import {promises}from'fs';import m from'path';import f from'os';var v="rapidkit",w=createRequire(import.meta.url),A=w("../package.json"),i=A?.version??"0.0.0";function g(r){let e=r.trim().match(/^(\d+)\.(\d+)\.(\d+)(?:-([0-9A-Za-z.-]+))?(?:\+[0-9A-Za-z.-]+)?$/);if(!e)return null;let t=e[4]?e[4].split(".").map(o=>o.match(/^\d+$/)?Number(o):o):[];return {major:Number(e[1]),minor:Number(e[2]),patch:Number(e[3]),prerelease:t}}function b(r,n){let e=g(r),t=g(n);if(!e||!t)return 0;if(e.major!==t.major)return e.major>t.major?1:-1;if(e.minor!==t.minor)return e.minor>t.minor?1:-1;if(e.patch!==t.patch)return e.patch>t.patch?1:-1;if(e.prerelease.length===0&&t.prerelease.length===0)return 0;if(e.prerelease.length===0)return 1;if(t.prerelease.length===0)return -1;let o=Math.max(e.prerelease.length,t.prerelease.length);for(let u=0;u<o;u+=1){let a=e.prerelease[u],s=t.prerelease[u];if(a===void 0)return -1;if(s===void 0)return 1;if(a===s)continue;let d=typeof a=="number",h=typeof s=="number";return d&&h?a>s?1:-1:d?-1:h||String(a)>String(s)?1:-1}return 0}var C=14400*1e3;function k(){let r=process.env.RAPIDKIT_CACHE_DIR?.trim()||(process.env.VITEST_WORKER_ID?m.join(f.homedir(),".rapidkit","cache",`vitest-${process.env.VITEST_WORKER_ID}`):m.join(f.homedir(),".rapidkit","cache"));return m.join(r,"update-check.json")}async function _(){try{let r=await promises.readFile(k(),"utf-8"),n=JSON.parse(r);return typeof n.latestVersion=="string"&&typeof n.checkedAt=="number"&&n.currentVersion===i&&Date.now()-n.checkedAt<C?n:null}catch{return null}}async function U(r){try{let n=k();await promises.mkdir(m.dirname(n),{recursive:true}),await promises.writeFile(n,JSON.stringify({latestVersion:r,checkedAt:Date.now(),currentVersion:i}),"utf-8");}catch{}}async function S(){try{a.debug("Checking for updates...");let r=await _();if(r){let t=Math.round((Date.now()-r.checkedAt)/6e4);a.debug(`Update check: cache hit (${t}m old)`),b(r.latestVersion,i)>0&&(console.log(l.yellow(`
2
+ \u26A0\uFE0F Update available: ${i} \u2192 ${r.latestVersion}`)),console.log(l.cyan(`Run: npm install -g rapidkit@latest
3
+ `)));return}let{stdout:n}=await execa("npm",["view",v,"version"],{timeout:3e3}),e=n.trim();await U(e),e&&b(e,i)>0?(console.log(l.yellow(`
4
+ \u26A0\uFE0F Update available: ${i} \u2192 ${e}`)),console.log(l.cyan(`Run: npm install -g rapidkit@latest
5
+ `))):a.debug("You are using the latest version");}catch{a.debug("Could not check for updates");}}function x(){return i}export{S as a,x as b};
@@ -0,0 +1,160 @@
1
+ import {promises}from'fs';import r from'path';var g="1.24",i="github.com/air-verse/air@v1.52.3",a="github.com/swaggo/swag/cmd/swag@v1.16.3",n="main.go -d cmd/server,internal/handlers,internal/apierr -o docs --parseDependency";function u(e){return e.split(/[-_\s]+/).map(t=>t.charAt(0).toUpperCase()+t.slice(1)).join("")}async function $(e,t){await promises.mkdir(r.dirname(e),{recursive:true}),await promises.writeFile(e,t,"utf8");}function h(e){let t=e.includeLintAndFmt?`
2
+ lint:
3
+ @command -v golangci-lint >/dev/null 2>&1 || (echo "golangci-lint not found. Install: https://golangci-lint.run/usage/install/" && exit 1)
4
+ golangci-lint run ./...
5
+
6
+ fmt:
7
+ gofmt -w .
8
+ `:"";return `.PHONY: dev run build test cover${e.includeLintAndFmt?" lint fmt":""} tidy docs docker-up docker-down
9
+
10
+ # Build-time metadata
11
+ VERSION ?= $(shell git describe --tags --always --dirty 2>/dev/null || echo "dev")
12
+ COMMIT ?= $(shell git rev-parse --short HEAD 2>/dev/null || echo "none")
13
+ DATE ?= $(shell date -u +"%Y-%m-%dT%H:%M:%SZ")
14
+ LDFLAGS = -ldflags "-s -w -X main.version=$(VERSION) -X main.commit=$(COMMIT) -X main.date=$(DATE)"
15
+ # Go tool binaries are installed to GOPATH/bin; include it so \`air\` and \`swag\` are found.
16
+ GOBIN ?= $(shell go env GOPATH)/bin
17
+
18
+ # Hot reload \u2014 installs pinned air version on first use
19
+ dev:
20
+ @test -x "$(GOBIN)/air" || go install ${i}
21
+ ${e.devCommand}
22
+
23
+ run:
24
+ ${e.runCommand}
25
+
26
+ build:
27
+ go build $(LDFLAGS) -o bin/${e.projectName} ./cmd/server
28
+
29
+ test:
30
+ ${e.testCommand}
31
+
32
+ cover:
33
+ ${e.testCommand.replace("./... -v -race","./... -race -coverprofile=coverage.out").replace("GIN_MODE=test ","GIN_MODE=test ")}
34
+ go tool cover -html=coverage.out -o coverage.html
35
+ @echo "Coverage report: coverage.html"
36
+
37
+ # Generate Swagger docs \u2014 installs pinned swag version on first use
38
+ docs:
39
+ @test -x "$(GOBIN)/swag" || go install ${a}
40
+ $(GOBIN)/swag init -g ${n}${t}
41
+ tidy:
42
+ go mod tidy
43
+
44
+ docker-up:
45
+ go mod tidy
46
+ docker compose up --build \\
47
+ --build-arg VERSION=$(VERSION) \\
48
+ --build-arg COMMIT=$(COMMIT) \\
49
+ --build-arg DATE=$(DATE) \\
50
+ -d
51
+
52
+ docker-down:
53
+ docker compose down
54
+ `}function p(e){return `#!/usr/bin/env sh
55
+ # RapidKit ${e.runtimeLabel} project launcher \u2014 generated by RapidKit CLI
56
+ # https://getrapidkit.com
57
+
58
+ SCRIPT_DIR=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)
59
+ CMD="\${1:-}"
60
+ shift 2>/dev/null || true
61
+
62
+ case "$CMD" in
63
+ init)
64
+ cd "$SCRIPT_DIR"
65
+ echo "\u{1F439} Initializing ${e.runtimeLabel} project\u2026"
66
+ GOBIN="$(go env GOPATH)/bin"
67
+ echo " \u2192 installing air (hot reload)\u2026"
68
+ go install ${i} 2>/dev/null && echo " \u2713 air" || echo " \u26A0 air install failed (run: go install ${i})"
69
+ echo " \u2192 installing swag (swagger)\u2026"
70
+ go install ${a} 2>/dev/null && echo " \u2713 swag" || echo " \u26A0 swag install failed (run: go install ${a})"
71
+ if [ ! -f ".env" ] && [ -f ".env.example" ]; then
72
+ cp .env.example .env && echo " \u2713 .env created from .env.example"
73
+ fi
74
+ go mod tidy && echo " \u2713 go mod tidy"
75
+ echo " \u2192 generating swagger docs (first build)\u2026"
76
+ "$(go env GOPATH)/bin/swag" init -g ${n} 2>/dev/null \\
77
+ && echo " \u2713 swagger docs generated" \\
78
+ || echo " \u26A0 swagger docs skipped (run: rapidkit docs)"
79
+ echo "\u2705 Ready \u2014 run: rapidkit dev"
80
+ ;;
81
+ dev)
82
+ cd "$SCRIPT_DIR"
83
+ echo "\u{1F4D6} Syncing swagger docs\u2026"
84
+ "$(go env GOPATH)/bin/swag" init -g ${n} 2>/dev/null || true
85
+ if [ -f "$SCRIPT_DIR/Makefile" ]; then
86
+ exec make -C "$SCRIPT_DIR" dev "$@"
87
+ else
88
+ ${e.fallbackDevCommand}
89
+ fi
90
+ ;;
91
+ start)
92
+ BIN="$SCRIPT_DIR/bin/${e.projectName}"
93
+ if [ ! -f "$BIN" ]; then
94
+ make -C "$SCRIPT_DIR" build
95
+ fi
96
+ exec "$BIN" "$@"
97
+ ;;
98
+ build)
99
+ exec make -C "$SCRIPT_DIR" build "$@"
100
+ ;;
101
+ test)
102
+ exec make -C "$SCRIPT_DIR" test "$@"
103
+ ;;
104
+ lint)
105
+ exec make -C "$SCRIPT_DIR" lint "$@"
106
+ ;;
107
+ format|fmt)
108
+ exec make -C "$SCRIPT_DIR" fmt "$@"
109
+ ;;
110
+ docs)
111
+ exec make -C "$SCRIPT_DIR" docs "$@"
112
+ ;;
113
+ help|--help|-h)
114
+ echo "RapidKit \u2014 ${e.runtimeLabel} project: ${e.projectName}"
115
+ echo ""
116
+ echo "Usage: rapidkit <command>"
117
+ echo ""
118
+ echo " init Install tools + create .env (air, swag, go mod tidy)"
119
+ echo " dev Hot reload dev server (make dev \u2014 requires air)"
120
+ echo " start Run compiled binary (make build + bin)"
121
+ echo " build Build binary (make build)"
122
+ echo " docs Generate Swagger docs (make docs \u2014 requires swag)"
123
+ echo " test Run tests (make test)"
124
+ echo " lint Run linter (make lint)"
125
+ echo " format Format code (make fmt)"
126
+ ;;
127
+ *)
128
+ if [ -n "$CMD" ]; then
129
+ echo "rapidkit: unknown command: $CMD" >&2
130
+ fi
131
+ echo "Available: init, dev, start, build, docs, test, lint, format" >&2
132
+ exit 1
133
+ ;;
134
+ esac
135
+ `}function v(e){return `@echo off
136
+ rem RapidKit ${e.runtimeLabel} project launcher \u2014 Windows
137
+ set CMD=%1
138
+ if "%CMD%"=="" goto usage
139
+ shift
140
+
141
+ if "%CMD%"=="init" (
142
+ echo Initializing ${e.runtimeLabel} project...
143
+ go install ${i}
144
+ go install ${a}
145
+ if not exist .env if exist .env.example copy .env.example .env
146
+ go mod tidy
147
+ exit /b %ERRORLEVEL%
148
+ )
149
+ if "%CMD%"=="dev" ( make dev %* & exit /b %ERRORLEVEL% )
150
+ if "%CMD%"=="build" ( make build %* & exit /b %ERRORLEVEL% )
151
+ if "%CMD%"=="test" ( make test %* & exit /b %ERRORLEVEL% )
152
+ if "%CMD%"=="lint" ( make lint %* & exit /b %ERRORLEVEL% )
153
+ if "%CMD%"=="format" ( make fmt %* & exit /b %ERRORLEVEL% )
154
+ if "%CMD%"=="docs" ( make docs %* & exit /b %ERRORLEVEL% )
155
+ if "%CMD%"=="start" ( bin\\${e.projectName}.exe %* & exit /b %ERRORLEVEL% )
156
+
157
+ :usage
158
+ echo Available: init, dev, start, build, docs, test, lint, format
159
+ exit /b 1
160
+ `}export{g as a,u as b,$ as c,h as d,p as e,v as f};
@@ -0,0 +1,2 @@
1
+ import o from'chalk';var s=class{debugEnabled=false;setDebug(n){this.debugEnabled=n;}debug(n,...e){this.debugEnabled&&console.log(o.gray(`[DEBUG] ${n}`),...e);}info(n,...e){console.log(o.blue(n),...e);}success(n,...e){console.log(o.green(n),...e);}warn(n,...e){console.log(o.yellow(n),...e);}error(n,...e){console.error(o.red(n),...e);}step(n,e,l){console.log(o.cyan(`
2
+ [${n}/${e}]`),o.white(l));}},i=new s;export{i as a};
@@ -0,0 +1,11 @@
1
+ import {a as a$1}from'./chunk-VM2TOHNX.js';import {promises}from'fs';import a from'path';import I from'os';import {pathToFileURL}from'url';var k=".rapidkitrc.json",K=["rapidkit.config.js","rapidkit.config.mjs","rapidkit.config.cjs"];async function A(){let e=a.join(I.homedir(),k);try{let t=await promises.readFile(e,"utf-8"),n=JSON.parse(t);return a$1.debug(`Loaded config from ${e}`),n}catch{return a$1.debug("No user config found, using defaults"),{}}}async function O(e=process.cwd()){let t=e,n=a.parse(t).root;for(;t!==n;){for(let s of K){let i=a.join(t,s);try{await promises.access(i),a$1.debug(`Found config file: ${i}`);let c=await import(pathToFileURL(i).href),x=c.default||c;return a$1.debug(`Loaded RapidKit config from ${s}`),x}catch{continue}}t=a.dirname(t);}return a$1.debug("No RapidKit config file found, using defaults"),{}}function N(e,t,n){return {author:n.author||t.workspace?.defaultAuthor||e.author,pythonVersion:n.pythonVersion||t.workspace?.pythonVersion||e.pythonVersion,defaultInstallMethod:n.defaultInstallMethod||t.workspace?.installMethod||e.defaultInstallMethod,defaultKit:n.defaultKit||t.projects?.defaultKit||e.defaultKit,skipGit:n.skipGit??t.projects?.skipGit??e.skipGit,license:n.license||e.license,testRapidKitPath:n.testRapidKitPath||e.testRapidKitPath}}function v(e){return process.env.RAPIDKIT_DEV_PATH||e.testRapidKitPath||void 0}var o=class extends Error{constructor(n,s,i){super(n);this.code=s;this.details=i;this.name="RapidKitError",Error.captureStackTrace(this,this.constructor);}},p=class extends o{constructor(t,n){let s=n?`Python ${t}+ required, found ${n}`:`Python ${t}+ not found`;super(s,"PYTHON_NOT_FOUND","Please install Python from https://www.python.org/downloads/");}},d=class extends o{constructor(){super("Poetry is not installed","POETRY_NOT_FOUND","Install Poetry from https://python-poetry.org/docs/#installation");}},f=class extends o{constructor(){super("pipx is not installed","PIPX_NOT_FOUND","Install pipx from https://pypa.github.io/pipx/installation/");}},u=class extends o{constructor(t){super(`Directory "${t}" already exists`,"DIRECTORY_EXISTS","Please choose a different name or remove the existing directory");}},g=class extends o{constructor(t,n){super(`Invalid project name: "${t}"`,"INVALID_PROJECT_NAME",n);}},h=class extends o{constructor(t,n){let s=`Installation failed at: ${t}`,i=`${n.message}
2
+
3
+ Troubleshooting:
4
+ - Check your internet connection
5
+ - Verify Python/Poetry installation
6
+ - Try running with --debug flag for more details`;super(s,"INSTALLATION_ERROR",i);}},m=class extends o{constructor(){super("RapidKit Python package is not yet available on PyPI","RAPIDKIT_NOT_AVAILABLE",`Available options:
7
+ 1. Install Python 3.10+ and retry the same command
8
+ 2. Use the core workflow: npx rapidkit create workspace <name>
9
+ 3. Offline fallback (limited): npx rapidkit create project fastapi.standard <name> --output .
10
+
11
+ Legacy: set RAPIDKIT_SHOW_LEGACY=1 to reveal template-mode flags in help.`);}};export{A as a,O as b,N as c,v as d,o as e,p as f,d as g,f as h,u as i,g as j,h as k,m as l};