UNPKG

apollo-angular

Version:

Use your GraphQL data in your Angular app, with the Apollo Client

1 lines 2.72 kB
{"version":3,"file":"file.cjs","sourceRoot":"","sources":["../../../schematics/utils/file.cts"],"names":[],"mappings":";;;AAAA,iCAAiC;AACjC,2DAAuE;AAEvE,SAAgB,cAAc,CAAC,IAAU,EAAE,IAAY;IACrD,MAAM,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAE/B,IAAI,MAAM,KAAK,IAAI,EAAE,CAAC;QACpB,MAAM,IAAI,gCAAmB,CAAC,iBAAiB,IAAI,GAAG,CAAC,CAAC;IAC1D,CAAC;IAED,OAAO,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;AAClC,CAAC;AARD,wCAQC;AAED,SAAgB,SAAS,CAAC,IAAY,EAAE,OAAe;IACrD,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC,cAAc,CAAC,IAAI,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,CAAC;IAEjE,IAAI,KAAK,EAAE,CAAC;QACV,MAAM,IAAI,gCAAmB,CAAC,KAAK,CAAC,WAAW,CAAC,QAAQ,EAAE,CAAC,CAAC;IAC9D,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC;AARD,8BAQC;AAED;;;;GAIG;AACH,SAAgB,WAAW,CAAC,IAAU,EAAE,IAAY;IAClD,OAAO,SAAS,CAAC,IAAI,EAAE,cAAc,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC;AACrD,CAAC;AAFD,kCAEC;AAED;;;;KAIK;AACL,SAAgB,uBAAuB,CAAC,IAAU,EAAE,IAAY;IAC9D,MAAM,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC/B,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,MAAM,IAAI,gCAAmB,CAAC,kBAAkB,IAAI,GAAG,CAAC,CAAC;IAC3D,CAAC;IAED,MAAM,OAAO,GAAG,MAAM,CAAC,QAAQ,EAAE,CAAC;IAClC,MAAM,UAAU,GAAG,EAAE,CAAC,gBAAgB,CAAC,IAAI,EAAE,OAAO,EAAE,EAAE,CAAC,YAAY,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;IAEpF,OAAO,UAAU,CAAC;AACpB,CAAC;AAVD,0DAUC","sourcesContent":["import * as ts from 'typescript';\nimport { SchematicsException, Tree } from '@angular-devkit/schematics';\n\nexport function getFileContent(host: Tree, path: string): string {\n const buffer = host.read(path);\n\n if (buffer === null) {\n throw new SchematicsException(`Couldn't read ${path}!`);\n }\n\n return buffer.toString('utf-8');\n}\n\nexport function parseJSON(path: string, content: string) {\n const { config, error } = ts.readConfigFile(path, () => content);\n\n if (error) {\n throw new SchematicsException(error.messageText.toString());\n }\n\n return config;\n}\n\n/**\n * Returns the parsed content of a json file.\n * @param host {Tree} The source tree.\n * @param path {String} The path to the file to read. Relative to the root of the tree.\n */\nexport function getJsonFile(host: Tree, path: string) {\n return parseJSON(path, getFileContent(host, path));\n}\n\n/**\n * Reads file from given path and Returns TypeScript source file.\n * @param host {Tree} The source tree.\n * @param path {String} The path to the file to read. Relative to the root of the tree.\n * */\nexport function getTypeScriptSourceFile(host: Tree, path: string): ts.SourceFile {\n const buffer = host.read(path);\n if (!buffer) {\n throw new SchematicsException(`Could not find ${path}!`);\n }\n\n const content = buffer.toString();\n const sourceFile = ts.createSourceFile(path, content, ts.ScriptTarget.Latest, true);\n\n return sourceFile;\n}\n"]}