@ghini/xstart 25.11.28033518 → 25.12.10043118

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/.clinerules ADDED
@@ -0,0 +1,2 @@
1
+ 1.你是一位崇尚“极简主义”和“实用主义”的架构师与技术专家,总是与时俱进基于当前最新时间点的成熟优秀技术进行思考,使用当前最新最稳的技术标准实现,不适用过时的方法。严格遵循“奥卡姆剃刀”原则——若无必要,勿增实体。强调代码紧凑、最小改动、不留死代码,且严禁随意重命名变量。
2
+ 2.中文为第一语言,充分利用每一次响应最大化解决问题:进行修改前,先把修改的核心思路说明;代码修改时,强制写入,禁止文本代替写入输出;修改后告知注意事项,无需过多总结。
package/README.md CHANGED
@@ -1,15 +1,34 @@
1
- # 一个标准JS(兼容ts)的npm库开始结构
1
+ # 一个标准 TypeScript 2025 的 npm 库脚手架
2
2
 
3
- ## build.js用来修改version和打包
3
+ ### 开发
4
+ ```bash
5
+ npx tsc --watch
6
+ npm run type-check # 类型检查(不生成文件)
7
+ npm run build # 编译 TypeScript + 打包 + 更新版本号
8
+ ```
4
9
 
5
- ## 全文件替换ghini为新库名
10
+ ### 发布
11
+ ```bash
12
+ npm run pub # 构建 + 发布到 npm + 提交 git
6
13
  ```
14
+
15
+ ## 🔧 TypeScript 配置亮点
16
+
17
+ - `moduleResolution: "bundler"` - 2025 最新模块解析策略
18
+ - `verbatimModuleSyntax: true` - 严格 ESM 语法
19
+ - `strict: true` - 全部严格类型检查
20
+ - `declaration: true` - 自动生成类型声明
21
+
22
+ ## 📦 创建新库
23
+
24
+ 全文件替换 `xstart` 为新库名:
25
+ ```bash
7
26
  Remove-Item -Recurse -Force .git
8
27
  git init
9
28
  git add .
10
29
  git commit -m "Initial commit"
11
- git branch -M ghini
12
- git remote add origin https://github.com/xghini/mynpm.git
13
- git push -u origin ghini
30
+ git branch -M xstart
31
+ git remote add origin git@github.com:xghini/mynpm.git
32
+ git push -u origin xstart
14
33
  npm run pub
15
34
  ```
package/build.js CHANGED
@@ -1,6 +1,8 @@
1
1
  // build.js
2
2
  import fs from 'fs';
3
3
  import path from 'path';
4
+ import { execSync } from 'child_process';
5
+ const srcDir = './src';
4
6
  const devDir = './dev';
5
7
  const distDir = './dist';
6
8
  const packageJsonPath = './package.json';
@@ -54,17 +56,20 @@ function generateVersionFromDate() {
54
56
  try {
55
57
  console.log('🚀 开始执行构建流程...');
56
58
 
57
- // 步骤 1: 清理旧的 'dist' 目录
59
+ // 步骤 1: 清理旧的 'dist' 和 'dev' 目录
58
60
  if (fs.existsSync(distDir)) {
59
61
  console.log(`[1/3] 正在删除旧目录: ${distDir}`);
60
- // fs.rmSync 是一个现代且高效的递归删除目录的方法
61
62
  fs.rmSync(distDir, { recursive: true, force: true });
62
63
  }
64
+ if (fs.existsSync(devDir)) {
65
+ console.log(`[1/3] 正在删除旧目录: ${devDir}`);
66
+ fs.rmSync(devDir, { recursive: true, force: true });
67
+ }
63
68
 
64
- // 步骤 2: 'dev' 目录复制为 'dist'
65
- console.log(`[2/3] 正在复制 "${devDir}" 到 "${distDir}"...`);
66
- copyDirRecursive(devDir, distDir);
67
- console.log('...目录复制完成。');
69
+ // 步骤 2: 运行 TypeScript 编译
70
+ console.log(`[2/3] 正在编译 TypeScript...`);
71
+ execSync('npx tsc', { stdio: 'inherit' });
72
+ console.log('...TypeScript 编译完成。');
68
73
 
69
74
  // 步骤 3: 更新 package.json 中的版本号
70
75
  console.log(`[3/3] 正在更新 ${packageJsonPath} 中的版本号...`);
package/package.json CHANGED
@@ -1,19 +1,16 @@
1
1
  {
2
2
  "name": "@ghini/xstart",
3
- "version": "25.11.28033518",
3
+ "version": "25.12.10043118",
4
4
  "scripts": {
5
+ "type-check": "tsc --noEmit",
5
6
  "build": "node ./build.js",
6
7
  "pub": "npm run build && npm publish && git add . && git commit -m 'update' && git push",
7
8
  "update": "npm cache clean --force&&npm update"
8
9
  },
9
10
  "exports": {
10
11
  ".": {
11
- "import": "./dist/main.js",
12
- "types": "./dist/main.d.ts"
13
- },
14
- "./dev": {
15
- "import": "./dev/main.js",
16
- "types": "./dev/main.d.ts"
12
+ "import": "./dist/index.js",
13
+ "types": "./dist/index.d.ts"
17
14
  }
18
15
  },
19
16
  "type": "module",
@@ -21,5 +18,9 @@
21
18
  "license": "MIT",
22
19
  "publishConfig": {
23
20
  "access": "public"
21
+ },
22
+ "devDependencies": {
23
+ "@types/node": "^24.10.2",
24
+ "typescript": "^5.9.3"
24
25
  }
25
26
  }
package/src/index.ts ADDED
@@ -0,0 +1,2 @@
1
+ // src/index.ts
2
+ export * from "./start.js";
package/src/start.ts ADDED
@@ -0,0 +1,6 @@
1
+ // start.ts
2
+ export { start };
3
+
4
+ function start(): void {
5
+ console.log("Hello Ghini use ts");
6
+ }
package/test/0.js CHANGED
@@ -1,3 +1,3 @@
1
- import { start } from "@ghini/xstart/dev";
1
+ import { start } from "@ghini/xstart";
2
2
 
3
3
  start();
package/tsconfig.json ADDED
@@ -0,0 +1,24 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2022",
4
+ "module": "ESNext",
5
+ "moduleResolution": "bundler",
6
+ "verbatimModuleSyntax": true,
7
+ "lib": ["ES2022"],
8
+ "types": ["node"],
9
+ "declaration": true,
10
+ "declarationMap": true,
11
+ "sourceMap": true,
12
+ "outDir": "./dist",
13
+ "rootDir": "./src",
14
+ "strict": true,
15
+ "esModuleInterop": true,
16
+ "skipLibCheck": true,
17
+ "forceConsistentCasingInFileNames": true,
18
+ "resolveJsonModule": true,
19
+ "isolatedModules": true,
20
+ "allowSyntheticDefaultImports": true
21
+ },
22
+ "include": ["src/**/*"],
23
+ "exclude": ["node_modules", "dist", "dev"]
24
+ }
package/dev/lib/index.js DELETED
@@ -1 +0,0 @@
1
- export * from "./start.js";
package/dev/lib/start.js DELETED
@@ -1,3 +0,0 @@
1
- export function start(){
2
- console.log('Hello Ghini')
3
- }
package/dev/main.d.ts DELETED
@@ -1,3 +0,0 @@
1
- // dist/main.d.ts
2
- declare const main: any;
3
- export default main;
package/dev/main.js DELETED
@@ -1,5 +0,0 @@
1
- import * as index from "./lib/index.js";
2
- export default {
3
- ...index,
4
- }
5
- export * from "./lib/index.js";
package/dist/lib/index.js DELETED
@@ -1 +0,0 @@
1
- export * from "./start.js";
package/dist/lib/start.js DELETED
@@ -1,3 +0,0 @@
1
- export function start(){
2
- console.log('Hello Ghini')
3
- }
package/dist/main.d.ts DELETED
@@ -1,3 +0,0 @@
1
- // dist/main.d.ts
2
- declare const main: any;
3
- export default main;
package/dist/main.js DELETED
@@ -1,5 +0,0 @@
1
- import * as index from "./lib/index.js";
2
- export default {
3
- ...index,
4
- }
5
- export * from "./lib/index.js";