@erudit-js/cli 3.0.0-dev.14 → 3.0.0-dev.15
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.mjs +62 -9
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -8,7 +8,7 @@ import * as fs from 'node:fs/promises';
|
|
|
8
8
|
import * as path from 'node:path';
|
|
9
9
|
import { spawn } from 'node:child_process';
|
|
10
10
|
|
|
11
|
-
const version = "3.0.0-dev.
|
|
11
|
+
const version = "3.0.0-dev.15";
|
|
12
12
|
|
|
13
13
|
function resolvePath(path) {
|
|
14
14
|
path = resolvePaths(path);
|
|
@@ -185,7 +185,11 @@ async function processFile(filePath, rootDir, replaceMap) {
|
|
|
185
185
|
}
|
|
186
186
|
}
|
|
187
187
|
|
|
188
|
-
async function prepare$1(
|
|
188
|
+
async function prepare$1({
|
|
189
|
+
projectPath,
|
|
190
|
+
eruditPath,
|
|
191
|
+
contentTargets
|
|
192
|
+
}) {
|
|
189
193
|
const eruditBuildDir = `${projectPath}/.erudit`;
|
|
190
194
|
const distDir = `${projectPath}/dist`;
|
|
191
195
|
const nodeModules = `${projectPath}/node_modules`;
|
|
@@ -228,8 +232,31 @@ async function prepare$1(projectPath, eruditPath) {
|
|
|
228
232
|
4
|
|
229
233
|
)
|
|
230
234
|
);
|
|
235
|
+
await prepareContentTargets(eruditBuildDir, contentTargets);
|
|
236
|
+
writeFileSync(
|
|
237
|
+
`${eruditBuildDir}/__AUTOGENERATED__`,
|
|
238
|
+
`This directory is autogenerated by Erudit CLI.
|
|
239
|
+
All changes will be lost on next launch!`
|
|
240
|
+
);
|
|
231
241
|
consola.success("Erudit build files ready!");
|
|
232
242
|
}
|
|
243
|
+
async function prepareContentTargets(buildDir, targets) {
|
|
244
|
+
if (typeof targets === "undefined" || targets === "") {
|
|
245
|
+
return;
|
|
246
|
+
}
|
|
247
|
+
if (typeof targets === "string") {
|
|
248
|
+
targets = [targets];
|
|
249
|
+
}
|
|
250
|
+
if (Array.isArray(targets)) {
|
|
251
|
+
writeFileSync(
|
|
252
|
+
`${buildDir}/targets.json`,
|
|
253
|
+
JSON.stringify(targets, null, 4)
|
|
254
|
+
);
|
|
255
|
+
consola.success(`Saved ${targets.length} content targets!`);
|
|
256
|
+
return;
|
|
257
|
+
}
|
|
258
|
+
throw new Error(`Failed to resolve content targets: "${targets}"!`);
|
|
259
|
+
}
|
|
233
260
|
|
|
234
261
|
async function spawnNuxt(command, projectPath) {
|
|
235
262
|
return new Promise((resolve) => {
|
|
@@ -274,6 +301,14 @@ const projectPathArg = {
|
|
|
274
301
|
default: "."
|
|
275
302
|
}
|
|
276
303
|
};
|
|
304
|
+
const contentTargetsArg = {
|
|
305
|
+
target: {
|
|
306
|
+
type: "string",
|
|
307
|
+
description: "Content targets to process",
|
|
308
|
+
required: false,
|
|
309
|
+
default: ""
|
|
310
|
+
}
|
|
311
|
+
};
|
|
277
312
|
function resolveArgPaths(projectPath, eruditPath) {
|
|
278
313
|
consola.start("Resolving project path...");
|
|
279
314
|
projectPath = resolvePath(projectPath);
|
|
@@ -308,7 +343,10 @@ const prepare = defineCommand({
|
|
|
308
343
|
args.projectPath,
|
|
309
344
|
args.eruditPath
|
|
310
345
|
);
|
|
311
|
-
await prepare$1(
|
|
346
|
+
await prepare$1({
|
|
347
|
+
projectPath,
|
|
348
|
+
eruditPath
|
|
349
|
+
});
|
|
312
350
|
consola.start("Generating Nuxt build files...");
|
|
313
351
|
await spawnNuxt("prepare", projectPath);
|
|
314
352
|
consola.success("Nuxt is prepared!");
|
|
@@ -322,7 +360,8 @@ const dev = defineCommand({
|
|
|
322
360
|
},
|
|
323
361
|
args: {
|
|
324
362
|
...projectPathArg,
|
|
325
|
-
...eruditPathArg
|
|
363
|
+
...eruditPathArg,
|
|
364
|
+
...contentTargetsArg
|
|
326
365
|
},
|
|
327
366
|
async run({ args }) {
|
|
328
367
|
logCommand("dev");
|
|
@@ -330,7 +369,11 @@ const dev = defineCommand({
|
|
|
330
369
|
args.projectPath,
|
|
331
370
|
args.eruditPath
|
|
332
371
|
);
|
|
333
|
-
await prepare$1(
|
|
372
|
+
await prepare$1({
|
|
373
|
+
projectPath,
|
|
374
|
+
eruditPath,
|
|
375
|
+
contentTargets: args.target
|
|
376
|
+
});
|
|
334
377
|
consola.start("Starting Nuxt dev...");
|
|
335
378
|
await spawnNuxt("dev", projectPath);
|
|
336
379
|
}
|
|
@@ -343,7 +386,8 @@ const generate = defineCommand({
|
|
|
343
386
|
},
|
|
344
387
|
args: {
|
|
345
388
|
...projectPathArg,
|
|
346
|
-
...eruditPathArg
|
|
389
|
+
...eruditPathArg,
|
|
390
|
+
...contentTargetsArg
|
|
347
391
|
},
|
|
348
392
|
async run({ args }) {
|
|
349
393
|
logCommand("generate");
|
|
@@ -351,7 +395,11 @@ const generate = defineCommand({
|
|
|
351
395
|
args.projectPath,
|
|
352
396
|
args.eruditPath
|
|
353
397
|
);
|
|
354
|
-
await prepare$1(
|
|
398
|
+
await prepare$1({
|
|
399
|
+
projectPath,
|
|
400
|
+
eruditPath,
|
|
401
|
+
contentTargets: args.target
|
|
402
|
+
});
|
|
355
403
|
consola.start("Starting Nuxt generate...");
|
|
356
404
|
await spawnNuxt("generate", projectPath);
|
|
357
405
|
}
|
|
@@ -398,7 +446,8 @@ const build = defineCommand({
|
|
|
398
446
|
},
|
|
399
447
|
args: {
|
|
400
448
|
...projectPathArg,
|
|
401
|
-
...eruditPathArg
|
|
449
|
+
...eruditPathArg,
|
|
450
|
+
...contentTargetsArg
|
|
402
451
|
},
|
|
403
452
|
async run({ args }) {
|
|
404
453
|
logCommand("build");
|
|
@@ -406,7 +455,11 @@ const build = defineCommand({
|
|
|
406
455
|
args.projectPath,
|
|
407
456
|
args.eruditPath
|
|
408
457
|
);
|
|
409
|
-
await prepare$1(
|
|
458
|
+
await prepare$1({
|
|
459
|
+
projectPath,
|
|
460
|
+
eruditPath,
|
|
461
|
+
contentTargets: args.target
|
|
462
|
+
});
|
|
410
463
|
consola$1.start("Starting Nuxt build...");
|
|
411
464
|
await spawnNuxt("build", projectPath);
|
|
412
465
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@erudit-js/cli",
|
|
3
|
-
"version": "3.0.0-dev.
|
|
3
|
+
"version": "3.0.0-dev.15",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "📟 Command Line Interface for Erudit",
|
|
6
6
|
"license": "MIT",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"dist"
|
|
29
29
|
],
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@erudit-js/cog": "3.0.0-dev.
|
|
31
|
+
"@erudit-js/cog": "3.0.0-dev.15",
|
|
32
32
|
"chalk": "^5.4.1",
|
|
33
33
|
"citty": "^0.1.6",
|
|
34
34
|
"consola": "^3.4.0"
|