Skip to content

Commit

Permalink
feat(publish): support package publishing from a subdirectory
Browse files Browse the repository at this point in the history
Follows package.json `distDir` while package publishing (and yalc publish)
...because uirouter/angular builds a publishable package in `./dist` using ng-packagr.
  • Loading branch information
christopherthielen committed Oct 4, 2019
1 parent 8d10df0 commit b609066
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
4 changes: 4 additions & 0 deletions publish_yalc_package.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,13 @@ function publishYalcPackage(installTargetDir, installSource, flags) {
}
}

// If ngPackage is found in package.json, the directory to be published is actually ./dist
const distDir = !!pkgJson.distDir || '.';
if (!flags.noPublish) {
shelljs.pushd(distDir);
// Publish to local yalc registry
util._exec('npx yalc publish');
shelljs.popd();
}
} finally {
shelljs.mv(BUILD_TEMP_DIR, installTargetDir);
Expand Down
3 changes: 3 additions & 0 deletions release.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,10 @@ if (!yargs.argv.dryrun) {

// Publish to NPM and push to github
if (!yargs.argv.dryrun) {
const distDir = packageJson.distDir || '.';
shelljs.pushd(distDir);
_exec(`npm publish`);
shelljs.popd();
_exec(`git tag ${version}`);
_exec(`git push origin master`);
_exec(`git push origin ${version}`);
Expand Down
3 changes: 3 additions & 0 deletions test_downstream_projects.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ function localPublish(packageDir) {
// Un-yalc any deps in the package.json (after building, but before yalc publishing)
const packageString = fs.readFileSync('package.json');
const package = JSON.parse(packageString);
const distDir = !!package.distDir || '.';
const { resolutions = {}, dependencies = {}, devDependencies = {} } = package;

const yalcLockfile = fs.existsSync('yalc.lock') ? JSON.parse(fs.readFileSync('yalc.lock')) : {};
Expand All @@ -75,7 +76,9 @@ function localPublish(packageDir) {
fs.writeFileSync('package.json', JSON.stringify(package, null, 2));
}

shelljs.pushd(distDir);
util._exec('npx yalc publish');
shelljs.popd();

if (yalcPackages.length) {
console.log(` ===> Restoring yalc'd manifest ${packageDir}/package.json <===`)
Expand Down

0 comments on commit b609066

Please sign in to comment.