@cubing/dev-config 0.6.4 → 0.6.6

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 (2) hide show
  1. package/bin/package.json.ts +23 -14
  2. package/package.json +1 -1
@@ -398,20 +398,24 @@ field(["type"], "string", {
398
398
  'Type must be `"module"`.': (type: string) => type === "module",
399
399
  },
400
400
  });
401
- if ("main" in packageJSON || "types" in packageJSON) {
402
- field(["main"], "string", {
403
- mustBePopulatedMessage: 'Must be populated if "types" is populated.',
404
- });
405
- field(["types"], "string", {
406
- mustBePopulatedMessage: 'Must be populated if "main" is populated.',
407
- });
408
- } else {
409
- console.log("☑️ .main");
410
- console.log("☑️ .types");
411
- }
401
+ const mainOrTypesArePopoulated = (() => {
402
+ if ("main" in packageJSON || "types" in packageJSON) {
403
+ field(["main"], "string", {
404
+ mustBePopulatedMessage: 'Must be populated if "types" is populated.',
405
+ });
406
+ field(["types"], "string", {
407
+ mustBePopulatedMessage: 'Must be populated if "main" is populated.',
408
+ });
409
+ return true;
410
+ } else {
411
+ console.log("☑️ .main");
412
+ console.log("☑️ .types");
413
+ return false;
414
+ }
415
+ })();
412
416
  mustNotBePopulated(["module"]);
413
417
  mustNotBePopulated(["browser"]);
414
- field(["exports"], "object");
418
+ field(["exports"], "object", { optional: !mainOrTypesArePopoulated });
415
419
  field(["bin"], "object", { optional: true });
416
420
  field(["dependencies"], "object", { optional: true });
417
421
  field(["devDependencies"], "object", { optional: true });
@@ -433,12 +437,17 @@ await using _ = {
433
437
  [Symbol.asyncDispose]: () => tempDir.rm_rf(),
434
438
  };
435
439
  const extractionDir = await tempDir.join("extracted").mkdir();
440
+ // TODO: is there a 100% reliable way to test against paths that *will* be packed?
441
+ // Note that this has to take into account `.gitignore`, `.npmignore`, and `"files"` — with globs and excludes.
442
+ // For now, we print the command to make it clear that some heavy lifting is going on (and that it's not our fault that it's slow).
436
443
  const data: { filename: string }[] = await new PrintableShellCommand("npm", [
437
444
  "pack",
438
445
  "--json",
439
446
  "--ignore-scripts",
440
447
  ["--pack-destination", tempDir],
441
- ]).json();
448
+ ])
449
+ .print()
450
+ .json();
442
451
  const tgzPath = tempDir.join(data[0].filename);
443
452
  await new PrintableShellCommand("tar", [
444
453
  ["-C", extractionDir],
@@ -637,7 +646,7 @@ if (exports) {
637
646
  ...fixingLines,
638
647
  ].join("\n");
639
648
  } else {
640
- return `✅ ${breadcrumbString} — Key set and ordering is okay.`;
649
+ return `✅ ${breadcrumbString} — Key set and ordering is OK.`;
641
650
  }
642
651
  }
643
652
  })(),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cubing/dev-config",
3
- "version": "0.6.4",
3
+ "version": "0.6.6",
4
4
  "description": "Common dev configs for projects.",
5
5
  "author": {
6
6
  "name": "Lucas Garron",