a zip code crypto-currency system good for red ONLY

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. var fs_1 = require("fs");
  4. var path_1 = require("path");
  5. var util_1 = require("../deep-linking/util");
  6. var config_1 = require("../util/config");
  7. var Constants = require("../util/constants");
  8. var glob_util_1 = require("../util/glob-util");
  9. var helpers_1 = require("../util/helpers");
  10. var typescript_utils_1 = require("../util/typescript-utils");
  11. function getTsFilePaths(context) {
  12. var tsFileGlobString = path_1.join(context.srcDir, '**', '*.ts');
  13. return glob_util_1.globAll([tsFileGlobString]).then(function (results) {
  14. return results.map(function (result) { return result.absolutePath; });
  15. });
  16. }
  17. exports.getTsFilePaths = getTsFilePaths;
  18. function readTsFiles(context, tsFilePaths) {
  19. var promises = tsFilePaths.map(function (tsFilePath) {
  20. var promise = helpers_1.readFileAsync(tsFilePath);
  21. promise.then(function (fileContent) {
  22. context.fileCache.set(tsFilePath, { path: tsFilePath, content: fileContent });
  23. });
  24. return promise;
  25. });
  26. return Promise.all(promises);
  27. }
  28. exports.readTsFiles = readTsFiles;
  29. function generateAndWriteNgModules(fileCache) {
  30. fileCache.getAll().forEach(function (file) {
  31. var sourceFile = typescript_utils_1.getTypescriptSourceFile(file.path, file.content);
  32. var deepLinkDecoratorData = util_1.getDeepLinkDecoratorContentForSourceFile(sourceFile);
  33. if (deepLinkDecoratorData) {
  34. // we have a valid DeepLink decorator
  35. var correspondingNgModulePath = util_1.getNgModulePathFromCorrespondingPage(file.path);
  36. var ngModuleFile = fileCache.get(correspondingNgModulePath);
  37. if (!ngModuleFile) {
  38. // the ngModule file does not exist, so go ahead and create a default one
  39. var defaultNgModuleContent = util_1.generateDefaultDeepLinkNgModuleContent(file.path, deepLinkDecoratorData.className);
  40. var ngModuleFilePath = helpers_1.changeExtension(file.path, helpers_1.getStringPropertyValue(Constants.ENV_NG_MODULE_FILE_NAME_SUFFIX));
  41. fs_1.writeFileSync(ngModuleFilePath, defaultNgModuleContent);
  42. }
  43. }
  44. });
  45. }
  46. exports.generateAndWriteNgModules = generateAndWriteNgModules;
  47. function run() {
  48. var context = config_1.generateContext();
  49. // find out what files to read
  50. return getTsFilePaths(context).then(function (filePaths) {
  51. // read the files
  52. return readTsFiles(context, filePaths);
  53. }).then(function () {
  54. generateAndWriteNgModules(context.fileCache);
  55. });
  56. }
  57. run();