@erudit-js/cli 4.2.0-dev.1 → 4.3.0-dev.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.
@@ -1,4 +1,10 @@
1
1
  export declare const dev: import("citty").CommandDef<{
2
+ readonly reload: {
3
+ type: "boolean";
4
+ alias: string;
5
+ default: true;
6
+ description: string;
7
+ };
2
8
  readonly target: {
3
9
  type: "string";
4
10
  description: string;
@@ -1,6 +1,6 @@
1
1
  import { defineCommand } from 'citty';
2
2
  import { prepareProject } from '../shared/prepare.js';
3
- import { projectPathArg, siteUrlArg, basePathArg, contentTargetsArg, } from '../shared/args.js';
3
+ import { projectPathArg, siteUrlArg, basePathArg, contentTargetsArg, reloadArg, } from '../shared/args.js';
4
4
  import { logProjectPath, normalizeProjectPath, retrieveProjectPath, } from '../shared/projectPath.js';
5
5
  import { logUrlProps, normalizeUrlProps, retrieveUrlProps, } from '../shared/urlProps.js';
6
6
  import { loadEnvFiles } from '../shared/env.js';
@@ -17,6 +17,7 @@ export const dev = defineCommand({
17
17
  ...siteUrlArg,
18
18
  ...basePathArg,
19
19
  ...contentTargetsArg,
20
+ ...reloadArg,
20
21
  },
21
22
  async run({ args }) {
22
23
  const absProjectPath = normalizeProjectPath(retrieveProjectPath(args.projectPath));
@@ -37,6 +38,7 @@ export const dev = defineCommand({
37
38
  NUXT_PROJECT_PATH: absProjectPath,
38
39
  NUXT_CONTENT_TARGETS: args.target ?? '',
39
40
  NUXT_PUBLIC_ERUDIT_MODE: 'dev',
41
+ NUXT_PUBLIC_ERUDIT_RELOAD: String(args.reload ?? true),
40
42
  NUXT_PUBLIC_ERUDIT_VERSION: version,
41
43
  NUXT_APP_BASE_URL: urlProps.basePath,
42
44
  NUXT_PUBLIC_SITE_URL: urlProps.siteUrl,
@@ -1,4 +1,10 @@
1
1
  export declare const launch: import("citty").CommandDef<{
2
+ readonly reload: {
3
+ type: "boolean";
4
+ alias: string;
5
+ default: true;
6
+ description: string;
7
+ };
2
8
  readonly target: {
3
9
  type: "string";
4
10
  description: string;
@@ -1,7 +1,7 @@
1
1
  import { existsSync } from 'node:fs';
2
2
  import { spawn } from 'node:child_process';
3
3
  import { defineCommand } from 'citty';
4
- import { basePathArg, contentTargetsArg, projectPathArg, siteUrlArg, } from '../shared/args.js';
4
+ import { basePathArg, contentTargetsArg, projectPathArg, siteUrlArg, reloadArg, } from '../shared/args.js';
5
5
  import { logProjectPath, normalizeProjectPath, retrieveProjectPath, } from '../shared/projectPath.js';
6
6
  import { loadEnvFiles } from '../shared/env.js';
7
7
  import { logUrlProps, normalizeUrlProps, retrieveUrlProps, } from '../shared/urlProps.js';
@@ -18,6 +18,7 @@ export const launch = defineCommand({
18
18
  ...siteUrlArg,
19
19
  ...basePathArg,
20
20
  ...contentTargetsArg,
21
+ ...reloadArg,
21
22
  },
22
23
  async run({ args }) {
23
24
  const absProjectPath = normalizeProjectPath(retrieveProjectPath(args.projectPath));
@@ -40,6 +41,7 @@ export const launch = defineCommand({
40
41
  NUXT_PROJECT_PATH: absProjectPath,
41
42
  NUXT_CONTENT_TARGETS: args.target,
42
43
  NUXT_PUBLIC_ERUDIT_MODE: 'write',
44
+ NUXT_PUBLIC_ERUDIT_RELOAD: String(args.reload ?? true),
43
45
  NUXT_PUBLIC_ERUDIT_VERSION: version,
44
46
  NUXT_APP_BASE_URL: urlProps.basePath,
45
47
  NUXT_PUBLIC_SITE_URL: urlProps.siteUrl,
@@ -1,5 +1,5 @@
1
1
  import { defineCommand } from 'citty';
2
- import chalk from 'chalk';
2
+ import { styleText } from 'node:util';
3
3
  import { brandColorLogotype } from '@erudit-js/core/brandTerminal';
4
4
  import { version } from '../inject.js';
5
5
  import { logCommand } from '../shared/logCommand.js';
@@ -27,10 +27,10 @@ export const main = defineCommand({
27
27
  },
28
28
  setup({ args }) {
29
29
  console.log(brandColorLogotype);
30
- console.log(`Version: ${chalk.bold.cyan(version)}`);
30
+ console.log(`Version: ${styleText(['bold', 'cyan'], version)}`);
31
31
  if (args._[0]) {
32
32
  logCommand(args._[0]);
33
33
  }
34
- console.log(`Erudit path: ${chalk.bold.cyan(CONFIG.ERUDIT_PATH)}`);
34
+ console.log(`Erudit path: ${styleText(['bold', 'cyan'], CONFIG.ERUDIT_PATH)}`);
35
35
  },
36
36
  });
@@ -2,7 +2,7 @@ import { spawn } from 'node:child_process';
2
2
  import { existsSync, readdirSync } from 'node:fs';
3
3
  import { join, relative, sep } from 'node:path';
4
4
  import { defineCommand } from 'citty';
5
- import chalk from 'chalk';
5
+ import { styleText } from 'node:util';
6
6
  import { projectPathArg } from '../shared/args.js';
7
7
  import { logProjectPath, normalizeProjectPath, retrieveProjectPath, } from '../shared/projectPath.js';
8
8
  import { cliError } from '../shared/cliError.js';
@@ -27,7 +27,7 @@ export const preview = defineCommand({
27
27
  if (!possibleBasePath) {
28
28
  throw cliError(`Failed to find valid entry point (index.html with _nuxt directory) in generated static Erudit site!\n${didYouRun}`);
29
29
  }
30
- console.log(`Launching static site preview...\n → ${chalk.underline.cyan(`http://localhost:3000${possibleBasePath}`)}\n`);
30
+ console.log(`Launching static site preview...\n → ${styleText(['underline', 'cyan'], `http://localhost:3000${possibleBasePath}`)}\n`);
31
31
  spawn(`http-server ${distPath} -p 3000`, {
32
32
  shell: true,
33
33
  stdio: 'inherit',
package/dist/inject.js CHANGED
@@ -1 +1 @@
1
- export const version = '4.2.0-dev.1';
1
+ export const version = '4.3.0-dev.1';
@@ -1,6 +1,6 @@
1
1
  import { existsSync, lstatSync } from 'node:fs';
2
2
  import { isAbsolute, resolve } from 'node:path';
3
- import chalk from 'chalk';
3
+ import { styleText } from 'node:util';
4
4
  export function absPath(path) {
5
5
  const normalize = (p) => p.replaceAll('\\', '/');
6
6
  path = normalize(path);
@@ -12,14 +12,14 @@ export function absPath(path) {
12
12
  export function absPathEnsured(path) {
13
13
  const abs = absPath(path);
14
14
  if (!existsSync(abs)) {
15
- throw new Error(chalk.red(`Path does not exist: ${abs}`));
15
+ throw new Error(styleText('red', `Path does not exist: ${abs}`));
16
16
  }
17
17
  return abs;
18
18
  }
19
19
  export function absDirectoryEnsured(path) {
20
20
  const abs = absPathEnsured(path);
21
21
  if (!lstatSync(abs).isDirectory()) {
22
- throw new Error(chalk.red(`Path is not a directory: ${abs}`));
22
+ throw new Error(styleText('red', `Path is not a directory: ${abs}`));
23
23
  }
24
24
  return abs;
25
25
  }
@@ -30,6 +30,14 @@ export declare const contentTargetsArg: {
30
30
  valueHint: string;
31
31
  };
32
32
  };
33
+ export declare const reloadArg: {
34
+ reload: {
35
+ type: "boolean";
36
+ alias: string;
37
+ default: true;
38
+ description: string;
39
+ };
40
+ };
33
41
  export declare const nitroPresetArg: {
34
42
  preset: {
35
43
  type: "string";
@@ -30,6 +30,14 @@ export const contentTargetsArg = {
30
30
  valueHint: '"combinatorics"',
31
31
  },
32
32
  };
33
+ export const reloadArg = {
34
+ reload: {
35
+ type: 'boolean',
36
+ alias: 'r',
37
+ default: true,
38
+ description: 'Auto-reload browser tabs on successful content rebuild',
39
+ },
40
+ };
33
41
  export const nitroPresetArg = {
34
42
  preset: {
35
43
  type: 'string',
@@ -1,6 +1,6 @@
1
- import chalk from 'chalk';
1
+ import { styleText } from 'node:util';
2
2
  export function cliError(message, causeError) {
3
- const error = new Error(`\n${chalk.red(message)}\n${causeError ?? ''}`, {
3
+ const error = new Error(`\n${styleText('red', message)}\n${causeError ?? ''}`, {
4
4
  cause: causeError,
5
5
  });
6
6
  error.name = '';
@@ -1,4 +1,4 @@
1
- import chalk from 'chalk';
1
+ import { styleText } from 'node:util';
2
2
  export function logCommand(command) {
3
- console.log(`Running command: ${chalk.bold.cyan(command)}`);
3
+ console.log(`Running command: ${styleText(['bold', 'cyan'], command)}`);
4
4
  }
@@ -25,6 +25,7 @@ export async function spawnNuxt(config) {
25
25
  shell: true,
26
26
  stdio: 'inherit',
27
27
  env: {
28
+ FORCE_COLOR: '3',
28
29
  ...process.env,
29
30
  ...config.env,
30
31
  },
@@ -1,5 +1,5 @@
1
1
  import { existsSync, mkdirSync, rmSync, writeFileSync } from 'node:fs';
2
- import chalk from 'chalk';
2
+ import { styleText } from 'node:util';
3
3
  import { CONFIG } from '../config.js';
4
4
  export async function prepareProject({ absProjectPath, }) {
5
5
  process.stdout.write('Preparing Erudit project...');
@@ -67,7 +67,7 @@ export async function prepareProject({ absProjectPath, }) {
67
67
  allowSyntheticDefaultImports: true,
68
68
  jsx: 'react-jsx',
69
69
  jsxImportSource: 'tsprose',
70
- types: ['tsprose/externals', '@erudit-js/prose/raw'],
70
+ types: ['tsprose/jsx', 'tsprose/externals', '@erudit-js/prose/raw'],
71
71
  lib: ['ESNext'],
72
72
  },
73
73
  include: [`${absProjectPath}/**/*`, `${eruditBuildPath}/**/*`],
@@ -96,5 +96,5 @@ export async function prepareProject({ absProjectPath, }) {
96
96
  }, null, 4));
97
97
  }
98
98
  writeFileSync(`${eruditBuildPath}/__AUTOGENERATED__`, `This directory is autogenerated by Erudit CLI.\nAll changes will be lost on next build!`);
99
- process.stdout.write(` ${chalk.bold.green('Done!')}\n`);
99
+ process.stdout.write(` ${styleText(['bold', 'green'], 'Done!')}\n`);
100
100
  }
@@ -1,4 +1,4 @@
1
- import chalk from 'chalk';
1
+ import { styleText } from 'node:util';
2
2
  import { absDirectoryEnsured } from './absPath.js';
3
3
  import { cliError } from './cliError.js';
4
4
  export function retrieveProjectPath(projectPathArg) {
@@ -18,5 +18,5 @@ export function normalizeProjectPath(projectPath) {
18
18
  return absProjectPath;
19
19
  }
20
20
  export function logProjectPath(projectPath) {
21
- console.log('Project path:', chalk.bold.cyan(projectPath));
21
+ console.log('Project path:', styleText(['bold', 'cyan'], projectPath));
22
22
  }
@@ -1,4 +1,4 @@
1
- import chalk from 'chalk';
1
+ import { styleText } from 'node:util';
2
2
  import { cliError } from './cliError.js';
3
3
  export function retrieveUrlProps(siteUrlArg, basePathArg) {
4
4
  const finalProps = {
@@ -72,6 +72,6 @@ function normalizeBasePath(input) {
72
72
  return trimmed === '' ? '/' : `/${trimmed}/`;
73
73
  }
74
74
  export function logUrlProps(urlProps) {
75
- console.log(`Site URL: ${chalk.bold.cyan(urlProps.siteUrl)}`);
76
- console.log(`Site base path: ${chalk.bold.cyan(urlProps.basePath)}`);
75
+ console.log(`Site URL: ${styleText(['bold', 'cyan'], urlProps.siteUrl)}`);
76
+ console.log(`Site base path: ${styleText(['bold', 'cyan'], urlProps.basePath)}`);
77
77
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@erudit-js/cli",
3
- "version": "4.2.0-dev.1",
3
+ "version": "4.3.0-dev.1",
4
4
  "type": "module",
5
5
  "description": "📟 Command Line Interface for Erudit",
6
6
  "license": "MIT",
@@ -30,9 +30,8 @@
30
30
  "dist"
31
31
  ],
32
32
  "dependencies": {
33
- "@erudit-js/core": "4.2.0-dev.1",
33
+ "@erudit-js/core": "4.3.0-dev.1",
34
34
  "http-server": "^14.1.1",
35
- "chalk": "^5.6.2",
36
35
  "citty": "^0.2.1",
37
36
  "dotenv": "^17.3.1"
38
37
  }