You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
abp/npm/ng-packs/scripts/install-new-dependencies.ts

46 lines
1.2 KiB

import execa from 'execa';
import fse from 'fs-extra';
const updateAndInstall = async () => {
const { projects } = await fse.readJSON('../angular.json');
const projectNames = Object.keys(projects).filter(project => project !== 'dev-app');
const packageJson = await fse.readJSON('../package.json');
projectNames.forEach(project => {
// do not convert to async
const { dependencies = {}, peerDependencies = {}, name, version } = fse.readJSONSync(
`../packages/${project}/package.json`,
);
packageJson.devDependencies = {
...packageJson.devDependencies,
...dependencies,
...peerDependencies,
...{ [name]: `^${version}` },
};
packageJson.devDependencies = Object.keys(packageJson.devDependencies)
.sort()
.reduce((acc, key) => ({ ...acc, [key]: packageJson.devDependencies[key] }), {});
});
await fse.writeJSON('../package.json', packageJson, { spaces: 2 });
try {
await execa('yarn', ['install', '--ignore-scripts'], {
stdout: 'inherit',
cwd: '../',
});
} catch (error) {
console.error(error.stderr);
process.exit(1);
}
process.exit(0);
};
updateAndInstall();
export default updateAndInstall;