@erudit-js/cli 4.2.0 → 4.3.0
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/commands/dev.d.ts +6 -0
- package/dist/commands/dev.js +3 -1
- package/dist/commands/launch.d.ts +6 -0
- package/dist/commands/launch.js +3 -1
- package/dist/commands/main.js +3 -3
- package/dist/commands/preview.js +2 -2
- package/dist/inject.js +1 -1
- package/dist/shared/absPath.js +3 -3
- package/dist/shared/args.d.ts +8 -0
- package/dist/shared/args.js +8 -0
- package/dist/shared/cliError.js +2 -2
- package/dist/shared/logCommand.js +2 -2
- package/dist/shared/nuxt.js +1 -0
- package/dist/shared/prepare.js +2 -2
- package/dist/shared/projectPath.js +2 -2
- package/dist/shared/urlProps.js +3 -3
- package/package.json +2 -3
package/dist/commands/dev.d.ts
CHANGED
package/dist/commands/dev.js
CHANGED
|
@@ -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,
|
package/dist/commands/launch.js
CHANGED
|
@@ -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,
|
package/dist/commands/main.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { defineCommand } from 'citty';
|
|
2
|
-
import
|
|
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: ${
|
|
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: ${
|
|
34
|
+
console.log(`Erudit path: ${styleText(['bold', 'cyan'], CONFIG.ERUDIT_PATH)}`);
|
|
35
35
|
},
|
|
36
36
|
});
|
package/dist/commands/preview.js
CHANGED
|
@@ -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
|
|
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 → ${
|
|
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.
|
|
1
|
+
export const version = '4.3.0';
|
package/dist/shared/absPath.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { existsSync, lstatSync } from 'node:fs';
|
|
2
2
|
import { isAbsolute, resolve } from 'node:path';
|
|
3
|
-
import
|
|
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(
|
|
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(
|
|
22
|
+
throw new Error(styleText('red', `Path is not a directory: ${abs}`));
|
|
23
23
|
}
|
|
24
24
|
return abs;
|
|
25
25
|
}
|
package/dist/shared/args.d.ts
CHANGED
|
@@ -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";
|
package/dist/shared/args.js
CHANGED
|
@@ -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',
|
package/dist/shared/cliError.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { styleText } from 'node:util';
|
|
2
2
|
export function cliError(message, causeError) {
|
|
3
|
-
const error = new Error(`\n${
|
|
3
|
+
const error = new Error(`\n${styleText('red', message)}\n${causeError ?? ''}`, {
|
|
4
4
|
cause: causeError,
|
|
5
5
|
});
|
|
6
6
|
error.name = '';
|
package/dist/shared/nuxt.js
CHANGED
package/dist/shared/prepare.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { existsSync, mkdirSync, rmSync, writeFileSync } from 'node:fs';
|
|
2
|
-
import
|
|
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...');
|
|
@@ -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(` ${
|
|
99
|
+
process.stdout.write(` ${styleText(['bold', 'green'], 'Done!')}\n`);
|
|
100
100
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
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:',
|
|
21
|
+
console.log('Project path:', styleText(['bold', 'cyan'], projectPath));
|
|
22
22
|
}
|
package/dist/shared/urlProps.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
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: ${
|
|
76
|
-
console.log(`Site base path: ${
|
|
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.
|
|
3
|
+
"version": "4.3.0",
|
|
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.
|
|
33
|
+
"@erudit-js/core": "4.3.0",
|
|
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
|
}
|