@erudit-js/cli 4.0.0-dev.4 → 4.0.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/README.md +2 -2
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +7 -0
- package/dist/commands/build.d.ts +2 -19
- package/dist/commands/build.js +24 -19
- package/dist/commands/dev.d.ts +12 -6
- package/dist/commands/dev.js +32 -14
- package/dist/commands/generate.d.ts +13 -7
- package/dist/commands/generate.js +35 -15
- package/dist/commands/launch.d.ts +20 -2
- package/dist/commands/launch.js +34 -23
- package/dist/commands/main.js +14 -9
- package/dist/commands/prepare.d.ts +2 -8
- package/dist/commands/prepare.js +23 -15
- package/dist/commands/preview.d.ts +2 -2
- package/dist/commands/preview.js +48 -21
- package/dist/config.d.ts +3 -0
- package/dist/config.js +3 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/inject.d.ts +1 -0
- package/dist/inject.js +1 -0
- package/dist/shared/absPath.d.ts +3 -0
- package/dist/shared/absPath.js +25 -0
- package/dist/shared/args.d.ts +16 -12
- package/dist/shared/args.js +19 -32
- package/dist/shared/cliError.d.ts +1 -0
- package/dist/shared/cliError.js +8 -0
- package/dist/shared/env.d.ts +1 -0
- package/dist/shared/env.js +9 -0
- package/dist/shared/logCommand.js +4 -0
- package/dist/shared/nuxt.d.ts +7 -2
- package/dist/shared/nuxt.js +20 -34
- package/dist/shared/prepare.d.ts +3 -7
- package/dist/shared/prepare.js +53 -45
- package/dist/shared/projectPath.d.ts +3 -0
- package/dist/shared/projectPath.js +22 -0
- package/dist/shared/urlProps.d.ts +7 -0
- package/dist/shared/urlProps.js +77 -0
- package/package.json +35 -36
- package/bin/erudit-cli.js +0 -5
- package/dist/commands/init.d.ts +0 -8
- package/dist/commands/init.js +0 -60
- package/dist/run.d.ts +0 -1
- package/dist/run.js +0 -5
- package/dist/shared/log.js +0 -6
- package/dist/shared/path.d.ts +0 -1
- package/dist/shared/path.js +0 -13
- /package/dist/shared/{log.d.ts → logCommand.d.ts} +0 -0
package/dist/commands/init.js
DELETED
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import { defineCommand } from 'citty';
|
|
2
|
-
import { consola } from 'consola';
|
|
3
|
-
import chalk from 'chalk';
|
|
4
|
-
import { existsSync, mkdirSync, readdirSync, rmSync, writeFileSync, } from 'node:fs';
|
|
5
|
-
import { resolvePath } from '../shared/path.js';
|
|
6
|
-
export const init = defineCommand({
|
|
7
|
-
meta: {
|
|
8
|
-
name: 'Init',
|
|
9
|
-
description: 'Creates a new Erudit project at specified path',
|
|
10
|
-
},
|
|
11
|
-
args: {
|
|
12
|
-
path: {
|
|
13
|
-
type: 'positional',
|
|
14
|
-
description: 'Path for the new Erudit project',
|
|
15
|
-
required: true,
|
|
16
|
-
valueHint: chalk.gray(`"${chalk.greenBright('.')}" OR "${chalk.greenBright('path/to/project')}"`),
|
|
17
|
-
},
|
|
18
|
-
},
|
|
19
|
-
async run({ args }) {
|
|
20
|
-
consola.start('Resolving project path...');
|
|
21
|
-
const projectPath = resolvePath(args.path);
|
|
22
|
-
if (projectPath === undefined)
|
|
23
|
-
return;
|
|
24
|
-
if (existsSync(projectPath) && readdirSync(projectPath).length > 0)
|
|
25
|
-
throw new Error(`Directory "${chalk.yellowBright(projectPath)}" is not empty!`);
|
|
26
|
-
consola.success('Resolved project path:', chalk.greenBright(projectPath));
|
|
27
|
-
consola.start('Creating project directory...');
|
|
28
|
-
try {
|
|
29
|
-
try {
|
|
30
|
-
rmSync(projectPath, { recursive: true });
|
|
31
|
-
}
|
|
32
|
-
catch (error) {
|
|
33
|
-
if (error?.code !== 'ENOENT') {
|
|
34
|
-
throw error;
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
mkdirSync(projectPath, { recursive: true });
|
|
38
|
-
}
|
|
39
|
-
catch (error) {
|
|
40
|
-
throw new Error(`Failed to prepare project directory "${chalk.yellowBright(projectPath)}"!\n\n${error}`);
|
|
41
|
-
}
|
|
42
|
-
consola.success('Project directory created!');
|
|
43
|
-
consola.start('Creating project files...');
|
|
44
|
-
consola.success('Project files created!');
|
|
45
|
-
},
|
|
46
|
-
});
|
|
47
|
-
function createPackageJson(projectPath) {
|
|
48
|
-
// TODO: Get correct package versions
|
|
49
|
-
writeFileSync(`${projectPath}/package.json`, JSON.stringify({
|
|
50
|
-
private: true,
|
|
51
|
-
name: projectPath.split('/').pop() || 'my-erudit-project',
|
|
52
|
-
type: 'module',
|
|
53
|
-
scripts: {
|
|
54
|
-
dev: 'erudit dev',
|
|
55
|
-
build: 'erudit build',
|
|
56
|
-
preview: 'erudit preview',
|
|
57
|
-
prepare: 'erudit prepare',
|
|
58
|
-
},
|
|
59
|
-
}));
|
|
60
|
-
}
|
package/dist/run.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function run(): void;
|
package/dist/run.js
DELETED
package/dist/shared/log.js
DELETED
package/dist/shared/path.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function resolvePath(path: string): string;
|
package/dist/shared/path.js
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { existsSync, lstatSync } from 'node:fs';
|
|
2
|
-
import chalk from 'chalk';
|
|
3
|
-
import { resolve, isAbsolute } from 'node:path';
|
|
4
|
-
export function resolvePath(path) {
|
|
5
|
-
path = path.replace(/\\/g, '/');
|
|
6
|
-
path = path.endsWith('/') ? path.slice(0, -1) : path;
|
|
7
|
-
if (!isAbsolute(path)) {
|
|
8
|
-
path = resolve(process.cwd(), path).replace(/\\/g, '/');
|
|
9
|
-
}
|
|
10
|
-
if (existsSync(path) && !lstatSync(path).isDirectory())
|
|
11
|
-
throw new Error(`Path "${chalk.yellowBright(path)}" is not a directory!`);
|
|
12
|
-
return path;
|
|
13
|
-
}
|
|
File without changes
|