@erudit-js/cli 3.0.0-dev.14 → 3.0.0-dev.16

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/README.md CHANGED
@@ -1,12 +1,12 @@
1
- # 📟 Erudit CLI
2
-
3
- Command Line Interface for [Erudit](https://github.com/erudit-js/erudit).
4
-
5
- CLI is accessible via `erudit` or `erudit-cli` commands.
6
-
7
- ## Commands
8
-
9
- - `init`
10
- - `dev`
11
- - `build`
12
- - `preview`
1
+ # 📟 Erudit CLI
2
+
3
+ Command Line Interface for [Erudit](https://github.com/erudit-js/erudit).
4
+
5
+ CLI is accessible via `erudit` or `erudit-cli` commands.
6
+
7
+ ## Commands
8
+
9
+ - `init`
10
+ - `dev`
11
+ - `build`
12
+ - `preview`
@@ -1,5 +1,5 @@
1
- #!/usr/bin/env node
2
-
3
- import { run } from '../dist/index.mjs';
4
-
5
- run();
1
+ #!/usr/bin/env node
2
+
3
+ import { run } from '../dist/index.mjs';
4
+
5
+ run();
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.14";
11
+ const version = "3.0.0-dev.16";
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(projectPath, eruditPath) {
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`;
@@ -222,14 +226,43 @@ async function prepare$1(projectPath, eruditPath) {
222
226
  `${eruditBuildDir}/tsconfig.json`,
223
227
  JSON.stringify(
224
228
  {
225
- extends: "./nuxt/.nuxt/tsconfig.json"
229
+ extends: "./nuxt/.nuxt/tsconfig.json",
230
+ compilerOptions: {
231
+ paths: {
232
+ "#project/*": [`${projectPath}/*`],
233
+ "#content/*": [`${projectPath}/content/*`]
234
+ }
235
+ }
226
236
  },
227
237
  null,
228
238
  4
229
239
  )
230
240
  );
241
+ await prepareContentTargets(eruditBuildDir, contentTargets);
242
+ writeFileSync(
243
+ `${eruditBuildDir}/__AUTOGENERATED__`,
244
+ `This directory is autogenerated by Erudit CLI.
245
+ All changes will be lost on next launch!`
246
+ );
231
247
  consola.success("Erudit build files ready!");
232
248
  }
249
+ async function prepareContentTargets(buildDir, targets) {
250
+ if (typeof targets === "undefined" || targets === "") {
251
+ return;
252
+ }
253
+ if (typeof targets === "string") {
254
+ targets = [targets];
255
+ }
256
+ if (Array.isArray(targets)) {
257
+ writeFileSync(
258
+ `${buildDir}/targets.json`,
259
+ JSON.stringify(targets, null, 4)
260
+ );
261
+ consola.success(`Saved ${targets.length} content targets!`);
262
+ return;
263
+ }
264
+ throw new Error(`Failed to resolve content targets: "${targets}"!`);
265
+ }
233
266
 
234
267
  async function spawnNuxt(command, projectPath) {
235
268
  return new Promise((resolve) => {
@@ -274,6 +307,14 @@ const projectPathArg = {
274
307
  default: "."
275
308
  }
276
309
  };
310
+ const contentTargetsArg = {
311
+ target: {
312
+ type: "string",
313
+ description: "Content targets to process",
314
+ required: false,
315
+ default: ""
316
+ }
317
+ };
277
318
  function resolveArgPaths(projectPath, eruditPath) {
278
319
  consola.start("Resolving project path...");
279
320
  projectPath = resolvePath(projectPath);
@@ -308,7 +349,10 @@ const prepare = defineCommand({
308
349
  args.projectPath,
309
350
  args.eruditPath
310
351
  );
311
- await prepare$1(projectPath, eruditPath);
352
+ await prepare$1({
353
+ projectPath,
354
+ eruditPath
355
+ });
312
356
  consola.start("Generating Nuxt build files...");
313
357
  await spawnNuxt("prepare", projectPath);
314
358
  consola.success("Nuxt is prepared!");
@@ -322,7 +366,8 @@ const dev = defineCommand({
322
366
  },
323
367
  args: {
324
368
  ...projectPathArg,
325
- ...eruditPathArg
369
+ ...eruditPathArg,
370
+ ...contentTargetsArg
326
371
  },
327
372
  async run({ args }) {
328
373
  logCommand("dev");
@@ -330,7 +375,11 @@ const dev = defineCommand({
330
375
  args.projectPath,
331
376
  args.eruditPath
332
377
  );
333
- await prepare$1(projectPath, eruditPath);
378
+ await prepare$1({
379
+ projectPath,
380
+ eruditPath,
381
+ contentTargets: args.target
382
+ });
334
383
  consola.start("Starting Nuxt dev...");
335
384
  await spawnNuxt("dev", projectPath);
336
385
  }
@@ -343,7 +392,8 @@ const generate = defineCommand({
343
392
  },
344
393
  args: {
345
394
  ...projectPathArg,
346
- ...eruditPathArg
395
+ ...eruditPathArg,
396
+ ...contentTargetsArg
347
397
  },
348
398
  async run({ args }) {
349
399
  logCommand("generate");
@@ -351,7 +401,11 @@ const generate = defineCommand({
351
401
  args.projectPath,
352
402
  args.eruditPath
353
403
  );
354
- await prepare$1(projectPath, eruditPath);
404
+ await prepare$1({
405
+ projectPath,
406
+ eruditPath,
407
+ contentTargets: args.target
408
+ });
355
409
  consola.start("Starting Nuxt generate...");
356
410
  await spawnNuxt("generate", projectPath);
357
411
  }
@@ -398,7 +452,8 @@ const build = defineCommand({
398
452
  },
399
453
  args: {
400
454
  ...projectPathArg,
401
- ...eruditPathArg
455
+ ...eruditPathArg,
456
+ ...contentTargetsArg
402
457
  },
403
458
  async run({ args }) {
404
459
  logCommand("build");
@@ -406,7 +461,11 @@ const build = defineCommand({
406
461
  args.projectPath,
407
462
  args.eruditPath
408
463
  );
409
- await prepare$1(projectPath, eruditPath);
464
+ await prepare$1({
465
+ projectPath,
466
+ eruditPath,
467
+ contentTargets: args.target
468
+ });
410
469
  consola$1.start("Starting Nuxt build...");
411
470
  await spawnNuxt("build", projectPath);
412
471
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@erudit-js/cli",
3
- "version": "3.0.0-dev.14",
3
+ "version": "3.0.0-dev.16",
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.14",
31
+ "@erudit-js/cog": "3.0.0-dev.16",
32
32
  "chalk": "^5.4.1",
33
33
  "citty": "^0.1.6",
34
34
  "consola": "^3.4.0"