@hagicode/hagiscript 0.1.6-dev.39.1.abb22ea → 0.1.6-dev.41.1.c7efd72

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 (34) hide show
  1. package/README.md +38 -8
  2. package/README_cn.md +55 -0
  3. package/dist/cli.js +2 -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/index.d.ts +3 -1
  9. package/dist/index.js +3 -1
  10. package/dist/index.js.map +1 -1
  11. package/dist/runtime/pm2-manager.d.ts +54 -0
  12. package/dist/runtime/pm2-manager.js +260 -0
  13. package/dist/runtime/pm2-manager.js.map +1 -0
  14. package/dist/runtime/runtime-executor.d.ts +18 -0
  15. package/dist/runtime/runtime-executor.js +58 -9
  16. package/dist/runtime/runtime-executor.js.map +1 -1
  17. package/dist/runtime/runtime-manager.d.ts +4 -0
  18. package/dist/runtime/runtime-manager.js +79 -13
  19. package/dist/runtime/runtime-manager.js.map +1 -1
  20. package/dist/runtime/runtime-manifest.d.ts +14 -0
  21. package/dist/runtime/runtime-manifest.js +46 -0
  22. package/dist/runtime/runtime-manifest.js.map +1 -1
  23. package/dist/runtime/runtime-paths.d.ts +8 -1
  24. package/dist/runtime/runtime-paths.js +27 -12
  25. package/dist/runtime/runtime-paths.js.map +1 -1
  26. package/package.json +1 -1
  27. package/runtime/lib/runtime-script-lib.mjs +40 -1
  28. package/runtime/manifest.yaml +15 -1
  29. package/runtime/scripts/configure-code-server.mjs +1 -1
  30. package/runtime/scripts/configure-omniroute.mjs +3 -3
  31. package/runtime/scripts/install-code-server.mjs +7 -4
  32. package/runtime/scripts/install-omniroute.mjs +9 -6
  33. package/runtime/templates/code-server-config.yaml +2 -2
  34. package/runtime/templates/omniroute-config.yaml +3 -3
@@ -3,18 +3,24 @@ import { isAbsolute, join, relative, resolve } from "node:path";
3
3
  export const defaultRuntimeRoot = "~/.hagicode/runtime";
4
4
  export function resolveRuntimePaths(manifest, options = {}) {
5
5
  const root = normalizeManagedRoot(options.runtimeRoot ?? manifest.paths.runtimeRoot ?? defaultRuntimeRoot);
6
+ const runtimeHome = resolveManagedPath(manifest.paths.runtimeHome, root);
7
+ const runtimeDataRoot = resolveManagedPath(manifest.paths.runtimeDataRoot, root);
6
8
  return {
7
9
  root,
8
- bin: resolveManagedPath(manifest.paths.bin, root),
9
- config: resolveManagedPath(manifest.paths.config, root),
10
- logs: resolveManagedPath(manifest.paths.logs, root),
11
- data: resolveManagedPath(manifest.paths.data, root),
12
- stateFile: resolveManagedPath(manifest.paths.stateFile, root),
13
- componentsRoot: resolveManagedPath(manifest.paths.componentsRoot, root),
14
- npmPrefix: resolveManagedPath(manifest.paths.npmPrefix, root),
15
- nodeRuntime: resolveManagedPath(manifest.paths.nodeRuntime, root),
16
- dotnetRuntime: resolveManagedPath(manifest.paths.dotnetRuntime, root),
17
- vendoredRoot: resolveManagedPath(manifest.paths.vendoredRoot, root)
10
+ runtimeHome,
11
+ runtimeDataRoot,
12
+ bin: resolveManagedPath(manifest.paths.bin, runtimeHome),
13
+ config: resolveManagedPath(manifest.paths.config, runtimeDataRoot),
14
+ logs: resolveManagedPath(manifest.paths.logs, runtimeDataRoot),
15
+ data: resolveManagedPath(manifest.paths.data, runtimeDataRoot),
16
+ stateFile: resolveManagedPath(manifest.paths.stateFile, runtimeDataRoot),
17
+ componentsRoot: resolveManagedPath(manifest.paths.componentsRoot, runtimeHome),
18
+ componentDataRoot: resolveManagedPath(manifest.paths.componentDataRoot, runtimeDataRoot),
19
+ defaultPm2Home: manifest.paths.defaultPm2Home,
20
+ npmPrefix: resolveManagedPath(manifest.paths.npmPrefix, runtimeHome),
21
+ nodeRuntime: resolveManagedPath(manifest.paths.nodeRuntime, runtimeHome),
22
+ dotnetRuntime: resolveManagedPath(manifest.paths.dotnetRuntime, runtimeHome),
23
+ vendoredRoot: resolveManagedPath(manifest.paths.vendoredRoot, runtimeHome)
18
24
  };
19
25
  }
20
26
  export function normalizeManagedRoot(value) {
@@ -43,8 +49,17 @@ export function getComponentManagedRoot(paths, componentName) {
43
49
  return join(paths.componentsRoot, componentName);
44
50
  }
45
51
  }
46
- export function getComponentConfigDirectory(paths, componentName) {
47
- return join(paths.config, componentName);
52
+ export function getComponentConfigDirectory(paths, componentName, runtimeDataDir) {
53
+ return join(getComponentRuntimeDataHome(paths, componentName, runtimeDataDir), "config");
54
+ }
55
+ export function getComponentLogsDirectory(paths, componentName, runtimeDataDir) {
56
+ return join(getComponentRuntimeDataHome(paths, componentName, runtimeDataDir), "logs");
57
+ }
58
+ export function getComponentRuntimeDataHome(paths, componentName, runtimeDataDir) {
59
+ return resolveManagedPath(runtimeDataDir ?? componentName, paths.componentDataRoot);
60
+ }
61
+ export function getComponentPm2Home(paths, componentName, runtimeDataDir, pm2Home) {
62
+ return resolveManagedPath(pm2Home ?? paths.defaultPm2Home, getComponentRuntimeDataHome(paths, componentName, runtimeDataDir));
48
63
  }
49
64
  export function isPathInsideRuntimeRoot(runtimeRoot, targetPath) {
50
65
  const relativePath = relative(resolve(runtimeRoot), resolve(targetPath));
@@ -1 +1 @@
1
- {"version":3,"file":"runtime-paths.js","sourceRoot":"","sources":["../../src/runtime/runtime-paths.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AACjC,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAG/D,MAAM,CAAC,MAAM,kBAAkB,GAAG,qBAAqB,CAAA;AAoBvD,MAAM,UAAU,mBAAmB,CACjC,QAA+B,EAC/B,UAAsC,EAAE;IAExC,MAAM,IAAI,GAAG,oBAAoB,CAC/B,OAAO,CAAC,WAAW,IAAI,QAAQ,CAAC,KAAK,CAAC,WAAW,IAAI,kBAAkB,CACxE,CAAA;IAED,OAAO;QAC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AA;IACxE,OAAO,YAAY,KAAK,EAAE,IAAI,CAAC,CAAC,YAAY,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,CAAA;AACnG,CAAC;AAED,SAAS,mBAAmB,CAAC,KAAa;IACxC,IAAI,KAAK,KAAK,GAAG,EAAE,CAAC;QAClB,OAAO,OAAO,EAAE,CAAA;IAClB,CAAC;IAED,IAAI,KAAK,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC;QAC3B,OAAO,IAAI,CAAC,OAAO,EAAE,EAAE,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAA;IACxC,CAAC;IAED,OAAO,KAAK,CAAA;AACd,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hagicode/hagiscript",
3
- "version": "0.1.6-dev.39.1.abb22ea",
3
+ "version": "0.1.6-dev.41.1.c7efd72",
4
4
  "description": "Scoped npm package foundation for Hagiscript language tooling.",
5
5
  "license": "MIT",
6
6
  "homepage": "https://github.com/HagiCode-org/hagiscript#readme",
@@ -1,10 +1,12 @@
1
- import { mkdir, readFile, writeFile } from "node:fs/promises"
1
+ import { chmod, mkdir, readFile, writeFile } from "node:fs/promises"
2
2
  import path from "node:path"
3
3
  import process from "node:process"
4
4
 
5
5
  export function readRuntimeScriptContext() {
6
6
  return {
7
7
  runtimeRoot: requiredEnv("HAGISCRIPT_RUNTIME_ROOT"),
8
+ runtimeHome: requiredEnv("HAGICODE_RUNTIME_HOME"),
9
+ runtimeDataHome: requiredEnv("HAGICODE_RUNTIME_DATA_HOME"),
8
10
  binDir: requiredEnv("HAGISCRIPT_RUNTIME_BIN_DIR"),
9
11
  configDir: requiredEnv("HAGISCRIPT_RUNTIME_CONFIG_DIR"),
10
12
  logsDir: requiredEnv("HAGISCRIPT_RUNTIME_LOGS_DIR"),
@@ -14,6 +16,9 @@ export function readRuntimeScriptContext() {
14
16
  componentType: requiredEnv("HAGISCRIPT_RUNTIME_COMPONENT_TYPE"),
15
17
  componentRoot: requiredEnv("HAGISCRIPT_RUNTIME_COMPONENT_ROOT"),
16
18
  componentConfigDir: requiredEnv("HAGISCRIPT_RUNTIME_COMPONENT_CONFIG_DIR"),
19
+ componentDataDir: requiredEnv("HAGISCRIPT_RUNTIME_COMPONENT_DATA_DIR"),
20
+ componentLogsDir: requiredEnv("HAGISCRIPT_RUNTIME_COMPONENT_LOGS_DIR"),
21
+ componentPm2Home: requiredEnv("HAGISCRIPT_RUNTIME_COMPONENT_PM2_HOME"),
17
22
  templateDir: requiredEnv("HAGISCRIPT_RUNTIME_TEMPLATE_DIR"),
18
23
  componentVersion: process.env.HAGISCRIPT_RUNTIME_COMPONENT_VERSION?.trim() || null,
19
24
  phase: process.env.HAGISCRIPT_RUNTIME_PHASE?.trim() || "install",
@@ -65,6 +70,31 @@ export async function writeNodeEntrypoint(filePath, message) {
65
70
  `#!/usr/bin/env node\nprocess.stdout.write(${JSON.stringify(message)} + "\\n")\n`,
66
71
  "utf8"
67
72
  )
73
+ await makeExecutable(filePath)
74
+ return filePath
75
+ }
76
+
77
+ export async function writeManagedServiceEntrypoint(filePath, serviceName) {
78
+ await ensureDirectory(path.dirname(filePath))
79
+ await writeFile(
80
+ filePath,
81
+ `#!/usr/bin/env node
82
+ const serviceName = ${JSON.stringify(serviceName)}
83
+ process.stdout.write(serviceName + " ready\\n")
84
+ const timer = setInterval(() => {
85
+ process.stdout.write("")
86
+ }, 60_000)
87
+ const shutdown = (signal) => {
88
+ clearInterval(timer)
89
+ process.stdout.write(serviceName + " shutting down via " + signal + "\\n")
90
+ process.exit(0)
91
+ }
92
+ process.on("SIGINT", () => shutdown("SIGINT"))
93
+ process.on("SIGTERM", () => shutdown("SIGTERM"))
94
+ `,
95
+ "utf8"
96
+ )
97
+ await makeExecutable(filePath)
68
98
  return filePath
69
99
  }
70
100
 
@@ -89,6 +119,7 @@ export async function writeCommandWrapper(binDir, commandName, scriptPath) {
89
119
  `#!/usr/bin/env sh\nexec node "$(dirname "$0")/${relativeTarget}" "$@"\n`,
90
120
  "utf8"
91
121
  )
122
+ await makeExecutable(wrapperPath)
92
123
  return wrapperPath
93
124
  }
94
125
 
@@ -101,3 +132,11 @@ function requiredEnv(name) {
101
132
 
102
133
  return value
103
134
  }
135
+
136
+ async function makeExecutable(filePath) {
137
+ if (process.platform === "win32") {
138
+ return
139
+ }
140
+
141
+ await chmod(filePath, 0o755)
142
+ }
@@ -4,13 +4,17 @@ runtime:
4
4
 
5
5
  paths:
6
6
  runtimeRoot: "~/.hagicode/runtime"
7
+ runtimeHome: "program"
8
+ runtimeDataRoot: "runtime-data"
7
9
  bin: "bin"
8
10
  config: "config"
9
11
  logs: "logs"
10
12
  data: "data"
11
13
  stateFile: "state.json"
12
14
  componentsRoot: "components"
13
- npmPrefix: "data/npm"
15
+ componentDataRoot: "components"
16
+ defaultPm2Home: "pm2"
17
+ npmPrefix: "npm"
14
18
  nodeRuntime: "components/node/runtime"
15
19
  dotnetRuntime: "components/dotnet/runtime"
16
20
  vendoredRoot: "components/bundled"
@@ -88,15 +92,25 @@ components:
88
92
  type: "bundled-runtime"
89
93
  source: "desktop-vendored-runtime"
90
94
  version: "3.6.9"
95
+ runtimeDataDir: "services/omniroute"
91
96
  installScript: "scripts/install-omniroute.mjs"
92
97
  configureScript: "scripts/configure-omniroute.mjs"
98
+ pm2:
99
+ appName: "hagicode-omniroute"
100
+ cwd: "."
101
+ script: "current/omniroute-launcher.mjs"
93
102
 
94
103
  - name: "code-server"
95
104
  type: "bundled-runtime"
96
105
  source: "desktop-vendored-runtime"
97
106
  version: "4.117.0"
107
+ runtimeDataDir: "services/code-server"
98
108
  installScript: "scripts/install-code-server.mjs"
99
109
  configureScript: "scripts/configure-code-server.mjs"
110
+ pm2:
111
+ appName: "hagicode-code-server"
112
+ cwd: "."
113
+ script: "current/code-server-launcher.mjs"
100
114
 
101
115
  phases:
102
116
  install:
@@ -9,6 +9,6 @@ import {
9
9
  const context = readRuntimeScriptContext()
10
10
  const configPath = path.join(context.componentConfigDir, "config.yaml")
11
11
  await materializeTemplate("code-server-config.yaml", configPath, {
12
- DATA_DIR: context.dataDir
12
+ DATA_DIR: context.runtimeDataHome
13
13
  })
14
14
  process.stdout.write(`Configured code-server template at ${configPath}\n`)
@@ -9,8 +9,8 @@ import {
9
9
  const context = readRuntimeScriptContext()
10
10
  const configPath = path.join(context.componentConfigDir, "config.yaml")
11
11
  await materializeTemplate("omniroute-config.yaml", configPath, {
12
- RUNTIME_ROOT: context.runtimeRoot,
13
- DATA_DIR: context.dataDir,
14
- LOGS_DIR: context.logsDir
12
+ RUNTIME_ROOT: context.runtimeHome,
13
+ DATA_DIR: context.runtimeDataHome,
14
+ LOGS_DIR: context.componentLogsDir
15
15
  })
16
16
  process.stdout.write(`Configured omniroute template at ${configPath}\n`)
@@ -7,7 +7,7 @@ import {
7
7
  readRuntimeScriptContext,
8
8
  writeCommandWrapper,
9
9
  writeComponentMarker,
10
- writeNodeEntrypoint
10
+ writeManagedServiceEntrypoint
11
11
  } from "../lib/runtime-script-lib.mjs"
12
12
 
13
13
  const context = readRuntimeScriptContext()
@@ -17,16 +17,19 @@ const configPath = path.join(context.componentConfigDir, "config.yaml")
17
17
 
18
18
  await ensureDirectory(currentRoot)
19
19
  await materializeTemplate("code-server-config.yaml", configPath, {
20
- DATA_DIR: context.dataDir
20
+ DATA_DIR: context.runtimeDataHome
21
21
  })
22
- await writeNodeEntrypoint(
22
+ await writeManagedServiceEntrypoint(
23
23
  launcherPath,
24
- `code-server placeholder managed by hagiscript at ${context.runtimeRoot}`
24
+ "code-server"
25
25
  )
26
26
  await writeCommandWrapper(context.binDir, "code-server", launcherPath)
27
27
  await writeComponentMarker(context, {
28
28
  configPath,
29
29
  launcherPath,
30
+ runtimeHome: context.runtimeHome,
31
+ runtimeDataHome: context.runtimeDataHome,
32
+ pm2Home: context.componentPm2Home,
30
33
  ownership: "vendored-runtime"
31
34
  })
32
35
  process.stdout.write(`Prepared code-server assets in ${currentRoot}\n`)
@@ -7,7 +7,7 @@ import {
7
7
  readRuntimeScriptContext,
8
8
  writeCommandWrapper,
9
9
  writeComponentMarker,
10
- writeNodeEntrypoint
10
+ writeManagedServiceEntrypoint
11
11
  } from "../lib/runtime-script-lib.mjs"
12
12
 
13
13
  const context = readRuntimeScriptContext()
@@ -17,18 +17,21 @@ const configPath = path.join(context.componentConfigDir, "config.yaml")
17
17
 
18
18
  await ensureDirectory(currentRoot)
19
19
  await materializeTemplate("omniroute-config.yaml", configPath, {
20
- RUNTIME_ROOT: context.runtimeRoot,
21
- DATA_DIR: context.dataDir,
22
- LOGS_DIR: context.logsDir
20
+ RUNTIME_ROOT: context.runtimeHome,
21
+ DATA_DIR: context.runtimeDataHome,
22
+ LOGS_DIR: context.componentLogsDir
23
23
  })
24
- await writeNodeEntrypoint(
24
+ await writeManagedServiceEntrypoint(
25
25
  launcherPath,
26
- `omniroute placeholder managed by hagiscript at ${context.runtimeRoot}`
26
+ "omniroute"
27
27
  )
28
28
  await writeCommandWrapper(context.binDir, "omniroute", launcherPath)
29
29
  await writeComponentMarker(context, {
30
30
  configPath,
31
31
  launcherPath,
32
+ runtimeHome: context.runtimeHome,
33
+ runtimeDataHome: context.runtimeDataHome,
34
+ pm2Home: context.componentPm2Home,
32
35
  ownership: "vendored-runtime"
33
36
  })
34
37
  process.stdout.write(`Prepared omniroute assets in ${currentRoot}\n`)
@@ -1,5 +1,5 @@
1
1
  bind-addr: 127.0.0.1:8080
2
2
  auth: none
3
- user-data-dir: "{{DATA_DIR}}/code-server"
4
- extensions-dir: "{{DATA_DIR}}/code-server/extensions"
3
+ user-data-dir: "{{DATA_DIR}}"
4
+ extensions-dir: "{{DATA_DIR}}/extensions"
5
5
  log: info
@@ -1,4 +1,4 @@
1
- runtimeRoot: "{{RUNTIME_ROOT}}"
1
+ runtimeHome: "{{RUNTIME_ROOT}}"
2
2
  listen: "127.0.0.1:39001"
3
- dataDir: "{{DATA_DIR}}/omniroute"
4
- logDir: "{{LOGS_DIR}}/omniroute"
3
+ dataDir: "{{DATA_DIR}}"
4
+ logDir: "{{LOGS_DIR}}"