@flun/node-mobile-app 4.0.1 → 4.0.2

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,4 +1,10 @@
1
1
  # 变更日志
2
+ ## [4.0.2] - 2026-10-20 15:56
3
+
4
+ ### 修复
5
+ - **CLI 或插件版本变化时跳过依赖重装,产物沿用旧优化规则**:`[3/11]` 检测到 CLI 版本、插件版本、ABI、libnode、模板文件变化时,原逻辑只清 Gradle 构建目录与插件 CMake 缓存,不清 `nodejs-assets` 与 `.deps-snapshot.json`;`[5/11]` 读到的仍是旧快照,判定"依赖与环境未变化",跳过安装与优化;结果是新版本代码配旧规则产物,原生模块的编译源文件、中间产物、异平台 prebuilds 可能残留;现拆分为 `clearGradleCaches` 与 `clearDepsCaches`,前者清 Gradle 与插件构建目录,后者清 `nodejs-assets` 与依赖快照;版本类变化同时清两者,触发重装、重编、重优化;
6
+ - **`[3/11]` 提示与实际清理范围不符**:原提示"清理全部缓存"实际只清 Gradle 构建目录;`depsChanged` / `appInfoChanged` 分支提示"清理 nodejs-assets 缓存 + app/build",但 `nodejs-assets` 从未被清理;现提示按实际清理目标拼接--版本类变化为"清理 Gradle 缓存、CMake 缓存与依赖缓存",依赖变化为"清理依赖缓存、Gradle 缓存",仅应用信息变化为"清理 Gradle 缓存";
7
+
2
8
  ## [4.0.1] - 2026-10-20 14:48
3
9
 
4
10
  ### 紧急修复
@@ -43,4 +49,4 @@
43
49
  - **修复原生模块编译时 `node-addon-api` 的 gyp / 头文件被误删**:`pruneDevFiles` 原保护条件为 `COMPILE_EXTS && inNativePkg`,而 `node-addon-api` 自身没有 `binding.gyp`,不在原生模块包列表内,其 `node_addon_api.gyp` 与头文件被当作开发文件删除,导致依赖它的原生模块(如 `bcrypt`)在 Gradle `npm rebuild` 时报 `../node-addon-api/node_addon_api.gyp not found`,构建中断;现新增 `isSkippedPkg`,保护条件改为 `COMPILE_EXTS && (inNativePkg || isSkippedPkg)`,仅保留 `SKIP_PKGS` 包内的编译文件(`.gyp`/`.gypi`/`.h`/`.c` 等),`.md`/`.map`/`.ts` 等仍照常清理,不扩大保留范围;
44
50
 
45
51
  ### 变更
46
- - **阶段 4 不再清理 `.d.ts`**:`.d.ts` 已由阶段 6 的 `TS_RE`(`/\.(ts|cts|mts)$/`)覆盖,阶段 4 重复清理属冗余;移除后 `.d.ts` 统一由阶段 6 处理,清理职责不重叠;
52
+ - **阶段 4 不再清理 `.d.ts`**:`.d.ts` 已由阶段 6 的 `TS_RE`(`/\.(ts|cts|mts)$/`)覆盖,阶段 4 重复清理属冗余;移除后 `.d.ts` 统一由阶段 6 处理,清理职责不重叠;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flun/node-mobile-app",
3
- "version": "4.0.1",
3
+ "version": "4.0.2",
4
4
  "description": "将 Node.js 项目一键打包为 Android / iOS 移动应用,运行时由 @flun/nodejs-mobile-react-native 提供,无需修改你的 Node 代码;",
5
5
  "author": "flun <open@flun.top>",
6
6
  "keywords": [
@@ -17,11 +17,15 @@ const FINGERPRINT_FILE = '.build-fingerprint.json',
17
17
  return h.digest('hex');
18
18
  },
19
19
  writeFp = (file, fp) => fs.writeFileSync(file, JSON.stringify(fp, null, 2), 'utf-8'),
20
- clearCommonCaches = (buildDir, userProjectDir) => {
20
+ clearGradleCaches = (buildDir, userProjectDir) => {
21
21
  removeDir(path.join(buildDir, 'android', 'build'));
22
22
  removeDir(path.join(buildDir, 'android', 'app', 'build'));
23
23
  removeDir(path.join(userProjectDir, 'node_modules', '@flun', 'nodejs-mobile-react-native', 'android', 'build'));
24
24
  },
25
+ clearDepsCaches = buildDir => {
26
+ removeDir(path.join(buildDir, 'nodejs-assets'));
27
+ removeDir(path.join(buildDir, '.deps-snapshot.json'));
28
+ },
25
29
  hashTemplate = templateDir => {
26
30
  const h = crypto.createHash('sha256'),
27
31
  walk = d => {
@@ -104,16 +108,18 @@ const FINGERPRINT_FILE = '.build-fingerprint.json',
104
108
  if (templateChanged) reasons.push('模板文件');
105
109
  if (depsChanged) reasons.push('用户依赖');
106
110
  if (appInfoChanged) reasons.push('应用信息');
107
- console.log(chalk.yellow(' ⚠️ 检测到变化(' + reasons.join('、') + '),清理全部缓存'));
108
- clearCommonCaches(buildDir, userProjectDir);
111
+ console.log(chalk.yellow(' ⚠️ 检测到变化(' + reasons.join('、') + '),清理 Gradle 缓存、CMake 缓存与依赖缓存'));
112
+ clearGradleCaches(buildDir, userProjectDir);
109
113
  removeDir(path.join(userProjectDir, 'node_modules', '@flun', 'nodejs-mobile-react-native', 'android', '.cxx'));
114
+ clearDepsCaches(buildDir);
110
115
  }
111
116
  else if (depsChanged || appInfoChanged) {
112
- const reasons = [];
113
- if (depsChanged) reasons.push('用户依赖');
114
- if (appInfoChanged) reasons.push('应用信息');
115
- console.log(chalk.yellow(' ⚠️ 检测到变化(' + reasons.join('、') + '),清理 nodejs-assets 缓存 + app/build'));
116
- clearCommonCaches(buildDir, userProjectDir);
117
+ const reasons = [], targets = [];
118
+ if (depsChanged) reasons.push('用户依赖'), targets.push('依赖缓存', 'Gradle 缓存');
119
+ if (appInfoChanged) reasons.push('应用信息'), targets.push('Gradle 缓存');
120
+ console.log(chalk.yellow(' ⚠️ 检测到变化(' + reasons.join('、') + '),清理 ' + targets.join('、')));
121
+ clearGradleCaches(buildDir, userProjectDir);
122
+ if (depsChanged) clearDepsCaches(buildDir);
117
123
  }
118
124
  else console.log(chalk.gray(' ✓ 缓存有效,跳过清理'));
119
125