pubflight 0.0.0-stage → 0.1.0
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/CONTRIBUTING.md +19 -0
- package/LICENSE +21 -0
- package/README.md +44 -2
- package/action.yml +24 -0
- package/dist/audit.d.ts +6 -0
- package/dist/audit.js +333 -0
- package/dist/audit.js.map +1 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +121 -0
- package/dist/cli.js.map +1 -0
- package/dist/formatters.d.ts +5 -0
- package/dist/formatters.js +99 -0
- package/dist/formatters.js.map +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -0
- package/dist/logs.d.ts +6 -0
- package/dist/logs.js +97 -0
- package/dist/logs.js.map +1 -0
- package/dist/types.d.ts +55 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/dist/zip.d.ts +7 -0
- package/dist/zip.js +138 -0
- package/dist/zip.js.map +1 -0
- package/package.json +56 -4
- package/skills/pubflight/SKILL.md +25 -0
package/CONTRIBUTING.md
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# Contributing to pubflight
|
|
2
|
+
|
|
3
|
+
Contributions expanding Android/iOS store compliance checks, build-log failure rules, and bundle analyzers are welcome!
|
|
4
|
+
|
|
5
|
+
## Local Setup
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
bun install
|
|
9
|
+
bun run typecheck
|
|
10
|
+
bun run build
|
|
11
|
+
bun test
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
## Good First Issues
|
|
15
|
+
|
|
16
|
+
- Add iOS `PrivacyInfo.xcprivacy` required-reason API audit rules in `src/audit.ts`
|
|
17
|
+
- Add React Native (`app.json` / `eas.json`) configuration checks
|
|
18
|
+
- Add additional AGP / Xcode / CocoaPods matcher hints in `src/logs.ts`
|
|
19
|
+
- Add SARIF output formatter alongside `text`, `json`, and `markdown`
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Vidit Jain
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,45 @@
|
|
|
1
|
-
#
|
|
1
|
+
# pubflight
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Zero-SDK **mobile & Flutter release pre-flight auditor, APK/AAB/IPA size inspector, and Gradle/Xcode build-log compressor** (`CLI + SDK + GitHub Action + Agent Skill`).
|
|
4
|
+
|
|
5
|
+
Runs on any Linux, macOS, or Windows CI runner in milliseconds—no Android Studio, Xcode, or Flutter SDK required.
|
|
6
|
+
|
|
7
|
+
## Why?
|
|
8
|
+
|
|
9
|
+
Mobile releases fail late because store-policy bugs, signing leaks, fat multi-ABI binaries, and 3,000-line Gradle build logs are caught manually after 20-minute CI builds:
|
|
10
|
+
- **`pubflight audit .`** catches `android:debuggable="true"`, cleartext HTTP, exported components without permissions, stale Play `targetSdk`, disabled iOS ATS, **missing `NSCameraUsageDescription` / `NSPhotoLibraryUsageDescription` keys** required by your plugins, unpinned `pubspec.yaml` dependencies, and committed `.jks`/`.p8`/`key.properties` signing secrets.
|
|
11
|
+
- **`pubflight inspect <app.apk|app.aab|app.ipa>`** parses ZIP Central Directories directly in Node (no `unzip` or `aapt` needed) to break down native `.so`, `libflutter.so`, `.dex`, and oversized media assets—flagging fat multi-ABI APKs immediately.
|
|
12
|
+
- **`pubflight logs <build.log | ->`** compresses repetitive Gradle/Xcode/CocoaPods progress chatter by **80–95%** into structured JSON error root causes and fix hints—saving coding-agent context windows.
|
|
13
|
+
|
|
14
|
+
## Quick Start
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
npx pubflight audit .
|
|
18
|
+
npx pubflight inspect build/app/outputs/bundle/release/app-release.aab --top 15
|
|
19
|
+
flutter build apk 2>&1 | npx pubflight logs - --format json
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## Implemented Pre-Flight Rules
|
|
23
|
+
|
|
24
|
+
| Rule ID | Severity | Check |
|
|
25
|
+
| :--- | :---: | :--- |
|
|
26
|
+
| `PF-AND-001` | `critical` | `android:debuggable="true"` in main `AndroidManifest.xml` |
|
|
27
|
+
| `PF-AND-002` | `high` | `android:usesCleartextTraffic="true"` allowing unencrypted HTTP |
|
|
28
|
+
| `PF-AND-003` | `medium` | `android:allowBackup="true"` exposing ADB backups |
|
|
29
|
+
| `PF-AND-004` | `high` | Exported Android component missing `android:permission` |
|
|
30
|
+
| `PF-AND-005` | `high` | `targetSdk` below Google Play floor (`< 34`) |
|
|
31
|
+
| `PF-IOS-001` | `high` | Global iOS ATS disabled (`NSAllowsArbitraryLoads=true`) |
|
|
32
|
+
| `PF-IOS-002` | `info` | Missing `ITSAppUsesNonExemptEncryption` declaration |
|
|
33
|
+
| `PF-IOS-003` | `critical` | Missing iOS privacy usage key required by camera/photo/location/mic dependency |
|
|
34
|
+
| `PF-FLT-001` | `medium` | Unpinned `any` constraint in `pubspec.yaml` |
|
|
35
|
+
| `PF-FLT-002` | `high` | Git dependency missing commit/tag `ref:` in `pubspec.yaml` |
|
|
36
|
+
| `PF-SEC-001` | `critical` | Committed `.jks`, `.keystore`, `.p12`, or `AuthKey_*.p8` signing credentials |
|
|
37
|
+
| `PF-SEC-002` | `critical` | Committed release passwords inside `key.properties` |
|
|
38
|
+
|
|
39
|
+
## Contributing
|
|
40
|
+
|
|
41
|
+
See [CONTRIBUTING.md](./CONTRIBUTING.md) for setup and `good first issue` ideas.
|
|
42
|
+
|
|
43
|
+
## License
|
|
44
|
+
|
|
45
|
+
[MIT](./LICENSE)
|
package/action.yml
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
name: 'pubflight'
|
|
2
|
+
description: 'Zero-SDK Flutter, Android & iOS release pre-flight audit and build-log compression'
|
|
3
|
+
inputs:
|
|
4
|
+
path:
|
|
5
|
+
description: 'Project directory to audit'
|
|
6
|
+
required: false
|
|
7
|
+
default: '.'
|
|
8
|
+
fail-on:
|
|
9
|
+
description: 'Minimum severity threshold to fail CI (critical, high, medium, none)'
|
|
10
|
+
required: false
|
|
11
|
+
default: 'high'
|
|
12
|
+
format:
|
|
13
|
+
description: 'Report output format (text, json, markdown)'
|
|
14
|
+
required: false
|
|
15
|
+
default: 'text'
|
|
16
|
+
runs:
|
|
17
|
+
using: 'composite'
|
|
18
|
+
steps:
|
|
19
|
+
- name: Run pubflight audit
|
|
20
|
+
shell: bash
|
|
21
|
+
run: |
|
|
22
|
+
npx --yes pubflight@latest audit "${{ inputs.path }}" \
|
|
23
|
+
--fail-on "${{ inputs.fail-on }}" \
|
|
24
|
+
--format "${{ inputs.format }}"
|
package/dist/audit.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { ProjectAuditReport } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Performs an offline, zero-SDK mobile & Flutter pre-flight audit covering AndroidManifest,
|
|
4
|
+
* Gradle SDK floors, Info.plist ATS/App Store privacy keys, pubspec reproducibility, and signing files.
|
|
5
|
+
*/
|
|
6
|
+
export declare function auditMobileProject(targetDir: string): ProjectAuditReport;
|
package/dist/audit.js
ADDED
|
@@ -0,0 +1,333 @@
|
|
|
1
|
+
import { existsSync, readdirSync, readFileSync, statSync } from 'node:fs';
|
|
2
|
+
import { extname, join, relative } from 'node:path';
|
|
3
|
+
const SKIP_DIRS = new Set([
|
|
4
|
+
'node_modules',
|
|
5
|
+
'.git',
|
|
6
|
+
'.dart_tool',
|
|
7
|
+
'build',
|
|
8
|
+
'dist',
|
|
9
|
+
'Pods',
|
|
10
|
+
'DerivedData',
|
|
11
|
+
'.gradle',
|
|
12
|
+
'.symlinks',
|
|
13
|
+
]);
|
|
14
|
+
const IOS_PRIVACY_DEPS = [
|
|
15
|
+
{
|
|
16
|
+
depRegex: /\b(camera|image_picker|mobile_scanner|qr_code_scanner|react-native-camera|expo-camera)\b/i,
|
|
17
|
+
plistKey: 'NSCameraUsageDescription',
|
|
18
|
+
capability: 'Camera access',
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
depRegex: /\b(image_picker|photo_manager|wechat_assets_picker|expo-image-picker)\b/i,
|
|
22
|
+
plistKey: 'NSPhotoLibraryUsageDescription',
|
|
23
|
+
capability: 'Photo library access',
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
depRegex: /\b(geolocator|location|flutter_background_geolocation|expo-location)\b/i,
|
|
27
|
+
plistKey: 'NSLocationWhenInUseUsageDescription',
|
|
28
|
+
capability: 'Location access',
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
depRegex: /\b(record|flutter_sound|speech_to_text|audio_waveforms)\b/i,
|
|
32
|
+
plistKey: 'NSMicrophoneUsageDescription',
|
|
33
|
+
capability: 'Microphone access',
|
|
34
|
+
},
|
|
35
|
+
];
|
|
36
|
+
function walkFiles(root) {
|
|
37
|
+
const results = [];
|
|
38
|
+
const stack = [root];
|
|
39
|
+
while (stack.length > 0) {
|
|
40
|
+
const dir = stack.pop();
|
|
41
|
+
if (!dir)
|
|
42
|
+
continue;
|
|
43
|
+
let entries;
|
|
44
|
+
try {
|
|
45
|
+
entries = readdirSync(dir, { withFileTypes: true });
|
|
46
|
+
}
|
|
47
|
+
catch {
|
|
48
|
+
continue;
|
|
49
|
+
}
|
|
50
|
+
for (const entry of entries) {
|
|
51
|
+
if (SKIP_DIRS.has(entry.name))
|
|
52
|
+
continue;
|
|
53
|
+
const fullPath = join(dir, entry.name);
|
|
54
|
+
if (entry.isDirectory()) {
|
|
55
|
+
stack.push(fullPath);
|
|
56
|
+
}
|
|
57
|
+
else if (entry.isFile()) {
|
|
58
|
+
results.push(fullPath);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
return results;
|
|
63
|
+
}
|
|
64
|
+
function lineNumberOf(content, index) {
|
|
65
|
+
let line = 1;
|
|
66
|
+
for (let i = 0; i < index && i < content.length; i += 1) {
|
|
67
|
+
if (content.charCodeAt(i) === 10)
|
|
68
|
+
line += 1;
|
|
69
|
+
}
|
|
70
|
+
return line;
|
|
71
|
+
}
|
|
72
|
+
function pushFinding(list, finding, line) {
|
|
73
|
+
const item = { ...finding };
|
|
74
|
+
if (line !== undefined) {
|
|
75
|
+
item.line = line;
|
|
76
|
+
}
|
|
77
|
+
list.push(item);
|
|
78
|
+
}
|
|
79
|
+
function auditAndroidManifest(relPath, content, findings) {
|
|
80
|
+
const debuggable = /android:debuggable\s*=\s*["']true["']/i.exec(content);
|
|
81
|
+
if (debuggable) {
|
|
82
|
+
pushFinding(findings, {
|
|
83
|
+
ruleId: 'PF-AND-001',
|
|
84
|
+
severity: 'critical',
|
|
85
|
+
file: relPath,
|
|
86
|
+
title: 'AndroidManifest hardcodes android:debuggable="true"',
|
|
87
|
+
detail: 'Play Store rejects debuggable APKs/AABs and attackers can attach JDWP debuggers.',
|
|
88
|
+
fix: 'Remove android:debuggable="true" so Gradle manages debuggable per buildType.',
|
|
89
|
+
}, lineNumberOf(content, debuggable.index));
|
|
90
|
+
}
|
|
91
|
+
const cleartext = /android:usesCleartextTraffic\s*=\s*["']true["']/i.exec(content);
|
|
92
|
+
if (cleartext) {
|
|
93
|
+
pushFinding(findings, {
|
|
94
|
+
ruleId: 'PF-AND-002',
|
|
95
|
+
severity: 'high',
|
|
96
|
+
file: relPath,
|
|
97
|
+
title: 'AndroidManifest permits unencrypted HTTP traffic (usesCleartextTraffic="true")',
|
|
98
|
+
detail: 'Cleartext HTTP leaks tokens/traffic and fails security compliance reviews.',
|
|
99
|
+
fix: 'Set android:usesCleartextTraffic="false" and whitelist localhost only in debug network_security_config.',
|
|
100
|
+
}, lineNumberOf(content, cleartext.index));
|
|
101
|
+
}
|
|
102
|
+
const backup = /android:allowBackup\s*=\s*["']true["']/i.exec(content);
|
|
103
|
+
if (backup) {
|
|
104
|
+
pushFinding(findings, {
|
|
105
|
+
ruleId: 'PF-AND-003',
|
|
106
|
+
severity: 'medium',
|
|
107
|
+
file: relPath,
|
|
108
|
+
title: 'android:allowBackup="true" exposes app shared data via ADB backup',
|
|
109
|
+
detail: 'Unless configured via dataExtractionRules, local tokens and SQLite state can be backed up.',
|
|
110
|
+
fix: 'Set android:allowBackup="false" or configure explicit Android 12+ dataExtractionRules.',
|
|
111
|
+
}, lineNumberOf(content, backup.index));
|
|
112
|
+
}
|
|
113
|
+
const tagRegex = /<(activity|service|receiver|provider)\b([^>]*)>([\s\S]*?)<\/\1>|<(activity|service|receiver|provider)\b([^>]*)\/>/gi;
|
|
114
|
+
for (const match of content.matchAll(tagRegex)) {
|
|
115
|
+
const tag = (match[1] ?? match[4] ?? '').toLowerCase();
|
|
116
|
+
const attrs = match[2] ?? match[5] ?? '';
|
|
117
|
+
const inner = match[3] ?? '';
|
|
118
|
+
const isExported = /android:exported\s*=\s*["']true["']/i.test(attrs);
|
|
119
|
+
const hasPerm = /android:permission\s*=\s*["'][^"']+["']/i.test(attrs);
|
|
120
|
+
const isMainLauncher = tag === 'activity' &&
|
|
121
|
+
inner.includes('android.intent.action.MAIN') &&
|
|
122
|
+
inner.includes('android.intent.category.LAUNCHER');
|
|
123
|
+
if (isExported && !hasPerm && !isMainLauncher) {
|
|
124
|
+
pushFinding(findings, {
|
|
125
|
+
ruleId: 'PF-AND-004',
|
|
126
|
+
severity: 'high',
|
|
127
|
+
file: relPath,
|
|
128
|
+
title: `Exported <${tag}> without android:permission protection`,
|
|
129
|
+
detail: 'Any installed app on the device can invoke or bind to this exported Android component.',
|
|
130
|
+
fix: 'Set android:exported="false" or guard the component with a signature-level android:permission.',
|
|
131
|
+
}, lineNumberOf(content, match.index ?? 0));
|
|
132
|
+
break;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
function auditGradleFile(relPath, content, findings) {
|
|
137
|
+
const targetMatch = /\btargetSdk(?:Version)?\s*(?:=|\s)\s*(\d+)/i.exec(content);
|
|
138
|
+
if (targetMatch?.[1]) {
|
|
139
|
+
const targetSdk = Number(targetMatch[1]);
|
|
140
|
+
if (Number.isFinite(targetSdk) && targetSdk > 0 && targetSdk < 34) {
|
|
141
|
+
pushFinding(findings, {
|
|
142
|
+
ruleId: 'PF-AND-005',
|
|
143
|
+
severity: 'high',
|
|
144
|
+
file: relPath,
|
|
145
|
+
title: `Android targetSdk (${targetSdk}) is below Google Play minimum (34/35)`,
|
|
146
|
+
detail: 'Google Play blocks new submissions and updates targeting API level < 34.',
|
|
147
|
+
fix: 'Update compileSdk and targetSdk to 34 or 35 and verify runtime permission changes.',
|
|
148
|
+
}, lineNumberOf(content, targetMatch.index));
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
function auditInfoPlist(relPath, content, dependencyManifestText, findings) {
|
|
153
|
+
const atsMatch = /<key>\s*NSAllowsArbitraryLoads\s*<\/key>\s*<true\s*\/>/i.exec(content);
|
|
154
|
+
if (atsMatch) {
|
|
155
|
+
pushFinding(findings, {
|
|
156
|
+
ruleId: 'PF-IOS-001',
|
|
157
|
+
severity: 'high',
|
|
158
|
+
file: relPath,
|
|
159
|
+
title: 'iOS ATS disabled globally via NSAllowsArbitraryLoads=true',
|
|
160
|
+
detail: 'App Store review routinely rejects apps disabling App Transport Security without justification.',
|
|
161
|
+
fix: 'Remove NSAllowsArbitraryLoads or scope NSExceptionDomains to specific legacy hosts only.',
|
|
162
|
+
}, lineNumberOf(content, atsMatch.index));
|
|
163
|
+
}
|
|
164
|
+
if (!/<key>\s*ITSAppUsesNonExemptEncryption\s*<\/key>/i.test(content)) {
|
|
165
|
+
pushFinding(findings, {
|
|
166
|
+
ruleId: 'PF-IOS-002',
|
|
167
|
+
severity: 'info',
|
|
168
|
+
file: relPath,
|
|
169
|
+
title: 'Missing ITSAppUsesNonExemptEncryption key in Info.plist',
|
|
170
|
+
detail: 'TestFlight & App Store Connect stall distribution on manual export compliance prompts without this boolean.',
|
|
171
|
+
fix: 'Add <key>ITSAppUsesNonExemptEncryption</key><false/> (if using standard HTTPS only).',
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
if (dependencyManifestText) {
|
|
175
|
+
for (const rule of IOS_PRIVACY_DEPS) {
|
|
176
|
+
if (rule.depRegex.test(dependencyManifestText) && !content.includes(rule.plistKey)) {
|
|
177
|
+
pushFinding(findings, {
|
|
178
|
+
ruleId: 'PF-IOS-003',
|
|
179
|
+
severity: 'critical',
|
|
180
|
+
file: relPath,
|
|
181
|
+
title: `Missing ${rule.plistKey} required for ${rule.capability}`,
|
|
182
|
+
detail: `Project dependencies reference ${rule.capability}, which causes immediate App Store Connect binary rejection or runtime crash without ${rule.plistKey}.`,
|
|
183
|
+
fix: `Add <key>${rule.plistKey}</key><string>Explain clearly why your app needs ${rule.capability.toLowerCase()}.</string> to Info.plist.`,
|
|
184
|
+
});
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
function auditPubspec(relPath, content, findings) {
|
|
190
|
+
const nonCommentContent = content
|
|
191
|
+
.split(/\r?\n/)
|
|
192
|
+
.map((line) => (line.trimStart().startsWith('#') ? '' : line))
|
|
193
|
+
.join('\n');
|
|
194
|
+
const anyMatch = /^(\s+[a-z0-9_-]+:\s*any)\s*(?:#.*)?$/im.exec(nonCommentContent);
|
|
195
|
+
if (anyMatch) {
|
|
196
|
+
pushFinding(findings, {
|
|
197
|
+
ruleId: 'PF-FLT-001',
|
|
198
|
+
severity: 'medium',
|
|
199
|
+
file: relPath,
|
|
200
|
+
title: 'Unpinned Dart dependency using "any" version constraint',
|
|
201
|
+
detail: 'Unconstrained dependencies break reproducible CI and release builds across machines.',
|
|
202
|
+
fix: 'Pin dependencies to explicit caret constraints (e.g. ^1.2.0).',
|
|
203
|
+
}, lineNumberOf(content, anyMatch.index));
|
|
204
|
+
}
|
|
205
|
+
for (const gitMatch of nonCommentContent.matchAll(/^(\s*)git\s*:\s*(.*)$/gim)) {
|
|
206
|
+
const indent = gitMatch[1]?.length ?? 0;
|
|
207
|
+
const inlineValue = (gitMatch[2] ?? '').trim();
|
|
208
|
+
const matchIndex = gitMatch.index ?? 0;
|
|
209
|
+
if (inlineValue.length > 0) {
|
|
210
|
+
pushFinding(findings, {
|
|
211
|
+
ruleId: 'PF-FLT-002',
|
|
212
|
+
severity: 'high',
|
|
213
|
+
file: relPath,
|
|
214
|
+
title: 'Git dependency in pubspec.yaml has no pinned ref/commit',
|
|
215
|
+
detail: 'Unpinned git dependencies silently change build artifacts whenever upstream pushes to main.',
|
|
216
|
+
fix: 'Pin a commit SHA or tag with `ref:` under the git dependency block.',
|
|
217
|
+
}, lineNumberOf(content, matchIndex));
|
|
218
|
+
break;
|
|
219
|
+
}
|
|
220
|
+
const tail = nonCommentContent.slice(matchIndex + gitMatch[0].length);
|
|
221
|
+
const blockLines = [];
|
|
222
|
+
for (const line of tail.split(/\r?\n/).slice(1)) {
|
|
223
|
+
if (line.trim() === '')
|
|
224
|
+
continue;
|
|
225
|
+
const lineIndent = /^(\s*)/.exec(line)?.[1]?.length ?? 0;
|
|
226
|
+
if (lineIndent <= indent)
|
|
227
|
+
break;
|
|
228
|
+
blockLines.push(line);
|
|
229
|
+
}
|
|
230
|
+
if (!/\bref\s*:/i.test(blockLines.join('\n'))) {
|
|
231
|
+
pushFinding(findings, {
|
|
232
|
+
ruleId: 'PF-FLT-002',
|
|
233
|
+
severity: 'high',
|
|
234
|
+
file: relPath,
|
|
235
|
+
title: 'Git dependency in pubspec.yaml has no pinned ref/commit',
|
|
236
|
+
detail: 'Unpinned git dependencies silently change build artifacts whenever upstream pushes to main.',
|
|
237
|
+
fix: 'Pin a commit SHA or tag with `ref:` under the git dependency block.',
|
|
238
|
+
}, lineNumberOf(content, matchIndex));
|
|
239
|
+
break;
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
/**
|
|
244
|
+
* Performs an offline, zero-SDK mobile & Flutter pre-flight audit covering AndroidManifest,
|
|
245
|
+
* Gradle SDK floors, Info.plist ATS/App Store privacy keys, pubspec reproducibility, and signing files.
|
|
246
|
+
*/
|
|
247
|
+
export function auditMobileProject(targetDir) {
|
|
248
|
+
const startedAt = performance.now();
|
|
249
|
+
if (!existsSync(targetDir) || !statSync(targetDir).isDirectory()) {
|
|
250
|
+
throw new Error(`Target directory does not exist: ${targetDir}`);
|
|
251
|
+
}
|
|
252
|
+
const allFiles = walkFiles(targetDir);
|
|
253
|
+
const findings = [];
|
|
254
|
+
const platformSet = new Set();
|
|
255
|
+
const dependencyManifests = [];
|
|
256
|
+
for (const file of allFiles) {
|
|
257
|
+
const rel = relative(targetDir, file).replace(/\\/g, '/');
|
|
258
|
+
const lower = rel.toLowerCase();
|
|
259
|
+
if (lower.endsWith('pubspec.yaml') || lower.endsWith('package.json') || lower.endsWith('podfile')) {
|
|
260
|
+
try {
|
|
261
|
+
dependencyManifests.push(readFileSync(file, 'utf8'));
|
|
262
|
+
}
|
|
263
|
+
catch {
|
|
264
|
+
// Ignore unreadable manifest files
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
const combinedDeps = dependencyManifests.join('\n');
|
|
269
|
+
for (const file of allFiles) {
|
|
270
|
+
const rel = relative(targetDir, file).replace(/\\/g, '/');
|
|
271
|
+
const lower = rel.toLowerCase();
|
|
272
|
+
const ext = extname(lower);
|
|
273
|
+
if (lower.endsWith('pubspec.yaml')) {
|
|
274
|
+
platformSet.add('flutter');
|
|
275
|
+
auditPubspec(rel, readFileSync(file, 'utf8'), findings);
|
|
276
|
+
}
|
|
277
|
+
else if (lower.endsWith('/androidmanifest.xml') || lower === 'androidmanifest.xml') {
|
|
278
|
+
if (!lower.includes('/debug/') && !lower.includes('/androidtest/') && !lower.includes('/test/')) {
|
|
279
|
+
platformSet.add('android');
|
|
280
|
+
auditAndroidManifest(rel, readFileSync(file, 'utf8'), findings);
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
else if (lower.endsWith('build.gradle') || lower.endsWith('build.gradle.kts')) {
|
|
284
|
+
platformSet.add('android');
|
|
285
|
+
auditGradleFile(rel, readFileSync(file, 'utf8'), findings);
|
|
286
|
+
}
|
|
287
|
+
else if (lower.endsWith('/info.plist') || lower === 'info.plist') {
|
|
288
|
+
if (!lower.includes('tests/') && !lower.includes('/macos/')) {
|
|
289
|
+
platformSet.add('ios');
|
|
290
|
+
auditInfoPlist(rel, readFileSync(file, 'utf8'), combinedDeps, findings);
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
else if (ext === '.jks' || ext === '.keystore' || ext === '.p12' || /authkey_[a-z0-9]+\.p8$/i.test(lower)) {
|
|
294
|
+
pushFinding(findings, {
|
|
295
|
+
ruleId: 'PF-SEC-001',
|
|
296
|
+
severity: 'critical',
|
|
297
|
+
file: rel,
|
|
298
|
+
title: `Committed signing key or certificate file (${ext || '.p8'})`,
|
|
299
|
+
detail: 'Binary app signing keystores and Apple AuthKeys committed to Git compromise store releases.',
|
|
300
|
+
fix: 'Remove from Git history, rotate compromised keys, and load signing certs via encrypted CI secrets.',
|
|
301
|
+
});
|
|
302
|
+
}
|
|
303
|
+
else if (lower.endsWith('key.properties')) {
|
|
304
|
+
const content = readFileSync(file, 'utf8');
|
|
305
|
+
if (/(?:storePassword|keyPassword)\s*=\s*\S+/i.test(content)) {
|
|
306
|
+
pushFinding(findings, {
|
|
307
|
+
ruleId: 'PF-SEC-002',
|
|
308
|
+
severity: 'critical',
|
|
309
|
+
file: rel,
|
|
310
|
+
title: 'Android release signing passwords present in key.properties',
|
|
311
|
+
detail: 'Committed key.properties passwords expose release keystore credentials.',
|
|
312
|
+
fix: 'Gitignore android/key.properties and generate it dynamically from CI secrets.',
|
|
313
|
+
});
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
const counts = {
|
|
318
|
+
critical: findings.filter((f) => f.severity === 'critical').length,
|
|
319
|
+
high: findings.filter((f) => f.severity === 'high').length,
|
|
320
|
+
medium: findings.filter((f) => f.severity === 'medium').length,
|
|
321
|
+
info: findings.filter((f) => f.severity === 'info').length,
|
|
322
|
+
};
|
|
323
|
+
return {
|
|
324
|
+
targetDir,
|
|
325
|
+
platformsDetected: [...platformSet].sort(),
|
|
326
|
+
filesScanned: allFiles.length,
|
|
327
|
+
durationMs: Math.round(performance.now() - startedAt),
|
|
328
|
+
passed: counts.critical === 0 && counts.high === 0,
|
|
329
|
+
counts,
|
|
330
|
+
findings,
|
|
331
|
+
};
|
|
332
|
+
}
|
|
333
|
+
//# sourceMappingURL=audit.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"audit.js","sourceRoot":"","sources":["../src/audit.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,WAAW,EA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CAAC,MAAM;QAClE,IAAI,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,KAAK,MAAM,CAAC,CAAC,MAAM;QAC1D,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,KAAK,QAAQ,CAAC,CAAC,MAAM;QAC9D,IAAI,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,KAAK,MAAM,CAAC,CAAC,MAAM;KAC3D,CAAC;IAEF,OAAO;QACL,SAAS;QACT,iBAAiB,EAAE,CAAC,GAAG,WAAW,CAAC,CAAC,IAAI,EAAE;QAC1C,YAAY,EAAE,QAAQ,CAAC,MAAM;QAC7B,UAAU,EAAE,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,GAAG,EAAE,GAAG,SAAS,CAAC;QACrD,MAAM,EAAE,MAAM,CAAC,QAAQ,KAAK,CAAC,IAAI,MAAM,CAAC,IAAI,KAAK,CAAC;QAClD,MAAM;QACN,QAAQ;KACT,CAAC;AACJ,CAAC"}
|
package/dist/cli.d.ts
ADDED
package/dist/cli.js
ADDED
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { readFileSync } from 'node:fs';
|
|
3
|
+
import { resolve } from 'node:path';
|
|
4
|
+
import { auditMobileProject } from './audit.js';
|
|
5
|
+
import { formatAuditReport, formatBundleReport, formatCompressedLog, meetsSeverityThreshold } from './formatters.js';
|
|
6
|
+
import { compressBuildLog } from './logs.js';
|
|
7
|
+
import { inspectMobileBundle } from './zip.js';
|
|
8
|
+
function getVersion() {
|
|
9
|
+
try {
|
|
10
|
+
const raw = readFileSync(new URL('../package.json', import.meta.url), 'utf8');
|
|
11
|
+
return JSON.parse(raw).version ?? '0.1.0';
|
|
12
|
+
}
|
|
13
|
+
catch {
|
|
14
|
+
return '0.1.0';
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
function printHelp() {
|
|
18
|
+
console.log(`pubflight v${getVersion()} — Zero-SDK mobile & Flutter pre-flight auditor, bundle size inspector & log compressor
|
|
19
|
+
|
|
20
|
+
Usage:
|
|
21
|
+
pubflight audit [dir] [--format text|json|markdown] [--fail-on critical|high|medium|none]
|
|
22
|
+
pubflight inspect <app.apk|app.aab|app.ipa|archive.zip> [--top 10] [--format text|json]
|
|
23
|
+
pubflight logs <build.log | -> [--format text|json]
|
|
24
|
+
|
|
25
|
+
Options:
|
|
26
|
+
--format <fmt> text | json | markdown (default: text)
|
|
27
|
+
--fail-on <level> critical | high | medium | none (default: high)
|
|
28
|
+
--top <n> Number of largest bundle files to show (default: 10)
|
|
29
|
+
-h, --help Show help
|
|
30
|
+
-v, --version Show version
|
|
31
|
+
`);
|
|
32
|
+
}
|
|
33
|
+
function parseArgs(argv) {
|
|
34
|
+
const positionals = [];
|
|
35
|
+
const flags = {};
|
|
36
|
+
for (let i = 0; i < argv.length; i += 1) {
|
|
37
|
+
const arg = argv[i];
|
|
38
|
+
if (!arg)
|
|
39
|
+
continue;
|
|
40
|
+
if (arg === '-h' || arg === '--help') {
|
|
41
|
+
flags.help = true;
|
|
42
|
+
}
|
|
43
|
+
else if (arg === '-v' || arg === '--version') {
|
|
44
|
+
flags.version = true;
|
|
45
|
+
}
|
|
46
|
+
else if (arg.startsWith('--')) {
|
|
47
|
+
const key = arg.slice(2);
|
|
48
|
+
const next = argv[i + 1];
|
|
49
|
+
if (next !== undefined && !next.startsWith('-')) {
|
|
50
|
+
flags[key] = next;
|
|
51
|
+
i += 1;
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
flags[key] = true;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
positionals.push(arg);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
return { positionals, flags };
|
|
62
|
+
}
|
|
63
|
+
function asString(v) {
|
|
64
|
+
return typeof v === 'string' ? v : undefined;
|
|
65
|
+
}
|
|
66
|
+
function parseFormat(raw) {
|
|
67
|
+
const val = raw ?? 'text';
|
|
68
|
+
if (val !== 'text' && val !== 'json' && val !== 'markdown') {
|
|
69
|
+
throw new Error(`Invalid format '${val}'. Expected text, json, or markdown.`);
|
|
70
|
+
}
|
|
71
|
+
return val;
|
|
72
|
+
}
|
|
73
|
+
function parseThreshold(raw) {
|
|
74
|
+
const val = raw ?? 'high';
|
|
75
|
+
if (val !== 'critical' && val !== 'high' && val !== 'medium' && val !== 'none') {
|
|
76
|
+
throw new Error(`Invalid --fail-on '${val}'. Expected critical, high, medium, or none.`);
|
|
77
|
+
}
|
|
78
|
+
return val;
|
|
79
|
+
}
|
|
80
|
+
async function main() {
|
|
81
|
+
const { positionals, flags } = parseArgs(process.argv.slice(2));
|
|
82
|
+
if (flags.help) {
|
|
83
|
+
printHelp();
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
if (flags.version) {
|
|
87
|
+
console.log(getVersion());
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
const first = positionals[0] ?? 'audit';
|
|
91
|
+
const format = parseFormat(asString(flags.format));
|
|
92
|
+
const failOn = parseThreshold(asString(flags['fail-on']));
|
|
93
|
+
if (first === 'inspect') {
|
|
94
|
+
const artifact = positionals[1];
|
|
95
|
+
if (!artifact) {
|
|
96
|
+
throw new Error('Artifact path required: pubflight inspect <file.apk|file.aab|file.ipa>');
|
|
97
|
+
}
|
|
98
|
+
const topN = Number(asString(flags.top) ?? '10');
|
|
99
|
+
const report = inspectMobileBundle(resolve(artifact), Number.isFinite(topN) && topN > 0 ? topN : 10);
|
|
100
|
+
console.log(formatBundleReport(report, format));
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
if (first === 'logs') {
|
|
104
|
+
const source = positionals[1] ?? '-';
|
|
105
|
+
const rawLog = source === '-' ? readFileSync(0, 'utf8') : readFileSync(resolve(source), 'utf8');
|
|
106
|
+
const compressed = compressBuildLog(rawLog);
|
|
107
|
+
console.log(formatCompressedLog(compressed, format));
|
|
108
|
+
process.exitCode = compressed.status === 'failed' ? 1 : 0;
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
const targetDir = first === 'audit' ? resolve(positionals[1] ?? '.') : resolve(first);
|
|
112
|
+
const report = auditMobileProject(targetDir);
|
|
113
|
+
console.log(formatAuditReport(report, format));
|
|
114
|
+
const shouldFail = report.findings.some((f) => meetsSeverityThreshold(f.severity, failOn));
|
|
115
|
+
process.exitCode = shouldFail ? 1 : 0;
|
|
116
|
+
}
|
|
117
|
+
main().catch((err) => {
|
|
118
|
+
console.error(`pubflight error: ${err instanceof Error ? err.message : String(err)}`);
|
|
119
|
+
process.exitCode = 2;
|
|
120
|
+
});
|
|
121
|
+
//# sourceMappingURL=cli.js.map
|
package/dist/cli.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAChD,OAAO,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AACrH,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAE7C,OAAO,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAE/C,SAAS,UAAU;IACjB,IAAI,CAAC;QACH,MAAM,GAAG,GAAG,YAAY,CAAC,IAAI,GAAG,CAAC,iBAAiB,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC,CAAC;QAC9E,OAAQ,IAAI,CAAC,KAAK,CAAC,GAAG,CAA0B,CAAC,OAAO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QAAQ,GAAG,UAAU,CAAC,MAAM,KAAK,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAC1D,OAAO;IACT,CAAC;IAED,MAAM,SAAS,GAAG,KAAK,KAAK,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;IACtF,MAAM,MAAM,GAAG,kBAAkB,CAAC,SAAS,CAAC,CAAC;IAC7C,OAAO,CAAC,GAAG,CAAC,iBAAiB,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IAC/C,MAAM,UAAU,GAAG,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,sBAAsB,CAAC,CAAC,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC,CAAC;IAC3F,OAAO,CAAC,QAAQ,GAAG,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AACxC,CAAC;AAED,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;IACnB,OAAO,CAAC,KAAK,CAAC,oBAAoB,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IACtF,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;AACvB,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { BundleSizeReport, CompressedBuildLog, OutputFormat, ProjectAuditReport, Severity } from './types.js';
|
|
2
|
+
export declare function meetsSeverityThreshold(severity: Severity, threshold: Severity | 'none'): boolean;
|
|
3
|
+
export declare function formatAuditReport(report: ProjectAuditReport, format: OutputFormat): string;
|
|
4
|
+
export declare function formatBundleReport(report: BundleSizeReport, format: OutputFormat): string;
|
|
5
|
+
export declare function formatCompressedLog(report: CompressedBuildLog, format: OutputFormat): string;
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
const RANK = { critical: 4, high: 3, medium: 2, info: 1 };
|
|
2
|
+
export function meetsSeverityThreshold(severity, threshold) {
|
|
3
|
+
if (threshold === 'none')
|
|
4
|
+
return false;
|
|
5
|
+
return RANK[severity] >= RANK[threshold];
|
|
6
|
+
}
|
|
7
|
+
function mb(bytes) {
|
|
8
|
+
return `${(bytes / (1024 * 1024)).toFixed(2)} MB`;
|
|
9
|
+
}
|
|
10
|
+
export function formatAuditReport(report, format) {
|
|
11
|
+
if (format === 'json')
|
|
12
|
+
return JSON.stringify(report, null, 2);
|
|
13
|
+
if (format === 'markdown') {
|
|
14
|
+
const lines = [
|
|
15
|
+
`# pubflight Audit Report`,
|
|
16
|
+
'',
|
|
17
|
+
`- **Platforms:** ${report.platformsDetected.join(', ') || 'none detected'}`,
|
|
18
|
+
`- **Status:** ${report.passed ? 'PASSED' : 'FAILED'}`,
|
|
19
|
+
`- **Findings:** ${report.counts.critical} critical, ${report.counts.high} high, ${report.counts.medium} medium, ${report.counts.info} info`,
|
|
20
|
+
'',
|
|
21
|
+
];
|
|
22
|
+
if (report.findings.length > 0) {
|
|
23
|
+
lines.push('| Severity | Rule | File | Finding |');
|
|
24
|
+
lines.push('| :---: | :--- | :--- | :--- |');
|
|
25
|
+
for (const f of report.findings) {
|
|
26
|
+
lines.push(`| ${f.severity} | \`${f.ruleId}\` | \`${f.file}\` | ${f.title} |`);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
return lines.join('\n');
|
|
30
|
+
}
|
|
31
|
+
const lines = [
|
|
32
|
+
`pubflight audit — platforms: ${report.platformsDetected.join(', ') || 'none'} (${report.filesScanned} files scanned in ${report.durationMs}ms)`,
|
|
33
|
+
'',
|
|
34
|
+
];
|
|
35
|
+
if (report.findings.length === 0) {
|
|
36
|
+
lines.push('No pre-flight issues detected.');
|
|
37
|
+
return lines.join('\n');
|
|
38
|
+
}
|
|
39
|
+
for (const f of report.findings) {
|
|
40
|
+
const loc = f.line !== undefined ? `${f.file}:${f.line}` : f.file;
|
|
41
|
+
lines.push(`[${f.severity.toUpperCase()}] ${f.ruleId} (${loc}) ${f.title}`);
|
|
42
|
+
lines.push(` ${f.detail}`);
|
|
43
|
+
lines.push(` Fix: ${f.fix}`);
|
|
44
|
+
}
|
|
45
|
+
lines.push('');
|
|
46
|
+
lines.push(`Summary: critical=${report.counts.critical} high=${report.counts.high} medium=${report.counts.medium} info=${report.counts.info}`);
|
|
47
|
+
return lines.join('\n');
|
|
48
|
+
}
|
|
49
|
+
export function formatBundleReport(report, format) {
|
|
50
|
+
if (format === 'json')
|
|
51
|
+
return JSON.stringify(report, null, 2);
|
|
52
|
+
const lines = [
|
|
53
|
+
`pubflight inspect — ${report.artifactPath} (${report.kind.toUpperCase()})`,
|
|
54
|
+
`Archive size: ${mb(report.archiveBytes)} | Entries: ${report.entryCount} | ABIs: ${report.abisDetected.join(', ') || 'n/a'}`,
|
|
55
|
+
'',
|
|
56
|
+
'Breakdown by category:',
|
|
57
|
+
];
|
|
58
|
+
for (const [cat, stat] of Object.entries(report.byCategory)) {
|
|
59
|
+
if (stat.count > 0) {
|
|
60
|
+
lines.push(` ${cat.padEnd(11)} ${String(stat.count).padStart(5)} files | ${mb(stat.compressedBytes).padStart(9)} compressed`);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
lines.push('', 'Largest entries:');
|
|
64
|
+
for (const entry of report.largestEntries) {
|
|
65
|
+
lines.push(` ${mb(entry.compressedBytes).padStart(9)} ${entry.name}`);
|
|
66
|
+
}
|
|
67
|
+
if (report.warnings.length > 0) {
|
|
68
|
+
lines.push('', 'Warnings:');
|
|
69
|
+
for (const w of report.warnings) {
|
|
70
|
+
lines.push(` - ${w}`);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
return lines.join('\n');
|
|
74
|
+
}
|
|
75
|
+
export function formatCompressedLog(report, format) {
|
|
76
|
+
if (format === 'json')
|
|
77
|
+
return JSON.stringify(report, null, 2);
|
|
78
|
+
const lines = [
|
|
79
|
+
`pubflight logs — status=${report.status} | toolchains=${report.toolchains.join(',')} | ${report.originalLines} -> ${report.compressedLines} lines (${report.reductionPercent}% reduction)`,
|
|
80
|
+
];
|
|
81
|
+
if (report.hints.length > 0) {
|
|
82
|
+
lines.push('', 'Matched Fixes:');
|
|
83
|
+
for (const h of report.hints) {
|
|
84
|
+
lines.push(` * ${h.issue}: ${h.fix}`);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
if (report.errors.length > 0) {
|
|
88
|
+
lines.push('', `Errors (${report.errors.length}):`);
|
|
89
|
+
for (const err of report.errors)
|
|
90
|
+
lines.push(` ${err}`);
|
|
91
|
+
}
|
|
92
|
+
if (report.warnings.length > 0) {
|
|
93
|
+
lines.push('', `Warnings (${report.warnings.length}):`);
|
|
94
|
+
for (const warn of report.warnings)
|
|
95
|
+
lines.push(` ${warn}`);
|
|
96
|
+
}
|
|
97
|
+
return lines.join('\n');
|
|
98
|
+
}
|
|
99
|
+
//# sourceMappingURL=formatters.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"formatters.js","sourceRoot":"","sources":["../src/formatters.ts"],"names":[],"mappings":"AAEA,MAAM,IAAI,GAA6B,EAAE,QAAQ,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC;AAEpF,MAAM,UAAU,sBAAsB,CAAC,QAAkB,EAAE,SAA4B;IACrF,IAAI,SAAS,KAAK,MAAM;QAAE,OAAO,KAAK,CAAC;IACvC,OAAO,IAAI,CAAC,QAAQ,CAAC,IAAI,IAAI,CAAC,SAAS,CAAC,CAAC;AAC3C,CAAC;AAED,SAAS,EAAE,CAAC,KAAa;IACvB,OAAO,GAAG,CAAC,KAAK,GAAG,CAAC,IAAI,GAAG,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AAE,EAAE,aAAa,MAAM,CAAC,QAAQ,CAAC,MAAM,IAAI,CAAC,CAAC;QACxD,KAAK,MAAM,IAAI,IAAI,MAAM,CAAC,QAAQ;YAAE,KAAK,CAAC,IAAI,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC;IAC9D,CAAC;IACD,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { auditMobileProject } from './audit.js';
|
|
2
|
+
export { formatAuditReport, formatBundleReport, formatCompressedLog, meetsSeverityThreshold, } from './formatters.js';
|
|
3
|
+
export { compressBuildLog } from './logs.js';
|
|
4
|
+
export type { AuditFinding, BundleSizeReport, CompressedBuildLog, OutputFormat, ProjectAuditReport, Severity, ZipEntryStat, } from './types.js';
|
|
5
|
+
export { inspectMobileBundle, parseZipCentralDirectory } from './zip.js';
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { auditMobileProject } from './audit.js';
|
|
2
|
+
export { formatAuditReport, formatBundleReport, formatCompressedLog, meetsSeverityThreshold, } from './formatters.js';
|
|
3
|
+
export { compressBuildLog } from './logs.js';
|
|
4
|
+
export { inspectMobileBundle, parseZipCentralDirectory } from './zip.js';
|
|
5
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAChD,OAAO,EACL,iBAAiB,EACjB,kBAAkB,EAClB,mBAAmB,EACnB,sBAAsB,GACvB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAU7C,OAAO,EAAE,mBAAmB,EAAE,wBAAwB,EAAE,MAAM,UAAU,CAAC"}
|
package/dist/logs.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { CompressedBuildLog } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Strips repetitive Gradle/Xcode/CocoaPods progress chatter from build output while
|
|
4
|
+
* retaining root-cause errors, stack anchors, and deterministic remediation hints.
|
|
5
|
+
*/
|
|
6
|
+
export declare function compressBuildLog(rawLog: string, maxErrors?: number, maxWarnings?: number): CompressedBuildLog;
|
package/dist/logs.js
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
const TOOLCHAIN_PATTERNS = [
|
|
2
|
+
{ name: 'flutter', regex: /\b(flutter|dart|Running Gradle task|libflutter\.so|pub get)\b/i },
|
|
3
|
+
{ name: 'gradle', regex: /\b(FAILURE: Build failed|Execution failed for task|> Task :|build\.gradle)\b/i },
|
|
4
|
+
{ name: 'xcode', regex: /\b(xcodebuild|ld: library|SWIFT_VERSION|Provisioning profile|\*\* BUILD FAILED \*\*)\b/i },
|
|
5
|
+
{ name: 'cocoapods', regex: /\b(CocoaPods|pod install|Podfile\.lock)\b/i },
|
|
6
|
+
{ name: 'metro', regex: /\b(Metro has encountered an error|Unable to resolve module)\b/i },
|
|
7
|
+
];
|
|
8
|
+
const ERROR_LINE_REGEX = /^(?:FAILURE:|\* What went wrong:|e:\s*|error:|fatal error:|ERROR:|Exception:|Unhandled exception:|Execution failed for task|\*\* BUILD FAILED \*\*|ld: |Undefined symbols|Could not resolve|Unable to resolve module|Duplicate class )|\b(?:\.dart|\.kt|\.java|\.swift|\.m):\d+(?::\d+)?:\s*error:/i;
|
|
9
|
+
const WARNING_LINE_REGEX = /^(?:w:\s*|warning:|WARNING:)|\bdeprecated\b/i;
|
|
10
|
+
const NOISE_LINE_REGEX = /^(?:> Task :[^\s]+ (?:UP-TO-DATE|FROM-CACHE|NO-SOURCE)|Downloading https?:\/\/|Download https?:\/\/|Compiling \S+\.(?:o|swift|m)|Copying |GenerateDSYMFile |ProcessInfoPlistFile |CodeSign |note: |\s*at\s+[\w.$<>]+\(|\[[ +]+\d+ ms\])/i;
|
|
11
|
+
const KNOWN_FIX_RULES = [
|
|
12
|
+
{
|
|
13
|
+
pattern: /Namespace not specified/i,
|
|
14
|
+
issue: 'Android Gradle Plugin 8+ missing namespace',
|
|
15
|
+
fix: 'Upgrade the offending plugin package or add namespace matching its package attribute inside android/build.gradle.',
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
pattern: /Duplicate class .* found in modules/i,
|
|
19
|
+
issue: 'Android transitive dependency duplicate class conflict',
|
|
20
|
+
fix: 'Run ./gradlew app:dependencies --configuration releaseRuntimeClasspath and exclude the duplicate artifact or align BOM versions.',
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
pattern: /CocoaPods could not find compatible versions/i,
|
|
24
|
+
issue: 'CocoaPods spec version conflict',
|
|
25
|
+
fix: 'Run pod repo update followed by cd ios && pod install --repo-update, or bump platform :ios version in ios/Podfile.',
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
pattern: /minSdkVersion .* cannot be smaller than version .* declared in library/i,
|
|
29
|
+
issue: 'Android minSdkVersion below plugin requirement',
|
|
30
|
+
fix: 'Raise minSdk / minSdkVersion in android/app/build.gradle(.kts) to at least the required floor.',
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
pattern: /Provisioning profile .* doesn't match|requires a provisioning profile/i,
|
|
34
|
+
issue: 'iOS code signing / provisioning mismatch',
|
|
35
|
+
fix: 'Verify DEVELOPMENT_TEAM, bundle identifier, and signing certificates/provisioning profile match the archive configuration.',
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
pattern: /Because .* depends on .* version solving failed/i,
|
|
39
|
+
issue: 'Dart pub dependency constraint conflict',
|
|
40
|
+
fix: 'Run dart pub outdated and align incompatible package versions in pubspec.yaml.',
|
|
41
|
+
},
|
|
42
|
+
];
|
|
43
|
+
/**
|
|
44
|
+
* Strips repetitive Gradle/Xcode/CocoaPods progress chatter from build output while
|
|
45
|
+
* retaining root-cause errors, stack anchors, and deterministic remediation hints.
|
|
46
|
+
*/
|
|
47
|
+
export function compressBuildLog(rawLog, maxErrors = 40, maxWarnings = 15) {
|
|
48
|
+
const lines = rawLog.split(/\r?\n/);
|
|
49
|
+
const toolchains = TOOLCHAIN_PATTERNS.filter((entry) => entry.regex.test(rawLog)).map((entry) => entry.name);
|
|
50
|
+
const errorSet = new Set();
|
|
51
|
+
const warningSet = new Set();
|
|
52
|
+
const errors = [];
|
|
53
|
+
const warnings = [];
|
|
54
|
+
for (let i = 0; i < lines.length; i += 1) {
|
|
55
|
+
const trimmed = (lines[i] ?? '').trim();
|
|
56
|
+
if (!trimmed || NOISE_LINE_REGEX.test(trimmed)) {
|
|
57
|
+
continue;
|
|
58
|
+
}
|
|
59
|
+
if (ERROR_LINE_REGEX.test(trimmed)) {
|
|
60
|
+
if (!errorSet.has(trimmed) && errors.length < maxErrors) {
|
|
61
|
+
errorSet.add(trimmed);
|
|
62
|
+
errors.push(trimmed);
|
|
63
|
+
}
|
|
64
|
+
// Capture up to 2 continuation detail lines immediately following a Gradle/Xcode failure header
|
|
65
|
+
for (let j = 1; j <= 2 && i + j < lines.length; j += 1) {
|
|
66
|
+
const cont = (lines[i + j] ?? '').trim();
|
|
67
|
+
if (cont && cont.startsWith('>') && !errorSet.has(cont) && errors.length < maxErrors) {
|
|
68
|
+
errorSet.add(cont);
|
|
69
|
+
errors.push(cont);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
continue;
|
|
73
|
+
}
|
|
74
|
+
if (WARNING_LINE_REGEX.test(trimmed) && !warningSet.has(trimmed) && warnings.length < maxWarnings) {
|
|
75
|
+
warningSet.add(trimmed);
|
|
76
|
+
warnings.push(trimmed);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
const hints = KNOWN_FIX_RULES.filter((rule) => rule.pattern.test(rawLog)).map(({ issue, fix }) => ({ issue, fix }));
|
|
80
|
+
const compressedLines = errors.length + warnings.length + hints.length * 2;
|
|
81
|
+
const originalLines = lines.length;
|
|
82
|
+
const reductionPercent = originalLines === 0
|
|
83
|
+
? 0
|
|
84
|
+
: Math.max(0, Math.round(((originalLines - compressedLines) / originalLines) * 1000) / 10);
|
|
85
|
+
const status = errors.length > 0 ? 'failed' : warnings.length > 0 ? 'warnings-only' : 'clean';
|
|
86
|
+
return {
|
|
87
|
+
toolchains: toolchains.length > 0 ? toolchains : ['generic'],
|
|
88
|
+
originalLines,
|
|
89
|
+
compressedLines,
|
|
90
|
+
reductionPercent,
|
|
91
|
+
status,
|
|
92
|
+
errors,
|
|
93
|
+
warnings,
|
|
94
|
+
hints,
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
//# sourceMappingURL=logs.js.map
|
package/dist/logs.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logs.js","sourceRoot":"","sources":["../src/logs.ts"],"names":[],"mappings":"AAEA,MAAM,kBAAkB,GAA2C;IACjE,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,gEAAgE,EAAE;IAC5F,EAAE,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,+EAA+E,EAAE;IAC1G,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,yFAAyF,EAAE;IACnH,EAAE,IAAI,EAAE,WAAW,EAAE,KAAK,EAAE,4CAA4C,EAAE;IAC1E,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,gEAAgE,EAAE;CAC3F,CAAC;AAEF,MAAM,gBAAgB,GACpB,qSAAqS,CAAC;AAExS,MAAM,kBAAkB,GAAG,8CAA8C,CAAC;AAE1E,MAAM,gBAAgB,GACpB,0OAA0O,CAAC;AAE7O,MAAM,eAAe,GAA2D;IAC9E;QACE,OAAO,EAAE,0BAA0B;QACnC,KAAK,EAAE,4CAA4C;QACnD,GAAG,EAAE,mHAAmH;KACzH;IACD;QACE,OAAO,EAAE,sCAAsC;QAC/C,KAAK,EAAE,wDAAwD;QAC/D,GAAG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CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,CAC3E,CAAC,EAAE,KAAK,EAAE,GAAG,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC,CACrC,CAAC;IAEF,MAAM,eAAe,GAAG,MAAM,CAAC,MAAM,GAAG,QAAQ,CAAC,MAAM,GAAG,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC;IAC3E,MAAM,aAAa,GAAG,KAAK,CAAC,MAAM,CAAC;IACnC,MAAM,gBAAgB,GACpB,aAAa,KAAK,CAAC;QACjB,CAAC,CAAC,CAAC;QACH,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,aAAa,GAAG,eAAe,CAAC,GAAG,aAAa,CAAC,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC;IAE/F,MAAM,MAAM,GACV,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,OAAO,CAAC;IAEjF,OAAO;QACL,UAAU,EAAE,UAAU,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;QAC5D,aAAa;QACb,eAAe;QACf,gBAAgB;QAChB,MAAM;QACN,MAAM;QACN,QAAQ;QACR,KAAK;KACN,CAAC;AACJ,CAAC"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
export type Severity = 'critical' | 'high' | 'medium' | 'info';
|
|
2
|
+
export type OutputFormat = 'text' | 'json' | 'markdown';
|
|
3
|
+
export interface AuditFinding {
|
|
4
|
+
ruleId: string;
|
|
5
|
+
severity: Severity;
|
|
6
|
+
file: string;
|
|
7
|
+
title: string;
|
|
8
|
+
detail: string;
|
|
9
|
+
fix: string;
|
|
10
|
+
line?: number;
|
|
11
|
+
}
|
|
12
|
+
export interface ProjectAuditReport {
|
|
13
|
+
targetDir: string;
|
|
14
|
+
platformsDetected: string[];
|
|
15
|
+
filesScanned: number;
|
|
16
|
+
durationMs: number;
|
|
17
|
+
passed: boolean;
|
|
18
|
+
counts: Record<Severity, number>;
|
|
19
|
+
findings: AuditFinding[];
|
|
20
|
+
}
|
|
21
|
+
export interface ZipEntryStat {
|
|
22
|
+
name: string;
|
|
23
|
+
compressedBytes: number;
|
|
24
|
+
uncompressedBytes: number;
|
|
25
|
+
category: 'native' | 'flutter' | 'dex' | 'assets' | 'resources' | 'metadata' | 'other';
|
|
26
|
+
}
|
|
27
|
+
export interface BundleSizeReport {
|
|
28
|
+
artifactPath: string;
|
|
29
|
+
kind: 'apk' | 'aab' | 'ipa' | 'zip';
|
|
30
|
+
archiveBytes: number;
|
|
31
|
+
entryCount: number;
|
|
32
|
+
totalCompressedBytes: number;
|
|
33
|
+
totalUncompressedBytes: number;
|
|
34
|
+
abisDetected: string[];
|
|
35
|
+
byCategory: Record<ZipEntryStat['category'], {
|
|
36
|
+
count: number;
|
|
37
|
+
compressedBytes: number;
|
|
38
|
+
uncompressedBytes: number;
|
|
39
|
+
}>;
|
|
40
|
+
largestEntries: ZipEntryStat[];
|
|
41
|
+
warnings: string[];
|
|
42
|
+
}
|
|
43
|
+
export interface CompressedBuildLog {
|
|
44
|
+
toolchains: string[];
|
|
45
|
+
originalLines: number;
|
|
46
|
+
compressedLines: number;
|
|
47
|
+
reductionPercent: number;
|
|
48
|
+
status: 'failed' | 'clean' | 'warnings-only';
|
|
49
|
+
errors: string[];
|
|
50
|
+
warnings: string[];
|
|
51
|
+
hints: Array<{
|
|
52
|
+
issue: string;
|
|
53
|
+
fix: string;
|
|
54
|
+
}>;
|
|
55
|
+
}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
|
package/dist/zip.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { BundleSizeReport, ZipEntryStat } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Parses a ZIP Central Directory (supporting .apk, .aab, .ipa, and .zip) with zero
|
|
4
|
+
* external unzip/aapt dependencies.
|
|
5
|
+
*/
|
|
6
|
+
export declare function parseZipCentralDirectory(buf: Buffer): ZipEntryStat[];
|
|
7
|
+
export declare function inspectMobileBundle(artifactPath: string, topN?: number): BundleSizeReport;
|
package/dist/zip.js
ADDED
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import { readFileSync, statSync } from 'node:fs';
|
|
2
|
+
import { extname } from 'node:path';
|
|
3
|
+
const EOCD_SIGNATURE = 0x06054b50;
|
|
4
|
+
const CEN_SIGNATURE = 0x02014b50;
|
|
5
|
+
function classifyEntry(name) {
|
|
6
|
+
const lower = name.toLowerCase();
|
|
7
|
+
if (lower.includes('libflutter.so') || lower.includes('libapp.so') || lower.includes('flutter_assets/') || lower.includes('app.framework/')) {
|
|
8
|
+
return 'flutter';
|
|
9
|
+
}
|
|
10
|
+
if (lower.endsWith('.so') || lower.includes('/frameworks/') || lower.endsWith('.dylib')) {
|
|
11
|
+
return 'native';
|
|
12
|
+
}
|
|
13
|
+
if (/^classes\d*\.dex$/i.test(lower) || lower.endsWith('.dex')) {
|
|
14
|
+
return 'dex';
|
|
15
|
+
}
|
|
16
|
+
if (lower.startsWith('assets/') || lower.includes('/assets/') || /\.(png|jpg|jpeg|webp|gif|mp4|mp3|wav|ttf|otf|json|rive|lottie)$/i.test(lower)) {
|
|
17
|
+
return 'assets';
|
|
18
|
+
}
|
|
19
|
+
if (lower.startsWith('res/') || lower.includes('/res/') || lower.endsWith('resources.arsc') || lower.endsWith('.pb')) {
|
|
20
|
+
return 'resources';
|
|
21
|
+
}
|
|
22
|
+
if (lower.startsWith('meta-inf/') || lower.endsWith('androidmanifest.xml') || lower.endsWith('info.plist') || lower.endsWith('mobileprovision')) {
|
|
23
|
+
return 'metadata';
|
|
24
|
+
}
|
|
25
|
+
return 'other';
|
|
26
|
+
}
|
|
27
|
+
function findEocdOffset(buf) {
|
|
28
|
+
const minOffset = Math.max(0, buf.length - 65557);
|
|
29
|
+
for (let offset = buf.length - 22; offset >= minOffset; offset -= 1) {
|
|
30
|
+
if (buf.readUInt32LE(offset) === EOCD_SIGNATURE) {
|
|
31
|
+
const commentLength = buf.readUInt16LE(offset + 20);
|
|
32
|
+
if (offset + 22 + commentLength === buf.length) {
|
|
33
|
+
return offset;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
return -1;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Parses a ZIP Central Directory (supporting .apk, .aab, .ipa, and .zip) with zero
|
|
41
|
+
* external unzip/aapt dependencies.
|
|
42
|
+
*/
|
|
43
|
+
export function parseZipCentralDirectory(buf) {
|
|
44
|
+
const eocdOffset = findEocdOffset(buf);
|
|
45
|
+
if (eocdOffset < 0) {
|
|
46
|
+
throw new Error('Not a valid ZIP/APK/AAB/IPA archive: End of Central Directory signature not found.');
|
|
47
|
+
}
|
|
48
|
+
const totalEntries = buf.readUInt16LE(eocdOffset + 10);
|
|
49
|
+
const cdOffset = buf.readUInt32LE(eocdOffset + 16);
|
|
50
|
+
if (cdOffset >= buf.length) {
|
|
51
|
+
throw new Error('Corrupt ZIP archive: Central Directory offset exceeds file size.');
|
|
52
|
+
}
|
|
53
|
+
const entries = [];
|
|
54
|
+
let cursor = cdOffset;
|
|
55
|
+
for (let i = 0; i < totalEntries && cursor + 46 <= eocdOffset; i += 1) {
|
|
56
|
+
if (buf.readUInt32LE(cursor) !== CEN_SIGNATURE) {
|
|
57
|
+
break;
|
|
58
|
+
}
|
|
59
|
+
const compressedBytes = buf.readUInt32LE(cursor + 20);
|
|
60
|
+
const uncompressedBytes = buf.readUInt32LE(cursor + 24);
|
|
61
|
+
const fileNameLen = buf.readUInt16LE(cursor + 28);
|
|
62
|
+
const extraLen = buf.readUInt16LE(cursor + 30);
|
|
63
|
+
const commentLen = buf.readUInt16LE(cursor + 32);
|
|
64
|
+
const nameStart = cursor + 46;
|
|
65
|
+
const nameEnd = nameStart + fileNameLen;
|
|
66
|
+
if (nameEnd > buf.length)
|
|
67
|
+
break;
|
|
68
|
+
const name = buf.subarray(nameStart, nameEnd).toString('utf8');
|
|
69
|
+
if (!name.endsWith('/')) {
|
|
70
|
+
entries.push({
|
|
71
|
+
name,
|
|
72
|
+
compressedBytes,
|
|
73
|
+
uncompressedBytes,
|
|
74
|
+
category: classifyEntry(name),
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
cursor = nameEnd + extraLen + commentLen;
|
|
78
|
+
}
|
|
79
|
+
return entries;
|
|
80
|
+
}
|
|
81
|
+
export function inspectMobileBundle(artifactPath, topN = 10) {
|
|
82
|
+
const stat = statSync(artifactPath);
|
|
83
|
+
const buf = readFileSync(artifactPath);
|
|
84
|
+
const entries = parseZipCentralDirectory(buf);
|
|
85
|
+
const ext = extname(artifactPath).toLowerCase().replace('.', '');
|
|
86
|
+
const kind = ext === 'apk' || ext === 'aab' || ext === 'ipa' ? ext : 'zip';
|
|
87
|
+
const byCategory = {
|
|
88
|
+
native: { count: 0, compressedBytes: 0, uncompressedBytes: 0 },
|
|
89
|
+
flutter: { count: 0, compressedBytes: 0, uncompressedBytes: 0 },
|
|
90
|
+
dex: { count: 0, compressedBytes: 0, uncompressedBytes: 0 },
|
|
91
|
+
assets: { count: 0, compressedBytes: 0, uncompressedBytes: 0 },
|
|
92
|
+
resources: { count: 0, compressedBytes: 0, uncompressedBytes: 0 },
|
|
93
|
+
metadata: { count: 0, compressedBytes: 0, uncompressedBytes: 0 },
|
|
94
|
+
other: { count: 0, compressedBytes: 0, uncompressedBytes: 0 },
|
|
95
|
+
};
|
|
96
|
+
let totalCompressedBytes = 0;
|
|
97
|
+
let totalUncompressedBytes = 0;
|
|
98
|
+
const abiSet = new Set();
|
|
99
|
+
for (const entry of entries) {
|
|
100
|
+
totalCompressedBytes += entry.compressedBytes;
|
|
101
|
+
totalUncompressedBytes += entry.uncompressedBytes;
|
|
102
|
+
const bucket = byCategory[entry.category];
|
|
103
|
+
bucket.count += 1;
|
|
104
|
+
bucket.compressedBytes += entry.compressedBytes;
|
|
105
|
+
bucket.uncompressedBytes += entry.uncompressedBytes;
|
|
106
|
+
const abiMatch = /(?:^|\/)lib\/(arm64-v8a|armeabi-v7a|x86_64|x86)\//i.exec(entry.name);
|
|
107
|
+
if (abiMatch?.[1]) {
|
|
108
|
+
abiSet.add(abiMatch[1]);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
const largestEntries = [...entries]
|
|
112
|
+
.sort((a, b) => b.compressedBytes - a.compressedBytes)
|
|
113
|
+
.slice(0, topN);
|
|
114
|
+
const warnings = [];
|
|
115
|
+
if (kind === 'apk' && abiSet.size >= 3) {
|
|
116
|
+
warnings.push(`Fat APK contains ${abiSet.size} ABIs (${[...abiSet].join(', ')}). Ship an Android App Bundle (.aab) or --split-per-abi APK to cut download size by ~40-60%.`);
|
|
117
|
+
}
|
|
118
|
+
const oversizedAssets = entries.filter((e) => e.category === 'assets' && e.compressedBytes >= 2 * 1024 * 1024);
|
|
119
|
+
if (oversizedAssets.length > 0) {
|
|
120
|
+
warnings.push(`${oversizedAssets.length} bundled asset(s) exceed 2 MB compressed (largest: ${oversizedAssets[0]?.name}). Convert large images to WebP/AVIF or fetch media remotely.`);
|
|
121
|
+
}
|
|
122
|
+
if (kind === 'apk' && totalCompressedBytes > 100 * 1024 * 1024) {
|
|
123
|
+
warnings.push('Compressed APK size exceeds 100 MB legacy distribution ceiling.');
|
|
124
|
+
}
|
|
125
|
+
return {
|
|
126
|
+
artifactPath,
|
|
127
|
+
kind,
|
|
128
|
+
archiveBytes: stat.size,
|
|
129
|
+
entryCount: entries.length,
|
|
130
|
+
totalCompressedBytes,
|
|
131
|
+
totalUncompressedBytes,
|
|
132
|
+
abisDetected: [...abiSet].sort(),
|
|
133
|
+
byCategory,
|
|
134
|
+
largestEntries,
|
|
135
|
+
warnings,
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
//# sourceMappingURL=zip.js.map
|
package/dist/zip.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"zip.js","sourceRoot":"","sources":["../src/zip.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACjD,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAGpC,MAAM,cAAc,GAAG,UAAU,CAAC;AAClC,MAAM,aAAa,GAAG,UAAU,CAAC;AAEjC,SAAS,aAAa,CAAC,IAAY;IACjC,MAAM,KAAK,GAAG,IAAI,CAAC,WAAW,EAAE,CAAC;IACjC,IAAI,KAAK,CAAC,QAAQ,CAAC,eAAe,CAAC,IAAI,KAAK,CAAC,QAAQ,CAAC,WAAW,CAAC,IAAI,KAAK,CAAC,QAAQ,CAAC,iBAAiB,CAAC,IAAI,KAAK,CAAC,QAAQ,CAAC,gBAAgB,CAAC,EAAE,CAAC;QAC5I,OAAO,SAAS,CAAC;IACnB,CAAC;IACD,IAAI,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,QAAQ,CAAC,cAAc,CAAC,IAAI,KAAK,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAC;QACxF,OAAO,QAAQ,CAAC;IAClB,CAAC;IACD,IAAI,oBAAoB,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC;QAC/D,OAAO,KAAK,CAAC;IACf,CAAC;IACD,IAAI,KAAK,CAAC,UAAU,CAAC,SAAS,CAAC,IAAI,KAAK,CAAC,QAAQ,CAAC,UAAU,CAAC,IAAI,kEAAkE,CAAC,IAAI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|
|
2
2
|
"name": "pubflight",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Zero-SDK mobile & Flutter release pre-flight auditor, APK/AAB/IPA ZIP size analyzer, and Gradle/Xcode build-log compressor (CLI + SDK + GitHub Action + Agent Skill).",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"bin": {
|
|
7
|
+
"pubflight": "./dist/cli.js"
|
|
8
|
+
},
|
|
9
|
+
"main": "./dist/index.js",
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"exports": {
|
|
12
|
+
".": {
|
|
13
|
+
"types": "./dist/index.d.ts",
|
|
14
|
+
"import": "./dist/index.js"
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
"files": [
|
|
18
|
+
"dist",
|
|
19
|
+
"skills",
|
|
20
|
+
"action.yml",
|
|
21
|
+
"README.md",
|
|
22
|
+
"CONTRIBUTING.md",
|
|
23
|
+
"LICENSE"
|
|
24
|
+
],
|
|
25
|
+
"scripts": {
|
|
26
|
+
"build": "tsc",
|
|
27
|
+
"typecheck": "tsc --noEmit",
|
|
28
|
+
"test": "bun test",
|
|
29
|
+
"prepublishOnly": "bun run build && bun test"
|
|
30
|
+
},
|
|
31
|
+
"keywords": [
|
|
32
|
+
"flutter",
|
|
33
|
+
"android",
|
|
34
|
+
"ios",
|
|
35
|
+
"apk",
|
|
36
|
+
"aab",
|
|
37
|
+
"ipa",
|
|
38
|
+
"gradle",
|
|
39
|
+
"xcode",
|
|
40
|
+
"mobile-ci",
|
|
41
|
+
"cli",
|
|
42
|
+
"ai-agents",
|
|
43
|
+
"skill"
|
|
44
|
+
],
|
|
45
|
+
"author": "Vidit Jain <viditjain180@gmail.com>",
|
|
46
|
+
"license": "MIT",
|
|
47
|
+
"engines": {
|
|
48
|
+
"node": ">=18.0.0"
|
|
49
|
+
},
|
|
50
|
+
"repository": {
|
|
51
|
+
"type": "git",
|
|
52
|
+
"url": "https://github.com/viditjain25/pubflight.git"
|
|
53
|
+
},
|
|
54
|
+
"devDependencies": {
|
|
55
|
+
"@types/node": "^22.10.0",
|
|
56
|
+
"typescript": "^5.7.2"
|
|
57
|
+
}
|
|
58
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: pubflight
|
|
3
|
+
description: Pre-flight mobile/Flutter store policy checks, offline APK/AAB/IPA ZIP size inspection, and 85%+ Gradle/Xcode build-log compression for coding agents.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# pubflight Agent Skill
|
|
7
|
+
|
|
8
|
+
Use `pubflight` whenever modifying Android (`AndroidManifest.xml`, `build.gradle*`), iOS (`Info.plist`), or Flutter (`pubspec.yaml`) configs, or before reading huge Gradle/Xcode/CocoaPods build logs.
|
|
9
|
+
|
|
10
|
+
## Workflow
|
|
11
|
+
|
|
12
|
+
1. **Audit repo before release PRs** (runs without Flutter/Android/Xcode SDKs installed):
|
|
13
|
+
```bash
|
|
14
|
+
npx pubflight audit . --format json --fail-on high
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
2. **Compress noisy CI/Gradle/Xcode build logs** before pasting into agent context:
|
|
18
|
+
```bash
|
|
19
|
+
flutter build appbundle 2>&1 | npx pubflight logs - --format json
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
3. **Inspect built APK / AAB / IPA binary size breakdown**:
|
|
23
|
+
```bash
|
|
24
|
+
npx pubflight inspect build/app/outputs/flutter-apk/app-release.apk --top 15
|
|
25
|
+
```
|