@hagicode/hagiscript 0.1.6 → 0.1.8

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.
Files changed (50) hide show
  1. package/README.md +144 -201
  2. package/bin/runtime +16 -0
  3. package/dist/cli.js +4 -0
  4. package/dist/cli.js.map +1 -1
  5. package/dist/commands/pm2-commands.d.ts +2 -0
  6. package/dist/commands/pm2-commands.js +54 -0
  7. package/dist/commands/pm2-commands.js.map +1 -0
  8. package/dist/commands/runtime-commands.d.ts +2 -0
  9. package/dist/commands/runtime-commands.js +136 -0
  10. package/dist/commands/runtime-commands.js.map +1 -0
  11. package/dist/index.d.ts +6 -0
  12. package/dist/index.js +6 -0
  13. package/dist/index.js.map +1 -1
  14. package/dist/runtime/command-launch.js +1 -0
  15. package/dist/runtime/command-launch.js.map +1 -1
  16. package/dist/runtime/pm2-manager.d.ts +54 -0
  17. package/dist/runtime/pm2-manager.js +258 -0
  18. package/dist/runtime/pm2-manager.js.map +1 -0
  19. package/dist/runtime/runtime-executor.d.ts +45 -0
  20. package/dist/runtime/runtime-executor.js +153 -0
  21. package/dist/runtime/runtime-executor.js.map +1 -0
  22. package/dist/runtime/runtime-manager.d.ts +79 -0
  23. package/dist/runtime/runtime-manager.js +651 -0
  24. package/dist/runtime/runtime-manager.js.map +1 -0
  25. package/dist/runtime/runtime-manifest.d.ts +77 -0
  26. package/dist/runtime/runtime-manifest.js +277 -0
  27. package/dist/runtime/runtime-manifest.js.map +1 -0
  28. package/dist/runtime/runtime-paths.d.ts +31 -0
  29. package/dist/runtime/runtime-paths.js +77 -0
  30. package/dist/runtime/runtime-paths.js.map +1 -0
  31. package/dist/runtime/runtime-state.d.ts +45 -0
  32. package/dist/runtime/runtime-state.js +82 -0
  33. package/dist/runtime/runtime-state.js.map +1 -0
  34. package/package.json +9 -5
  35. package/runtime/lib/runtime-script-lib.mjs +531 -0
  36. package/runtime/manifest.yaml +136 -0
  37. package/runtime/scripts/configure-code-server.mjs +14 -0
  38. package/runtime/scripts/configure-omniroute.mjs +16 -0
  39. package/runtime/scripts/install-code-server.mjs +53 -0
  40. package/runtime/scripts/install-dotnet.mjs +24 -0
  41. package/runtime/scripts/install-node.mjs +4 -0
  42. package/runtime/scripts/install-npm-packages.mjs +4 -0
  43. package/runtime/scripts/install-omniroute.mjs +60 -0
  44. package/runtime/scripts/remove-npm-packages.mjs +4 -0
  45. package/runtime/scripts/update-npm-packages.mjs +4 -0
  46. package/runtime/scripts/verify-dotnet.mjs +10 -0
  47. package/runtime/scripts/verify-node.mjs +4 -0
  48. package/runtime/templates/code-server-config.yaml +5 -0
  49. package/runtime/templates/omniroute-config.yaml +4 -0
  50. package/README_cn.md +0 -266
@@ -0,0 +1,153 @@
1
+ import { appendFile, mkdir } from "node:fs/promises";
2
+ import { basename, dirname, extname } from "node:path";
3
+ import process from "node:process";
4
+ import { runCommand } from "./command-launch.js";
5
+ import { getRuntimeExecutablePaths } from "./node-verify.js";
6
+ import { getComponentLogsDirectory, getComponentPm2Home, getComponentRuntimeDataHome } from "./runtime-paths.js";
7
+ export async function executeRuntimeScript(scriptPath, context) {
8
+ const runner = context.runner ?? runCommand;
9
+ const { command, args } = getRuntimeScriptLaunch(scriptPath);
10
+ const result = await runner(command, args, {
11
+ cwd: context.manifest.manifestDir,
12
+ env: buildRuntimeScriptEnvironment(context),
13
+ maxBuffer: 10 * 1024 * 1024
14
+ });
15
+ if (context.logFilePath) {
16
+ await writeRuntimeLog(context.logFilePath, [
17
+ `# ${context.phase}:${context.component.name}`,
18
+ `$ ${command} ${args.join(" ")}`,
19
+ result.stdout ? `stdout:\n${result.stdout}` : "",
20
+ result.stderr ? `stderr:\n${result.stderr}` : ""
21
+ ]
22
+ .filter(Boolean)
23
+ .join("\n"));
24
+ }
25
+ return {
26
+ command,
27
+ args,
28
+ stdout: result.stdout,
29
+ stderr: result.stderr
30
+ };
31
+ }
32
+ export async function writeRuntimeLog(logFilePath, content) {
33
+ await mkdir(dirname(logFilePath), { recursive: true });
34
+ await appendFile(logFilePath, `${content}\n`, "utf8");
35
+ }
36
+ export function getRuntimeScriptLaunch(scriptPath) {
37
+ const extension = extname(scriptPath).toLowerCase();
38
+ if (extension === ".mjs" || extension === ".js" || extension === ".cjs") {
39
+ return {
40
+ command: process.execPath,
41
+ args: [scriptPath]
42
+ };
43
+ }
44
+ return {
45
+ command: scriptPath,
46
+ args: []
47
+ };
48
+ }
49
+ function buildRuntimeScriptEnvironment(context) {
50
+ return buildManagedRuntimeEnvironment({
51
+ component: context.component,
52
+ manifest: context.manifest,
53
+ paths: context.paths,
54
+ componentRoot: context.componentRoot,
55
+ componentConfigDir: context.componentConfigDir,
56
+ componentDataHome: getComponentRuntimeDataHome(context.paths, context.component.name, context.component.runtimeDataDir),
57
+ componentLogsDir: getComponentLogsDirectory(context.paths, context.component.name, context.component.runtimeDataDir),
58
+ pm2Home: getComponentPm2Home(context.paths, context.component.name, context.component.runtimeDataDir, context.component.pm2?.pm2Home),
59
+ phase: context.phase,
60
+ purge: context.purge,
61
+ verbose: context.verbose,
62
+ scriptBasename: basename(scriptPathForEnv(context.component, context.phase))
63
+ });
64
+ }
65
+ export function buildManagedRuntimeEnvironment(context, baseEnv = process.env) {
66
+ const componentDataHome = context.componentDataHome ??
67
+ getComponentRuntimeDataHome(context.paths, context.component.name, context.component.runtimeDataDir);
68
+ const componentLogsDir = context.componentLogsDir ??
69
+ getComponentLogsDirectory(context.paths, context.component.name, context.component.runtimeDataDir);
70
+ const pm2Home = context.pm2Home ??
71
+ getComponentPm2Home(context.paths, context.component.name, context.component.runtimeDataDir, undefined);
72
+ return prependPathEntries({
73
+ ...baseEnv,
74
+ HAGICODE_RUNTIME_HOME: context.paths.runtimeHome,
75
+ HAGICODE_RUNTIME_DATA_HOME: componentDataHome,
76
+ PM2_HOME: pm2Home,
77
+ HAGISCRIPT_RUNTIME_ROOT: context.paths.root,
78
+ HAGISCRIPT_RUNTIME_BIN_DIR: context.paths.bin,
79
+ HAGISCRIPT_RUNTIME_CONFIG_DIR: context.paths.config,
80
+ HAGISCRIPT_RUNTIME_LOGS_DIR: context.paths.logs,
81
+ HAGISCRIPT_RUNTIME_DATA_DIR: context.paths.data,
82
+ HAGISCRIPT_RUNTIME_STATE_PATH: context.paths.stateFile,
83
+ HAGISCRIPT_RUNTIME_TEMPLATE_DIR: `${context.manifest.manifestDir}/templates`,
84
+ HAGISCRIPT_RUNTIME_COMPONENT_NAME: context.component.name,
85
+ HAGISCRIPT_RUNTIME_COMPONENT_TYPE: context.component.type,
86
+ HAGISCRIPT_RUNTIME_COMPONENT_VERSION: context.component.version ?? "",
87
+ HAGISCRIPT_RUNTIME_COMPONENT_ROOT: context.componentRoot,
88
+ HAGISCRIPT_RUNTIME_COMPONENT_CONFIG_DIR: context.componentConfigDir,
89
+ HAGISCRIPT_RUNTIME_COMPONENT_DATA_DIR: componentDataHome,
90
+ HAGISCRIPT_RUNTIME_COMPONENT_LOGS_DIR: componentLogsDir,
91
+ HAGISCRIPT_RUNTIME_COMPONENT_PM2_HOME: pm2Home,
92
+ ...(context.phase ? { HAGISCRIPT_RUNTIME_PHASE: context.phase } : {}),
93
+ ...(context.purge !== undefined
94
+ ? { HAGISCRIPT_RUNTIME_PURGE: context.purge ? "1" : "0" }
95
+ : {}),
96
+ ...(context.verbose !== undefined
97
+ ? { HAGISCRIPT_RUNTIME_VERBOSE: context.verbose ? "1" : "0" }
98
+ : {}),
99
+ ...(context.scriptBasename
100
+ ? { HAGISCRIPT_RUNTIME_SCRIPT_BASENAME: context.scriptBasename }
101
+ : {})
102
+ }, getManagedRuntimePathEntries(context.paths));
103
+ }
104
+ export function prependPathEntries(env, pathEntries, platform = process.platform) {
105
+ const pathKey = platform === "win32" ? "Path" : "PATH";
106
+ const currentPath = getPathValue(env, platform);
107
+ const environmentWithoutPath = stripPathKeys(env, platform);
108
+ return {
109
+ ...environmentWithoutPath,
110
+ [pathKey]: [...pathEntries, currentPath]
111
+ .filter(Boolean)
112
+ .join(platform === "win32" ? ";" : ":")
113
+ };
114
+ }
115
+ export function getManagedRuntimePathEntries(paths) {
116
+ const nodeExecutables = getRuntimeExecutablePaths(paths.nodeRuntime);
117
+ return [
118
+ dirname(nodeExecutables.nodePath),
119
+ getManagedNpmBinDirectory(paths.npmPrefix),
120
+ paths.bin
121
+ ];
122
+ }
123
+ export function getManagedNpmBinDirectory(npmPrefix) {
124
+ return process.platform === "win32" ? npmPrefix : `${npmPrefix}/bin`;
125
+ }
126
+ function getPathValue(env, platform) {
127
+ if (platform !== "win32") {
128
+ return env.PATH ?? "";
129
+ }
130
+ for (const [key, value] of Object.entries(env)) {
131
+ if (key.toLowerCase() === "path" && typeof value === "string") {
132
+ return value;
133
+ }
134
+ }
135
+ return "";
136
+ }
137
+ function stripPathKeys(env, platform) {
138
+ if (platform !== "win32") {
139
+ return { ...env };
140
+ }
141
+ return Object.fromEntries(Object.entries(env).filter(([key]) => key.toLowerCase() !== "path"));
142
+ }
143
+ function scriptPathForEnv(component, phase) {
144
+ switch (phase) {
145
+ case "install":
146
+ return component.scripts.install;
147
+ case "remove":
148
+ return component.scripts.remove ?? component.scripts.install;
149
+ case "update":
150
+ return component.scripts.update ?? component.scripts.install;
151
+ }
152
+ }
153
+ //# sourceMappingURL=runtime-executor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runtime-executor.js","sourceRoot":"","sources":["../../src/runtime/runtime-executor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAA;AACpD,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACtD,OAAO,OAAO,MAAM,cAAc,CAAA;AAElC,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAA;AAChD,OAAO,EAAE,yBAAyB,EAAE,MAAM,kBAAkB,CAAA;AAO5D,OAAO,EACL,yBAAyB,EACzB,mBAAmB,EACnB,2BAA2B,EAC5B,MAAM,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AO,EAAE,CAAA;AACX,CAAC;AAED,SAAS,aAAa,CACpB,GAAsB,EACtB,QAAyB;IAEzB,IAAI,QAAQ,KAAK,OAAO,EAAE,CAAC;QACzB,OAAO,EAAE,GAAG,GAAG,EAAE,CAAA;IACnB,CAAC;IAED,OAAO,MAAM,CAAC,WAAW,CACvB,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC,GAAG,CAAC,WAAW,EAAE,KAAK,MAAM,CAAC,CACpE,CAAA;AACH,CAAC;AAED,SAAS,gBAAgB,CACvB,SAAqC,EACrC,KAA4B;IAE5B,QAAQ,KAAK,EAAE,CAAC;QACd,KAAK,SAAS;YACZ,OAAO,SAAS,CAAC,OAAO,CAAC,OAAO,CAAA;QAClC,KAAK,QAAQ;YACX,OAAO,SAAS,CAAC,OAAO,CAAC,MAAM,IAAI,SAAS,CAAC,OAAO,CAAC,OAAO,CAAA;QAC9D,KAAK,QAAQ;YACX,OAAO,SAAS,CAAC,OAAO,CAAC,MAAM,IAAI,SAAS,CAAC,OAAO,CAAC,OAAO,CAAA;IAChE,CAAC;AACH,CAAC"}
@@ -0,0 +1,79 @@
1
+ import { type LoadedRuntimeManifest, type RuntimeLifecyclePhase } from "./runtime-manifest.js";
2
+ import { type ResolvedRuntimePaths } from "./runtime-paths.js";
3
+ import { type RuntimeComponentStatus, type RuntimeState } from "./runtime-state.js";
4
+ export interface RuntimeLifecycleOptions {
5
+ manifestPath?: string;
6
+ runtimeRoot?: string;
7
+ components?: readonly string[];
8
+ dryRun?: boolean;
9
+ force?: boolean;
10
+ purge?: boolean;
11
+ checkOnly?: boolean;
12
+ verbose?: boolean;
13
+ logger?: (message: string) => void;
14
+ now?: () => Date;
15
+ }
16
+ export interface RuntimePlannedAction {
17
+ componentName: string;
18
+ phase: RuntimeLifecyclePhase;
19
+ strategy: "builtin" | "script" | "fallback-install" | "fallback-cleanup";
20
+ scriptPath?: string;
21
+ reason?: string;
22
+ }
23
+ export interface RuntimeLifecycleResult {
24
+ manifest: LoadedRuntimeManifest;
25
+ paths: ResolvedRuntimePaths;
26
+ state: RuntimeState;
27
+ plan: RuntimePlannedAction[];
28
+ skipped: {
29
+ componentName: string;
30
+ reason: string;
31
+ }[];
32
+ changedComponents: string[];
33
+ logFilePath?: string;
34
+ }
35
+ export interface RuntimeStateReport {
36
+ runtime: {
37
+ name: string;
38
+ version: string;
39
+ manifestPath: string;
40
+ };
41
+ managedRoot: string;
42
+ managedPaths: ResolvedRuntimePaths;
43
+ layout: {
44
+ separated: boolean;
45
+ runtimeHome: string;
46
+ runtimeDataRoot: string;
47
+ programRoots: string[];
48
+ externalDataRoots: string[];
49
+ };
50
+ ready: boolean;
51
+ components: Array<{
52
+ name: string;
53
+ type: string;
54
+ status: RuntimeComponentStatus;
55
+ version: string | null;
56
+ runtimeDataHome: string | null;
57
+ pm2Home: string | null;
58
+ programPaths: string[];
59
+ externalDataPaths: string[];
60
+ managedPaths: string[];
61
+ }>;
62
+ lastOperation: RuntimeState["lastOperation"];
63
+ }
64
+ export declare class RuntimeLifecycleError extends Error {
65
+ constructor(message: string, options?: ErrorOptions);
66
+ }
67
+ export declare function installRuntime(options?: RuntimeLifecycleOptions): Promise<RuntimeLifecycleResult>;
68
+ export declare function removeRuntime(options?: RuntimeLifecycleOptions): Promise<RuntimeLifecycleResult>;
69
+ export declare function updateRuntime(options?: RuntimeLifecycleOptions): Promise<RuntimeLifecycleResult>;
70
+ export declare function runRuntimeLifecycle(phase: RuntimeLifecyclePhase, options?: RuntimeLifecycleOptions): Promise<RuntimeLifecycleResult>;
71
+ export declare function queryRuntimeState(options: Pick<RuntimeLifecycleOptions, "manifestPath" | "runtimeRoot">): Promise<RuntimeStateReport>;
72
+ export declare function renderRuntimeStateText(report: RuntimeStateReport): string;
73
+ export declare function planRuntimeLifecycle(phase: RuntimeLifecyclePhase, manifest: LoadedRuntimeManifest, state: RuntimeState, options?: RuntimeLifecycleOptions): {
74
+ plan: RuntimePlannedAction[];
75
+ skipped: {
76
+ componentName: string;
77
+ reason: string;
78
+ }[];
79
+ };