create-puzzmo 1.0.9 → 1.0.11
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/README.md +6 -6
- package/package.json +1 -1
- package/src/index.js +22 -4
package/README.md
CHANGED
|
@@ -22,12 +22,12 @@ yarn create puzzmo game [accesstoken] --name <name> --url <url> --agent <agent>
|
|
|
22
22
|
|
|
23
23
|
<!-- cspell:ignore accesstoken -->
|
|
24
24
|
|
|
25
|
-
| Option | Description
|
|
26
|
-
| ----------------- |
|
|
27
|
-
| `[accesstoken]` | Optional Puzzmo API token for deployment setup
|
|
28
|
-
| `--name <name>` | Game name (prompted if not provided)
|
|
29
|
-
| `--url <url>` | Source URL to import an HTML game from
|
|
30
|
-
| `--agent <agent>` | LLM agent to use: `claude`, `codex`, `gemini`, or `none`
|
|
25
|
+
| Option | Description |
|
|
26
|
+
| ----------------- | -------------------------------------------------------- |
|
|
27
|
+
| `[accesstoken]` | Optional Puzzmo API token for deployment setup |
|
|
28
|
+
| `--name <name>` | Game name (prompted if not provided) |
|
|
29
|
+
| `--url <url>` | Source URL to import an HTML game from |
|
|
30
|
+
| `--agent <agent>` | LLM agent to use: `claude`, `codex`, `gemini`, or `none` |
|
|
31
31
|
|
|
32
32
|
## Workflow
|
|
33
33
|
|
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
import { spawnSync } from "node:child_process"
|
|
4
|
-
|
|
4
|
+
import { get } from "node:https"
|
|
5
5
|
// Forward all args to `puzzmo game create`
|
|
6
6
|
const args = process.argv.slice(2)
|
|
7
7
|
|
|
8
8
|
// Detect the package manager that invoked this script
|
|
9
9
|
const pm = detectPackageManager()
|
|
10
10
|
|
|
11
|
-
//
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
// Fetch the actual latest version from the registry to avoid npm cache staleness
|
|
12
|
+
const version = await fetchLatestVersion("@puzzmo/cli")
|
|
13
|
+
console.log(`Installing @puzzmo/cli@${version}...`)
|
|
14
|
+
spawnSync("npm", ["install", "-g", `@puzzmo/cli@${version}`], { stdio: "inherit" })
|
|
14
15
|
|
|
15
16
|
// Pass --pm so the CLI knows which package manager to use in generated files
|
|
16
17
|
const extraArgs = args.includes("--pm") ? [] : ["--pm", pm]
|
|
@@ -28,3 +29,20 @@ function detectPackageManager() {
|
|
|
28
29
|
if (ua.startsWith("pnpm")) return "pnpm"
|
|
29
30
|
return "npm"
|
|
30
31
|
}
|
|
32
|
+
|
|
33
|
+
/** Fetches the latest version from the npm registry, falls back to "latest" tag */
|
|
34
|
+
function fetchLatestVersion(pkg) {
|
|
35
|
+
return new Promise((resolve) => {
|
|
36
|
+
get(`https://registry.npmjs.org/${pkg}/latest`, (res) => {
|
|
37
|
+
let data = ""
|
|
38
|
+
res.on("data", (chunk) => (data += chunk))
|
|
39
|
+
res.on("end", () => {
|
|
40
|
+
try {
|
|
41
|
+
resolve(JSON.parse(data).version)
|
|
42
|
+
} catch {
|
|
43
|
+
resolve("latest")
|
|
44
|
+
}
|
|
45
|
+
})
|
|
46
|
+
}).on("error", () => resolve("latest"))
|
|
47
|
+
})
|
|
48
|
+
}
|