chore(scripts): update main and dist package files for angular

This commit is contained in:
Brandy Carney
2020-01-03 16:58:29 -05:00
parent cb94d8d978
commit 0feace4f89
3 changed files with 33 additions and 5 deletions

View File

@ -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,

12
.scripts/copy-package.js Normal file
View File

@ -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);

View File

@ -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);