Skip to content

Commit b609066

Browse files
feat(publish): support package publishing from a subdirectory
Follows package.json `distDir` while package publishing (and yalc publish) ...because uirouter/angular builds a publishable package in `./dist` using ng-packagr.
1 parent 8d10df0 commit b609066

File tree

3 files changed

+10
-0
lines changed

3 files changed

+10
-0
lines changed

publish_yalc_package.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,13 @@ function publishYalcPackage(installTargetDir, installSource, flags) {
9292
}
9393
}
9494

95+
// If ngPackage is found in package.json, the directory to be published is actually ./dist
96+
const distDir = !!pkgJson.distDir || '.';
9597
if (!flags.noPublish) {
98+
shelljs.pushd(distDir);
9699
// Publish to local yalc registry
97100
util._exec('npx yalc publish');
101+
shelljs.popd();
98102
}
99103
} finally {
100104
shelljs.mv(BUILD_TEMP_DIR, installTargetDir);

release.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,10 @@ if (!yargs.argv.dryrun) {
111111

112112
// Publish to NPM and push to github
113113
if (!yargs.argv.dryrun) {
114+
const distDir = packageJson.distDir || '.';
115+
shelljs.pushd(distDir);
114116
_exec(`npm publish`);
117+
shelljs.popd();
115118
_exec(`git tag ${version}`);
116119
_exec(`git push origin master`);
117120
_exec(`git push origin ${version}`);

test_downstream_projects.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ function localPublish(packageDir) {
5353
// Un-yalc any deps in the package.json (after building, but before yalc publishing)
5454
const packageString = fs.readFileSync('package.json');
5555
const package = JSON.parse(packageString);
56+
const distDir = !!package.distDir || '.';
5657
const { resolutions = {}, dependencies = {}, devDependencies = {} } = package;
5758

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

79+
shelljs.pushd(distDir);
7880
util._exec('npx yalc publish');
81+
shelljs.popd();
7982

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

0 commit comments

Comments
 (0)