1
0
mirror of https://gitcode.com/github-mirrors/react-native-update-cli.git synced 2025-10-30 22:33:11 +08:00
Code Issues Packages Projects Releases Wiki Activity GitHub Gitee

Support sentry (#8)

* add logic to support sentry

* udpate

* change reference path

* support git commits and version info

* udate

* add try catch for require.resolve

* update upload sourcemap workflow
This commit is contained in:
波仔糕
2025-01-23 22:02:13 +08:00
committed by GitHub
parent b24b27d100
commit 0b08c7760d
5 changed files with 182 additions and 4 deletions

30
src/utils/check-plugin.ts Normal file
View File

@@ -0,0 +1,30 @@
import { plugins } from './plugin-config';
interface BundleParams {
sentry: boolean;
minify: boolean;
sourcemap: boolean;
[key: string]: any;
}
export async function checkPlugins(): Promise<BundleParams> {
const params: BundleParams = {
sentry: false,
minify: true,
sourcemap: false,
};
for (const plugin of plugins) {
try {
const isEnabled = await plugin.detect();
if (isEnabled && plugin.bundleParams) {
Object.assign(params, plugin.bundleParams);
console.log(`检测到 ${plugin.name} 插件,应用相应打包配置`);
}
} catch (err) {
console.warn(`检测 ${plugin.name} 插件时出错:`, err);
}
}
return params;
}

View File

@@ -6,6 +6,7 @@ import AppInfoParser from './app-info-parser';
import semverSatisfies from 'semver/functions/satisfies';
import chalk from 'chalk';
import latestVersion from '@badisi/latest-version';
import { checkPlugins } from './check-plugin';
import { read } from 'read';
@@ -225,3 +226,5 @@ export async function printVersionCommand() {
}
export const pricingPageUrl = 'https://pushy.reactnative.cn/pricing.html';
export { checkPlugins };

View File

@@ -0,0 +1,34 @@
import fs from 'fs-extra';
interface PluginConfig {
name: string;
bundleParams?: {
minify?: boolean;
[key: string]: any;
};
detect: () => Promise<boolean>;
}
export const plugins: PluginConfig[] = [
{
name: 'sentry',
bundleParams: {
sentry: true,
minify: false,
sourcemap: true,
},
detect: async () => {
try {
await fs.access('ios/sentry.properties');
return true;
} catch {
try {
await fs.access('android/sentry.properties');
return true;
} catch {
return false;
}
}
}
}
];