Skip to content

Commit

Permalink
feat: ios hermes sourcemap
Browse files Browse the repository at this point in the history
  • Loading branch information
田亮 committed Jun 7, 2021
1 parent b1cdff5 commit 3c092c6
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 13 deletions.
22 changes: 10 additions & 12 deletions src/command-executor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1248,18 +1248,16 @@ export var releaseReact = (command: cli.IReleaseReactCommand): Promise<void> =>
)
)
.then(() => {
if (platform === "android") {
return getHermesEnabled(command.gradleFile).then((isHermesEnabled) => {
if (isHermesEnabled) {
return runHermesEmitBinaryCommand(
bundleName,
outputFolder,
command.sourcemapOutput,
[] // TODO: extra flags
);
}
});
}
return getHermesEnabled(command.platform, command.gradleFile, command.podFile).then((isHermesEnabled) => {
if (isHermesEnabled) {
return runHermesEmitBinaryCommand(
bundleName,
outputFolder,
command.sourcemapOutput,
[] // TODO: extra flags
);
}
});
})
.then(() => {
out.text(chalk.cyan("\nReleasing update contents to CodePush:\n"));
Expand Down
7 changes: 7 additions & 0 deletions src/command-parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -828,6 +828,12 @@ var argv = yargs
demand: false,
description: "Path to the gradle file which specifies the binary version you want to target this release at (android only).",
})
.option("podFile", {
alias: "pf",
default: null,
demand: false,
description: "Path to the cocopods config file (iOS only).",
})
.option("mandatory", {
alias: "m",
default: false,
Expand Down Expand Up @@ -1316,6 +1322,7 @@ function createCommand(): cli.ICommand {
releaseReactCommand.development = argv["development"];
releaseReactCommand.entryFile = argv["entryFile"];
releaseReactCommand.gradleFile = argv["gradleFile"];
releaseReactCommand.podFile = argv["podFile"];
releaseReactCommand.mandatory = argv["mandatory"];
releaseReactCommand.noDuplicateReleaseError = argv["noDuplicateReleaseError"];
releaseReactCommand.plistFile = argv["plistFile"];
Expand Down
1 change: 1 addition & 0 deletions src/definitions/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ export interface IReleaseReactCommand extends IReleaseBaseCommand {
development?: boolean;
entryFile?: string;
gradleFile?: string;
podFile?: string;
platform: string;
plistFile?: string;
plistFilePrefix?: string;
Expand Down
22 changes: 21 additions & 1 deletion src/lib/react-native-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,27 @@ export function runHermesEmitBinaryCommand(
});
}

export function getHermesEnabled(gradleFile: string): Promise<boolean> {
export function getHermesEnabled(platform: string, gradleFile?: string, podFile?: string): Promise<boolean> {
if (platform === "ios") {
let podPath = path.join("ios", "Podfile");
if (podFile) {
podPath = podFile;
}
if (fileDoesNotExistOrIsDirectory(podPath)) {
throw new Error(`Unable to find Podfile file "${podPath}".`);
}

return new Promise((resolve, reject) => {
fs.readFile(podPath, { encoding: "utf8" }, (error, res) => {
if (error) {
reject(error);
return;
}
resolve(/:hermes_enabled(\s+|\n+)?=>(\s+|\n+)?true/.test(res));
});
});
}

let buildGradlePath: string = path.join("android", "app");
if (gradleFile) {
buildGradlePath = gradleFile;
Expand Down

0 comments on commit 3c092c6

Please sign in to comment.