UNPKG

2.68 kBSource Map (JSON)View Raw
1{"version":3,"file":"update.js","sourceRoot":"","sources":["../../../../../modules/schematics/schematics-core/utility/update.ts"],"names":[],"mappings":";;;AAAA,yDAKoC;AAEpC,SAAgB,aAAa,CAAC,IAAY;IACxC,OAAO,UAAC,IAAU,EAAE,OAAyB;QAC3C,IAAM,OAAO,GAAG,eAAe,CAAC;QAChC,IAAM,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAClC,IAAI,MAAM,KAAK,IAAI,EAAE,CAAC;YACpB,MAAM,IAAI,gCAAmB,CAAC,6BAA6B,CAAC,CAAC;QAC/D,CAAC;QACD,IAAM,OAAO,GAAG,MAAM,CAAC,QAAQ,EAAE,CAAC;QAClC,IAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;QAEhC,IAAI,GAAG,KAAK,IAAI,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC;YAClE,MAAM,IAAI,gCAAmB,CAAC,4BAA4B,CAAC,CAAC;QAC9D,CAAC;QAED,IAAM,oBAAoB,GAAG,CAAC,cAAc,EAAE,iBAAiB,CAAC,CAAC;QAEjE,oBAAoB,CAAC,OAAO,CAAC,UAAC,QAAQ;YACpC,IAAM,WAAW,GAAG,gBAAS,IAAI,CAAE,CAAC;YAEpC,IAAI,GAAG,CAAC,QAAQ,CAAC,IAAI,GAAG,CAAC,QAAQ,CAAC,CAAC,WAAW,CAAC,EAAE,CAAC;gBAChD,IAAM,SAAS,GAAG,GAAG,CAAC,QAAQ,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC;gBAChD,IAAM,MAAM,GAAG,KAAK,CAAC,SAAS,EAAE,GAAG,CAAC,IAAI,KAAK,CAAC,SAAS,EAAE,GAAG,CAAC,CAAC;gBAE9D,GAAG,CAAC,QAAQ,CAAC,CAAC,WAAW,CAAC,GAAG,UAAG,MAAM,UAAO,CAAC;YAChD,CAAC;QACH,CAAC,CAAC,CAAC;QAEH,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,IAAI,CAAC,SAAS,CAAC,GAAG,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;QAEtD,OAAO,IAAI,CAAC;IACd,CAAC,CAAC;AACJ,CAAC;AA/BD,sCA+BC;AAED,SAAS,KAAK,CAAC,KAAa,EAAE,IAAY;IACxC,OAAO,KAAK,KAAK,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC;AACpC,CAAC","sourcesContent":["import {\n Rule,\n SchematicContext,\n Tree,\n SchematicsException,\n} from '@angular-devkit/schematics';\n\nexport function updatePackage(name: string): Rule {\n return (tree: Tree, context: SchematicContext) => {\n const pkgPath = '/package.json';\n const buffer = tree.read(pkgPath);\n if (buffer === null) {\n throw new SchematicsException('Could not read package.json');\n }\n const content = buffer.toString();\n const pkg = JSON.parse(content);\n\n if (pkg === null || typeof pkg !== 'object' || Array.isArray(pkg)) {\n throw new SchematicsException('Error reading package.json');\n }\n\n const dependencyCategories = ['dependencies', 'devDependencies'];\n\n dependencyCategories.forEach((category) => {\n const packageName = `@ngrx/${name}`;\n\n if (pkg[category] && pkg[category][packageName]) {\n const firstChar = pkg[category][packageName][0];\n const suffix = match(firstChar, '^') || match(firstChar, '~');\n\n pkg[category][packageName] = `${suffix}6.0.0`;\n }\n });\n\n tree.overwrite(pkgPath, JSON.stringify(pkg, null, 2));\n\n return tree;\n };\n}\n\nfunction match(value: string, test: string) {\n return value === test ? test : '';\n}\n"]}
\No newline at end of file