@vited/create 0.0.2 → 0.0.3

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 CHANGED
@@ -1,5 +1,11 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.0.3 - 2026-10-28
4
+
5
+ ### Fixed
6
+
7
+ - Overwrite an existing `vited-new.config.ts` when generating a comparison config, without changing `vited.config.ts`.
8
+
3
9
  ## 0.0.2 - 2026-10-28
4
10
 
5
11
  ### Added
package/README.md CHANGED
@@ -37,3 +37,4 @@ 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.
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-CtHXEots.mjs";
1
+ export { t as THEMES, n as create, r as installPackages, i as resolvePackageManager } from "./src-Ch1B-4Rg.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.",
@@ -34,7 +34,6 @@ const resources = {
34
34
  multipleLockfiles: "Multiple package manager lockfiles found in {{path}}. Set packageManager in package.json.",
35
35
  installFailed: "{{packageManager}} install 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 查看命令行选项。",
@@ -70,7 +69,6 @@ const resources = {
70
69
  multipleLockfiles: "{{path}} 中存在多个包管理器锁文件,请在 package.json 中设置 packageManager。",
71
70
  installFailed: "{{packageManager}} install 退出,代码为 {{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}}",
@@ -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,12 +156,13 @@ 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(path.join(projectPath, "vited.config.ts"), makeVitedConfig(packageJson, theme), { flag: "wx" });
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) {
@@ -187,26 +186,28 @@ async function validateTarget(projectPath) {
187
186
  try {
188
187
  projectStat = await stat(projectPath);
189
188
  } catch (error) {
190
- if (isNodeError(error, "ENOENT")) return "create";
189
+ if (isNodeError(error, "ENOENT")) return {
190
+ mode: "create",
191
+ configPath: path.join(projectPath, "vited.config.ts"),
192
+ overwriteConfig: false
193
+ };
191
194
  throw error;
192
195
  }
193
196
  if (!projectStat.isDirectory()) throw new Error(t("errors.projectNotDirectory", { path: projectPath }));
194
- const configPath = path.join(projectPath, "vited.config.ts");
195
- let configExists = false;
196
- try {
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 }));
197
+ const hasExistingConfig = await fileExists(path.join(projectPath, "vited.config.ts"));
198
+ const configPath = path.join(projectPath, hasExistingConfig ? "vited-new.config.ts" : "vited.config.ts");
199
+ const overwriteConfig = hasExistingConfig && await fileExists(configPath);
203
200
  const docsPath = path.join(projectPath, "docs");
204
201
  try {
205
202
  if (!(await stat(docsPath)).isDirectory()) throw new Error(t("errors.docsNotDirectory", { path: docsPath }));
206
203
  } catch (error) {
207
204
  if (!isNodeError(error, "ENOENT")) throw error;
208
205
  }
209
- return "init";
206
+ return {
207
+ mode: "init",
208
+ configPath,
209
+ overwriteConfig
210
+ };
210
211
  }
211
212
  async function readProjectPackageJson(packageJsonPath, projectPath) {
212
213
  try {
@@ -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-CtHXEots.mjs";
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-Ch1B-4Rg.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.2";
8
+ var version = "0.0.3";
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", { path: result.projectPath }));
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", { path: result.projectPath }));
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.2",
3
+ "version": "0.0.3",
4
4
  "description": "Create and initialize Vited documentation projects",
5
5
  "keywords": [
6
6
  "cli",