@vited/create 0.0.2 → 0.0.4
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 +12 -0
- package/README.md +3 -0
- package/dist/index.d.mts +1 -0
- package/dist/index.mjs +1 -1
- package/dist/{src-CtHXEots.mjs → src-BWiFwqr3.mjs} +45 -28
- package/dist/vited-create.mjs +10 -4
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.0.4 - 2026-10-28
|
|
4
|
+
|
|
5
|
+
### Fixed
|
|
6
|
+
|
|
7
|
+
- Upgrade existing React and React DOM dependencies to React 19 when initializing a Vited project.
|
|
8
|
+
|
|
9
|
+
## 0.0.3 - 2026-10-28
|
|
10
|
+
|
|
11
|
+
### Fixed
|
|
12
|
+
|
|
13
|
+
- Overwrite an existing `vited-new.config.ts` when generating a comparison config, without changing `vited.config.ts`.
|
|
14
|
+
|
|
3
15
|
## 0.0.2 - 2026-10-28
|
|
4
16
|
|
|
5
17
|
### Added
|
package/README.md
CHANGED
|
@@ -37,3 +37,6 @@ The generated project includes `vited.config.ts`, a `docs` directory, and
|
|
|
37
37
|
`docs:dev` / `docs:build` scripts. `@vited/core` provides the HTML shell, so no
|
|
38
38
|
`index.html` is added to the project. Existing package scripts and documentation
|
|
39
39
|
files are preserved. An existing `vited.config.ts` is not overwritten.
|
|
40
|
+
If it already exists, `vited-new.config.ts` is created or overwritten for comparison.
|
|
41
|
+
When installing with pnpm, the required `@swc/core` and `esbuild` build scripts
|
|
42
|
+
are approved automatically to comply with pnpm's build-script policy.
|
package/dist/index.d.mts
CHANGED
|
@@ -11,6 +11,7 @@ export interface CreateOptions {
|
|
|
11
11
|
export interface CreateResult {
|
|
12
12
|
projectPath: string;
|
|
13
13
|
mode: ProjectMode;
|
|
14
|
+
configPath: string;
|
|
14
15
|
}
|
|
15
16
|
export declare function resolvePackageManager(projectPath: string, environment?: NodeJS.ProcessEnv): Promise<PackageManager>;
|
|
16
17
|
export declare function create({ directory, theme, packageManager, install }: CreateOptions): Promise<CreateResult>;
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { t as THEMES, n as create, r as installPackages, i as resolvePackageManager } from "./src-
|
|
1
|
+
export { t as THEMES, n as create, r as installPackages, i as resolvePackageManager } from "./src-BWiFwqr3.mjs";
|
|
@@ -17,7 +17,7 @@ const resources = {
|
|
|
17
17
|
language: "Language for prompts and messages",
|
|
18
18
|
showHelp: "Show full help",
|
|
19
19
|
showVersion: "Show version number",
|
|
20
|
-
configured: "Vited documentation configured at {{path}}"
|
|
20
|
+
configured: "Vited documentation configured at {{path}}. Configuration file: {{configPath}}"
|
|
21
21
|
},
|
|
22
22
|
interactive: {
|
|
23
23
|
terminalRequired: "Interactive mode requires a terminal. Use --help for command-line options.",
|
|
@@ -32,9 +32,8 @@ const resources = {
|
|
|
32
32
|
invalidPackageManagerType: "Invalid package.json: packageManager must be a string in {{path}}",
|
|
33
33
|
unsupportedPackageManager: "Unsupported package manager in {{path}}: {{packageManager}}",
|
|
34
34
|
multipleLockfiles: "Multiple package manager lockfiles found in {{path}}. Set packageManager in package.json.",
|
|
35
|
-
|
|
35
|
+
commandFailed: "{{command}} exited with code {{code}}",
|
|
36
36
|
projectNotDirectory: "Project path is not a directory: {{path}}",
|
|
37
|
-
alreadyConfigured: "Vited is already configured in {{path}}. Remove or rename vited.config.ts before running create again.",
|
|
38
37
|
docsNotDirectory: "Cannot create documentation: {{path}} is not a directory.",
|
|
39
38
|
invalidPackageJson: "Invalid package.json: expected a JSON object in {{path}}",
|
|
40
39
|
invalidPackageJsonSyntax: "Invalid JSON in package.json: {{path}}",
|
|
@@ -53,7 +52,7 @@ const resources = {
|
|
|
53
52
|
language: "提示和消息使用的语言",
|
|
54
53
|
showHelp: "显示帮助信息",
|
|
55
54
|
showVersion: "显示版本号",
|
|
56
|
-
configured: "已在 {{path}} 配置 Vited
|
|
55
|
+
configured: "已在 {{path}} 配置 Vited 文档。配置文件:{{configPath}}"
|
|
57
56
|
},
|
|
58
57
|
interactive: {
|
|
59
58
|
terminalRequired: "交互模式需要终端。请使用 --help 查看命令行选项。",
|
|
@@ -68,9 +67,8 @@ const resources = {
|
|
|
68
67
|
invalidPackageManagerType: "package.json 配置无效:{{path}} 中的 packageManager 必须是字符串",
|
|
69
68
|
unsupportedPackageManager: "{{path}} 中配置了不支持的包管理器:{{packageManager}}",
|
|
70
69
|
multipleLockfiles: "{{path}} 中存在多个包管理器锁文件,请在 package.json 中设置 packageManager。",
|
|
71
|
-
|
|
70
|
+
commandFailed: "{{command}} 退出,代码为 {{code}}",
|
|
72
71
|
projectNotDirectory: "项目路径不是目录:{{path}}",
|
|
73
|
-
alreadyConfigured: "{{path}} 已配置 Vited。请删除或重命名 vited.config.ts 后再运行 create。",
|
|
74
72
|
docsNotDirectory: "无法创建文档:{{path}} 不是目录。",
|
|
75
73
|
invalidPackageJson: "package.json 无效:{{path}} 应为 JSON 对象",
|
|
76
74
|
invalidPackageJsonSyntax: "package.json 中的 JSON 无效:{{path}}",
|
|
@@ -101,12 +99,12 @@ function t(key, options) {
|
|
|
101
99
|
}
|
|
102
100
|
// src/index.ts
|
|
103
101
|
const THEMES = ["@vited/theme-mantine"];
|
|
102
|
+
const defaultReactVersion = "^19.3.1";
|
|
103
|
+
const reactPackages = ["react", "react-dom"];
|
|
104
104
|
const vitedPackages = {
|
|
105
105
|
"@vited/cli": "^0.1.0",
|
|
106
106
|
"@vited/core": "^0.1.0",
|
|
107
|
-
"@vited/theme-mantine": "^0.
|
|
108
|
-
react: "^19.3.1",
|
|
109
|
-
"react-dom": "^19.3.1",
|
|
107
|
+
"@vited/theme-mantine": "^0.2.0",
|
|
110
108
|
vite: "^8.3.5"
|
|
111
109
|
};
|
|
112
110
|
const packageManagerLockfiles = {
|
|
@@ -150,7 +148,7 @@ async function resolvePackageManager(projectPath, environment = process.env) {
|
|
|
150
148
|
}
|
|
151
149
|
async function create({ directory, theme, packageManager, install }) {
|
|
152
150
|
const projectPath = path.resolve(directory);
|
|
153
|
-
const mode = await validateTarget(projectPath);
|
|
151
|
+
const { mode, configPath, overwriteConfig } = await validateTarget(projectPath);
|
|
154
152
|
const packageJsonPath = path.join(projectPath, "package.json");
|
|
155
153
|
const packageJson = await readProjectPackageJson(packageJsonPath, projectPath);
|
|
156
154
|
addVitedConfiguration(packageJson, projectPath, theme);
|
|
@@ -158,27 +156,38 @@ async function create({ directory, theme, packageManager, install }) {
|
|
|
158
156
|
const docsPath = path.join(projectPath, "docs");
|
|
159
157
|
await mkdir(docsPath, { recursive: true });
|
|
160
158
|
await writeFile(packageJsonPath, `${JSON.stringify(packageJson, void 0, 2)}\n`);
|
|
161
|
-
await writeFile(
|
|
159
|
+
await writeFile(configPath, makeVitedConfig(packageJson, theme), { flag: overwriteConfig ? "w" : "wx" });
|
|
162
160
|
await writeIfMissing(path.join(docsPath, "README.md"), makeReadme(packageJson));
|
|
163
161
|
if (install) await installPackages(projectPath, packageManager);
|
|
164
162
|
return {
|
|
165
163
|
projectPath,
|
|
166
|
-
mode
|
|
164
|
+
mode,
|
|
165
|
+
configPath
|
|
167
166
|
};
|
|
168
167
|
}
|
|
169
168
|
async function installPackages(projectPath, packageManager) {
|
|
169
|
+
if (packageManager === "pnpm") await runPackageCommand("pnpm", [
|
|
170
|
+
"approve-builds",
|
|
171
|
+
"@swc/core",
|
|
172
|
+
"esbuild"
|
|
173
|
+
], projectPath);
|
|
174
|
+
await runPackageCommand(packageManager, ["install"], projectPath);
|
|
175
|
+
}
|
|
176
|
+
async function runPackageCommand(packageManager, args, projectPath) {
|
|
177
|
+
const command = [packageManager, ...args].join(" ");
|
|
178
|
+
const createCommandError = (code) => new Error(t("errors.commandFailed", {
|
|
179
|
+
command,
|
|
180
|
+
code: code === null ? "unknown" : code
|
|
181
|
+
}));
|
|
170
182
|
await new Promise((resolve, reject) => {
|
|
171
|
-
const child = spawn(packageManager,
|
|
183
|
+
const child = spawn(packageManager, args, {
|
|
172
184
|
cwd: projectPath,
|
|
173
185
|
stdio: "inherit"
|
|
174
186
|
});
|
|
175
187
|
child.once("error", reject);
|
|
176
188
|
child.once("close", (code) => {
|
|
177
189
|
if (code === 0) resolve();
|
|
178
|
-
else reject(
|
|
179
|
-
packageManager,
|
|
180
|
-
code: code === null ? "unknown" : code
|
|
181
|
-
})));
|
|
190
|
+
else reject(createCommandError(code));
|
|
182
191
|
});
|
|
183
192
|
});
|
|
184
193
|
}
|
|
@@ -187,26 +196,28 @@ async function validateTarget(projectPath) {
|
|
|
187
196
|
try {
|
|
188
197
|
projectStat = await stat(projectPath);
|
|
189
198
|
} catch (error) {
|
|
190
|
-
if (isNodeError(error, "ENOENT")) return
|
|
199
|
+
if (isNodeError(error, "ENOENT")) return {
|
|
200
|
+
mode: "create",
|
|
201
|
+
configPath: path.join(projectPath, "vited.config.ts"),
|
|
202
|
+
overwriteConfig: false
|
|
203
|
+
};
|
|
191
204
|
throw error;
|
|
192
205
|
}
|
|
193
206
|
if (!projectStat.isDirectory()) throw new Error(t("errors.projectNotDirectory", { path: projectPath }));
|
|
194
|
-
const
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
await stat(configPath);
|
|
198
|
-
configExists = true;
|
|
199
|
-
} catch (error) {
|
|
200
|
-
if (!isNodeError(error, "ENOENT")) throw error;
|
|
201
|
-
}
|
|
202
|
-
if (configExists) throw new Error(t("errors.alreadyConfigured", { path: projectPath }));
|
|
207
|
+
const hasExistingConfig = await fileExists(path.join(projectPath, "vited.config.ts"));
|
|
208
|
+
const configPath = path.join(projectPath, hasExistingConfig ? "vited-new.config.ts" : "vited.config.ts");
|
|
209
|
+
const overwriteConfig = hasExistingConfig && await fileExists(configPath);
|
|
203
210
|
const docsPath = path.join(projectPath, "docs");
|
|
204
211
|
try {
|
|
205
212
|
if (!(await stat(docsPath)).isDirectory()) throw new Error(t("errors.docsNotDirectory", { path: docsPath }));
|
|
206
213
|
} catch (error) {
|
|
207
214
|
if (!isNodeError(error, "ENOENT")) throw error;
|
|
208
215
|
}
|
|
209
|
-
return
|
|
216
|
+
return {
|
|
217
|
+
mode: "init",
|
|
218
|
+
configPath,
|
|
219
|
+
overwriteConfig
|
|
220
|
+
};
|
|
210
221
|
}
|
|
211
222
|
async function readProjectPackageJson(packageJsonPath, projectPath) {
|
|
212
223
|
try {
|
|
@@ -243,6 +254,12 @@ function addVitedConfiguration(packageJson, projectPath, theme) {
|
|
|
243
254
|
if (name === "@vited/theme-mantine" && theme !== name) continue;
|
|
244
255
|
if (dependencies[name] === void 0 && devDependencies[name] === void 0) devDependencies[name] = version;
|
|
245
256
|
}
|
|
257
|
+
const reactTarget = reactPackages.some((name) => dependencies[name] !== void 0) ? dependencies : devDependencies;
|
|
258
|
+
const reactOther = reactTarget === dependencies ? devDependencies : dependencies;
|
|
259
|
+
for (const name of reactPackages) {
|
|
260
|
+
reactTarget[name] = defaultReactVersion;
|
|
261
|
+
delete reactOther[name];
|
|
262
|
+
}
|
|
246
263
|
packageJson["devDependencies"] = devDependencies;
|
|
247
264
|
}
|
|
248
265
|
function getRecord(value, name) {
|
package/dist/vited-create.mjs
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { a as LANGUAGES, c as t, i as resolvePackageManager, n as create, o as isLanguage, s as setLanguage, t as THEMES } from "./src-
|
|
2
|
+
import { a as LANGUAGES, c as t, i as resolvePackageManager, n as create, o as isLanguage, s as setLanguage, t as THEMES } from "./src-BWiFwqr3.mjs";
|
|
3
3
|
import process from "node:process";
|
|
4
4
|
import console from "node:console";
|
|
5
5
|
import { Command, Option } from "commander";
|
|
6
6
|
import { cancel, confirm, intro, isCancel, outro, select, text } from "@clack/prompts";
|
|
7
7
|
// package.json
|
|
8
|
-
var version = "0.0.
|
|
8
|
+
var version = "0.0.4";
|
|
9
9
|
// src/interactive.ts
|
|
10
10
|
async function runInteractive() {
|
|
11
11
|
if (!process.stdin.isTTY || !process.stdout.isTTY) throw new Error(t("interactive.terminalRequired"));
|
|
@@ -49,7 +49,10 @@ async function runInteractive() {
|
|
|
49
49
|
packageManager,
|
|
50
50
|
install
|
|
51
51
|
});
|
|
52
|
-
outro(t("cli.configured", {
|
|
52
|
+
outro(t("cli.configured", {
|
|
53
|
+
path: result.projectPath,
|
|
54
|
+
configPath: result.configPath
|
|
55
|
+
}));
|
|
53
56
|
}
|
|
54
57
|
// src/vited-create.ts
|
|
55
58
|
function getLanguageArgument(args) {
|
|
@@ -79,7 +82,10 @@ program.description(t("cli.description")).argument("[directory]", t("cli.directo
|
|
|
79
82
|
packageManager,
|
|
80
83
|
install: options.install
|
|
81
84
|
});
|
|
82
|
-
console.log(t("cli.configured", {
|
|
85
|
+
console.log(t("cli.configured", {
|
|
86
|
+
path: result.projectPath,
|
|
87
|
+
configPath: result.configPath
|
|
88
|
+
}));
|
|
83
89
|
});
|
|
84
90
|
program.helpOption("-h, --help", t("cli.showHelp"));
|
|
85
91
|
program.version(version, "-v, --version", t("cli.showVersion"));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vited/create",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.4",
|
|
4
4
|
"description": "Create and initialize Vited documentation projects",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cli",
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
"@types/node": "^20.5.8",
|
|
54
54
|
"@vited/cli": "^0.1.0",
|
|
55
55
|
"@vited/core": "^0.1.0",
|
|
56
|
-
"@vited/theme-mantine": "^0.
|
|
56
|
+
"@vited/theme-mantine": "^0.2.0",
|
|
57
57
|
"husky": "^9.1.7",
|
|
58
58
|
"lint-staged": "^17.6.0",
|
|
59
59
|
"oxfmt": "^0.75.0",
|