firebase-tools-with-isolate 12.9.1 → 13.0.2-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 (53) hide show
  1. package/README.md +3 -5
  2. package/lib/api.js +2 -2
  3. package/lib/apiv2.js +7 -0
  4. package/lib/auth.js +8 -4
  5. package/lib/commands/{frameworks-backends-create.js → apphosting-backends-create.js} +6 -3
  6. package/lib/commands/{frameworks-backends-delete.js → apphosting-backends-delete.js} +9 -7
  7. package/lib/commands/{frameworks-backends-get.js → apphosting-backends-get.js} +16 -27
  8. package/lib/commands/{frameworks-backends-list.js → apphosting-backends-list.js} +9 -19
  9. package/lib/commands/apphosting-builds-create.js +31 -0
  10. package/lib/commands/apphosting-builds-get.js +18 -0
  11. package/lib/commands/apphosting-rollouts-create.js +26 -0
  12. package/lib/commands/apphosting-rollouts-list.js +18 -0
  13. package/lib/commands/index.js +12 -7
  14. package/lib/commands/login-use.js +25 -6
  15. package/lib/config.js +10 -8
  16. package/lib/deploy/functions/runtimes/node/parseRuntimeAndValidateSDK.js +2 -2
  17. package/lib/deploy/functions/services/firestore.js +11 -1
  18. package/lib/deploy/lifecycleHooks.js +5 -0
  19. package/lib/fetchMOTD.js +1 -1
  20. package/lib/firestore/api.js +6 -6
  21. package/lib/frameworks/angular/index.js +5 -3
  22. package/lib/frameworks/angular/utils.js +33 -4
  23. package/lib/frameworks/astro/index.js +5 -2
  24. package/lib/frameworks/astro/utils.js +3 -2
  25. package/lib/frameworks/constants.js +37 -10
  26. package/lib/frameworks/index.js +12 -7
  27. package/lib/frameworks/next/index.js +28 -8
  28. package/lib/frameworks/next/utils.js +7 -3
  29. package/lib/frameworks/nuxt/index.js +15 -5
  30. package/lib/frameworks/nuxt2/index.js +5 -4
  31. package/lib/frameworks/sveltekit/index.js +2 -1
  32. package/lib/frameworks/utils.js +13 -9
  33. package/lib/frameworks/vite/index.js +18 -5
  34. package/lib/functionsShellCommandAction.js +3 -3
  35. package/lib/gcp/apphosting.js +89 -0
  36. package/lib/gcp/cloudbuild.js +28 -3
  37. package/lib/gcp/storage.js +11 -5
  38. package/lib/hosting/api.js +19 -1
  39. package/lib/hosting/runTags.js +2 -1
  40. package/lib/init/features/{frameworks → apphosting}/constants.js +1 -2
  41. package/lib/init/features/apphosting/index.js +147 -0
  42. package/lib/init/features/apphosting/repo.js +225 -0
  43. package/lib/init/features/hosting/index.js +1 -1
  44. package/lib/init/features/index.js +3 -3
  45. package/lib/init/index.js +0 -4
  46. package/lib/localFunction.js +77 -14
  47. package/lib/utils.js +50 -1
  48. package/package.json +10 -8
  49. package/templates/popup.html +64 -0
  50. package/lib/commands/ext-dev-publish.js +0 -32
  51. package/lib/gcp/frameworks.js +0 -40
  52. package/lib/init/features/frameworks/index.js +0 -120
  53. package/lib/init/features/frameworks/repo.js +0 -132
package/README.md CHANGED
@@ -16,17 +16,15 @@ It is probably best to install this as a local dependency on whatever package yo
16
16
  npm install firebase-tools-with-isolate --save-dev
17
17
  ```
18
18
 
19
- Personally I would advise you to [try PNPM](https://pnpm.io/feature-comparison) for monorepo setups. At the moment, `isolate-package` only supports generating isolated lockfiles for PNPM, but you can always choose to deploy to Firebase without a lockfile, similar to other workarounds people have been using.
19
+ Personally I would advise you to [try PNPM](https://pnpm.io/feature-comparison) for monorepo setups.
20
20
 
21
21
  ```bash
22
22
  pnpm add firebase-tools-with-isolate -D
23
23
  ```
24
24
 
25
- Or, if you want to work with the latest pre-release version
25
+ At the moment, `isolate-package` only supports generating isolated lockfiles for PNPM and NPM, but if you depend on Yarn you can always choose to deploy to Firebase without a lockfile, similar to other workarounds people have been using.
26
26
 
27
- ```bash
28
- pnpm add firebase-tools-with-isolate@next -D
29
- ```
27
+ > !! Do not forget to remove/uninstall the original `firebase-tools` package from your repository if you have it installed as a local dependency on your project, because otherwise that binary might get precedence over the forked one, and `npx firebase deploy` will execute the wrong one.
30
28
 
31
29
  ## Commands
32
30
 
package/lib/api.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.githubApiOrigin = exports.githubOrigin = exports.frameworksOrigin = exports.serviceUsageOrigin = exports.cloudRunApiOrigin = exports.hostingApiOrigin = exports.firebaseStorageOrigin = exports.storageOrigin = exports.runtimeconfigOrigin = exports.rulesOrigin = exports.resourceManagerOrigin = exports.remoteConfigApiOrigin = exports.rtdbMetadataOrigin = exports.rtdbManagementOrigin = exports.realtimeOrigin = exports.extensionsTOSOrigin = exports.extensionsPublisherOrigin = exports.extensionsOrigin = exports.iamOrigin = exports.identityOrigin = exports.hostingOrigin = exports.googleOrigin = exports.pubsubOrigin = exports.cloudTasksOrigin = exports.cloudschedulerOrigin = exports.cloudbuildOrigin = exports.functionsDefaultRegion = exports.runOrigin = exports.functionsV2Origin = exports.functionsOrigin = exports.firestoreOrigin = exports.firestoreOriginOrEmulator = exports.firedataOrigin = exports.firebaseExtensionsRegistryOrigin = exports.firebaseApiOrigin = exports.eventarcOrigin = exports.dynamicLinksKey = exports.dynamicLinksOrigin = exports.deployOrigin = exports.consoleOrigin = exports.authOrigin = exports.appDistributionOrigin = exports.artifactRegistryDomain = exports.containerRegistryDomain = exports.cloudMonitoringOrigin = exports.cloudloggingOrigin = exports.cloudbillingOrigin = exports.clientSecret = exports.clientId = exports.authProxyOrigin = void 0;
3
+ exports.githubApiOrigin = exports.githubOrigin = exports.apphostingOrigin = exports.serviceUsageOrigin = exports.cloudRunApiOrigin = exports.hostingApiOrigin = exports.firebaseStorageOrigin = exports.storageOrigin = exports.runtimeconfigOrigin = exports.rulesOrigin = exports.resourceManagerOrigin = exports.remoteConfigApiOrigin = exports.rtdbMetadataOrigin = exports.rtdbManagementOrigin = exports.realtimeOrigin = exports.extensionsTOSOrigin = exports.extensionsPublisherOrigin = exports.extensionsOrigin = exports.iamOrigin = exports.identityOrigin = exports.hostingOrigin = exports.googleOrigin = exports.pubsubOrigin = exports.cloudTasksOrigin = exports.cloudschedulerOrigin = exports.cloudbuildOrigin = exports.functionsDefaultRegion = exports.runOrigin = exports.functionsV2Origin = exports.functionsOrigin = exports.firestoreOrigin = exports.firestoreOriginOrEmulator = exports.firedataOrigin = exports.firebaseExtensionsRegistryOrigin = exports.firebaseApiOrigin = exports.eventarcOrigin = exports.dynamicLinksKey = exports.dynamicLinksOrigin = exports.deployOrigin = exports.consoleOrigin = exports.authOrigin = exports.appDistributionOrigin = exports.artifactRegistryDomain = exports.containerRegistryDomain = exports.cloudMonitoringOrigin = exports.cloudloggingOrigin = exports.cloudbillingOrigin = exports.clientSecret = exports.clientId = exports.authProxyOrigin = void 0;
4
4
  exports.setScopes = exports.getScopes = exports.githubClientSecret = exports.githubClientId = exports.secretManagerOrigin = void 0;
5
5
  const constants_1 = require("./emulator/constants");
6
6
  const logger_1 = require("./logger");
@@ -59,7 +59,7 @@ exports.firebaseStorageOrigin = utils.envOverride("FIREBASE_FIREBASESTORAGE_URL"
59
59
  exports.hostingApiOrigin = utils.envOverride("FIREBASE_HOSTING_API_URL", "https://firebasehosting.googleapis.com");
60
60
  exports.cloudRunApiOrigin = utils.envOverride("CLOUD_RUN_API_URL", "https://run.googleapis.com");
61
61
  exports.serviceUsageOrigin = utils.envOverride("FIREBASE_SERVICE_USAGE_URL", "https://serviceusage.googleapis.com");
62
- exports.frameworksOrigin = utils.envOverride("FRAMEWORKS_URL", "https://placeholder.googleapis.com");
62
+ exports.apphostingOrigin = utils.envOverride("APPHOSTING_URL", "https://firebaseapphosting.googleapis.com");
63
63
  exports.githubOrigin = utils.envOverride("GITHUB_URL", "https://github.com");
64
64
  exports.githubApiOrigin = utils.envOverride("GITHUB_API_URL", "https://api.github.com");
65
65
  exports.secretManagerOrigin = utils.envOverride("CLOUD_SECRET_MANAGER_URL", "https://secretmanager.googleapis.com");
package/lib/apiv2.js CHANGED
@@ -81,6 +81,13 @@ class Client {
81
81
  });
82
82
  return this.request(reqOptions);
83
83
  }
84
+ options(path, options = {}) {
85
+ const reqOptions = Object.assign(options, {
86
+ method: "OPTIONS",
87
+ path,
88
+ });
89
+ return this.request(reqOptions);
90
+ }
84
91
  async request(reqOptions) {
85
92
  if (!reqOptions.responseType) {
86
93
  reqOptions.responseType = "json";
package/lib/auth.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.logout = exports.getAccessToken = exports.findAccountByEmail = exports.loginGithub = exports.loginGoogle = exports.setGlobalDefaultAccount = exports.setProjectAccount = exports.loginAdditionalAccount = exports.selectAccount = exports.setRefreshToken = exports.setActiveAccount = exports.getAllAccounts = exports.getAdditionalAccounts = exports.getProjectDefaultAccount = exports.getGlobalDefaultAccount = void 0;
3
+ exports.addAdditionalAccount = exports.logout = exports.getAccessToken = exports.findAccountByEmail = exports.loginGithub = exports.loginGoogle = exports.setGlobalDefaultAccount = exports.setProjectAccount = exports.loginAdditionalAccount = exports.selectAccount = exports.setRefreshToken = exports.setActiveAccount = exports.getAllAccounts = exports.getAdditionalAccounts = exports.getProjectDefaultAccount = exports.getGlobalDefaultAccount = void 0;
4
4
  const clc = require("colorette");
5
5
  const FormData = require("form-data");
6
6
  const fs = require("fs");
@@ -110,9 +110,7 @@ async function loginAdditionalAccount(useLocalhost, email) {
110
110
  updateAccount(newAccount);
111
111
  }
112
112
  else {
113
- const additionalAccounts = getAdditionalAccounts();
114
- additionalAccounts.push(newAccount);
115
- configstore_1.configstore.set("additionalAccounts", additionalAccounts);
113
+ addAdditionalAccount(newAccount);
116
114
  }
117
115
  return newAccount;
118
116
  }
@@ -530,3 +528,9 @@ async function logout(refreshToken) {
530
528
  }
531
529
  }
532
530
  exports.logout = logout;
531
+ function addAdditionalAccount(account) {
532
+ const additionalAccounts = getAdditionalAccounts();
533
+ additionalAccounts.push(account);
534
+ configstore_1.configstore.set("additionalAccounts", additionalAccounts);
535
+ }
536
+ exports.addAdditionalAccount = addAdditionalAccount;
@@ -4,11 +4,14 @@ exports.command = void 0;
4
4
  const command_1 = require("../command");
5
5
  const projectUtils_1 = require("../projectUtils");
6
6
  const requireInteractive_1 = require("../requireInteractive");
7
- const frameworks_1 = require("../init/features/frameworks");
8
- exports.command = new command_1.Command("backends:create")
7
+ const apphosting_1 = require("../init/features/apphosting");
8
+ const apphosting_2 = require("../gcp/apphosting");
9
+ exports.command = new command_1.Command("apphosting:backends:create")
9
10
  .description("Create a backend in a Firebase project")
11
+ .option("-l, --location <location>", "Specify the region of the backend", "")
12
+ .before(apphosting_2.ensureApiEnabled)
10
13
  .before(requireInteractive_1.default)
11
14
  .action(async (options) => {
12
15
  const projectId = (0, projectUtils_1.needProjectId)(options);
13
- await (0, frameworks_1.doSetup)(options, projectId);
16
+ await (0, apphosting_1.doSetup)(options, projectId);
14
17
  });
@@ -4,11 +4,11 @@ exports.command = void 0;
4
4
  const command_1 = require("../command");
5
5
  const projectUtils_1 = require("../projectUtils");
6
6
  const error_1 = require("../error");
7
- const gcp = require("../gcp/frameworks");
8
7
  const prompt_1 = require("../prompt");
9
- const utils = require("../utils");
10
8
  const logger_1 = require("../logger");
11
- const constants_1 = require("../init/features/frameworks/constants");
9
+ const constants_1 = require("../init/features/apphosting/constants");
10
+ const utils = require("../utils");
11
+ const apphosting = require("../gcp/apphosting");
12
12
  const Table = require("cli-table");
13
13
  const COLUMN_LENGTH = 20;
14
14
  const TABLE_HEAD = [
@@ -19,11 +19,12 @@ const TABLE_HEAD = [
19
19
  "Created Date",
20
20
  "Updated Date",
21
21
  ];
22
- exports.command = new command_1.Command("backends:delete")
22
+ exports.command = new command_1.Command("apphosting:backends:delete")
23
23
  .description("Delete a backend from a Firebase project")
24
24
  .option("-l, --location <location>", "App Backend location", "")
25
25
  .option("-s, --backend <backend>", "Backend Id", "")
26
26
  .withForce()
27
+ .before(apphosting.ensureApiEnabled)
27
28
  .action(async (options) => {
28
29
  const projectId = (0, projectUtils_1.needProjectId)(options);
29
30
  let location = options.location;
@@ -32,12 +33,13 @@ exports.command = new command_1.Command("backends:delete")
32
33
  throw new error_1.FirebaseError("Backend id can't be empty.");
33
34
  }
34
35
  if (!location) {
36
+ const allowedLocations = (await apphosting.listLocations(projectId)).map((loc) => loc.locationId);
35
37
  location = await (0, prompt_1.promptOnce)({
36
38
  name: "region",
37
39
  type: "list",
38
40
  default: constants_1.DEFAULT_REGION,
39
41
  message: "Please select the region of the backend you'd like to delete:",
40
- choices: constants_1.ALLOWED_REGIONS,
42
+ choices: allowedLocations,
41
43
  });
42
44
  }
43
45
  const table = new Table({
@@ -47,7 +49,7 @@ exports.command = new command_1.Command("backends:delete")
47
49
  table.colWidths = COLUMN_LENGTH;
48
50
  let backend;
49
51
  try {
50
- backend = await gcp.getBackend(projectId, location, backendId);
52
+ backend = await apphosting.getBackend(projectId, location, backendId);
51
53
  populateTable(backend, table);
52
54
  }
53
55
  catch (err) {
@@ -67,7 +69,7 @@ exports.command = new command_1.Command("backends:delete")
67
69
  throw new error_1.FirebaseError("Deletion Aborted");
68
70
  }
69
71
  try {
70
- await gcp.deleteBackend(projectId, location, backendId);
72
+ await apphosting.deleteBackend(projectId, location, backendId);
71
73
  utils.logSuccess(`Successfully deleted the backend: ${backendId}`);
72
74
  }
73
75
  catch (err) {
@@ -3,30 +3,20 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.command = void 0;
4
4
  const command_1 = require("../command");
5
5
  const projectUtils_1 = require("../projectUtils");
6
- const gcp = require("../gcp/frameworks");
7
6
  const error_1 = require("../error");
8
7
  const logger_1 = require("../logger");
8
+ const utils_1 = require("../utils");
9
+ const apphosting = require("../gcp/apphosting");
9
10
  const Table = require("cli-table");
10
11
  const COLUMN_LENGTH = 20;
11
- const TABLE_HEAD = [
12
- "Backend Id",
13
- "Repository Name",
14
- "Location",
15
- "URL",
16
- "Created Date",
17
- "Updated Date",
18
- ];
19
- exports.command = new command_1.Command("backends:get")
12
+ const TABLE_HEAD = ["Backend Id", "Repository", "Location", "URL", "Created Date", "Updated Date"];
13
+ exports.command = new command_1.Command("apphosting:backends:get <backendId>")
20
14
  .description("Get backend details of a Firebase project")
21
15
  .option("-l, --location <location>", "App Backend location", "-")
22
- .option("-b, --backend <backend>", "Backend Id", "")
23
- .action(async (options) => {
16
+ .before(apphosting.ensureApiEnabled)
17
+ .action(async (backendId, options) => {
24
18
  const projectId = (0, projectUtils_1.needProjectId)(options);
25
19
  const location = options.location;
26
- const backendId = options.backend;
27
- if (!backendId) {
28
- throw new error_1.FirebaseError("Backend id can't be empty.");
29
- }
30
20
  let backendsList = [];
31
21
  const table = new Table({
32
22
  head: TABLE_HEAD,
@@ -35,27 +25,26 @@ exports.command = new command_1.Command("backends:get")
35
25
  table.colWidths = COLUMN_LENGTH;
36
26
  try {
37
27
  if (location !== "-") {
38
- const backendInRegion = await gcp.getBackend(projectId, location, backendId);
28
+ const backendInRegion = await apphosting.getBackend(projectId, location, backendId);
39
29
  backendsList.push(backendInRegion);
40
30
  populateTable(backendInRegion, table);
41
31
  }
42
32
  else {
43
- const allBackend = await gcp.listBackends(projectId, location);
44
- backendsList = allBackend.backends.filter((bkd) => bkd.name.split("/").pop() === backendId);
33
+ const resp = await apphosting.listBackends(projectId, "-");
34
+ const allBackends = resp.backends || [];
35
+ backendsList = allBackends.filter((bkd) => bkd.name.split("/").pop() === backendId);
45
36
  backendsList.forEach((bkd) => populateTable(bkd, table));
46
37
  }
47
- if (backendsList.length !== 0) {
48
- logger_1.logger.info(table.toString());
49
- }
50
- else {
51
- logger_1.logger.info();
52
- logger_1.logger.info(`There are no backends with id: ${backendId}`);
53
- }
54
38
  }
55
39
  catch (err) {
56
40
  throw new error_1.FirebaseError(`Failed to get backend: ${backendId}. Please check the parameters you have provided.`, { original: err });
57
41
  }
58
- return backendsList;
42
+ if (backendsList.length === 0) {
43
+ (0, utils_1.logWarning)(`Found no backend with id: ${backendId}`);
44
+ return;
45
+ }
46
+ logger_1.logger.info(table.toString());
47
+ return backendsList[0];
59
48
  });
60
49
  function populateTable(backend, table) {
61
50
  const [location, , backendId] = backend.name.split("/").slice(3, 6);
@@ -3,23 +3,16 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.command = void 0;
4
4
  const command_1 = require("../command");
5
5
  const projectUtils_1 = require("../projectUtils");
6
- const gcp = require("../gcp/frameworks");
7
6
  const error_1 = require("../error");
8
7
  const logger_1 = require("../logger");
9
- const colorette_1 = require("colorette");
8
+ const apphosting = require("../gcp/apphosting");
10
9
  const Table = require("cli-table");
11
10
  const COLUMN_LENGTH = 20;
12
- const TABLE_HEAD = [
13
- "Backend Id",
14
- "Repository Name",
15
- "Location",
16
- "URL",
17
- "Created Date",
18
- "Updated Date",
19
- ];
20
- exports.command = new command_1.Command("backends:list")
11
+ const TABLE_HEAD = ["Backend Id", "Repository", "Location", "URL", "Created Date", "Updated Date"];
12
+ exports.command = new command_1.Command("apphosting:backends:list")
21
13
  .description("List backends of a Firebase project.")
22
14
  .option("-l, --location <location>", "App Backend location", "-")
15
+ .before(apphosting.ensureApiEnabled)
23
16
  .action(async (options) => {
24
17
  const projectId = (0, projectUtils_1.needProjectId)(options);
25
18
  const location = options.location;
@@ -30,12 +23,9 @@ exports.command = new command_1.Command("backends:list")
30
23
  table.colWidths = COLUMN_LENGTH;
31
24
  const backendsList = [];
32
25
  try {
33
- const backendsPerRegion = await gcp.listBackends(projectId, location);
34
- backendsList.push(backendsPerRegion);
35
- populateTable(backendsPerRegion, location, table);
36
- logger_1.logger.info();
37
- logger_1.logger.info(`Backends for project ${(0, colorette_1.bold)(projectId)}`);
38
- logger_1.logger.info();
26
+ const backendsPerRegion = await apphosting.listBackends(projectId, location);
27
+ backendsList.push(...(backendsPerRegion.backends || []));
28
+ populateTable(backendsList, table);
39
29
  logger_1.logger.info(table.toString());
40
30
  }
41
31
  catch (err) {
@@ -43,8 +33,8 @@ exports.command = new command_1.Command("backends:list")
43
33
  }
44
34
  return backendsList;
45
35
  });
46
- function populateTable(backendsLists, location, table) {
47
- for (const backend of backendsLists.backends) {
36
+ function populateTable(backends, table) {
37
+ for (const backend of backends) {
48
38
  const [location, , backendId] = backend.name.split("/").slice(3, 6);
49
39
  const entry = [
50
40
  backendId,
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.command = void 0;
4
+ const apphosting = require("../gcp/apphosting");
5
+ const logger_1 = require("../logger");
6
+ const command_1 = require("../command");
7
+ const utils_1 = require("../utils");
8
+ const projectUtils_1 = require("../projectUtils");
9
+ exports.command = new command_1.Command("apphosting:builds:create <backendId>")
10
+ .description("Create a build for an App Hosting backend")
11
+ .option("-l, --location <location>", "Specify the region of the backend", "us-central1")
12
+ .option("-i, --id <buildId>", "Id of the build. If not present, autogenerate a random id", "")
13
+ .option("-b, --branch <branch>", "Repository branch to deploy. Defaults to 'main'", "main")
14
+ .before(apphosting.ensureApiEnabled)
15
+ .action(async (backendId, options) => {
16
+ const projectId = (0, projectUtils_1.needProjectId)(options);
17
+ const location = options.location;
18
+ const buildId = options.buildId || (0, utils_1.generateId)();
19
+ const branch = options.branch;
20
+ const op = await apphosting.createBuild(projectId, location, backendId, buildId, {
21
+ source: {
22
+ codebase: {
23
+ branch: "main",
24
+ },
25
+ },
26
+ });
27
+ logger_1.logger.info(`Started a build for backend ${backendId} on branch ${branch}.`);
28
+ logger_1.logger.info("Check status by running:");
29
+ logger_1.logger.info(`\tfirebase apphosting:builds:get ${backendId} ${buildId} --location ${location}`);
30
+ return op;
31
+ });
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.command = void 0;
4
+ const apphosting = require("../gcp/apphosting");
5
+ const logger_1 = require("../logger");
6
+ const command_1 = require("../command");
7
+ const projectUtils_1 = require("../projectUtils");
8
+ exports.command = new command_1.Command("apphosting:builds:get <backendId> <buildId>")
9
+ .description("Create a build for an App Hosting backend")
10
+ .option("-l, --location <location>", "Specify the region of the backend", "us-central1")
11
+ .before(apphosting.ensureApiEnabled)
12
+ .action(async (backendId, buildId, options) => {
13
+ const projectId = (0, projectUtils_1.needProjectId)(options);
14
+ const location = options.location;
15
+ const build = await apphosting.getBuild(projectId, location, backendId, buildId);
16
+ logger_1.logger.info(JSON.stringify(build, null, 2));
17
+ return build;
18
+ });
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.command = void 0;
4
+ const apphosting = require("../gcp/apphosting");
5
+ const logger_1 = require("../logger");
6
+ const command_1 = require("../command");
7
+ const projectUtils_1 = require("../projectUtils");
8
+ const utils_1 = require("../utils");
9
+ exports.command = new command_1.Command("apphosting:rollouts:create <backendId> <buildId>")
10
+ .description("Create a build for an App Hosting backend")
11
+ .option("-l, --location <location>", "Specify the region of the backend", "us-central1")
12
+ .option("-i, --id <rolloutId>", "Id of the rollout. If not present, autogenerate a random id", "")
13
+ .before(apphosting.ensureApiEnabled)
14
+ .action(async (backendId, buildId, options) => {
15
+ const projectId = (0, projectUtils_1.needProjectId)(options);
16
+ const location = options.location;
17
+ const rolloutId = options.buildId || (0, utils_1.generateId)();
18
+ const build = `projects/${projectId}/backends/${backendId}/builds/${buildId}`;
19
+ const op = await apphosting.createRollout(projectId, location, backendId, rolloutId, {
20
+ build,
21
+ });
22
+ logger_1.logger.info(`Started a rollout for backend ${backendId} with build ${buildId}.`);
23
+ logger_1.logger.info("Check status by running:");
24
+ logger_1.logger.info(`\tfirebase apphosting:rollouts:list --location ${location}`);
25
+ return op;
26
+ });
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.command = void 0;
4
+ const apphosting = require("../gcp/apphosting");
5
+ const logger_1 = require("../logger");
6
+ const command_1 = require("../command");
7
+ const projectUtils_1 = require("../projectUtils");
8
+ exports.command = new command_1.Command("apphosting:rollouts:list <backendId>")
9
+ .description("List rollouts of an App Hosting backend")
10
+ .option("-l, --location <location>", "Rgion of the rollouts. Defaults to listing rollouts from all regions", "-")
11
+ .before(apphosting.ensureApiEnabled)
12
+ .action(async (backendId, options) => {
13
+ const projectId = (0, projectUtils_1.needProjectId)(options);
14
+ const location = options.location;
15
+ const rollouts = await apphosting.listRollouts(projectId, location, backendId);
16
+ logger_1.logger.info(JSON.stringify(rollouts, null, 2));
17
+ return rollouts;
18
+ });
@@ -90,7 +90,6 @@ function load(client) {
90
90
  client.ext.dev.deprecate = loadCommand("ext-dev-deprecate");
91
91
  client.ext.dev.undeprecate = loadCommand("ext-dev-undeprecate");
92
92
  client.ext.dev.upload = loadCommand("ext-dev-upload");
93
- client.ext.dev.publish = loadCommand("ext-dev-publish");
94
93
  client.ext.dev.usage = loadCommand("ext-dev-usage");
95
94
  client.firestore = {};
96
95
  client.firestore.delete = loadCommand("firestore-delete");
@@ -146,12 +145,18 @@ function load(client) {
146
145
  client.internaltesting.functions.discover = loadCommand("internaltesting-functions-discover");
147
146
  }
148
147
  if (experiments.isEnabled("internalframeworks")) {
149
- client.frameworks = {};
150
- client.frameworks.backends = {};
151
- client.frameworks.backends.list = loadCommand("frameworks-backends-list");
152
- client.frameworks.backends.create = loadCommand("frameworks-backends-create");
153
- client.frameworks.backends.get = loadCommand("frameworks-backends-get");
154
- client.frameworks.backends.delete = loadCommand("frameworks-backends-delete");
148
+ client.apphosting = {};
149
+ client.apphosting.backends = {};
150
+ client.apphosting.backends.list = loadCommand("apphosting-backends-list");
151
+ client.apphosting.backends.create = loadCommand("apphosting-backends-create");
152
+ client.apphosting.backends.get = loadCommand("apphosting-backends-get");
153
+ client.apphosting.backends.delete = loadCommand("apphosting-backends-delete");
154
+ client.apphosting.builds = {};
155
+ client.apphosting.builds.get = loadCommand("apphosting-builds-get");
156
+ client.apphosting.builds.create = loadCommand("apphosting-builds-create");
157
+ client.apphosting.rollouts = {};
158
+ client.apphosting.rollouts.create = loadCommand("apphosting-rollouts-create");
159
+ client.apphosting.rollouts.list = loadCommand("apphosting-rollouts-list");
155
160
  }
156
161
  client.login = loadCommand("login");
157
162
  client.login.add = loadCommand("login-add");
@@ -7,7 +7,7 @@ const utils = require("../utils");
7
7
  const auth = require("../auth");
8
8
  const error_1 = require("../error");
9
9
  exports.command = new command_1.Command("login:use <email>")
10
- .description("set the default account to use for this project directory")
10
+ .description("set the default account to use for this project directory or the global default account if not in a Firebase project directory")
11
11
  .action((email, options) => {
12
12
  const allAccounts = auth.getAllAccounts();
13
13
  const accountExists = allAccounts.some((a) => a.user.email === email);
@@ -15,10 +15,29 @@ exports.command = new command_1.Command("login:use <email>")
15
15
  throw new error_1.FirebaseError(`Account ${email} does not exist, run "${clc.bold("firebase login:list")}" to see valid accounts`);
16
16
  }
17
17
  const projectDir = options.projectRoot;
18
- if (!projectDir) {
19
- throw new error_1.FirebaseError("Could not determine active Firebase project directory");
18
+ if (projectDir) {
19
+ if (options.user.email === email) {
20
+ throw new error_1.FirebaseError(`Already using account ${email} for this project directory.`);
21
+ }
22
+ auth.setProjectAccount(projectDir, email);
23
+ utils.logSuccess(`Set default account ${email} for current project directory.`);
24
+ return email;
25
+ }
26
+ else {
27
+ if (options.user.email === email) {
28
+ throw new error_1.FirebaseError(`Already using account ${email} for the global default account.`);
29
+ }
30
+ const newDefaultAccount = allAccounts.find((a) => a.user.email === email);
31
+ if (!newDefaultAccount) {
32
+ throw new error_1.FirebaseError(`Account ${email} does not exist, run "${clc.bold("firebase login:list")}" to see valid accounts`);
33
+ }
34
+ const oldDefaultAccount = auth.getGlobalDefaultAccount();
35
+ if (!oldDefaultAccount) {
36
+ throw new error_1.FirebaseError("Could not determine global default account");
37
+ }
38
+ auth.setGlobalDefaultAccount(newDefaultAccount);
39
+ auth.addAdditionalAccount(oldDefaultAccount);
40
+ utils.logSuccess(`Set global default account to ${email}.`);
41
+ return email;
20
42
  }
21
- auth.setProjectAccount(projectDir, email);
22
- utils.logSuccess(`Set default account ${email} for current project directory.`);
23
- return email;
24
43
  });
package/lib/config.js CHANGED
@@ -39,15 +39,17 @@ class Config {
39
39
  _.set(this.data, target, this.materialize(target));
40
40
  }
41
41
  });
42
- if (this.projectDir && fsutils.dirExistsSync(this.path(Config.DEFAULT_FUNCTIONS_SOURCE))) {
43
- if (Array.isArray(this.get("functions"))) {
44
- if (!this.get("functions.[0].source")) {
45
- this.set("functions.[0].source", Config.DEFAULT_FUNCTIONS_SOURCE);
42
+ if (this.get("functions")) {
43
+ if (this.projectDir && fsutils.dirExistsSync(this.path(Config.DEFAULT_FUNCTIONS_SOURCE))) {
44
+ if (Array.isArray(this.get("functions"))) {
45
+ if (!this.get("functions.[0].source")) {
46
+ this.set("functions.[0].source", Config.DEFAULT_FUNCTIONS_SOURCE);
47
+ }
46
48
  }
47
- }
48
- else {
49
- if (!this.get("functions.source")) {
50
- this.set("functions.source", Config.DEFAULT_FUNCTIONS_SOURCE);
49
+ else {
50
+ if (!this.get("functions.source")) {
51
+ this.set("functions.source", Config.DEFAULT_FUNCTIONS_SOURCE);
52
+ }
51
53
  }
52
54
  }
53
55
  }
@@ -21,9 +21,9 @@ exports.RUNTIME_NOT_SET = "`runtime` field is required but was not found in fire
21
21
  "To fix this, add the following lines to the `functions` section of your firebase.json:\n" +
22
22
  '"runtime": "nodejs18"\n';
23
23
  exports.UNSUPPORTED_NODE_VERSION_FIREBASE_JSON_MSG = clc.bold(`functions.runtime value is unsupported. ` +
24
- `Valid choices are: ${clc.bold("nodejs{10|12|14|16|18}")}.`);
24
+ `Valid choices are: ${clc.bold("nodejs{10|12|14|16|18|20}")}.`);
25
25
  exports.UNSUPPORTED_NODE_VERSION_PACKAGE_JSON_MSG = clc.bold(`package.json in functions directory has an engines field which is unsupported. ` +
26
- `Valid choices are: ${clc.bold('{"node": 10|12|14|16|18}')}`);
26
+ `Valid choices are: ${clc.bold('{"node": 10|12|14|16|18|20}')}`);
27
27
  exports.DEPRECATED_NODE_VERSION_INFO = `\n\nDeploys to runtimes below Node.js 10 are now disabled in the Firebase CLI. ` +
28
28
  `${clc.bold(`Existing Node.js 8 functions ${clc.underline("will stop executing at a future date")}`)}. Update existing functions to Node.js 10 or greater as soon as possible.`;
29
29
  function getRuntimeChoiceFromPackageJson(sourceDir) {
@@ -3,8 +3,18 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ensureFirestoreTriggerRegion = void 0;
4
4
  const firestore = require("../../../gcp/firestore");
5
5
  const error_1 = require("../../../error");
6
+ const dbCache = new Map();
7
+ async function getDatabase(project, databaseId) {
8
+ const key = `${project}/${databaseId}`;
9
+ if (dbCache.has(key)) {
10
+ return dbCache.get(key);
11
+ }
12
+ const db = await firestore.getDatabase(project, databaseId);
13
+ dbCache.set(key, db);
14
+ return db;
15
+ }
6
16
  async function ensureFirestoreTriggerRegion(endpoint) {
7
- const db = await firestore.getDatabase(endpoint.project, endpoint.eventTrigger.eventFilters?.database || "(default)");
17
+ const db = await getDatabase(endpoint.project, endpoint.eventTrigger.eventFilters?.database || "(default)");
8
18
  const dbRegion = db.locationId;
9
19
  if (!endpoint.eventTrigger.region) {
10
20
  endpoint.eventTrigger.region = dbRegion;
@@ -18,6 +18,11 @@ function runCommand(command, childOptions) {
18
18
  const translatedCommand = '"' + nodeExecutable + '" "' + crossEnvShellPath + '" "' + escapedCommand + '"';
19
19
  return new Promise((resolve, reject) => {
20
20
  logger_1.logger.info("Running command: " + command);
21
+ if (command.includes("=")) {
22
+ utils.logWarning(clc.yellow(clc.bold("Warning: ")) +
23
+ "Your command contains '=', it may result in the command not running." +
24
+ " Please consider removing it.");
25
+ }
21
26
  if (translatedCommand === "") {
22
27
  return resolve();
23
28
  }
package/lib/fetchMOTD.js CHANGED
@@ -38,7 +38,7 @@ function fetchMOTD() {
38
38
  configstore_1.configstore.set("motd.fetched", Date.now());
39
39
  })
40
40
  .catch((err) => {
41
- utils.logWarning("Unable to fetch the CLI MOTD and remote config.");
41
+ utils.logWarning("Unable to fetch the CLI MOTD and remote config. This is not a fatal error, but may indicate an issue with your network connection.");
42
42
  logger_1.logger.debug(`Failed to fetch MOTD ${err}`);
43
43
  });
44
44
  }
@@ -54,9 +54,9 @@ class FirestoreApi {
54
54
  utils.logLabeledBullet("firestore", `The following indexes are defined in your project but are not present in your firestore indexes file:\n\t${indexesString}`);
55
55
  }
56
56
  if (!shouldDeleteIndexes) {
57
- shouldDeleteIndexes = await (0, prompt_1.promptOnce)({
58
- type: "confirm",
59
- name: "confirm",
57
+ shouldDeleteIndexes = await (0, prompt_1.confirm)({
58
+ nonInteractive: options.nonInteractive,
59
+ force: options.force,
60
60
  default: false,
61
61
  message: "Would you like to delete these indexes? Selecting no will continue the rest of the deployment.",
62
62
  });
@@ -91,9 +91,9 @@ class FirestoreApi {
91
91
  utils.logLabeledBullet("firestore", `The following field overrides are defined in your project but are not present in your firestore indexes file:\n\t${indexesString}`);
92
92
  }
93
93
  if (!shouldDeleteFields) {
94
- shouldDeleteFields = await (0, prompt_1.promptOnce)({
95
- type: "confirm",
96
- name: "confirm",
94
+ shouldDeleteFields = await (0, prompt_1.confirm)({
95
+ nonInteractive: options.nonInteractive,
96
+ force: options.force,
97
97
  default: false,
98
98
  message: "Would you like to delete these field overrides? Selecting no will continue the rest of the deployment.",
99
99
  });
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ɵcodegenFunctionsDirectory = exports.shouldUseDevModeHandle = exports.getValidBuildTargets = exports.ɵcodegenPublicDirectory = exports.getDevModeHandle = exports.build = exports.init = exports.discover = exports.docsUrl = exports.type = exports.support = exports.name = void 0;
3
+ exports.ɵcodegenFunctionsDirectory = exports.shouldUseDevModeHandle = exports.getValidBuildTargets = exports.ɵcodegenPublicDirectory = exports.getDevModeHandle = exports.build = exports.init = exports.discover = exports.supportedRange = exports.docsUrl = exports.type = exports.support = exports.name = void 0;
4
4
  const path_1 = require("path");
5
5
  const child_process_1 = require("child_process");
6
6
  const cross_spawn_1 = require("cross-spawn");
@@ -15,16 +15,18 @@ exports.support = "preview";
15
15
  exports.type = 3;
16
16
  exports.docsUrl = "https://firebase.google.com/docs/hosting/frameworks/angular";
17
17
  const DEFAULT_BUILD_SCRIPT = ["ng build"];
18
+ exports.supportedRange = "14 - 17";
18
19
  async function discover(dir) {
19
20
  if (!(await (0, fs_extra_1.pathExists)((0, path_1.join)(dir, "package.json"))))
20
21
  return;
21
22
  if (!(await (0, fs_extra_1.pathExists)((0, path_1.join)(dir, "angular.json"))))
22
23
  return;
23
- return { mayWantBackend: true, publicDirectory: (0, path_1.join)(dir, "src", "assets") };
24
+ const version = (0, utils_2.getAngularVersion)(dir);
25
+ return { mayWantBackend: true, publicDirectory: (0, path_1.join)(dir, "src", "assets"), version };
24
26
  }
25
27
  exports.discover = discover;
26
28
  function init(setup, config) {
27
- (0, child_process_1.execSync)(`npx --yes -p @angular/cli@latest ng new ${setup.projectId} --directory ${setup.hosting.source} --skip-git`, {
29
+ (0, child_process_1.execSync)(`npx --yes -p @angular/cli@"${exports.supportedRange}" ng new ${setup.projectId} --directory ${setup.hosting.source} --skip-git`, {
28
30
  stdio: "inherit",
29
31
  cwd: config.projectDir,
30
32
  });