UNPKG

@o3r/core

Version:
41 lines 1.67 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.o3rBasicUpdates = o3rBasicUpdates; const schematics_1 = require("@o3r/schematics"); const ngUpdateScript = (tree, packageJsonObj, packageJsonPath = '/package.json') => { if (!packageJsonObj.scripts) { packageJsonObj.scripts = {}; } packageJsonObj.scripts['update:otter'] = 'ng update @o3r/core'; tree.overwrite(packageJsonPath, JSON.stringify(packageJsonObj, null, 2)); }; /** * Package.json updates to include o3r ng update script * @param pName project name * @param _o3rCoreVersion * @param projectType */ function o3rBasicUpdates(pName, _o3rCoreVersion, projectType) { return (tree, context) => { const workspace = (0, schematics_1.getWorkspaceConfig)(tree); if (!workspace) { context.logger.error('No workspace detected'); return tree; } if (!projectType) { // at the root of the monorepo const rootPackageJsonPath = '/package.json'; if (tree.exists(rootPackageJsonPath)) { const rootPackageJsonObject = tree.readJson(rootPackageJsonPath); ngUpdateScript(tree, rootPackageJsonObject, rootPackageJsonPath); } } Object.entries(workspace.projects) .filter(([name]) => !pName || pName === name) .forEach(([, workspaceProject]) => { const packageJson = (0, schematics_1.readPackageJson)(tree, workspaceProject); ngUpdateScript(tree, packageJson, `${workspaceProject.root}/package.json`); }); return tree; }; } //# sourceMappingURL=index.js.map