Skip to content

Commit f85b399

Browse files
committed
fix: release scripts
1 parent 41a7dbf commit f85b399

File tree

2 files changed

+66
-4
lines changed

2 files changed

+66
-4
lines changed

scripts/monorepo/for-each-package.js

+63
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
/**
2+
* Copyright (c) Meta Platforms, Inc. and affiliates.
3+
*
4+
* This source code is licensed under the MIT license found in the
5+
* LICENSE file in the root directory of this source tree.
6+
*
7+
* @format
8+
*/
9+
10+
const path = require('path');
11+
const {readdirSync, readFileSync} = require('fs');
12+
13+
const ROOT_LOCATION = path.join(__dirname, '..', '..');
14+
const PACKAGES_LOCATION = path.join(ROOT_LOCATION, 'packages');
15+
16+
const DEFAULT_OPTIONS = {includeReactNative: false};
17+
18+
/**
19+
* Function, which returns an array of all directories inside specified location
20+
*
21+
* @param {string} source Path to directory, where this should be executed
22+
* @returns {string[]} List of directories names
23+
*/
24+
const getDirectories = source =>
25+
readdirSync(source, {withFileTypes: true})
26+
.filter(file => file.isDirectory())
27+
.map(directory => directory.name);
28+
29+
/**
30+
* @callback forEachPackageCallback
31+
* @param {string} packageAbsolutePath
32+
* @param {string} packageRelativePathFromRoot
33+
* @param {Object} packageManifest
34+
*/
35+
36+
/**
37+
* Iterate through every package inside /packages (ignoring react-native) and call provided callback for each of them
38+
*
39+
* @param {forEachPackageCallback} callback The callback which will be called for each package
40+
* @param {{includeReactNative: (boolean|undefined)}} [options={}] description
41+
*/
42+
const forEachPackage = (callback, options = DEFAULT_OPTIONS) => {
43+
const {includeReactNative} = options;
44+
45+
// We filter react-native package on purpose, so that no CI's script will be executed for this package in future
46+
// Unless includeReactNative options is provided
47+
const packagesDirectories = getDirectories(PACKAGES_LOCATION).filter(
48+
directoryName => directoryName !== 'react-native' || includeReactNative,
49+
);
50+
51+
packagesDirectories.forEach(packageDirectory => {
52+
const packageAbsolutePath = path.join(PACKAGES_LOCATION, packageDirectory);
53+
const packageRelativePathFromRoot = path.join('packages', packageDirectory);
54+
55+
const packageManifest = JSON.parse(
56+
readFileSync(path.join(packageAbsolutePath, 'package.json')),
57+
);
58+
59+
callback(packageAbsolutePath, packageRelativePathFromRoot, packageManifest);
60+
});
61+
};
62+
63+
module.exports = forEachPackage;

scripts/oot-release.js

+3-4
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@
99
const forEachPackage = require('./monorepo/for-each-package');
1010
const newGithubReleaseUrl = require('./new-github-release-url');
1111
const {applyPackageVersions, publishPackage} = require('./npm-utils');
12-
const {failIfTagExists} = require('./release-utils');
13-
const updateTemplatePackage = require('./update-template-package');
12+
const updateTemplatePackage = require('./releases/update-template-package');
1413
const {execSync} = require('child_process');
1514
const fs = require('fs');
1615
const path = require('path');
@@ -94,6 +93,7 @@ function releaseOOT(
9493
oneTimePassword,
9594
tag = 'latest',
9695
) {
96+
console.log('Releasing visionOS packages with tag: ', tag);
9797
const isNightly = tag === 'nightly';
9898
const allPackages = getPackages();
9999
const corePackages = Object.keys(allPackages).filter(packageName =>
@@ -150,7 +150,6 @@ function releaseOOT(
150150
}
151151

152152
const gitTag = `v${newVersion}-visionos`;
153-
failIfTagExists(gitTag, 'release');
154153
// Create git tag
155154
execSync(`git tag -a ${gitTag} -m "Release ${newVersion}"`, {
156155
cwd: REPO_ROOT,
@@ -164,7 +163,7 @@ function releaseOOT(
164163
.map(packagePath => {
165164
echo(`Releasing ${packagePath}`);
166165
const result = publishPackage(packagePath, {
167-
tag,
166+
tags: [tag],
168167
otp: oneTimePassword,
169168
});
170169

0 commit comments

Comments
 (0)