Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
' dependencies.');
} else {
console.log(appPackageJson.name + '@' + appPackageJson.version +
' \'package.json\' will be updated with Vulcan@' + vulcanPackageJson.version +
' dependencies.');
}
var backupDirPath = vulcanDirPath + 'bkp/';
if (!fs.existsSync(backupDirPath)) {
fs.mkdirSync(backupDirPath);
}
var backupFilePath = backupDirPath + 'package-' + Date.now() + '.json';
console.log('Saving a backup of \'' + appDirPath + 'package.json\' in \'' + backupFilePath + '\'');
fs.writeFileSync(backupFilePath, appPackageFile);
var updatedAppPackageJson = mergePackages.npm(
// IMPORTANT: parse again because mergePackages.npm mutates json
JSON.parse(appPackageFile),
[vulcanDirPath]
);
updatedAppPackageJson.vulcanVersion = vulcanPackageJson.version;
[
'dependencies',
'devDependencies',
'peerDependencies'
].forEach(function(key) {
if (updatedAppPackageJson[key]) {
updatedAppPackageJson[key] = sortObjectByKeyNameList(updatedAppPackageJson[key]);
}
const packageJson = JSON.parse(readFileSync(resolve(process.cwd(), 'package.json')));
const isDirectory = source => lstatSync(source).isDirectory();
const getDirectories = source => readdirSync(source).map(name => join(source, name)).filter(isDirectory);
const packages = getDirectories(resolve(process.cwd(), 'packages')).map(path => {
// We'll first try to read the legacy package.json file, under lib
if (existsSync(`${path}/lib/`)) {
return `${path}/lib/`;
// If that doesn't work out, we're most likely dealing with the new Angular 6 structure,
// where the package.json file is listed directly under the package directory
} else if (existsSync(`${path}/src/`)) {
return `${path}/`
}
});
const result = mergePackages.npm(packageJson, packages);
if (!preserve) {
return {
dependencies: result.dependencies || {},
peerDependencies: result.peerDependencies || {},
};
}
return result;
};
module.exports.getNPMDependencies = ({ preserve = false } = {}) => {
const packageJson = JSON.parse(readFileSync(resolve(process.cwd(), 'package.json')));
const isDirectory = source => lstatSync(source).isDirectory();
const getDirectories = source => readdirSync(source).map(name => join(source, name)).filter(isDirectory);
const packages = getDirectories(resolve(process.cwd(), 'packages')).map(path => `${path}/`);
const result = mergePackages.npm(packageJson, packages);
if (!preserve) {
return {
dependencies: result.dependencies || {},
peerDependencies: result.peerDependencies || {},
};
}
return result;
};