Skip to content

Commit 42e62bf

Browse files
committed
Refactor remaining forEachPackage call sites (facebook#43112)
Summary: Pull Request resolved: facebook#43112 Changelog: [Internal] Reviewed By: cipolleschi Differential Revision: D53942028 fbshipit-source-id: 335bff3c3a31026bae7140fac1d1a6aae23a0f1e
1 parent 3b170a0 commit 42e62bf

File tree

15 files changed

+369
-481
lines changed

15 files changed

+369
-481
lines changed

scripts/e2e/init-template-e2e.js

Lines changed: 23 additions & 22 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,7 +22,6 @@ const {
2222
const {parseArgs} = require('@pkgjs/parseargs');
2323
const chalk = require('chalk');
2424
const {execSync} = require('child_process');
25-
const {promises: fs} = require('fs');
2625
const path = require('path');
2726

2827
const config = {
@@ -92,26 +91,28 @@ async function initNewProjectFromSource(
9291
console.log('\nDone ✅');
9392

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

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

0 commit comments

Comments
 (0)