@seeka-labs/cli-apps 3.3.2 → 3.4.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/index.js CHANGED
@@ -35657,7 +35657,7 @@ var os2 = __toESM(require("os"));
35657
35657
  var path4 = __toESM(require("path"));
35658
35658
 
35659
35659
  // package.json
35660
- var version = "3.3.2";
35660
+ var version = "3.4.1";
35661
35661
 
35662
35662
  // src/helpers/index.ts
35663
35663
  var fs2 = __toESM(require("fs"));
@@ -44320,6 +44320,35 @@ var SeekaAppScaffolder = class {
44320
44320
  current[last] = value;
44321
44321
  return target;
44322
44322
  }
44323
+ deleteByJsonPointer(target, pointer) {
44324
+ if (pointer === "" || pointer === "/") {
44325
+ return null;
44326
+ }
44327
+ const parts = pointer.split("/").filter(Boolean).map((p) => p.replace(/~1/g, "/").replace(/~0/g, "~"));
44328
+ let current = target;
44329
+ for (let i = 0; i < parts.length - 1; i++) {
44330
+ const key = parts[i];
44331
+ if (current == null || !(key in current)) {
44332
+ throw new Error(`JSON pointer could not be resolved: ${pointer}`);
44333
+ }
44334
+ current = current[key];
44335
+ }
44336
+ const last = parts[parts.length - 1];
44337
+ if (current == null) {
44338
+ throw new Error(`JSON pointer could not be resolved: ${pointer}`);
44339
+ }
44340
+ if (Array.isArray(current)) {
44341
+ const idx = Number(last);
44342
+ if (Number.isInteger(idx)) {
44343
+ current.splice(idx, 1);
44344
+ } else {
44345
+ delete current[last];
44346
+ }
44347
+ } else {
44348
+ delete current[last];
44349
+ }
44350
+ return target;
44351
+ }
44323
44352
  applyJsonActions(rootDir, actions) {
44324
44353
  for (const action of actions) {
44325
44354
  const files = this.resolveMatches(rootDir, action.sourcePath, { nodir: true });
@@ -44339,12 +44368,50 @@ var SeekaAppScaffolder = class {
44339
44368
  json,
44340
44369
  resultType: "pointer"
44341
44370
  });
44342
- if ((!pointers || pointers.length === 0) && action.jsonPath !== "$.version" && action.jsonPath !== "$.author") {
44343
- throw new Error(`jsonActions jsonPath did not resolve in file ${path3.join(rootDir, fileAbs)}: ${action.jsonPath}`);
44371
+ if (action.action !== "overrideValue" && action.action !== "removeIfExists") {
44372
+ throw new Error(
44373
+ `jsonActions action must be one of 'overrideValue' | 'removeIfExists' (got: ${action.action})`
44374
+ );
44375
+ }
44376
+ if (!pointers || pointers.length === 0) {
44377
+ if (action.action === "removeIfExists") {
44378
+ continue;
44379
+ }
44380
+ if (action.jsonPath === "$.version" || action.jsonPath === "$.author") {
44381
+ continue;
44382
+ }
44383
+ throw new Error(
44384
+ `jsonActions jsonPath did not resolve in file ${path3.join(rootDir, fileAbs)}: ${action.jsonPath}`
44385
+ );
44344
44386
  }
44345
44387
  let updated = json;
44346
- for (const ptr of pointers) {
44347
- updated = this.setByJsonPointer(updated, ptr, action.overrideValue);
44388
+ if (action.action === "overrideValue") {
44389
+ if (!("overrideValue" in action) || action.overrideValue === void 0) {
44390
+ throw new Error(`jsonActions overrideValue must be provided when action == 'overrideValue'`);
44391
+ }
44392
+ for (const ptr of pointers) {
44393
+ updated = this.setByJsonPointer(updated, ptr, action.overrideValue);
44394
+ }
44395
+ } else {
44396
+ const orderedPointers = [...pointers].sort((a, b) => {
44397
+ const aParts = a.split("/").filter(Boolean);
44398
+ const bParts = b.split("/").filter(Boolean);
44399
+ if (aParts.length !== bParts.length) return bParts.length - aParts.length;
44400
+ const aParent = aParts.slice(0, -1).join("/");
44401
+ const bParent = bParts.slice(0, -1).join("/");
44402
+ if (aParent !== bParent) return bParent.localeCompare(aParent);
44403
+ const aLast = aParts[aParts.length - 1];
44404
+ const bLast = bParts[bParts.length - 1];
44405
+ const aIdx = Number(aLast);
44406
+ const bIdx = Number(bLast);
44407
+ const aIsIdx = Number.isInteger(aIdx) && String(aIdx) === aLast;
44408
+ const bIsIdx = Number.isInteger(bIdx) && String(bIdx) === bLast;
44409
+ if (aIsIdx && bIsIdx) return bIdx - aIdx;
44410
+ return bLast.localeCompare(aLast);
44411
+ });
44412
+ for (const ptr of orderedPointers) {
44413
+ updated = this.deleteByJsonPointer(updated, ptr);
44414
+ }
44348
44415
  }
44349
44416
  fs3.writeFileSync(fileAbs, JSON.stringify(updated, null, 2));
44350
44417
  }
@@ -44445,7 +44512,7 @@ var initCommandV2 = async (options) => {
44445
44512
  {
44446
44513
  sourcePath: "**/*",
44447
44514
  findText: "ExampleApp",
44448
- replaceText: projectPascalCase + "App"
44515
+ replaceText: projectPascalCase
44449
44516
  },
44450
44517
  {
44451
44518
  sourcePath: "app/**/package.json",
@@ -44483,28 +44550,43 @@ var initCommandV2 = async (options) => {
44483
44550
  {
44484
44551
  sourcePath: "package.json",
44485
44552
  jsonPath: "$.version",
44553
+ action: "overrideValue",
44486
44554
  overrideValue: version
44487
44555
  },
44488
44556
  {
44489
44557
  sourcePath: "package.json",
44490
- jsonPath: "$.author",
44491
- overrideValue: `${options.developerName} <${options.developerEmail}>`
44558
+ jsonPath: "$.version",
44559
+ action: "overrideValue",
44560
+ overrideValue: version
44561
+ },
44562
+ {
44563
+ sourcePath: "package.json",
44564
+ jsonPath: "$.gitHead",
44565
+ action: "removeIfExists"
44492
44566
  },
44493
44567
  // app projects
44494
44568
  {
44495
44569
  sourcePath: "app/**/package.json",
44496
44570
  jsonPath: "$.version",
44571
+ action: "overrideValue",
44497
44572
  overrideValue: version
44498
44573
  },
44499
44574
  {
44500
44575
  sourcePath: "app/**/package.json",
44501
44576
  jsonPath: "$.author",
44577
+ action: "overrideValue",
44502
44578
  overrideValue: `${options.developerName} <${options.developerEmail}>`
44503
44579
  },
44580
+ {
44581
+ sourcePath: "app/**/package.json",
44582
+ jsonPath: "$.gitHead",
44583
+ action: "removeIfExists"
44584
+ },
44504
44585
  // server project
44505
44586
  {
44506
44587
  sourcePath: "app/server/package.json",
44507
44588
  jsonPath: "$.name",
44589
+ action: "overrideValue",
44508
44590
  overrideValue: `@${orgName}/${projectName}-server`
44509
44591
  }
44510
44592
  ]