Skip to content

Commit

Permalink
Refactor remaining forEachPackage call sites
Browse files Browse the repository at this point in the history
Summary: Changelog: [Internal]

Differential Revision: D53942028
  • Loading branch information
huntie authored and facebook-github-bot committed Feb 20, 2024
1 parent a4d6be8 commit 23cda55
Show file tree
Hide file tree
Showing 15 changed files with 370 additions and 480 deletions.
45 changes: 24 additions & 21 deletions scripts/e2e/init-template-e2e.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

const {retry} = require('../circleci/retry');
const {REPO_ROOT} = require('../consts');
const forEachPackage = require('../monorepo/for-each-package');
const {getPackages} = require('../utils/monorepo');
const {
VERDACCIO_SERVER_URL,
VERDACCIO_STORAGE_PATH,
Expand All @@ -22,6 +22,7 @@ const {
const {parseArgs} = require('@pkgjs/parseargs');
const chalk = require('chalk');
const {execSync} = require('child_process');
const path = require('path');

const config = {
options: {
Expand Down Expand Up @@ -86,26 +87,28 @@ async function initNewProjectFromSource(
console.log('\nDone ✅');

console.log('Publishing packages to local npm proxy\n');
forEachPackage(
(packageAbsolutePath, packageRelativePathFromRoot, packageManifest) => {
if (packageManifest.private) {
return;
}

const desc = `${packageManifest.name} (${packageRelativePathFromRoot})`;
process.stdout.write(
`${desc} ${chalk.dim('.').repeat(Math.max(0, 72 - desc.length))} `,
);
execSync(
`npm publish --registry ${VERDACCIO_SERVER_URL} --access public`,
{
cwd: packageAbsolutePath,
stdio: verbose ? 'inherit' : [process.stderr],
},
);
process.stdout.write(chalk.reset.inverse.bold.green(' DONE ') + '\n');
},
);
const packages = await getPackages({
includeReactNative: true,
includePrivate: false,
});

for (const {path: packagePath, packageJson} of Object.values(packages)) {
const desc = `${packageJson.name} (${path.relative(
REPO_ROOT,
packagePath,
)})`;
process.stdout.write(
`${desc} ${chalk.dim('.').repeat(Math.max(0, 72 - desc.length))} `,
);
execSync(
`npm publish --registry ${VERDACCIO_SERVER_URL} --access public`,
{
cwd: packagePath,
stdio: verbose ? 'inherit' : [process.stderr],
},
);
process.stdout.write(chalk.reset.inverse.bold.green(' DONE ') + '\n');
}
console.log('\nDone ✅');

console.log('Running react-native init without install');
Expand Down
Loading

0 comments on commit 23cda55

Please sign in to comment.