main() — react Function Reference
Architecture documentation for the main() function in publish.js from the react codebase.
Entity Profile
Dependency Diagram
graph TD c6b702e6_04b9_cbac_8909_3140c6390097["main()"] f45932c5_2ab3_a92d_4f35_db53f36391a0["publish.js"] c6b702e6_04b9_cbac_8909_3140c6390097 -->|defined in| f45932c5_2ab3_a92d_4f35_db53f36391a0 style c6b702e6_04b9_cbac_8909_3140c6390097 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
compiler/scripts/release/publish.js lines 43–235
async function main() {
const argv = yargs(process.argv.slice(2))
.option('packages', {
description: 'which packages to publish, defaults to all',
choices: PUBLISHABLE_PACKAGES,
default: PUBLISHABLE_PACKAGES,
})
.option('for-real', {
alias: 'frfr',
description:
'whether to publish to npm (npm publish) or dryrun (npm publish --dry-run)',
type: 'boolean',
default: false,
})
.option('debug', {
description:
'If enabled, will always run npm commands in dry run mode irregardless of the for-real flag',
type: 'boolean',
default: false,
})
.option('ci', {
description: 'Publish packages via CI',
type: 'boolean',
default: false,
})
.option('tag', {
description: 'Tag to publish to npm',
type: 'choices',
choices: ['experimental', 'beta', 'rc', 'latest'],
default: 'experimental',
})
.option('tag-version', {
description:
'Optional tag version to append to tag name, eg `1` becomes 0.0.0-rc.1',
type: 'number',
default: null,
})
.option('version-name', {
description: 'Version name',
type: 'string',
default: '0.0.0',
})
.help('help')
.strict()
.parseSync();
if (argv.debug === false) {
const currBranchName = await execHelper('git rev-parse --abbrev-ref HEAD');
const isPristine = (await execHelper('git status --porcelain')) === '';
if (currBranchName !== 'main' || isPristine === false) {
throw new Error(
'This script must be run from the `main` branch with no uncommitted changes'
);
}
}
let pkgNames = argv.packages;
if (Array.isArray(argv.packages) === false) {
pkgNames = [argv.packages];
}
const spinner = ora(
`Preparing to publish ${argv.versionName}@${argv.tag} ${
argv.forReal === true ? '(for real)' : '(dry run)'
} [debug=${argv.debug}]`
).info();
await buildPackages(pkgNames);
if (argv.forReal === false) {
spinner.info('Dry run: Report tarball contents');
for (const pkgName of pkgNames) {
console.log(`\n========== ${pkgName} ==========\n`);
spinner.start(`Running npm pack --dry-run\n`);
try {
await spawnHelper('npm', ['pack', '--dry-run'], {
cwd: path.resolve(__dirname, `../../packages/${pkgName}`),
stdio: 'inherit',
});
} catch (e) {
spinner.fail(e.toString());
throw e;
Domain
Subdomains
Defined In
Source
Frequently Asked Questions
What does main() do?
main() is a function in the react codebase, defined in compiler/scripts/release/publish.js.
Where is main() defined?
main() is defined in compiler/scripts/release/publish.js at line 43.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free