@ghini/xstart 25.12.29104833 → 26.1.3144738

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.
Files changed (3) hide show
  1. package/README.md +8 -4
  2. package/build.js +9 -11
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -1,6 +1,7 @@
1
1
  # 一个标准 TypeScript 2026 的 npm 库脚手架
2
2
 
3
3
  ### 开发
4
+
4
5
  ```bash
5
6
  pnpm tsc --watch
6
7
  pnpm type-check # 类型检查(不生成文件)
@@ -8,6 +9,7 @@ pnpm build # 编译 TypeScript + 打包 + 更新版本号
8
9
  ```
9
10
 
10
11
  ### 发布
12
+
11
13
  ```bash
12
14
  pnpm pub # 构建 + 发布到 npm + 提交 git
13
15
  ```
@@ -19,16 +21,20 @@ pnpm pub # 构建 + 发布到 npm + 提交 git
19
21
  - `strict: true` - 全部严格类型检查
20
22
  - `declaration: true` - 自动生成类型声明
21
23
 
22
- 如果需要pnpm迁移:
24
+ 如果需要 pnpm 迁移:
25
+
23
26
  ```ps1
24
27
  pnpm import
25
28
  Remove-Item -Recurse -Force node_modules
26
29
  Remove-Item package-lock.json
27
- pnpm install
30
+ pnpm i
31
+ pnpm tsc --watch
28
32
  ```
29
33
 
30
34
  ## 📦 创建新库
35
+
31
36
  全文件替换 `xstart` 为新库名:
37
+
32
38
  ```bash
33
39
  Remove-Item -Recurse -Force .git
34
40
  git init
@@ -39,5 +45,3 @@ git remote add origin git@github.com:xghini/mynpm.git
39
45
  git push -u origin xstart
40
46
  pnpm pub
41
47
  ```
42
-
43
-
package/build.js CHANGED
@@ -1,6 +1,6 @@
1
1
  // build.js
2
2
  import fs from 'fs';
3
- import { execSync } from 'child_process';
3
+ import {execSync} from 'child_process';
4
4
  const devDir = './dev';
5
5
  const distDir = './dist';
6
6
  const packageJsonPath = './package.json';
@@ -13,15 +13,14 @@ const packageJsonPath = './package.json';
13
13
  function generateVersionFromDate() {
14
14
  const now = new Date();
15
15
  const year = now.getFullYear().toString().slice(-2); // 获取年份后两位
16
- const month = (now.getMonth() + 1).toString(); // 月份(1-12)
17
- const day = now.getDate().toString(); // 日(1-31)
18
- const hours = now.getHours().toString().padStart(2, '0'); // 小时(00-23)
16
+ const month = (now.getMonth() + 1).toString(); // 月份(1-12)
17
+ const day = now.getDate().toString(); // 日(1-31)
18
+ const hours = now.getHours().toString().padStart(2, '0'); // 小时(00-23)
19
19
  const minutes = now.getMinutes().toString().padStart(2, '0'); // 分钟(00-59)
20
20
  const seconds = now.getSeconds().toString().padStart(2, '0'); // 秒(00-59)
21
21
  return `${year}.${month}.${day}${hours}${minutes}${seconds}`;
22
22
  }
23
23
 
24
-
25
24
  // --- 主要构建流程 ---
26
25
  try {
27
26
  console.log('🚀 开始执行构建流程...');
@@ -29,32 +28,31 @@ try {
29
28
  // 步骤 1: 清理旧的 'dist' 和 'dev' 目录
30
29
  if (fs.existsSync(distDir)) {
31
30
  console.log(`[1/3] 正在删除旧目录: ${distDir}`);
32
- fs.rmSync(distDir, { recursive: true, force: true });
31
+ fs.rmSync(distDir, {recursive: true, force: true});
33
32
  }
34
33
  if (fs.existsSync(devDir)) {
35
34
  console.log(`[1/3] 正在删除旧目录: ${devDir}`);
36
- fs.rmSync(devDir, { recursive: true, force: true });
35
+ fs.rmSync(devDir, {recursive: true, force: true});
37
36
  }
38
37
 
39
38
  // 步骤 2: 运行 TypeScript 编译
40
39
  console.log(`[2/3] 正在编译 TypeScript...`);
41
- execSync('npx tsc', { stdio: 'inherit' });
40
+ execSync('pnpm tsc', {stdio: 'inherit'});
42
41
  console.log('...TypeScript 编译完成。');
43
42
 
44
43
  // 步骤 3: 更新 package.json 中的版本号
45
44
  console.log(`[3/3] 正在更新 ${packageJsonPath} 中的版本号...`);
46
45
  const packageJsonContent = fs.readFileSync(packageJsonPath, 'utf8');
47
46
  const packageJson = JSON.parse(packageJsonContent);
48
-
47
+
49
48
  const oldVersion = packageJson.version;
50
49
  const newVersion = generateVersionFromDate();
51
50
  packageJson.version = newVersion;
52
-
51
+
53
52
  fs.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2));
54
53
  console.log(`...版本号已从 ${oldVersion} 更新为 ${newVersion}。`);
55
54
 
56
55
  console.log('\n✅ 构建流程成功完成!');
57
-
58
56
  } catch (error) {
59
57
  console.error('\n❌ 构建流程失败:');
60
58
  console.error(error.message);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ghini/xstart",
3
- "version": "25.12.29104833",
3
+ "version": "26.1.3144738",
4
4
  "exports": {
5
5
  ".": {
6
6
  "import": "./dist/index.js",