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.
- package/README.md +14 -8
- package/lib/api.js +2 -2
- package/lib/apiv2.js +7 -0
- package/lib/auth.js +8 -4
- package/lib/commands/{frameworks-backends-create.js → apphosting-backends-create.js} +6 -3
- package/lib/commands/{frameworks-backends-delete.js → apphosting-backends-delete.js} +9 -7
- package/lib/commands/{frameworks-backends-get.js → apphosting-backends-get.js} +16 -27
- package/lib/commands/{frameworks-backends-list.js → apphosting-backends-list.js} +9 -19
- package/lib/commands/apphosting-builds-create.js +31 -0
- package/lib/commands/apphosting-builds-get.js +18 -0
- package/lib/commands/apphosting-rollouts-create.js +26 -0
- package/lib/commands/apphosting-rollouts-list.js +18 -0
- package/lib/commands/index.js +12 -7
- package/lib/commands/login-use.js +25 -6
- package/lib/config.js +10 -8
- package/lib/deploy/functions/runtimes/node/parseRuntimeAndValidateSDK.js +2 -2
- package/lib/deploy/functions/services/firestore.js +11 -1
- package/lib/deploy/lifecycleHooks.js +5 -0
- package/lib/fetchMOTD.js +1 -1
- package/lib/firestore/api.js +6 -6
- package/lib/frameworks/angular/index.js +5 -3
- package/lib/frameworks/angular/utils.js +33 -4
- package/lib/frameworks/astro/index.js +5 -2
- package/lib/frameworks/astro/utils.js +3 -2
- package/lib/frameworks/constants.js +37 -10
- package/lib/frameworks/index.js +12 -7
- package/lib/frameworks/next/index.js +28 -8
- package/lib/frameworks/next/utils.js +7 -3
- package/lib/frameworks/nuxt/index.js +15 -5
- package/lib/frameworks/nuxt2/index.js +5 -4
- package/lib/frameworks/sveltekit/index.js +2 -1
- package/lib/frameworks/utils.js +13 -9
- package/lib/frameworks/vite/index.js +18 -5
- package/lib/functionsShellCommandAction.js +3 -3
- package/lib/gcp/apphosting.js +89 -0
- package/lib/gcp/cloudbuild.js +28 -3
- package/lib/gcp/storage.js +11 -5
- package/lib/hosting/api.js +19 -1
- package/lib/hosting/runTags.js +2 -1
- package/lib/init/features/{frameworks → apphosting}/constants.js +1 -2
- package/lib/init/features/apphosting/index.js +147 -0
- package/lib/init/features/apphosting/repo.js +225 -0
- package/lib/init/features/hosting/index.js +1 -1
- package/lib/init/features/index.js +3 -3
- package/lib/init/index.js +0 -4
- package/lib/localFunction.js +77 -14
- package/lib/utils.js +50 -1
- package/package.json +10 -8
- package/templates/popup.html +64 -0
- package/lib/commands/ext-dev-publish.js +0 -32
- package/lib/gcp/frameworks.js +0 -40
- package/lib/init/features/frameworks/index.js +0 -120
- package/lib/init/features/frameworks/repo.js +0 -132
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getDevModeHandle = exports.ɵcodegenPublicDirectory = exports.build = exports.discover = exports.vitePluginDiscover = exports.viteDiscoverWithNpmDependency = exports.init = exports.initViteTemplate = exports.DEFAULT_BUILD_SCRIPT = exports.type = exports.support = exports.name = void 0;
|
|
3
|
+
exports.getDevModeHandle = exports.ɵcodegenPublicDirectory = exports.build = exports.discover = exports.vitePluginDiscover = exports.viteDiscoverWithNpmDependency = exports.init = exports.initViteTemplate = exports.DEFAULT_BUILD_SCRIPT = exports.supportedRange = exports.type = exports.support = exports.name = void 0;
|
|
4
4
|
const child_process_1 = require("child_process");
|
|
5
5
|
const cross_spawn_1 = require("cross-spawn");
|
|
6
6
|
const fs_1 = require("fs");
|
|
7
7
|
const fs_extra_1 = require("fs-extra");
|
|
8
8
|
const path_1 = require("path");
|
|
9
|
+
const stripAnsi = require("strip-ansi");
|
|
9
10
|
const prompt_1 = require("../../prompt");
|
|
10
11
|
const utils_1 = require("../utils");
|
|
11
12
|
exports.name = "Vite";
|
|
12
13
|
exports.support = "experimental";
|
|
13
14
|
exports.type = 4;
|
|
15
|
+
exports.supportedRange = "3 - 5";
|
|
14
16
|
exports.DEFAULT_BUILD_SCRIPT = ["vite build", "tsc && vite build"];
|
|
15
17
|
const initViteTemplate = (template) => async (setup, config) => await init(setup, config, template);
|
|
16
18
|
exports.initViteTemplate = initViteTemplate;
|
|
@@ -24,7 +26,7 @@ async function init(setup, config, baseTemplate = "vanilla") {
|
|
|
24
26
|
{ name: "TypeScript", value: `${baseTemplate}-ts` },
|
|
25
27
|
],
|
|
26
28
|
});
|
|
27
|
-
(0, child_process_1.execSync)(`npm create vite@
|
|
29
|
+
(0, child_process_1.execSync)(`npm create vite@"${exports.supportedRange}" ${setup.hosting.source} --yes -- --template ${template}`, {
|
|
28
30
|
stdio: "inherit",
|
|
29
31
|
cwd: config.projectDir,
|
|
30
32
|
});
|
|
@@ -45,14 +47,24 @@ async function discover(dir, plugin, npmDependency) {
|
|
|
45
47
|
(0, fs_extra_1.pathExists)((0, path_1.join)(dir, "vite.config.ts")),
|
|
46
48
|
]);
|
|
47
49
|
const anyConfigFileExists = configFilesExist.some((it) => it);
|
|
48
|
-
|
|
50
|
+
const version = (0, utils_1.findDependency)("vite", {
|
|
51
|
+
cwd: dir,
|
|
52
|
+
depth,
|
|
53
|
+
omitDev: false,
|
|
54
|
+
})?.version;
|
|
55
|
+
if (!anyConfigFileExists && !version)
|
|
49
56
|
return;
|
|
50
57
|
if (npmDependency && !additionalDep)
|
|
51
58
|
return;
|
|
52
59
|
const { appType, publicDir: publicDirectory, plugins } = await getConfig(dir);
|
|
53
60
|
if (plugin && !plugins.find(({ name }) => name === plugin))
|
|
54
61
|
return;
|
|
55
|
-
return {
|
|
62
|
+
return {
|
|
63
|
+
mayWantBackend: appType !== "spa",
|
|
64
|
+
publicDirectory,
|
|
65
|
+
version,
|
|
66
|
+
vite: true,
|
|
67
|
+
};
|
|
56
68
|
}
|
|
57
69
|
exports.discover = discover;
|
|
58
70
|
async function build(root) {
|
|
@@ -77,7 +89,8 @@ async function getDevModeHandle(dir) {
|
|
|
77
89
|
const serve = (0, cross_spawn_1.spawn)(cli, [], { cwd: dir });
|
|
78
90
|
serve.stdout.on("data", (data) => {
|
|
79
91
|
process.stdout.write(data);
|
|
80
|
-
const
|
|
92
|
+
const dataWithoutAnsiCodes = stripAnsi(data.toString());
|
|
93
|
+
const match = dataWithoutAnsiCodes.match(/(http:\/\/.+:\d+)/);
|
|
81
94
|
if (match)
|
|
82
95
|
resolve(match[1]);
|
|
83
96
|
});
|
|
@@ -4,7 +4,6 @@ exports.actionFunction = void 0;
|
|
|
4
4
|
const clc = require("colorette");
|
|
5
5
|
const repl = require("repl");
|
|
6
6
|
const _ = require("lodash");
|
|
7
|
-
const request = require("request");
|
|
8
7
|
const util = require("util");
|
|
9
8
|
const shell = require("./emulator/functionsEmulatorShell");
|
|
10
9
|
const commandUtils = require("./emulator/commandUtils");
|
|
@@ -16,6 +15,7 @@ const types_1 = require("./emulator/types");
|
|
|
16
15
|
const hubClient_1 = require("./emulator/hubClient");
|
|
17
16
|
const portUtils_1 = require("./emulator/portUtils");
|
|
18
17
|
const constants_1 = require("./emulator/constants");
|
|
18
|
+
const localFunction_2 = require("./localFunction");
|
|
19
19
|
const projectUtils_1 = require("./projectUtils");
|
|
20
20
|
const serveFunctions = new functions_1.FunctionsServer();
|
|
21
21
|
const actionFunction = async (options) => {
|
|
@@ -88,8 +88,8 @@ const actionFunction = async (options) => {
|
|
|
88
88
|
}
|
|
89
89
|
utils.logLabeledWarning("functions", `The following emulators are not running, calls to these services will affect production: ${clc.bold(otherEmulators.join(", "))}`);
|
|
90
90
|
const writer = (output) => {
|
|
91
|
-
if (output
|
|
92
|
-
return
|
|
91
|
+
if (output === localFunction_2.HTTPS_SENTINEL) {
|
|
92
|
+
return localFunction_2.HTTPS_SENTINEL;
|
|
93
93
|
}
|
|
94
94
|
return util.inspect(output);
|
|
95
95
|
};
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ensureApiEnabled = exports.listLocations = exports.updateTraffic = exports.listRollouts = exports.createRollout = exports.createBuild = exports.getBuild = exports.deleteBackend = exports.listBackends = exports.getBackend = exports.createBackend = exports.API_VERSION = exports.API_HOST = void 0;
|
|
4
|
+
const proto = require("../gcp/proto");
|
|
5
|
+
const apiv2_1 = require("../apiv2");
|
|
6
|
+
const projectUtils_1 = require("../projectUtils");
|
|
7
|
+
const api_1 = require("../api");
|
|
8
|
+
const ensureApiEnabled_1 = require("../ensureApiEnabled");
|
|
9
|
+
exports.API_HOST = new URL(api_1.apphostingOrigin).host;
|
|
10
|
+
exports.API_VERSION = "v1alpha";
|
|
11
|
+
const client = new apiv2_1.Client({
|
|
12
|
+
urlPrefix: api_1.apphostingOrigin,
|
|
13
|
+
auth: true,
|
|
14
|
+
apiVersion: exports.API_VERSION,
|
|
15
|
+
});
|
|
16
|
+
async function createBackend(projectId, location, backendReqBoby, backendId) {
|
|
17
|
+
const res = await client.post(`projects/${projectId}/locations/${location}/backends`, backendReqBoby, { queryParams: { backendId } });
|
|
18
|
+
return res.body;
|
|
19
|
+
}
|
|
20
|
+
exports.createBackend = createBackend;
|
|
21
|
+
async function getBackend(projectId, location, backendId) {
|
|
22
|
+
const name = `projects/${projectId}/locations/${location}/backends/${backendId}`;
|
|
23
|
+
const res = await client.get(name);
|
|
24
|
+
return res.body;
|
|
25
|
+
}
|
|
26
|
+
exports.getBackend = getBackend;
|
|
27
|
+
async function listBackends(projectId, location) {
|
|
28
|
+
const name = `projects/${projectId}/locations/${location}/backends`;
|
|
29
|
+
const res = await client.get(name);
|
|
30
|
+
return res.body;
|
|
31
|
+
}
|
|
32
|
+
exports.listBackends = listBackends;
|
|
33
|
+
async function deleteBackend(projectId, location, backendId) {
|
|
34
|
+
const name = `projects/${projectId}/locations/${location}/backends/${backendId}`;
|
|
35
|
+
const res = await client.delete(name);
|
|
36
|
+
return res.body;
|
|
37
|
+
}
|
|
38
|
+
exports.deleteBackend = deleteBackend;
|
|
39
|
+
async function getBuild(projectId, location, backendId, buildId) {
|
|
40
|
+
const name = `projects/${projectId}/locations/${location}/backends/${backendId}/builds/${buildId}`;
|
|
41
|
+
const res = await client.get(name);
|
|
42
|
+
return res.body;
|
|
43
|
+
}
|
|
44
|
+
exports.getBuild = getBuild;
|
|
45
|
+
async function createBuild(projectId, location, backendId, buildId, buildInput) {
|
|
46
|
+
const res = await client.post(`projects/${projectId}/locations/${location}/backends/${backendId}/builds`, buildInput, { queryParams: { buildId } });
|
|
47
|
+
return res.body;
|
|
48
|
+
}
|
|
49
|
+
exports.createBuild = createBuild;
|
|
50
|
+
async function createRollout(projectId, location, backendId, rolloutId, rollout) {
|
|
51
|
+
const res = await client.post(`projects/${projectId}/locations/${location}/backends/${backendId}/rollouts`, rollout, { queryParams: { rolloutId } });
|
|
52
|
+
return res.body;
|
|
53
|
+
}
|
|
54
|
+
exports.createRollout = createRollout;
|
|
55
|
+
async function listRollouts(projectId, location, backendId) {
|
|
56
|
+
const res = await client.get(`projects/${projectId}/locations/${location}/backends/${backendId}/rollouts`);
|
|
57
|
+
return res.body.rollouts;
|
|
58
|
+
}
|
|
59
|
+
exports.listRollouts = listRollouts;
|
|
60
|
+
async function updateTraffic(projectId, location, backendId, traffic) {
|
|
61
|
+
const fieldMasks = proto.fieldMasks(traffic);
|
|
62
|
+
const queryParams = {
|
|
63
|
+
updateMask: fieldMasks.join(","),
|
|
64
|
+
};
|
|
65
|
+
const name = `projects/${projectId}/locations/${location}/backends/${backendId}/traffic`;
|
|
66
|
+
const res = await client.patch(name, { ...traffic, name }, {
|
|
67
|
+
queryParams,
|
|
68
|
+
});
|
|
69
|
+
return res.body;
|
|
70
|
+
}
|
|
71
|
+
exports.updateTraffic = updateTraffic;
|
|
72
|
+
async function listLocations(projectId) {
|
|
73
|
+
let pageToken;
|
|
74
|
+
let locations = [];
|
|
75
|
+
do {
|
|
76
|
+
const response = await client.get(`projects/${projectId}/locations`);
|
|
77
|
+
if (response.body.locations && response.body.locations.length > 0) {
|
|
78
|
+
locations = locations.concat(response.body.locations);
|
|
79
|
+
}
|
|
80
|
+
pageToken = response.body.nextPageToken;
|
|
81
|
+
} while (pageToken);
|
|
82
|
+
return locations;
|
|
83
|
+
}
|
|
84
|
+
exports.listLocations = listLocations;
|
|
85
|
+
async function ensureApiEnabled(options) {
|
|
86
|
+
const projectId = (0, projectUtils_1.needProjectId)(options);
|
|
87
|
+
return await (0, ensureApiEnabled_1.ensure)(projectId, exports.API_HOST, "frameworks", true);
|
|
88
|
+
}
|
|
89
|
+
exports.ensureApiEnabled = ensureApiEnabled;
|
package/lib/gcp/cloudbuild.js
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.deleteRepository = exports.getRepository = exports.createRepository = exports.fetchLinkableRepositories = exports.deleteConnection = exports.getConnection = exports.createConnection = void 0;
|
|
3
|
+
exports.serviceAgentEmail = exports.deleteRepository = exports.getRepository = exports.createRepository = exports.fetchLinkableRepositories = exports.deleteConnection = exports.listConnections = exports.getConnection = exports.createConnection = void 0;
|
|
4
4
|
const apiv2_1 = require("../apiv2");
|
|
5
5
|
const api_1 = require("../api");
|
|
6
|
+
const PAGE_SIZE_MAX = 100;
|
|
6
7
|
const client = new apiv2_1.Client({
|
|
7
8
|
urlPrefix: api_1.cloudbuildOrigin,
|
|
8
9
|
auth: true,
|
|
9
10
|
apiVersion: "v2",
|
|
10
11
|
});
|
|
11
|
-
async function createConnection(projectId, location, connectionId) {
|
|
12
|
-
const res = await client.post(`projects/${projectId}/locations/${location}/connections`, { githubConfig
|
|
12
|
+
async function createConnection(projectId, location, connectionId, githubConfig = {}) {
|
|
13
|
+
const res = await client.post(`projects/${projectId}/locations/${location}/connections`, { githubConfig }, { queryParams: { connectionId } });
|
|
13
14
|
return res.body;
|
|
14
15
|
}
|
|
15
16
|
exports.createConnection = createConnection;
|
|
@@ -19,6 +20,26 @@ async function getConnection(projectId, location, connectionId) {
|
|
|
19
20
|
return res.body;
|
|
20
21
|
}
|
|
21
22
|
exports.getConnection = getConnection;
|
|
23
|
+
async function listConnections(projectId, location) {
|
|
24
|
+
const conns = [];
|
|
25
|
+
const getNextPage = async (pageToken = "") => {
|
|
26
|
+
const res = await client.get(`/projects/${projectId}/locations/${location}/connections`, {
|
|
27
|
+
queryParams: {
|
|
28
|
+
pageSize: PAGE_SIZE_MAX,
|
|
29
|
+
pageToken,
|
|
30
|
+
},
|
|
31
|
+
});
|
|
32
|
+
if (Array.isArray(res.body.connections)) {
|
|
33
|
+
conns.push(...res.body.connections);
|
|
34
|
+
}
|
|
35
|
+
if (res.body.nextPageToken) {
|
|
36
|
+
await getNextPage(res.body.nextPageToken);
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
await getNextPage();
|
|
40
|
+
return conns;
|
|
41
|
+
}
|
|
42
|
+
exports.listConnections = listConnections;
|
|
22
43
|
async function deleteConnection(projectId, location, connectionId) {
|
|
23
44
|
const name = `projects/${projectId}/locations/${location}/connections/${connectionId}`;
|
|
24
45
|
const res = await client.delete(name);
|
|
@@ -48,3 +69,7 @@ async function deleteRepository(projectId, location, connectionId, repositoryId)
|
|
|
48
69
|
return res.body;
|
|
49
70
|
}
|
|
50
71
|
exports.deleteRepository = deleteRepository;
|
|
72
|
+
function serviceAgentEmail(projectNumber) {
|
|
73
|
+
return `service-${projectNumber}@gcp-sa-cloudbuild.iam.gserviceaccount.com`;
|
|
74
|
+
}
|
|
75
|
+
exports.serviceAgentEmail = serviceAgentEmail;
|
package/lib/gcp/storage.js
CHANGED
|
@@ -2,22 +2,28 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getServiceAccount = exports.listBuckets = exports.getBucket = exports.deleteObject = exports.uploadObject = exports.upload = exports.getDefaultBucket = void 0;
|
|
4
4
|
const path = require("path");
|
|
5
|
+
const clc = require("colorette");
|
|
5
6
|
const api_1 = require("../api");
|
|
6
7
|
const apiv2_1 = require("../apiv2");
|
|
7
8
|
const error_1 = require("../error");
|
|
8
9
|
const logger_1 = require("../logger");
|
|
9
|
-
const
|
|
10
|
+
const ensureApiEnabled_1 = require("../ensureApiEnabled");
|
|
10
11
|
async function getDefaultBucket(projectId) {
|
|
12
|
+
await (0, ensureApiEnabled_1.ensure)(projectId, "firebasestorage.googleapis.com", "storage", false);
|
|
11
13
|
try {
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
+
const localAPIClient = new apiv2_1.Client({ urlPrefix: api_1.firebaseStorageOrigin, apiVersion: "v1alpha" });
|
|
15
|
+
const response = await localAPIClient.get(`/projects/${projectId}/defaultBucket`);
|
|
16
|
+
if (!response.body?.bucket.name) {
|
|
14
17
|
logger_1.logger.debug("Default storage bucket is undefined.");
|
|
15
18
|
throw new error_1.FirebaseError("Your project is being set up. Please wait a minute before deploying again.");
|
|
16
19
|
}
|
|
17
|
-
return
|
|
20
|
+
return response.body.bucket.name.split("/").pop();
|
|
18
21
|
}
|
|
19
22
|
catch (err) {
|
|
20
|
-
|
|
23
|
+
if (err?.status === 404) {
|
|
24
|
+
throw new error_1.FirebaseError(`Firebase Storage has not been set up on project '${clc.bold(projectId)}'. Go to https://console.firebase.google.com/project/${projectId}/storage and click 'Get Started' to set up Firebase Storage.`);
|
|
25
|
+
}
|
|
26
|
+
logger_1.logger.info("\n\nUnexpected error when fetching default storage bucket.");
|
|
21
27
|
throw err;
|
|
22
28
|
}
|
|
23
29
|
}
|
package/lib/hosting/api.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getAllSiteDomains = exports.getSiteDomains = exports.cleanAuthState = exports.getCleanDomains = exports.removeAuthDomain = exports.addAuthDomains = exports.deleteSite = exports.updateSite = exports.createSite = exports.getSite = exports.listSites = exports.createRelease = exports.cloneVersion = exports.listVersions = exports.updateVersion = exports.createVersion = exports.deleteChannel = exports.updateChannelTtl = exports.createChannel = exports.listChannels = exports.getChannel = exports.normalizeName = exports.SiteType = void 0;
|
|
3
|
+
exports.getDeploymentDomain = exports.getAllSiteDomains = exports.getSiteDomains = exports.cleanAuthState = exports.getCleanDomains = exports.removeAuthDomain = exports.addAuthDomains = exports.deleteSite = exports.updateSite = exports.createSite = exports.getSite = exports.listSites = exports.createRelease = exports.cloneVersion = exports.listVersions = exports.updateVersion = exports.createVersion = exports.deleteChannel = exports.updateChannelTtl = exports.createChannel = exports.listChannels = exports.getChannel = exports.normalizeName = exports.SiteType = void 0;
|
|
4
4
|
const error_1 = require("../error");
|
|
5
5
|
const api_1 = require("../api");
|
|
6
6
|
const apiv2_1 = require("../apiv2");
|
|
@@ -8,6 +8,7 @@ const operationPoller = require("../operation-poller");
|
|
|
8
8
|
const expireUtils_1 = require("../hosting/expireUtils");
|
|
9
9
|
const auth_1 = require("../gcp/auth");
|
|
10
10
|
const proto = require("../gcp/proto");
|
|
11
|
+
const utils_1 = require("../utils");
|
|
11
12
|
const ONE_WEEK_MS = 604800000;
|
|
12
13
|
var ReleaseType;
|
|
13
14
|
(function (ReleaseType) {
|
|
@@ -170,6 +171,7 @@ async function getSite(project, site) {
|
|
|
170
171
|
if (e instanceof error_1.FirebaseError && e.status === 404) {
|
|
171
172
|
throw new error_1.FirebaseError(`could not find site "${site}" for project "${project}"`, {
|
|
172
173
|
original: e,
|
|
174
|
+
status: e.status,
|
|
173
175
|
});
|
|
174
176
|
}
|
|
175
177
|
throw e;
|
|
@@ -286,3 +288,19 @@ async function getAllSiteDomains(projectId, siteId) {
|
|
|
286
288
|
return Array.from(allSiteDomains);
|
|
287
289
|
}
|
|
288
290
|
exports.getAllSiteDomains = getAllSiteDomains;
|
|
291
|
+
async function getDeploymentDomain(projectId, siteId, hostingChannel) {
|
|
292
|
+
if (hostingChannel) {
|
|
293
|
+
const channel = await getChannel(projectId, siteId, hostingChannel);
|
|
294
|
+
return channel && (0, utils_1.getHostnameFromUrl)(channel?.url);
|
|
295
|
+
}
|
|
296
|
+
const site = await getSite(projectId, siteId).catch((e) => {
|
|
297
|
+
if (e instanceof error_1.FirebaseError &&
|
|
298
|
+
e.original instanceof error_1.FirebaseError &&
|
|
299
|
+
e.original.status === 404) {
|
|
300
|
+
return null;
|
|
301
|
+
}
|
|
302
|
+
throw e;
|
|
303
|
+
});
|
|
304
|
+
return site && (0, utils_1.getHostnameFromUrl)(site?.defaultUrl);
|
|
305
|
+
}
|
|
306
|
+
exports.getDeploymentDomain = getDeploymentDomain;
|
package/lib/hosting/runTags.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ensureLatestRevisionTagged = exports.setRewriteTags = exports.setGarbageCollectionThreshold = exports.gcTagsForServices = exports.TODO_TAG_NAME = void 0;
|
|
4
|
+
const node_path_1 = require("node:path");
|
|
4
5
|
const run = require("../gcp/run");
|
|
5
6
|
const api = require("./api");
|
|
6
7
|
const error_1 = require("../error");
|
|
@@ -9,7 +10,7 @@ exports.TODO_TAG_NAME = "this is an invalid tag name so it cannot be real";
|
|
|
9
10
|
async function gcTagsForServices(project, services) {
|
|
10
11
|
const validTagsByServiceByRegion = {};
|
|
11
12
|
const sites = await api.listSites(project);
|
|
12
|
-
const allVersionsNested = await Promise.all(sites.map((site) => api.listVersions(site.name)));
|
|
13
|
+
const allVersionsNested = await Promise.all(sites.map((site) => api.listVersions(node_path_1.posix.basename(site.name))));
|
|
13
14
|
const activeVersions = [...(0, functional_1.flattenArray)(allVersionsNested)].filter((version) => {
|
|
14
15
|
return version.status === "CREATED" || version.status === "FINALIZED";
|
|
15
16
|
});
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ALLOWED_DEPLOY_METHODS = exports.DEFAULT_DEPLOY_METHOD = exports.
|
|
3
|
+
exports.ALLOWED_DEPLOY_METHODS = exports.DEFAULT_DEPLOY_METHOD = exports.DEFAULT_REGION = void 0;
|
|
4
4
|
exports.DEFAULT_REGION = "us-central1";
|
|
5
|
-
exports.ALLOWED_REGIONS = [{ name: "us-central1 (Iowa)", value: "us-central1" }];
|
|
6
5
|
exports.DEFAULT_DEPLOY_METHOD = "github";
|
|
7
6
|
exports.ALLOWED_DEPLOY_METHODS = [{ name: "Deploy using github", value: "github" }];
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.onboardRollout = exports.createBackend = exports.onboardBackend = exports.doSetup = void 0;
|
|
4
|
+
const clc = require("colorette");
|
|
5
|
+
const repo = require("./repo");
|
|
6
|
+
const poller = require("../../../operation-poller");
|
|
7
|
+
const apphosting = require("../../../gcp/apphosting");
|
|
8
|
+
const utils_1 = require("../../../utils");
|
|
9
|
+
const api_1 = require("../../../api");
|
|
10
|
+
const apphosting_1 = require("../../../gcp/apphosting");
|
|
11
|
+
const error_1 = require("../../../error");
|
|
12
|
+
const prompt_1 = require("../../../prompt");
|
|
13
|
+
const constants_1 = require("./constants");
|
|
14
|
+
const ensureApiEnabled_1 = require("../../../ensureApiEnabled");
|
|
15
|
+
const apphostingPollerOptions = {
|
|
16
|
+
apiOrigin: api_1.apphostingOrigin,
|
|
17
|
+
apiVersion: apphosting_1.API_VERSION,
|
|
18
|
+
masterTimeout: 25 * 60 * 1000,
|
|
19
|
+
maxBackoff: 10000,
|
|
20
|
+
};
|
|
21
|
+
async function doSetup(setup, projectId) {
|
|
22
|
+
await Promise.all([
|
|
23
|
+
(0, ensureApiEnabled_1.ensure)(projectId, "cloudbuild.googleapis.com", "apphosting", true),
|
|
24
|
+
(0, ensureApiEnabled_1.ensure)(projectId, "secretmanager.googleapis.com", "apphosting", true),
|
|
25
|
+
(0, ensureApiEnabled_1.ensure)(projectId, "run.googleapis.com", "apphosting", true),
|
|
26
|
+
(0, ensureApiEnabled_1.ensure)(projectId, "artifactregistry.googleapis.com", "apphosting", true),
|
|
27
|
+
]);
|
|
28
|
+
const allowedLocations = (await apphosting.listLocations(projectId)).map((loc) => loc.locationId);
|
|
29
|
+
if (setup.location) {
|
|
30
|
+
if (!allowedLocations.includes(setup.location)) {
|
|
31
|
+
throw new error_1.FirebaseError(`Invalid location ${setup.location}. Valid choices are ${allowedLocations.join(", ")}`);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
(0, utils_1.logBullet)("First we need a few details to create your backend.");
|
|
35
|
+
const location = setup.location || (await promptLocation(projectId, allowedLocations));
|
|
36
|
+
(0, utils_1.logSuccess)(`Region set to ${location}.\n`);
|
|
37
|
+
let backendId;
|
|
38
|
+
while (true) {
|
|
39
|
+
backendId = await (0, prompt_1.promptOnce)({
|
|
40
|
+
name: "backendId",
|
|
41
|
+
type: "input",
|
|
42
|
+
default: "my-web-app",
|
|
43
|
+
message: "Create a name for your backend [1-30 characters]",
|
|
44
|
+
});
|
|
45
|
+
try {
|
|
46
|
+
await apphosting.getBackend(projectId, location, backendId);
|
|
47
|
+
}
|
|
48
|
+
catch (err) {
|
|
49
|
+
if (err.status === 404) {
|
|
50
|
+
break;
|
|
51
|
+
}
|
|
52
|
+
throw new error_1.FirebaseError(`Failed to check if backend with id ${backendId} already exists in ${location}`, { original: err });
|
|
53
|
+
}
|
|
54
|
+
(0, utils_1.logWarning)(`Backend with id ${backendId} already exists in ${location}`);
|
|
55
|
+
}
|
|
56
|
+
const backend = await onboardBackend(projectId, location, backendId);
|
|
57
|
+
const confirmRollout = await (0, prompt_1.promptOnce)({
|
|
58
|
+
type: "confirm",
|
|
59
|
+
name: "rollout",
|
|
60
|
+
default: true,
|
|
61
|
+
message: "Do you want to deploy now?",
|
|
62
|
+
});
|
|
63
|
+
if (!confirmRollout) {
|
|
64
|
+
(0, utils_1.logSuccess)(`Successfully created backend:\n\t${backend.name}`);
|
|
65
|
+
(0, utils_1.logSuccess)(`Your site will be deployed at:\n\thttps://${backend.uri}`);
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
const branch = await (0, prompt_1.promptOnce)({
|
|
69
|
+
name: "branch",
|
|
70
|
+
type: "input",
|
|
71
|
+
default: "main",
|
|
72
|
+
message: "Which branch do you want to deploy?",
|
|
73
|
+
});
|
|
74
|
+
const { build } = await onboardRollout(projectId, location, backendId, {
|
|
75
|
+
source: {
|
|
76
|
+
codebase: {
|
|
77
|
+
branch,
|
|
78
|
+
},
|
|
79
|
+
},
|
|
80
|
+
});
|
|
81
|
+
if (build.state !== "READY") {
|
|
82
|
+
throw new error_1.FirebaseError(`Failed to build your app. Please inspect the build logs at ${build.buildLogsUri}.`, { children: [build.error] });
|
|
83
|
+
}
|
|
84
|
+
(0, utils_1.logSuccess)(`Successfully created backend:\n\t${backend.name}`);
|
|
85
|
+
(0, utils_1.logSuccess)(`Your site is now deployed at:\n\thttps://${backend.uri}`);
|
|
86
|
+
(0, utils_1.logSuccess)(`View the rollout status by running:\n\tfirebase apphosting:backends:get ${backendId} --project ${projectId}`);
|
|
87
|
+
}
|
|
88
|
+
exports.doSetup = doSetup;
|
|
89
|
+
async function promptLocation(projectId, locations) {
|
|
90
|
+
return (await (0, prompt_1.promptOnce)({
|
|
91
|
+
name: "region",
|
|
92
|
+
type: "list",
|
|
93
|
+
default: constants_1.DEFAULT_REGION,
|
|
94
|
+
message: "Please select a region " +
|
|
95
|
+
`(${clc.yellow("info")}: Your region determines where your backend is located):\n`,
|
|
96
|
+
choices: locations.map((loc) => ({ value: loc })),
|
|
97
|
+
}));
|
|
98
|
+
}
|
|
99
|
+
function toBackend(cloudBuildConnRepo) {
|
|
100
|
+
return {
|
|
101
|
+
servingLocality: "GLOBAL_ACCESS",
|
|
102
|
+
codebase: {
|
|
103
|
+
repository: `${cloudBuildConnRepo.name}`,
|
|
104
|
+
rootDirectory: "/",
|
|
105
|
+
},
|
|
106
|
+
labels: {},
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
async function onboardBackend(projectId, location, backendId) {
|
|
110
|
+
const cloudBuildConnRepo = await repo.linkGitHubRepository(projectId, location);
|
|
111
|
+
const backendDetails = toBackend(cloudBuildConnRepo);
|
|
112
|
+
return await createBackend(projectId, location, backendDetails, backendId);
|
|
113
|
+
}
|
|
114
|
+
exports.onboardBackend = onboardBackend;
|
|
115
|
+
async function createBackend(projectId, location, backendReqBoby, backendId) {
|
|
116
|
+
const op = await apphosting.createBackend(projectId, location, backendReqBoby, backendId);
|
|
117
|
+
const backend = await poller.pollOperation({
|
|
118
|
+
...apphostingPollerOptions,
|
|
119
|
+
pollerName: `create-${projectId}-${location}-${backendId}`,
|
|
120
|
+
operationResourceName: op.name,
|
|
121
|
+
});
|
|
122
|
+
return backend;
|
|
123
|
+
}
|
|
124
|
+
exports.createBackend = createBackend;
|
|
125
|
+
async function onboardRollout(projectId, location, backendId, buildInput) {
|
|
126
|
+
(0, utils_1.logBullet)("Starting a new rollout... this may take a few minutes.");
|
|
127
|
+
const buildId = (0, utils_1.generateId)();
|
|
128
|
+
const buildOp = await apphosting.createBuild(projectId, location, backendId, buildId, buildInput);
|
|
129
|
+
const rolloutId = (0, utils_1.generateId)();
|
|
130
|
+
const rolloutOp = await apphosting.createRollout(projectId, location, backendId, rolloutId, {
|
|
131
|
+
build: `projects/${projectId}/locations/${location}/backends/${backendId}/builds/${buildId}`,
|
|
132
|
+
});
|
|
133
|
+
const rolloutPoll = poller.pollOperation({
|
|
134
|
+
...apphostingPollerOptions,
|
|
135
|
+
pollerName: `create-${projectId}-${location}-backend-${backendId}-rollout-${rolloutId}`,
|
|
136
|
+
operationResourceName: rolloutOp.name,
|
|
137
|
+
});
|
|
138
|
+
const buildPoll = poller.pollOperation({
|
|
139
|
+
...apphostingPollerOptions,
|
|
140
|
+
pollerName: `create-${projectId}-${location}-backend-${backendId}-build-${buildId}`,
|
|
141
|
+
operationResourceName: buildOp.name,
|
|
142
|
+
});
|
|
143
|
+
const [rollout, build] = await Promise.all([rolloutPoll, buildPoll]);
|
|
144
|
+
(0, utils_1.logSuccess)("Rollout completed.");
|
|
145
|
+
return { rollout, build };
|
|
146
|
+
}
|
|
147
|
+
exports.onboardRollout = onboardRollout;
|