@rathnasgala/cli 1.1.10 → 1.1.11

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rathnasgala/cli",
3
- "version": "1.1.10",
3
+ "version": "1.1.11",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "src"
@@ -26,7 +26,7 @@
26
26
  "url": "git+https://github.com/rathnasgala/cli.git"
27
27
  },
28
28
  "dependencies": {
29
- "@rathnasgala/content-validation": "0.0.8",
29
+ "@rathnasgala/content-validation": "0.0.28",
30
30
  "libsodium-wrappers": "0.8.4",
31
31
  "tar": "7.5.22",
32
32
  "yaml": "2.9.0"
@@ -39,6 +39,10 @@ export async function preview({
39
39
  terminal.done('Installed');
40
40
  }
41
41
 
42
+ terminal.step('Preparing the preview');
43
+ await buildReader(root, spawnProcess);
44
+ terminal.done('Preview is ready');
45
+
42
46
  const publication = await readPublication(root);
43
47
  terminal.step('Starting the preview - stop it with Ctrl-C');
44
48
  if (publication != null) terminal.note(`this is ${publication.name ?? 'your publication'} as it will look`);
@@ -67,6 +71,27 @@ export async function preview({
67
71
  });
68
72
  }
69
73
 
74
+ function buildReader(root, spawnProcess) {
75
+ return new Promise((resolve, reject) => {
76
+ const child = spawnProcess('npm', ['run', 'build:reader'], {
77
+ cwd: root, shell: false, stdio: ['ignore', 'pipe', 'pipe']
78
+ });
79
+ let said = '';
80
+ child.stdout?.on('data', (chunk) => { said += chunk; });
81
+ child.stderr?.on('data', (chunk) => { said += chunk; });
82
+ child.once('error', reject);
83
+ child.once('exit', (code) => {
84
+ if (code === 0) {
85
+ resolve();
86
+ return;
87
+ }
88
+ const failure = new Error('Gala could not prepare the publication styles and reader tools. The build output below contains the cause.');
89
+ failure.detail = said.trim();
90
+ reject(failure);
91
+ });
92
+ });
93
+ }
94
+
70
95
  async function exists(target) {
71
96
  try {
72
97
  await access(target);