UNPKG

@rxap/plugin-library

Version:

This package provides generators and executors for managing and maintaining Nx plugin libraries. It includes functionality for generating index exports, fixing dependencies, generating JSON schemas, and more. It helps streamline the development process fo

60 lines 3.32 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.updateProjectPackageJson = updateProjectPackageJson; const devkit_1 = require("@nx/devkit"); const workspace_utilities_1 = require("@rxap/workspace-utilities"); const path_1 = require("path"); function updateProjectPackageJson(tree, project, projectName, rootPackageJson) { var _a, _b, _c, _d, _e, _f; const packageJson = (0, devkit_1.readJson)(tree, (0, path_1.join)(project.root, 'package.json')); const scope = (0, workspace_utilities_1.GetWorkspaceScope)(tree); (_a = packageJson.scripts) !== null && _a !== void 0 ? _a : (packageJson.scripts = {}); if (Object.keys(packageJson.scripts).length === 0) { delete packageJson.scripts; } if (packageJson.name && !packageJson.name.startsWith('@') && packageJson.name !== 'rxap') { const newName = `${scope}/${projectName}`; updatePathsAliasInBaseTsConfig(tree, project, packageJson.name, newName); packageJson.name = newName; } (_b = packageJson.publishConfig) !== null && _b !== void 0 ? _b : (packageJson.publishConfig = {}); packageJson.publishConfig.access = 'public'; const output = (0, workspace_utilities_1.GetBuildOutputForProject)(project); packageJson.publishConfig.directory = (0, path_1.relative)(project.root, output); // add common properties packageJson.keywords = [ ...new Set([ ...((_c = packageJson.keywords) !== null && _c !== void 0 ? _c : []), ...((_d = rootPackageJson.keywords) !== null && _d !== void 0 ? _d : []), ...((_e = project.tags) !== null && _e !== void 0 ? _e : []), projectName, ]), ]; if (rootPackageJson.homepage) { packageJson.homepage = (0, path_1.join)(rootPackageJson.homepage, project.root); } packageJson.bugs = rootPackageJson.bugs; (_f = packageJson.license) !== null && _f !== void 0 ? _f : (packageJson.license = rootPackageJson.license); packageJson.contributors = rootPackageJson.contributors; packageJson.funding = rootPackageJson.funding; packageJson.repository = rootPackageJson.repository; if (packageJson.repository && typeof packageJson.repository === 'object') { packageJson.repository.directory = project.root; } packageJson.author = rootPackageJson.author; (0, devkit_1.writeJson)(tree, (0, path_1.join)(project.root, 'package.json'), packageJson); } function updatePathsAliasInBaseTsConfig(tree, project, currentPackageJsonName, newPackageJsonName) { (0, workspace_utilities_1.UpdateTsConfigJson)(tree, tsConfig => { var _a, _b; var _c; (_a = tsConfig.compilerOptions) !== null && _a !== void 0 ? _a : (tsConfig.compilerOptions = {}); (_b = (_c = tsConfig.compilerOptions).paths) !== null && _b !== void 0 ? _b : (_c.paths = {}); if (tsConfig.compilerOptions.paths[currentPackageJsonName]) { const aliasList = tsConfig.compilerOptions.paths[currentPackageJsonName]; delete tsConfig.compilerOptions.paths[currentPackageJsonName]; tsConfig.compilerOptions.paths[newPackageJsonName] = aliasList; } }, { infix: tree.exists('tsconfig.base.json') ? 'base' : undefined }); } //# sourceMappingURL=update-project-package-json.js.map