@mty-coder/cli 0.1.6 → 0.1.9
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/{mty → mty.cjs} +30 -10
- package/package.json +2 -2
package/bin/{mty → mty.cjs}
RENAMED
|
@@ -5,8 +5,9 @@ const fs = require("fs")
|
|
|
5
5
|
const path = require("path")
|
|
6
6
|
const os = require("os")
|
|
7
7
|
|
|
8
|
-
function run(target) {
|
|
9
|
-
const
|
|
8
|
+
function run(target, extraArgs) {
|
|
9
|
+
const args = extraArgs ? [...extraArgs, ...process.argv.slice(2)] : process.argv.slice(2)
|
|
10
|
+
const result = childProcess.spawnSync(target, args, {
|
|
10
11
|
stdio: "inherit",
|
|
11
12
|
})
|
|
12
13
|
if (result.error) {
|
|
@@ -169,12 +170,31 @@ function findBinary(startDir) {
|
|
|
169
170
|
|
|
170
171
|
const resolved = findBinary(scriptDir)
|
|
171
172
|
if (!resolved) {
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
)
|
|
177
|
-
|
|
173
|
+
// Fallback: run via bun from the package root
|
|
174
|
+
const pkgRoot = path.resolve(scriptDir, "..")
|
|
175
|
+
const entryPoint = path.join(pkgRoot, "src", "index.ts")
|
|
176
|
+
|
|
177
|
+
if (fs.existsSync(entryPoint)) {
|
|
178
|
+
const bun = process.env.BUN_PATH || "bun"
|
|
179
|
+
// Check if bun is available
|
|
180
|
+
const check = childProcess.spawnSync(bun, ["--version"], {
|
|
181
|
+
encoding: "utf8",
|
|
182
|
+
timeout: 3000,
|
|
183
|
+
stdio: "pipe",
|
|
184
|
+
})
|
|
185
|
+
if (check.error || check.status !== 0) {
|
|
186
|
+
console.error("Error: bun is required to run mty. Install it from https://bun.sh")
|
|
187
|
+
process.exit(1)
|
|
188
|
+
}
|
|
189
|
+
run(bun, ["run", "--conditions=browser", entryPoint])
|
|
190
|
+
} else {
|
|
191
|
+
console.error(
|
|
192
|
+
"It seems that your package manager failed to install the right version of the mtycoder CLI for your platform. You can try manually installing " +
|
|
193
|
+
names.map((n) => `\"${n}\"`).join(" or ") +
|
|
194
|
+
" package",
|
|
195
|
+
)
|
|
196
|
+
process.exit(1)
|
|
197
|
+
}
|
|
198
|
+
} else {
|
|
199
|
+
run(resolved)
|
|
178
200
|
}
|
|
179
|
-
|
|
180
|
-
run(resolved)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json.schemastore.org/package.json",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.9",
|
|
4
4
|
"name": "@mty-coder/cli",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"db": "bun drizzle-kit"
|
|
22
22
|
},
|
|
23
23
|
"bin": {
|
|
24
|
-
"mty": "./bin/mty"
|
|
24
|
+
"mty": "./bin/mty.cjs"
|
|
25
25
|
},
|
|
26
26
|
"exports": {
|
|
27
27
|
"./*": "./src/*.ts"
|