@canopy-iiif/app 1.8.0 → 1.8.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.
Files changed (2) hide show
  1. package/lib/orchestrator.js +50 -13
  2. package/package.json +1 -1
@@ -10,6 +10,40 @@ let uiWatcherChild = null;
10
10
 
11
11
  const workspacePackageJsonPath = path.resolve(process.cwd(), 'packages/app/package.json');
12
12
  const hasAppWorkspace = fs.existsSync(workspacePackageJsonPath);
13
+ const workspaceUiDistDir = path.resolve(process.cwd(), 'packages/app/ui/dist');
14
+ const requiredUiArtifacts = [
15
+ path.join(workspaceUiDistDir, 'server.mjs'),
16
+ path.join(workspaceUiDistDir, 'index.mjs'),
17
+ ];
18
+
19
+ function prettyPath(p) {
20
+ try {
21
+ const rel = path.relative(process.cwd(), p);
22
+ return rel ? rel.split(path.sep).join('/') : p;
23
+ } catch (_) {
24
+ return p;
25
+ }
26
+ }
27
+
28
+ function ensureUiDistReady(context = 'build') {
29
+ if (!hasAppWorkspace) return;
30
+ const missing = [];
31
+ for (const file of requiredUiArtifacts) {
32
+ try {
33
+ if (!fs.existsSync(file)) missing.push(file);
34
+ } catch (_) {
35
+ missing.push(file);
36
+ }
37
+ }
38
+ if (missing.length) {
39
+ const list = missing.map((file) => prettyPath(file)).join(', ');
40
+ const label = context ? `${context} ` : '';
41
+ throw new Error(
42
+ `@canopy-iiif/app/ui ${label}did not produce required bundle(s): ${list}. ` +
43
+ 'Run "npm -w @canopy-iiif/app run ui:build" and ensure it completes successfully.'
44
+ );
45
+ }
46
+ }
13
47
 
14
48
  function getMode(argv = process.argv.slice(2), env = process.env) {
15
49
  const cli = new Set(argv);
@@ -49,6 +83,20 @@ function start(cmd, args, opts = {}) {
49
83
  return child;
50
84
  }
51
85
 
86
+ async function buildUiOnce(label, env = process.env) {
87
+ if (!hasAppWorkspace) return;
88
+ const prefix = label || 'Building';
89
+ log(`${prefix} UI assets (@canopy-iiif/app/ui)`);
90
+ try {
91
+ await runOnce('npm', ['-w', '@canopy-iiif/app', 'run', 'ui:build'], { env });
92
+ } catch (error) {
93
+ const message = (error && error.message) || String(error);
94
+ throw new Error(`[canopy] Failed to ${prefix.toLowerCase()} UI assets: ${message}`);
95
+ }
96
+ ensureUiDistReady(prefix.toLowerCase());
97
+ log('UI assets ready');
98
+ }
99
+
52
100
  async function prepareUi(mode, env = process.env) {
53
101
  if (!hasAppWorkspace) {
54
102
  log('Using bundled UI assets from @canopy-iiif/app (workspace not detected)');
@@ -56,22 +104,11 @@ async function prepareUi(mode, env = process.env) {
56
104
  }
57
105
 
58
106
  if (mode === 'build') {
59
- log('Building UI assets (@canopy-iiif/app/ui)');
60
- try {
61
- await runOnce('npm', ['-w', '@canopy-iiif/app', 'run', 'ui:build'], { env });
62
- log('UI assets built');
63
- } catch (error) {
64
- warn(`UI build skipped: ${(error && error.message) || String(error)}`);
65
- }
107
+ await buildUiOnce('Building', env);
66
108
  return null;
67
109
  }
68
110
 
69
- try {
70
- log('Prebuilding UI assets (@canopy-iiif/app/ui)');
71
- await runOnce('npm', ['-w', '@canopy-iiif/app', 'run', 'ui:build'], { env });
72
- } catch (error) {
73
- warn(`UI prebuild skipped: ${(error && error.message) || String(error)}`);
74
- }
111
+ await buildUiOnce('Prebuilding', env);
75
112
 
76
113
  log('Starting UI watcher (@canopy-iiif/app/ui)');
77
114
  try {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@canopy-iiif/app",
3
- "version": "1.8.0",
3
+ "version": "1.8.1",
4
4
  "private": false,
5
5
  "license": "MIT",
6
6
  "author": "Mat Jordan <mat@northwestern.edu>",