mirror of
https://gitcode.com/github-mirrors/react-native-update-cli.git
synced 2025-10-30 22:33:11 +08:00
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:
30
src/utils/check-plugin.ts
Normal file
30
src/utils/check-plugin.ts
Normal 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;
|
||||
}
|
||||
@@ -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 };
|
||||
|
||||
34
src/utils/plugin-config.ts
Normal file
34
src/utils/plugin-config.ts
Normal 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
];
|
||||
Reference in New Issue
Block a user