diff --git a/.scripts/common.js b/.scripts/common.js index be2a21604d..1a93fb4f07 100644 --- a/.scripts/common.js +++ b/.scripts/common.js @@ -268,11 +268,7 @@ function updatePackageVersions(tasks, packages, version) { } function updatePackageVersion(tasks, package, version) { - let projectRoot = projectPath(package); - - if (package === 'packages/angular-server' || package === 'angular') { - projectRoot = path.join(projectRoot, 'dist') - } + const projectRoot = projectPath(package); tasks.push({ title: `${package}: update package.json ${tc.dim(`(${version})`)}`, @@ -282,6 +278,22 @@ function updatePackageVersion(tasks, package, version) { }); } +function copyPackageToDist(tasks, packages) { + packages.forEach(package => { + const projectRoot = projectPath(package); + + // angular and angular-server are the only packages that publish dist + if (package !== 'angular' && package !== 'packages/angular-server') { + return; + } + + tasks.push({ + title: `${package}: Copy package.json to dist`, + task: () => execa('node', ['copy-package.js', package], { cwd: path.join(rootDir, '.scripts') }) + }); + }); +} + function publishPackages(tasks, packages, version, tag = 'latest') { // first verify version packages.forEach(package => { @@ -351,6 +363,7 @@ module.exports = { isValidVersion, isVersionGreater, copyCDNLoader, + copyPackageToDist, packages, packagePath, prepareDevPackage, diff --git a/.scripts/copy-package.js b/.scripts/copy-package.js new file mode 100644 index 0000000000..34e2010976 --- /dev/null +++ b/.scripts/copy-package.js @@ -0,0 +1,12 @@ + +// copy the package.json to the directory to dist to publish it + +const fs = require('fs'); +const path = require('path'); + +const package = process.argv[2]; + +const srcPath = path.join(__dirname, '..', package, 'package.json'); +let packageContent = fs.readFileSync(srcPath, 'utf-8'); + +fs.writeFileSync(path.join(__dirname, '..', package, 'dist', 'package.json'), packageContent); diff --git a/.scripts/prepare.js b/.scripts/prepare.js index 0d37e4bbce..fe17a73959 100644 --- a/.scripts/prepare.js +++ b/.scripts/prepare.js @@ -113,6 +113,9 @@ async function preparePackages(packages, version, install) { // add update package.json of each project common.updatePackageVersions(tasks, packages, version); + // copy package.json to dist + common.copyPackageToDist(tasks, packages); + // generate changelog generateChangeLog(tasks);