Skip to content

Commit 51affc8

Browse files
committed
implement checkSentry file
;
1 parent fe694b8 commit 51affc8

File tree

3 files changed

+38
-1
lines changed

3 files changed

+38
-1
lines changed

src/bundle.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import path from 'node:path';
2-
import { getRNVersion, translateOptions } from './utils';
2+
import { getRNVersion, translateOptions, checkXcodeScript } from './utils';
33
import * as fs from 'fs-extra';
44
import { ZipFile } from 'yazl';
55
import { open as openZipFile } from 'yauzl';
@@ -718,6 +718,18 @@ export const commands = {
718718
options.platform || (await question('平台(ios/android/harmony):')),
719719
);
720720

721+
let hasSentryScript = false;
722+
723+
if (platform === 'ios') {
724+
hasSentryScript = checkXcodeScript();
725+
} else {
726+
hasSentryScript = false;
727+
}
728+
729+
if (hasSentryScript && platform === 'ios') {
730+
throw new Error('请先执行xcodebuild命令,然后再执行pushy bundleAfterXcodeBuild');
731+
}
732+
721733
const { bundleName, entryFile, intermediaDir, output, dev, sourcemap } =
722734
translateOptions({
723735
...options,

src/utils/checkSentry.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
const fs = require('fs');
2+
const path = require('path');
3+
4+
export function checkXcodeScript() {
5+
try {
6+
const iosPath = path.join(process.cwd(), 'ios');
7+
const projects = fs.readdirSync(iosPath)
8+
.filter(file => file.endsWith('.xcodeproj'));
9+
if (projects.length === 0) {
10+
throw new Error('找不到 .xcodeproj 文件');
11+
}
12+
const projectPath = path.join(iosPath, projects[0], 'project.pbxproj');
13+
const content = fs.readFileSync(projectPath, 'utf8');
14+
const hasSentryScript = content.includes('sentry-xcode.sh');
15+
16+
console.log(`是否包含 sentry-xcode.sh: ${hasSentryScript}`);
17+
return hasSentryScript;
18+
} catch (error) {
19+
console.error('读取文件失败:', error);
20+
return false;
21+
}
22+
}

src/utils/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import AppInfoParser from './app-info-parser';
66
import semverSatisfies from 'semver/functions/satisfies';
77
import chalk from 'chalk';
88
import latestVersion from '@badisi/latest-version';
9+
import { checkXcodeScript } from './checkSentry';
910

1011
import { read } from 'read';
1112

@@ -225,3 +226,5 @@ export async function printVersionCommand() {
225226
}
226227

227228
export const pricingPageUrl = 'https://pushy.reactnative.cn/pricing.html';
229+
230+
export { checkXcodeScript };

0 commit comments

Comments
 (0)