firebase-tools-with-isolate 15.32.0 → 15.34.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/lib/accountImporter.js +6 -3
- package/lib/api.js +3 -3
- package/lib/apphosting/backend.js +1 -1
- package/lib/apphosting/secrets/index.js +7 -2
- package/lib/checkValidTargetFilters.js +1 -0
- package/lib/command.js +31 -24
- package/lib/commands/apps-create.js +34 -3
- package/lib/commands/crashlytics-heapdumps-disable.js +26 -0
- package/lib/commands/crashlytics-heapdumps-enable.js +54 -0
- package/lib/commands/crashlytics-heapdumps-status.js +32 -0
- package/lib/commands/deploy.js +3 -0
- package/lib/commands/functions-kits-uninstall.js +43 -21
- package/lib/commands/functions-lifecycle-list.js +5 -6
- package/lib/commands/hosting-channel-deploy.js +3 -3
- package/lib/commands/hosting-clone.js +102 -31
- package/lib/commands/hosting-disable.js +5 -1
- package/lib/commands/index.js +9 -0
- package/lib/commands/init.js +7 -0
- package/lib/commands/run-services-update.js +16 -0
- package/lib/config.js +1 -0
- package/lib/crashlytics/alerts.js +122 -0
- package/lib/crashlytics/onboarding.js +71 -3
- package/lib/crashlytics/profilingManager.js +195 -0
- package/lib/crashlytics/sourcemap.js +46 -11
- package/lib/crashlytics/types.js +6 -1
- package/lib/deploy/apphosting/prepare.js +1 -0
- package/lib/deploy/auth/deploy.js +1 -1
- package/lib/deploy/auth/prepare.js +6 -7
- package/lib/deploy/firestore/prepare.js +5 -5
- package/lib/deploy/functions/build.js +3 -0
- package/lib/deploy/functions/cel.js +89 -58
- package/lib/deploy/functions/functionsDeployHelper.js +10 -0
- package/lib/deploy/functions/params.js +4 -2
- package/lib/deploy/functions/prepare.js +25 -8
- package/lib/deploy/functions/release/executor.js +7 -3
- package/lib/deploy/functions/release/fabricator.js +42 -14
- package/lib/deploy/functions/release/planner.js +3 -2
- package/lib/deploy/functions/release/sourceTokenScraper.js +1 -1
- package/lib/deploy/functions/validate.js +16 -0
- package/lib/deploy/hosting/prepare.js +1 -1
- package/lib/deploy/hosting/release.js +2 -2
- package/lib/deploy/index.js +5 -0
- package/lib/deploy/run/args.js +2 -0
- package/lib/deploy/run/buildEnv.js +72 -0
- package/lib/deploy/run/deploy.js +214 -0
- package/lib/deploy/run/index.js +23 -0
- package/lib/deploy/run/prepare.js +47 -0
- package/lib/deploy/run/prereqs.js +32 -0
- package/lib/deploy/run/release.js +9 -0
- package/lib/deploy/run/update.js +50 -0
- package/lib/deploy/run/util.js +73 -0
- package/lib/emulator/apphosting/serve.js +1 -1
- package/lib/emulator/auth/operations.js +8 -4
- package/lib/emulator/auth/utils.js +1 -1
- package/lib/emulator/commandUtils.js +7 -3
- package/lib/emulator/databaseEmulator.js +7 -3
- package/lib/emulator/dataconnect/pgliteServer.js +1 -1
- package/lib/emulator/dataconnectEmulator.js +1 -1
- package/lib/emulator/download.js +1 -1
- package/lib/emulator/downloadableEmulatorInfo.json +31 -31
- package/lib/emulator/downloadableEmulators.js +1 -3
- package/lib/emulator/emulatorLogger.js +2 -1
- package/lib/emulator/eventarcEmulator.js +1 -1
- package/lib/emulator/functionsEmulatorRuntime.js +2 -1
- package/lib/emulator/functionsEmulatorShared.js +1 -41
- package/lib/experiments.js +17 -11
- package/lib/extensions/warnings.js +48 -7
- package/lib/firestore/validator.js +1 -1
- package/lib/frameworks/next/constants.js +20 -12
- package/lib/frameworks/next/index.js +4 -23
- package/lib/frameworks/next/utils.js +28 -0
- package/lib/functions/env.js +4 -2
- package/lib/functions/projectConfig.js +10 -5
- package/lib/gcp/artifactregistry.js +20 -0
- package/lib/gcp/cloudmonitoring.js +80 -3
- package/lib/gcp/cloudsql/permissions.js +21 -32
- package/lib/gcp/cloudsql/permissionsSetup.js +6 -6
- package/lib/gcp/cloudtasks.js +15 -1
- package/lib/gcp/cloudtrace.js +38 -0
- package/lib/gcp/run.js +5 -0
- package/lib/gcp/runv2.js +32 -11
- package/lib/gcp/storage.js +9 -5
- package/lib/hosting/api.js +15 -15
- package/lib/hosting/runTags.js +1 -1
- package/lib/init/features/auth.js +46 -8
- package/lib/init/features/hosting/index.js +4 -2
- package/lib/init/features/index.js +4 -1
- package/lib/init/features/run.js +159 -0
- package/lib/init/index.js +6 -0
- package/lib/management/apps.js +4 -2
- package/lib/mcp/tools/firestore/converter.js +2 -2
- package/lib/mcp/util.js +11 -10
- package/lib/profileReport.js +12 -9
- package/lib/scopes.js +1 -3
- package/lib/streamJson.js +1 -0
- package/lib/throttler/throttler.js +1 -0
- package/lib/tsconfig.publish.tsbuildinfo +1 -1
- package/lib/utils.js +0 -15
- package/package.json +11 -17
- package/schema/firebase-config.json +41 -0
- package/schema/firebaserc.json +133 -0
- package/lib/mcp/resources/guides/init_data_connect.js +0 -30
- package/lib/mcp/resources/guides/init_rtdb.js +0 -30
package/lib/gcp/cloudtasks.js
CHANGED
|
@@ -5,6 +5,7 @@ exports.createQueue = createQueue;
|
|
|
5
5
|
exports.getQueue = getQueue;
|
|
6
6
|
exports.updateQueue = updateQueue;
|
|
7
7
|
exports.upsertQueue = upsertQueue;
|
|
8
|
+
exports.disableQueue = disableQueue;
|
|
8
9
|
exports.purgeQueue = purgeQueue;
|
|
9
10
|
exports.deleteQueue = deleteQueue;
|
|
10
11
|
exports.enqueueTask = enqueueTask;
|
|
@@ -72,6 +73,19 @@ async function upsertQueue(queue) {
|
|
|
72
73
|
throw err;
|
|
73
74
|
}
|
|
74
75
|
}
|
|
76
|
+
async function disableQueue(name) {
|
|
77
|
+
try {
|
|
78
|
+
await module.exports.getQueue(name);
|
|
79
|
+
}
|
|
80
|
+
catch (err) {
|
|
81
|
+
const responseError = err;
|
|
82
|
+
if (responseError.context?.response?.statusCode === 404) {
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
throw err;
|
|
86
|
+
}
|
|
87
|
+
await module.exports.updateQueue({ name, state: "DISABLED" });
|
|
88
|
+
}
|
|
75
89
|
async function purgeQueue(name) {
|
|
76
90
|
await client.post(`${name}:purge`);
|
|
77
91
|
}
|
|
@@ -108,7 +122,7 @@ async function setEnqueuer(name, invoker, assumeEmpty = false) {
|
|
|
108
122
|
const invokerMembers = proto.getInvokerMembers(invoker, project);
|
|
109
123
|
while (true) {
|
|
110
124
|
const policy = {
|
|
111
|
-
bindings: existing.bindings.filter((binding) => binding.role !== ENQUEUER_ROLE),
|
|
125
|
+
bindings: (existing.bindings || []).filter((binding) => binding.role !== ENQUEUER_ROLE),
|
|
112
126
|
etag: existing.etag,
|
|
113
127
|
version: existing.version,
|
|
114
128
|
};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.provisionTraceStorage = provisionTraceStorage;
|
|
4
|
+
const api_1 = require("../api");
|
|
5
|
+
const apiv2_1 = require("../apiv2");
|
|
6
|
+
const error_1 = require("../error");
|
|
7
|
+
const API_VERSION = "v2";
|
|
8
|
+
const getTraceClient = () => new apiv2_1.Client({
|
|
9
|
+
urlPrefix: (0, api_1.cloudTraceOrigin)(),
|
|
10
|
+
auth: true,
|
|
11
|
+
apiVersion: API_VERSION,
|
|
12
|
+
});
|
|
13
|
+
async function provisionTraceStorage(projectId) {
|
|
14
|
+
const TRACE_ID = "33fc0d8c45bb4e5cebb29f047931270d";
|
|
15
|
+
const SPAN_ID = "f8fde40b437488e5";
|
|
16
|
+
const now = new Date();
|
|
17
|
+
const later = new Date(now.getTime() + 1000);
|
|
18
|
+
const payload = {
|
|
19
|
+
name: `projects/${projectId}`,
|
|
20
|
+
spans: [
|
|
21
|
+
{
|
|
22
|
+
name: `projects/${projectId}/traces/${TRACE_ID}/spans/${SPAN_ID}`,
|
|
23
|
+
spanId: SPAN_ID,
|
|
24
|
+
displayName: { value: "/welcome" },
|
|
25
|
+
startTime: now.toISOString(),
|
|
26
|
+
endTime: later.toISOString(),
|
|
27
|
+
},
|
|
28
|
+
],
|
|
29
|
+
};
|
|
30
|
+
try {
|
|
31
|
+
await getTraceClient().post(`/projects/${projectId}/traces:batchWrite`, payload);
|
|
32
|
+
}
|
|
33
|
+
catch (err) {
|
|
34
|
+
throw new error_1.FirebaseError(`Failed to provision trace storage for project ${projectId}: ${(0, error_1.getErrMsg)(err)}`, {
|
|
35
|
+
original: (0, error_1.getError)(err),
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
}
|
package/lib/gcp/run.js
CHANGED
|
@@ -11,6 +11,7 @@ exports.getIamPolicy = getIamPolicy;
|
|
|
11
11
|
exports.setInvokerCreate = setInvokerCreate;
|
|
12
12
|
exports.setInvokerUpdate = setInvokerUpdate;
|
|
13
13
|
exports.fetchServiceLogs = fetchServiceLogs;
|
|
14
|
+
exports.listLocations = listLocations;
|
|
14
15
|
const apiv2_1 = require("../apiv2");
|
|
15
16
|
const error_1 = require("../error");
|
|
16
17
|
const api_1 = require("../api");
|
|
@@ -166,3 +167,7 @@ async function fetchServiceLogs(projectId, serviceId) {
|
|
|
166
167
|
});
|
|
167
168
|
}
|
|
168
169
|
}
|
|
170
|
+
async function listLocations(projectId) {
|
|
171
|
+
const res = await client.get(`/projects/${projectId}/locations`);
|
|
172
|
+
return res.body?.locations?.map((l) => l.locationId) ?? [];
|
|
173
|
+
}
|
package/lib/gcp/runv2.js
CHANGED
|
@@ -28,33 +28,52 @@ const client = new apiv2_1.Client({
|
|
|
28
28
|
apiVersion: exports.API_VERSION,
|
|
29
29
|
});
|
|
30
30
|
(0, metaprogramming_1.assertImplements)();
|
|
31
|
+
const PENDING_BUILD_STATUSES = ["STATUS_UNKNOWN", "PENDING", "QUEUED", "WORKING"];
|
|
31
32
|
async function submitBuild(projectId, location, build) {
|
|
32
|
-
const res = await client.post(`/projects/${projectId}/locations/${location}/builds`, build);
|
|
33
|
-
if (res.
|
|
34
|
-
|
|
33
|
+
const res = await client.post(`/projects/${projectId}/locations/${location}/builds:submit`, build);
|
|
34
|
+
if (res.body?.baseImageWarning) {
|
|
35
|
+
logger_1.logger.warn(res.body.baseImageWarning);
|
|
35
36
|
}
|
|
37
|
+
const cloudBuild = res.body?.buildOperation?.metadata?.build;
|
|
38
|
+
if (!cloudBuild) {
|
|
39
|
+
throw new error_1.FirebaseError("Failed to submit build: no build was returned.");
|
|
40
|
+
}
|
|
41
|
+
let status;
|
|
36
42
|
await (0, operation_poller_1.pollOperation)({
|
|
37
43
|
apiOrigin: (0, api_1.cloudbuildOrigin)(),
|
|
38
44
|
apiVersion: "v1",
|
|
39
|
-
operationResourceName:
|
|
45
|
+
operationResourceName: cloudBuild.name,
|
|
46
|
+
masterTimeout: 30 * 60 * 1000,
|
|
47
|
+
maxBackoff: 10000,
|
|
48
|
+
doneFn: (b) => {
|
|
49
|
+
status = b?.status;
|
|
50
|
+
return !b?.status || !PENDING_BUILD_STATUSES.includes(b.status);
|
|
51
|
+
},
|
|
40
52
|
});
|
|
53
|
+
if (status !== "SUCCESS") {
|
|
54
|
+
throw new error_1.FirebaseError(`Cloud Build failed with status ${status ?? "UNKNOWN"}. View the build logs at ${cloudBuild.logUrl ?? ""}`);
|
|
55
|
+
}
|
|
41
56
|
}
|
|
42
|
-
async function updateService(service) {
|
|
43
|
-
|
|
44
|
-
|
|
57
|
+
async function updateService(service, opts = {}) {
|
|
58
|
+
let updateMask = opts.updateMask;
|
|
59
|
+
if (!updateMask) {
|
|
60
|
+
updateMask = proto.fieldMasks(service, "labels", "annotations", "tags");
|
|
61
|
+
updateMask.push("template.revision");
|
|
62
|
+
}
|
|
45
63
|
const res = await client.patch(service.name, service, {
|
|
46
64
|
queryParams: {
|
|
47
|
-
updateMask:
|
|
65
|
+
updateMask: updateMask.join(","),
|
|
48
66
|
},
|
|
49
67
|
});
|
|
50
68
|
const svc = await (0, operation_poller_1.pollOperation)({
|
|
51
69
|
apiOrigin: (0, api_1.runOrigin)(),
|
|
52
70
|
apiVersion: exports.API_VERSION,
|
|
53
71
|
operationResourceName: res.body.name,
|
|
72
|
+
masterTimeout: opts.pollTimeoutMs,
|
|
54
73
|
});
|
|
55
74
|
return svc;
|
|
56
75
|
}
|
|
57
|
-
async function createService(projectId, location, serviceId, service) {
|
|
76
|
+
async function createService(projectId, location, serviceId, service, opts = {}) {
|
|
58
77
|
const { name, ...serviceBody } = service;
|
|
59
78
|
const res = await client.post(`/projects/${projectId}/locations/${location}/services`, serviceBody, {
|
|
60
79
|
queryParams: {
|
|
@@ -65,6 +84,7 @@ async function createService(projectId, location, serviceId, service) {
|
|
|
65
84
|
apiOrigin: (0, api_1.runOrigin)(),
|
|
66
85
|
apiVersion: exports.API_VERSION,
|
|
67
86
|
operationResourceName: res.body.name,
|
|
87
|
+
masterTimeout: opts.pollTimeoutMs,
|
|
68
88
|
});
|
|
69
89
|
return svc;
|
|
70
90
|
}
|
|
@@ -82,7 +102,7 @@ async function getService(projectId, location, serviceId) {
|
|
|
82
102
|
const res = await client.get(name);
|
|
83
103
|
return res.body;
|
|
84
104
|
}
|
|
85
|
-
async function listServices(projectId) {
|
|
105
|
+
async function listServices(projectId, functionsOnly = true) {
|
|
86
106
|
const allServices = [];
|
|
87
107
|
let pageToken = undefined;
|
|
88
108
|
do {
|
|
@@ -98,7 +118,8 @@ async function listServices(projectId) {
|
|
|
98
118
|
}
|
|
99
119
|
if (res.body.services) {
|
|
100
120
|
for (const service of res.body.services) {
|
|
101
|
-
if (
|
|
121
|
+
if (!functionsOnly ||
|
|
122
|
+
service.labels?.[exports.CLIENT_NAME_LABEL] === "cloud-functions" ||
|
|
102
123
|
service.labels?.[exports.CLIENT_NAME_LABEL] === "cloudfunctions" ||
|
|
103
124
|
service.labels?.[exports.CLIENT_NAME_LABEL] === "firebase-functions") {
|
|
104
125
|
allServices.push(service);
|
package/lib/gcp/storage.js
CHANGED
|
@@ -118,9 +118,11 @@ async function getBucket(bucketName) {
|
|
|
118
118
|
return result.body;
|
|
119
119
|
}
|
|
120
120
|
catch (err) {
|
|
121
|
-
|
|
121
|
+
const error = (0, error_1.getError)(err);
|
|
122
|
+
logger_1.logger.debug(error);
|
|
122
123
|
throw new error_1.FirebaseError("Failed to obtain the storage bucket", {
|
|
123
|
-
original:
|
|
124
|
+
original: error,
|
|
125
|
+
status: (0, error_1.getErrStatus)(err),
|
|
124
126
|
});
|
|
125
127
|
}
|
|
126
128
|
}
|
|
@@ -147,14 +149,16 @@ async function createBucket(projectId, req, projectPrivate) {
|
|
|
147
149
|
async function patchBucket(bucketName, metadata) {
|
|
148
150
|
try {
|
|
149
151
|
const localAPIClient = new apiv2_1.Client({ urlPrefix: (0, api_1.storageOrigin)() });
|
|
150
|
-
const mask = (0, proto_1.fieldMasks)(metadata, "labels", "acl", "defaultObjectAcl", "lifecycle");
|
|
152
|
+
const mask = (0, proto_1.fieldMasks)(metadata, "labels", "acl", "defaultObjectAcl", "lifecycle", "cors");
|
|
151
153
|
const result = await localAPIClient.patch(`/storage/v1/b/${bucketName}`, metadata, { queryParams: { updateMask: mask.join(",") } });
|
|
152
154
|
return result.body;
|
|
153
155
|
}
|
|
154
156
|
catch (err) {
|
|
155
|
-
|
|
157
|
+
const error = (0, error_1.getError)(err);
|
|
158
|
+
logger_1.logger.debug(error);
|
|
156
159
|
throw new error_1.FirebaseError("Failed to patch the storage bucket", {
|
|
157
|
-
original:
|
|
160
|
+
original: error,
|
|
161
|
+
status: (0, error_1.getErrStatus)(err),
|
|
158
162
|
});
|
|
159
163
|
}
|
|
160
164
|
}
|
package/lib/hosting/api.js
CHANGED
|
@@ -56,7 +56,7 @@ const apiClient = new apiv2_1.Client({
|
|
|
56
56
|
apiVersion: "v1beta1",
|
|
57
57
|
auth: true,
|
|
58
58
|
});
|
|
59
|
-
async function getChannel(project
|
|
59
|
+
async function getChannel(project, site, channelId) {
|
|
60
60
|
try {
|
|
61
61
|
const res = await apiClient.get(`/projects/${project}/sites/${site}/channels/${channelId}`);
|
|
62
62
|
return res.body;
|
|
@@ -68,7 +68,7 @@ async function getChannel(project = "-", site, channelId) {
|
|
|
68
68
|
throw e;
|
|
69
69
|
}
|
|
70
70
|
}
|
|
71
|
-
async function listChannels(project
|
|
71
|
+
async function listChannels(project, site) {
|
|
72
72
|
const channels = [];
|
|
73
73
|
let nextPageToken = "";
|
|
74
74
|
for (;;) {
|
|
@@ -90,30 +90,30 @@ async function listChannels(project = "-", site) {
|
|
|
90
90
|
}
|
|
91
91
|
}
|
|
92
92
|
}
|
|
93
|
-
async function createChannel(project
|
|
93
|
+
async function createChannel(project, site, channelId, ttlMillis = expireUtils_1.DEFAULT_DURATION) {
|
|
94
94
|
const res = await apiClient.post(`/projects/${project}/sites/${site}/channels?channelId=${channelId}`, { ttl: `${ttlMillis / 1000}s` });
|
|
95
95
|
return res.body;
|
|
96
96
|
}
|
|
97
|
-
async function updateChannelTtl(project
|
|
97
|
+
async function updateChannelTtl(project, site, channelId, ttlMillis = ONE_WEEK_MS) {
|
|
98
98
|
const res = await apiClient.patch(`/projects/${project}/sites/${site}/channels/${channelId}`, { ttl: `${ttlMillis / 1000}s` }, { queryParams: { updateMask: "ttl" } });
|
|
99
99
|
return res.body;
|
|
100
100
|
}
|
|
101
|
-
async function deleteChannel(project
|
|
101
|
+
async function deleteChannel(project, site, channelId) {
|
|
102
102
|
await apiClient.delete(`/projects/${project}/sites/${site}/channels/${channelId}`);
|
|
103
103
|
}
|
|
104
|
-
async function createVersion(siteId, version) {
|
|
105
|
-
const res = await apiClient.post(
|
|
104
|
+
async function createVersion(project, siteId, version) {
|
|
105
|
+
const res = await apiClient.post(`/projects/${project}/sites/${siteId}/versions`, version);
|
|
106
106
|
return res.body.name;
|
|
107
107
|
}
|
|
108
|
-
async function updateVersion(site, versionId, version) {
|
|
109
|
-
const res = await apiClient.patch(
|
|
108
|
+
async function updateVersion(project, site, versionId, version) {
|
|
109
|
+
const res = await apiClient.patch(`/projects/${project}/sites/${site}/versions/${versionId}`, version, {
|
|
110
110
|
queryParams: {
|
|
111
111
|
updateMask: proto.fieldMasks(version, "labels", "config").join(","),
|
|
112
112
|
},
|
|
113
113
|
});
|
|
114
114
|
return res.body;
|
|
115
115
|
}
|
|
116
|
-
async function listVersions(site) {
|
|
116
|
+
async function listVersions(project, site) {
|
|
117
117
|
let pageToken = undefined;
|
|
118
118
|
const versions = [];
|
|
119
119
|
do {
|
|
@@ -121,7 +121,7 @@ async function listVersions(site) {
|
|
|
121
121
|
if (pageToken) {
|
|
122
122
|
queryParams.pageToken = pageToken;
|
|
123
123
|
}
|
|
124
|
-
const res = await apiClient.get(
|
|
124
|
+
const res = await apiClient.get(`/projects/${project}/sites/${site}/versions`, {
|
|
125
125
|
queryParams,
|
|
126
126
|
});
|
|
127
127
|
versions.push(...(res.body.versions ?? []));
|
|
@@ -129,8 +129,8 @@ async function listVersions(site) {
|
|
|
129
129
|
} while (pageToken);
|
|
130
130
|
return versions;
|
|
131
131
|
}
|
|
132
|
-
async function cloneVersion(site, versionName, finalize = false) {
|
|
133
|
-
const res = await apiClient.post(`/projects
|
|
132
|
+
async function cloneVersion(project, site, versionName, finalize = false) {
|
|
133
|
+
const res = await apiClient.post(`/projects/${project}/sites/${site}/versions:clone`, {
|
|
134
134
|
sourceVersion: versionName,
|
|
135
135
|
finalize,
|
|
136
136
|
});
|
|
@@ -143,8 +143,8 @@ async function cloneVersion(site, versionName, finalize = false) {
|
|
|
143
143
|
});
|
|
144
144
|
return pollRes;
|
|
145
145
|
}
|
|
146
|
-
async function createRelease(site, channel, version, partialRelease) {
|
|
147
|
-
const res = await apiClient.post(`/projects
|
|
146
|
+
async function createRelease(project, site, channel, version, partialRelease) {
|
|
147
|
+
const res = await apiClient.post(`/projects/${project}/sites/${site}/channels/${channel}/releases`, partialRelease, { queryParams: { versionName: version } });
|
|
148
148
|
return res.body;
|
|
149
149
|
}
|
|
150
150
|
async function listSites(project) {
|
package/lib/hosting/runTags.js
CHANGED
|
@@ -14,7 +14,7 @@ exports.TODO_TAG_NAME = "this is an invalid tag name so it cannot be real";
|
|
|
14
14
|
async function gcTagsForServices(project, services) {
|
|
15
15
|
const validTagsByServiceByRegion = {};
|
|
16
16
|
const sites = await api.listSites(project);
|
|
17
|
-
const allVersionsNested = await Promise.all(sites.map((site) => api.listVersions(node_path_1.posix.basename(site.name))));
|
|
17
|
+
const allVersionsNested = await Promise.all(sites.map((site) => api.listVersions(project, node_path_1.posix.basename(site.name))));
|
|
18
18
|
const activeVersions = [...(0, functional_1.flattenArray)(allVersionsNested)].filter((version) => {
|
|
19
19
|
return version.status === "CREATED" || version.status === "FINALIZED";
|
|
20
20
|
});
|
|
@@ -5,7 +5,11 @@ exports.actuate = actuate;
|
|
|
5
5
|
const clc = require("colorette");
|
|
6
6
|
const prompt_1 = require("../../prompt");
|
|
7
7
|
const logger_1 = require("../../logger");
|
|
8
|
-
|
|
8
|
+
const getDefaultHostingSite_1 = require("../../getDefaultHostingSite");
|
|
9
|
+
const interactive_1 = require("../../hosting/interactive");
|
|
10
|
+
const api_1 = require("../../hosting/api");
|
|
11
|
+
const utils_1 = require("../../utils");
|
|
12
|
+
async function askQuestions(setup, config, options) {
|
|
9
13
|
const authConfig = setup.config.auth;
|
|
10
14
|
const choices = [
|
|
11
15
|
{
|
|
@@ -38,33 +42,67 @@ async function askQuestions(setup) {
|
|
|
38
42
|
if (providers.includes("google")) {
|
|
39
43
|
logger_1.logger.info("");
|
|
40
44
|
logger_1.logger.info("Configuring Google Sign-In...");
|
|
45
|
+
const projectId = setup.projectId;
|
|
46
|
+
const defaultDisplayName = authConfig?.providers?.googleSignIn?.oAuthBrandDisplayName || projectId || "My App";
|
|
41
47
|
const oAuthBrandDisplayName = await (0, prompt_1.input)({
|
|
42
48
|
message: "What display name would you like to use for your OAuth brand?",
|
|
43
|
-
default:
|
|
44
|
-
setup.project?.projectId ||
|
|
45
|
-
"My App",
|
|
49
|
+
default: defaultDisplayName,
|
|
46
50
|
});
|
|
51
|
+
const defaultEmail = authConfig?.providers?.googleSignIn?.supportEmail ||
|
|
52
|
+
(projectId ? `support@${projectId}.firebaseapp.com` : undefined);
|
|
47
53
|
const supportEmail = await (0, prompt_1.input)({
|
|
48
54
|
message: "What support email would you like to register for your OAuth brand?",
|
|
49
|
-
default:
|
|
50
|
-
(setup.project ? `support@${setup.project.projectId}.firebaseapp.com` : undefined),
|
|
55
|
+
default: defaultEmail,
|
|
51
56
|
});
|
|
52
57
|
providersConfig.googleSignIn = {
|
|
53
58
|
oAuthBrandDisplayName,
|
|
54
59
|
supportEmail,
|
|
55
60
|
};
|
|
56
61
|
}
|
|
62
|
+
let newSiteId;
|
|
63
|
+
if (setup.projectId) {
|
|
64
|
+
let existingSite = setup.featureInfo?.hosting?.newSiteId;
|
|
65
|
+
if (!existingSite) {
|
|
66
|
+
try {
|
|
67
|
+
existingSite = await (0, getDefaultHostingSite_1.getDefaultHostingSite)({ projectId: setup.projectId });
|
|
68
|
+
}
|
|
69
|
+
catch (err) {
|
|
70
|
+
if (err !== getDefaultHostingSite_1.errNoDefaultSite) {
|
|
71
|
+
throw err;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
if (existingSite) {
|
|
76
|
+
logger_1.logger.info(`Firebase Hosting site is present: ${clc.bold(existingSite)}.`);
|
|
77
|
+
}
|
|
78
|
+
else if (await (0, prompt_1.confirm)({
|
|
79
|
+
message: "A Firebase Hosting site is required for Firebase Authentication. Would you like to create a default site now?",
|
|
80
|
+
default: true,
|
|
81
|
+
nonInteractive: options?.nonInteractive,
|
|
82
|
+
})) {
|
|
83
|
+
newSiteId = await (0, interactive_1.pickHostingSiteName)("", {
|
|
84
|
+
projectId: setup.projectId,
|
|
85
|
+
nonInteractive: options?.nonInteractive,
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
}
|
|
57
89
|
if (!setup.featureInfo) {
|
|
58
90
|
setup.featureInfo = {};
|
|
59
91
|
}
|
|
60
|
-
setup.featureInfo.auth = { providers: providersConfig };
|
|
92
|
+
setup.featureInfo.auth = { providers: providersConfig, newSiteId };
|
|
61
93
|
}
|
|
62
94
|
async function actuate(setup, config) {
|
|
63
95
|
const authConfig = setup.featureInfo?.auth;
|
|
64
96
|
if (!authConfig) {
|
|
65
97
|
return;
|
|
66
98
|
}
|
|
67
|
-
|
|
99
|
+
if (authConfig.newSiteId && setup.projectId) {
|
|
100
|
+
await (0, api_1.createSite)(setup.projectId, authConfig.newSiteId);
|
|
101
|
+
logger_1.logger.info("");
|
|
102
|
+
(0, utils_1.logSuccess)(`Firebase Hosting site ${authConfig.newSiteId} created!`);
|
|
103
|
+
logger_1.logger.info("");
|
|
104
|
+
}
|
|
105
|
+
config.set("auth", { providers: authConfig.providers });
|
|
68
106
|
config.writeProjectFile("firebase.json", config.src);
|
|
69
107
|
logger_1.logger.info("");
|
|
70
108
|
logger_1.logger.info("Generated firebase.json with auth configuration.");
|
|
@@ -30,7 +30,7 @@ async function askQuestions(setup, config, options) {
|
|
|
30
30
|
case "nuxt2":
|
|
31
31
|
case "express":
|
|
32
32
|
case "svelekit":
|
|
33
|
-
case "sveltekit":
|
|
33
|
+
case "sveltekit": {
|
|
34
34
|
logger_1.logger.info();
|
|
35
35
|
const useAppHosting = await (0, prompt_1.confirm)({
|
|
36
36
|
message: `Detected a ${frameworkName} codebase with SSR features. We can't guarantee that ` +
|
|
@@ -47,7 +47,8 @@ async function askQuestions(setup, config, options) {
|
|
|
47
47
|
return;
|
|
48
48
|
}
|
|
49
49
|
break;
|
|
50
|
-
|
|
50
|
+
}
|
|
51
|
+
default: {
|
|
51
52
|
logger_1.logger.info();
|
|
52
53
|
logger_1.logger.info(`Detected a ${frameworkName} codebase with SSR features. We can't guarantee that ` +
|
|
53
54
|
`this site will work on Firebase Hosting, which is optimized for static sites. Another ` +
|
|
@@ -62,6 +63,7 @@ async function askQuestions(setup, config, options) {
|
|
|
62
63
|
throw new error_1.FirebaseError("Hosting initialization cancelled.", { exit: 1 });
|
|
63
64
|
}
|
|
64
65
|
break;
|
|
66
|
+
}
|
|
65
67
|
}
|
|
66
68
|
}
|
|
67
69
|
setup.featureInfo = setup.featureInfo || {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.agentSkillsActuate = exports.agentSkillsAskQuestions = exports.authActuate = exports.authAskQuestions = exports.aiLogicActuate = exports.aiLogicAskQuestions = exports.aitools = exports.apptestingAcutate = exports.apptestingAskQuestions = exports.genkit = exports.apphosting = exports.dataconnectResolverActuate = exports.dataconnectResolverAskQuestions = exports.dataconnectSdkActuate = exports.dataconnectSdkAskQuestions = exports.dataconnectActuate = exports.dataconnectAskQuestions = exports.hostingGithub = exports.remoteconfig = exports.project = exports.extensions = exports.emulators = exports.storageActuate = exports.storageAskQuestions = exports.hostingActuate = exports.hostingAskQuestions = exports.functionsActuate = exports.functionsAskQuestions = exports.firestoreActuate = exports.firestoreAskQuestions = exports.databaseActuate = exports.databaseAskQuestions = exports.account = void 0;
|
|
3
|
+
exports.runActuate = exports.runAskQuestions = exports.agentSkillsActuate = exports.agentSkillsAskQuestions = exports.authActuate = exports.authAskQuestions = exports.aiLogicActuate = exports.aiLogicAskQuestions = exports.aitools = exports.apptestingAcutate = exports.apptestingAskQuestions = exports.genkit = exports.apphosting = exports.dataconnectResolverActuate = exports.dataconnectResolverAskQuestions = exports.dataconnectSdkActuate = exports.dataconnectSdkAskQuestions = exports.dataconnectActuate = exports.dataconnectAskQuestions = exports.hostingGithub = exports.remoteconfig = exports.project = exports.extensions = exports.emulators = exports.storageActuate = exports.storageAskQuestions = exports.hostingActuate = exports.hostingAskQuestions = exports.functionsActuate = exports.functionsAskQuestions = exports.firestoreActuate = exports.firestoreAskQuestions = exports.databaseActuate = exports.databaseAskQuestions = exports.account = void 0;
|
|
4
4
|
var account_1 = require("./account");
|
|
5
5
|
Object.defineProperty(exports, "account", { enumerable: true, get: function () { return account_1.doSetup; } });
|
|
6
6
|
var database_1 = require("./database");
|
|
@@ -55,3 +55,6 @@ Object.defineProperty(exports, "authActuate", { enumerable: true, get: function
|
|
|
55
55
|
var agentSkills_1 = require("./agentSkills");
|
|
56
56
|
Object.defineProperty(exports, "agentSkillsAskQuestions", { enumerable: true, get: function () { return agentSkills_1.askQuestions; } });
|
|
57
57
|
Object.defineProperty(exports, "agentSkillsActuate", { enumerable: true, get: function () { return agentSkills_1.actuate; } });
|
|
58
|
+
var run_1 = require("./run");
|
|
59
|
+
Object.defineProperty(exports, "runAskQuestions", { enumerable: true, get: function () { return run_1.askQuestions; } });
|
|
60
|
+
Object.defineProperty(exports, "runActuate", { enumerable: true, get: function () { return run_1.actuate; } });
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.askQuestions = askQuestions;
|
|
4
|
+
exports.actuate = actuate;
|
|
5
|
+
exports.upsertRunConfig = upsertRunConfig;
|
|
6
|
+
const path = require("path");
|
|
7
|
+
const deploy_1 = require("../../deploy");
|
|
8
|
+
const prereqs_1 = require("../../deploy/run/prereqs");
|
|
9
|
+
const util_1 = require("../../deploy/run/util");
|
|
10
|
+
const error_1 = require("../../error");
|
|
11
|
+
const fsutils_1 = require("../../fsutils");
|
|
12
|
+
const run = require("../../gcp/run");
|
|
13
|
+
const runv2 = require("../../gcp/runv2");
|
|
14
|
+
const prompt_1 = require("../../prompt");
|
|
15
|
+
const requirePermissions_1 = require("../../requirePermissions");
|
|
16
|
+
const utils_1 = require("../../utils");
|
|
17
|
+
const DEFAULT_IGNORE = ["node_modules", ".git", "firebase-debug.log", "firebase-debug.*.log"];
|
|
18
|
+
const SERVICE_ID_REGEX = /^[a-z]([-a-z0-9]{0,47}[a-z0-9])?$/;
|
|
19
|
+
async function askQuestions(setup, config, options) {
|
|
20
|
+
const projectId = setup.projectId;
|
|
21
|
+
if (!projectId) {
|
|
22
|
+
throw new error_1.FirebaseError("Cloud Run requires a Firebase project. Run firebase use --add first.");
|
|
23
|
+
}
|
|
24
|
+
await (0, requirePermissions_1.requirePermissions)({ ...options, projectId }, prereqs_1.RUN_PERMISSIONS);
|
|
25
|
+
await (0, prereqs_1.prereqs)(projectId);
|
|
26
|
+
let existing;
|
|
27
|
+
const action = await (0, prompt_1.select)({
|
|
28
|
+
message: "Please select an option",
|
|
29
|
+
choices: [
|
|
30
|
+
{ name: "Create a new service and deploy", value: "create" },
|
|
31
|
+
{ name: "Update an existing service and deploy", value: "update" },
|
|
32
|
+
],
|
|
33
|
+
default: "create",
|
|
34
|
+
});
|
|
35
|
+
if (action === "update") {
|
|
36
|
+
existing = await promptExistingService(projectId);
|
|
37
|
+
}
|
|
38
|
+
let serviceId;
|
|
39
|
+
let region;
|
|
40
|
+
if (existing) {
|
|
41
|
+
({ region, serviceId } = parseServiceName(existing.name));
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
region = await (0, prompt_1.select)({
|
|
45
|
+
message: "Which region should this service be deployed to?",
|
|
46
|
+
choices: await run.listLocations(projectId),
|
|
47
|
+
default: "us-central1",
|
|
48
|
+
});
|
|
49
|
+
serviceId = await promptNewServiceId(projectId, region);
|
|
50
|
+
}
|
|
51
|
+
const savedEntry = findRunEntry(getRunEntries(config), serviceId, region);
|
|
52
|
+
const localBuild = await (0, prompt_1.select)({
|
|
53
|
+
message: "Would you like to build your app locally or remotely?",
|
|
54
|
+
choices: [
|
|
55
|
+
{ name: "Build remotely on Cloud Build", value: false },
|
|
56
|
+
{ name: "Build locally", value: true },
|
|
57
|
+
],
|
|
58
|
+
default: savedEntry?.localBuild === true,
|
|
59
|
+
});
|
|
60
|
+
const rawBaseImage = await (0, prompt_1.input)({
|
|
61
|
+
message: localBuild
|
|
62
|
+
? "Which base image should your app use? (e.g. nodejs20, nodejs22)"
|
|
63
|
+
: "Which base image should your app use, if any? (e.g. nodejs20, nodejs22)",
|
|
64
|
+
default: (0, util_1.mainContainer)(existing?.template)?.baseImageUri,
|
|
65
|
+
validate: (img) => localBuild && !img.trim() ? "Local builds require a base image." : true,
|
|
66
|
+
});
|
|
67
|
+
const baseImage = (rawBaseImage || "").trim();
|
|
68
|
+
const rootDir = await promptRootDir(config.projectDir, savedEntry?.rootDir ?? "/");
|
|
69
|
+
const runInfo = { serviceId, region, baseImage, rootDir };
|
|
70
|
+
if (localBuild) {
|
|
71
|
+
runInfo.localBuild = true;
|
|
72
|
+
}
|
|
73
|
+
setup.featureInfo = { ...setup.featureInfo, run: runInfo };
|
|
74
|
+
}
|
|
75
|
+
async function promptExistingService(projectId) {
|
|
76
|
+
const allServices = await runv2.listServices(projectId, false);
|
|
77
|
+
const services = allServices.filter((s) => !s.labels?.[runv2.CLIENT_NAME_LABEL]);
|
|
78
|
+
if (services.length === 0) {
|
|
79
|
+
(0, utils_1.logBullet)("No Cloud Run services to update. Creating a new service instead.");
|
|
80
|
+
return undefined;
|
|
81
|
+
}
|
|
82
|
+
const choices = services.map((service) => {
|
|
83
|
+
const { serviceId, region } = parseServiceName(service.name);
|
|
84
|
+
return { name: `${serviceId} (${region})`, value: service };
|
|
85
|
+
});
|
|
86
|
+
return (0, prompt_1.select)({
|
|
87
|
+
message: "Which service would you like to update?",
|
|
88
|
+
choices,
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
function parseServiceName(name) {
|
|
92
|
+
const parts = name.split("/");
|
|
93
|
+
return { region: parts[3], serviceId: parts[5] };
|
|
94
|
+
}
|
|
95
|
+
async function promptNewServiceId(projectId, region) {
|
|
96
|
+
return (0, prompt_1.input)({
|
|
97
|
+
message: "Please enter a unique ID for your service",
|
|
98
|
+
validate: async (id) => {
|
|
99
|
+
if (!SERVICE_ID_REGEX.test(id)) {
|
|
100
|
+
return "Use up to 49 lowercase letters, digits, and hyphens, starting with a letter and not ending with a hyphen.";
|
|
101
|
+
}
|
|
102
|
+
const existing = await (0, util_1.getExistingService)(projectId, region, id);
|
|
103
|
+
if (existing) {
|
|
104
|
+
return `A service named ${id} already exists in ${region}.`;
|
|
105
|
+
}
|
|
106
|
+
return true;
|
|
107
|
+
},
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
async function promptRootDir(projectDir, defaultDir) {
|
|
111
|
+
return (0, prompt_1.input)({
|
|
112
|
+
message: "Specify your app's root directory relative to your firebase.json directory",
|
|
113
|
+
default: defaultDir,
|
|
114
|
+
validate: (dir) => {
|
|
115
|
+
const absPath = path.join(projectDir, dir);
|
|
116
|
+
if (!(0, fsutils_1.dirExistsSync)(absPath)) {
|
|
117
|
+
return `Directory ${absPath} does not exist. Please enter a valid directory.`;
|
|
118
|
+
}
|
|
119
|
+
return true;
|
|
120
|
+
},
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
async function actuate(setup, config, options) {
|
|
124
|
+
const info = setup.featureInfo?.run;
|
|
125
|
+
if (!info) {
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
128
|
+
const service = { serviceId: info.serviceId, rootDir: info.rootDir, region: info.region };
|
|
129
|
+
if (info.localBuild) {
|
|
130
|
+
upsertRunConfig({ ...service, localBuild: true }, config);
|
|
131
|
+
}
|
|
132
|
+
else {
|
|
133
|
+
upsertRunConfig(service, config);
|
|
134
|
+
}
|
|
135
|
+
await (0, deploy_1.deploy)(["run"], { ...options, projectId: setup.projectId, config, only: `run:${(0, util_1.fullServiceName)(info)}` }, { baseImage: info.baseImage || null });
|
|
136
|
+
}
|
|
137
|
+
function upsertRunConfig(service, config) {
|
|
138
|
+
const entries = getRunEntries(config);
|
|
139
|
+
const existing = findRunEntry(entries, service.serviceId, service.region);
|
|
140
|
+
if (existing) {
|
|
141
|
+
existing.rootDir = service.rootDir;
|
|
142
|
+
if (service.localBuild) {
|
|
143
|
+
existing.localBuild = true;
|
|
144
|
+
}
|
|
145
|
+
else {
|
|
146
|
+
delete existing.localBuild;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
else {
|
|
150
|
+
entries.push({ ...service, ignore: DEFAULT_IGNORE });
|
|
151
|
+
}
|
|
152
|
+
config.set("run", entries.length === 1 ? entries[0] : entries);
|
|
153
|
+
}
|
|
154
|
+
function getRunEntries(config) {
|
|
155
|
+
return [config.src.run ?? []].flat();
|
|
156
|
+
}
|
|
157
|
+
function findRunEntry(entries, serviceId, region) {
|
|
158
|
+
return entries.find((e) => e.serviceId === serviceId && e.region === region);
|
|
159
|
+
}
|
package/lib/init/index.js
CHANGED
|
@@ -80,6 +80,12 @@ const featuresList = [
|
|
|
80
80
|
askQuestions: features.agentSkillsAskQuestions,
|
|
81
81
|
actuate: features.agentSkillsActuate,
|
|
82
82
|
},
|
|
83
|
+
{
|
|
84
|
+
name: "run",
|
|
85
|
+
displayName: "Cloud Run",
|
|
86
|
+
askQuestions: features.runAskQuestions,
|
|
87
|
+
actuate: features.runActuate,
|
|
88
|
+
},
|
|
83
89
|
];
|
|
84
90
|
const featureMap = new Map(featuresList.map((feature) => [feature.name, feature]));
|
|
85
91
|
async function init(setup, config, options) {
|
package/lib/management/apps.js
CHANGED
|
@@ -169,14 +169,16 @@ async function sdkInit(appPlatform, options) {
|
|
|
169
169
|
}
|
|
170
170
|
async function getSdkOutputPath(appDir, platform, config) {
|
|
171
171
|
switch (platform) {
|
|
172
|
-
case AppPlatform.ANDROID:
|
|
172
|
+
case AppPlatform.ANDROID: {
|
|
173
173
|
const androidPath = await findIntelligentPathForAndroid(appDir, config);
|
|
174
174
|
return path.join(androidPath, "google-services.json");
|
|
175
|
+
}
|
|
175
176
|
case AppPlatform.WEB:
|
|
176
177
|
return path.join(appDir, "firebase-js-config.json");
|
|
177
|
-
case AppPlatform.IOS:
|
|
178
|
+
case AppPlatform.IOS: {
|
|
178
179
|
const iosPath = await findIntelligentPathForIOS(appDir, config);
|
|
179
180
|
return path.join(iosPath, "GoogleService-Info.plist");
|
|
181
|
+
}
|
|
180
182
|
}
|
|
181
183
|
throw new error_1.FirebaseError("Platform " + platform.toString() + " is not supported yet.");
|
|
182
184
|
}
|
|
@@ -28,9 +28,9 @@ function convertInputToValue(inputValue) {
|
|
|
28
28
|
return { arrayValue: arrayValue };
|
|
29
29
|
}
|
|
30
30
|
else if (typeof inputValue === "object") {
|
|
31
|
-
if (
|
|
31
|
+
if (Object.prototype.hasOwnProperty.call(inputValue, "latitude") &&
|
|
32
32
|
typeof inputValue.latitude === "number" &&
|
|
33
|
-
|
|
33
|
+
Object.prototype.hasOwnProperty.call(inputValue, "longitude") &&
|
|
34
34
|
typeof inputValue.longitude === "number") {
|
|
35
35
|
return { geoPointValue: inputValue };
|
|
36
36
|
}
|