@hlw-uni/mp-cli 1.0.37 → 1.0.39

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hlw-uni/mp-cli",
3
- "version": "1.0.37",
3
+ "version": "1.0.39",
4
4
  "description": "uniapp 小程序脚手架生成器",
5
5
  "main": "bin/cli.js",
6
6
  "bin": {
@@ -10,7 +10,8 @@
10
10
  "dev": "tsx bin/cli.ts",
11
11
  "create": "tsx bin/cli.ts create",
12
12
  "build": "esbuild bin/cli.ts --bundle --platform=node --outfile=bin/cli.js --format=cjs --external:fs-extra --external:inquirer --external:chalk --external:commander --external:ora --external:path --external:fs",
13
- "prepublish": "pnpm build",
13
+ "sync-versions": "node scripts/sync-template-versions.js",
14
+ "prepublish": "node scripts/sync-template-versions.js && pnpm build",
14
15
  "postbuild": "node scripts/fix-templates-path.js"
15
16
  },
16
17
  "keywords": [
@@ -0,0 +1,60 @@
1
+ // prepublish 脚本:同步本地各包版本到模板 package.json
2
+ // 读取 monorepo 中各包的 package.json version,
3
+ // 自动更新 templates/{platform}/base/package.json 里的依赖版本。
4
+ const path = require('path');
5
+ const fs = require('fs');
6
+
7
+ const ROOT = path.join(__dirname, '..', '..');
8
+
9
+ /** 需要同步的本地包 */
10
+ const LOCAL_PACKAGES = [
11
+ '@hlw-uni/mp-core',
12
+ '@hlw-uni/mp-vue',
13
+ '@hlw-uni/mp-vite-plugin',
14
+ ];
15
+
16
+ /** 读取本地包的当前版本 */
17
+ function getLocalVersion(pkgName) {
18
+ const dir = pkgName.replace('@hlw-uni/', '');
19
+ const file = path.join(ROOT, dir, 'package.json');
20
+ const pkg = JSON.parse(fs.readFileSync(file, 'utf8'));
21
+ return pkg.version;
22
+ }
23
+
24
+ /** 更新单个模板的 package.json */
25
+ function syncTemplate(templatePkgPath) {
26
+ const pkg = JSON.parse(fs.readFileSync(templatePkgPath, 'utf8'));
27
+ let changed = false;
28
+
29
+ for (const name of LOCAL_PACKAGES) {
30
+ const version = `^${getLocalVersion(name)}`;
31
+ if (pkg.dependencies?.[name] && pkg.dependencies[name] !== version) {
32
+ console.log(` ${name}: ${pkg.dependencies[name]} → ${version}`);
33
+ pkg.dependencies[name] = version;
34
+ changed = true;
35
+ }
36
+ if (pkg.devDependencies?.[name] && pkg.devDependencies[name] !== version) {
37
+ console.log(` ${name}: ${pkg.devDependencies[name]} → ${version}`);
38
+ pkg.devDependencies[name] = version;
39
+ changed = true;
40
+ }
41
+ }
42
+
43
+ if (changed) {
44
+ fs.writeFileSync(templatePkgPath, JSON.stringify(pkg, null, 2) + '\n');
45
+ console.log(`✓ Updated ${path.relative(ROOT, templatePkgPath)}`);
46
+ } else {
47
+ console.log(`✓ Already up to date: ${path.relative(ROOT, templatePkgPath)}`);
48
+ }
49
+ }
50
+
51
+ const templatesDir = path.join(__dirname, '..', 'templates');
52
+ const templates = fs.readdirSync(templatesDir);
53
+
54
+ console.log('Syncing template versions...');
55
+ for (const tpl of templates) {
56
+ const pkgFile = path.join(templatesDir, tpl, 'base', 'package.json');
57
+ if (fs.existsSync(pkgFile)) {
58
+ syncTemplate(pkgFile);
59
+ }
60
+ }
@@ -11,8 +11,8 @@
11
11
  "@dcloudio/uni-app-plus": "3.0.0-4080420251103001",
12
12
  "@dcloudio/uni-components": "3.0.0-4080420251103001",
13
13
  "@dcloudio/uni-mp-toutiao": "3.0.0-4080420251103001",
14
- "@hlw-uni/mp-core": "^1.0.12",
15
- "@hlw-uni/mp-vue": "^1.0.3",
14
+ "@hlw-uni/mp-core": "^1.0.13",
15
+ "@hlw-uni/mp-vue": "^1.0.4",
16
16
  "@vueuse/core": "^10.9.0",
17
17
  "pinia": "^2.1.7",
18
18
  "pinia-plugin-unistorage": "^0.1.2",
@@ -12,8 +12,8 @@
12
12
  "@dcloudio/uni-app-plus": "3.0.0-4080420251103001",
13
13
  "@dcloudio/uni-components": "3.0.0-4080420251103001",
14
14
  "@dcloudio/uni-mp-weixin": "3.0.0-4080420251103001",
15
- "@hlw-uni/mp-core": "^1.0.12",
16
- "@hlw-uni/mp-vue": "^1.0.3",
15
+ "@hlw-uni/mp-core": "^1.0.13",
16
+ "@hlw-uni/mp-vue": "^1.0.4",
17
17
  "@vueuse/core": "^10.9.0",
18
18
  "pinia": "^2.1.7",
19
19
  "pinia-plugin-unistorage": "^0.1.2",
@@ -23,7 +23,7 @@
23
23
  "@dcloudio/types": "^3.4.8",
24
24
  "@dcloudio/uni-cli-shared": "3.0.0-4080420251103001",
25
25
  "@dcloudio/vite-plugin-uni": "3.0.0-4080420251103001",
26
- "@hlw-uni/mp-vite-plugin": "^1.0.10",
26
+ "@hlw-uni/mp-vite-plugin": "^1.0.11",
27
27
  "@unocss/transformer-directives": "^65.4.3",
28
28
  "sass": "^1.70.0",
29
29
  "typescript": "^4.9.4",