@dforge-core/dforge-cli 0.1.0-test.5 → 0.1.1

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/dist/lib.d.mts ADDED
@@ -0,0 +1,68 @@
1
+ type Preset = "minimal" | "minimal-plus" | "full";
2
+ type Traits = "identity" | "identity+audit";
3
+ interface EntitySpec {
4
+ name: string;
5
+ label: string;
6
+ traits: Traits;
7
+ }
8
+ interface ScaffoldOpts {
9
+ path: string;
10
+ code: string;
11
+ displayName: string;
12
+ description: string;
13
+ author: string;
14
+ license: string;
15
+ version: string;
16
+ dbSchemaVersion: string;
17
+ dependencies: string[];
18
+ preset: Preset;
19
+ entities: EntitySpec[];
20
+ }
21
+ interface Manifest {
22
+ packageFormat: number;
23
+ moduleId: string;
24
+ code: string;
25
+ version: string;
26
+ dbSchemaVersion: string;
27
+ displayName: string;
28
+ description?: string;
29
+ author?: {
30
+ name: string;
31
+ };
32
+ license?: string;
33
+ dependencies?: Record<string, string>;
34
+ entities: Record<string, string>;
35
+ created?: string;
36
+ updated?: string;
37
+ }
38
+ interface Entity {
39
+ description: string;
40
+ dbObject: string;
41
+ toString: string;
42
+ traits: string[];
43
+ fields: Record<string, unknown>;
44
+ }
45
+ interface DataView {
46
+ viewType: string;
47
+ label: string;
48
+ dataSources: Array<{
49
+ entityCode: string;
50
+ columns: string[];
51
+ }>;
52
+ }
53
+
54
+ declare function buildManifest(opts: ScaffoldOpts, moduleId: string): Manifest;
55
+ declare function buildEntity(entity: EntitySpec): Entity;
56
+ declare function buildDataViews(entities: EntitySpec[]): Record<string, DataView>;
57
+ declare function buildFolders(opts: ScaffoldOpts): Record<string, unknown>;
58
+ declare function buildMenus(opts: ScaffoldOpts): Record<string, unknown>;
59
+ declare function buildRoles(opts: ScaffoldOpts): Record<string, unknown>;
60
+ declare function buildActions(): Record<string, unknown>;
61
+ declare function buildSettings(): Record<string, unknown>;
62
+ declare function buildTranslations(opts: ScaffoldOpts): Record<string, string>;
63
+ declare function buildSeedData(): unknown[];
64
+ declare function buildGitignore(): string;
65
+ declare function buildVscodeSettings(): Record<string, unknown>;
66
+ declare function buildZedSettings(): Record<string, unknown>;
67
+
68
+ export { type DataView, type Entity, type EntitySpec, type Manifest, type Preset, type ScaffoldOpts, type Traits, buildActions, buildDataViews, buildEntity, buildFolders, buildGitignore, buildManifest, buildMenus, buildRoles, buildSeedData, buildSettings, buildTranslations, buildVscodeSettings, buildZedSettings };
package/dist/lib.d.ts ADDED
@@ -0,0 +1,68 @@
1
+ type Preset = "minimal" | "minimal-plus" | "full";
2
+ type Traits = "identity" | "identity+audit";
3
+ interface EntitySpec {
4
+ name: string;
5
+ label: string;
6
+ traits: Traits;
7
+ }
8
+ interface ScaffoldOpts {
9
+ path: string;
10
+ code: string;
11
+ displayName: string;
12
+ description: string;
13
+ author: string;
14
+ license: string;
15
+ version: string;
16
+ dbSchemaVersion: string;
17
+ dependencies: string[];
18
+ preset: Preset;
19
+ entities: EntitySpec[];
20
+ }
21
+ interface Manifest {
22
+ packageFormat: number;
23
+ moduleId: string;
24
+ code: string;
25
+ version: string;
26
+ dbSchemaVersion: string;
27
+ displayName: string;
28
+ description?: string;
29
+ author?: {
30
+ name: string;
31
+ };
32
+ license?: string;
33
+ dependencies?: Record<string, string>;
34
+ entities: Record<string, string>;
35
+ created?: string;
36
+ updated?: string;
37
+ }
38
+ interface Entity {
39
+ description: string;
40
+ dbObject: string;
41
+ toString: string;
42
+ traits: string[];
43
+ fields: Record<string, unknown>;
44
+ }
45
+ interface DataView {
46
+ viewType: string;
47
+ label: string;
48
+ dataSources: Array<{
49
+ entityCode: string;
50
+ columns: string[];
51
+ }>;
52
+ }
53
+
54
+ declare function buildManifest(opts: ScaffoldOpts, moduleId: string): Manifest;
55
+ declare function buildEntity(entity: EntitySpec): Entity;
56
+ declare function buildDataViews(entities: EntitySpec[]): Record<string, DataView>;
57
+ declare function buildFolders(opts: ScaffoldOpts): Record<string, unknown>;
58
+ declare function buildMenus(opts: ScaffoldOpts): Record<string, unknown>;
59
+ declare function buildRoles(opts: ScaffoldOpts): Record<string, unknown>;
60
+ declare function buildActions(): Record<string, unknown>;
61
+ declare function buildSettings(): Record<string, unknown>;
62
+ declare function buildTranslations(opts: ScaffoldOpts): Record<string, string>;
63
+ declare function buildSeedData(): unknown[];
64
+ declare function buildGitignore(): string;
65
+ declare function buildVscodeSettings(): Record<string, unknown>;
66
+ declare function buildZedSettings(): Record<string, unknown>;
67
+
68
+ export { type DataView, type Entity, type EntitySpec, type Manifest, type Preset, type ScaffoldOpts, type Traits, buildActions, buildDataViews, buildEntity, buildFolders, buildGitignore, buildManifest, buildMenus, buildRoles, buildSeedData, buildSettings, buildTranslations, buildVscodeSettings, buildZedSettings };
package/dist/lib.js ADDED
@@ -0,0 +1,216 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/lib.ts
21
+ var lib_exports = {};
22
+ __export(lib_exports, {
23
+ buildActions: () => buildActions,
24
+ buildDataViews: () => buildDataViews,
25
+ buildEntity: () => buildEntity,
26
+ buildFolders: () => buildFolders,
27
+ buildGitignore: () => buildGitignore,
28
+ buildManifest: () => buildManifest,
29
+ buildMenus: () => buildMenus,
30
+ buildRoles: () => buildRoles,
31
+ buildSeedData: () => buildSeedData,
32
+ buildSettings: () => buildSettings,
33
+ buildTranslations: () => buildTranslations,
34
+ buildVscodeSettings: () => buildVscodeSettings,
35
+ buildZedSettings: () => buildZedSettings
36
+ });
37
+ module.exports = __toCommonJS(lib_exports);
38
+
39
+ // src/init/templates.ts
40
+ function buildManifest(opts, moduleId) {
41
+ const today = (/* @__PURE__ */ new Date()).toISOString().slice(0, 10);
42
+ const manifest = {
43
+ packageFormat: 1,
44
+ moduleId,
45
+ code: opts.code,
46
+ version: opts.version,
47
+ dbSchemaVersion: opts.dbSchemaVersion,
48
+ displayName: opts.displayName,
49
+ entities: Object.fromEntries(
50
+ opts.entities.map((e) => [e.name, `./entities/${e.name}.json`])
51
+ ),
52
+ created: today,
53
+ updated: today
54
+ };
55
+ if (opts.description) manifest.description = opts.description;
56
+ if (opts.author) manifest.author = { name: opts.author };
57
+ if (opts.license) manifest.license = opts.license;
58
+ if (opts.dependencies.length > 0) {
59
+ manifest.dependencies = Object.fromEntries(
60
+ opts.dependencies.map((d) => [d, ">=0.0.1"])
61
+ );
62
+ }
63
+ return manifest;
64
+ }
65
+ function buildEntity(entity) {
66
+ const traits = entity.traits === "identity+audit" ? ["identity", "audit"] : ["identity"];
67
+ return {
68
+ description: entity.label,
69
+ dbObject: entity.name,
70
+ toString: "{id}",
71
+ traits,
72
+ fields: {}
73
+ };
74
+ }
75
+ function buildDataViews(entities) {
76
+ const views = {};
77
+ for (const e of entities) {
78
+ views[e.name] = {
79
+ viewType: "grid",
80
+ label: e.label,
81
+ dataSources: [
82
+ {
83
+ entityCode: e.name,
84
+ columns: []
85
+ }
86
+ ]
87
+ };
88
+ }
89
+ return views;
90
+ }
91
+ function buildFolders(opts) {
92
+ return {
93
+ [opts.code]: {
94
+ label: opts.displayName,
95
+ description: opts.description || opts.displayName,
96
+ icon: "bi-folder",
97
+ color: "#2196F3",
98
+ entities: Object.fromEntries(
99
+ opts.entities.map((e) => [
100
+ e.name,
101
+ { viewName: e.name, quickAdd: true }
102
+ ])
103
+ )
104
+ }
105
+ };
106
+ }
107
+ function buildMenus(opts) {
108
+ return {
109
+ [`${opts.code}_menu`]: {
110
+ label: opts.displayName,
111
+ items: Object.fromEntries(
112
+ opts.entities.map((e, idx) => [
113
+ e.name,
114
+ {
115
+ itemType: "V",
116
+ label: e.label,
117
+ dataViewCode: e.name,
118
+ orderNum: idx + 1,
119
+ icon: "table"
120
+ }
121
+ ])
122
+ )
123
+ }
124
+ };
125
+ }
126
+ function buildRoles(opts) {
127
+ const rights = {};
128
+ for (const e of opts.entities) rights[e.name] = "SIUDC";
129
+ return {
130
+ [`${opts.code}.admin`]: {
131
+ description: `${opts.displayName} administrators`,
132
+ rights
133
+ }
134
+ };
135
+ }
136
+ function buildActions() {
137
+ return {};
138
+ }
139
+ function buildSettings() {
140
+ return {};
141
+ }
142
+ function buildTranslations(opts) {
143
+ const t = {};
144
+ t[`module.${opts.code}.label`] = opts.displayName;
145
+ if (opts.description) t[`module.${opts.code}.description`] = opts.description;
146
+ for (const e of opts.entities) {
147
+ t[`entity.${e.name}.label`] = e.label;
148
+ t[`view.${e.name}.label`] = e.label;
149
+ t[`menu.${e.name}.label`] = e.label;
150
+ }
151
+ return t;
152
+ }
153
+ function buildSeedData() {
154
+ return [];
155
+ }
156
+ function buildGitignore() {
157
+ return [
158
+ "# Built module package archives",
159
+ "*.dforge",
160
+ "",
161
+ "# Editor / OS noise",
162
+ "node_modules/",
163
+ ".DS_Store",
164
+ "*.swp",
165
+ ""
166
+ ].join("\n");
167
+ }
168
+ var SCHEMA_BASE = "https://cdn.jsdelivr.net/npm/@dforge-core/dforge-mcp@latest/resources/schemas";
169
+ var SCHEMA_BINDINGS = [
170
+ { fileMatch: ["manifest.json"], schema: "manifest" },
171
+ { fileMatch: ["entities/*.json"], schema: "entity" },
172
+ { fileMatch: ["ui/data_views.json"], schema: "data-views" },
173
+ { fileMatch: ["ui/folders.json"], schema: "folders" },
174
+ { fileMatch: ["ui/menus.json"], schema: "menus" },
175
+ { fileMatch: ["ui/reports.json"], schema: "reports" },
176
+ { fileMatch: ["security/roles.json"], schema: "roles" },
177
+ { fileMatch: ["logic/jobs.json"], schema: "jobs" },
178
+ { fileMatch: ["seed-data/*.json"], schema: "seed-data" },
179
+ { fileMatch: ["settings.json"], schema: "settings" }
180
+ ];
181
+ function buildVscodeSettings() {
182
+ return {
183
+ "json.schemas": SCHEMA_BINDINGS.map((b) => ({
184
+ fileMatch: b.fileMatch,
185
+ url: `${SCHEMA_BASE}/${b.schema}.schema.json`
186
+ }))
187
+ };
188
+ }
189
+ function buildZedSettings() {
190
+ return {
191
+ languages: {
192
+ JSON: {
193
+ "json.schemas": SCHEMA_BINDINGS.map((b) => ({
194
+ fileMatch: b.fileMatch,
195
+ url: `${SCHEMA_BASE}/${b.schema}.schema.json`
196
+ }))
197
+ }
198
+ }
199
+ };
200
+ }
201
+ // Annotate the CommonJS export names for ESM import in node:
202
+ 0 && (module.exports = {
203
+ buildActions,
204
+ buildDataViews,
205
+ buildEntity,
206
+ buildFolders,
207
+ buildGitignore,
208
+ buildManifest,
209
+ buildMenus,
210
+ buildRoles,
211
+ buildSeedData,
212
+ buildSettings,
213
+ buildTranslations,
214
+ buildVscodeSettings,
215
+ buildZedSettings
216
+ });
package/dist/lib.mjs ADDED
@@ -0,0 +1,177 @@
1
+ // src/init/templates.ts
2
+ function buildManifest(opts, moduleId) {
3
+ const today = (/* @__PURE__ */ new Date()).toISOString().slice(0, 10);
4
+ const manifest = {
5
+ packageFormat: 1,
6
+ moduleId,
7
+ code: opts.code,
8
+ version: opts.version,
9
+ dbSchemaVersion: opts.dbSchemaVersion,
10
+ displayName: opts.displayName,
11
+ entities: Object.fromEntries(
12
+ opts.entities.map((e) => [e.name, `./entities/${e.name}.json`])
13
+ ),
14
+ created: today,
15
+ updated: today
16
+ };
17
+ if (opts.description) manifest.description = opts.description;
18
+ if (opts.author) manifest.author = { name: opts.author };
19
+ if (opts.license) manifest.license = opts.license;
20
+ if (opts.dependencies.length > 0) {
21
+ manifest.dependencies = Object.fromEntries(
22
+ opts.dependencies.map((d) => [d, ">=0.0.1"])
23
+ );
24
+ }
25
+ return manifest;
26
+ }
27
+ function buildEntity(entity) {
28
+ const traits = entity.traits === "identity+audit" ? ["identity", "audit"] : ["identity"];
29
+ return {
30
+ description: entity.label,
31
+ dbObject: entity.name,
32
+ toString: "{id}",
33
+ traits,
34
+ fields: {}
35
+ };
36
+ }
37
+ function buildDataViews(entities) {
38
+ const views = {};
39
+ for (const e of entities) {
40
+ views[e.name] = {
41
+ viewType: "grid",
42
+ label: e.label,
43
+ dataSources: [
44
+ {
45
+ entityCode: e.name,
46
+ columns: []
47
+ }
48
+ ]
49
+ };
50
+ }
51
+ return views;
52
+ }
53
+ function buildFolders(opts) {
54
+ return {
55
+ [opts.code]: {
56
+ label: opts.displayName,
57
+ description: opts.description || opts.displayName,
58
+ icon: "bi-folder",
59
+ color: "#2196F3",
60
+ entities: Object.fromEntries(
61
+ opts.entities.map((e) => [
62
+ e.name,
63
+ { viewName: e.name, quickAdd: true }
64
+ ])
65
+ )
66
+ }
67
+ };
68
+ }
69
+ function buildMenus(opts) {
70
+ return {
71
+ [`${opts.code}_menu`]: {
72
+ label: opts.displayName,
73
+ items: Object.fromEntries(
74
+ opts.entities.map((e, idx) => [
75
+ e.name,
76
+ {
77
+ itemType: "V",
78
+ label: e.label,
79
+ dataViewCode: e.name,
80
+ orderNum: idx + 1,
81
+ icon: "table"
82
+ }
83
+ ])
84
+ )
85
+ }
86
+ };
87
+ }
88
+ function buildRoles(opts) {
89
+ const rights = {};
90
+ for (const e of opts.entities) rights[e.name] = "SIUDC";
91
+ return {
92
+ [`${opts.code}.admin`]: {
93
+ description: `${opts.displayName} administrators`,
94
+ rights
95
+ }
96
+ };
97
+ }
98
+ function buildActions() {
99
+ return {};
100
+ }
101
+ function buildSettings() {
102
+ return {};
103
+ }
104
+ function buildTranslations(opts) {
105
+ const t = {};
106
+ t[`module.${opts.code}.label`] = opts.displayName;
107
+ if (opts.description) t[`module.${opts.code}.description`] = opts.description;
108
+ for (const e of opts.entities) {
109
+ t[`entity.${e.name}.label`] = e.label;
110
+ t[`view.${e.name}.label`] = e.label;
111
+ t[`menu.${e.name}.label`] = e.label;
112
+ }
113
+ return t;
114
+ }
115
+ function buildSeedData() {
116
+ return [];
117
+ }
118
+ function buildGitignore() {
119
+ return [
120
+ "# Built module package archives",
121
+ "*.dforge",
122
+ "",
123
+ "# Editor / OS noise",
124
+ "node_modules/",
125
+ ".DS_Store",
126
+ "*.swp",
127
+ ""
128
+ ].join("\n");
129
+ }
130
+ var SCHEMA_BASE = "https://cdn.jsdelivr.net/npm/@dforge-core/dforge-mcp@latest/resources/schemas";
131
+ var SCHEMA_BINDINGS = [
132
+ { fileMatch: ["manifest.json"], schema: "manifest" },
133
+ { fileMatch: ["entities/*.json"], schema: "entity" },
134
+ { fileMatch: ["ui/data_views.json"], schema: "data-views" },
135
+ { fileMatch: ["ui/folders.json"], schema: "folders" },
136
+ { fileMatch: ["ui/menus.json"], schema: "menus" },
137
+ { fileMatch: ["ui/reports.json"], schema: "reports" },
138
+ { fileMatch: ["security/roles.json"], schema: "roles" },
139
+ { fileMatch: ["logic/jobs.json"], schema: "jobs" },
140
+ { fileMatch: ["seed-data/*.json"], schema: "seed-data" },
141
+ { fileMatch: ["settings.json"], schema: "settings" }
142
+ ];
143
+ function buildVscodeSettings() {
144
+ return {
145
+ "json.schemas": SCHEMA_BINDINGS.map((b) => ({
146
+ fileMatch: b.fileMatch,
147
+ url: `${SCHEMA_BASE}/${b.schema}.schema.json`
148
+ }))
149
+ };
150
+ }
151
+ function buildZedSettings() {
152
+ return {
153
+ languages: {
154
+ JSON: {
155
+ "json.schemas": SCHEMA_BINDINGS.map((b) => ({
156
+ fileMatch: b.fileMatch,
157
+ url: `${SCHEMA_BASE}/${b.schema}.schema.json`
158
+ }))
159
+ }
160
+ }
161
+ };
162
+ }
163
+ export {
164
+ buildActions,
165
+ buildDataViews,
166
+ buildEntity,
167
+ buildFolders,
168
+ buildGitignore,
169
+ buildManifest,
170
+ buildMenus,
171
+ buildRoles,
172
+ buildSeedData,
173
+ buildSettings,
174
+ buildTranslations,
175
+ buildVscodeSettings,
176
+ buildZedSettings
177
+ };
package/package.json CHANGED
@@ -1,30 +1,51 @@
1
1
  {
2
2
  "name": "@dforge-core/dforge-cli",
3
- "version": "0.1.0-test.5",
4
- "description": "dForge CLI \u2014 validate, pack, publish, and install dForge modules. Distributes a single-file native binary per platform via optionalDependencies (esbuild-style).",
3
+ "version": "0.1.1",
4
+ "description": "dForge CLI - validate, pack, publish, and install dForge modules. Distributes a single-file native binary per platform via optionalDependencies (esbuild-style).",
5
5
  "license": "MIT",
6
6
  "homepage": "https://github.com/iash44/dForge-core",
7
7
  "repository": {
8
8
  "type": "git",
9
- "url": "https://github.com/dforge-core/dforge-cli.git"
9
+ "url": "git+https://github.com/dforge-core/dforge-cli.git"
10
10
  },
11
11
  "bin": {
12
- "dforge-cli": "index.js"
12
+ "dforge-cli": "dist/cli.js"
13
13
  },
14
14
  "files": [
15
- "index.js",
15
+ "dist/",
16
16
  "README.md"
17
17
  ],
18
- "main": "index.js",
18
+ "main": "dist/cli.js",
19
+ "exports": {
20
+ ".": "./dist/cli.js",
21
+ "./templates": {
22
+ "types": "./dist/lib.d.ts",
23
+ "import": "./dist/lib.mjs",
24
+ "require": "./dist/lib.js"
25
+ }
26
+ },
19
27
  "engines": {
20
28
  "node": ">=18"
21
29
  },
30
+ "scripts": {
31
+ "build": "tsup",
32
+ "prepublishOnly": "tsup",
33
+ "typecheck": "tsc --noEmit"
34
+ },
35
+ "dependencies": {
36
+ "@clack/prompts": "^0.11.0"
37
+ },
38
+ "devDependencies": {
39
+ "@types/node": "^22.10.2",
40
+ "tsup": "^8.5.1",
41
+ "typescript": "^6.0.3"
42
+ },
22
43
  "optionalDependencies": {
23
- "@dforge-core/dforge-cli-darwin-arm64": "0.1.0-test.5",
24
- "@dforge-core/dforge-cli-darwin-x64": "0.1.0-test.5",
25
- "@dforge-core/dforge-cli-linux-x64": "0.1.0-test.5",
26
- "@dforge-core/dforge-cli-linux-arm64": "0.1.0-test.5",
27
- "@dforge-core/dforge-cli-win32-x64": "0.1.0-test.5",
28
- "@dforge-core/dforge-cli-win32-arm64": "0.1.0-test.5"
44
+ "@dforge-core/dforge-cli-darwin-arm64": "0.1.1",
45
+ "@dforge-core/dforge-cli-darwin-x64": "0.1.1",
46
+ "@dforge-core/dforge-cli-linux-arm64": "0.1.1",
47
+ "@dforge-core/dforge-cli-linux-x64": "0.1.1",
48
+ "@dforge-core/dforge-cli-win32-arm64": "0.1.1",
49
+ "@dforge-core/dforge-cli-win32-x64": "0.1.1"
29
50
  }
30
51
  }
package/index.js DELETED
@@ -1,100 +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
- // Escape hatch for source-repo / dist-repo maintainers who want to test a
23
- // freshly-built binary without going through the publish pipeline.
24
- // Honored before anything else.
25
- const override = process.env.DFORGE_CLI_BINARY;
26
- if (override) {
27
- if (!fs.existsSync(override)) {
28
- console.error(`dforge-cli: DFORGE_CLI_BINARY points at non-existent path: ${override}`);
29
- process.exit(1);
30
- }
31
- return override;
32
- }
33
-
34
- const key = `${process.platform}-${process.arch}`;
35
- const pkg = platformMap[key];
36
- if (!pkg) {
37
- console.error(
38
- `dforge-cli: unsupported platform "${key}". Supported: ${Object.keys(platformMap).join(", ")}.`,
39
- );
40
- process.exit(1);
41
- }
42
-
43
- let pkgJsonPath;
44
- try {
45
- pkgJsonPath = require.resolve(`${pkg}/package.json`);
46
- } catch {
47
- // Dist-repo dev fallback: after running scripts/fetch-binaries.sh the
48
- // sidecars sit under ./packages/<shortName>/ at the repo root, but
49
- // they're not in node_modules (no `pnpm install` to symlink them).
50
- // Check that path before bailing. Consumers of the published package
51
- // never hit this branch — require.resolve succeeds via npm-installed
52
- // node_modules.
53
- const shortName = pkg.split("/").pop();
54
- const siblingPkgJson = path.join(__dirname, "packages", shortName, "package.json");
55
- if (fs.existsSync(siblingPkgJson)) {
56
- pkgJsonPath = siblingPkgJson;
57
- } else {
58
- console.error(
59
- `dforge-cli: platform package "${pkg}" not installed. ` +
60
- `Re-run \`npm install\` without --no-optional, or install it explicitly.`,
61
- );
62
- process.exit(1);
63
- }
64
- }
65
-
66
- const pkgDir = path.dirname(pkgJsonPath);
67
- const binName = process.platform === "win32" ? "dforge-cli.exe" : "dforge-cli";
68
- const binPath = path.join(pkgDir, "bin", binName);
69
- if (!fs.existsSync(binPath)) {
70
- console.error(`dforge-cli: binary missing at ${binPath}`);
71
- process.exit(1);
72
- }
73
-
74
- // Ensure the binary is executable. pnpm/npm tarball-packing has dropped the
75
- // +x bit on files outside `bin` fields in some versions, so a freshly-
76
- // downloaded sidecar can land as 0644 even though the local checkout was
77
- // 0755. chmod is idempotent — no-op when already executable — and skipped
78
- // on Windows where it has no effect on .exe invocation.
79
- if (process.platform !== "win32") {
80
- try {
81
- const mode = fs.statSync(binPath).mode;
82
- if ((mode & 0o111) === 0) fs.chmodSync(binPath, mode | 0o755);
83
- } catch (e) {
84
- // Non-fatal: spawnSync below will surface EACCES with a clear message
85
- // if chmod failed for an unexpected reason (read-only fs, perms).
86
- }
87
- }
88
- return binPath;
89
- }
90
-
91
- const result = spawnSync(resolveBinary(), process.argv.slice(2), {
92
- stdio: "inherit",
93
- shell: false,
94
- });
95
-
96
- if (result.error) {
97
- console.error(`dforge-cli: failed to exec binary: ${result.error.message}`);
98
- process.exit(1);
99
- }
100
- process.exit(result.status ?? 1);