Skip to content

Commit

Permalink
cleanup publish-npm.js: --include-hermes is not used anywhere (#35166)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: #35166

The Hermes source code is not included in the RN npm package. This piece of code is a remnant from an early experimentation into integrating Hermes more tightly with React Native. We ended up using a combination of the scripts in `scripts/hermes` to fetch the source code from GitHub and relying on prebuilts for stable releases.

Added `strict()` flag to ensure the script fails immediately if an unrecognized flag is passed.

Avoid logging temp publishing folder value to console when `--help` is used.

Changelog: [internal]

Reviewed By: cortinico

Differential Revision: D40918939

fbshipit-source-id: 2e62ab16467c4c67f03efdf5211a156cb70e0b11
  • Loading branch information
hramos authored and facebook-github-bot committed Nov 3, 2022
1 parent a671d61 commit 4f3ca8f
Showing 1 changed file with 5 additions and 62 deletions.
67 changes: 5 additions & 62 deletions scripts/publish-npm.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ const otp = process.env.NPM_CONFIG_OTP;
const tmpPublishingFolder = fs.mkdtempSync(
path.join(os.tmpdir(), 'rn-publish-'),
);
echo(`The temp publishing folder is ${tmpPublishingFolder}`);

const argv = yargs
.option('n', {
Expand All @@ -66,73 +65,17 @@ const argv = yargs
type: 'boolean',
default: false,
})
.option('h', {
alias: 'include-hermes',
type: 'boolean',
default: false,
}).argv;
.strict().argv;
const nightlyBuild = argv.nightly;
const dryRunBuild = argv.dryRun;
const includeHermes = argv.includeHermes;
const isCommitly = nightlyBuild || dryRunBuild;

saveFilesToRestore(tmpPublishingFolder);

if (includeHermes) {
const HERMES_INSTALL_LOCATION = 'sdks';
const HERMES_SOURCE_DEST_PATH = `${HERMES_INSTALL_LOCATION}/hermes`;

let hermesReleaseTag;
let hermesReleaseURI;
if (isCommitly) {
// use latest commit / tarball
hermesReleaseURI = 'https://github.com/facebook/hermes/tarball/main';
} else {
// use one configured in disk
fs.readFile(
`${HERMES_INSTALL_LOCATION}/.hermesversion`,
{
encoding: 'utf8',
flag: 'r',
},
function (err, data) {
if (err) {
echo('Failed to read current Hermes release tag.');
// TODO: We'll need to make sure every release going forward has one of these.
exit(1);
} else {
hermesReleaseTag = data.trim();
hermesReleaseURI = `https://github.com/facebook/hermes/archive/refs/tags/${hermesReleaseTag}.tar.gz`;
}
},
);
}

const tmpDownloadDir = fs.mkdtempSync(
path.join(os.tmpdir(), 'hermes-tarball'),
);
const tmpExtractDir = fs.mkdtempSync(path.join(os.tmpdir(), 'hermes'));

const hermesInstallScript = `
mkdir -p ${HERMES_SOURCE_DEST_PATH} && \
wget ${hermesReleaseURI} -O ${tmpDownloadDir}/hermes.tar.gz && \
tar -xzf ${tmpDownloadDir}/hermes.tar.gz -C ${tmpExtractDir} && \
HERMES_SOURCE_EXTRACT_PATH=$(ls -d ${tmpExtractDir}/*) && \
mv $HERMES_SOURCE_EXTRACT_PATH ${HERMES_SOURCE_DEST_PATH}
`;

if (fs.existsSync(`${HERMES_SOURCE_DEST_PATH}`)) {
if (exec(`rm -rf ./${HERMES_SOURCE_DEST_PATH}`).code) {
echo('Failed to clean up previous Hermes installation.');
exit(1);
}
}
if (exec(hermesInstallScript).code) {
echo('Failed to include Hermes in release.');
exit(1);
}
if (!argv.help) {
echo(`The temp publishing folder is ${tmpPublishingFolder}`);
}

saveFilesToRestore(tmpPublishingFolder);

// 34c034298dc9cad5a4553964a5a324450fda0385
const currentCommit = getCurrentCommit();
const shortCommit = currentCommit.slice(0, 9);
Expand Down

0 comments on commit 4f3ca8f

Please sign in to comment.