@dforge-core/dforge-cli 0.1.0-rc.2 → 0.1.0-rc.3

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.
Files changed (4) hide show
  1. package/README.md +118 -7
  2. package/dist/cli.js +1387 -0
  3. package/package.json +42 -25
  4. package/index.js +0 -76
package/package.json CHANGED
@@ -1,26 +1,43 @@
1
1
  {
2
- "name": "@dforge-core/dforge-cli",
3
- "version": "0.1.0-rc.2",
4
- "description": "dForge CLI validate, pack, publish, and install dForge modules. Distributes a single-file native binary per platform via optionalDependencies (esbuild-style).",
5
- "license": "MIT",
6
- "homepage": "https://github.com/dforge-core/create-module",
7
- "bin": {
8
- "dforge-cli": "index.js"
9
- },
10
- "files": [
11
- "index.js",
12
- "README.md"
13
- ],
14
- "main": "index.js",
15
- "engines": {
16
- "node": ">=18"
17
- },
18
- "optionalDependencies": {
19
- "@dforge-core/dforge-cli-darwin-arm64": "0.1.0-rc.1",
20
- "@dforge-core/dforge-cli-darwin-x64": "0.1.0-rc.1",
21
- "@dforge-core/dforge-cli-win32-x64": "0.1.0-rc.1",
22
- "@dforge-core/dforge-cli-linux-x64": "0.1.0-rc.1",
23
- "@dforge-core/dforge-cli-win32-arm64": "0.1.0-rc.1",
24
- "@dforge-core/dforge-cli-linux-arm64": "0.1.0-rc.1"
25
- }
26
- }
2
+ "name": "@dforge-core/dforge-cli",
3
+ "version": "0.1.0-rc.3",
4
+ "description": "dForge CLI \u2014 validate, pack, publish, and install dForge modules. Distributes a single-file native binary per platform via optionalDependencies (esbuild-style).",
5
+ "license": "MIT",
6
+ "homepage": "https://github.com/iash44/dForge-core",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "https://github.com/dforge-core/dforge-cli.git"
10
+ },
11
+ "bin": {
12
+ "dforge-cli": "dist/cli.js"
13
+ },
14
+ "files": [
15
+ "dist/",
16
+ "README.md"
17
+ ],
18
+ "main": "dist/cli.js",
19
+ "engines": {
20
+ "node": ">=18"
21
+ },
22
+ "scripts": {
23
+ "build": "tsup",
24
+ "prepublishOnly": "tsup",
25
+ "typecheck": "tsc --noEmit"
26
+ },
27
+ "dependencies": {
28
+ "@clack/prompts": "^0.11.0"
29
+ },
30
+ "devDependencies": {
31
+ "@types/node": "^22.10.2",
32
+ "tsup": "^8.5.1",
33
+ "typescript": "^6.0.3"
34
+ },
35
+ "optionalDependencies": {
36
+ "@dforge-core/dforge-cli-darwin-arm64": "0.1.0-rc.2",
37
+ "@dforge-core/dforge-cli-darwin-x64": "0.1.0-rc.2",
38
+ "@dforge-core/dforge-cli-linux-arm64": "0.1.0-rc.2",
39
+ "@dforge-core/dforge-cli-linux-x64": "0.1.0-rc.2",
40
+ "@dforge-core/dforge-cli-win32-arm64": "0.1.0-rc.2",
41
+ "@dforge-core/dforge-cli-win32-x64": "0.1.0-rc.2"
42
+ }
43
+ }
package/index.js DELETED
@@ -1,76 +0,0 @@
1
- #!/usr/bin/env node
2
- // Resolve the platform-specific binary package via require.resolve. Mirrors the
3
- // esbuild distribution model: each supported platform is a separately-published
4
- // optionalDependency with `os`/`cpu` pins, so npm installs only the right one
5
- // for the user's machine. Fails fast with a clear message when no binary
6
- // matches (most often: user is on an unsupported platform, or someone passed
7
- // --no-optional to npm install).
8
- const { spawnSync } = require("node:child_process");
9
- const path = require("node:path");
10
- const fs = require("node:fs");
11
-
12
- const platformMap = {
13
- "darwin-arm64": "@dforge-core/dforge-cli-darwin-arm64",
14
- "darwin-x64": "@dforge-core/dforge-cli-darwin-x64",
15
- "linux-x64": "@dforge-core/dforge-cli-linux-x64",
16
- "linux-arm64": "@dforge-core/dforge-cli-linux-arm64",
17
- "win32-x64": "@dforge-core/dforge-cli-win32-x64",
18
- "win32-arm64": "@dforge-core/dforge-cli-win32-arm64",
19
- };
20
-
21
- function resolveBinary() {
22
- const key = `${process.platform}-${process.arch}`;
23
- const pkg = platformMap[key];
24
- if (!pkg) {
25
- console.error(
26
- `dforge-cli: unsupported platform "${key}". Supported: ${Object.keys(platformMap).join(", ")}.`,
27
- );
28
- process.exit(1);
29
- }
30
-
31
- let pkgJsonPath;
32
- try {
33
- pkgJsonPath = require.resolve(`${pkg}/package.json`);
34
- } catch {
35
- console.error(
36
- `dforge-cli: platform package "${pkg}" not installed. ` +
37
- `Re-run \`npm install\` without --no-optional, or install it explicitly.`,
38
- );
39
- process.exit(1);
40
- }
41
-
42
- const pkgDir = path.dirname(pkgJsonPath);
43
- const binName = process.platform === "win32" ? "dforge-cli.exe" : "dforge-cli";
44
- const binPath = path.join(pkgDir, "bin", binName);
45
- if (!fs.existsSync(binPath)) {
46
- console.error(`dforge-cli: binary missing at ${binPath}`);
47
- process.exit(1);
48
- }
49
-
50
- // Ensure the binary is executable. pnpm/npm tarball-packing has dropped the
51
- // +x bit on files outside `bin` fields in some versions, so a freshly-
52
- // downloaded sidecar can land as 0644 even though the local checkout was
53
- // 0755. chmod is idempotent — no-op when already executable — and skipped
54
- // on Windows where it has no effect on .exe invocation.
55
- if (process.platform !== "win32") {
56
- try {
57
- const mode = fs.statSync(binPath).mode;
58
- if ((mode & 0o111) === 0) fs.chmodSync(binPath, mode | 0o755);
59
- } catch (e) {
60
- // Non-fatal: spawnSync below will surface EACCES with a clear message
61
- // if chmod failed for an unexpected reason (read-only fs, perms).
62
- }
63
- }
64
- return binPath;
65
- }
66
-
67
- const result = spawnSync(resolveBinary(), process.argv.slice(2), {
68
- stdio: "inherit",
69
- shell: false,
70
- });
71
-
72
- if (result.error) {
73
- console.error(`dforge-cli: failed to exec binary: ${result.error.message}`);
74
- process.exit(1);
75
- }
76
- process.exit(result.status ?? 1);