@simondotm/nx-firebase 1.1.0 → 2.0.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (128) hide show
  1. package/README.md +14 -27
  2. package/executors.json +0 -8
  3. package/generators.json +11 -0
  4. package/package.json +5 -4
  5. package/src/generators/application/application.d.ts +3 -3
  6. package/src/generators/application/application.js +119 -19
  7. package/src/generators/application/application.js.map +1 -1
  8. package/src/generators/application/files/readme.md__tmpl__ +12 -9
  9. package/src/generators/application/files_firebase/firebase.json__tmpl__ +6 -13
  10. package/src/generators/application/files_workspace/{firebase.__name__.json__tmpl__ → firebase.__projectName__.json__tmpl__} +6 -13
  11. package/src/generators/application/lib/create-files.js +10 -25
  12. package/src/generators/application/lib/create-files.js.map +1 -1
  13. package/src/generators/application/lib/index.d.ts +0 -3
  14. package/src/generators/application/lib/index.js +0 -3
  15. package/src/generators/application/lib/index.js.map +1 -1
  16. package/src/generators/application/schema.d.ts +3 -11
  17. package/src/generators/application/schema.json +0 -41
  18. package/src/generators/function/files/package.json__tmpl__ +19 -0
  19. package/src/generators/function/files/readme.md__tmpl__ +31 -0
  20. package/src/generators/function/function.d.ts +14 -0
  21. package/src/generators/function/function.js +77 -0
  22. package/src/generators/function/function.js.map +1 -0
  23. package/src/generators/function/lib/add-function.d.ts +3 -0
  24. package/src/generators/function/lib/add-function.js +29 -0
  25. package/src/generators/function/lib/add-function.js.map +1 -0
  26. package/src/generators/function/lib/create-files.d.ts +9 -0
  27. package/src/generators/function/lib/create-files.js +37 -0
  28. package/src/generators/function/lib/create-files.js.map +1 -0
  29. package/src/generators/function/lib/delete-files.js.map +1 -0
  30. package/src/generators/function/lib/index.d.ts +3 -0
  31. package/src/generators/function/lib/index.js +7 -0
  32. package/src/generators/function/lib/index.js.map +1 -0
  33. package/src/generators/function/lib/update-project.d.ts +3 -0
  34. package/src/generators/function/lib/update-project.js +52 -0
  35. package/src/generators/function/lib/update-project.js.map +1 -0
  36. package/src/generators/function/schema.d.ts +51 -0
  37. package/src/generators/function/schema.json +57 -0
  38. package/src/generators/init/init.d.ts +1 -1
  39. package/src/generators/init/init.js +2 -6
  40. package/src/generators/init/init.js.map +1 -1
  41. package/src/generators/init/lib/add-dependencies.js +3 -4
  42. package/src/generators/init/lib/add-dependencies.js.map +1 -1
  43. package/src/generators/init/lib/add-git-ignore-entry.d.ts +1 -1
  44. package/src/generators/init/lib/add-git-ignore-entry.js +1 -0
  45. package/src/generators/init/lib/add-git-ignore-entry.js.map +1 -1
  46. package/src/generators/init/schema.d.ts +4 -4
  47. package/src/generators/init/schema.json +8 -7
  48. package/src/generators/sync/lib/firebase-changes.d.ts +3 -0
  49. package/src/generators/sync/lib/firebase-changes.js +102 -0
  50. package/src/generators/sync/lib/firebase-changes.js.map +1 -0
  51. package/src/generators/sync/lib/firebase-configs.d.ts +3 -0
  52. package/src/generators/sync/lib/firebase-configs.js +61 -0
  53. package/src/generators/sync/lib/firebase-configs.js.map +1 -0
  54. package/src/generators/sync/lib/firebase-projects.d.ts +20 -0
  55. package/src/generators/sync/lib/firebase-projects.js +75 -0
  56. package/src/generators/sync/lib/firebase-projects.js.map +1 -0
  57. package/src/generators/sync/lib/firebase-workspace.d.ts +3 -0
  58. package/src/generators/sync/lib/firebase-workspace.js +15 -0
  59. package/src/generators/sync/lib/firebase-workspace.js.map +1 -0
  60. package/src/generators/sync/lib/index.d.ts +7 -0
  61. package/src/generators/sync/lib/index.js +11 -0
  62. package/src/generators/sync/lib/index.js.map +1 -0
  63. package/src/generators/sync/lib/tags.d.ts +14 -0
  64. package/src/generators/sync/lib/tags.js +43 -0
  65. package/src/generators/sync/lib/tags.js.map +1 -0
  66. package/src/generators/sync/lib/types.d.ts +46 -0
  67. package/src/generators/sync/lib/types.js +5 -0
  68. package/src/generators/sync/lib/types.js.map +1 -0
  69. package/src/generators/sync/schema.d.ts +5 -0
  70. package/src/generators/sync/schema.json +19 -0
  71. package/src/generators/sync/sync.d.ts +8 -0
  72. package/src/generators/sync/sync.js +170 -0
  73. package/src/generators/sync/sync.js.map +1 -0
  74. package/src/utils/debug.d.ts +4 -0
  75. package/src/utils/debug.js +25 -0
  76. package/src/utils/debug.js.map +1 -0
  77. package/src/utils/firebase-config.d.ts +77 -0
  78. package/src/utils/firebase-config.js +52 -0
  79. package/src/utils/firebase-config.js.map +1 -0
  80. package/src/utils/index.d.ts +3 -0
  81. package/src/utils/index.js +3 -0
  82. package/src/utils/index.js.map +1 -1
  83. package/src/utils/project-name.d.ts +5 -0
  84. package/src/utils/project-name.js +38 -0
  85. package/src/utils/project-name.js.map +1 -0
  86. package/src/utils/types.d.ts +1 -1
  87. package/src/{generators/application/lib → utils}/update-tsconfig.d.ts +1 -2
  88. package/src/{generators/application/lib → utils}/update-tsconfig.js +5 -5
  89. package/src/utils/update-tsconfig.js.map +1 -0
  90. package/src/utils/versions.d.ts +1 -0
  91. package/src/utils/versions.js +5 -4
  92. package/src/utils/versions.js.map +1 -1
  93. package/src/utils/workspace.d.ts +1 -1
  94. package/src/executors/build/build.d.ts +0 -8
  95. package/src/executors/build/build.js +0 -82
  96. package/src/executors/build/build.js.map +0 -1
  97. package/src/executors/build/lib/copy-dependencies.d.ts +0 -3
  98. package/src/executors/build/lib/copy-dependencies.js +0 -53
  99. package/src/executors/build/lib/copy-dependencies.js.map +0 -1
  100. package/src/executors/build/lib/firebase-build.d.ts +0 -2
  101. package/src/executors/build/lib/firebase-build.js +0 -16
  102. package/src/executors/build/lib/firebase-build.js.map +0 -1
  103. package/src/executors/build/lib/get-dependencies.d.ts +0 -8
  104. package/src/executors/build/lib/get-dependencies.js +0 -87
  105. package/src/executors/build/lib/get-dependencies.js.map +0 -1
  106. package/src/executors/build/lib/index.d.ts +0 -1
  107. package/src/executors/build/lib/index.js +0 -5
  108. package/src/executors/build/lib/index.js.map +0 -1
  109. package/src/executors/build/lib/rewrite-package.d.ts +0 -8
  110. package/src/executors/build/lib/rewrite-package.js +0 -44
  111. package/src/executors/build/lib/rewrite-package.js.map +0 -1
  112. package/src/executors/build/schema.d.ts +0 -1
  113. package/src/executors/build/schema.json +0 -167
  114. package/src/generators/application/files/package.json__tmpl__ +0 -21
  115. package/src/generators/application/lib/add-project.d.ts +0 -39
  116. package/src/generators/application/lib/add-project.js +0 -115
  117. package/src/generators/application/lib/add-project.js.map +0 -1
  118. package/src/generators/application/lib/delete-files.js.map +0 -1
  119. package/src/generators/application/lib/normalize-options.d.ts +0 -5
  120. package/src/generators/application/lib/normalize-options.js +0 -44
  121. package/src/generators/application/lib/normalize-options.js.map +0 -1
  122. package/src/generators/application/lib/update-tsconfig.js.map +0 -1
  123. package/src/utils/e2ePatch.d.ts +0 -2
  124. package/src/utils/e2ePatch.js +0 -135
  125. package/src/utils/e2ePatch.js.map +0 -1
  126. /package/src/generators/{application/files/src/index.ts__tmpl__ → function/files/src/main.ts__tmpl__} +0 -0
  127. /package/src/generators/{application → function}/lib/delete-files.d.ts +0 -0
  128. /package/src/generators/{application → function}/lib/delete-files.js +0 -0
@@ -0,0 +1,170 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.syncGenerator = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const devkit_1 = require("@nx/devkit");
6
+ const utils_1 = require("../../utils");
7
+ const init_1 = require("../init/init");
8
+ const lib_1 = require("./lib");
9
+ const FUNCTIONS_DEPLOY_MATCHER = /(--only[ =]functions:)([^\s]+)/;
10
+ /**
11
+ * Sync firebase workspace
12
+ *
13
+ */
14
+ function syncGenerator(tree, options) {
15
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
16
+ const tasks = [];
17
+ // initialise plugin
18
+ const initTask = yield (0, init_1.default)(tree, {});
19
+ tasks.push(initTask);
20
+ // change the firebase project for an nx firebase app project
21
+ if (options.project) {
22
+ // --project option requires --app option to be specified
23
+ if (!options.app) {
24
+ throw new Error('--app not specified for --project option');
25
+ }
26
+ // validate app parameter
27
+ const project = (0, devkit_1.readProjectConfiguration)(tree, options.app);
28
+ if (!(0, lib_1.isFirebaseApp)(project)) {
29
+ throw new Error(`Project '${options.app}' is not a Firebase application.`);
30
+ }
31
+ (0, lib_1.debugInfo)(`- changing project for ${options.app} to ${options.project}`);
32
+ if ((0, lib_1.updateFirebaseAppDeployProject)(project.targets.firebase, options)) {
33
+ (0, devkit_1.updateProjectConfiguration)(tree, options.app, project);
34
+ }
35
+ return;
36
+ }
37
+ // otherwise, sync the workspace.
38
+ // build lists of firebase apps & functions that have been deleted or renamed
39
+ (0, lib_1.debugInfo)('- Syncing workspace');
40
+ const workspace = (0, lib_1.getFirebaseWorkspace)(tree);
41
+ devkit_1.logger.info(`This workspace has ${workspace.firebaseAppProjects.size} firebase apps and ${workspace.firebaseFunctionProjects.size} firebase functions\n\n`);
42
+ /**
43
+ * Nx automatically:
44
+ * - updates implicitDependencies when projects are renamed with `nx g mv`
45
+ * - deletes implicitDependencies when projects are deleted with `nx g rm`
46
+ * So we do not have to consider these scenarios.
47
+ */
48
+ // 1. remove any orphaned firebase config files that no longer linked to an app
49
+ workspace.firebaseConfigProjects.forEach((projectName, configName) => {
50
+ if (projectName === lib_1.CONFIG_NO_APP) {
51
+ (0, lib_1.debugInfo)(`- found firebase config ${configName} with no app`);
52
+ tree.delete(configName);
53
+ // its ok to delete keys in forEach
54
+ workspace.firebaseConfigProjects.delete(configName);
55
+ workspace.firebaseConfigs.delete(configName);
56
+ // dont need to sync firebaseAppConfigs since this app wont exist in there
57
+ devkit_1.logger.info(`CHANGE Firebase config '${configName}' is no longer referenced by any firebase app, deleted`);
58
+ }
59
+ });
60
+ // 2. rename firebase config files too if app is renamed
61
+ workspace.renamedApps.forEach((project, oldProjectName) => {
62
+ const configFileName = workspace.firebaseAppConfigs.get(project.name);
63
+ // dont rename config file if it is firebase.json
64
+ if (configFileName === 'firebase.json') {
65
+ devkit_1.logger.info(`CHANGE Firebase app '${oldProjectName}' linked to primary config file was renamed to '${project.name}', skipping rename of '${configFileName}'`);
66
+ }
67
+ else {
68
+ const config = workspace.firebaseConfigs.get(configFileName);
69
+ // create a copy of the firebase config with the renamed project name
70
+ const newConfigFileName = `firebase.${project.name}.json`;
71
+ (0, devkit_1.writeJson)(tree, newConfigFileName, config);
72
+ // rewrite the --config=<configFileName> part of the firebase target command
73
+ (0, utils_1.setFirebaseConfigFromCommand)(project, newConfigFileName);
74
+ // write the updated project
75
+ (0, devkit_1.updateProjectConfiguration)(tree, project.name, project);
76
+ // delete the original config from the workspace
77
+ tree.delete(configFileName);
78
+ // rewrite the workspace to the newly renamed config file
79
+ workspace.firebaseConfigs.delete(configFileName);
80
+ workspace.firebaseAppConfigs.delete(project.name);
81
+ workspace.firebaseConfigProjects.delete(configFileName);
82
+ workspace.firebaseConfigs.set(newConfigFileName, config);
83
+ workspace.firebaseAppConfigs.set(project.name, newConfigFileName);
84
+ workspace.firebaseConfigProjects.set(newConfigFileName, project.name);
85
+ devkit_1.logger.info(`CHANGE Firebase app '${oldProjectName}' was renamed to '${project.name}', renamed config file to '${newConfigFileName}'`);
86
+ }
87
+ });
88
+ // 3. update the firebase:name tag for renamed apps
89
+ workspace.renamedApps.forEach((project, oldName) => {
90
+ (0, lib_1.updateFirebaseProjectNameTag)(tree, project);
91
+ devkit_1.logger.info(`CHANGE Firebase app '${oldName}' was renamed to '${project.name}', updated firebase:name tag`);
92
+ });
93
+ // 4. update the firebase:dep tag for functions linked to renamed apps
94
+ workspace.firebaseFunctionProjects.forEach((project, name) => {
95
+ const { tagValue, tagIndex } = (0, lib_1.getFirebaseScopeFromTag)(project, 'firebase:dep');
96
+ if (workspace.renamedApps.has(tagValue)) {
97
+ const renamedApp = workspace.renamedApps.get(tagValue);
98
+ project.tags[tagIndex] = `firebase:dep:${renamedApp.name}`;
99
+ devkit_1.logger.info(`CHANGE Firebase app '${tagValue}' was renamed to '${renamedApp.name}', updated firebase:dep tag in firebase function '${name}'`);
100
+ (0, devkit_1.updateProjectConfiguration)(tree, project.name, project);
101
+ }
102
+ else {
103
+ if (workspace.deletedApps.has(tagValue) ||
104
+ !workspace.firebaseAppProjects.has(tagValue)) {
105
+ devkit_1.logger.warn(`CHANGE Firebase app '${tagValue}' was deleted, firebase:dep tag for firebase function '${name}' is no longer linked to a Firebase app.`);
106
+ }
107
+ }
108
+ });
109
+ // 5. update the firebase:name tag for renamed functions
110
+ workspace.renamedFunctions.forEach((project, oldName) => {
111
+ (0, lib_1.updateFirebaseProjectNameTag)(tree, project);
112
+ devkit_1.logger.info(`CHANGE Firebase function '${oldName}' was renamed to '${project.name}', updated firebase:name tag`);
113
+ });
114
+ // 6. update the deploy command for renamed functions
115
+ workspace.renamedFunctions.forEach((project, oldName) => {
116
+ const deployCommand = project.targets.deploy.options.command;
117
+ project.targets.deploy.options.command = deployCommand.replace(FUNCTIONS_DEPLOY_MATCHER, '$1' + project.name);
118
+ devkit_1.logger.info(`CHANGE Firebase function '${oldName}' was renamed to '${project.name}', updated deploy target to '--only=functions:${project.name}'`);
119
+ (0, devkit_1.updateProjectConfiguration)(tree, project.name, project);
120
+ });
121
+ // 7. sync firebase configs for deleted & renamed functions
122
+ workspace.firebaseConfigs.forEach((config, configFileName) => {
123
+ let configUpdated = false;
124
+ const functions = config.functions;
125
+ const updatedFunctions = [];
126
+ // remove deleted functions
127
+ functions.forEach((func) => {
128
+ // remove functions where codebase is linked to a now deleted firebase function project
129
+ if (workspace.deletedFunctions.has(func.codebase)) {
130
+ devkit_1.logger.info(`CHANGE Firebase function '${func.codebase}' was deleted, removing function codebase from '${configFileName}'`);
131
+ configUpdated = true;
132
+ }
133
+ else {
134
+ // rename function codebase if linked to a renamed firebase function project
135
+ const codebase = func.codebase;
136
+ (0, lib_1.debugInfo)(`- checking if codebase '${codebase}' is renamed`);
137
+ if (workspace.renamedFunctions.has(codebase)) {
138
+ // change name of codebase
139
+ const project = workspace.renamedFunctions.get(codebase);
140
+ (0, lib_1.debugInfo)(`- codebase '${codebase}' is renamed to ${project.name}`);
141
+ func.codebase = project.name;
142
+ // change source dir
143
+ func.source = project.targets.build.options.outputPath;
144
+ devkit_1.logger.info(`CHANGE Firebase function '${codebase}' was renamed to '${project.name}', updated codebase in '${configFileName}'`);
145
+ configUpdated = true;
146
+ }
147
+ updatedFunctions.push(func);
148
+ }
149
+ });
150
+ if (configUpdated) {
151
+ config.functions = updatedFunctions;
152
+ config.functions.sort((a, b) => {
153
+ return a.codebase < b.codebase ? -1 : a.codebase > b.codebase ? 1 : 0;
154
+ });
155
+ (0, devkit_1.writeJson)(tree, configFileName, config);
156
+ }
157
+ });
158
+ // if user deletes a project that was linked to firebase.json config but there
159
+ // are other firebase apps in the workspace, we need to inform user about
160
+ // this, since we dont have a way
161
+ // other firebase apps in the workspace, we'll just advise
162
+ if (!tree.exists('firebase.json') && workspace.firebaseAppProjects.size) {
163
+ devkit_1.logger.warn(`None of the Firebase apps in this workspace use 'firebase.json' as their config. Firebase CLI may not work as expected. This can be fixed by renaming the config for one of your firebase projects to 'firebase.json'.`);
164
+ }
165
+ return (0, devkit_1.runTasksInSerial)(...tasks);
166
+ });
167
+ }
168
+ exports.syncGenerator = syncGenerator;
169
+ exports.default = syncGenerator;
170
+ //# sourceMappingURL=sync.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sync.js","sourceRoot":"","sources":["../../../../../../packages/nx-firebase/src/generators/sync/sync.ts"],"names":[],"mappings":";;;;AAAA,uCAQmB;AAGnB,uCAA4E;AAC5E,uCAAwC;AAExC,+BAQc;AAEd,MAAM,wBAAwB,GAAG,gCAAgC,CAAA;AAEjE;;;GAGG;AACH,SAAsB,aAAa,CACjC,IAAU,EACV,OAA4B;;QAE5B,MAAM,KAAK,GAAwB,EAAE,CAAA;QAErC,oBAAoB;QACpB,MAAM,QAAQ,GAAG,MAAM,IAAA,cAAa,EAAC,IAAI,EAAE,EAAE,CAAC,CAAA;QAC9C,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;QAEpB,6DAA6D;QAC7D,IAAI,OAAO,CAAC,OAAO,EAA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AG,gBAAgB,CAAA;gBACnC,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAmB,EAAE,CAAmB,EAAE,EAAE;oBACjE,OAAO,CAAC,CAAC,QAAQ,GAAG,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,GAAG,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;gBACvE,CAAC,CAAC,CAAA;gBACF,IAAA,kBAAS,EAAC,IAAI,EAAE,cAAc,EAAE,MAAM,CAAC,CAAA;aACxC;QACH,CAAC,CAAC,CAAA;QAEF,8EAA8E;QAC9E,yEAAyE;QACzE,iCAAiC;QACjC,0DAA0D;QAC1D,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,eAAe,CAAC,IAAI,SAAS,CAAC,mBAAmB,CAAC,IAAI,EAAE;YACvE,eAAM,CAAC,IAAI,CACT,wNAAwN,CACzN,CAAA;SACF;QAED,OAAO,IAAA,yBAAgB,EAAC,GAAG,KAAK,CAAC,CAAA;IACnC,CAAC;CAAA;AAhND,sCAgNC;AAED,kBAAe,aAAa,CAAA"}
@@ -0,0 +1,4 @@
1
+ export declare function debugInfo(info: string): void;
2
+ export declare function mapKeys(map: Map<any, any>): string;
3
+ export declare function mapValues(map: Map<any, any>): string;
4
+ export declare function mapEntries(map: Map<any, any>): string;
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.mapEntries = exports.mapValues = exports.mapKeys = exports.debugInfo = void 0;
4
+ const devkit_1 = require("@nx/devkit");
5
+ // debug info just for plugin
6
+ const ENABLE_DEBUG_INFO = false;
7
+ function debugInfo(info) {
8
+ if (ENABLE_DEBUG_INFO) {
9
+ devkit_1.logger.info(info);
10
+ }
11
+ }
12
+ exports.debugInfo = debugInfo;
13
+ function mapKeys(map) {
14
+ return JSON.stringify([...map.keys()], null, 3);
15
+ }
16
+ exports.mapKeys = mapKeys;
17
+ function mapValues(map) {
18
+ return JSON.stringify([...map.values()], null, 3);
19
+ }
20
+ exports.mapValues = mapValues;
21
+ function mapEntries(map) {
22
+ return JSON.stringify([...map.entries()], null, 3);
23
+ }
24
+ exports.mapEntries = mapEntries;
25
+ //# sourceMappingURL=debug.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"debug.js","sourceRoot":"","sources":["../../../../../packages/nx-firebase/src/utils/debug.ts"],"names":[],"mappings":";;;AAAA,uCAAmC;AAEnC,6BAA6B;AAC7B,MAAM,iBAAiB,GAAG,KAAK,CAAA;AAE/B,SAAgB,SAAS,CAAC,IAAY;IACpC,IAAI,iBAAiB,EAAE;QACrB,eAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;KAClB;AACH,CAAC;AAJD,8BAIC;AAED,SAAgB,OAAO,CAAC,GAAkB;IACxC,OAAO,IAAI,CAAC,SAAS,CAAC,CAAC,GAAG,GAAG,CAAC,IAAI,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,CAAA;AACjD,CAAC;AAFD,0BAEC;AAED,SAAgB,SAAS,CAAC,GAAkB;IAC1C,OAAO,IAAI,CAAC,SAAS,CAAC,CAAC,GAAG,GAAG,CAAC,MAAM,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,CAAA;AACnD,CAAC;AAFD,8BAEC;AAED,SAAgB,UAAU,CAAC,GAAkB;IAC3C,OAAO,IAAI,CAAC,SAAS,CAAC,CAAC,GAAG,GAAG,CAAC,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,CAAA;AACpD,CAAC;AAFD,gCAEC"}
@@ -0,0 +1,77 @@
1
+ import { Tree, ProjectConfiguration } from '@nx/devkit';
2
+ export interface FirebaseFunction {
3
+ predeploy?: string[];
4
+ source: string;
5
+ codebase: string;
6
+ runtime: string;
7
+ }
8
+ export interface FirebaseConfig {
9
+ database: {
10
+ rules: string;
11
+ };
12
+ firestore: {
13
+ rules: string;
14
+ indexes: string;
15
+ };
16
+ hosting: {
17
+ target: string;
18
+ public: string;
19
+ ignore: string[];
20
+ rewrites: {
21
+ source: string;
22
+ destination: string;
23
+ }[];
24
+ headers: [
25
+ {
26
+ source: string;
27
+ headers: {
28
+ key: string;
29
+ value: string;
30
+ }[];
31
+ }
32
+ ];
33
+ }[];
34
+ storage: {
35
+ rules: string;
36
+ };
37
+ functions: FirebaseFunction | FirebaseFunction[];
38
+ emulators: {
39
+ functions: {
40
+ port: number;
41
+ };
42
+ firestore: {
43
+ port: number;
44
+ };
45
+ hosting: {
46
+ port: number;
47
+ };
48
+ auth: {
49
+ port: number;
50
+ };
51
+ pubsub: {
52
+ port: number;
53
+ };
54
+ };
55
+ }
56
+ /**
57
+ * Return the config file from the provided firebase target command
58
+ * This can be used to parse commands in additional configurations
59
+ * @param project
60
+ * @param command
61
+ * @returns
62
+ */
63
+ export declare function getFirebaseConfigFromCommand(tree: Tree, project: ProjectConfiguration, command: string): string;
64
+ /**
65
+ * Return the config file used by the `firebase` target command of the provided firebase app project
66
+ * @param command
67
+ * @param project
68
+ * @param firebaseConfigs
69
+ * @returns
70
+ */
71
+ export declare function getFirebaseConfigFromProject(tree: Tree, project: ProjectConfiguration): string;
72
+ /**
73
+ * Modify the config file used by the `firebase` target command of the provided firebase app project
74
+ * @param project
75
+ * @param configFileName
76
+ */
77
+ export declare function setFirebaseConfigFromCommand(project: ProjectConfiguration, configFileName: string): void;
@@ -0,0 +1,52 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.setFirebaseConfigFromCommand = exports.getFirebaseConfigFromProject = exports.getFirebaseConfigFromCommand = void 0;
4
+ const FIREBASE_TARGET_CONFIG_MATCHER = /(--config[ =])([^\s]+)/;
5
+ /**
6
+ * Return the config file from the provided firebase target command
7
+ * This can be used to parse commands in additional configurations
8
+ * @param project
9
+ * @param command
10
+ * @returns
11
+ */
12
+ function getFirebaseConfigFromCommand(tree, project, command) {
13
+ const match = command.match(FIREBASE_TARGET_CONFIG_MATCHER);
14
+ if (match && match.length === 3) {
15
+ const configName = match[2];
16
+ // check the config we've parsed actually resolves to a firebase config file in the workspace
17
+ if (!tree.exists(configName)) {
18
+ throw new Error(`Firebase app project ${project.name} is using a firebase config file ${configName} that does not exist in the workspace.`);
19
+ }
20
+ return configName;
21
+ }
22
+ throw new Error(`Firebase app project ${project.name} does not have --config set in its 'firebase' target.`);
23
+ }
24
+ exports.getFirebaseConfigFromCommand = getFirebaseConfigFromCommand;
25
+ /**
26
+ * Return the config file used by the `firebase` target command of the provided firebase app project
27
+ * @param command
28
+ * @param project
29
+ * @param firebaseConfigs
30
+ * @returns
31
+ */
32
+ function getFirebaseConfigFromProject(tree, project) {
33
+ return getFirebaseConfigFromCommand(tree, project, project.targets.firebase.options.command);
34
+ }
35
+ exports.getFirebaseConfigFromProject = getFirebaseConfigFromProject;
36
+ /**
37
+ * Modify the config file used by the `firebase` target command of the provided firebase app project
38
+ * @param project
39
+ * @param configFileName
40
+ */
41
+ function setFirebaseConfigFromCommand(project, configFileName) {
42
+ // we've already checked that firebase target exists when setting up workspace
43
+ const firebaseTarget = project.targets.firebase;
44
+ firebaseTarget.options.command = firebaseTarget.options.command.replace(FIREBASE_TARGET_CONFIG_MATCHER, '$1' + configFileName);
45
+ // do this for all other configurations on this target too
46
+ const configurations = firebaseTarget.configurations;
47
+ for (const configuration in configurations) {
48
+ configurations[configuration].command = configurations[configuration].command.replace(FIREBASE_TARGET_CONFIG_MATCHER, '$1' + configFileName);
49
+ }
50
+ }
51
+ exports.setFirebaseConfigFromCommand = setFirebaseConfigFromCommand;
52
+ //# sourceMappingURL=firebase-config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"firebase-config.js","sourceRoot":"","sources":["../../../../../packages/nx-firebase/src/utils/firebase-config.ts"],"names":[],"mappings":";;;AAEA,MAAM,8BAA8B,GAAG,wBAAwB,CAAA;AA0D/D;;;;;;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OAAO,CAAC,8BAA8B,EAAE,IAAI,GAAG,cAAc,CAAC,CAAA;KACzE;AACH,CAAC;AAjBD,oEAiBC"}
@@ -1,3 +1,6 @@
1
1
  export * from './types';
2
2
  export * from './versions';
3
3
  export * from './workspace';
4
+ export * from './update-tsconfig';
5
+ export * from './project-name';
6
+ export * from './firebase-config';
@@ -4,4 +4,7 @@ const tslib_1 = require("tslib");
4
4
  tslib_1.__exportStar(require("./types"), exports);
5
5
  tslib_1.__exportStar(require("./versions"), exports);
6
6
  tslib_1.__exportStar(require("./workspace"), exports);
7
+ tslib_1.__exportStar(require("./update-tsconfig"), exports);
8
+ tslib_1.__exportStar(require("./project-name"), exports);
9
+ tslib_1.__exportStar(require("./firebase-config"), exports);
7
10
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../packages/nx-firebase/src/utils/index.ts"],"names":[],"mappings":";;;AAAA,kDAAuB;AACvB,qDAA0B;AAC1B,sDAA2B"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../packages/nx-firebase/src/utils/index.ts"],"names":[],"mappings":";;;AAAA,kDAAuB;AACvB,qDAA0B;AAC1B,sDAA2B;AAC3B,4DAAiC;AACjC,yDAA8B;AAC9B,4DAAiC"}
@@ -0,0 +1,5 @@
1
+ import { Tree } from '@nx/devkit';
2
+ export declare function getProjectName(tree: Tree, name: string, directory?: string): {
3
+ projectRoot: string;
4
+ projectName: string;
5
+ };
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getProjectName = void 0;
4
+ const devkit_1 = require("@nx/devkit");
5
+ function getProjectName(tree, name, directory) {
6
+ // console.log(`name ${name}`)
7
+ // console.log(`directory ${directory}`)
8
+ const { layoutDirectory, projectDirectory } = (0, devkit_1.extractLayoutDirectory)(directory);
9
+ // console.log(`layoutDirectory ${layoutDirectory}`)
10
+ // console.log(`projectDirectory ${projectDirectory}`)
11
+ const appsDir = layoutDirectory !== null && layoutDirectory !== void 0 ? layoutDirectory : (0, devkit_1.getWorkspaceLayout)(tree).appsDir;
12
+ // console.log(`appsDir ${appsDir}`)
13
+ const appDirectory = projectDirectory
14
+ ? `${(0, devkit_1.names)(projectDirectory).fileName}/${(0, devkit_1.names)(name).fileName}`
15
+ : (0, devkit_1.names)(name).fileName;
16
+ // console.log(`appDirectory ${appDirectory}`)
17
+ const appProjectName = appDirectory.replace(new RegExp('/', 'g'), '-');
18
+ // console.log(`appProjectName ${appProjectName}`)
19
+ const appProjectRoot = (0, devkit_1.joinPathFragments)(appsDir, appDirectory);
20
+ // console.log(`appProjectRoot ${appProjectRoot}`)
21
+ // // see https://github.com/nrwl/nx/blob/84cbcb7e105cd2b3bf5b3d84a519e5c52951e0f3/packages/js/src/generators/library/library.ts#L332
22
+ // // for how the project name is derived from options.name and --directory
23
+ // const fileName = names(name).fileName
24
+ // const projectDirectory = directory
25
+ // ? `${names(directory).fileName}/${fileName}`
26
+ // : name
27
+ // const projectRoot = joinPathFragments(
28
+ // getWorkspaceLayout(tree).appsDir,
29
+ // projectDirectory,
30
+ // )
31
+ // const projectName = projectDirectory.replace(new RegExp('/', 'g'), '-')
32
+ return {
33
+ projectRoot: appProjectRoot,
34
+ projectName: appProjectName,
35
+ };
36
+ }
37
+ exports.getProjectName = getProjectName;
38
+ //# sourceMappingURL=project-name.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"project-name.js","sourceRoot":"","sources":["../../../../../packages/nx-firebase/src/utils/project-name.ts"],"names":[],"mappings":";;;AAAA,uCAMmB;AAEnB,SAAgB,cAAc,CAAC,IAAU,EAAE,IAAY,EAAE,SAAkB;IACzE,8BAA8B;IAC9B,wCAAwC;IAExC,MAAM,EAAE,eAAe,EAAE,gBAAgB,EAAE,GACzC,IAAA,+BAAsB,EAAC,SAAS,CAAC,CAAA;IAEnC,oDAAoD;IACpD,sDAAsD;IAEtD,MAAM,OAAO,GAAG,eAAe,aAAf,eAAe,cAAf,eAAe,GAAI,IAAA,2BAAkB,EAAC,IAAI,CAAC,CAAC,OAAO,CAAA;IAEnE,oCAAoC;IAEpC,MAAM,YAAY,GAAG,gBAAgB;QACnC,CAAC,CAAC,GAAG,IAAA,cAAK,EAAC,gBAAgB,CAAC,CAAC,QAAQ,IAAI,IAAA,cAAK,EAAC,IAAI,CAAC,CAAC,QAAQ,EAAE;QAC/D,CAAC,CAAC,IAAA,cAAK,EAAC,IAAI,CAAC,CAAC,QAAQ,CAAA;IAExB,8CAA8C;IAE9C,MAAM,cAAc,GAAG,YAAY,CAAC,OAAO,CAAC,IAAI,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC,EAAE,GAAG,CAAC,CAAA;IAEtE,kDAAkD;IAElD,MAAM,cAAc,GAAG,IAAA,0BAAiB,EAAC,OAAO,EAAE,YAAY,CAAC,CAAA;IAE/D,kDAAkD;IAElD,qIAAqI;IACrI,2EAA2E;IAC3E,wCAAwC;IACxC,qCAAqC;IACrC,iDAAiD;IACjD,WAAW;IAEX,yCAAyC;IACzC,sCAAsC;IACtC,sBAAsB;IACtB,IAAI;IAEJ,0EAA0E;IAC1E,OAAO;QACL,WAAW,EAAE,cAAc;QAC3B,WAAW,EAAE,cAAc;KAC5B,CAAA;AACH,CAAC;AA7CD,wCA6CC"}
@@ -1 +1 @@
1
- export type UnitTestRunner = 'jest' | 'none';
1
+ export declare type UnitTestRunner = 'jest' | 'none';
@@ -1,9 +1,8 @@
1
1
  import type { Tree } from '@nx/devkit';
2
- import type { NormalizedOptions } from '../schema';
3
2
  /**
4
3
  * With firebase cli > 10.0.1 now compatible with node versions >=14 we can use es modules rather than commonjs
5
4
  *
6
5
  * @param tree
7
6
  * @param options
8
7
  */
9
- export declare function updateTsConfig(tree: Tree, options: NormalizedOptions): void;
8
+ export declare function updateTsConfig(tree: Tree, projectRoot: string, runTime: string, format: 'esm' | 'cjs'): void;
@@ -2,17 +2,17 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.updateTsConfig = void 0;
4
4
  const devkit_1 = require("@nx/devkit");
5
- const utils_1 = require("../../../utils");
5
+ const versions_1 = require("./versions");
6
6
  /**
7
7
  * With firebase cli > 10.0.1 now compatible with node versions >=14 we can use es modules rather than commonjs
8
8
  *
9
9
  * @param tree
10
10
  * @param options
11
11
  */
12
- function updateTsConfig(tree, options) {
13
- (0, devkit_1.updateJson)(tree, (0, devkit_1.joinPathFragments)(options.projectRoot, 'tsconfig.app.json'), (json) => {
14
- json.compilerOptions.emitDecoratorMetadata = true;
15
- json.compilerOptions.target = utils_1.tsConfigTarget;
12
+ function updateTsConfig(tree, projectRoot, runTime, format) {
13
+ (0, devkit_1.updateJson)(tree, (0, devkit_1.joinPathFragments)(projectRoot, 'tsconfig.app.json'), (json) => {
14
+ json.compilerOptions.target = versions_1.nodeEsVersion[runTime];
15
+ json.compilerOptions.module = format === 'esm' ? 'es2020' : 'commonjs';
16
16
  return json;
17
17
  });
18
18
  }
@@ -0,0 +1 @@
1
+ {"version":3,"file":"update-tsconfig.js","sourceRoot":"","sources":["../../../../../packages/nx-firebase/src/utils/update-tsconfig.ts"],"names":[],"mappings":";;;AACA,uCAA0D;AAC1D,yCAA0C;AAE1C;;;;;GAKG;AACH,SAAgB,cAAc,CAC5B,IAAU,EACV,WAAmB,EACnB,OAAe,EACf,MAAqB;IAErB,IAAA,mBAAU,EACR,IAAI,EACJ,IAAA,0BAAiB,EAAC,WAAW,EAAE,mBAAmB,CAAC,EACnD,CAAC,IAAI,EAAE,EAAE;QACP,IAAI,CAAC,eAAe,CAAC,MAAM,GAAG,wBAAa,CAAC,OAAO,CAAC,CAAA;QACpD,IAAI,CAAC,eAAe,CAAC,MAAM,GAAG,MAAM,KAAK,KAAK,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,UAAU,CAAA;QACtE,OAAO,IAAI,CAAA;IACb,CAAC,CACF,CAAA;AACH,CAAC;AAfD,wCAeC"}
@@ -8,5 +8,6 @@ export declare const firebaseVersion = "^9.14.0";
8
8
  export declare const firebaseFunctionsTestVersion = "^0.2.0";
9
9
  export declare const firebaseNodeEngine = "16";
10
10
  export declare const firebaseNodeRuntime: string;
11
+ export declare const nodeEsVersion: Record<string, string>;
11
12
  export declare const tsConfigTarget: string;
12
13
  export declare const killportVersion = "^2.0.1";
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.killportVersion = exports.tsConfigTarget = exports.firebaseNodeRuntime = exports.firebaseNodeEngine = exports.firebaseFunctionsTestVersion = exports.firebaseVersion = exports.firebaseToolsVersion = exports.firebaseFunctionsVersion = exports.firebaseAdminVersion = exports.tsLibVersion = exports.pluginNxVersionMajor = exports.pluginNxVersion = void 0;
3
+ exports.killportVersion = exports.tsConfigTarget = exports.nodeEsVersion = exports.firebaseNodeRuntime = exports.firebaseNodeEngine = exports.firebaseFunctionsTestVersion = exports.firebaseVersion = exports.firebaseToolsVersion = exports.firebaseFunctionsVersion = exports.firebaseAdminVersion = exports.tsLibVersion = exports.pluginNxVersionMajor = exports.pluginNxVersion = void 0;
4
4
  // Declare target version of Nx that the plugin is currently compatible with
5
5
  exports.pluginNxVersion = '^16.1.1';
6
6
  exports.pluginNxVersionMajor = 16;
@@ -17,13 +17,14 @@ exports.firebaseFunctionsTestVersion = '^0.2.0';
17
17
  exports.firebaseNodeEngine = '16';
18
18
  exports.firebaseNodeRuntime = `nodejs${exports.firebaseNodeEngine}`;
19
19
  // https://stackoverflow.com/questions/59787574/typescript-tsconfig-settings-for-node-js-12
20
- const nodeVersion = {
20
+ exports.nodeEsVersion = {
21
21
  '12': 'es2019',
22
22
  '14': 'es2020',
23
- '16': 'es2021',
23
+ '16': 'es2020',
24
24
  '18': 'es2022',
25
+ '20': 'es2022',
25
26
  };
26
- exports.tsConfigTarget = nodeVersion[exports.firebaseNodeEngine];
27
+ exports.tsConfigTarget = exports.nodeEsVersion[exports.firebaseNodeEngine];
27
28
  if (!exports.tsConfigTarget) {
28
29
  throw new Error('Undefined tsConfigTarget');
29
30
  }
@@ -1 +1 @@
1
- {"version":3,"file":"versions.js","sourceRoot":"","sources":["../../../../../packages/nx-firebase/src/utils/versions.ts"],"names":[],"mappings":";;;AAAA,4EAA4E;AAC/D,QAAA,eAAe,GAAG,SAAS,CAAA;AAC3B,QAAA,oBAAoB,GAAG,EAAE,CAAA;AAEtC,6CAA6C;AAChC,QAAA,YAAY,GAAG,QAAQ,CAAA;AAEpC,kDAAkD;AAClD,mEAAmE;AACtD,QAAA,oBAAoB,GAAG,SAAS,CAAA;AAChC,QAAA,wBAAwB,GAAG,QAAQ,CAAA;AACnC,QAAA,oBAAoB,GAAG,UAAU,CAAA;AACjC,QAAA,eAAe,GAAG,SAAS,CAAA;AAC3B,QAAA,4BAA4B,GAAG,QAAQ,CAAA;AAEpD,+CAA+C;AAClC,QAAA,kBAAkB,GAAG,IAAI,CAAA;AACzB,QAAA,mBAAmB,GAAG,SAAS,0BAAkB,EAAE,CAAA;AAEhE,2FAA2F;AAE3F,MAAM,WAAW,GAA2B;IAC1C,IAAI,EAAE,QAAQ;IACd,IAAI,EAAE,QAAQ;IACd,IAAI,EAAE,QAAQ;IACd,IAAI,EAAE,QAAQ;CACf,CAAA;AAEY,QAAA,cAAc,GAAG,WAAW,CAAC,0BAAkB,CAAC,CAAA;AAE7D,IAAI,CAAC,sBAAc,EAAE;IACnB,MAAM,IAAI,KAAK,CAAC,0BAA0B,CAAC,CAAA;CAC5C;AAED,iDAAiD;AACpC,QAAA,eAAe,GAAG,QAAQ,CAAA"}
1
+ {"version":3,"file":"versions.js","sourceRoot":"","sources":["../../../../../packages/nx-firebase/src/utils/versions.ts"],"names":[],"mappings":";;;AAAA,4EAA4E;AAC/D,QAAA,eAAe,GAAG,SAAS,CAAA;AAC3B,QAAA,oBAAoB,GAAG,EAAE,CAAA;AAEtC,6CAA6C;AAChC,QAAA,YAAY,GAAG,QAAQ,CAAA;AAEpC,kDAAkD;AAClD,mEAAmE;AACtD,QAAA,oBAAoB,GAAG,SAAS,CAAA;AAChC,QAAA,wBAAwB,GAAG,QAAQ,CAAA;AACnC,QAAA,oBAAoB,GAAG,UAAU,CAAA;AACjC,QAAA,eAAe,GAAG,SAAS,CAAA;AAC3B,QAAA,4BAA4B,GAAG,QAAQ,CAAA;AAEpD,+CAA+C;AAClC,QAAA,kBAAkB,GAAG,IAAI,CAAA;AACzB,QAAA,mBAAmB,GAAG,SAAS,0BAAkB,EAAE,CAAA;AAEhE,2FAA2F;AAE9E,QAAA,aAAa,GAA2B;IACnD,IAAI,EAAE,QAAQ;IACd,IAAI,EAAE,QAAQ;IACd,IAAI,EAAE,QAAQ;IACd,IAAI,EAAE,QAAQ;IACd,IAAI,EAAE,QAAQ;CACf,CAAA;AAEY,QAAA,cAAc,GAAG,qBAAa,CAAC,0BAAkB,CAAC,CAAA;AAE/D,IAAI,CAAC,sBAAc,EAAE;IACnB,MAAM,IAAI,KAAK,CAAC,0BAA0B,CAAC,CAAA;CAC5C;AAED,iDAAiD;AACpC,QAAA,eAAe,GAAG,QAAQ,CAAA"}
@@ -1,4 +1,4 @@
1
- export type WorkspaceVersion = {
1
+ export declare type WorkspaceVersion = {
2
2
  version: string;
3
3
  versionCode: number;
4
4
  major: number;
@@ -1,8 +0,0 @@
1
- import { ExecutorContext } from '@nx/devkit';
2
- import type { ExecutorOptions } from '@nx/js/src/utils/schema';
3
- /**
4
- * @simondotm/nx-firebase:build executor is a
5
- * customized version of @nx/js:tsc executor
6
- */
7
- export declare function runExecutor(options: ExecutorOptions, context: ExecutorContext): AsyncGenerator<import("@nx/js/src/utils/typescript/compile-typescript-files").TypescriptCompilationResult, void, unknown>;
8
- export default runExecutor;
@@ -1,82 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.runExecutor = void 0;
4
- const tslib_1 = require("tslib");
5
- // import '../../utils/e2ePatch' // intentional side effects
6
- const devkit_1 = require("@nx/devkit");
7
- const tsc_impl_1 = require("@nx/js/src/executors/tsc/tsc.impl");
8
- const lib_1 = require("./lib");
9
- const utils_1 = require("../../utils");
10
- /**
11
- * @simondotm/nx-firebase:build executor is a
12
- * customized version of @nx/js:tsc executor
13
- */
14
- function runExecutor(options, context) {
15
- return tslib_1.__asyncGenerator(this, arguments, function* runExecutor_1() {
16
- var _a, e_1, _b, _c;
17
- (0, utils_1.checkNxVersion)();
18
- if (process.env.NX_WORKSPACE_ROOT_PATH) {
19
- devkit_1.logger.warn(`WARNING: @simondotm/nx-firebase plugin is located outside this workspace, NX_WORKSPACE_ROOT_PATH has been set to ${process.env.NX_WORKSPACE_ROOT_PATH}`);
20
- }
21
- /*
22
- // --updateBuildableProjectDepsInPackageJson is true by default for @nx/js:tsc
23
- // https://nx.dev/packages/js/executors/tsc
24
- // but we havent programmed our executor schema to match yet, so hack them in here.
25
- const customOptions: ExecutorOptions = {
26
- ...options,
27
- updateBuildableProjectDepsInPackageJson: true,
28
- clean: true,
29
- }
30
- */
31
- if (process.env.NX_VERBOSE_LOGGING) {
32
- devkit_1.logger.info(`options=${JSON.stringify(options, null, 3)}`);
33
- }
34
- // console.log(`NX_WORKSPACE_ROOT_PATH=${process.env.NX_WORKSPACE_ROOT_PATH}`)
35
- // logger.info(`process.env.CI=${process.env.CI}`)
36
- // logger.info(`process.env.NX_DAEMON=${process.env.CI}`)
37
- // // SM: recompute the project graph on every iteration so that --watch will work,
38
- // // since the context.projectGraph is only a snapshot
39
- if (options.watch) {
40
- // const projectGraph = await createProjectGraphAsync()
41
- yield tslib_1.__await((0, devkit_1.createProjectGraphAsync)()
42
- // logger.info(JSON.stringify(graph, null, 3))
43
- );
44
- // logger.info(JSON.stringify(graph, null, 3))
45
- }
46
- try {
47
- // iterate the tscExecutor generator until it completes
48
- // this approach allows us to add a custom post-compile process.
49
- //
50
- // with --watch enabled, this loop will run until the process terminates
51
- // https://github.com/nrwl/nx/blob/8bfc0b5527e3ea3acd14e4a11254505f02046d98/packages/js/src/executors/tsc/tsc.impl.ts#L176
52
- for (var _d = true, _e = tslib_1.__asyncValues((0, tsc_impl_1.tscExecutor)(options, context)), _f; _f = yield tslib_1.__await(_e.next()), _a = _f.done, !_a;) {
53
- _c = _f.value;
54
- _d = false;
55
- try {
56
- const output = _c;
57
- // logger.info(output)
58
- if (output.success) {
59
- // Post-process Firebase Functions dependencies if compilation succeeded
60
- yield tslib_1.__await((0, lib_1.firebaseBuildExecutor)(context, options.outputPath));
61
- }
62
- yield yield tslib_1.__await(output);
63
- }
64
- finally {
65
- _d = true;
66
- }
67
- }
68
- }
69
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
70
- finally {
71
- try {
72
- if (!_d && !_a && (_b = _e.return)) yield tslib_1.__await(_b.call(_e));
73
- }
74
- finally { if (e_1) throw e_1.error; }
75
- }
76
- });
77
- }
78
- exports.runExecutor = runExecutor;
79
- //SM: no idea what this shenanigans is for
80
- //export default convertNxExecutor(runExecutor);
81
- exports.default = runExecutor;
82
- //# sourceMappingURL=build.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"build.js","sourceRoot":"","sources":["../../../../../../packages/nx-firebase/src/executors/build/build.ts"],"names":[],"mappings":";;;;AAAA,4DAA4D;AAC5D,uCAA6E;AAE7E,gEAA+D;AAC/D,+BAA6C;AAC7C,uCAA4C;AAE5C;;;GAGG;AACH,SAAuB,WAAW,CAChC,OAAwB,EACxB,OAAwB;;;QAExB,IAAA,sBAAc,GAAE,CAAA;QAEhB,IAAI,OAAO,CAAC,GAAG,CAAC,sBAAsB,EAAE;YACtC,eAAM,CAAC,IAAI,CACT,oHAAoH,OAAO,CAAC,GAAG,CAAC,sBAAsB,EAAE,CACzJ,CAAA;SACF;QAED;;;;;;;;;UASE;QACF,IAAI,OAAO,CAAC,GAAG,CAAC,kBAAkB,EAAE;YAClC,eAAM,CAAC,IAAI,CAAC,WAAW,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC,CAAA;SAC3D;QAED,8EAA8E;QAE9E,kDAAkD;QAClD,yDAAyD;QAEzD,mFAAmF;QACnF,wDAAwD;QACxD,IAAI,OAAO,CAAC,KAAK,EAAE;YACjB,uDAAuD;YACvD,sBAAM,IAAA,gCAAuB,GAAE;YAC/B,8CAA8C;aADf,CAAA;YAC/B,8CAA8C;SAC/C;;YAED,uDAAuD;YACvD,gEAAgE;YAChE,EAAE;YACF,wEAAwE;YACxE,0HAA0H;YAC1H,KAA2B,eAAA,KAAA,sBAAA,IAAA,sBAAW,EAAC,OAAO,EAAE,OAAO,CAAC,CAAA,IAAA;gBAA7B,cAA6B;gBAA7B,WAA6B;;oBAA7C,MAAM,MAAM,KAAA,CAAA;oBACrB,sBAAsB;oBACtB,IAAI,MAAM,CAAC,OAAO,EAAE;wBAClB,wEAAwE;wBACxE,sBAAM,IAAA,2BAAqB,EAAC,OAAO,EAAE,OAAO,CAAC,UAAU,CAAC,CAAA,CAAA;qBACzD;oBACD,4BAAM,MAAM,CAAA,CAAA;;;;;aACb;;;;;;;;;IACH,CAAC;CAAA;AApDD,kCAoDC;AAED,0CAA0C;AAC1C,gDAAgD;AAChD,kBAAe,WAAW,CAAA"}
@@ -1,3 +0,0 @@
1
- import { DependentBuildableProjectNode } from '@nx/workspace/src/utilities/buildable-libs-utils';
2
- export declare const FIREBASE_DEPS_DIR = "libs";
3
- export declare function copyFirebaseDependencies(outputPath: string, workspaceRoot: string, projectDependencies: DependentBuildableProjectNode[]): Promise<Record<string, DependentBuildableProjectNode>>;