@dforge-core/dforge-cli 0.1.1 → 0.1.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.
package/dist/cli.js CHANGED
@@ -935,18 +935,16 @@ function buildDataViews(entities) {
935
935
  }
936
936
  function buildFolders(opts) {
937
937
  return {
938
- [opts.code]: {
939
- label: opts.displayName,
940
- description: opts.description || opts.displayName,
941
- icon: "bi-folder",
942
- color: "#2196F3",
943
- entities: Object.fromEntries(
944
- opts.entities.map((e2) => [
945
- e2.name,
946
- { viewName: e2.name, quickAdd: true }
947
- ])
948
- )
949
- }
938
+ label: opts.displayName,
939
+ description: opts.description || opts.displayName,
940
+ icon: "bi-folder",
941
+ color: "#2196F3",
942
+ entities: Object.fromEntries(
943
+ opts.entities.map((e2) => [
944
+ e2.name,
945
+ { viewName: "default", quickAdd: true }
946
+ ])
947
+ )
950
948
  };
951
949
  }
952
950
  function buildMenus(opts) {
@@ -1329,6 +1327,110 @@ var init_init = __esm({
1329
1327
  }
1330
1328
  });
1331
1329
 
1330
+ // src/pack.ts
1331
+ var pack_exports = {};
1332
+ __export(pack_exports, {
1333
+ runPack: () => runPack
1334
+ });
1335
+ async function runPack(argv2) {
1336
+ const positional = [];
1337
+ let outPath;
1338
+ for (let i = 0; i < argv2.length; i++) {
1339
+ const a = argv2[i];
1340
+ if (a === "-o" || a === "--output") {
1341
+ outPath = argv2[++i];
1342
+ } else if (a === "-h" || a === "--help") {
1343
+ printHelp2();
1344
+ return 0;
1345
+ } else {
1346
+ positional.push(a);
1347
+ }
1348
+ }
1349
+ if (positional.length === 0) {
1350
+ console.error("Usage: dforge-cli module pack <module-dir> [-o <output>]");
1351
+ return 2;
1352
+ }
1353
+ const moduleDir = path3.resolve(positional[0]);
1354
+ const manifestPath = path3.join(moduleDir, "manifest.json");
1355
+ if (!fs3.existsSync(manifestPath)) {
1356
+ console.error(`No manifest.json at ${manifestPath}`);
1357
+ return 1;
1358
+ }
1359
+ let manifest;
1360
+ try {
1361
+ manifest = JSON.parse(fs3.readFileSync(manifestPath, "utf8"));
1362
+ } catch (e2) {
1363
+ console.error(`manifest.json: ${e2.message}`);
1364
+ return 1;
1365
+ }
1366
+ if (!manifest.code || !manifest.version) {
1367
+ console.error("manifest.json missing required `code` or `version`");
1368
+ return 1;
1369
+ }
1370
+ const defaultName = `${manifest.code}-${manifest.version}.dforge`;
1371
+ let finalOut;
1372
+ if (!outPath) {
1373
+ finalOut = path3.resolve(process.cwd(), defaultName);
1374
+ } else {
1375
+ const abs = path3.resolve(outPath);
1376
+ if (abs.endsWith(".dforge")) {
1377
+ finalOut = abs;
1378
+ } else {
1379
+ fs3.mkdirSync(abs, { recursive: true });
1380
+ finalOut = path3.join(abs, defaultName);
1381
+ }
1382
+ }
1383
+ fs3.mkdirSync(path3.dirname(finalOut), { recursive: true });
1384
+ if (fs3.existsSync(finalOut)) fs3.rmSync(finalOut);
1385
+ const zip = (0, import_node_child_process3.spawnSync)(
1386
+ "zip",
1387
+ ["-r", "-q", finalOut, "."],
1388
+ {
1389
+ cwd: moduleDir,
1390
+ stdio: ["ignore", "inherit", "inherit"]
1391
+ }
1392
+ );
1393
+ if (zip.error) {
1394
+ console.error(
1395
+ `pack: failed to run \`zip\`: ${zip.error.message}. Install zip (brew install zip / apt install zip / git-for-windows ships it).`
1396
+ );
1397
+ return 1;
1398
+ }
1399
+ if (zip.status !== 0) {
1400
+ console.error(`pack: zip exited ${zip.status}`);
1401
+ return zip.status ?? 1;
1402
+ }
1403
+ const size = fs3.statSync(finalOut).size;
1404
+ const kib = (size / 1024).toFixed(1);
1405
+ console.log(`\u2713 ${finalOut} (${kib} KB)`);
1406
+ void import_promises.pipeline;
1407
+ void import_node_zlib.createGzip;
1408
+ return 0;
1409
+ }
1410
+ function printHelp2() {
1411
+ console.log("Usage: dforge-cli module pack <module-dir> [-o <output>]");
1412
+ console.log("");
1413
+ console.log(
1414
+ "Packages a module directory into a .dforge archive (zip with .dforge extension)."
1415
+ );
1416
+ console.log("");
1417
+ console.log("Examples:");
1418
+ console.log(" dforge-cli module pack ./my-module # \u2192 ./<code>-<version>.dforge");
1419
+ console.log(" dforge-cli module pack ./my-module -o ./dist/ # \u2192 ./dist/<code>-<version>.dforge");
1420
+ console.log(" dforge-cli module pack ./my-module -o pkg.dforge # \u2192 ./pkg.dforge");
1421
+ }
1422
+ var fs3, path3, import_node_zlib, import_promises, import_node_child_process3;
1423
+ var init_pack = __esm({
1424
+ "src/pack.ts"() {
1425
+ "use strict";
1426
+ fs3 = __toESM(require("fs"));
1427
+ path3 = __toESM(require("path"));
1428
+ import_node_zlib = require("zlib");
1429
+ import_promises = require("stream/promises");
1430
+ import_node_child_process3 = require("child_process");
1431
+ }
1432
+ });
1433
+
1332
1434
  // src/native.ts
1333
1435
  var import_node_child_process = require("child_process");
1334
1436
  var path = __toESM(require("path"));
@@ -1411,14 +1513,19 @@ function spawnNative(argv2) {
1411
1513
 
1412
1514
  // src/cli.ts
1413
1515
  var argv = process.argv.slice(2);
1414
- if (argv[0] === "init") {
1415
- Promise.resolve().then(() => (init_init(), init_exports)).then(({ runInit: runInit2 }) => runInit2(argv.slice(1))).then(
1516
+ function jsCommand(loader, rest) {
1517
+ loader().then((run) => run(rest)).then(
1416
1518
  (code) => process.exit(code ?? 0),
1417
1519
  (err) => {
1418
1520
  console.error(err.message ?? err);
1419
1521
  process.exit(1);
1420
1522
  }
1421
1523
  );
1524
+ }
1525
+ if (argv[0] === "init") {
1526
+ jsCommand(() => Promise.resolve().then(() => (init_init(), init_exports)).then((m2) => m2.runInit), argv.slice(1));
1527
+ } else if (argv[0] === "module" && argv[1] === "pack") {
1528
+ jsCommand(() => Promise.resolve().then(() => (init_pack(), pack_exports)).then((m2) => m2.runPack), argv.slice(2));
1422
1529
  } else {
1423
1530
  spawnNative(argv);
1424
1531
  }
package/dist/lib.js CHANGED
@@ -90,18 +90,16 @@ function buildDataViews(entities) {
90
90
  }
91
91
  function buildFolders(opts) {
92
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
- }
93
+ label: opts.displayName,
94
+ description: opts.description || opts.displayName,
95
+ icon: "bi-folder",
96
+ color: "#2196F3",
97
+ entities: Object.fromEntries(
98
+ opts.entities.map((e) => [
99
+ e.name,
100
+ { viewName: "default", quickAdd: true }
101
+ ])
102
+ )
105
103
  };
106
104
  }
107
105
  function buildMenus(opts) {
package/dist/lib.mjs CHANGED
@@ -52,18 +52,16 @@ function buildDataViews(entities) {
52
52
  }
53
53
  function buildFolders(opts) {
54
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
- }
55
+ label: opts.displayName,
56
+ description: opts.description || opts.displayName,
57
+ icon: "bi-folder",
58
+ color: "#2196F3",
59
+ entities: Object.fromEntries(
60
+ opts.entities.map((e) => [
61
+ e.name,
62
+ { viewName: "default", quickAdd: true }
63
+ ])
64
+ )
67
65
  };
68
66
  }
69
67
  function buildMenus(opts) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dforge-core/dforge-cli",
3
- "version": "0.1.1",
3
+ "version": "0.1.3",
4
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",
@@ -41,11 +41,11 @@
41
41
  "typescript": "^6.0.3"
42
42
  },
43
43
  "optionalDependencies": {
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"
44
+ "@dforge-core/dforge-cli-darwin-arm64": "0.1.3",
45
+ "@dforge-core/dforge-cli-darwin-x64": "0.1.3",
46
+ "@dforge-core/dforge-cli-linux-arm64": "0.1.3",
47
+ "@dforge-core/dforge-cli-linux-x64": "0.1.3",
48
+ "@dforge-core/dforge-cli-win32-arm64": "0.1.3",
49
+ "@dforge-core/dforge-cli-win32-x64": "0.1.3"
50
50
  }
51
51
  }