@vantaloom/cli 0.1.23 → 0.2.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/package.json +1 -1
- package/src/cli.mjs +51 -12
package/package.json
CHANGED
package/src/cli.mjs
CHANGED
|
@@ -109,11 +109,13 @@ async function installFromPackage(options) {
|
|
|
109
109
|
|
|
110
110
|
async function packageRuntime(options) {
|
|
111
111
|
const sourceRoot = findSourceRoot(options.source)
|
|
112
|
+
const targetPlatform = options.target ?? platformId()
|
|
112
113
|
const packageRoot = safeDirectory(
|
|
113
|
-
options.output ?? path.join(sourceRoot, "artifacts", "packages", `vantaloom-${
|
|
114
|
+
options.output ?? path.join(sourceRoot, "artifacts", "packages", `vantaloom-${targetPlatform}`)
|
|
114
115
|
)
|
|
115
116
|
const { platform: builtPlatform, version } = await buildRuntimePackage(sourceRoot, packageRoot, {
|
|
116
117
|
buildWeb: options.buildWeb,
|
|
118
|
+
target: targetPlatform,
|
|
117
119
|
})
|
|
118
120
|
|
|
119
121
|
if (options.npmPackage) {
|
|
@@ -140,16 +142,22 @@ async function packageRuntime(options) {
|
|
|
140
142
|
|
|
141
143
|
async function buildRuntimePackage(sourceRoot, packageRoot, options) {
|
|
142
144
|
const version = gitVersion(sourceRoot)
|
|
143
|
-
const platform = platformId()
|
|
145
|
+
const platform = options.target ?? platformId()
|
|
144
146
|
const buildBin = path.join(packageRoot, "bin")
|
|
145
147
|
const buildWeb = path.join(packageRoot, "web")
|
|
146
148
|
|
|
147
149
|
removeKnownPath(packageRoot, path.dirname(packageRoot))
|
|
148
150
|
mkdirSync(buildBin, { recursive: true })
|
|
149
151
|
|
|
150
|
-
buildGo(sourceRoot, buildBin, "vantaloom-api")
|
|
151
|
-
buildGo(sourceRoot, buildBin, "vantaloom-agent")
|
|
152
|
-
buildGo(sourceRoot, buildBin, "vantaloomctl")
|
|
152
|
+
buildGo(sourceRoot, buildBin, "vantaloom-api", platform)
|
|
153
|
+
buildGo(sourceRoot, buildBin, "vantaloom-agent", platform)
|
|
154
|
+
buildGo(sourceRoot, buildBin, "vantaloomctl", platform)
|
|
155
|
+
// Tray app requires CGO (systray), only buildable natively on Windows.
|
|
156
|
+
if (platform.startsWith("win32") && process.platform === "win32") {
|
|
157
|
+
try {
|
|
158
|
+
buildGo(sourceRoot, buildBin, "vantaloom-tray", platform)
|
|
159
|
+
} catch { /* optional: skip if systray build fails */ }
|
|
160
|
+
}
|
|
153
161
|
|
|
154
162
|
if (options.buildWeb) {
|
|
155
163
|
runPnpm(["--filter", "vantaloom-app", "build"], { cwd: sourceRoot })
|
|
@@ -598,13 +606,20 @@ function printPaths(options) {
|
|
|
598
606
|
console.log(JSON.stringify({ sourceRoot, prefix }, null, 2))
|
|
599
607
|
}
|
|
600
608
|
|
|
601
|
-
function buildGo(sourceRoot, buildBin, name) {
|
|
609
|
+
function buildGo(sourceRoot, buildBin, name, targetPlatform) {
|
|
610
|
+
const goEnv = targetPlatform ? platformToGoEnv(targetPlatform) : {}
|
|
611
|
+
const isWindowsTarget = targetPlatform
|
|
612
|
+
? targetPlatform.startsWith("win32")
|
|
613
|
+
: process.platform === "win32"
|
|
614
|
+
const ext = isWindowsTarget ? ".exe" : ""
|
|
615
|
+
const ldflags = name === "vantaloom-tray" ? "-s -w -H windowsgui" : "-s -w"
|
|
602
616
|
run("go", [
|
|
603
617
|
"build",
|
|
618
|
+
"-ldflags", ldflags,
|
|
604
619
|
"-o",
|
|
605
|
-
path.join(buildBin,
|
|
620
|
+
path.join(buildBin, `${name}${ext}`),
|
|
606
621
|
`./apps/api/cmd/${name}`,
|
|
607
|
-
], { cwd: sourceRoot })
|
|
622
|
+
], { cwd: sourceRoot, env: { ...process.env, ...goEnv } })
|
|
608
623
|
}
|
|
609
624
|
|
|
610
625
|
async function copyDir(source, destination, options = {}) {
|
|
@@ -621,6 +636,10 @@ async function copyDir(source, destination, options = {}) {
|
|
|
621
636
|
}
|
|
622
637
|
|
|
623
638
|
function writeBuildManifest(buildRoot, version, platform) {
|
|
639
|
+
const components = ["api", "agent", "web", "ctl"]
|
|
640
|
+
if (platform.startsWith("win32")) {
|
|
641
|
+
components.push("tray")
|
|
642
|
+
}
|
|
624
643
|
writeFileSync(path.join(buildRoot, "VERSION"), `${version}\n`)
|
|
625
644
|
writeFileSync(
|
|
626
645
|
path.join(buildRoot, "manifest.json"),
|
|
@@ -630,7 +649,7 @@ function writeBuildManifest(buildRoot, version, platform) {
|
|
|
630
649
|
version,
|
|
631
650
|
platform,
|
|
632
651
|
updatedAt: new Date().toISOString(),
|
|
633
|
-
components
|
|
652
|
+
components,
|
|
634
653
|
},
|
|
635
654
|
null,
|
|
636
655
|
2
|
|
@@ -748,6 +767,12 @@ function parseOptions(args) {
|
|
|
748
767
|
case "npm-package":
|
|
749
768
|
options.npmPackage = true
|
|
750
769
|
break
|
|
770
|
+
case "target":
|
|
771
|
+
options.target = inlineValue ?? args[++index]
|
|
772
|
+
if (!options.target) {
|
|
773
|
+
throw new Error("missing value for --target")
|
|
774
|
+
}
|
|
775
|
+
break
|
|
751
776
|
case "local":
|
|
752
777
|
options.local = true
|
|
753
778
|
break
|
|
@@ -799,8 +824,22 @@ function runPnpm(args, options = {}) {
|
|
|
799
824
|
run("pnpm", args, options)
|
|
800
825
|
}
|
|
801
826
|
|
|
802
|
-
function binaryName(name) {
|
|
803
|
-
|
|
827
|
+
function binaryName(name, targetPlatform) {
|
|
828
|
+
const isWindows = targetPlatform
|
|
829
|
+
? targetPlatform.startsWith("win32")
|
|
830
|
+
: process.platform === "win32"
|
|
831
|
+
return isWindows ? `${name}.exe` : name
|
|
832
|
+
}
|
|
833
|
+
|
|
834
|
+
function platformToGoEnv(platform) {
|
|
835
|
+
const { os: runtimeOS, cpu } = parsePlatformId(platform)
|
|
836
|
+
const goosMap = { win32: "windows", linux: "linux", darwin: "darwin" }
|
|
837
|
+
const goarchMap = { x64: "amd64", arm64: "arm64" }
|
|
838
|
+
return {
|
|
839
|
+
GOOS: goosMap[runtimeOS] ?? runtimeOS,
|
|
840
|
+
GOARCH: goarchMap[cpu] ?? cpu,
|
|
841
|
+
CGO_ENABLED: "0",
|
|
842
|
+
}
|
|
804
843
|
}
|
|
805
844
|
|
|
806
845
|
function platformId() {
|
|
@@ -866,7 +905,7 @@ Usage:
|
|
|
866
905
|
vantaloom install --local [--prefix <dir>] [--source <repo>] [--build-web] [--no-start]
|
|
867
906
|
vantaloom update [--prefix <dir>] [--runtime-version <version>] [--npm-registry <url>] [--no-start]
|
|
868
907
|
vantaloom update --local [--prefix <dir>] [--source <repo>] [--build-web] [--no-start]
|
|
869
|
-
vantaloom package [--source <repo>] [--output <dir>] [--build-web] [--archive] [--npm-package]
|
|
908
|
+
vantaloom package [--source <repo>] [--output <dir>] [--build-web] [--archive] [--npm-package] [--target <platform>]
|
|
870
909
|
vantaloom start [--prefix <dir>] [--component all|api|agent|web]
|
|
871
910
|
vantaloom stop [--prefix <dir>] [--component all|api|agent|web]
|
|
872
911
|
vantaloom restart [--prefix <dir>] [--component all|api|agent|web]
|