pinokiod 7.1.41 → 7.1.43
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/kernel/bin/bluefairy.js +43 -0
- package/package.json +1 -1
package/kernel/bin/bluefairy.js
CHANGED
|
@@ -33,6 +33,16 @@ class Bluefairy {
|
|
|
33
33
|
return path.resolve(this.moduleRoot(), this.packageName(), "package.json")
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
+
runtimeHome() {
|
|
37
|
+
return this.kernel.bin.path("bluefairy")
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
env() {
|
|
41
|
+
return {
|
|
42
|
+
BLUEFAIRY_HOME: this.runtimeHome()
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
36
46
|
installedArtifacts() {
|
|
37
47
|
const binDir = this.npmBinDir()
|
|
38
48
|
if (this.kernel.platform === "win32") {
|
|
@@ -49,10 +59,33 @@ class Bluefairy {
|
|
|
49
59
|
]
|
|
50
60
|
}
|
|
51
61
|
|
|
62
|
+
runtimeArtifacts() {
|
|
63
|
+
const runtimeHome = this.runtimeHome()
|
|
64
|
+
if (this.kernel.platform === "win32") {
|
|
65
|
+
return [
|
|
66
|
+
path.resolve(runtimeHome, "shims", "npm.cmd"),
|
|
67
|
+
path.resolve(runtimeHome, "shims", "bun.cmd"),
|
|
68
|
+
path.resolve(runtimeHome, "shims", "uv.cmd"),
|
|
69
|
+
path.resolve(runtimeHome, "shims", "uv.exe"),
|
|
70
|
+
path.resolve(runtimeHome, "state", "cli-launcher.mjs"),
|
|
71
|
+
path.resolve(runtimeHome, "state", "shim-launcher.exe"),
|
|
72
|
+
]
|
|
73
|
+
}
|
|
74
|
+
return [
|
|
75
|
+
path.resolve(runtimeHome, "shims", "npm"),
|
|
76
|
+
path.resolve(runtimeHome, "shims", "bun"),
|
|
77
|
+
path.resolve(runtimeHome, "shims", "uv"),
|
|
78
|
+
path.resolve(runtimeHome, "state", "cli-launcher.mjs"),
|
|
79
|
+
]
|
|
80
|
+
}
|
|
81
|
+
|
|
52
82
|
isInstalledSync() {
|
|
53
83
|
if (!this.installedArtifacts().every((artifact) => fs.existsSync(artifact))) {
|
|
54
84
|
return false
|
|
55
85
|
}
|
|
86
|
+
if (!this.runtimeArtifacts().every((artifact) => fs.existsSync(artifact))) {
|
|
87
|
+
return false
|
|
88
|
+
}
|
|
56
89
|
try {
|
|
57
90
|
const pkg = JSON.parse(fs.readFileSync(this.packageJsonPath(), "utf8"))
|
|
58
91
|
const coerced = semver.coerce(pkg && pkg.version)
|
|
@@ -64,6 +97,16 @@ class Bluefairy {
|
|
|
64
97
|
|
|
65
98
|
async install(req, ondata) {
|
|
66
99
|
const spec = this.packageSpec().replaceAll('"', '\\"')
|
|
100
|
+
const runtimeHome = this.runtimeHome()
|
|
101
|
+
if (fs.existsSync(runtimeHome)) {
|
|
102
|
+
try {
|
|
103
|
+
await fs.promises.rm(runtimeHome, { recursive: true, force: true })
|
|
104
|
+
ondata({ raw: `Removed existing Bluefairy runtime: ${runtimeHome}\r\n` })
|
|
105
|
+
} catch (error) {
|
|
106
|
+
const message = error && error.message ? error.message : String(error)
|
|
107
|
+
ondata({ raw: `Warning: failed to remove Bluefairy runtime ${runtimeHome}: ${message}\r\n` })
|
|
108
|
+
}
|
|
109
|
+
}
|
|
67
110
|
await this.kernel.exec({
|
|
68
111
|
message: `npm install -g "${spec}" --force`,
|
|
69
112
|
}, ondata)
|