firebase-tools-with-isolate 12.9.1-9 → 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 +14 -8
  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
@@ -1,120 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createBackend = exports.getOrCreateBackend = exports.doSetup = void 0;
4
- const clc = require("colorette");
5
- const utils = require("../../../utils");
6
- const logger_1 = require("../../../logger");
7
- const prompt_1 = require("../../../prompt");
8
- const constants_1 = require("./constants");
9
- const repo = require("./repo");
10
- const poller = require("../../../operation-poller");
11
- const api_1 = require("../../../api");
12
- const gcp = require("../../../gcp/frameworks");
13
- const frameworks_1 = require("../../../gcp/frameworks");
14
- const error_1 = require("../../../error");
15
- const frameworksPollerOptions = {
16
- apiOrigin: api_1.frameworksOrigin,
17
- apiVersion: frameworks_1.API_VERSION,
18
- masterTimeout: 25 * 60 * 1000,
19
- maxBackoff: 10000,
20
- };
21
- async function doSetup(setup, projectId) {
22
- setup.frameworks = {};
23
- utils.logBullet("First we need a few details to create your backend.");
24
- await (0, prompt_1.promptOnce)({
25
- name: "serviceName",
26
- type: "input",
27
- default: "acme-inc-web",
28
- message: "Create a name for your backend [1-30 characters]",
29
- }, setup.frameworks);
30
- await (0, prompt_1.promptOnce)({
31
- name: "region",
32
- type: "list",
33
- default: constants_1.DEFAULT_REGION,
34
- message: "Please select a region " +
35
- `(${clc.yellow("info")}: Your region determines where your backend is located):\n`,
36
- choices: constants_1.ALLOWED_REGIONS,
37
- }, setup.frameworks);
38
- utils.logSuccess(`Region set to ${setup.frameworks.region}.`);
39
- const backend = await getOrCreateBackend(projectId, setup);
40
- if (backend) {
41
- logger_1.logger.info();
42
- utils.logSuccess(`Successfully created backend:\n ${backend.name}`);
43
- logger_1.logger.info();
44
- utils.logSuccess(`Your site is being deployed at:\n https://${backend.uri}`);
45
- logger_1.logger.info();
46
- utils.logSuccess(`View the rollout status by running:\n firebase backends:get --backend=${backend.name}`);
47
- logger_1.logger.info();
48
- }
49
- }
50
- exports.doSetup = doSetup;
51
- function toBackend(cloudBuildConnRepo) {
52
- return {
53
- codebase: {
54
- repository: `${cloudBuildConnRepo.name}`,
55
- rootDirectory: "/",
56
- },
57
- labels: {},
58
- };
59
- }
60
- async function getOrCreateBackend(projectId, setup) {
61
- const location = setup.frameworks.region;
62
- try {
63
- return await getExistingBackend(projectId, setup, location);
64
- }
65
- catch (err) {
66
- if (err.status === 404) {
67
- const cloudBuildConnRepo = await repo.linkGitHubRepository(projectId, location);
68
- logger_1.logger.info();
69
- await (0, prompt_1.promptOnce)({
70
- name: "branchName",
71
- type: "input",
72
- default: "main",
73
- message: "Which branch do you want to deploy?",
74
- }, setup.frameworks);
75
- const backendDetails = toBackend(cloudBuildConnRepo);
76
- logger_1.logger.info(clc.bold(`\n${clc.white("===")} Creating your backend`));
77
- return await createBackend(projectId, location, backendDetails, setup.frameworks.serviceName);
78
- }
79
- else {
80
- throw new error_1.FirebaseError(`Failed to get or create a backend using the given initialization details: ${err}`);
81
- }
82
- }
83
- return undefined;
84
- }
85
- exports.getOrCreateBackend = getOrCreateBackend;
86
- async function getExistingBackend(projectId, setup, location) {
87
- let backend = await gcp.getBackend(projectId, location, setup.frameworks.serviceName);
88
- while (backend) {
89
- setup.frameworks.serviceName = undefined;
90
- await (0, prompt_1.promptOnce)({
91
- name: "existingBackend",
92
- type: "confirm",
93
- default: true,
94
- message: "A backend already exists for the given serviceName, do you want to use existing backend? (yes/no)",
95
- }, setup.frameworks);
96
- if (setup.frameworks.existingBackend) {
97
- logger_1.logger.info("Using the existing backend.");
98
- return backend;
99
- }
100
- await (0, prompt_1.promptOnce)({
101
- name: "serviceName",
102
- type: "input",
103
- default: "acme-inc-web",
104
- message: "Please enter a new service name [1-30 characters]",
105
- }, setup.frameworks);
106
- backend = await gcp.getBackend(projectId, location, setup.frameworks.serviceName);
107
- setup.frameworks.existingBackend = undefined;
108
- }
109
- return backend;
110
- }
111
- async function createBackend(projectId, location, backendReqBoby, backendId) {
112
- const op = await gcp.createBackend(projectId, location, backendReqBoby, backendId);
113
- const backend = await poller.pollOperation({
114
- ...frameworksPollerOptions,
115
- pollerName: `create-${projectId}-${location}-${backendId}`,
116
- operationResourceName: op.name,
117
- });
118
- return backend;
119
- }
120
- exports.createBackend = createBackend;
@@ -1,132 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getOrCreateRepository = exports.getOrCreateConnection = exports.linkGitHubRepository = void 0;
4
- const api_1 = require("../../../api");
5
- const error_1 = require("../../../error");
6
- const gcb = require("../../../gcp/cloudbuild");
7
- const logger_1 = require("../../../logger");
8
- const poller = require("../../../operation-poller");
9
- const utils = require("../../../utils");
10
- const prompt_1 = require("../../../prompt");
11
- const clc = require("colorette");
12
- const gcbPollerOptions = {
13
- apiOrigin: api_1.cloudbuildOrigin,
14
- apiVersion: "v2",
15
- masterTimeout: 25 * 60 * 1000,
16
- maxBackoff: 10000,
17
- };
18
- function extractRepoSlugFromURI(remoteUri) {
19
- const match = /github.com\/(.+).git/.exec(remoteUri);
20
- if (!match) {
21
- return undefined;
22
- }
23
- return match[1];
24
- }
25
- function generateRepositoryId(remoteUri) {
26
- return extractRepoSlugFromURI(remoteUri)?.replaceAll("/", "-");
27
- }
28
- function generateConnectionId(location) {
29
- return `frameworks-${location}`;
30
- }
31
- async function linkGitHubRepository(projectId, location) {
32
- logger_1.logger.info(clc.bold(`\n${clc.white("===")} Connect a github repository`));
33
- const connectionId = generateConnectionId(location);
34
- await getOrCreateConnection(projectId, location, connectionId);
35
- let remoteUri = await promptRepositoryURI(projectId, location, connectionId);
36
- while (remoteUri === "") {
37
- await utils.openInBrowser("https://github.com/apps/google-cloud-build/installations/new");
38
- await (0, prompt_1.promptOnce)({
39
- type: "input",
40
- message: "Press ENTER once you have finished configuring your installation's access settings.",
41
- });
42
- remoteUri = await promptRepositoryURI(projectId, location, connectionId);
43
- }
44
- const repo = await getOrCreateRepository(projectId, location, connectionId, remoteUri);
45
- logger_1.logger.info();
46
- utils.logSuccess(`Successfully linked GitHub repository at remote URI:\n ${remoteUri}`);
47
- return repo;
48
- }
49
- exports.linkGitHubRepository = linkGitHubRepository;
50
- async function promptRepositoryURI(projectId, location, connectionId) {
51
- const resp = await gcb.fetchLinkableRepositories(projectId, location, connectionId);
52
- if (!resp.repositories || resp.repositories.length === 0) {
53
- throw new error_1.FirebaseError("The GitHub App does not have access to any repositories. Please configure " +
54
- "your app installation permissions at https://github.com/settings/installations.");
55
- }
56
- const choices = resp.repositories.map((repo) => ({
57
- name: extractRepoSlugFromURI(repo.remoteUri) || repo.remoteUri,
58
- value: repo.remoteUri,
59
- }));
60
- choices.push({
61
- name: "Missing a repo? Select this option to configure your installation's access settings",
62
- value: "",
63
- });
64
- return await (0, prompt_1.promptOnce)({
65
- type: "list",
66
- message: "Which of the following repositories would you like to deploy?",
67
- choices,
68
- });
69
- }
70
- async function promptConnectionAuth(conn, projectId, location, connectionId) {
71
- logger_1.logger.info("First, log in to GitHub, install and authorize Cloud Build app:");
72
- logger_1.logger.info(conn.installationState.actionUri);
73
- await utils.openInBrowser(conn.installationState.actionUri);
74
- await (0, prompt_1.promptOnce)({
75
- type: "input",
76
- message: "Press Enter once you have authorized the app (Cloud Build) to access your GitHub repo.",
77
- });
78
- return await gcb.getConnection(projectId, location, connectionId);
79
- }
80
- async function getOrCreateConnection(projectId, location, connectionId) {
81
- let conn;
82
- try {
83
- conn = await gcb.getConnection(projectId, location, connectionId);
84
- }
85
- catch (err) {
86
- if (err.status === 404) {
87
- const op = await gcb.createConnection(projectId, location, connectionId);
88
- conn = await poller.pollOperation({
89
- ...gcbPollerOptions,
90
- pollerName: `create-${location}-${connectionId}`,
91
- operationResourceName: op.name,
92
- });
93
- }
94
- else {
95
- throw err;
96
- }
97
- }
98
- while (conn.installationState.stage !== "COMPLETE") {
99
- conn = await promptConnectionAuth(conn, projectId, location, connectionId);
100
- }
101
- return conn;
102
- }
103
- exports.getOrCreateConnection = getOrCreateConnection;
104
- async function getOrCreateRepository(projectId, location, connectionId, remoteUri) {
105
- const repositoryId = generateRepositoryId(remoteUri);
106
- if (!repositoryId) {
107
- throw new error_1.FirebaseError(`Failed to generate repositoryId for URI "${remoteUri}".`);
108
- }
109
- let repo;
110
- try {
111
- repo = await gcb.getRepository(projectId, location, connectionId, repositoryId);
112
- const repoSlug = extractRepoSlugFromURI(repo.remoteUri);
113
- if (repoSlug) {
114
- throw new error_1.FirebaseError(`${repoSlug} has already been linked.`);
115
- }
116
- }
117
- catch (err) {
118
- if (err.status === 404) {
119
- const op = await gcb.createRepository(projectId, location, connectionId, repositoryId, remoteUri);
120
- repo = await poller.pollOperation({
121
- ...gcbPollerOptions,
122
- pollerName: `create-${location}-${connectionId}-${repositoryId}`,
123
- operationResourceName: op.name,
124
- });
125
- }
126
- else {
127
- throw err;
128
- }
129
- }
130
- return repo;
131
- }
132
- exports.getOrCreateRepository = getOrCreateRepository;