Skip to content

Commit 58bebdd

Browse files
huntiefacebook-github-bot
authored andcommitted
Refactor remaining forEachPackage call sites (#43112)
Summary: Pull Request resolved: #43112 Changelog: [Internal] Reviewed By: cipolleschi Differential Revision: D53942028
1 parent 4ecf57e commit 58bebdd

15 files changed

Lines changed: 370 additions & 480 deletions

File tree

scripts/e2e/init-template-e2e.js

Lines changed: 24 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
const {retry} = require('../circleci/retry');
1515
const {REPO_ROOT} = require('../consts');
16-
const forEachPackage = require('../monorepo/for-each-package');
16+
const {getPackages} = require('../utils/monorepo');
1717
const {
1818
VERDACCIO_SERVER_URL,
1919
VERDACCIO_STORAGE_PATH,
@@ -22,6 +22,7 @@ const {
2222
const {parseArgs} = require('@pkgjs/parseargs');
2323
const chalk = require('chalk');
2424
const {execSync} = require('child_process');
25+
const path = require('path');
2526

2627
const config = {
2728
options: {
@@ -86,26 +87,28 @@ async function initNewProjectFromSource(
8687
console.log('\nDone ✅');
8788

8889
console.log('Publishing packages to local npm proxy\n');
89-
forEachPackage(
90-
(packageAbsolutePath, packageRelativePathFromRoot, packageManifest) => {
91-
if (packageManifest.private) {
92-
return;
93-
}
94-
95-
const desc = `${packageManifest.name} (${packageRelativePathFromRoot})`;
96-
process.stdout.write(
97-
`${desc} ${chalk.dim('.').repeat(Math.max(0, 72 - desc.length))} `,
98-
);
99-
execSync(
100-
`npm publish --registry ${VERDACCIO_SERVER_URL} --access public`,
101-
{
102-
cwd: packageAbsolutePath,
103-
stdio: verbose ? 'inherit' : [process.stderr],
104-
},
105-
);
106-
process.stdout.write(chalk.reset.inverse.bold.green(' DONE ') + '\n');
107-
},
108-
);
90+
const packages = await getPackages({
91+
includeReactNative: false,
92+
includePrivate: false,
93+
});
94+
95+
for (const {path: packagePath, packageJson} of Object.values(packages)) {
96+
const desc = `${packageJson.name} (${path.relative(
97+
REPO_ROOT,
98+
packagePath,
99+
)})`;
100+
process.stdout.write(
101+
`${desc} ${chalk.dim('.').repeat(Math.max(0, 72 - desc.length))} `,
102+
);
103+
execSync(
104+
`npm publish --registry ${VERDACCIO_SERVER_URL} --access public`,
105+
{
106+
cwd: packagePath,
107+
stdio: verbose ? 'inherit' : [process.stderr],
108+
},
109+
);
110+
process.stdout.write(chalk.reset.inverse.bold.green(' DONE ') + '\n');
111+
}
109112
console.log('\nDone ✅');
110113

111114
console.log('Running react-native init without install');

0 commit comments

Comments
 (0)