firebase-tools 10.0.0 → 10.1.2

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 (244) hide show
  1. package/lib/accountExporter.js +9 -8
  2. package/lib/accountImporter.js +10 -8
  3. package/lib/api.js +1 -0
  4. package/lib/apiv2.js +2 -2
  5. package/lib/appdistribution/client.js +1 -1
  6. package/lib/appdistribution/options-parser-util.js +1 -1
  7. package/lib/auth.js +2 -2
  8. package/lib/bin/firebase.js +1 -1
  9. package/lib/command.js +26 -26
  10. package/lib/commands/appdistribution-distribute.js +4 -4
  11. package/lib/commands/appdistribution-testers-add.js +2 -2
  12. package/lib/commands/appdistribution-testers-remove.js +2 -2
  13. package/lib/commands/apps-android-sha-create.js +2 -2
  14. package/lib/commands/apps-android-sha-delete.js +2 -2
  15. package/lib/commands/apps-android-sha-list.js +2 -2
  16. package/lib/commands/apps-create.js +9 -9
  17. package/lib/commands/apps-list.js +3 -3
  18. package/lib/commands/apps-sdkconfig.js +8 -8
  19. package/lib/commands/auth-export.js +26 -25
  20. package/lib/commands/auth-import.js +88 -78
  21. package/lib/commands/database-get.js +1 -1
  22. package/lib/commands/database-instances-create.js +4 -4
  23. package/lib/commands/database-instances-list.js +4 -4
  24. package/lib/commands/database-profile.js +1 -1
  25. package/lib/commands/database-push.js +1 -1
  26. package/lib/commands/database-remove.js +2 -2
  27. package/lib/commands/database-set.js +2 -2
  28. package/lib/commands/database-settings-get.js +1 -1
  29. package/lib/commands/database-settings-set.js +1 -1
  30. package/lib/commands/database-update.js +2 -2
  31. package/lib/commands/ext-configure.js +3 -3
  32. package/lib/commands/ext-dev-deprecate.js +4 -4
  33. package/lib/commands/ext-dev-extension-delete.js +3 -3
  34. package/lib/commands/ext-dev-init.js +4 -4
  35. package/lib/commands/ext-dev-list.js +1 -1
  36. package/lib/commands/ext-dev-publish.js +4 -4
  37. package/lib/commands/ext-dev-register.js +6 -6
  38. package/lib/commands/ext-dev-undeprecate.js +4 -4
  39. package/lib/commands/ext-dev-unpublish.js +3 -3
  40. package/lib/commands/ext-dev-usage.js +145 -0
  41. package/lib/commands/ext-export.js +8 -8
  42. package/lib/commands/ext-info.js +5 -5
  43. package/lib/commands/ext-install.js +27 -23
  44. package/lib/commands/ext-list.js +2 -2
  45. package/lib/commands/ext-sources-create.js +2 -2
  46. package/lib/commands/ext-uninstall.js +4 -4
  47. package/lib/commands/ext-update.js +18 -18
  48. package/lib/commands/ext.js +3 -3
  49. package/lib/commands/firestore-delete.js +1 -1
  50. package/lib/commands/functions-config-clone.js +22 -23
  51. package/lib/commands/functions-config-export.js +11 -11
  52. package/lib/commands/functions-config-get.js +22 -22
  53. package/lib/commands/functions-config-set.js +24 -22
  54. package/lib/commands/functions-config-unset.js +20 -22
  55. package/lib/commands/functions-delete.js +3 -3
  56. package/lib/commands/functions-deletegcfartifacts.js +4 -4
  57. package/lib/commands/functions-list.js +1 -1
  58. package/lib/commands/functions-log.js +1 -1
  59. package/lib/commands/help.js +12 -12
  60. package/lib/commands/hosting-channel-create.js +13 -13
  61. package/lib/commands/hosting-channel-delete.js +10 -10
  62. package/lib/commands/hosting-channel-deploy.js +18 -18
  63. package/lib/commands/hosting-channel-list.js +5 -5
  64. package/lib/commands/hosting-channel-open.js +9 -9
  65. package/lib/commands/hosting-clone.js +16 -16
  66. package/lib/commands/hosting-disable.js +1 -1
  67. package/lib/commands/hosting-sites-create.js +7 -7
  68. package/lib/commands/hosting-sites-delete.js +7 -7
  69. package/lib/commands/hosting-sites-get.js +2 -2
  70. package/lib/commands/hosting-sites-list.js +3 -3
  71. package/lib/commands/index.js +1 -0
  72. package/lib/commands/login-ci.js +10 -10
  73. package/lib/commands/login.js +2 -2
  74. package/lib/commands/logout.js +1 -1
  75. package/lib/commands/open.js +1 -1
  76. package/lib/commands/projects-addfirebase.js +2 -2
  77. package/lib/commands/projects-create.js +2 -2
  78. package/lib/commands/projects-list.js +1 -1
  79. package/lib/commands/remoteconfig-get.js +3 -3
  80. package/lib/commands/remoteconfig-rollback.js +3 -3
  81. package/lib/commands/remoteconfig-versions-list.js +7 -2
  82. package/lib/commands/setup-emulators-database.js +8 -7
  83. package/lib/commands/setup-emulators-firestore.js +8 -7
  84. package/lib/commands/setup-emulators-pubsub.js +5 -4
  85. package/lib/commands/setup-emulators-storage.js +4 -3
  86. package/lib/commands/setup-emulators-ui.js +8 -7
  87. package/lib/commands/target-apply.js +17 -16
  88. package/lib/commands/target-clear.js +11 -10
  89. package/lib/commands/target-remove.js +10 -9
  90. package/lib/commands/target.js +20 -20
  91. package/lib/config.js +6 -6
  92. package/lib/database/api.js +2 -2
  93. package/lib/defaultCredentials.js +3 -3
  94. package/lib/deploy/extensions/deploy.js +4 -4
  95. package/lib/deploy/extensions/deploymentSummary.js +5 -4
  96. package/lib/deploy/extensions/index.js +1 -0
  97. package/lib/deploy/extensions/params.js +1 -1
  98. package/lib/deploy/extensions/planner.js +3 -3
  99. package/lib/deploy/extensions/prepare.js +9 -9
  100. package/lib/deploy/extensions/release.js +1 -1
  101. package/lib/deploy/extensions/secrets.js +7 -7
  102. package/lib/deploy/extensions/validate.js +2 -2
  103. package/lib/deploy/functions/backend.js +6 -4
  104. package/lib/deploy/functions/checkIam.js +7 -7
  105. package/lib/deploy/functions/containerCleaner.js +3 -3
  106. package/lib/deploy/functions/deploy.js +4 -4
  107. package/lib/deploy/functions/ensureCloudBuildEnabled.js +3 -3
  108. package/lib/deploy/functions/index.js +1 -0
  109. package/lib/deploy/functions/prepare.js +27 -21
  110. package/lib/deploy/functions/prompts.js +5 -5
  111. package/lib/deploy/functions/release/executor.js +4 -1
  112. package/lib/deploy/functions/release/fabricator.js +5 -5
  113. package/lib/deploy/functions/release/index.js +2 -2
  114. package/lib/deploy/functions/release/planner.js +6 -6
  115. package/lib/deploy/functions/release/reporter.js +8 -4
  116. package/lib/deploy/functions/runtimes/discovery/index.js +2 -2
  117. package/lib/deploy/functions/runtimes/discovery/v1alpha1.js +14 -14
  118. package/lib/deploy/functions/runtimes/golang/index.js +11 -14
  119. package/lib/deploy/functions/runtimes/index.js +6 -10
  120. package/lib/deploy/functions/runtimes/node/index.js +6 -10
  121. package/lib/deploy/functions/runtimes/node/parseTriggers.js +3 -3
  122. package/lib/deploy/functions/runtimes/node/validate.js +2 -1
  123. package/lib/deploy/functions/services/storage.js +1 -1
  124. package/lib/deploy/functions/triggerRegionHelper.js +1 -1
  125. package/lib/deploy/functions/validate.js +4 -3
  126. package/lib/deploy/hosting/deploy.js +7 -7
  127. package/lib/deploy/hosting/uploader.js +1 -1
  128. package/lib/deploy/hosting/validate.js +3 -3
  129. package/lib/deploy/remoteconfig/prepare.js +3 -3
  130. package/lib/deploy/remoteconfig/release.js +3 -3
  131. package/lib/deploy/storage/deploy.js +1 -1
  132. package/lib/deploy/storage/release.js +2 -2
  133. package/lib/detectProjectRoot.js +5 -5
  134. package/lib/emulator/auth/apiSpec.js +13 -7
  135. package/lib/emulator/auth/handlers.js +3 -3
  136. package/lib/emulator/auth/index.js +1 -1
  137. package/lib/emulator/auth/operations.js +256 -248
  138. package/lib/emulator/auth/server.js +11 -8
  139. package/lib/emulator/auth/state.js +12 -12
  140. package/lib/emulator/commandUtils.js +5 -5
  141. package/lib/emulator/controller.js +16 -11
  142. package/lib/emulator/downloadableEmulators.js +10 -9
  143. package/lib/emulator/emulatorLogger.js +1 -1
  144. package/lib/emulator/functionsEmulator.js +107 -74
  145. package/lib/emulator/functionsEmulatorRuntime.js +36 -21
  146. package/lib/emulator/functionsEmulatorShell.js +3 -2
  147. package/lib/emulator/functionsRuntimeWorker.js +1 -1
  148. package/lib/emulator/hubExport.js +2 -2
  149. package/lib/emulator/storage/apis/firebase.js +2 -2
  150. package/lib/emulator/storage/apis/gcloud.js +2 -2
  151. package/lib/emulator/storage/cloudFunctions.js +1 -1
  152. package/lib/emulator/storage/files.js +14 -14
  153. package/lib/emulator/storage/index.js +2 -2
  154. package/lib/emulator/storage/metadata.js +7 -6
  155. package/lib/emulator/storage/rules/runtime.js +10 -9
  156. package/lib/emulator/storage/server.js +2 -2
  157. package/lib/ensureApiEnabled.js +7 -7
  158. package/lib/error.js +3 -3
  159. package/lib/extensions/askUserForConsent.js +3 -4
  160. package/lib/extensions/askUserForParam.js +11 -11
  161. package/lib/extensions/billingMigrationHelper.js +2 -2
  162. package/lib/extensions/changelog.js +4 -4
  163. package/lib/extensions/displayExtensionInfo.js +6 -6
  164. package/lib/extensions/emulator/optionsHelper.js +1 -1
  165. package/lib/extensions/emulator/specHelper.js +1 -1
  166. package/lib/extensions/emulator/triggerHelper.js +1 -1
  167. package/lib/extensions/export.js +6 -6
  168. package/lib/extensions/extensionsApi.js +69 -110
  169. package/lib/extensions/extensionsHelper.js +56 -43
  170. package/lib/extensions/listExtensions.js +1 -1
  171. package/lib/extensions/localHelper.js +1 -1
  172. package/lib/extensions/metricsTypeDef.js +2 -0
  173. package/lib/extensions/metricsUtils.js +98 -0
  174. package/lib/extensions/paramHelper.js +6 -6
  175. package/lib/extensions/provisioningHelper.js +13 -14
  176. package/lib/extensions/resolveSource.js +6 -6
  177. package/lib/extensions/secretsUtils.js +3 -3
  178. package/lib/extensions/updateHelper.js +10 -10
  179. package/lib/extensions/utils.js +1 -1
  180. package/lib/extensions/warnings.js +11 -10
  181. package/lib/fetchWebSetup.js +2 -2
  182. package/lib/filterTargets.js +2 -2
  183. package/lib/firestore/indexes.js +2 -2
  184. package/lib/fsAsync.js +3 -3
  185. package/lib/fsutils.js +2 -2
  186. package/lib/functional.js +2 -1
  187. package/lib/functions/env.js +1 -1
  188. package/lib/functions/runtimeConfigExport.js +4 -4
  189. package/lib/functionsConfig.js +7 -8
  190. package/lib/functionsShellCommandAction.js +4 -3
  191. package/lib/gcp/cloudmonitoring.js +74 -0
  192. package/lib/gcp/cloudscheduler.js +1 -1
  193. package/lib/gcp/iam.js +2 -2
  194. package/lib/gcp/resourceManager.js +2 -2
  195. package/lib/gcp/rules.js +18 -41
  196. package/lib/gcp/secretManager.js +3 -2
  197. package/lib/getDefaultDatabaseInstance.js +1 -1
  198. package/lib/getDefaultHostingSite.js +1 -1
  199. package/lib/getProjectNumber.js +2 -2
  200. package/lib/handlePreviewToggles.js +5 -5
  201. package/lib/hosting/api.js +6 -6
  202. package/lib/hosting/cloudRunProxy.js +6 -6
  203. package/lib/hosting/functionsProxy.js +3 -3
  204. package/lib/hosting/implicitInit.js +2 -2
  205. package/lib/hosting/normalizedHostingConfigs.js +3 -3
  206. package/lib/hosting/proxy.js +2 -2
  207. package/lib/init/features/account.js +7 -7
  208. package/lib/init/features/database.js +9 -9
  209. package/lib/init/features/emulators.js +8 -8
  210. package/lib/init/features/firestore/index.js +3 -3
  211. package/lib/init/features/firestore/indexes.js +2 -2
  212. package/lib/init/features/firestore/rules.js +2 -2
  213. package/lib/init/features/functions/golang.js +4 -4
  214. package/lib/init/features/functions/index.js +4 -4
  215. package/lib/init/features/hosting/github.js +31 -31
  216. package/lib/init/features/project.js +8 -8
  217. package/lib/init/features/remoteconfig.js +2 -2
  218. package/lib/init/features/storage.js +2 -2
  219. package/lib/listFiles.js +1 -1
  220. package/lib/management/apps.js +3 -3
  221. package/lib/management/projects.js +6 -6
  222. package/lib/previews.js +2 -2
  223. package/lib/profiler.js +1 -1
  224. package/lib/projectPath.js +1 -1
  225. package/lib/projectUtils.js +2 -2
  226. package/lib/prompt.js +0 -1
  227. package/lib/rc.js +1 -1
  228. package/lib/remoteconfig/get.js +14 -8
  229. package/lib/remoteconfig/rollback.js +13 -6
  230. package/lib/remoteconfig/versionslist.js +13 -7
  231. package/lib/requireAuth.js +2 -2
  232. package/lib/requireDatabaseInstance.js +1 -1
  233. package/lib/requireHostingSite.js +1 -1
  234. package/lib/requirePermissions.js +4 -4
  235. package/lib/rulesDeploy.js +2 -2
  236. package/lib/serve/functions.js +14 -7
  237. package/lib/serve/hosting.js +7 -7
  238. package/lib/utils.js +3 -2
  239. package/npm-shrinkwrap.json +24095 -0
  240. package/package.json +33 -30
  241. package/templates/init/hosting/index.html +1 -1
  242. package/CHANGELOG.md +0 -5
  243. package/lib/commands/functions-config-legacy.js +0 -45
  244. package/lib/prepareFirebaseRules.js +0 -58
@@ -16,10 +16,10 @@ const projectUtils_1 = require("../../projectUtils");
16
16
  const track_1 = require("../../track");
17
17
  const runtimes = require("./runtimes");
18
18
  const validate = require("./validate");
19
- const utils = require("../../utils");
20
19
  const logger_1 = require("../../logger");
21
20
  const triggerRegionHelper_1 = require("./triggerRegionHelper");
22
21
  const checkIam_1 = require("./checkIam");
22
+ const error_1 = require("../../error");
23
23
  function hasUserConfig(config) {
24
24
  return Object.keys(config).length > 1;
25
25
  }
@@ -34,31 +34,37 @@ async function maybeEnableAR(projectId) {
34
34
  return true;
35
35
  }
36
36
  async function prepare(context, options, payload) {
37
- if (!options.config.src.functions) {
38
- return;
37
+ const projectId = (0, projectUtils_1.needProjectId)(options);
38
+ const sourceDirName = options.config.get("functions.source");
39
+ if (!sourceDirName) {
40
+ throw new error_1.FirebaseError(`No functions code detected at default location (./functions), and no functions.source defined in firebase.json`);
39
41
  }
40
- const runtimeDelegate = await runtimes.getRuntimeDelegate(context, options);
42
+ const sourceDir = options.config.path(sourceDirName);
43
+ const delegateContext = {
44
+ projectId,
45
+ sourceDir,
46
+ projectDir: options.config.projectDir,
47
+ runtime: options.config.get("functions.runtime") || "",
48
+ };
49
+ const runtimeDelegate = await runtimes.getRuntimeDelegate(delegateContext);
41
50
  logger_1.logger.debug(`Validating ${runtimeDelegate.name} source`);
42
51
  await runtimeDelegate.validate();
43
52
  logger_1.logger.debug(`Building ${runtimeDelegate.name} source`);
44
53
  await runtimeDelegate.build();
45
- const projectId = projectUtils_1.needProjectId(options);
46
54
  const checkAPIsEnabled = await Promise.all([
47
55
  ensureApiEnabled.ensure(projectId, "cloudfunctions.googleapis.com", "functions"),
48
56
  ensureApiEnabled.check(projectId, "runtimeconfig.googleapis.com", "runtimeconfig", true),
49
- ensureCloudBuildEnabled_1.ensureCloudBuildEnabled(projectId),
57
+ (0, ensureCloudBuildEnabled_1.ensureCloudBuildEnabled)(projectId),
50
58
  maybeEnableAR(projectId),
51
59
  ]);
52
60
  context.runtimeConfigEnabled = checkAPIsEnabled[1];
53
61
  context.artifactRegistryEnabled = checkAPIsEnabled[3];
54
62
  const firebaseConfig = await functionsConfig.getFirebaseConfig(options);
55
63
  context.firebaseConfig = firebaseConfig;
56
- const runtimeConfig = await prepareFunctionsUpload_1.getFunctionsConfig(context);
57
- utils.assertDefined(options.config.src.functions.source, "Error: 'functions.source' is not defined");
58
- const source = options.config.src.functions.source;
64
+ const runtimeConfig = await (0, prepareFunctionsUpload_1.getFunctionsConfig)(context);
59
65
  const firebaseEnvs = functionsEnv.loadFirebaseEnvs(firebaseConfig, projectId);
60
66
  const userEnvOpt = {
61
- functionsSource: options.config.path(source),
67
+ functionsSource: sourceDir,
62
68
  projectId: projectId,
63
69
  projectAlias: options.projectAlias,
64
70
  };
@@ -71,7 +77,7 @@ async function prepare(context, options, payload) {
71
77
  : usedDotenv
72
78
  ? "dotenv"
73
79
  : "none";
74
- await track_1.track("functions_codebase_deploy_env_method", tag);
80
+ await (0, track_1.track)("functions_codebase_deploy_env_method", tag);
75
81
  logger_1.logger.debug(`Analyzing ${runtimeDelegate.name} backend spec`);
76
82
  const wantBackend = await runtimeDelegate.discoverSpec(runtimeConfig, firebaseEnvs);
77
83
  wantBackend.environmentVariables = Object.assign(Object.assign({}, userEnvs), firebaseEnvs);
@@ -90,16 +96,16 @@ async function prepare(context, options, payload) {
90
96
  await Promise.all(enablements);
91
97
  }
92
98
  if (backend.someEndpoint(wantBackend, () => true)) {
93
- utils_1.logBullet(clc.cyan.bold("functions:") +
99
+ (0, utils_1.logBullet)(clc.cyan.bold("functions:") +
94
100
  " preparing " +
95
- clc.bold(options.config.src.functions.source) +
101
+ clc.bold(sourceDirName) +
96
102
  " directory for uploading...");
97
103
  }
98
104
  if (backend.someEndpoint(wantBackend, (e) => e.platform === "gcfv1")) {
99
- context.functionsSourceV1 = await prepareFunctionsUpload_1.prepareFunctionsUpload(runtimeConfig, options);
105
+ context.functionsSourceV1 = await (0, prepareFunctionsUpload_1.prepareFunctionsUpload)(runtimeConfig, options);
100
106
  }
101
107
  if (backend.someEndpoint(wantBackend, (e) => e.platform === "gcfv2")) {
102
- context.functionsSourceV2 = await prepareFunctionsUpload_1.prepareFunctionsUpload(undefined, options);
108
+ context.functionsSourceV2 = await (0, prepareFunctionsUpload_1.prepareFunctionsUpload)(undefined, options);
103
109
  }
104
110
  for (const endpoint of backend.allEndpoints(wantBackend)) {
105
111
  endpoint.environmentVariables = wantBackend.environmentVariables;
@@ -108,16 +114,16 @@ async function prepare(context, options, payload) {
108
114
  return ensureApiEnabled.ensure(projectId, api, "functions", false);
109
115
  }));
110
116
  validate.functionIdsAreValid(backend.allEndpoints(wantBackend));
111
- context.filters = functionsDeployHelper_1.getFilterGroups(options);
117
+ context.filters = (0, functionsDeployHelper_1.getFilterGroups)(options);
112
118
  const matchingBackend = backend.matchingBackend(wantBackend, (endpoint) => {
113
- return functionsDeployHelper_1.functionMatchesAnyGroup(endpoint, context.filters);
119
+ return (0, functionsDeployHelper_1.functionMatchesAnyGroup)(endpoint, context.filters);
114
120
  });
115
121
  const haveBackend = await backend.existingBackend(context);
116
- await checkIam_1.ensureServiceAgentRoles(projectId, wantBackend, haveBackend);
122
+ await (0, checkIam_1.ensureServiceAgentRoles)(projectId, wantBackend, haveBackend);
117
123
  inferDetailsFromExisting(wantBackend, haveBackend, usedDotenv);
118
- await triggerRegionHelper_1.ensureTriggerRegions(wantBackend);
119
- await prompts_1.promptForFailurePolicies(options, matchingBackend, haveBackend);
120
- await prompts_1.promptForMinInstances(options, matchingBackend, haveBackend);
124
+ await (0, triggerRegionHelper_1.ensureTriggerRegions)(wantBackend);
125
+ await (0, prompts_1.promptForFailurePolicies)(options, matchingBackend, haveBackend);
126
+ await (0, prompts_1.promptForMinInstances)(options, matchingBackend, haveBackend);
121
127
  await backend.checkAvailability(context, wantBackend);
122
128
  }
123
129
  exports.prepare = prepare;
@@ -38,7 +38,7 @@ async function promptForFailurePolicies(options, want, have) {
38
38
  exit: 1,
39
39
  });
40
40
  }
41
- const proceed = await prompt_1.promptOnce({
41
+ const proceed = await (0, prompt_1.promptOnce)({
42
42
  type: "confirm",
43
43
  name: "confirm",
44
44
  default: false,
@@ -56,7 +56,7 @@ async function promptForFunctionDeletion(functionsToDelete, force, nonInteractiv
56
56
  }
57
57
  const deleteList = functionsToDelete
58
58
  .sort(backend.compareFunctions)
59
- .map((fn) => "\t" + functionsDeployHelper_1.getFunctionLabel(fn))
59
+ .map((fn) => "\t" + (0, functionsDeployHelper_1.getFunctionLabel)(fn))
60
60
  .join("\n");
61
61
  if (nonInteractive) {
62
62
  const deleteCommands = functionsToDelete
@@ -75,7 +75,7 @@ async function promptForFunctionDeletion(functionsToDelete, force, nonInteractiv
75
75
  "\n\nIf you are renaming a function or changing its region, it is recommended that you create the new " +
76
76
  "function first before deleting the old one to prevent event loss. For more info, visit " +
77
77
  clc.underline("https://firebase.google.com/docs/functions/manage-functions#modify" + "\n"));
78
- shouldDeleteFns = await prompt_1.promptOnce({
78
+ shouldDeleteFns = await (0, prompt_1.promptOnce)({
79
79
  type: "confirm",
80
80
  name: "confirm",
81
81
  default: false,
@@ -121,7 +121,7 @@ async function promptForMinInstances(options, want, have) {
121
121
  .filter((fn) => fn.minInstances)
122
122
  .sort(backend.compareFunctions)
123
123
  .map((fn) => {
124
- return (`\t${functionsDeployHelper_1.getFunctionLabel(fn)}: ${fn.minInstances} instances, ` +
124
+ return (`\t${(0, functionsDeployHelper_1.getFunctionLabel)(fn)}: ${fn.minInstances} instances, ` +
125
125
  backend.memoryOptionDisplayName(fn.availableMemoryMb || 256) +
126
126
  " of memory each");
127
127
  })
@@ -150,7 +150,7 @@ async function promptForMinInstances(options, want, have) {
150
150
  costLine +
151
151
  cudAnnotation;
152
152
  utils.logLabeledWarning("functions", warnMessage);
153
- const proceed = await prompt_1.promptOnce({
153
+ const proceed = await (0, prompt_1.promptOnce)({
154
154
  type: "confirm",
155
155
  name: "confirm",
156
156
  default: false,
@@ -9,7 +9,10 @@ async function handler(op) {
9
9
  }
10
10
  catch (err) {
11
11
  const code = err.status ||
12
- err.code || ((_b = (_a = err.context) === null || _a === void 0 ? void 0 : _a.response) === null || _b === void 0 ? void 0 : _b.statusCode) || ((_c = err.original) === null || _c === void 0 ? void 0 : _c.code) || ((_f = (_e = (_d = err.original) === null || _d === void 0 ? void 0 : _d.context) === null || _e === void 0 ? void 0 : _e.response) === null || _f === void 0 ? void 0 : _f.statusCode);
12
+ err.code ||
13
+ ((_b = (_a = err.context) === null || _a === void 0 ? void 0 : _a.response) === null || _b === void 0 ? void 0 : _b.statusCode) ||
14
+ ((_c = err.original) === null || _c === void 0 ? void 0 : _c.code) ||
15
+ ((_f = (_e = (_d = err.original) === null || _d === void 0 ? void 0 : _d.context) === null || _e === void 0 ? void 0 : _e.response) === null || _f === void 0 ? void 0 : _f.statusCode);
13
16
  if (code === 429 || code === 409) {
14
17
  throw err;
15
18
  }
@@ -119,7 +119,7 @@ class Fabricator {
119
119
  await this.createV2Function(endpoint);
120
120
  }
121
121
  else {
122
- functional_1.assertExhaustive(endpoint.platform);
122
+ (0, functional_1.assertExhaustive)(endpoint.platform);
123
123
  }
124
124
  await this.setTrigger(endpoint);
125
125
  }
@@ -139,7 +139,7 @@ class Fabricator {
139
139
  await this.updateV2Function(update.endpoint);
140
140
  }
141
141
  else {
142
- functional_1.assertExhaustive(update.endpoint.platform);
142
+ (0, functional_1.assertExhaustive)(update.endpoint.platform);
143
143
  }
144
144
  await this.setTrigger(update.endpoint);
145
145
  }
@@ -351,7 +351,7 @@ class Fabricator {
351
351
  await this.upsertScheduleV2(endpoint);
352
352
  return;
353
353
  }
354
- functional_1.assertExhaustive(endpoint.platform);
354
+ (0, functional_1.assertExhaustive)(endpoint.platform);
355
355
  }
356
356
  else if (backend.isTaskQueueTriggered(endpoint)) {
357
357
  await this.upsertTaskQueue(endpoint);
@@ -367,7 +367,7 @@ class Fabricator {
367
367
  await this.deleteScheduleV2(endpoint);
368
368
  return;
369
369
  }
370
- functional_1.assertExhaustive(endpoint.platform);
370
+ (0, functional_1.assertExhaustive)(endpoint.platform);
371
371
  }
372
372
  else if (backend.isTaskQueueTriggered(endpoint)) {
373
373
  await this.disableTaskQueue(endpoint);
@@ -415,7 +415,7 @@ class Fabricator {
415
415
  .catch(rethrowAs(endpoint, "disable task queue"));
416
416
  }
417
417
  logOpStart(op, endpoint) {
418
- const runtime = runtimes_1.getHumanFriendlyRuntimeName(endpoint.runtime);
418
+ const runtime = (0, runtimes_1.getHumanFriendlyRuntimeName)(endpoint.runtime);
419
419
  const label = helper.getFunctionLabel(endpoint);
420
420
  utils.logBullet(`${clc.bold.cyan("functions:")} ${op} ${runtime} function ${clc.bold(label)}...`);
421
421
  }
@@ -39,7 +39,7 @@ async function release(context, options, payload) {
39
39
  executor: new executor.QueueExecutor({}),
40
40
  sourceUrl: context.sourceUrl,
41
41
  storage: context.storage,
42
- appEngineLocation: functionsConfig_1.getAppEngineLocation(context.firebaseConfig),
42
+ appEngineLocation: (0, functionsConfig_1.getAppEngineLocation)(context.firebaseConfig),
43
43
  });
44
44
  const summary = await fab.applyPlan(plan);
45
45
  await reporter.logAndTrackDeployStats(summary);
@@ -71,7 +71,7 @@ function printTriggerUrls(results) {
71
71
  logger_1.logger.debug("Missing URI for HTTPS function in printTriggerUrls. This shouldn't happen");
72
72
  continue;
73
73
  }
74
- logger_1.logger.info(clc.bold("Function URL"), `(${functionsDeployHelper_1.getFunctionLabel(httpsFunc)}):`, httpsFunc.uri);
74
+ logger_1.logger.info(clc.bold("Function URL"), `(${(0, functionsDeployHelper_1.getFunctionLabel)(httpsFunc)}):`, httpsFunc.uri);
75
75
  }
76
76
  }
77
77
  exports.printTriggerUrls = printTriggerUrls;
@@ -14,7 +14,7 @@ function calculateRegionalChanges(want, have, options) {
14
14
  .map((id) => want[id]);
15
15
  const endpointsToDelete = Object.keys(have)
16
16
  .filter((id) => !want[id])
17
- .filter((id) => options.deleteAll || deploymentTool_1.isFirebaseManaged(have[id].labels || {}))
17
+ .filter((id) => options.deleteAll || (0, deploymentTool_1.isFirebaseManaged)(have[id].labels || {}))
18
18
  .map((id) => have[id]);
19
19
  const endpointsToUpdate = Object.keys(want)
20
20
  .filter((id) => have[id])
@@ -39,10 +39,10 @@ exports.calculateUpdate = calculateUpdate;
39
39
  function createDeploymentPlan(want, have, options = {}) {
40
40
  const deployment = {};
41
41
  want = backend.matchingBackend(want, (endpoint) => {
42
- return functionsDeployHelper_1.functionMatchesAnyGroup(endpoint, options.filters || []);
42
+ return (0, functionsDeployHelper_1.functionMatchesAnyGroup)(endpoint, options.filters || []);
43
43
  });
44
44
  have = backend.matchingBackend(have, (endpoint) => {
45
- return functionsDeployHelper_1.functionMatchesAnyGroup(endpoint, options.filters || []);
45
+ return (0, functionsDeployHelper_1.functionMatchesAnyGroup)(endpoint, options.filters || []);
46
46
  });
47
47
  const regions = new Set([...Object.keys(want.endpoints), ...Object.keys(have.endpoints)]);
48
48
  for (const region of regions) {
@@ -146,17 +146,17 @@ function checkForIllegalUpdate(want, have) {
146
146
  const wantType = triggerType(want);
147
147
  const haveType = triggerType(have);
148
148
  if (wantType != haveType) {
149
- throw new error_1.FirebaseError(`[${functionsDeployHelper_2.getFunctionLabel(want)}] Changing from ${haveType} function to ${wantType} function is not allowed. Please delete your function and create a new one instead.`);
149
+ throw new error_1.FirebaseError(`[${(0, functionsDeployHelper_2.getFunctionLabel)(want)}] Changing from ${haveType} function to ${wantType} function is not allowed. Please delete your function and create a new one instead.`);
150
150
  }
151
151
  if (want.platform == "gcfv1" && have.platform == "gcfv2") {
152
- throw new error_1.FirebaseError(`[${functionsDeployHelper_2.getFunctionLabel(want)}] Functions cannot be downgraded from GCFv2 to GCFv1`);
152
+ throw new error_1.FirebaseError(`[${(0, functionsDeployHelper_2.getFunctionLabel)(want)}] Functions cannot be downgraded from GCFv2 to GCFv1`);
153
153
  }
154
154
  exports.checkForV2Upgrade(want, have);
155
155
  }
156
156
  exports.checkForIllegalUpdate = checkForIllegalUpdate;
157
157
  function checkForV2Upgrade(want, have) {
158
158
  if (want.platform == "gcfv2" && have.platform == "gcfv1") {
159
- throw new error_1.FirebaseError(`[${functionsDeployHelper_2.getFunctionLabel(have)}] Upgrading from GCFv1 to GCFv2 is not yet supported. Please delete your old function or wait for this feature to be ready.`);
159
+ throw new error_1.FirebaseError(`[${(0, functionsDeployHelper_2.getFunctionLabel)(have)}] Upgrading from GCFv1 to GCFv2 is not yet supported. Please delete your old function or wait for this feature to be ready.`);
160
160
  }
161
161
  }
162
162
  exports.checkForV2Upgrade = checkForV2Upgrade;
@@ -85,7 +85,7 @@ function printErrors(summary) {
85
85
  logger_1.logger.info("Functions deploy had errors with the following functions:" +
86
86
  errored
87
87
  .filter((r) => !(r.error instanceof AbortedDeploymentError))
88
- .map((result) => `\n\t${functionsDeployHelper_1.getFunctionLabel(result.endpoint)}`)
88
+ .map((result) => `\n\t${(0, functionsDeployHelper_1.getFunctionLabel)(result.endpoint)}`)
89
89
  .join(""));
90
90
  printIamErrors(errored);
91
91
  printQuotaErrors(errored);
@@ -99,7 +99,7 @@ function printIamErrors(results) {
99
99
  }
100
100
  logger_1.logger.info("");
101
101
  logger_1.logger.info("Unable to set the invoker for the IAM policy on the following functions:" +
102
- iamFailures.map((result) => `\n\t${functionsDeployHelper_1.getFunctionLabel(result.endpoint)}`).join(""));
102
+ iamFailures.map((result) => `\n\t${(0, functionsDeployHelper_1.getFunctionLabel)(result.endpoint)}`).join(""));
103
103
  logger_1.logger.info("");
104
104
  logger_1.logger.info("Some common causes of this:");
105
105
  logger_1.logger.info("");
@@ -124,7 +124,11 @@ function printQuotaErrors(results) {
124
124
  return false;
125
125
  }
126
126
  const original = r.error.original;
127
- const code = (original === null || original === void 0 ? void 0 : original.status) || (original === null || original === void 0 ? void 0 : original.code) || ((_b = (_a = original === null || original === void 0 ? void 0 : original.context) === null || _a === void 0 ? void 0 : _a.response) === null || _b === void 0 ? void 0 : _b.statusCode) || ((_c = original === null || original === void 0 ? void 0 : original.original) === null || _c === void 0 ? void 0 : _c.code) || ((_f = (_e = (_d = original === null || original === void 0 ? void 0 : original.original) === null || _d === void 0 ? void 0 : _d.context) === null || _e === void 0 ? void 0 : _e.response) === null || _f === void 0 ? void 0 : _f.statusCode);
127
+ const code = (original === null || original === void 0 ? void 0 : original.status) ||
128
+ (original === null || original === void 0 ? void 0 : original.code) ||
129
+ ((_b = (_a = original === null || original === void 0 ? void 0 : original.context) === null || _a === void 0 ? void 0 : _a.response) === null || _b === void 0 ? void 0 : _b.statusCode) ||
130
+ ((_c = original === null || original === void 0 ? void 0 : original.original) === null || _c === void 0 ? void 0 : _c.code) ||
131
+ ((_f = (_e = (_d = original === null || original === void 0 ? void 0 : original.original) === null || _d === void 0 ? void 0 : _d.context) === null || _e === void 0 ? void 0 : _e.response) === null || _f === void 0 ? void 0 : _f.statusCode);
128
132
  return code === 429 || code === 409;
129
133
  });
130
134
  if (!hadQuotaError) {
@@ -145,7 +149,7 @@ function printAbortedErrors(results) {
145
149
  logger_1.logger.info("");
146
150
  logger_1.logger.info("Because there were errors creating or updating functions, the following " +
147
151
  "functions were not deleted" +
148
- aborted.map((result) => `\n\t${functionsDeployHelper_1.getFunctionLabel(result.endpoint)}`).join(""));
152
+ aborted.map((result) => `\n\t${(0, functionsDeployHelper_1.getFunctionLabel)(result.endpoint)}`).join(""));
149
153
  logger_1.logger.info(`To delete these, use ${clc.bold("firebase functions:delete")}`);
150
154
  }
151
155
  exports.printAbortedErrors = printAbortedErrors;
@@ -10,7 +10,7 @@ const logger_1 = require("../../../../logger");
10
10
  const api = require("../../.../../../../api");
11
11
  const v1alpha1 = require("./v1alpha1");
12
12
  const error_1 = require("../../../../error");
13
- exports.readFileAsync = util_1.promisify(fs.readFile);
13
+ exports.readFileAsync = (0, util_1.promisify)(fs.readFile);
14
14
  function yamlToBackend(yaml, project, region, runtime) {
15
15
  try {
16
16
  if (!yaml.specVersion) {
@@ -54,7 +54,7 @@ async function detectFromPort(port, project, runtime, timeout = 30000) {
54
54
  });
55
55
  while (true) {
56
56
  try {
57
- res = await Promise.race([node_fetch_1.default(`http://localhost:${port}/backend.yaml`), timedOut]);
57
+ res = await Promise.race([(0, node_fetch_1.default)(`http://localhost:${port}/backend.yaml`), timedOut]);
58
58
  break;
59
59
  }
60
60
  catch (err) {
@@ -9,8 +9,8 @@ function backendFromV1Alpha1(yaml, project, region, runtime) {
9
9
  const manifest = JSON.parse(JSON.stringify(yaml));
10
10
  const bkend = backend.empty();
11
11
  bkend.requiredAPIs = parseRequiredAPIs(manifest);
12
- parsing_1.requireKeys("", manifest, "endpoints");
13
- parsing_1.assertKeyTypes("", manifest, {
12
+ (0, parsing_1.requireKeys)("", manifest, "endpoints");
13
+ (0, parsing_1.assertKeyTypes)("", manifest, {
14
14
  specVersion: "string",
15
15
  requiredAPIs: "object",
16
16
  endpoints: "object",
@@ -41,7 +41,7 @@ function parseEndpoints(manifest, id, project, defaultRegion, runtime) {
41
41
  const allParsed = [];
42
42
  const prefix = `endpoints[${id}]`;
43
43
  const ep = manifest.endpoints[id];
44
- parsing_1.assertKeyTypes(prefix, ep, {
44
+ (0, parsing_1.assertKeyTypes)(prefix, ep, {
45
45
  region: "array",
46
46
  platform: "string",
47
47
  entryPoint: "string",
@@ -83,8 +83,8 @@ function parseEndpoints(manifest, id, project, defaultRegion, runtime) {
83
83
  for (const region of ep.region || [defaultRegion]) {
84
84
  let triggered;
85
85
  if (backend.isEventTriggered(ep)) {
86
- parsing_1.requireKeys(prefix + ".eventTrigger", ep.eventTrigger, "eventType", "eventFilters");
87
- parsing_1.assertKeyTypes(prefix + ".eventTrigger", ep.eventTrigger, {
86
+ (0, parsing_1.requireKeys)(prefix + ".eventTrigger", ep.eventTrigger, "eventType", "eventFilters");
87
+ (0, parsing_1.assertKeyTypes)(prefix + ".eventTrigger", ep.eventTrigger, {
88
88
  eventFilters: "object",
89
89
  eventType: "string",
90
90
  retry: "boolean",
@@ -94,19 +94,19 @@ function parseEndpoints(manifest, id, project, defaultRegion, runtime) {
94
94
  triggered = { eventTrigger: ep.eventTrigger };
95
95
  }
96
96
  else if (backend.isHttpsTriggered(ep)) {
97
- parsing_1.assertKeyTypes(prefix + ".httpsTrigger", ep.httpsTrigger, {
97
+ (0, parsing_1.assertKeyTypes)(prefix + ".httpsTrigger", ep.httpsTrigger, {
98
98
  invoker: "array",
99
99
  });
100
100
  triggered = { httpsTrigger: {} };
101
- proto_1.copyIfPresent(triggered.httpsTrigger, ep.httpsTrigger, "invoker");
101
+ (0, proto_1.copyIfPresent)(triggered.httpsTrigger, ep.httpsTrigger, "invoker");
102
102
  }
103
103
  else if (backend.isScheduleTriggered(ep)) {
104
- parsing_1.assertKeyTypes(prefix + ".scheduleTrigger", ep.scheduleTrigger, {
104
+ (0, parsing_1.assertKeyTypes)(prefix + ".scheduleTrigger", ep.scheduleTrigger, {
105
105
  schedule: "string",
106
106
  timeZone: "string",
107
107
  retryConfig: "object",
108
108
  });
109
- parsing_1.assertKeyTypes(prefix + ".scheduleTrigger.retryConfig", ep.scheduleTrigger.retryConfig, {
109
+ (0, parsing_1.assertKeyTypes)(prefix + ".scheduleTrigger.retryConfig", ep.scheduleTrigger.retryConfig, {
110
110
  retryCount: "number",
111
111
  maxDoublings: "number",
112
112
  minBackoffDuration: "string",
@@ -116,20 +116,20 @@ function parseEndpoints(manifest, id, project, defaultRegion, runtime) {
116
116
  triggered = { scheduleTrigger: ep.scheduleTrigger };
117
117
  }
118
118
  else if (backend.isTaskQueueTriggered(ep)) {
119
- parsing_1.assertKeyTypes(prefix + ".taskQueueTrigger", ep.taskQueueTrigger, {
119
+ (0, parsing_1.assertKeyTypes)(prefix + ".taskQueueTrigger", ep.taskQueueTrigger, {
120
120
  rateLimits: "object",
121
121
  retryConfig: "object",
122
122
  invoker: "array",
123
123
  });
124
124
  if (ep.taskQueueTrigger.rateLimits) {
125
- parsing_1.assertKeyTypes(prefix + ".taskQueueTrigger.rateLimits", ep.taskQueueTrigger.rateLimits, {
125
+ (0, parsing_1.assertKeyTypes)(prefix + ".taskQueueTrigger.rateLimits", ep.taskQueueTrigger.rateLimits, {
126
126
  maxBurstSize: "number",
127
127
  maxConcurrentDispatches: "number",
128
128
  maxDispatchesPerSecond: "number",
129
129
  });
130
130
  }
131
131
  if (ep.taskQueueTrigger.retryConfig) {
132
- parsing_1.assertKeyTypes(prefix + ".taskQueueTrigger.retryConfig", ep.taskQueueTrigger.retryConfig, {
132
+ (0, parsing_1.assertKeyTypes)(prefix + ".taskQueueTrigger.retryConfig", ep.taskQueueTrigger.retryConfig, {
133
133
  maxAttempts: "number",
134
134
  maxRetryDuration: "string",
135
135
  minBackoff: "string",
@@ -143,12 +143,12 @@ function parseEndpoints(manifest, id, project, defaultRegion, runtime) {
143
143
  throw new error_1.FirebaseError(`Do not recognize trigger type for endpoint ${id}. Try upgrading ` +
144
144
  "firebase-tools with npm install -g firebase-tools@latest");
145
145
  }
146
- parsing_1.requireKeys(prefix, ep, "entryPoint");
146
+ (0, parsing_1.requireKeys)(prefix, ep, "entryPoint");
147
147
  const parsed = Object.assign({ platform: ep.platform || "gcfv2", id,
148
148
  region,
149
149
  project,
150
150
  runtime, entryPoint: ep.entryPoint }, triggered);
151
- proto_1.copyIfPresent(parsed, ep, "availableMemoryMb", "maxInstances", "minInstances", "concurrency", "serviceAccountEmail", "timeout", "vpcConnector", "vpcConnectorEgressSettings", "labels", "ingressSettings", "environmentVariables");
151
+ (0, proto_1.copyIfPresent)(parsed, ep, "availableMemoryMb", "maxInstances", "minInstances", "concurrency", "serviceAccountEmail", "timeout", "vpcConnector", "vpcConnectorEgressSettings", "labels", "ingressSettings", "environmentVariables");
152
152
  allParsed.push(parsed);
153
153
  }
154
154
  return allParsed;
@@ -10,7 +10,6 @@ const spawn = require("cross-spawn");
10
10
  const error_1 = require("../../../../error");
11
11
  const logger_1 = require("../../../../logger");
12
12
  const discovery = require("../discovery");
13
- const projectUtils_1 = require("../../../../projectUtils");
14
13
  const gomod = require("./gomod");
15
14
  const VERSION_TO_RUNTIME = {
16
15
  "1.13": "go113",
@@ -19,21 +18,18 @@ exports.ADMIN_SDK = "firebase.google.com/go/v4";
19
18
  exports.FUNCTIONS_SDK = "github.com/FirebaseExtended/firebase-functions-go";
20
19
  exports.FUNCTIONS_CODEGEN = exports.FUNCTIONS_SDK + "/support/codegen";
21
20
  exports.FUNCTIONS_RUNTIME = exports.FUNCTIONS_SDK + "/support/runtime";
22
- async function tryCreateDelegate(context, options) {
23
- const relativeSourceDir = options.config.get("functions.source");
24
- const sourceDir = options.config.path(relativeSourceDir);
25
- const goModPath = path.join(sourceDir, "go.mod");
26
- const projectId = projectUtils_1.needProjectId(options);
21
+ async function tryCreateDelegate(context) {
22
+ const goModPath = path.join(context.sourceDir, "go.mod");
27
23
  let module;
28
24
  try {
29
- const modBuffer = await util_1.promisify(fs.readFile)(goModPath);
25
+ const modBuffer = await (0, util_1.promisify)(fs.readFile)(goModPath);
30
26
  module = gomod.parseModule(modBuffer.toString("utf8"));
31
27
  }
32
28
  catch (err) {
33
29
  logger_1.logger.debug("Customer code is not Golang code (or they aren't using gomod)");
34
30
  return;
35
31
  }
36
- let runtime = options.config.get("functions.runtime");
32
+ let runtime = context.runtime;
37
33
  if (!runtime) {
38
34
  if (!module.version) {
39
35
  throw new error_1.FirebaseError("Could not detect Golang version from go.mod");
@@ -43,7 +39,7 @@ async function tryCreateDelegate(context, options) {
43
39
  }
44
40
  runtime = VERSION_TO_RUNTIME[module.version];
45
41
  }
46
- return new Delegate(projectId, sourceDir, runtime, module);
42
+ return new Delegate(context.projectId, context.sourceDir, runtime, module);
47
43
  }
48
44
  exports.tryCreateDelegate = tryCreateDelegate;
49
45
  class Delegate {
@@ -59,7 +55,7 @@ class Delegate {
59
55
  }
60
56
  async build() {
61
57
  try {
62
- await util_1.promisify(fs.mkdir)(path.join(this.sourceDir, "autogen"));
58
+ await (0, util_1.promisify)(fs.mkdir)(path.join(this.sourceDir, "autogen"));
63
59
  }
64
60
  catch (err) {
65
61
  if ((err === null || err === void 0 ? void 0 : err.code) !== "EEXIST") {
@@ -80,18 +76,19 @@ class Delegate {
80
76
  children: [new Error(genBinary.stderr.toString())],
81
77
  });
82
78
  }
83
- await util_1.promisify(fs.writeFile)(path.join(this.sourceDir, "autogen", "main.go"), genBinary.stdout);
79
+ await (0, util_1.promisify)(fs.writeFile)(path.join(this.sourceDir, "autogen", "main.go"), genBinary.stdout);
84
80
  }
85
81
  watch() {
86
82
  return Promise.resolve(() => Promise.resolve());
87
83
  }
88
84
  serve(port, adminPort, envs) {
85
+ var _a;
89
86
  const childProcess = spawn("go", ["run", "./autogen"], {
90
87
  env: Object.assign(Object.assign({}, envs), { PORT: port.toString(), ADMIN_PORT: adminPort.toString(), HOME: process.env.HOME, PATH: process.env.PATH, GOPATH: process.env.GOPATH }),
91
88
  cwd: this.sourceDir,
92
89
  stdio: ["ignore", "pipe", "inherit"],
93
90
  });
94
- childProcess.stdout.on("data", (chunk) => {
91
+ (_a = childProcess.stdout) === null || _a === void 0 ? void 0 : _a.on("data", (chunk) => {
95
92
  logger_1.logger.debug(chunk.toString());
96
93
  });
97
94
  return Promise.resolve(async () => {
@@ -99,7 +96,7 @@ class Delegate {
99
96
  childProcess.once("exit", resolve);
100
97
  childProcess.once("error", reject);
101
98
  });
102
- await node_fetch_1.default(`http://localhost:${adminPort}/quitquitquit`);
99
+ await (0, node_fetch_1.default)(`http://localhost:${adminPort}/quitquitquit`);
103
100
  setTimeout(() => {
104
101
  if (!childProcess.killed) {
105
102
  childProcess.kill("SIGKILL");
@@ -111,7 +108,7 @@ class Delegate {
111
108
  async discoverSpec(configValues, envs) {
112
109
  let discovered = await discovery.detectFromYaml(this.sourceDir, this.projectId, this.runtime);
113
110
  if (!discovered) {
114
- const getPort = util_1.promisify(portfinder.getPort);
111
+ const getPort = (0, util_1.promisify)(portfinder.getPort);
115
112
  const port = await getPort();
116
113
  portfinder.basePort = port + 1;
117
114
  const adminPort = await getPort();
@@ -30,22 +30,18 @@ function getHumanFriendlyRuntimeName(runtime) {
30
30
  }
31
31
  exports.getHumanFriendlyRuntimeName = getHumanFriendlyRuntimeName;
32
32
  const factories = [node.tryCreateDelegate, golang.tryCreateDelegate];
33
- async function getRuntimeDelegate(context, options) {
34
- const sourceDirName = options.config.get("functions.source");
35
- if (!sourceDirName) {
36
- throw new error_1.FirebaseError(`No functions code detected at default location (./functions), and no functions.source defined in firebase.json`);
37
- }
38
- validate.functionsDirectoryExists(options, sourceDirName);
39
- const runtime = options.config.get("functions.runtime");
33
+ async function getRuntimeDelegate(context) {
34
+ const { projectDir, sourceDir, runtime } = context;
35
+ validate.functionsDirectoryExists(sourceDir, projectDir);
40
36
  if (runtime && !isValidRuntime(runtime)) {
41
- throw new error_1.FirebaseError("Cannot deploy function with runtime " + runtime);
37
+ throw new error_1.FirebaseError(`Cannot deploy function with runtime ${runtime}`);
42
38
  }
43
39
  for (const factory of factories) {
44
- const delegate = await factory(context, options);
40
+ const delegate = await factory(context);
45
41
  if (delegate) {
46
42
  return delegate;
47
43
  }
48
44
  }
49
- throw new error_1.FirebaseError(`Could not detect language for functions at ${options.config.get("functions.source")}`);
45
+ throw new error_1.FirebaseError(`Could not detect language for functions at ${sourceDir}`);
50
46
  }
51
47
  exports.getRuntimeDelegate = getRuntimeDelegate;
@@ -6,26 +6,22 @@ const fs = require("fs");
6
6
  const path = require("path");
7
7
  const error_1 = require("../../../../error");
8
8
  const parseRuntimeAndValidateSDK_1 = require("./parseRuntimeAndValidateSDK");
9
- const projectUtils_1 = require("../../../../projectUtils");
10
- const validate = require("./validate");
11
9
  const logger_1 = require("../../../../logger");
10
+ const validate = require("./validate");
12
11
  const versioning = require("./versioning");
13
12
  const parseTriggers = require("./parseTriggers");
14
- async function tryCreateDelegate(context, options) {
15
- const projectRelativeSourceDir = options.config.get("functions.source");
16
- const sourceDir = options.config.path(projectRelativeSourceDir);
17
- const packageJsonPath = path.join(sourceDir, "package.json");
18
- if (!(await util_1.promisify(fs.exists)(packageJsonPath))) {
13
+ async function tryCreateDelegate(context) {
14
+ const packageJsonPath = path.join(context.sourceDir, "package.json");
15
+ if (!(await (0, util_1.promisify)(fs.exists)(packageJsonPath))) {
19
16
  logger_1.logger.debug("Customer code is not Node");
20
17
  return undefined;
21
18
  }
22
- let runtime = options.config.get("functions.runtime") || "";
23
- runtime = parseRuntimeAndValidateSDK_1.getRuntimeChoice(sourceDir, runtime);
19
+ const runtime = (0, parseRuntimeAndValidateSDK_1.getRuntimeChoice)(context.sourceDir, context.runtime);
24
20
  if (!runtime.startsWith("nodejs")) {
25
21
  logger_1.logger.debug("Customer has a package.json but did not get a nodejs runtime. This should not happen");
26
22
  throw new error_1.FirebaseError(`Unexpected runtime ${runtime}`);
27
23
  }
28
- return new Delegate(projectUtils_1.needProjectId(options), options.config.projectDir, sourceDir, runtime);
24
+ return new Delegate(context.projectId, context.projectDir, context.sourceDir, runtime);
29
25
  }
30
26
  exports.tryCreateDelegate = tryCreateDelegate;
31
27
  class Delegate {
@@ -25,7 +25,7 @@ function parseTriggers(projectId, sourceDir, configValues, envs) {
25
25
  if (env.NODE_OPTIONS) {
26
26
  env.NODE_OPTIONS = removeInspectOptions(env.NODE_OPTIONS.split(" ")).join(" ");
27
27
  }
28
- const parser = child_process_1.fork(TRIGGER_PARSER, [sourceDir], {
28
+ const parser = (0, child_process_1.fork)(TRIGGER_PARSER, [sourceDir], {
29
29
  silent: true,
30
30
  env: env,
31
31
  execArgv: execArgv,
@@ -100,9 +100,9 @@ function addResourcesToBackend(projectId, runtime, annotation, want) {
100
100
  }
101
101
  }
102
102
  const endpoint = Object.assign({ platform: annotation.platform || "gcfv1", id: annotation.name, region: region, project: projectId, entryPoint: annotation.entryPoint, runtime: runtime }, triggered);
103
- if (annotation.vpcConnector) {
103
+ if (annotation.vpcConnector != null) {
104
104
  let maybeId = annotation.vpcConnector;
105
- if (!maybeId.includes("/")) {
105
+ if (maybeId && !maybeId.includes("/")) {
106
106
  maybeId = `projects/${projectId}/locations/${region}/connectors/${maybeId}`;
107
107
  }
108
108
  endpoint.vpcConnector = maybeId;
@@ -9,7 +9,8 @@ const cjson = require("cjson");
9
9
  function assertFunctionsSourcePresent(data, sourceDir, projectDir) {
10
10
  const indexJsFile = path.join(sourceDir, data.main || "index.js");
11
11
  if (!fsutils.fileExistsSync(indexJsFile)) {
12
- const msg = `${path.relative(projectDir, indexJsFile)} does not exist, can't deploy Cloud Functions`;
12
+ const relativeMainPath = path.relative(projectDir, indexJsFile);
13
+ const msg = `${relativeMainPath} does not exist, can't deploy Cloud Functions`;
13
14
  throw new error_1.FirebaseError(msg);
14
15
  }
15
16
  }
@@ -36,7 +36,7 @@ async function ensureStorageTriggerRegion(endpoint, eventTrigger) {
36
36
  }
37
37
  if (endpoint.region !== eventTrigger.region &&
38
38
  eventTrigger.region !== "us-central1" &&
39
- !location_1.regionInLocation(endpoint.region, eventTrigger.region)) {
39
+ !(0, location_1.regionInLocation)(endpoint.region, eventTrigger.region)) {
40
40
  throw new error_1.FirebaseError(`A function in region ${endpoint.region} cannot listen to a bucket in region ${eventTrigger.region}`);
41
41
  }
42
42
  }
@@ -9,7 +9,7 @@ async function ensureTriggerRegions(want) {
9
9
  if (ep.platform === "gcfv1" || !backend.isEventTriggered(ep)) {
10
10
  continue;
11
11
  }
12
- regionLookups.push(services_1.serviceForEndpoint(ep).ensureTriggerRegion(ep, ep.eventTrigger));
12
+ regionLookups.push((0, services_1.serviceForEndpoint)(ep).ensureTriggerRegion(ep, ep.eventTrigger));
13
13
  }
14
14
  await Promise.all(regionLookups);
15
15
  }