create-vanilla-vite 1.2.0 → 1.2.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.
- package/CHANGELOG.md +34 -29
- package/README.md +195 -195
- package/bin/create-template.mjs +1764 -1764
- package/package.json +1 -1
- package/scripts/add-dependency.mjs +112 -112
- package/scripts/dev.mjs +625 -625
- package/scripts/install-info.mjs +78 -78
- package/scripts/run-app.mjs +40 -40
package/scripts/install-info.mjs
CHANGED
|
@@ -1,78 +1,78 @@
|
|
|
1
|
-
import { readFile, writeFile } from "node:fs/promises";
|
|
2
|
-
import { existsSync } from "node:fs";
|
|
3
|
-
import { join, relative } from "node:path";
|
|
4
|
-
import { fileURLToPath } from "node:url";
|
|
5
|
-
|
|
6
|
-
const root = fileURLToPath(new URL("../", import.meta.url));
|
|
7
|
-
const project = JSON.parse(await readFile(join(root, "package.json"), "utf8"));
|
|
8
|
-
const installStatePath = join(root, ".install-state");
|
|
9
|
-
if (process.argv.includes("--complete")) {
|
|
10
|
-
await writeFile(installStatePath, "installed\n");
|
|
11
|
-
process.exit(0);
|
|
12
|
-
}
|
|
13
|
-
const workspaces = await Promise.all(
|
|
14
|
-
project.workspaces.map(async (workspace) => ({
|
|
15
|
-
path: join(root, workspace),
|
|
16
|
-
manifest: JSON.parse(await readFile(join(root, workspace, "package.json"), "utf8")),
|
|
17
|
-
})),
|
|
18
|
-
);
|
|
19
|
-
const declaredDependencies = [
|
|
20
|
-
...Object.keys(project.dependencies ?? {}),
|
|
21
|
-
...Object.keys(project.devDependencies ?? {}),
|
|
22
|
-
...workspaces.flatMap(({ manifest }) => [
|
|
23
|
-
...Object.keys(manifest.dependencies ?? {}),
|
|
24
|
-
...Object.keys(manifest.devDependencies ?? {}),
|
|
25
|
-
]),
|
|
26
|
-
];
|
|
27
|
-
const hasInstalledDependencies = declaredDependencies.some(
|
|
28
|
-
(dependency) =>
|
|
29
|
-
existsSync(join(root, "node_modules", dependency)) ||
|
|
30
|
-
workspaces.some(({ path }) => existsSync(join(path, "node_modules", dependency))),
|
|
31
|
-
);
|
|
32
|
-
let installState;
|
|
33
|
-
try {
|
|
34
|
-
installState = (await readFile(installStatePath, "utf8")).trim();
|
|
35
|
-
} catch (error) {
|
|
36
|
-
if (error.code !== "ENOENT") throw error;
|
|
37
|
-
}
|
|
38
|
-
const freshInstall = installState === undefined && process.env.npm_command === "install";
|
|
39
|
-
|
|
40
|
-
if (
|
|
41
|
-
process.env.VANILLA_VITE_ALLOW_INSTALL !== "1" &&
|
|
42
|
-
process.env.CI === undefined &&
|
|
43
|
-
process.env.npm_command !== "ci" &&
|
|
44
|
-
!freshInstall &&
|
|
45
|
-
(installState === "installing" || installState === "installed" || hasInstalledDependencies)
|
|
46
|
-
) {
|
|
47
|
-
console.error(
|
|
48
|
-
"\nDirect installs are disabled to keep dependencies in the intended workspace.\n" +
|
|
49
|
-
"Use `pnpm adD <package>` or `pnpm add-dependency <package>`; with npm, use `npm run adD -- <package>` or `npm run add-dependency -- <package>`.\n" +
|
|
50
|
-
"The adD commands are the supported way to add packages.",
|
|
51
|
-
);
|
|
52
|
-
process.exit(1);
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
if (
|
|
56
|
-
process.env.VANILLA_VITE_ALLOW_INSTALL === "1" ||
|
|
57
|
-
process.env.CI !== undefined ||
|
|
58
|
-
process.env.npm_command === "ci" ||
|
|
59
|
-
freshInstall
|
|
60
|
-
) {
|
|
61
|
-
await writeFile(installStatePath, "installing\n");
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
console.log("Installing workspace dependencies:");
|
|
65
|
-
for (const { path, manifest } of workspaces) {
|
|
66
|
-
const dependencies = {
|
|
67
|
-
...manifest.dependencies,
|
|
68
|
-
...manifest.devDependencies,
|
|
69
|
-
};
|
|
70
|
-
console.log(`\n${manifest.name} (${relative(root, path)}):`);
|
|
71
|
-
if (!Object.keys(dependencies).length) {
|
|
72
|
-
console.log(" No dependencies declared.");
|
|
73
|
-
continue;
|
|
74
|
-
}
|
|
75
|
-
for (const [name, version] of Object.entries(dependencies)) {
|
|
76
|
-
console.log(` - ${name}@${version}`);
|
|
77
|
-
}
|
|
78
|
-
}
|
|
1
|
+
import { readFile, writeFile } from "node:fs/promises";
|
|
2
|
+
import { existsSync } from "node:fs";
|
|
3
|
+
import { join, relative } from "node:path";
|
|
4
|
+
import { fileURLToPath } from "node:url";
|
|
5
|
+
|
|
6
|
+
const root = fileURLToPath(new URL("../", import.meta.url));
|
|
7
|
+
const project = JSON.parse(await readFile(join(root, "package.json"), "utf8"));
|
|
8
|
+
const installStatePath = join(root, ".install-state");
|
|
9
|
+
if (process.argv.includes("--complete")) {
|
|
10
|
+
await writeFile(installStatePath, "installed\n");
|
|
11
|
+
process.exit(0);
|
|
12
|
+
}
|
|
13
|
+
const workspaces = await Promise.all(
|
|
14
|
+
project.workspaces.map(async (workspace) => ({
|
|
15
|
+
path: join(root, workspace),
|
|
16
|
+
manifest: JSON.parse(await readFile(join(root, workspace, "package.json"), "utf8")),
|
|
17
|
+
})),
|
|
18
|
+
);
|
|
19
|
+
const declaredDependencies = [
|
|
20
|
+
...Object.keys(project.dependencies ?? {}),
|
|
21
|
+
...Object.keys(project.devDependencies ?? {}),
|
|
22
|
+
...workspaces.flatMap(({ manifest }) => [
|
|
23
|
+
...Object.keys(manifest.dependencies ?? {}),
|
|
24
|
+
...Object.keys(manifest.devDependencies ?? {}),
|
|
25
|
+
]),
|
|
26
|
+
];
|
|
27
|
+
const hasInstalledDependencies = declaredDependencies.some(
|
|
28
|
+
(dependency) =>
|
|
29
|
+
existsSync(join(root, "node_modules", dependency)) ||
|
|
30
|
+
workspaces.some(({ path }) => existsSync(join(path, "node_modules", dependency))),
|
|
31
|
+
);
|
|
32
|
+
let installState;
|
|
33
|
+
try {
|
|
34
|
+
installState = (await readFile(installStatePath, "utf8")).trim();
|
|
35
|
+
} catch (error) {
|
|
36
|
+
if (error.code !== "ENOENT") throw error;
|
|
37
|
+
}
|
|
38
|
+
const freshInstall = installState === undefined && process.env.npm_command === "install";
|
|
39
|
+
|
|
40
|
+
if (
|
|
41
|
+
process.env.VANILLA_VITE_ALLOW_INSTALL !== "1" &&
|
|
42
|
+
process.env.CI === undefined &&
|
|
43
|
+
process.env.npm_command !== "ci" &&
|
|
44
|
+
!freshInstall &&
|
|
45
|
+
(installState === "installing" || installState === "installed" || hasInstalledDependencies)
|
|
46
|
+
) {
|
|
47
|
+
console.error(
|
|
48
|
+
"\nDirect installs are disabled to keep dependencies in the intended workspace.\n" +
|
|
49
|
+
"Use `pnpm adD <package>` or `pnpm add-dependency <package>`; with npm, use `npm run adD -- <package>` or `npm run add-dependency -- <package>`.\n" +
|
|
50
|
+
"The adD commands are the supported way to add packages.",
|
|
51
|
+
);
|
|
52
|
+
process.exit(1);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
if (
|
|
56
|
+
process.env.VANILLA_VITE_ALLOW_INSTALL === "1" ||
|
|
57
|
+
process.env.CI !== undefined ||
|
|
58
|
+
process.env.npm_command === "ci" ||
|
|
59
|
+
freshInstall
|
|
60
|
+
) {
|
|
61
|
+
await writeFile(installStatePath, "installing\n");
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
console.log("Installing workspace dependencies:");
|
|
65
|
+
for (const { path, manifest } of workspaces) {
|
|
66
|
+
const dependencies = {
|
|
67
|
+
...manifest.dependencies,
|
|
68
|
+
...manifest.devDependencies,
|
|
69
|
+
};
|
|
70
|
+
console.log(`\n${manifest.name} (${relative(root, path)}):`);
|
|
71
|
+
if (!Object.keys(dependencies).length) {
|
|
72
|
+
console.log(" No dependencies declared.");
|
|
73
|
+
continue;
|
|
74
|
+
}
|
|
75
|
+
for (const [name, version] of Object.entries(dependencies)) {
|
|
76
|
+
console.log(` - ${name}@${version}`);
|
|
77
|
+
}
|
|
78
|
+
}
|
package/scripts/run-app.mjs
CHANGED
|
@@ -1,40 +1,40 @@
|
|
|
1
|
-
import spawn from "cross-spawn";
|
|
2
|
-
import { readFile } from "node:fs/promises";
|
|
3
|
-
import { join } from "node:path";
|
|
4
|
-
import { fileURLToPath } from "node:url";
|
|
5
|
-
|
|
6
|
-
const [app, ...args] = process.argv.slice(2);
|
|
7
|
-
const root = fileURLToPath(new URL("../", import.meta.url));
|
|
8
|
-
const { workspaces } = JSON.parse(
|
|
9
|
-
await readFile(join(root, "package.json"), "utf8"),
|
|
10
|
-
);
|
|
11
|
-
const workspace = workspaces.find((name) => name.endsWith(`-${app}`));
|
|
12
|
-
|
|
13
|
-
if (!workspace || !["client", "server"].includes(app)) {
|
|
14
|
-
console.error("Usage: npm|pnpm client|server [dev|-dev]");
|
|
15
|
-
process.exit(1);
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
const packageManager = process.env.npm_config_user_agent?.startsWith("pnpm/")
|
|
19
|
-
? "pnpm"
|
|
20
|
-
: "npm";
|
|
21
|
-
let commandArgs;
|
|
22
|
-
if (args.length === 0 || (args.length === 1 && ["dev", "-dev"].includes(args[0]))) {
|
|
23
|
-
const script = args.length === 1 ? "dev" : "start";
|
|
24
|
-
commandArgs =
|
|
25
|
-
packageManager === "pnpm"
|
|
26
|
-
? ["--filter", workspace, "run", script]
|
|
27
|
-
: ["run", script, "--workspace", workspace];
|
|
28
|
-
} else {
|
|
29
|
-
console.error(`Usage: ${packageManager} ${app} [dev|-dev]`);
|
|
30
|
-
process.exit(1);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
const child = spawn(packageManager, commandArgs, { cwd: root, stdio: "inherit" });
|
|
34
|
-
child.once("error", (error) => {
|
|
35
|
-
console.error(`Unable to run ${packageManager}: ${error.message}`);
|
|
36
|
-
process.exitCode = 1;
|
|
37
|
-
});
|
|
38
|
-
child.once("exit", (code, signal) => {
|
|
39
|
-
process.exitCode = code ?? (signal ? 1 : 0);
|
|
40
|
-
});
|
|
1
|
+
import spawn from "cross-spawn";
|
|
2
|
+
import { readFile } from "node:fs/promises";
|
|
3
|
+
import { join } from "node:path";
|
|
4
|
+
import { fileURLToPath } from "node:url";
|
|
5
|
+
|
|
6
|
+
const [app, ...args] = process.argv.slice(2);
|
|
7
|
+
const root = fileURLToPath(new URL("../", import.meta.url));
|
|
8
|
+
const { workspaces } = JSON.parse(
|
|
9
|
+
await readFile(join(root, "package.json"), "utf8"),
|
|
10
|
+
);
|
|
11
|
+
const workspace = workspaces.find((name) => name.endsWith(`-${app}`));
|
|
12
|
+
|
|
13
|
+
if (!workspace || !["client", "server"].includes(app)) {
|
|
14
|
+
console.error("Usage: npm|pnpm client|server [dev|-dev]");
|
|
15
|
+
process.exit(1);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const packageManager = process.env.npm_config_user_agent?.startsWith("pnpm/")
|
|
19
|
+
? "pnpm"
|
|
20
|
+
: "npm";
|
|
21
|
+
let commandArgs;
|
|
22
|
+
if (args.length === 0 || (args.length === 1 && ["dev", "-dev"].includes(args[0]))) {
|
|
23
|
+
const script = args.length === 1 ? "dev" : "start";
|
|
24
|
+
commandArgs =
|
|
25
|
+
packageManager === "pnpm"
|
|
26
|
+
? ["--filter", workspace, "run", script]
|
|
27
|
+
: ["run", script, "--workspace", workspace];
|
|
28
|
+
} else {
|
|
29
|
+
console.error(`Usage: ${packageManager} ${app} [dev|-dev]`);
|
|
30
|
+
process.exit(1);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const child = spawn(packageManager, commandArgs, { cwd: root, stdio: "inherit" });
|
|
34
|
+
child.once("error", (error) => {
|
|
35
|
+
console.error(`Unable to run ${packageManager}: ${error.message}`);
|
|
36
|
+
process.exitCode = 1;
|
|
37
|
+
});
|
|
38
|
+
child.once("exit", (code, signal) => {
|
|
39
|
+
process.exitCode = code ?? (signal ? 1 : 0);
|
|
40
|
+
});
|