swallowkit 1.0.0-beta.22 → 1.0.0-beta.24
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.ja.md +9 -4
- package/README.md +9 -4
- package/dist/cli/commands/dev.d.ts +14 -0
- package/dist/cli/commands/dev.d.ts.map +1 -1
- package/dist/cli/commands/dev.js +187 -54
- package/dist/cli/commands/dev.js.map +1 -1
- package/dist/cli/commands/init.d.ts.map +1 -1
- package/dist/cli/commands/init.js +33 -18
- package/dist/cli/commands/init.js.map +1 -1
- package/dist/cli/commands/scaffold.d.ts +0 -3
- package/dist/cli/commands/scaffold.d.ts.map +1 -1
- package/dist/cli/commands/scaffold.js +3 -172
- package/dist/cli/commands/scaffold.js.map +1 -1
- package/dist/core/project/validation.js +2 -2
- package/dist/core/project/validation.js.map +1 -1
- package/dist/core/scaffold/model-parser.d.ts.map +1 -1
- package/dist/core/scaffold/model-parser.js +5 -6
- package/dist/core/scaffold/model-parser.js.map +1 -1
- package/dist/core/scaffold/native-schema-generator.d.ts +13 -0
- package/dist/core/scaffold/native-schema-generator.d.ts.map +1 -0
- package/dist/core/scaffold/native-schema-generator.js +677 -0
- package/dist/core/scaffold/native-schema-generator.js.map +1 -0
- package/dist/utils/python-uv.d.ts +21 -0
- package/dist/utils/python-uv.d.ts.map +1 -0
- package/dist/utils/python-uv.js +112 -0
- package/dist/utils/python-uv.js.map +1 -0
- package/package.json +1 -1
- package/src/__tests__/dev.test.ts +95 -0
- package/src/__tests__/model-parser.test.ts +44 -64
- package/src/__tests__/python-uv.test.ts +48 -0
- package/src/__tests__/scaffold.test.ts +54 -26
- package/src/cli/commands/dev.ts +258 -74
- package/src/cli/commands/init.ts +45 -19
- package/src/cli/commands/scaffold.ts +3 -213
- package/src/core/project/validation.ts +2 -2
- package/src/core/scaffold/model-parser.ts +7 -7
- package/src/core/scaffold/native-schema-generator.ts +798 -0
- package/src/utils/python-uv.ts +97 -0
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import * as path from "path";
|
|
2
|
+
|
|
3
|
+
export const SWALLOWKIT_PYTHON_VERSION = "3.11";
|
|
4
|
+
|
|
5
|
+
export interface ProjectLocalUvPaths {
|
|
6
|
+
stateDir: string;
|
|
7
|
+
cacheDir: string;
|
|
8
|
+
pythonInstallDir: string;
|
|
9
|
+
toolDir: string;
|
|
10
|
+
toolBinDir: string;
|
|
11
|
+
localUvInstallDir: string;
|
|
12
|
+
localUvExecutable: string;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export function getPythonProjectRoot(functionsDir: string): string {
|
|
16
|
+
return path.dirname(functionsDir);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export function getProjectLocalUvPaths(projectRoot: string): ProjectLocalUvPaths {
|
|
20
|
+
const stateDir = path.join(projectRoot, ".uv");
|
|
21
|
+
const localUvInstallDir = path.join(stateDir, "bin");
|
|
22
|
+
|
|
23
|
+
return {
|
|
24
|
+
stateDir,
|
|
25
|
+
cacheDir: path.join(stateDir, "cache"),
|
|
26
|
+
pythonInstallDir: path.join(stateDir, "python"),
|
|
27
|
+
toolDir: path.join(stateDir, "tools"),
|
|
28
|
+
toolBinDir: path.join(stateDir, "tools", "bin"),
|
|
29
|
+
localUvInstallDir,
|
|
30
|
+
localUvExecutable: process.platform === "win32"
|
|
31
|
+
? path.join(localUvInstallDir, "uv.exe")
|
|
32
|
+
: path.join(localUvInstallDir, "uv"),
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export function buildProjectLocalUvEnv(
|
|
37
|
+
baseEnv: NodeJS.ProcessEnv,
|
|
38
|
+
projectRoot: string
|
|
39
|
+
): NodeJS.ProcessEnv {
|
|
40
|
+
const uvPaths = getProjectLocalUvPaths(projectRoot);
|
|
41
|
+
const env: NodeJS.ProcessEnv = {
|
|
42
|
+
...baseEnv,
|
|
43
|
+
UV_CACHE_DIR: uvPaths.cacheDir,
|
|
44
|
+
UV_PYTHON_INSTALL_DIR: uvPaths.pythonInstallDir,
|
|
45
|
+
UV_TOOL_DIR: uvPaths.toolDir,
|
|
46
|
+
UV_TOOL_BIN_DIR: uvPaths.toolBinDir,
|
|
47
|
+
UV_PYTHON_PREFERENCE: "managed",
|
|
48
|
+
UV_MANAGED_PYTHON: "true",
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
if (process.platform === "win32") {
|
|
52
|
+
env.UV_PYTHON_NO_REGISTRY = "true";
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
return env;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export function buildProjectLocalUvInstallerEnv(
|
|
59
|
+
baseEnv: NodeJS.ProcessEnv,
|
|
60
|
+
projectRoot: string
|
|
61
|
+
): NodeJS.ProcessEnv {
|
|
62
|
+
const uvPaths = getProjectLocalUvPaths(projectRoot);
|
|
63
|
+
|
|
64
|
+
return {
|
|
65
|
+
...buildProjectLocalUvEnv(baseEnv, projectRoot),
|
|
66
|
+
UV_UNMANAGED_INSTALL: uvPaths.localUvInstallDir,
|
|
67
|
+
UV_NO_MODIFY_PATH: "1",
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export function getProjectLocalUvInstallerCommand(): { command: string; args: string[] } {
|
|
72
|
+
if (process.platform === "win32") {
|
|
73
|
+
return {
|
|
74
|
+
command: "powershell",
|
|
75
|
+
args: [
|
|
76
|
+
"-NoProfile",
|
|
77
|
+
"-ExecutionPolicy",
|
|
78
|
+
"Bypass",
|
|
79
|
+
"-Command",
|
|
80
|
+
"$ProgressPreference = 'SilentlyContinue'; irm https://astral.sh/uv/install.ps1 | iex",
|
|
81
|
+
],
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
return {
|
|
86
|
+
command: "sh",
|
|
87
|
+
args: ["-c", "curl -LsSf https://astral.sh/uv/install.sh | sh"],
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
export function buildUvVenvArgs(venvDir: string, pythonVersion = SWALLOWKIT_PYTHON_VERSION): string[] {
|
|
92
|
+
return ["venv", venvDir, "--python", pythonVersion, "--managed-python"];
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
export function buildUvPipInstallArgs(pythonExecutable: string, requirementsPath: string): string[] {
|
|
96
|
+
return ["pip", "install", "--python", pythonExecutable, "-r", requirementsPath];
|
|
97
|
+
}
|