UNPKG

3.15 kBSource Map (JSON)View Raw
1{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../modules/schematics/src/selector/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,yDAaoC;AACpC,yDAA+E;AAG/E,mBAAyB,OAAwB;IAC/C,OAAO,UAAC,IAAU,EAAE,OAAyB;QAC3C,OAAO,CAAC,IAAI,GAAG,IAAA,gCAAc,EAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QAE7C,IAAM,UAAU,GAAG,IAAA,2BAAS,EAAC,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC;QAC/D,OAAO,CAAC,IAAI,GAAG,UAAU,CAAC,IAAI,CAAC;QAC/B,OAAO,CAAC,IAAI,GAAG,UAAU,CAAC,IAAI,CAAC;QAE/B,IAAM,cAAc,GAAG,IAAA,kBAAK,EAAC,IAAA,gBAAG,EAAC,SAAS,CAAC,EAAE;YAC3C,OAAO,CAAC,SAAS;gBACf,CAAC,CAAC,IAAA,mBAAM,EAAC,UAAC,IAAI,IAAK,OAAA,CAAC,IAAI,CAAC,QAAQ,CAAC,mBAAmB,CAAC,EAAnC,CAAmC,CAAC;gBACvD,CAAC,CAAC,IAAA,iBAAI,GAAE;YACV,IAAA,2BAAc,EAAC,+BACV,6BAAW,KACd,SAAS,EAAE,UAAC,CAAS;oBACnB,OAAA,6BAAW,CAAC,KAAK,CACf,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,EACrB,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,CACjC;gBAHD,CAGC,EACH,WAAW,EAAE,UAAG,YAAY,CAAC,OAAO,CAAC,SAAG,6BAAW,CAAC,SAAS,CAC3D,OAAO,CAAC,IAAI,CACb,aAAU,KACP,OAAkB,CAChB,CAAC;YACT,IAAA,iBAAI,EAAC,UAAU,CAAC,IAAI,CAAC;SACtB,CAAC,CAAC;QAEH,OAAO,IAAA,kBAAK,EAAC,CAAC,IAAA,2BAAc,EAAC,IAAA,kBAAK,EAAC,CAAC,IAAA,sBAAS,EAAC,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAChE,IAAI,EACJ,OAAO,CACR,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC;AAhCD,4BAgCC;AAED,SAAS,YAAY,CAAC,OAAwB;IAC5C,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;QACpB,OAAO,6BAAW,CAAC,WAAW,CAC5B,OAAO,CAAC,KAAK,EACb,OAAO,CAAC,IAAI,EACZ,UAAU,EACV,6BAAW,CAAC,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC,CACpC,CAAC;IACJ,CAAC;IAED,OAAO,EAAE,CAAC;AACZ,CAAC","sourcesContent":["import {\n Rule,\n SchematicContext,\n Tree,\n apply,\n applyTemplates,\n branchAndMerge,\n chain,\n filter,\n mergeWith,\n move,\n noop,\n url,\n} from '@angular-devkit/schematics';\nimport { getProjectPath, parseName, stringUtils } from '../../schematics-core';\nimport { Schema as SelectorOptions } from './schema';\n\nexport default function (options: SelectorOptions): Rule {\n return (host: Tree, context: SchematicContext) => {\n options.path = getProjectPath(host, options);\n\n const parsedPath = parseName(options.path, options.name || '');\n options.name = parsedPath.name;\n options.path = parsedPath.path;\n\n const templateSource = apply(url('./files'), [\n options.skipTests\n ? filter((path) => !path.endsWith('.spec.ts.template'))\n : noop(),\n applyTemplates({\n ...stringUtils,\n 'if-flat': (s: string) =>\n stringUtils.group(\n options.flat ? '' : s,\n options.group ? 'selectors' : ''\n ),\n reducerPath: `${relativePath(options)}${stringUtils.dasherize(\n options.name\n )}.reducer`,\n ...(options as object),\n } as any),\n move(parsedPath.path),\n ]);\n\n return chain([branchAndMerge(chain([mergeWith(templateSource)]))])(\n host,\n context\n );\n };\n}\n\nfunction relativePath(options: SelectorOptions) {\n if (options.feature) {\n return stringUtils.featurePath(\n options.group,\n options.flat,\n 'reducers',\n stringUtils.dasherize(options.name)\n );\n }\n\n return '';\n}\n"]}
\No newline at end of file