firebase-tools-with-isolate 13.6.4 → 13.9.0

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 (157) hide show
  1. package/README.md +4 -6
  2. package/lib/api.js +18 -8
  3. package/lib/apiv2.js +19 -13
  4. package/lib/apphosting/app.js +69 -0
  5. package/lib/apphosting/config.js +97 -0
  6. package/lib/{init/features/apphosting → apphosting}/constants.js +2 -2
  7. package/lib/apphosting/githubConnections.js +263 -0
  8. package/lib/apphosting/index.js +319 -0
  9. package/lib/{init/features/apphosting → apphosting}/repo.js +12 -12
  10. package/lib/apphosting/secrets/dialogs.js +170 -0
  11. package/lib/apphosting/secrets/index.js +103 -0
  12. package/lib/checkValidTargetFilters.js +8 -1
  13. package/lib/commands/apphosting-backends-create.js +9 -4
  14. package/lib/commands/apphosting-backends-delete.js +27 -30
  15. package/lib/commands/apphosting-backends-get.js +8 -8
  16. package/lib/commands/apphosting-backends-list.js +6 -7
  17. package/lib/commands/apphosting-secrets-access.js +24 -0
  18. package/lib/commands/apphosting-secrets-describe.js +29 -0
  19. package/lib/commands/apphosting-secrets-grantaccess.js +49 -0
  20. package/lib/commands/apphosting-secrets-set.js +56 -0
  21. package/lib/commands/dataconnect-sdk-generate.js +37 -0
  22. package/lib/commands/dataconnect-services-list.js +80 -0
  23. package/lib/commands/dataconnect-sql-diff.js +25 -0
  24. package/lib/commands/dataconnect-sql-migrate.js +45 -0
  25. package/lib/commands/deploy.js +27 -1
  26. package/lib/commands/firestore-databases-create.js +1 -0
  27. package/lib/commands/firestore-databases-restore.js +1 -0
  28. package/lib/commands/functions-secrets-access.js +2 -2
  29. package/lib/commands/functions-secrets-describe.js +14 -0
  30. package/lib/commands/functions-secrets-destroy.js +2 -2
  31. package/lib/commands/functions-secrets-get.js +3 -17
  32. package/lib/commands/functions-secrets-prune.js +2 -1
  33. package/lib/commands/functions-secrets-set.js +3 -19
  34. package/lib/commands/index.js +25 -6
  35. package/lib/commands/init.js +10 -3
  36. package/lib/commands/setup-emulators-dataconnect.js +12 -0
  37. package/lib/config.js +1 -0
  38. package/lib/dataconnect/build.js +22 -0
  39. package/lib/dataconnect/checkIam.js +30 -0
  40. package/lib/dataconnect/client.js +112 -0
  41. package/lib/dataconnect/dataplaneClient.js +16 -0
  42. package/lib/dataconnect/ensureApis.js +12 -0
  43. package/lib/dataconnect/errors.js +29 -0
  44. package/lib/dataconnect/fileUtils.js +92 -0
  45. package/lib/dataconnect/filters.js +45 -0
  46. package/lib/dataconnect/freeTrial.js +22 -0
  47. package/lib/dataconnect/graphqlError.js +12 -0
  48. package/lib/dataconnect/load.js +40 -0
  49. package/lib/dataconnect/names.js +46 -0
  50. package/lib/dataconnect/prompts.js +20 -0
  51. package/lib/dataconnect/provisionCloudSql.js +74 -0
  52. package/lib/dataconnect/schemaMigration.js +246 -0
  53. package/lib/dataconnect/types.js +22 -0
  54. package/lib/deploy/dataconnect/deploy.js +75 -0
  55. package/lib/deploy/dataconnect/index.js +9 -0
  56. package/lib/deploy/dataconnect/prepare.js +33 -0
  57. package/lib/deploy/dataconnect/release.js +65 -0
  58. package/lib/deploy/firestore/prepare.js +4 -2
  59. package/lib/deploy/functions/checkIam.js +6 -39
  60. package/lib/deploy/functions/containerCleaner.js +1 -15
  61. package/lib/deploy/functions/deploy.js +2 -2
  62. package/lib/deploy/functions/params.js +2 -2
  63. package/lib/deploy/functions/prepare.js +13 -3
  64. package/lib/deploy/functions/pricing.js +2 -2
  65. package/lib/deploy/functions/prompts.js +39 -7
  66. package/lib/deploy/functions/release/fabricator.js +12 -7
  67. package/lib/deploy/functions/release/index.js +17 -2
  68. package/lib/deploy/functions/release/planner.js +11 -3
  69. package/lib/deploy/functions/runtimes/discovery/index.js +3 -3
  70. package/lib/deploy/functions/runtimes/index.js +6 -43
  71. package/lib/deploy/functions/runtimes/node/index.js +3 -2
  72. package/lib/deploy/functions/runtimes/node/parseRuntimeAndValidateSDK.js +15 -34
  73. package/lib/deploy/functions/runtimes/python/index.js +10 -7
  74. package/lib/deploy/functions/runtimes/supported/index.js +80 -0
  75. package/lib/deploy/functions/runtimes/supported/types.js +74 -0
  76. package/lib/deploy/functions/services/index.js +4 -0
  77. package/lib/deploy/index.js +2 -0
  78. package/lib/downloadUtils.js +3 -2
  79. package/lib/emulator/constants.js +3 -0
  80. package/lib/emulator/controller.js +44 -13
  81. package/lib/emulator/dataconnectEmulator.js +95 -0
  82. package/lib/emulator/download.js +1 -1
  83. package/lib/emulator/downloadableEmulators.js +57 -8
  84. package/lib/emulator/functionsEmulator.js +2 -2
  85. package/lib/emulator/hub.js +5 -0
  86. package/lib/emulator/portUtils.js +3 -3
  87. package/lib/emulator/registry.js +6 -1
  88. package/lib/emulator/types.js +3 -0
  89. package/lib/experiments.js +31 -6
  90. package/lib/extensions/emulator/specHelper.js +9 -42
  91. package/lib/extensions/extensionsApi.js +2 -2
  92. package/lib/extensions/localHelper.js +3 -3
  93. package/lib/firestore/pretty-print.js +5 -0
  94. package/lib/frameworks/astro/index.js +1 -1
  95. package/lib/frameworks/flutter/index.js +2 -2
  96. package/lib/frameworks/next/constants.js +2 -1
  97. package/lib/frameworks/next/index.js +27 -15
  98. package/lib/frameworks/next/utils.js +33 -3
  99. package/lib/functional.js +2 -2
  100. package/lib/functions/events/v2.js +7 -1
  101. package/lib/functions/python.js +4 -3
  102. package/lib/functions/secrets.js +40 -22
  103. package/lib/gcp/apphosting.js +25 -3
  104. package/lib/gcp/cloudbuild.js +7 -3
  105. package/lib/gcp/cloudfunctions.js +5 -5
  106. package/lib/gcp/cloudfunctionsv2.js +3 -3
  107. package/lib/gcp/cloudscheduler.js +2 -2
  108. package/lib/gcp/cloudsql/cloudsqladmin.js +174 -0
  109. package/lib/gcp/cloudsql/connect.js +144 -0
  110. package/lib/gcp/cloudsql/fbToolsAuthClient.js +44 -0
  111. package/lib/gcp/computeEngine.js +7 -0
  112. package/lib/gcp/devConnect.js +25 -12
  113. package/lib/gcp/firedata.js +27 -0
  114. package/lib/gcp/iam.js +41 -1
  115. package/lib/gcp/secretManager.js +55 -7
  116. package/lib/gcp/serviceusage.js +24 -5
  117. package/lib/hosting/interactive.js +4 -0
  118. package/lib/init/features/dataconnect/index.js +166 -0
  119. package/lib/init/features/emulators.js +13 -1
  120. package/lib/init/features/functions/index.js +19 -3
  121. package/lib/init/features/functions/npm-dependencies.js +12 -23
  122. package/lib/init/features/functions/python.js +4 -3
  123. package/lib/init/features/genkit.js +53 -0
  124. package/lib/init/features/hosting/github.js +4 -5
  125. package/lib/init/features/index.js +6 -2
  126. package/lib/init/index.js +2 -0
  127. package/lib/init/spawn.js +23 -0
  128. package/lib/logger.js +22 -2
  129. package/lib/operation-poller.js +8 -2
  130. package/lib/rc.js +9 -1
  131. package/lib/requireAuth.js +1 -8
  132. package/lib/requireTosAcceptance.js +22 -0
  133. package/lib/utils.js +76 -8
  134. package/package.json +11 -5
  135. package/schema/connector-yaml.json +54 -0
  136. package/schema/dataconnect-yaml.json +72 -0
  137. package/schema/firebase-config.json +115 -2
  138. package/templates/extensions/javascript/package.lint.json +2 -2
  139. package/templates/extensions/javascript/package.nolint.json +2 -2
  140. package/templates/extensions/typescript/package.lint.json +2 -2
  141. package/templates/extensions/typescript/package.nolint.json +2 -2
  142. package/templates/init/dataconnect/connector.yaml +2 -0
  143. package/templates/init/dataconnect/dataconnect.yaml +10 -0
  144. package/templates/init/dataconnect/mutations.gql +30 -0
  145. package/templates/init/dataconnect/queries.gql +51 -0
  146. package/templates/init/dataconnect/schema.gql +28 -0
  147. package/templates/init/functions/javascript/_gitignore +2 -1
  148. package/templates/init/functions/javascript/package.lint.json +2 -2
  149. package/templates/init/functions/javascript/package.nolint.json +2 -2
  150. package/templates/init/functions/python/_gitignore +1 -0
  151. package/templates/init/functions/typescript/_eslintrc +1 -0
  152. package/templates/init/functions/typescript/_gitignore +1 -0
  153. package/templates/init/functions/typescript/package.lint.json +2 -2
  154. package/templates/init/functions/typescript/package.nolint.json +2 -2
  155. package/lib/init/features/apphosting/index.js +0 -229
  156. package/lib/monospace/index.js +0 -82
  157. /package/lib/{monospace/interfaces.js → gcp/cloudsql/types.js} +0 -0
@@ -23,9 +23,9 @@ const EMULATOR_UPDATE_DETAILS = {
23
23
  expectedChecksum: "2fd771101c0e1f7898c04c9204f2ce63",
24
24
  },
25
25
  firestore: {
26
- version: "1.19.4",
27
- expectedSize: 65913000,
28
- expectedChecksum: "a861bfa9d12ef69645b41e2f3bd8db8d",
26
+ version: "1.19.6",
27
+ expectedSize: 66349770,
28
+ expectedChecksum: "2eaabbe3cdb4867df585b7ec5505bad7",
29
29
  },
30
30
  storage: {
31
31
  version: "1.1.3",
@@ -44,6 +44,17 @@ const EMULATOR_UPDATE_DETAILS = {
44
44
  expectedSize: 65611398,
45
45
  expectedChecksum: "70bb840321423e6ae621a3ae2f314903",
46
46
  },
47
+ dataconnect: process.platform === "darwin"
48
+ ? {
49
+ version: "1.1.17",
50
+ expectedSize: 25602224,
51
+ expectedChecksum: "1f9e3dd040a0ac4d1cb4d9dde4a3c0b0",
52
+ }
53
+ : {
54
+ version: "1.1.17",
55
+ expectedSize: 23036912,
56
+ expectedChecksum: "a0ec0517108f842ed06fea14fe7c7e56",
57
+ },
47
58
  };
48
59
  exports.DownloadDetails = {
49
60
  database: {
@@ -107,6 +118,22 @@ exports.DownloadDetails = {
107
118
  namePrefix: "pubsub-emulator",
108
119
  },
109
120
  },
121
+ dataconnect: {
122
+ downloadPath: path.join(CACHE_DIR, `dataconnect-emulator-${EMULATOR_UPDATE_DETAILS.dataconnect.version}`),
123
+ version: EMULATOR_UPDATE_DETAILS.dataconnect.version,
124
+ binaryPath: path.join(CACHE_DIR, `dataconnect-emulator-${EMULATOR_UPDATE_DETAILS.dataconnect.version}`),
125
+ opts: {
126
+ cacheDir: CACHE_DIR,
127
+ remoteUrl: process.platform === "darwin"
128
+ ? `https://storage.googleapis.com/firemat-preview-drop/emulator/dataconnect-emulator-macos-v${EMULATOR_UPDATE_DETAILS.dataconnect.version}`
129
+ : `https://storage.googleapis.com/firemat-preview-drop/emulator/dataconnect-emulator-linux-v${EMULATOR_UPDATE_DETAILS.dataconnect.version}`,
130
+ expectedSize: EMULATOR_UPDATE_DETAILS.dataconnect.expectedSize,
131
+ expectedChecksum: EMULATOR_UPDATE_DETAILS.dataconnect.expectedChecksum,
132
+ skipChecksumAndSize: false,
133
+ namePrefix: "dataconnect-emulator",
134
+ auth: true,
135
+ },
136
+ },
110
137
  };
111
138
  const EmulatorDetails = {
112
139
  database: {
@@ -134,6 +161,11 @@ const EmulatorDetails = {
134
161
  instance: null,
135
162
  stdout: null,
136
163
  },
164
+ dataconnect: {
165
+ name: types_1.Emulators.DATACONNECT,
166
+ instance: null,
167
+ stdout: null,
168
+ },
137
169
  };
138
170
  const Commands = {
139
171
  database: {
@@ -147,6 +179,7 @@ const Commands = {
147
179
  "single_project_mode",
148
180
  ],
149
181
  joinArgs: false,
182
+ shell: false,
150
183
  },
151
184
  firestore: {
152
185
  binary: "java",
@@ -168,6 +201,7 @@ const Commands = {
168
201
  "single_project_mode",
169
202
  ],
170
203
  joinArgs: false,
204
+ shell: false,
171
205
  },
172
206
  storage: {
173
207
  binary: "java",
@@ -179,18 +213,28 @@ const Commands = {
179
213
  ],
180
214
  optionalArgs: [],
181
215
  joinArgs: false,
216
+ shell: false,
182
217
  },
183
218
  pubsub: {
184
219
  binary: getExecPath(types_1.Emulators.PUBSUB),
185
220
  args: [],
186
221
  optionalArgs: ["port", "host"],
187
222
  joinArgs: true,
223
+ shell: true,
188
224
  },
189
225
  ui: {
190
226
  binary: "node",
191
227
  args: [getExecPath(types_1.Emulators.UI)],
192
228
  optionalArgs: [],
193
229
  joinArgs: false,
230
+ shell: false,
231
+ },
232
+ dataconnect: {
233
+ binary: getExecPath(types_1.Emulators.DATACONNECT),
234
+ args: ["dev"],
235
+ optionalArgs: ["http_port", "grpc_port", "config_dir", "local_connection_string", "project_id"],
236
+ joinArgs: true,
237
+ shell: true,
194
238
  },
195
239
  };
196
240
  function getExecPath(name) {
@@ -237,6 +281,7 @@ function _getCommand(emulator, args) {
237
281
  args: cmdLineArgs,
238
282
  optionalArgs: baseCmd.optionalArgs,
239
283
  joinArgs: baseCmd.joinArgs,
284
+ shell: baseCmd.shell,
240
285
  };
241
286
  }
242
287
  exports._getCommand = _getCommand;
@@ -272,11 +317,15 @@ async function _runBinary(emulator, command, extraEnv) {
272
317
  const logger = emulatorLogger_1.EmulatorLogger.forEmulator(emulator.name);
273
318
  emulator.stdout = fs.createWriteStream(getLogFileName(emulator.name));
274
319
  try {
275
- emulator.instance = childProcess.spawn(command.binary, command.args, {
320
+ const opts = {
276
321
  env: { ...process.env, ...extraEnv },
277
322
  detached: true,
278
323
  stdio: ["inherit", "pipe", "pipe"],
279
- });
324
+ };
325
+ if (command.shell && utils.IS_WINDOWS) {
326
+ opts.shell = true;
327
+ }
328
+ emulator.instance = childProcess.spawn(command.binary, command.args, opts);
280
329
  }
281
330
  catch (e) {
282
331
  if (e.code === "EACCES") {
@@ -353,10 +402,10 @@ async function stop(targetName) {
353
402
  exports.stop = stop;
354
403
  async function downloadIfNecessary(targetName) {
355
404
  const hasEmulator = fs.existsSync(getExecPath(targetName));
356
- if (hasEmulator) {
357
- return;
405
+ if (!hasEmulator) {
406
+ await (0, download_1.downloadEmulator)(targetName);
358
407
  }
359
- await (0, download_1.downloadEmulator)(targetName);
408
+ return Commands[targetName];
360
409
  }
361
410
  exports.downloadIfNecessary = downloadIfNecessary;
362
411
  async function start(targetName, args, extraEnv = {}) {
@@ -300,9 +300,9 @@ class FunctionsEmulator {
300
300
  runtime: emulatableBackend.runtime,
301
301
  };
302
302
  const runtimeDelegate = await runtimes.getRuntimeDelegate(runtimeDelegateContext);
303
- logger_1.logger.debug(`Validating ${runtimeDelegate.name} source`);
303
+ logger_1.logger.debug(`Validating ${runtimeDelegate.language} source`);
304
304
  await runtimeDelegate.validate();
305
- logger_1.logger.debug(`Building ${runtimeDelegate.name} source`);
305
+ logger_1.logger.debug(`Building ${runtimeDelegate.language} source`);
306
306
  await runtimeDelegate.build();
307
307
  emulatableBackend.runtime = runtimeDelegate.runtime;
308
308
  emulatableBackend.bin = runtimeDelegate.bin;
@@ -60,6 +60,11 @@ class EmulatorHub extends ExpressBasedEmulator_1.ExpressBasedEmulator {
60
60
  res.json(body);
61
61
  });
62
62
  app.post(EmulatorHub.PATH_EXPORT, async (req, res) => {
63
+ if (req.headers.origin) {
64
+ res.status(403).json({
65
+ message: `Export cannot be triggered by external callers.`,
66
+ });
67
+ }
63
68
  const path = req.body.path;
64
69
  const initiatedBy = req.body.initiatedBy || "unknown";
65
70
  utils.logLabeledBullet("emulators", `Received export request. Exporting data to ${path}.`);
@@ -131,9 +131,8 @@ async function checkListenable(arg1, port) {
131
131
  });
132
132
  }
133
133
  exports.checkListenable = checkListenable;
134
- async function waitForPortUsed(port, host) {
135
- const interval = 250;
136
- const timeout = 60000;
134
+ async function waitForPortUsed(port, host, timeout = 60000) {
135
+ const interval = 200;
137
136
  try {
138
137
  await tcpport.waitUntilUsedOnHost(port, host, interval, timeout);
139
138
  }
@@ -147,6 +146,7 @@ const EMULATOR_CAN_LISTEN_ON_PRIMARY_ONLY = {
147
146
  firestore: true,
148
147
  "firestore.websocket": true,
149
148
  pubsub: true,
149
+ dataconnect: true,
150
150
  hub: false,
151
151
  ui: false,
152
152
  auth: true,
@@ -8,6 +8,7 @@ const constants_1 = require("./constants");
8
8
  const emulatorLogger_1 = require("./emulatorLogger");
9
9
  const utils_1 = require("../utils");
10
10
  const apiv2_1 = require("../apiv2");
11
+ const downloadableEmulators_1 = require("./downloadableEmulators");
11
12
  class EmulatorRegistry {
12
13
  static async start(instance) {
13
14
  const description = constants_1.Constants.description(instance.getName());
@@ -18,7 +19,7 @@ class EmulatorRegistry {
18
19
  await instance.start();
19
20
  if (instance.getName() !== types_1.Emulators.EXTENSIONS) {
20
21
  const info = instance.getInfo();
21
- await portUtils.waitForPortUsed(info.port, (0, utils_1.connectableHostname)(info.host));
22
+ await portUtils.waitForPortUsed(info.port, (0, utils_1.connectableHostname)(info.host), info.timeout);
22
23
  }
23
24
  }
24
25
  static async stop(name) {
@@ -47,6 +48,7 @@ class EmulatorRegistry {
47
48
  auth: 3.3,
48
49
  storage: 3.5,
49
50
  eventarc: 3.6,
51
+ dataconnect: 3.7,
50
52
  hub: 4,
51
53
  logging: 5,
52
54
  };
@@ -85,6 +87,9 @@ class EmulatorRegistry {
85
87
  host: (0, utils_1.connectableHostname)(info.host),
86
88
  };
87
89
  }
90
+ static getDetails(emulator) {
91
+ return (0, downloadableEmulators_1.get)(emulator);
92
+ }
88
93
  static url(emulator, req) {
89
94
  const url = new URL("http://unknown/");
90
95
  if (req) {
@@ -15,6 +15,7 @@ var Emulators;
15
15
  Emulators["STORAGE"] = "storage";
16
16
  Emulators["EXTENSIONS"] = "extensions";
17
17
  Emulators["EVENTARC"] = "eventarc";
18
+ Emulators["DATACONNECT"] = "dataconnect";
18
19
  })(Emulators = exports.Emulators || (exports.Emulators = {}));
19
20
  exports.DOWNLOADABLE_EMULATORS = [
20
21
  Emulators.FIRESTORE,
@@ -22,6 +23,7 @@ exports.DOWNLOADABLE_EMULATORS = [
22
23
  Emulators.PUBSUB,
23
24
  Emulators.UI,
24
25
  Emulators.STORAGE,
26
+ Emulators.DATACONNECT,
25
27
  ];
26
28
  exports.IMPORT_EXPORT_EMULATORS = [
27
29
  Emulators.FIRESTORE,
@@ -38,6 +40,7 @@ exports.ALL_SERVICE_EMULATORS = [
38
40
  Emulators.PUBSUB,
39
41
  Emulators.STORAGE,
40
42
  Emulators.EVENTARC,
43
+ Emulators.DATACONNECT,
41
44
  ].filter((v) => v);
42
45
  exports.EMULATORS_SUPPORTED_BY_FUNCTIONS = [
43
46
  Emulators.FIRESTORE,
@@ -20,11 +20,13 @@ exports.ALL_EXPERIMENTS = experiments({
20
20
  rtdbmanagement: {
21
21
  shortDescription: "Use new endpoint to administer realtime database instances",
22
22
  },
23
- pythonfunctions: {
24
- shortDescription: "Python support for Cloud Functions for Firebase",
25
- fullDescription: "Adds the ability to initializea and deploy Cloud " +
26
- "Functions for Firebase in Python. While this feature is experimental " +
27
- "breaking API changes are allowed in MINOR API revisions",
23
+ functionsv2deployoptimizations: {
24
+ shortDescription: "Optimize deployments of v2 firebase functions",
25
+ fullDescription: "Reuse build images across funtions to increase performance and reliaibility " +
26
+ "of deploys. This has been made an experiment due to backend bugs that are " +
27
+ "temporarily causing failures in some regions with this optimization enabled",
28
+ public: true,
29
+ default: false,
28
30
  },
29
31
  deletegcfartifacts: {
30
32
  shortDescription: `Add the ${(0, colorette_1.bold)("functions:deletegcfartifacts")} command to purge docker build images`,
@@ -39,6 +41,18 @@ exports.ALL_EXPERIMENTS = experiments({
39
41
  "of how that image was created.",
40
42
  public: true,
41
43
  },
44
+ automaticallydeletegcfartifacts: {
45
+ shortDescription: "Control whether functions cleans up images after deploys",
46
+ fullDescription: "To control costs, Firebase defaults to automatically deleting containers " +
47
+ "created during the build process. This has the side-effect of preventing " +
48
+ "users from rolling back to previous revisions using the Run API. To change " +
49
+ `this behavior, call ${(0, colorette_1.bold)("experiments:disable deletegcfartifactsondeploy")} ` +
50
+ `consider also calling ${(0, colorette_1.bold)("experiments:enable deletegcfartifacts")} ` +
51
+ `to enable the new command ${(0, colorette_1.bold)("functions:deletegcfartifacts")} which` +
52
+ "lets you clean up images manually",
53
+ public: true,
54
+ default: true,
55
+ },
42
56
  emulatoruisnapshot: {
43
57
  shortDescription: "Load pre-release versions of the emulator UI",
44
58
  },
@@ -74,7 +88,18 @@ exports.ALL_EXPERIMENTS = experiments({
74
88
  },
75
89
  apphosting: {
76
90
  shortDescription: "Allow CLI option for Frameworks",
77
- default: false,
91
+ default: true,
92
+ public: false,
93
+ },
94
+ dataconnect: {
95
+ shortDescription: "Enable Data Connect related features.",
96
+ fullDescription: "Enable Data Connect related features.",
97
+ public: false,
98
+ },
99
+ genkit: {
100
+ shortDescription: "Enable Genkit related features.",
101
+ fullDescription: "Enable Genkit related features.",
102
+ default: true,
78
103
  public: false,
79
104
  },
80
105
  });
@@ -1,12 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getRuntime = exports.DEFAULT_RUNTIME = exports.getFunctionProperties = exports.getFunctionResourcesWithParamSubstitution = exports.readFileFromDirectory = exports.readPostinstall = exports.readExtensionYaml = void 0;
4
- const yaml = require("js-yaml");
5
- const path = require("path");
6
- const fs = require("fs-extra");
3
+ exports.getRuntime = exports.DEFAULT_RUNTIME = exports.getFunctionProperties = exports.getFunctionResourcesWithParamSubstitution = exports.readPostinstall = exports.readExtensionYaml = void 0;
4
+ const supported = require("../../deploy/functions/runtimes/supported");
7
5
  const error_1 = require("../../error");
8
6
  const extensionsHelper_1 = require("../extensionsHelper");
9
7
  const utils_1 = require("../utils");
8
+ const utils_2 = require("../../utils");
10
9
  const SPEC_FILE = "extension.yaml";
11
10
  const POSTINSTALL_FILE = "POSTINSTALL.md";
12
11
  const validFunctionTypes = [
@@ -14,21 +13,10 @@ const validFunctionTypes = [
14
13
  "firebaseextensions.v1beta.v2function",
15
14
  "firebaseextensions.v1beta.scheduledFunction",
16
15
  ];
17
- function wrappedSafeLoad(source) {
18
- try {
19
- return yaml.safeLoad(source);
20
- }
21
- catch (err) {
22
- if (err instanceof yaml.YAMLException) {
23
- throw new error_1.FirebaseError(`YAML Error: ${err.message}`, { original: err });
24
- }
25
- throw err;
26
- }
27
- }
28
16
  async function readExtensionYaml(directory) {
29
- const extensionYaml = await readFileFromDirectory(directory, SPEC_FILE);
17
+ const extensionYaml = await (0, utils_2.readFileFromDirectory)(directory, SPEC_FILE);
30
18
  const source = extensionYaml.source;
31
- const spec = wrappedSafeLoad(source);
19
+ const spec = (0, utils_2.wrappedSafeLoad)(source);
32
20
  spec.params = spec.params ?? [];
33
21
  spec.systemParams = spec.systemParams ?? [];
34
22
  spec.resources = spec.resources ?? [];
@@ -42,31 +30,10 @@ async function readExtensionYaml(directory) {
42
30
  }
43
31
  exports.readExtensionYaml = readExtensionYaml;
44
32
  async function readPostinstall(directory) {
45
- const content = await readFileFromDirectory(directory, POSTINSTALL_FILE);
33
+ const content = await (0, utils_2.readFileFromDirectory)(directory, POSTINSTALL_FILE);
46
34
  return content.source;
47
35
  }
48
36
  exports.readPostinstall = readPostinstall;
49
- function readFileFromDirectory(directory, file) {
50
- return new Promise((resolve, reject) => {
51
- fs.readFile(path.resolve(directory, file), "utf8", (err, data) => {
52
- if (err) {
53
- if (err.code === "ENOENT") {
54
- return reject(new error_1.FirebaseError(`Could not find "${file}" in "${directory}"`, { original: err }));
55
- }
56
- reject(new error_1.FirebaseError(`Failed to read file "${file}" in "${directory}"`, { original: err }));
57
- }
58
- else {
59
- resolve(data);
60
- }
61
- });
62
- }).then((source) => {
63
- return {
64
- source,
65
- sourceDirectory: directory,
66
- };
67
- });
68
- }
69
- exports.readFileFromDirectory = readFileFromDirectory;
70
37
  function getFunctionResourcesWithParamSubstitution(extensionSpec, params) {
71
38
  const rawResources = extensionSpec.resources.filter((resource) => validFunctionTypes.includes(resource.type));
72
39
  return (0, extensionsHelper_1.substituteParams)(rawResources, params);
@@ -76,7 +43,7 @@ function getFunctionProperties(resources) {
76
43
  return resources.map((r) => r.properties);
77
44
  }
78
45
  exports.getFunctionProperties = getFunctionProperties;
79
- exports.DEFAULT_RUNTIME = "nodejs14";
46
+ exports.DEFAULT_RUNTIME = supported.latest("nodejs");
80
47
  function getRuntime(resources) {
81
48
  if (resources.length === 0) {
82
49
  return exports.DEFAULT_RUNTIME;
@@ -87,7 +54,7 @@ function getRuntime(resources) {
87
54
  if (!runtime) {
88
55
  return exports.DEFAULT_RUNTIME;
89
56
  }
90
- if (!/^(nodejs)?([0-9]+)/.test(runtime)) {
57
+ if (!supported.runtimeIsLanguage(runtime, "nodejs")) {
91
58
  invalidRuntimes.push(runtime);
92
59
  return exports.DEFAULT_RUNTIME;
93
60
  }
@@ -96,6 +63,6 @@ function getRuntime(resources) {
96
63
  if (invalidRuntimes.length) {
97
64
  throw new error_1.FirebaseError(`The following runtimes are not supported by the Emulator Suite: ${invalidRuntimes.join(", ")}. \n Only Node runtimes are supported.`);
98
65
  }
99
- return runtimes.sort()[runtimes.length - 1];
66
+ return supported.latest("nodejs", runtimes);
100
67
  }
101
68
  exports.getRuntime = getRuntime;
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.refNotFoundError = exports.getExtension = exports.listExtensionVersions = exports.listExtensions = exports.getExtensionVersion = exports.getSource = exports.createSource = exports.populateSpec = exports.updateInstanceFromRegistry = exports.updateInstance = exports.configureInstance = exports.listInstances = exports.getInstance = exports.deleteInstance = exports.createInstance = void 0;
4
- const yaml = require("js-yaml");
4
+ const yaml = require("yaml");
5
5
  const clc = require("colorette");
6
6
  const apiv2_1 = require("../apiv2");
7
7
  const api_1 = require("../api");
@@ -225,7 +225,7 @@ function populateSpec(spec) {
225
225
  for (const r of spec.resources) {
226
226
  try {
227
227
  if (r.propertiesYaml) {
228
- r.properties = yaml.safeLoad(r.propertiesYaml);
228
+ r.properties = yaml.parse(r.propertiesYaml);
229
229
  }
230
230
  }
231
231
  catch (err) {
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.isLocalExtension = exports.readFile = exports.findExtensionYaml = exports.getLocalExtensionSpec = exports.EXTENSIONS_SPEC_FILE = void 0;
4
4
  const fs = require("fs-extra");
5
5
  const path = require("path");
6
- const yaml = require("js-yaml");
6
+ const yaml = require("yaml");
7
7
  const fsutils_1 = require("../fsutils");
8
8
  const error_1 = require("../error");
9
9
  const logger_1 = require("../logger");
@@ -56,10 +56,10 @@ function isLocalExtension(extensionName) {
56
56
  exports.isLocalExtension = isLocalExtension;
57
57
  function parseYAML(source) {
58
58
  try {
59
- return yaml.safeLoad(source);
59
+ return yaml.parse(source);
60
60
  }
61
61
  catch (err) {
62
- if (err instanceof yaml.YAMLException) {
62
+ if (err instanceof yaml.YAMLParseError) {
63
63
  throw new error_1.FirebaseError(`YAML Error: ${err.message}`, { original: err });
64
64
  }
65
65
  throw new error_1.FirebaseError(err.message);
@@ -7,6 +7,7 @@ const sort = require("./api-sort");
7
7
  const types = require("./api-types");
8
8
  const logger_1 = require("../logger");
9
9
  const util = require("./util");
10
+ const utils_1 = require("../utils");
10
11
  class PrettyPrint {
11
12
  prettyPrintIndexes(indexes) {
12
13
  if (indexes.length === 0) {
@@ -163,6 +164,10 @@ class PrettyPrint {
163
164
  prettyDatabaseString(database) {
164
165
  return clc.yellow(typeof database === "string" ? database : database.name);
165
166
  }
167
+ firebaseConsoleDatabaseUrl(project, databaseId) {
168
+ const urlFriendlyDatabaseId = databaseId === "(default)" ? "-default-" : databaseId;
169
+ return (0, utils_1.consoleUrl)(project, `/firestore/databases/${urlFriendlyDatabaseId}/data`);
170
+ }
166
171
  prettyFieldString(field) {
167
172
  let result = "";
168
173
  const parsedName = util.parseFieldName(field.name);
@@ -10,7 +10,7 @@ const utils_2 = require("./utils");
10
10
  exports.name = "Astro";
11
11
  exports.support = "experimental";
12
12
  exports.type = 2;
13
- exports.supportedRange = "2 - 3";
13
+ exports.supportedRange = "2 - 4";
14
14
  async function discover(dir) {
15
15
  if (!(0, fs_extra_1.existsSync)((0, path_1.join)(dir, "package.json")))
16
16
  return;
@@ -4,7 +4,7 @@ exports.ɵcodegenPublicDirectory = exports.build = exports.init = exports.discov
4
4
  const cross_spawn_1 = require("cross-spawn");
5
5
  const fs_extra_1 = require("fs-extra");
6
6
  const path_1 = require("path");
7
- const js_yaml_1 = require("js-yaml");
7
+ const yaml = require("yaml");
8
8
  const promises_1 = require("fs/promises");
9
9
  const error_1 = require("../../error");
10
10
  const utils_1 = require("./utils");
@@ -18,7 +18,7 @@ async function discover(dir) {
18
18
  if (!(await (0, fs_extra_1.pathExists)((0, path_1.join)(dir, "web"))))
19
19
  return;
20
20
  const pubSpecBuffer = await (0, promises_1.readFile)((0, path_1.join)(dir, "pubspec.yaml"));
21
- const pubSpec = (0, js_yaml_1.load)(pubSpecBuffer.toString());
21
+ const pubSpec = yaml.parse(pubSpecBuffer.toString());
22
22
  const usingFlutter = pubSpec.dependencies?.flutter;
23
23
  if (!usingFlutter)
24
24
  return;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.WEBPACK_LAYERS = exports.ESBUILD_VERSION = exports.SERVER_REFERENCE_MANIFEST = exports.APP_PATHS_MANIFEST = exports.ROUTES_MANIFEST = exports.PRERENDER_MANIFEST = exports.PAGES_MANIFEST = exports.MIDDLEWARE_MANIFEST = exports.IMAGES_MANIFEST = exports.EXPORT_MARKER = exports.APP_PATH_ROUTES_MANIFEST = void 0;
3
+ exports.WEBPACK_LAYERS = exports.ESBUILD_VERSION = exports.CONFIG_FILES = exports.SERVER_REFERENCE_MANIFEST = exports.APP_PATHS_MANIFEST = exports.ROUTES_MANIFEST = exports.PRERENDER_MANIFEST = exports.PAGES_MANIFEST = exports.MIDDLEWARE_MANIFEST = exports.IMAGES_MANIFEST = exports.EXPORT_MARKER = exports.APP_PATH_ROUTES_MANIFEST = void 0;
4
4
  exports.APP_PATH_ROUTES_MANIFEST = "app-path-routes-manifest.json";
5
5
  exports.EXPORT_MARKER = "export-marker.json";
6
6
  exports.IMAGES_MANIFEST = "images-manifest.json";
@@ -10,6 +10,7 @@ exports.PRERENDER_MANIFEST = "prerender-manifest.json";
10
10
  exports.ROUTES_MANIFEST = "routes-manifest.json";
11
11
  exports.APP_PATHS_MANIFEST = "app-paths-manifest.json";
12
12
  exports.SERVER_REFERENCE_MANIFEST = "server-reference-manifest.json";
13
+ exports.CONFIG_FILES = ["next.config.js", "next.config.mjs"];
13
14
  exports.ESBUILD_VERSION = "0.19.2";
14
15
  const WEBPACK_LAYERS_NAMES = {
15
16
  shared: "shared",
@@ -7,7 +7,6 @@ const promises_1 = require("fs/promises");
7
7
  const path_1 = require("path");
8
8
  const fs_extra_1 = require("fs-extra");
9
9
  const url_1 = require("url");
10
- const fs_1 = require("fs");
11
10
  const semver_1 = require("semver");
12
11
  const clc = require("colorette");
13
12
  const stream_chain_1 = require("stream-chain");
@@ -39,7 +38,7 @@ async function discover(dir) {
39
38
  if (!(await (0, fs_extra_1.pathExists)((0, path_1.join)(dir, "package.json"))))
40
39
  return;
41
40
  const version = (0, utils_2.getNextVersion)(dir);
42
- if (!(await (0, fs_extra_1.pathExists)("next.config.js")) && !version)
41
+ if (!(await (0, utils_2.whichNextConfigFile)(dir)) && !version)
43
42
  return;
44
43
  return { mayWantBackend: true, publicDirectory: (0, path_1.join)(dir, PUBLIC_DIR), version };
45
44
  }
@@ -121,9 +120,9 @@ async function build(dir, target, context) {
121
120
  headers.push(...headersFromMetaFiles);
122
121
  if (appPathsManifest) {
123
122
  const unrenderedServerComponents = (0, utils_2.getNonStaticServerComponents)(appPathsManifest, appPathRoutesManifest, prerenderedRoutes, dynamicRoutes);
124
- if (unrenderedServerComponents.has("/_not-found") &&
125
- (await (0, utils_2.hasStaticAppNotFoundComponent)(dir, distDir))) {
126
- unrenderedServerComponents.delete("/_not-found");
123
+ const notFoundPageKey = ["/_not-found", "/_not-found/page"].find((key) => unrenderedServerComponents.has(key));
124
+ if (notFoundPageKey && (await (0, utils_2.hasStaticAppNotFoundComponent)(dir, distDir))) {
125
+ unrenderedServerComponents.delete(notFoundPageKey);
127
126
  }
128
127
  for (const key of unrenderedServerComponents) {
129
128
  reasonsForBackend.add(`non-static component ${key}`);
@@ -335,7 +334,8 @@ exports.ɵcodegenPublicDirectory = ɵcodegenPublicDirectory;
335
334
  async function ɵcodegenFunctionsDirectory(sourceDir, destDir, target, context) {
336
335
  const { distDir } = await getConfig(sourceDir);
337
336
  const packageJson = await (0, utils_1.readJSON)((0, path_1.join)(sourceDir, "package.json"));
338
- if ((0, fs_1.existsSync)((0, path_1.join)(sourceDir, "next.config.js"))) {
337
+ const configFile = await (0, utils_2.whichNextConfigFile)(sourceDir);
338
+ if (configFile) {
339
339
  try {
340
340
  const productionDeps = await new Promise((resolve) => {
341
341
  const dependencies = [];
@@ -360,8 +360,14 @@ async function ɵcodegenFunctionsDirectory(sourceDir, destDir, target, context)
360
360
  });
361
361
  const esbuildArgs = productionDeps
362
362
  .map((it) => `--external:${it}`)
363
- .concat("--bundle", "--platform=node", `--target=node${constants_1.NODE_VERSION}`, `--outdir=${destDir}`, "--log-level=error");
364
- const bundle = (0, cross_spawn_1.sync)("npx", ["--yes", `esbuild@${constants_2.ESBUILD_VERSION}`, "next.config.js", ...esbuildArgs], {
363
+ .concat("--bundle", "--platform=node", `--target=node${constants_1.NODE_VERSION}`, "--log-level=error");
364
+ if (configFile === "next.config.mjs") {
365
+ esbuildArgs.push(...[`--outfile=${(0, path_1.join)(destDir, configFile)}`, "--format=esm"]);
366
+ }
367
+ else {
368
+ esbuildArgs.push(`--outfile=${(0, path_1.join)(destDir, configFile)}`);
369
+ }
370
+ const bundle = (0, cross_spawn_1.sync)("npx", ["--yes", `esbuild@${constants_2.ESBUILD_VERSION}`, configFile, ...esbuildArgs], {
365
371
  cwd: sourceDir,
366
372
  timeout: BUNDLE_NEXT_CONFIG_TIMEOUT,
367
373
  });
@@ -370,9 +376,9 @@ async function ɵcodegenFunctionsDirectory(sourceDir, destDir, target, context)
370
376
  }
371
377
  }
372
378
  catch (e) {
373
- console.warn("Unable to bundle next.config.js for use in Cloud Functions, proceeding with deploy but problems may be enountered.");
379
+ console.warn(`Unable to bundle ${configFile} for use in Cloud Functions, proceeding with deploy but problems may be encountered.`);
374
380
  console.error(e.message || e);
375
- (0, fs_extra_1.copy)((0, path_1.join)(sourceDir, "next.config.js"), (0, path_1.join)(destDir, "next.config.js"));
381
+ await (0, fs_extra_1.copy)((0, path_1.join)(sourceDir, configFile), (0, path_1.join)(destDir, configFile));
376
382
  }
377
383
  }
378
384
  if (await (0, fs_extra_1.pathExists)((0, path_1.join)(sourceDir, "public"))) {
@@ -389,8 +395,13 @@ async function ɵcodegenFunctionsDirectory(sourceDir, destDir, target, context)
389
395
  dotEnv["VERCEL_URL"] = deploymentDomain;
390
396
  }
391
397
  }
392
- await (0, fs_extra_1.mkdirp)((0, path_1.join)(destDir, distDir));
393
- await (0, fs_extra_1.copy)((0, path_1.join)(sourceDir, distDir), (0, path_1.join)(destDir, distDir));
398
+ const [productionDistDirfiles] = await Promise.all([
399
+ (0, utils_2.getProductionDistDirFiles)(sourceDir, distDir),
400
+ (0, fs_extra_1.mkdirp)((0, path_1.join)(destDir, distDir)),
401
+ ]);
402
+ await Promise.all(productionDistDirfiles.map((file) => (0, fs_extra_1.copy)((0, path_1.join)(sourceDir, distDir, file), (0, path_1.join)(destDir, distDir, file), {
403
+ recursive: true,
404
+ })));
394
405
  return { packageJson, frameworksEntry: "next.js", dotEnv };
395
406
  }
396
407
  exports.ɵcodegenFunctionsDirectory = ɵcodegenFunctionsDirectory;
@@ -420,7 +431,8 @@ exports.getDevModeHandle = getDevModeHandle;
420
431
  async function getConfig(dir) {
421
432
  var _a;
422
433
  let config = {};
423
- if ((0, fs_1.existsSync)((0, path_1.join)(dir, "next.config.js"))) {
434
+ const configFile = await (0, utils_2.whichNextConfigFile)(dir);
435
+ if (configFile) {
424
436
  const version = (0, utils_2.getNextVersion)(dir);
425
437
  if (!version)
426
438
  throw new Error("Unable to find the next dep, try NPM installing?");
@@ -433,10 +445,10 @@ async function getConfig(dir) {
433
445
  }
434
446
  else {
435
447
  try {
436
- config = await (_a = (0, url_1.pathToFileURL)((0, path_1.join)(dir, "next.config.js")).toString(), Promise.resolve().then(() => require(_a)));
448
+ config = await (_a = (0, url_1.pathToFileURL)((0, path_1.join)(dir, configFile)).toString(), Promise.resolve().then(() => require(_a)));
437
449
  }
438
450
  catch (e) {
439
- throw new Error("Unable to load next.config.js.");
451
+ throw new Error(`Unable to load ${configFile}.`);
440
452
  }
441
453
  }
442
454
  }