@crumbsdk/react-native 0.0.1-rc.4 → 0.0.1-rc.5
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/README.md +10 -0
- package/android/build.gradle +1 -0
- package/app.plugin.js +34 -4
- package/lib/module/build-release.js +19 -0
- package/lib/module/build-release.js.map +1 -0
- package/lib/module/index.js +3 -1
- package/lib/module/index.js.map +1 -1
- package/lib/typescript/src/build-release.d.ts +6 -0
- package/lib/typescript/src/build-release.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +1 -1
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/metro.cjs +35 -0
- package/metro.d.cts +2 -0
- package/native/ios/VERSION +1 -1
- package/native/ios/packages/ios/Sources/CrumbCore/Crumb.swift +1 -1
- package/native/ios/packages/ios/Sources/CrumbCore/CrumbJavaScriptCrashStore.swift +8 -2
- package/native/ios/packages/ios/Sources/CrumbCore/CrumbSDKVersion.swift +1 -1
- package/native/ios/provenance.json +1 -1
- package/package.json +18 -4
- package/plugin/build-hooks.cjs +52 -0
- package/src/build-release.ts +30 -0
- package/src/index.ts +3 -1
- package/tools/cli.cjs +116 -0
- package/tools/config.cjs +72 -0
- package/tools/crumb.gradle +63 -0
- package/tools/expo-export.cjs +122 -0
- package/tools/ios.cjs +93 -0
- package/tools/node.cjs +21 -0
- package/tools/release.cjs +65 -0
- package/tools/setup.cjs +291 -0
- package/tools/upload.cjs +137 -0
package/tools/upload.cjs
ADDED
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
const fs = require('node:fs');
|
|
2
|
+
const path = require('node:path');
|
|
3
|
+
const { spawnSync } = require('node:child_process');
|
|
4
|
+
const { readConfig, isStrict } = require('./config.cjs');
|
|
5
|
+
const { readRelease, hashFile, verifyMapIdentity } = require('./release.cjs');
|
|
6
|
+
|
|
7
|
+
function uploaderPath() {
|
|
8
|
+
return path.join(
|
|
9
|
+
path.dirname(require.resolve('@crumbsdk/source-maps/package.json')),
|
|
10
|
+
'dist/cli.js'
|
|
11
|
+
);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
function uploadRelease(
|
|
15
|
+
{ root, manifest, platform, appVersion, nativeBuild, bundle, sourceMap },
|
|
16
|
+
options = {}
|
|
17
|
+
) {
|
|
18
|
+
const config = readConfig(root);
|
|
19
|
+
if (!config.sourceMaps.enabled) return { status: 'disabled' };
|
|
20
|
+
const dryRun = options.dryRun || process.env.CRUMB_SOURCE_MAP_DRY_RUN === '1';
|
|
21
|
+
try {
|
|
22
|
+
const release = readRelease(manifest);
|
|
23
|
+
verifyMapIdentity(sourceMap, release.bundleVersion);
|
|
24
|
+
for (const value of [appVersion, nativeBuild]) {
|
|
25
|
+
if (
|
|
26
|
+
typeof value !== 'string' ||
|
|
27
|
+
!/^[A-Za-z0-9][A-Za-z0-9._+-]{0,63}$/.test(value)
|
|
28
|
+
) {
|
|
29
|
+
throw new Error(
|
|
30
|
+
'The final native version/build could not be determined. Use the advanced uploader with the exact built release.'
|
|
31
|
+
);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
if (!['ios', 'android'].includes(platform))
|
|
35
|
+
throw new Error('The release platform must be ios or android.');
|
|
36
|
+
const archive = options.retained
|
|
37
|
+
? path.dirname(manifest)
|
|
38
|
+
: path.join(
|
|
39
|
+
path.dirname(manifest),
|
|
40
|
+
'retained',
|
|
41
|
+
release.bundleVersion,
|
|
42
|
+
platform
|
|
43
|
+
);
|
|
44
|
+
fs.mkdirSync(archive, { recursive: true });
|
|
45
|
+
function retain(source, name) {
|
|
46
|
+
const destination = path.join(archive, name);
|
|
47
|
+
if (fs.existsSync(destination)) {
|
|
48
|
+
if (hashFile(source) !== hashFile(destination))
|
|
49
|
+
throw new Error(
|
|
50
|
+
'Retained release artifacts conflict with this build. Use a new release identity.'
|
|
51
|
+
);
|
|
52
|
+
} else fs.copyFileSync(source, destination, fs.constants.COPYFILE_EXCL);
|
|
53
|
+
return destination;
|
|
54
|
+
}
|
|
55
|
+
bundle = retain(bundle, 'bundle');
|
|
56
|
+
sourceMap = retain(sourceMap, 'bundle.map');
|
|
57
|
+
manifest = retain(manifest, 'release.json');
|
|
58
|
+
const retained = {
|
|
59
|
+
root,
|
|
60
|
+
manifest,
|
|
61
|
+
platform,
|
|
62
|
+
appVersion,
|
|
63
|
+
nativeBuild,
|
|
64
|
+
bundle,
|
|
65
|
+
sourceMap,
|
|
66
|
+
bundleSha256: hashFile(bundle),
|
|
67
|
+
sourceMapSha256: hashFile(sourceMap),
|
|
68
|
+
};
|
|
69
|
+
const receipt = path.join(
|
|
70
|
+
path.dirname(manifest),
|
|
71
|
+
`upload-${platform}-${appVersion}-${nativeBuild}.json`
|
|
72
|
+
);
|
|
73
|
+
fs.writeFileSync(receipt, JSON.stringify(retained, null, 2));
|
|
74
|
+
const args = [
|
|
75
|
+
uploaderPath(),
|
|
76
|
+
'upload',
|
|
77
|
+
'--platform',
|
|
78
|
+
platform,
|
|
79
|
+
'--app-version',
|
|
80
|
+
appVersion,
|
|
81
|
+
'--native-build',
|
|
82
|
+
nativeBuild,
|
|
83
|
+
'--bundle-version',
|
|
84
|
+
release.bundleVersion,
|
|
85
|
+
'--bundle',
|
|
86
|
+
bundle,
|
|
87
|
+
'--source-map',
|
|
88
|
+
sourceMap,
|
|
89
|
+
'--expected-bundle-sha256',
|
|
90
|
+
retained.bundleSha256,
|
|
91
|
+
'--expected-source-map-sha256',
|
|
92
|
+
retained.sourceMapSha256,
|
|
93
|
+
'--url',
|
|
94
|
+
config.sourceMaps.uploadUrl,
|
|
95
|
+
];
|
|
96
|
+
if (dryRun) args.push('--dry-run');
|
|
97
|
+
const result = spawnSync(process.execPath, args, {
|
|
98
|
+
encoding: 'utf8',
|
|
99
|
+
timeout: 240000,
|
|
100
|
+
});
|
|
101
|
+
if (result.error || result.status !== 0) {
|
|
102
|
+
throw new Error(
|
|
103
|
+
`Source maps were not uploaded. Check CRUMB_SOURCE_MAP_TOKEN and the upload origin, then retry with crumb retry --receipt ${JSON.stringify(receipt)}.`
|
|
104
|
+
);
|
|
105
|
+
}
|
|
106
|
+
const output = JSON.parse(result.stdout);
|
|
107
|
+
if (output.status !== (dryRun ? 'dry_run' : 'verified'))
|
|
108
|
+
throw new Error(
|
|
109
|
+
'The uploader did not confirm the artifacts. Run crumb doctor and retry.'
|
|
110
|
+
);
|
|
111
|
+
console.log(
|
|
112
|
+
dryRun
|
|
113
|
+
? 'Crumb: release artifacts validated locally; no upload performed.'
|
|
114
|
+
: 'Crumb: source-map artifacts uploaded and verified. Confirm a test crash in the dashboard.'
|
|
115
|
+
);
|
|
116
|
+
return output;
|
|
117
|
+
} catch (error) {
|
|
118
|
+
if (options.strict || isStrict(config)) throw error;
|
|
119
|
+
console.warn(`Crumb warning: ${error.message}`);
|
|
120
|
+
return { status: 'unavailable' };
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
function retryUpload(receipt) {
|
|
125
|
+
const retained = JSON.parse(fs.readFileSync(receipt, 'utf8'));
|
|
126
|
+
if (
|
|
127
|
+
hashFile(retained.bundle) !== retained.bundleSha256 ||
|
|
128
|
+
hashFile(retained.sourceMap) !== retained.sourceMapSha256
|
|
129
|
+
) {
|
|
130
|
+
throw new Error(
|
|
131
|
+
'Retained artifacts have changed. Restore the exact original files; do not upload a rebuilt bundle under the old identity.'
|
|
132
|
+
);
|
|
133
|
+
}
|
|
134
|
+
return uploadRelease(retained, { strict: true, retained: true });
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
module.exports = { uploadRelease, retryUpload };
|