@randomlabs/slate 1.0.24 → 1.0.26
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/bin/bin/slate +96 -0
- package/package.json +12 -12
- package/postinstall.mjs +75 -109
- package/bin/slate1 +0 -103
package/bin/bin/slate
ADDED
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const childProcess = require("child_process")
|
|
4
|
+
const fs = require("fs")
|
|
5
|
+
const path = require("path")
|
|
6
|
+
const os = require("os")
|
|
7
|
+
|
|
8
|
+
function run(target) {
|
|
9
|
+
const result = childProcess.spawnSync(target, process.argv.slice(2), {
|
|
10
|
+
stdio: "inherit",
|
|
11
|
+
})
|
|
12
|
+
if (result.error) {
|
|
13
|
+
console.error(result.error.message)
|
|
14
|
+
process.exit(1)
|
|
15
|
+
}
|
|
16
|
+
const code = typeof result.status === "number" ? result.status : 0
|
|
17
|
+
process.exit(code)
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const envPath = process.env.SLATE_BIN_PATH
|
|
21
|
+
if (envPath) {
|
|
22
|
+
run(envPath)
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const scriptPath = fs.realpathSync(__filename)
|
|
26
|
+
const scriptDir = path.dirname(scriptPath)
|
|
27
|
+
const projectRoot = path.dirname(scriptDir)
|
|
28
|
+
|
|
29
|
+
const platformMap = {
|
|
30
|
+
darwin: "darwin",
|
|
31
|
+
linux: "linux",
|
|
32
|
+
win32: "windows",
|
|
33
|
+
}
|
|
34
|
+
const archMap = {
|
|
35
|
+
x64: "x64",
|
|
36
|
+
arm64: "arm64",
|
|
37
|
+
arm: "arm",
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
let platform = platformMap[os.platform()]
|
|
41
|
+
if (!platform) {
|
|
42
|
+
platform = os.platform()
|
|
43
|
+
}
|
|
44
|
+
let arch = archMap[os.arch()]
|
|
45
|
+
if (!arch) {
|
|
46
|
+
arch = os.arch()
|
|
47
|
+
}
|
|
48
|
+
const base = "slate-" + platform + "-" + arch
|
|
49
|
+
const binary = platform === "windows" ? "slate.exe" : "slate"
|
|
50
|
+
|
|
51
|
+
function findBinary(startDir) {
|
|
52
|
+
let current = startDir
|
|
53
|
+
for (;;) {
|
|
54
|
+
const modules = path.join(current, "node_modules")
|
|
55
|
+
if (fs.existsSync(modules)) {
|
|
56
|
+
const entries = fs.readdirSync(modules)
|
|
57
|
+
for (const entry of entries) {
|
|
58
|
+
if (!entry.startsWith(base)) {
|
|
59
|
+
continue
|
|
60
|
+
}
|
|
61
|
+
const candidate = path.join(modules, entry, "bin", binary)
|
|
62
|
+
if (fs.existsSync(candidate)) {
|
|
63
|
+
return candidate
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
const scopedCandidate = path.join(modules, "@randomlabs", base, "bin", binary)
|
|
67
|
+
if (fs.existsSync(scopedCandidate)) {
|
|
68
|
+
return scopedCandidate
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
const parent = path.dirname(current)
|
|
72
|
+
if (parent === current) {
|
|
73
|
+
return
|
|
74
|
+
}
|
|
75
|
+
current = parent
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
function findBinaryInDist(rootDir) {
|
|
80
|
+
const candidate = path.join(rootDir, "dist", "@randomlabs", base, "bin", binary)
|
|
81
|
+
if (fs.existsSync(candidate)) {
|
|
82
|
+
return candidate
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
const resolved = findBinary(scriptDir) || findBinaryInDist(projectRoot)
|
|
87
|
+
if (!resolved) {
|
|
88
|
+
console.error(
|
|
89
|
+
'It seems that your package manager failed to install the right version of the slate CLI for your platform. You can try manually installing the "' +
|
|
90
|
+
base +
|
|
91
|
+
'" package',
|
|
92
|
+
)
|
|
93
|
+
process.exit(1)
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
run(resolved)
|
package/package.json
CHANGED
|
@@ -6,19 +6,19 @@
|
|
|
6
6
|
"scripts": {
|
|
7
7
|
"postinstall": "bun ./postinstall.mjs || node ./postinstall.mjs"
|
|
8
8
|
},
|
|
9
|
-
"version": "1.0.
|
|
9
|
+
"version": "1.0.26",
|
|
10
10
|
"license": "Proprietary",
|
|
11
11
|
"optionalDependencies": {
|
|
12
|
-
"@randomlabs/slate-linux-arm64": "1.0.
|
|
13
|
-
"@randomlabs/slate-linux-x64-baseline-musl": "1.0.
|
|
14
|
-
"@randomlabs/slate-darwin-arm64": "1.0.
|
|
15
|
-
"@randomlabs/slate-windows-x64": "1.0.
|
|
16
|
-
"@randomlabs/slate-windows-x64-baseline": "1.0.
|
|
17
|
-
"@randomlabs/slate-darwin-x64": "1.0.
|
|
18
|
-
"@randomlabs/slate-linux-x64-musl": "1.0.
|
|
19
|
-
"@randomlabs/slate-linux-arm64-musl": "1.0.
|
|
20
|
-
"@randomlabs/slate-linux-x64-baseline": "1.0.
|
|
21
|
-
"@randomlabs/slate-darwin-x64-baseline": "1.0.
|
|
22
|
-
"@randomlabs/slate-linux-x64": "1.0.
|
|
12
|
+
"@randomlabs/slate-linux-arm64": "1.0.26",
|
|
13
|
+
"@randomlabs/slate-linux-x64-baseline-musl": "1.0.26",
|
|
14
|
+
"@randomlabs/slate-darwin-arm64": "1.0.26",
|
|
15
|
+
"@randomlabs/slate-windows-x64": "1.0.26",
|
|
16
|
+
"@randomlabs/slate-windows-x64-baseline": "1.0.26",
|
|
17
|
+
"@randomlabs/slate-darwin-x64": "1.0.26",
|
|
18
|
+
"@randomlabs/slate-linux-x64-musl": "1.0.26",
|
|
19
|
+
"@randomlabs/slate-linux-arm64-musl": "1.0.26",
|
|
20
|
+
"@randomlabs/slate-linux-x64-baseline": "1.0.26",
|
|
21
|
+
"@randomlabs/slate-darwin-x64-baseline": "1.0.26",
|
|
22
|
+
"@randomlabs/slate-linux-x64": "1.0.26"
|
|
23
23
|
}
|
|
24
24
|
}
|
package/postinstall.mjs
CHANGED
|
@@ -1,125 +1,91 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
-
import fs from "fs"
|
|
4
|
-
import
|
|
5
|
-
import os from "os"
|
|
6
|
-
import
|
|
7
|
-
import {
|
|
3
|
+
import fs from "node:fs";
|
|
4
|
+
import { createRequire } from "node:module";
|
|
5
|
+
import os from "node:os";
|
|
6
|
+
import path from "node:path";
|
|
7
|
+
import { fileURLToPath } from "node:url";
|
|
8
8
|
|
|
9
|
-
const __dirname = path.dirname(fileURLToPath(import.meta.url))
|
|
10
|
-
const require = createRequire(import.meta.url)
|
|
9
|
+
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
10
|
+
const require = createRequire(import.meta.url);
|
|
11
11
|
|
|
12
12
|
function detectPlatformAndArch() {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
return { platform, arch }
|
|
13
|
+
let platform;
|
|
14
|
+
switch (os.platform()) {
|
|
15
|
+
case "darwin":
|
|
16
|
+
platform = "darwin";
|
|
17
|
+
break;
|
|
18
|
+
case "linux":
|
|
19
|
+
platform = "linux";
|
|
20
|
+
break;
|
|
21
|
+
case "win32":
|
|
22
|
+
platform = "windows";
|
|
23
|
+
break;
|
|
24
|
+
default:
|
|
25
|
+
platform = os.platform();
|
|
26
|
+
break;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
let arch;
|
|
30
|
+
switch (os.arch()) {
|
|
31
|
+
case "x64":
|
|
32
|
+
arch = "x64";
|
|
33
|
+
break;
|
|
34
|
+
case "arm64":
|
|
35
|
+
arch = "arm64";
|
|
36
|
+
break;
|
|
37
|
+
case "arm":
|
|
38
|
+
arch = "arm";
|
|
39
|
+
break;
|
|
40
|
+
default:
|
|
41
|
+
arch = os.arch();
|
|
42
|
+
break;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
return { platform, arch };
|
|
48
46
|
}
|
|
49
47
|
|
|
50
48
|
function findBinary() {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
function prepareBinDirectory(binaryName) {
|
|
72
|
-
const binDir = path.join(__dirname, "bin")
|
|
73
|
-
const targetPath = path.join(binDir, binaryName)
|
|
74
|
-
|
|
75
|
-
// Ensure bin directory exists
|
|
76
|
-
if (!fs.existsSync(binDir)) {
|
|
77
|
-
fs.mkdirSync(binDir, { recursive: true })
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
// Remove existing binary/symlink if it exists
|
|
81
|
-
if (fs.existsSync(targetPath)) {
|
|
82
|
-
fs.unlinkSync(targetPath)
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
return { binDir, targetPath }
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
function symlinkBinary(sourcePath, binaryName) {
|
|
89
|
-
const { targetPath } = prepareBinDirectory(binaryName)
|
|
90
|
-
|
|
91
|
-
fs.symlinkSync(sourcePath, targetPath)
|
|
92
|
-
console.log(`slate binary symlinked: ${targetPath} -> ${sourcePath}`)
|
|
93
|
-
|
|
94
|
-
// Verify the file exists after operation
|
|
95
|
-
if (!fs.existsSync(targetPath)) {
|
|
96
|
-
throw new Error(`Failed to symlink binary to ${targetPath}`)
|
|
97
|
-
}
|
|
49
|
+
const { platform, arch } = detectPlatformAndArch();
|
|
50
|
+
const packageName = "@randomlabs/slate-" + platform + "-" + arch;
|
|
51
|
+
const binaryName = platform === "windows" ? "slate.exe" : "slate";
|
|
52
|
+
|
|
53
|
+
try {
|
|
54
|
+
const packageJsonPath = require.resolve(packageName + "/package.json");
|
|
55
|
+
const packageDir = path.dirname(packageJsonPath);
|
|
56
|
+
const binaryPath = path.join(packageDir, "bin", binaryName);
|
|
57
|
+
|
|
58
|
+
if (!fs.existsSync(binaryPath)) {
|
|
59
|
+
throw new Error("Binary not found at " + binaryPath);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
return { binaryPath, binaryName };
|
|
63
|
+
} catch (error) {
|
|
64
|
+
throw new Error("Could not find package " + packageName + ": " + error.message);
|
|
65
|
+
}
|
|
98
66
|
}
|
|
99
67
|
|
|
100
68
|
async function main() {
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
process.exit(1)
|
|
117
|
-
}
|
|
69
|
+
try {
|
|
70
|
+
if (os.platform() === "win32") {
|
|
71
|
+
console.log(
|
|
72
|
+
"Windows detected: binary setup not needed (using packaged .exe)",
|
|
73
|
+
);
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
const { binaryPath } = findBinary();
|
|
78
|
+
console.log("Platform binary verified at: " + binaryPath);
|
|
79
|
+
console.log("Wrapper script will handle binary execution");
|
|
80
|
+
} catch (error) {
|
|
81
|
+
console.error("Failed to setup slate binary:", error.message);
|
|
82
|
+
process.exit(1);
|
|
83
|
+
}
|
|
118
84
|
}
|
|
119
85
|
|
|
120
86
|
try {
|
|
121
|
-
|
|
87
|
+
main();
|
|
122
88
|
} catch (error) {
|
|
123
|
-
|
|
124
|
-
|
|
89
|
+
console.error("Postinstall script error:", error.message);
|
|
90
|
+
process.exit(0);
|
|
125
91
|
}
|
package/bin/slate1
DELETED
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env bun
|
|
2
|
-
|
|
3
|
-
import { spawnSync } from "child_process"
|
|
4
|
-
import { existsSync, readdirSync, realpathSync } from "fs"
|
|
5
|
-
import { dirname, join } from "path"
|
|
6
|
-
import { platform, arch } from "os"
|
|
7
|
-
|
|
8
|
-
function run(target) {
|
|
9
|
-
const result = spawnSync(target, process.argv.slice(2), {
|
|
10
|
-
stdio: "inherit",
|
|
11
|
-
})
|
|
12
|
-
if (result.error) {
|
|
13
|
-
console.error(result.error.message)
|
|
14
|
-
process.exit(1)
|
|
15
|
-
}
|
|
16
|
-
const code = typeof result.status === "number" ? result.status : 0
|
|
17
|
-
process.exit(code)
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
const envPath = process.env.SLATE_BIN_PATH
|
|
21
|
-
if (envPath) {
|
|
22
|
-
run(envPath)
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
const scriptPath = realpathSync(import.meta.filename)
|
|
26
|
-
const scriptDir = dirname(scriptPath)
|
|
27
|
-
const projectRoot = dirname(scriptDir)
|
|
28
|
-
|
|
29
|
-
const platformMap = {
|
|
30
|
-
darwin: "darwin",
|
|
31
|
-
linux: "linux",
|
|
32
|
-
win32: "windows",
|
|
33
|
-
}
|
|
34
|
-
const archMap = {
|
|
35
|
-
x64: "x64",
|
|
36
|
-
arm64: "arm64",
|
|
37
|
-
arm: "arm",
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
let plat = platformMap[platform()]
|
|
41
|
-
if (!plat) {
|
|
42
|
-
plat = platform()
|
|
43
|
-
}
|
|
44
|
-
let ar = archMap[arch()]
|
|
45
|
-
if (!ar) {
|
|
46
|
-
ar = arch()
|
|
47
|
-
}
|
|
48
|
-
const base = "slate-" + plat + "-" + ar
|
|
49
|
-
const binary = plat === "windows" ? "slate.exe" : "slate"
|
|
50
|
-
|
|
51
|
-
function findBinaryInNodeModules(startDir) {
|
|
52
|
-
let current = startDir
|
|
53
|
-
for (;;) {
|
|
54
|
-
const modules = join(current, "node_modules")
|
|
55
|
-
if (existsSync(modules)) {
|
|
56
|
-
const entries = readdirSync(modules)
|
|
57
|
-
for (const entry of entries) {
|
|
58
|
-
if (!entry.startsWith(base)) {
|
|
59
|
-
continue
|
|
60
|
-
}
|
|
61
|
-
const candidate = join(modules, entry, "bin", binary)
|
|
62
|
-
if (existsSync(candidate)) {
|
|
63
|
-
return candidate
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
const parent = dirname(current)
|
|
68
|
-
if (parent === current) {
|
|
69
|
-
return
|
|
70
|
-
}
|
|
71
|
-
current = parent
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
function findBinaryInDist(rootDir) {
|
|
76
|
-
const distDir = join(rootDir, "dist")
|
|
77
|
-
if (!existsSync(distDir)) {
|
|
78
|
-
return
|
|
79
|
-
}
|
|
80
|
-
const candidate = join(distDir, base, "bin", binary)
|
|
81
|
-
if (existsSync(candidate)) {
|
|
82
|
-
return candidate
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
// First try from current working directory's node_modules,
|
|
87
|
-
// then script directory's node_modules,
|
|
88
|
-
// then the dist directory relative to the project root
|
|
89
|
-
const resolved =
|
|
90
|
-
findBinaryInNodeModules(process.cwd()) ||
|
|
91
|
-
findBinaryInNodeModules(scriptDir) ||
|
|
92
|
-
findBinaryInDist(projectRoot)
|
|
93
|
-
|
|
94
|
-
if (!resolved) {
|
|
95
|
-
console.error(
|
|
96
|
-
'It seems that your package manager failed to install the right version of the slate CLI for your platform. You can try manually installing the "' +
|
|
97
|
-
base +
|
|
98
|
-
'" package',
|
|
99
|
-
)
|
|
100
|
-
process.exit(1)
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
run(resolved)
|