@widgetic/dev-tools 0.3.7 → 0.3.9

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.
@@ -45,12 +45,14 @@ test('the design-system table expands to every subpath plus the index', () => {
45
45
 
46
46
  test('entry packages alias to their entry file, lib packages to their tree', () => {
47
47
  const aliases = buildSiblingAliases(FRONTEND, {
48
- packages: ['api-sdk', 'cache-layer', 'chat', 'file-browser']
48
+ packages: ['api-sdk', 'cache-layer', 'chat', 'file-browser', 'workflows', 'workflows-engine']
49
49
  });
50
50
  assert.equal(aliases['@widgetic/api-sdk'], `${FRONTEND}/api-sdk/src/index.ts`);
51
51
  assert.equal(aliases['@widgetic/cache-layer'], `${FRONTEND}/cache-layer/src/index.ts`);
52
52
  assert.equal(aliases['@widgetic/chat'], `${FRONTEND}/chat/src/lib`);
53
53
  assert.equal(aliases['@widgetic/file-browser'], `${FRONTEND}/file-browser/src/lib`);
54
+ assert.equal(aliases['@widgetic/workflows'], `${FRONTEND}/workflows/src/lib`);
55
+ assert.equal(aliases['@widgetic/workflows-engine'], `${FRONTEND}/workflows-engine/src/index.ts`);
54
56
  });
55
57
 
56
58
  test('a selection without design-system emits no design-system aliases', () => {
@@ -0,0 +1,89 @@
1
+ import { test } from 'node:test';
2
+ import assert from 'node:assert/strict';
3
+ import { readFileSync } from 'node:fs';
4
+ import { resolve } from 'node:path';
5
+ import { fileURLToPath } from 'node:url';
6
+ import { PUBLISHABLE_PACKAGES } from '../lib/publish-to-npm.mjs';
7
+ import { SIBLING_PACKAGES } from '../lib/frontend-layout.mjs';
8
+ import { PUBLISH_PACKAGES } from '../lib/readme-contract.mjs';
9
+
10
+ /**
11
+ * Four lists in dev-tools name packages, and none of them knows about the
12
+ * others: the walk (`lib/publish-to-npm.mjs`), the publisher
13
+ * (`bin/publish-package.mjs`), the sibling layout (`lib/frontend-layout.mjs`)
14
+ * and the README contract (`lib/readme-contract.mjs`). A new package has to be
15
+ * added to each, and forgetting one fails nowhere at the time of the change:
16
+ *
17
+ * - in the walk but not in the publisher: the walk stops with "is not one of
18
+ * the packages this script publishes" after the earlier packages were
19
+ * already published;
20
+ * - in the publisher but not in the walk: the package is only ever published
21
+ * by hand, and nobody notices a release that never happens;
22
+ * - missing from the sibling layout: an app that selects the package for its
23
+ * dev aliases gets a throw from `siblingPackageRoots`.
24
+ *
25
+ * So the lists are compared here, and a gap names the file that needs the name.
26
+ */
27
+
28
+ const DEV_TOOLS = fileURLToPath(new URL('..', import.meta.url));
29
+ const publisherSource = readFileSync(resolve(DEV_TOOLS, 'bin/publish-package.mjs'), 'utf8');
30
+
31
+ /**
32
+ * The names inside one `const NAME = new Set([...])` literal of the publisher.
33
+ * The publisher runs a publish the moment it is imported, so it is read as
34
+ * text rather than imported.
35
+ *
36
+ * @param {string} setName
37
+ * @returns {string[]}
38
+ */
39
+ function namesInPublisherSet(setName) {
40
+ const match = publisherSource.match(new RegExp(`const ${setName} = new Set\\(\\[([^\\]]*)\\]\\)`));
41
+ assert.ok(
42
+ match,
43
+ `bin/publish-package.mjs no longer declares ${setName} as a Set literal of names. Update this test with it.`
44
+ );
45
+ return [...match[1].matchAll(/'([^']+)'/g)].map((found) => found[1]);
46
+ }
47
+
48
+ /** The packages the publisher builds from their own source, then publishes. */
49
+ const builtFromSource = [...namesInPublisherSet('BUILD_PACKAGES'), ...namesInPublisherSet('PACKAGE_PACKAGES')];
50
+
51
+ /** The packages the publisher gives a branch of their own (`packageName === 'ui-sdk'`). */
52
+ const specialCased = [...publisherSource.matchAll(/packageName === '([^']+)'/g)].map((found) => found[1]);
53
+
54
+ const publisherNames = new Set([...builtFromSource, ...specialCased]);
55
+ const walkNames = new Set(PUBLISHABLE_PACKAGES.map((pkg) => pkg.dir));
56
+
57
+ test('the walk and the publisher name the same packages', () => {
58
+ const inWalkOnly = [...walkNames].filter((name) => !publisherNames.has(name));
59
+ const inPublisherOnly = [...publisherNames].filter((name) => !walkNames.has(name));
60
+ assert.deepEqual(
61
+ inWalkOnly,
62
+ [],
63
+ `in lib/publish-to-npm.mjs but not in bin/publish-package.mjs: the walk would stop part-way, after earlier packages were already published. Add ${inWalkOnly.join(', ')} to BUILD_PACKAGES or PACKAGE_PACKAGES.`
64
+ );
65
+ assert.deepEqual(
66
+ inPublisherOnly,
67
+ [],
68
+ `in bin/publish-package.mjs but not in lib/publish-to-npm.mjs: ${inPublisherOnly.join(', ')} would only ever be published by hand. Add it to PUBLISHABLE_PACKAGES, in dependency order.`
69
+ );
70
+ });
71
+
72
+ test('every package the publisher builds from source has a sibling-layout entry for its directory', () => {
73
+ const directoriesInLayout = new Set(Object.values(SIBLING_PACKAGES).map((entry) => entry.dir));
74
+ const missing = builtFromSource.filter((dir) => !directoriesInLayout.has(dir));
75
+ assert.deepEqual(
76
+ missing,
77
+ [],
78
+ `no SIBLING_PACKAGES entry points at ${missing.join(', ')}. Add one to lib/frontend-layout.mjs so an app can alias that package's source in dev.`
79
+ );
80
+ });
81
+
82
+ test('a package held to the README contract publish section is one the walk publishes', () => {
83
+ const notInWalk = PUBLISH_PACKAGES.filter((dir) => !walkNames.has(dir));
84
+ assert.deepEqual(
85
+ notInWalk,
86
+ [],
87
+ `PUBLISH_PACKAGES in lib/readme-contract.mjs names ${notInWalk.join(', ')}, which lib/publish-to-npm.mjs does not publish.`
88
+ );
89
+ });
@@ -20,6 +20,8 @@ test('the walk calls publish-to-npm in each npm package', () => {
20
20
  'editor:publish-to-npm',
21
21
  'file-browser:publish-to-npm',
22
22
  'widget-creator:publish-to-npm',
23
+ 'workflows-engine:publish-to-npm',
24
+ 'workflows:publish-to-npm',
23
25
  'embed-sdk:publish-to-npm',
24
26
  'ui-sdk:publish-to-npm'
25
27
  ]
@@ -271,7 +271,7 @@ npm run llinks
271
271
 
272
272
  describe('the publish contract', () => {
273
273
  it('publishes to exactly the packages that ship a dist tarball', { skip: !DISK_OK }, () => {
274
- assert.deepEqual(PUBLISH_PACKAGES, ['chat', 'file-browser']);
274
+ assert.deepEqual(PUBLISH_PACKAGES, ['chat', 'file-browser', 'workflows']);
275
275
  assert.ok(PUBLISH_PACKAGES.every((p) => ADOPTER_PACKAGES.includes(p)));
276
276
  // Every publisher ships `files: ['dist']` — the sentence that calls
277
277
  // dist the tarball's only content must match manifest reality.