1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow strict-local
* @format
*/
const {REACT_NATIVE_PACKAGE_DIR} = require('../../shared/consts');
const {
getPackages,
getWorkspaceRoot,
updatePackageJson,
} = require('../../shared/monorepoUtils');
const {getPackageVersionStrByTag} = require('./npm-utils');
const {promises: fs} = require('fs');
const path = require('path');
const MAVEN_VERSIONS_FILE_PATH = path.join(
REACT_NATIVE_PACKAGE_DIR,
'sdks',
'hermes-engine',
'version.properties',
);
async function getLatestHermesNightlyVersion() /*: Promise<{
compilerVersion: string,
compilerV1Version: string,
runtimeVersion: string,
runtimeV1Version: string,
}> */ {
// fetch the latest commitly version of hermes v0
const compilerVersion = await getPackageVersionStrByTag(
'hermes-compiler',
'nightly',
);
// fetch the latest version of hermes v1
const compilerV1Version = await getPackageVersionStrByTag(
'hermes-compiler',
'latest-v1',
);
return {
compilerVersion,
compilerV1Version,
// runtime version should match the compiler version
runtimeVersion: compilerVersion,
runtimeV1Version: compilerV1Version,
};
}
async function updateHermesCompilerVersionInDependencies(
hermesVersion /*: string */,
) /*: Promise<void> */ {
const packages = await getPackages({
includePrivate: true,
includeReactNative: true,
});
const packagesToUpdate = [
await getWorkspaceRoot(),
...Object.values(packages),
];
// Update generated files in packages/react-native/
await Promise.all(
packagesToUpdate.map(pkg =>
updatePackageJson(pkg, {'hermes-compiler': hermesVersion}),
),
);
}
async function updateHermesRuntimeDependenciesVersions(
hermesVersion /*: string */,
hermesV1Version /*: string */,
) /*: Promise<void> */ {
const newVersionsFile =
`HERMES_VERSION_NAME=${hermesVersion}\n` +
`HERMES_V1_VERSION_NAME=${hermesV1Version}`;
await fs.writeFile(MAVEN_VERSIONS_FILE_PATH, newVersionsFile.trim() + '\n');
}
async function updateHermesVersionsToNightly() {
const hermesVersions = await getLatestHermesNightlyVersion();
await updateHermesCompilerVersionInDependencies(
hermesVersions.compilerV1Version,
);
await updateHermesRuntimeDependenciesVersions(
hermesVersions.runtimeVersion,
hermesVersions.runtimeV1Version,
);
}
module.exports = {
updateHermesVersionsToNightly,
updateHermesCompilerVersionInDependencies,
updateHermesRuntimeDependenciesVersions,
};