Skip to content

Commit

Permalink
build: do not extract CLI for top-level packages
Browse files Browse the repository at this point in the history
  • Loading branch information
Planeshifter committed Nov 9, 2023
1 parent e924a7a commit 5ad662c
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions lib/node_modules/@stdlib/_tools/scripts/publish_packages.js
Original file line number Diff line number Diff line change
Expand Up @@ -617,6 +617,7 @@ function publish( pkg, clbk ) {
var ghpagesOpts;
var jscodeshift;
var pkgJsonPath;
var extractCLI;
var repoExists;
var readmePath;
var noBundles;
Expand All @@ -629,7 +630,6 @@ function publish( pkg, clbk ) {
var distPkg;
var pkgJSON;
var version;
var hasCLI;
var badges;
var branch;
var nLines;
Expand Down Expand Up @@ -782,7 +782,7 @@ function publish( pkg, clbk ) {
debug( 'Copying and populating README.md file...' );
readmePath = join( dist, 'README.md' );
readme = readFileSync( readmePath, 'utf-8' );
hasCLI = RE_CLI_USAGE_SECTION.test( readme );
extractCLI = !isTopLevelNS && RE_CLI_USAGE_SECTION.test( readme );

readme = replace( readme, RE_CLI_USAGE_SECTION, replacer );
readme = replace( readme, RE_C_USAGE_SECTION, replacer );
Expand All @@ -807,9 +807,9 @@ function publish( pkg, clbk ) {

branch = ( triggerRelease ) ? 'v'+version : 'main';
if ( contains( readme, '<section class="links">' ) ) {
readme = replace( readme, '<section class="links">', mainRepoSection( customLicense, branch, !noBundles, hasCLI ) );
readme = replace( readme, '<section class="links">', mainRepoSection( customLicense, branch, !noBundles, extractCLI ) );
} else {
readme += mainRepoSection( customLicense, branch, !noBundles, hasCLI );
readme += mainRepoSection( customLicense, branch, !noBundles, extractCLI );

Check warning on line 812 in lib/node_modules/@stdlib/_tools/scripts/publish_packages.js

View workflow job for this annotation

GitHub Actions / Lint Changed Files

This line has a length of 83. Maximum allowed is 80
readme += '\n\n';
readme += '</section>';
readme += '\n\n';
Expand Down Expand Up @@ -993,7 +993,7 @@ function publish( pkg, clbk ) {
'recursive': true
});
fs.copyFileSync( join( __dirname, 'templates', 'workflow_publish.yml.txt' ), join( dist, '.github', 'workflows', 'publish.yml' ) );
if ( hasCLI ) {
if ( extractCLI ) {
fs.copyFileSync( join( __dirname, 'templates', 'workflow_publish_cli.yml.txt' ), join( dist, '.github', 'workflows', 'publish_cli.yml' ) );
}
schedule = cronSchedule( '@stdlib/'+pkg );
Expand All @@ -1007,7 +1007,7 @@ function publish( pkg, clbk ) {
writeFileSync( join( dist, '.github', 'workflows', 'npm_downloads.yml' ), workflow );

if ( !noBundles ) {
if ( hasCLI ) {
if ( extractCLI ) {
fs.copyFileSync( join( __dirname, 'templates', 'workflow_productionize_cli.yml.txt' ), join( dist, '.github', 'workflows', 'productionize.yml' ) );
} else {
fs.copyFileSync( join( __dirname, 'templates', 'workflow_productionize.yml.txt' ), join( dist, '.github', 'workflows', 'productionize.yml' ) );
Expand Down Expand Up @@ -1049,7 +1049,7 @@ function publish( pkg, clbk ) {
fs.copyFileSync( join( __dirname, 'templates', 'CODE_OF_CONDUCT.md.txt' ), join( dist, 'CODE_OF_CONDUCT.md' ) );
fs.copyFileSync( join( __dirname, 'templates', 'CONTRIBUTING.md.txt' ), join( dist, 'CONTRIBUTING.md' ) );

if ( hasCLI ) {
if ( extractCLI ) {
writeFileSync( join( dist, 'branches.md' ), replace( replace( BRANCHES_WITH_CLI, '<pkg-path>', pth ), '<pkg>', distPkg ) );
} else {
writeFileSync( join( dist, 'branches.md' ), replace( replace( BRANCHES, '<pkg-path>', pth ), '<pkg>', distPkg ) );
Expand Down Expand Up @@ -1180,7 +1180,7 @@ function publish( pkg, clbk ) {

command = 'rm -f docs/repl.txt && rm -f docs/types/test.ts';
shell( command, opts );
if ( hasCLI ) {
if ( extractCLI ) {
// Delete the `bin` field from the `package.json` file:
delete pkgJSON.bin;

Expand Down Expand Up @@ -1297,7 +1297,7 @@ function publish( pkg, clbk ) {
out = INSTALLATION_SECTION_BASIC;
} else {
out = INSTALLATION_SECTION_BUNDLES;
out = out.replace( '<cli>', ( hasCLI ) ? INSTALLATION_SECTION_BUNDLES_CLI : '' );
out = out.replace( '<cli>', ( extractCLI ) ? INSTALLATION_SECTION_BUNDLES_CLI : '' );
}
out += '\n<section class="usage">';
return out;
Expand Down

0 comments on commit 5ad662c

Please sign in to comment.