create-pubinfo-pr 0.171.1 → 0.171.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/dist/cli.d.mts ADDED
@@ -0,0 +1 @@
1
+ export { };
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { a as validateInput, n as readPackageJSON, r as run, t as bootstrop } from "./helper.js";
2
+ import { a as validateInput, n as readPackageJSON, r as run, t as bootstrop } from "./helper.mjs";
3
3
  import { checkbox, confirm, input, select } from "@inquirer/prompts";
4
4
  import { logger } from "@pubinfo-pr/shared";
5
5
  import { Command } from "commander";
@@ -7,6 +7,7 @@ import { copy } from "fs-extra";
7
7
  import fs, { existsSync, renameSync } from "node:fs";
8
8
  import colors from "ansi-colors";
9
9
  import nodePlop from "node-plop";
10
+ import { spawn } from "node:child_process";
10
11
  import fonts from "cfonts";
11
12
 
12
13
  //#region src/core/copy.ts
@@ -20,6 +21,39 @@ async function copyTemplate(options) {
20
21
  await copy(resolve(templateDir, templateName), targetDir);
21
22
  }
22
23
 
24
+ //#endregion
25
+ //#region src/git.ts
26
+ function runGitCommand(args, cwd$1) {
27
+ return new Promise((resolvePromise, rejectPromise) => {
28
+ const child = spawn("git", args, {
29
+ cwd: cwd$1,
30
+ stdio: "ignore"
31
+ });
32
+ child.on("error", rejectPromise);
33
+ child.on("close", (code) => {
34
+ if (code === 0) {
35
+ resolvePromise();
36
+ return;
37
+ }
38
+ rejectPromise(/* @__PURE__ */ new Error(`git ${args.join(" ")} exited with code ${code}`));
39
+ });
40
+ });
41
+ }
42
+ async function initGitRepository(targetDir) {
43
+ if (!targetDir || !existsSync(targetDir)) return;
44
+ if (existsSync(resolve(targetDir, ".git"))) {
45
+ logger.info("检测到已存在 Git 仓库,跳过初始化。");
46
+ return;
47
+ }
48
+ try {
49
+ await runGitCommand(["init"], targetDir);
50
+ logger.success("已在项目目录中初始化 Git 仓库。");
51
+ } catch (error) {
52
+ logger.warn("Git 初始化失败,请手动执行 `git init`。");
53
+ logger.debug(error);
54
+ }
55
+ }
56
+
23
57
  //#endregion
24
58
  //#region src/core/generate.ts
25
59
  const __dirname = dirname(fileURLToPath(import.meta.url));
@@ -82,6 +116,7 @@ async function generate(options) {
82
116
  const newPath = resolve(targetDir, newName || oldName);
83
117
  if (existsSync(oldPath)) renameSync(oldPath, newPath);
84
118
  }
119
+ await initGitRepository(targetDir);
85
120
  logger.success(`${colors.green("项目模板初始化完成.")}`);
86
121
  }
87
122
 
@@ -161,21 +196,21 @@ async function run(version$1) {
161
196
  var package_default = {
162
197
  name: "create-pubinfo-pr",
163
198
  type: "module",
164
- version: "2.1.4",
199
+ version: "2.1.10-beta.2",
165
200
  description: "初始化项目框架",
166
201
  author: "Werheng <werheng.zhang@gmail.com>",
167
202
  license: "MIT",
168
203
  exports: {
169
204
  ".": {
170
- "types": "./dist/index.d.ts",
171
- "default": "./dist/index.js"
205
+ "types": "./dist/index.d.mts",
206
+ "default": "./dist/index.mjs"
172
207
  },
173
208
  "./package.json": "./package.json"
174
209
  },
175
- main: "./dist/index.js",
176
- module: "./dist/index.js",
177
- types: "./dist/index.d.ts",
178
- bin: { "pubinfo-pr": "./dist/cli.js" },
210
+ main: "./dist/index.mjs",
211
+ module: "./dist/index.mjs",
212
+ types: "./dist/index.d.mts",
213
+ bin: { "pubinfo-pr": "./dist/cli.mjs" },
179
214
  files: ["dist", "templates"],
180
215
  engines: { "node": "^20.19.0 || >=22.12.0" },
181
216
  scripts: {
@@ -1,3 +1,3 @@
1
- import { i as interaction, n as readPackageJSON, o as generate, r as run, s as copyTemplate } from "./helper.js";
1
+ import { i as interaction, n as readPackageJSON, o as generate, r as run, s as copyTemplate } from "./helper.mjs";
2
2
 
3
3
  export { copyTemplate, generate, interaction, readPackageJSON, run };
package/package.json CHANGED
@@ -1,22 +1,22 @@
1
1
  {
2
2
  "name": "create-pubinfo-pr",
3
3
  "type": "module",
4
- "version": "0.171.1",
4
+ "version": "0.171.3",
5
5
  "description": "初始化项目框架",
6
6
  "author": "Werheng <werheng.zhang@gmail.com>",
7
7
  "license": "MIT",
8
8
  "exports": {
9
9
  ".": {
10
- "types": "./dist/index.d.ts",
11
- "default": "./dist/index.js"
10
+ "types": "./dist/index.d.mts",
11
+ "default": "./dist/index.mjs"
12
12
  },
13
13
  "./package.json": "./package.json"
14
14
  },
15
- "main": "./dist/index.js",
16
- "module": "./dist/index.js",
17
- "types": "./dist/index.d.ts",
15
+ "main": "./dist/index.mjs",
16
+ "module": "./dist/index.mjs",
17
+ "types": "./dist/index.d.mts",
18
18
  "bin": {
19
- "pubinfo": "./dist/cli.js"
19
+ "pubinfo": "./dist/cli.mjs"
20
20
  },
21
21
  "files": [
22
22
  "dist",
@@ -27,7 +27,7 @@
27
27
  },
28
28
  "dependencies": {
29
29
  "@inquirer/prompts": "^7.6.0",
30
- "@pubinfo-pr/shared": "0.171.1",
30
+ "@pubinfo-pr/shared": "0.171.3",
31
31
  "ansi-colors": "^4.1.3",
32
32
  "cfonts": "^3.3.0",
33
33
  "commander": "^14.0.0",
package/dist/cli.d.ts DELETED
@@ -1,2 +0,0 @@
1
- #!/usr/bin/env node
2
- export {};
File without changes