firebase-tools 13.6.0 → 13.6.1
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/apphosting/config.js +31 -0
- package/lib/apphosting/githubConnections.js +261 -0
- package/lib/{init/features/apphosting → apphosting}/index.js +21 -17
- package/lib/{init/features/apphosting → apphosting}/repo.js +9 -9
- package/lib/apphosting/secrets/dialogs.js +169 -0
- package/lib/apphosting/secrets/index.js +98 -0
- package/lib/commands/apphosting-backends-create.js +4 -2
- package/lib/commands/apphosting-backends-delete.js +1 -1
- package/lib/commands/apphosting-secrets-describe.js +29 -0
- package/lib/commands/apphosting-secrets-grantaccess.js +45 -0
- package/lib/commands/apphosting-secrets-set.js +102 -0
- package/lib/commands/functions-secrets-access.js +2 -2
- package/lib/commands/functions-secrets-describe.js +14 -0
- package/lib/commands/functions-secrets-destroy.js +2 -2
- package/lib/commands/functions-secrets-get.js +3 -17
- package/lib/commands/functions-secrets-prune.js +2 -1
- package/lib/commands/functions-secrets-set.js +2 -2
- package/lib/commands/index.js +5 -0
- package/lib/deploy/functions/checkIam.js +3 -6
- package/lib/deploy/functions/containerCleaner.js +1 -11
- package/lib/deploy/functions/params.js +2 -2
- package/lib/deploy/functions/prepare.js +12 -3
- package/lib/deploy/functions/release/fabricator.js +5 -5
- package/lib/deploy/functions/runtimes/index.js +6 -43
- package/lib/deploy/functions/runtimes/node/index.js +3 -2
- package/lib/deploy/functions/runtimes/node/parseRuntimeAndValidateSDK.js +15 -34
- package/lib/deploy/functions/runtimes/python/index.js +11 -7
- package/lib/deploy/functions/runtimes/supported.js +135 -0
- package/lib/emulator/controller.js +8 -1
- package/lib/emulator/functionsEmulator.js +2 -2
- package/lib/emulator/hub.js +5 -0
- package/lib/extensions/emulator/specHelper.js +4 -3
- package/lib/functional.js +2 -2
- package/lib/functions/secrets.js +40 -22
- package/lib/gcp/apphosting.js +15 -2
- package/lib/gcp/cloudbuild.js +7 -3
- package/lib/gcp/cloudfunctions.js +5 -5
- package/lib/gcp/cloudfunctionsv2.js +3 -3
- package/lib/gcp/cloudscheduler.js +2 -2
- package/lib/gcp/computeEngine.js +7 -0
- package/lib/gcp/devConnect.js +24 -11
- package/lib/gcp/iam.js +9 -1
- package/lib/gcp/secretManager.js +53 -13
- package/lib/gcp/serviceusage.js +21 -5
- package/lib/init/features/functions/python.js +4 -3
- package/lib/init/features/index.js +1 -1
- package/package.json +1 -1
- package/schema/firebase-config.json +12 -2
- /package/lib/{init/features/apphosting → apphosting}/constants.js +0 -0
package/lib/gcp/devConnect.js
CHANGED
|
@@ -1,24 +1,32 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.serviceAgentEmail = exports.getGitRepositoryLink = exports.createGitRepositoryLink = exports.listAllLinkableGitRepositories = exports.listAllConnections = exports.getConnection = exports.createConnection = exports.client = void 0;
|
|
3
|
+
exports.generateP4SA = exports.serviceAgentEmail = exports.getGitRepositoryLink = exports.createGitRepositoryLink = exports.listAllLinkableGitRepositories = exports.listAllConnections = exports.getConnection = exports.deleteConnection = exports.createConnection = exports.client = void 0;
|
|
4
4
|
const apiv2_1 = require("../apiv2");
|
|
5
5
|
const api_1 = require("../api");
|
|
6
|
+
const serviceusage_1 = require("./serviceusage");
|
|
6
7
|
const PAGE_SIZE_MAX = 1000;
|
|
8
|
+
const LOCATION_OVERRIDE = process.env.FIREBASE_DEVELOPERCONNECT_LOCATION_OVERRIDE;
|
|
7
9
|
exports.client = new apiv2_1.Client({
|
|
8
10
|
urlPrefix: (0, api_1.developerConnectOrigin)(),
|
|
9
11
|
auth: true,
|
|
10
12
|
apiVersion: "v1",
|
|
11
13
|
});
|
|
12
|
-
async function createConnection(projectId, location, connectionId, githubConfig) {
|
|
14
|
+
async function createConnection(projectId, location, connectionId, githubConfig = {}) {
|
|
13
15
|
const config = Object.assign(Object.assign({}, githubConfig), { githubApp: "FIREBASE" });
|
|
14
|
-
const res = await exports.client.post(`projects/${projectId}/locations/${location}/connections`, {
|
|
16
|
+
const res = await exports.client.post(`projects/${projectId}/locations/${LOCATION_OVERRIDE !== null && LOCATION_OVERRIDE !== void 0 ? LOCATION_OVERRIDE : location}/connections`, {
|
|
15
17
|
githubConfig: config,
|
|
16
18
|
}, { queryParams: { connectionId } });
|
|
17
19
|
return res.body;
|
|
18
20
|
}
|
|
19
21
|
exports.createConnection = createConnection;
|
|
22
|
+
async function deleteConnection(projectId, location, connectionId) {
|
|
23
|
+
const name = `projects/${projectId}/locations/${LOCATION_OVERRIDE !== null && LOCATION_OVERRIDE !== void 0 ? LOCATION_OVERRIDE : location}/connections/${connectionId}`;
|
|
24
|
+
const res = await exports.client.delete(name, { queryParams: { force: "true" } });
|
|
25
|
+
return res.body;
|
|
26
|
+
}
|
|
27
|
+
exports.deleteConnection = deleteConnection;
|
|
20
28
|
async function getConnection(projectId, location, connectionId) {
|
|
21
|
-
const name = `projects/${projectId}/locations/${location}/connections/${connectionId}`;
|
|
29
|
+
const name = `projects/${projectId}/locations/${LOCATION_OVERRIDE !== null && LOCATION_OVERRIDE !== void 0 ? LOCATION_OVERRIDE : location}/connections/${connectionId}`;
|
|
22
30
|
const res = await exports.client.get(name);
|
|
23
31
|
return res.body;
|
|
24
32
|
}
|
|
@@ -26,7 +34,7 @@ exports.getConnection = getConnection;
|
|
|
26
34
|
async function listAllConnections(projectId, location) {
|
|
27
35
|
const conns = [];
|
|
28
36
|
const getNextPage = async (pageToken = "") => {
|
|
29
|
-
const res = await exports.client.get(`/projects/${projectId}/locations/${location}/connections`, {
|
|
37
|
+
const res = await exports.client.get(`/projects/${projectId}/locations/${LOCATION_OVERRIDE !== null && LOCATION_OVERRIDE !== void 0 ? LOCATION_OVERRIDE : location}/connections`, {
|
|
30
38
|
queryParams: {
|
|
31
39
|
pageSize: PAGE_SIZE_MAX,
|
|
32
40
|
pageToken,
|
|
@@ -44,17 +52,17 @@ async function listAllConnections(projectId, location) {
|
|
|
44
52
|
}
|
|
45
53
|
exports.listAllConnections = listAllConnections;
|
|
46
54
|
async function listAllLinkableGitRepositories(projectId, location, connectionId) {
|
|
47
|
-
const name = `projects/${projectId}/locations/${location}/connections/${connectionId}:
|
|
55
|
+
const name = `projects/${projectId}/locations/${LOCATION_OVERRIDE !== null && LOCATION_OVERRIDE !== void 0 ? LOCATION_OVERRIDE : location}/connections/${connectionId}:fetchLinkableGitRepositories`;
|
|
48
56
|
const repos = [];
|
|
49
57
|
const getNextPage = async (pageToken = "") => {
|
|
50
58
|
const res = await exports.client.get(name, {
|
|
51
59
|
queryParams: {
|
|
52
|
-
PAGE_SIZE_MAX,
|
|
60
|
+
pageSize: PAGE_SIZE_MAX,
|
|
53
61
|
pageToken,
|
|
54
62
|
},
|
|
55
63
|
});
|
|
56
|
-
if (Array.isArray(res.body.
|
|
57
|
-
repos.push(...res.body.
|
|
64
|
+
if (Array.isArray(res.body.linkableGitRepositories)) {
|
|
65
|
+
repos.push(...res.body.linkableGitRepositories);
|
|
58
66
|
}
|
|
59
67
|
if (res.body.nextPageToken) {
|
|
60
68
|
await getNextPage(res.body.nextPageToken);
|
|
@@ -65,12 +73,12 @@ async function listAllLinkableGitRepositories(projectId, location, connectionId)
|
|
|
65
73
|
}
|
|
66
74
|
exports.listAllLinkableGitRepositories = listAllLinkableGitRepositories;
|
|
67
75
|
async function createGitRepositoryLink(projectId, location, connectionId, gitRepositoryLinkId, cloneUri) {
|
|
68
|
-
const res = await exports.client.post(`projects/${projectId}/locations/${location}/connections/${connectionId}/gitRepositoryLinks`, { cloneUri }, { queryParams: { gitRepositoryLinkId } });
|
|
76
|
+
const res = await exports.client.post(`projects/${projectId}/locations/${LOCATION_OVERRIDE !== null && LOCATION_OVERRIDE !== void 0 ? LOCATION_OVERRIDE : location}/connections/${connectionId}/gitRepositoryLinks`, { cloneUri }, { queryParams: { gitRepositoryLinkId } });
|
|
69
77
|
return res.body;
|
|
70
78
|
}
|
|
71
79
|
exports.createGitRepositoryLink = createGitRepositoryLink;
|
|
72
80
|
async function getGitRepositoryLink(projectId, location, connectionId, gitRepositoryLinkId) {
|
|
73
|
-
const name = `projects/${projectId}/locations/${location}/connections/${connectionId}/gitRepositoryLinks/${gitRepositoryLinkId}`;
|
|
81
|
+
const name = `projects/${projectId}/locations/${LOCATION_OVERRIDE !== null && LOCATION_OVERRIDE !== void 0 ? LOCATION_OVERRIDE : location}/connections/${connectionId}/gitRepositoryLinks/${gitRepositoryLinkId}`;
|
|
74
82
|
const res = await exports.client.get(name);
|
|
75
83
|
return res.body;
|
|
76
84
|
}
|
|
@@ -79,3 +87,8 @@ function serviceAgentEmail(projectNumber) {
|
|
|
79
87
|
return `service-${projectNumber}@${(0, api_1.developerConnectP4SAOrigin)()}`;
|
|
80
88
|
}
|
|
81
89
|
exports.serviceAgentEmail = serviceAgentEmail;
|
|
90
|
+
async function generateP4SA(projectNumber) {
|
|
91
|
+
const devConnectOrigin = (0, api_1.developerConnectOrigin)();
|
|
92
|
+
await (0, serviceusage_1.generateServiceIdentityAndPoll)(projectNumber, new URL(devConnectOrigin).hostname, "apphosting");
|
|
93
|
+
}
|
|
94
|
+
exports.generateP4SA = generateP4SA;
|
package/lib/gcp/iam.js
CHANGED
|
@@ -1,10 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.testIamPermissions = exports.testResourceIamPermissions = exports.getRole = exports.listServiceAccountKeys = exports.deleteServiceAccount = exports.createServiceAccountKey = exports.getServiceAccount = exports.createServiceAccount = void 0;
|
|
3
|
+
exports.testIamPermissions = exports.testResourceIamPermissions = exports.getRole = exports.listServiceAccountKeys = exports.deleteServiceAccount = exports.createServiceAccountKey = exports.getServiceAccount = exports.createServiceAccount = exports.getDefaultComputeEngineServiceAgent = exports.getDefaultCloudBuildServiceAgent = void 0;
|
|
4
4
|
const api_1 = require("../api");
|
|
5
5
|
const logger_1 = require("../logger");
|
|
6
6
|
const apiv2_1 = require("../apiv2");
|
|
7
7
|
const apiClient = new apiv2_1.Client({ urlPrefix: (0, api_1.iamOrigin)(), apiVersion: "v1" });
|
|
8
|
+
function getDefaultCloudBuildServiceAgent(projectNumber) {
|
|
9
|
+
return `${projectNumber}@cloudbuild.gserviceaccount.com`;
|
|
10
|
+
}
|
|
11
|
+
exports.getDefaultCloudBuildServiceAgent = getDefaultCloudBuildServiceAgent;
|
|
12
|
+
function getDefaultComputeEngineServiceAgent(projectNumber) {
|
|
13
|
+
return `${projectNumber}-compute@developer.gserviceaccount.com`;
|
|
14
|
+
}
|
|
15
|
+
exports.getDefaultComputeEngineServiceAgent = getDefaultComputeEngineServiceAgent;
|
|
8
16
|
async function createServiceAccount(projectId, accountId, description, displayName) {
|
|
9
17
|
const response = await apiClient.post(`/projects/${projectId}/serviceAccounts`, {
|
|
10
18
|
accountId,
|
package/lib/gcp/secretManager.js
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ensureServiceAgentRole = exports.setIamPolicy = exports.getIamPolicy = exports.addVersion = exports.deleteSecret = exports.patchSecret = exports.createSecret = exports.toSecretVersionResourceName = exports.parseSecretVersionResourceName = exports.parseSecretResourceName = exports.secretExists = exports.destroySecretVersion = exports.accessSecretVersion = exports.getSecretVersion = exports.listSecretVersions = exports.getSecretMetadata = exports.listSecrets = exports.getSecret = exports.secretManagerConsoleUri = void 0;
|
|
3
|
+
exports.labels = exports.ensureApi = exports.isAppHostingManaged = exports.isFunctionsManaged = exports.FIREBASE_MANAGED = exports.ensureServiceAgentRole = exports.setIamPolicy = exports.getIamPolicy = exports.addVersion = exports.deleteSecret = exports.patchSecret = exports.createSecret = exports.toSecretVersionResourceName = exports.parseSecretVersionResourceName = exports.parseSecretResourceName = exports.secretExists = exports.destroySecretVersion = exports.accessSecretVersion = exports.getSecretVersion = exports.listSecretVersions = exports.getSecretMetadata = exports.listSecrets = exports.getSecret = exports.secretManagerConsoleUri = void 0;
|
|
4
4
|
const utils_1 = require("../utils");
|
|
5
5
|
const error_1 = require("../error");
|
|
6
6
|
const apiv2_1 = require("../apiv2");
|
|
7
7
|
const api_1 = require("../api");
|
|
8
|
+
const ensureApiEnabled = require("../ensureApiEnabled");
|
|
9
|
+
const projectUtils_1 = require("../projectUtils");
|
|
8
10
|
const SECRET_NAME_REGEX = new RegExp("projects\\/" +
|
|
9
11
|
"(?<project>(?:\\d+)|(?:[A-Za-z]+[A-Za-z\\d-]*[A-Za-z\\d]?))\\/" +
|
|
10
12
|
"secrets\\/" +
|
|
@@ -15,15 +17,16 @@ exports.secretManagerConsoleUri = secretManagerConsoleUri;
|
|
|
15
17
|
const API_VERSION = "v1";
|
|
16
18
|
const client = new apiv2_1.Client({ urlPrefix: (0, api_1.secretManagerOrigin)(), apiVersion: API_VERSION });
|
|
17
19
|
async function getSecret(projectId, name) {
|
|
18
|
-
var _a;
|
|
20
|
+
var _a, _b;
|
|
19
21
|
const getRes = await client.get(`projects/${projectId}/secrets/${name}`);
|
|
20
22
|
const secret = parseSecretResourceName(getRes.body.name);
|
|
21
23
|
secret.labels = (_a = getRes.body.labels) !== null && _a !== void 0 ? _a : {};
|
|
24
|
+
secret.replication = (_b = getRes.body.replication) !== null && _b !== void 0 ? _b : {};
|
|
22
25
|
return secret;
|
|
23
26
|
}
|
|
24
27
|
exports.getSecret = getSecret;
|
|
25
28
|
async function listSecrets(projectId, filter) {
|
|
26
|
-
var _a;
|
|
29
|
+
var _a, _b;
|
|
27
30
|
const secrets = [];
|
|
28
31
|
const path = `projects/${projectId}/secrets`;
|
|
29
32
|
const baseOpts = filter ? { queryParams: { filter } } : {};
|
|
@@ -34,7 +37,7 @@ async function listSecrets(projectId, filter) {
|
|
|
34
37
|
: Object.assign(Object.assign({}, baseOpts), { queryParams: Object.assign(Object.assign({}, baseOpts === null || baseOpts === void 0 ? void 0 : baseOpts.queryParams), { pageToken }) });
|
|
35
38
|
const res = await client.get(path, opts);
|
|
36
39
|
for (const s of res.body.secrets || []) {
|
|
37
|
-
secrets.push(Object.assign(Object.assign({}, parseSecretResourceName(s.name)), { labels: (_a = s.labels) !== null && _a !== void 0 ? _a : {} }));
|
|
40
|
+
secrets.push(Object.assign(Object.assign({}, parseSecretResourceName(s.name)), { labels: (_a = s.labels) !== null && _a !== void 0 ? _a : {}, replication: (_b = s.replication) !== null && _b !== void 0 ? _b : {} }));
|
|
38
41
|
}
|
|
39
42
|
if (!res.body.nextPageToken) {
|
|
40
43
|
break;
|
|
@@ -69,7 +72,7 @@ async function listSecretVersions(projectId, name, filter) {
|
|
|
69
72
|
: Object.assign(Object.assign({}, baseOpts), { queryParams: Object.assign(Object.assign({}, baseOpts === null || baseOpts === void 0 ? void 0 : baseOpts.queryParams), { pageToken }) });
|
|
70
73
|
const res = await client.get(path, opts);
|
|
71
74
|
for (const s of res.body.versions || []) {
|
|
72
|
-
secrets.push(Object.assign(Object.assign({}, parseSecretVersionResourceName(s.name)), { state: s.state }));
|
|
75
|
+
secrets.push(Object.assign(Object.assign({}, parseSecretVersionResourceName(s.name)), { state: s.state, createTime: s.createTime }));
|
|
73
76
|
}
|
|
74
77
|
if (!res.body.nextPageToken) {
|
|
75
78
|
break;
|
|
@@ -81,7 +84,7 @@ async function listSecretVersions(projectId, name, filter) {
|
|
|
81
84
|
exports.listSecretVersions = listSecretVersions;
|
|
82
85
|
async function getSecretVersion(projectId, name, version) {
|
|
83
86
|
const getRes = await client.get(`projects/${projectId}/secrets/${name}/versions/${version}`);
|
|
84
|
-
return Object.assign(Object.assign({}, parseSecretVersionResourceName(getRes.body.name)), { state: getRes.body.state });
|
|
87
|
+
return Object.assign(Object.assign({}, parseSecretVersionResourceName(getRes.body.name)), { state: getRes.body.state, createTime: getRes.body.createTime });
|
|
85
88
|
}
|
|
86
89
|
exports.getSecretVersion = getSecretVersion;
|
|
87
90
|
async function accessSecretVersion(projectId, name, version) {
|
|
@@ -118,6 +121,8 @@ function parseSecretResourceName(resourceName) {
|
|
|
118
121
|
return {
|
|
119
122
|
projectId: match.groups.project,
|
|
120
123
|
name: match.groups.secret,
|
|
124
|
+
labels: {},
|
|
125
|
+
replication: {},
|
|
121
126
|
};
|
|
122
127
|
}
|
|
123
128
|
exports.parseSecretResourceName = parseSecretResourceName;
|
|
@@ -130,8 +135,11 @@ function parseSecretVersionResourceName(resourceName) {
|
|
|
130
135
|
secret: {
|
|
131
136
|
projectId: match.groups.project,
|
|
132
137
|
name: match.groups.secret,
|
|
138
|
+
labels: {},
|
|
139
|
+
replication: {},
|
|
133
140
|
},
|
|
134
141
|
versionId: match.groups.version,
|
|
142
|
+
createTime: "",
|
|
135
143
|
};
|
|
136
144
|
}
|
|
137
145
|
exports.parseSecretVersionResourceName = parseSecretVersionResourceName;
|
|
@@ -139,21 +147,35 @@ function toSecretVersionResourceName(secretVersion) {
|
|
|
139
147
|
return `projects/${secretVersion.secret.projectId}/secrets/${secretVersion.secret.name}/versions/${secretVersion.versionId}`;
|
|
140
148
|
}
|
|
141
149
|
exports.toSecretVersionResourceName = toSecretVersionResourceName;
|
|
142
|
-
async function createSecret(projectId, name, labels) {
|
|
150
|
+
async function createSecret(projectId, name, labels, location) {
|
|
151
|
+
let replication;
|
|
152
|
+
if (location) {
|
|
153
|
+
replication = {
|
|
154
|
+
userManaged: {
|
|
155
|
+
replicas: [
|
|
156
|
+
{
|
|
157
|
+
location,
|
|
158
|
+
},
|
|
159
|
+
],
|
|
160
|
+
},
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
else {
|
|
164
|
+
replication = { automatic: {} };
|
|
165
|
+
}
|
|
143
166
|
const createRes = await client.post(`projects/${projectId}/secrets`, {
|
|
144
167
|
name,
|
|
145
|
-
replication
|
|
146
|
-
automatic: {},
|
|
147
|
-
},
|
|
168
|
+
replication,
|
|
148
169
|
labels,
|
|
149
170
|
}, { queryParams: { secretId: name } });
|
|
150
|
-
return Object.assign(Object.assign({}, parseSecretResourceName(createRes.body.name)), { labels
|
|
171
|
+
return Object.assign(Object.assign({}, parseSecretResourceName(createRes.body.name)), { labels,
|
|
172
|
+
replication });
|
|
151
173
|
}
|
|
152
174
|
exports.createSecret = createSecret;
|
|
153
175
|
async function patchSecret(projectId, name, labels) {
|
|
154
176
|
const fullName = `projects/${projectId}/secrets/${name}`;
|
|
155
177
|
const res = await client.patch(fullName, { name: fullName, labels }, { queryParams: { updateMask: "labels" } });
|
|
156
|
-
return parseSecretResourceName(res.body.name);
|
|
178
|
+
return Object.assign(Object.assign({}, parseSecretResourceName(res.body.name)), { labels: res.body.labels, replication: res.body.replication });
|
|
157
179
|
}
|
|
158
180
|
exports.patchSecret = patchSecret;
|
|
159
181
|
async function deleteSecret(projectId, name) {
|
|
@@ -167,7 +189,7 @@ async function addVersion(projectId, name, payloadData) {
|
|
|
167
189
|
data: Buffer.from(payloadData).toString("base64"),
|
|
168
190
|
},
|
|
169
191
|
});
|
|
170
|
-
return Object.assign(Object.assign({}, parseSecretVersionResourceName(res.body.name)), { state: res.body.state });
|
|
192
|
+
return Object.assign(Object.assign({}, parseSecretVersionResourceName(res.body.name)), { state: res.body.state, createTime: "" });
|
|
171
193
|
}
|
|
172
194
|
exports.addVersion = addVersion;
|
|
173
195
|
async function getIamPolicy(secret) {
|
|
@@ -205,3 +227,21 @@ async function ensureServiceAgentRole(secret, serviceAccountEmails, role) {
|
|
|
205
227
|
(0, utils_1.logLabeledSuccess)("secretmanager", `Granted ${role} on projects/${secret.projectId}/secrets/${secret.name} to ${serviceAccountEmails.join(", ")}`);
|
|
206
228
|
}
|
|
207
229
|
exports.ensureServiceAgentRole = ensureServiceAgentRole;
|
|
230
|
+
exports.FIREBASE_MANAGED = "firebase-managed";
|
|
231
|
+
function isFunctionsManaged(secret) {
|
|
232
|
+
return (secret.labels[exports.FIREBASE_MANAGED] === "true" || secret.labels[exports.FIREBASE_MANAGED] === "functions");
|
|
233
|
+
}
|
|
234
|
+
exports.isFunctionsManaged = isFunctionsManaged;
|
|
235
|
+
function isAppHostingManaged(secret) {
|
|
236
|
+
return secret.labels[exports.FIREBASE_MANAGED] === "apphosting";
|
|
237
|
+
}
|
|
238
|
+
exports.isAppHostingManaged = isAppHostingManaged;
|
|
239
|
+
function ensureApi(options) {
|
|
240
|
+
const projectId = (0, projectUtils_1.needProjectId)(options);
|
|
241
|
+
return ensureApiEnabled.ensure(projectId, (0, api_1.secretManagerOrigin)(), "secretmanager", true);
|
|
242
|
+
}
|
|
243
|
+
exports.ensureApi = ensureApi;
|
|
244
|
+
function labels(product = "functions") {
|
|
245
|
+
return { [exports.FIREBASE_MANAGED]: product };
|
|
246
|
+
}
|
|
247
|
+
exports.labels = labels;
|
package/lib/gcp/serviceusage.js
CHANGED
|
@@ -1,19 +1,27 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.generateServiceIdentity = void 0;
|
|
3
|
+
exports.generateServiceIdentityAndPoll = exports.generateServiceIdentity = exports.apiClient = void 0;
|
|
4
4
|
const colorette_1 = require("colorette");
|
|
5
5
|
const api_1 = require("../api");
|
|
6
6
|
const apiv2_1 = require("../apiv2");
|
|
7
7
|
const error_1 = require("../error");
|
|
8
8
|
const utils = require("../utils");
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
const poller = require("../operation-poller");
|
|
10
|
+
const API_VERSION = "v1beta1";
|
|
11
|
+
const SERVICE_USAGE_ORIGIN = (0, api_1.serviceUsageOrigin)();
|
|
12
|
+
exports.apiClient = new apiv2_1.Client({
|
|
13
|
+
urlPrefix: SERVICE_USAGE_ORIGIN,
|
|
14
|
+
apiVersion: API_VERSION,
|
|
12
15
|
});
|
|
16
|
+
const serviceUsagePollerOptions = {
|
|
17
|
+
apiOrigin: SERVICE_USAGE_ORIGIN,
|
|
18
|
+
apiVersion: API_VERSION,
|
|
19
|
+
};
|
|
13
20
|
async function generateServiceIdentity(projectNumber, service, prefix) {
|
|
14
21
|
utils.logLabeledBullet(prefix, `generating the service identity for ${(0, colorette_1.bold)(service)}...`);
|
|
15
22
|
try {
|
|
16
|
-
|
|
23
|
+
const res = await exports.apiClient.post(`projects/${projectNumber}/services/${service}:generateServiceIdentity`);
|
|
24
|
+
return res.body;
|
|
17
25
|
}
|
|
18
26
|
catch (err) {
|
|
19
27
|
throw new error_1.FirebaseError(`Error generating the service identity for ${service}.`, {
|
|
@@ -22,3 +30,11 @@ async function generateServiceIdentity(projectNumber, service, prefix) {
|
|
|
22
30
|
}
|
|
23
31
|
}
|
|
24
32
|
exports.generateServiceIdentity = generateServiceIdentity;
|
|
33
|
+
async function generateServiceIdentityAndPoll(projectNumber, service, prefix) {
|
|
34
|
+
const op = await generateServiceIdentity(projectNumber, service, prefix);
|
|
35
|
+
if (op.done) {
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
await poller.pollOperation(Object.assign(Object.assign({}, serviceUsagePollerOptions), { operationResourceName: op.name }));
|
|
39
|
+
}
|
|
40
|
+
exports.generateServiceIdentityAndPoll = generateServiceIdentityAndPoll;
|
|
@@ -7,6 +7,7 @@ const path = require("path");
|
|
|
7
7
|
const python_1 = require("../../../deploy/functions/runtimes/python");
|
|
8
8
|
const python_2 = require("../../../functions/python");
|
|
9
9
|
const prompt_1 = require("../../../prompt");
|
|
10
|
+
const supported_1 = require("../../../deploy/functions/runtimes/supported");
|
|
10
11
|
const TEMPLATE_ROOT = path.resolve(__dirname, "../../../../templates/init/functions/python");
|
|
11
12
|
const MAIN_TEMPLATE = fs.readFileSync(path.join(TEMPLATE_ROOT, "main.py"), "utf8");
|
|
12
13
|
const REQUIREMENTS_TEMPLATE = fs.readFileSync(path.join(TEMPLATE_ROOT, "requirements.txt"), "utf8");
|
|
@@ -15,9 +16,9 @@ async function setup(setup, config) {
|
|
|
15
16
|
await config.askWriteProjectFile(`${setup.functions.source}/requirements.txt`, REQUIREMENTS_TEMPLATE);
|
|
16
17
|
await config.askWriteProjectFile(`${setup.functions.source}/.gitignore`, GITIGNORE_TEMPLATE);
|
|
17
18
|
await config.askWriteProjectFile(`${setup.functions.source}/main.py`, MAIN_TEMPLATE);
|
|
18
|
-
config.set("functions.runtime",
|
|
19
|
+
config.set("functions.runtime", (0, supported_1.latest)("python"));
|
|
19
20
|
config.set("functions.ignore", ["venv", "__pycache__"]);
|
|
20
|
-
const venvProcess = spawn((0, python_1.getPythonBinary)(
|
|
21
|
+
const venvProcess = spawn((0, python_1.getPythonBinary)((0, supported_1.latest)("python")), ["-m", "venv", "venv"], {
|
|
21
22
|
shell: true,
|
|
22
23
|
cwd: config.path(setup.functions.source),
|
|
23
24
|
stdio: ["pipe", "pipe", "pipe", "pipe"],
|
|
@@ -38,7 +39,7 @@ async function setup(setup, config) {
|
|
|
38
39
|
upgradeProcess.on("exit", resolve);
|
|
39
40
|
upgradeProcess.on("error", reject);
|
|
40
41
|
});
|
|
41
|
-
const installProcess = (0, python_2.runWithVirtualEnv)([(0, python_1.getPythonBinary)(
|
|
42
|
+
const installProcess = (0, python_2.runWithVirtualEnv)([(0, python_1.getPythonBinary)((0, supported_1.latest)("python")), "-m", "pip", "install", "-r", "requirements.txt"], config.path(setup.functions.source), {}, { stdio: ["inherit", "inherit", "inherit"] });
|
|
42
43
|
await new Promise((resolve, reject) => {
|
|
43
44
|
installProcess.on("exit", resolve);
|
|
44
45
|
installProcess.on("error", reject);
|
|
@@ -23,5 +23,5 @@ var remoteconfig_1 = require("./remoteconfig");
|
|
|
23
23
|
Object.defineProperty(exports, "remoteconfig", { enumerable: true, get: function () { return remoteconfig_1.doSetup; } });
|
|
24
24
|
var github_1 = require("./hosting/github");
|
|
25
25
|
Object.defineProperty(exports, "hostingGithub", { enumerable: true, get: function () { return github_1.initGitHub; } });
|
|
26
|
-
var apphosting_1 = require("
|
|
26
|
+
var apphosting_1 = require("../../apphosting");
|
|
27
27
|
Object.defineProperty(exports, "apphosting", { enumerable: true, get: function () { return apphosting_1.doSetup; } });
|
package/package.json
CHANGED
|
@@ -622,7 +622,12 @@
|
|
|
622
622
|
"nodejs14",
|
|
623
623
|
"nodejs16",
|
|
624
624
|
"nodejs18",
|
|
625
|
-
"nodejs20"
|
|
625
|
+
"nodejs20",
|
|
626
|
+
"nodejs6",
|
|
627
|
+
"nodejs8",
|
|
628
|
+
"python310",
|
|
629
|
+
"python311",
|
|
630
|
+
"python312"
|
|
626
631
|
],
|
|
627
632
|
"type": "string"
|
|
628
633
|
},
|
|
@@ -678,7 +683,12 @@
|
|
|
678
683
|
"nodejs14",
|
|
679
684
|
"nodejs16",
|
|
680
685
|
"nodejs18",
|
|
681
|
-
"nodejs20"
|
|
686
|
+
"nodejs20",
|
|
687
|
+
"nodejs6",
|
|
688
|
+
"nodejs8",
|
|
689
|
+
"python310",
|
|
690
|
+
"python311",
|
|
691
|
+
"python312"
|
|
682
692
|
],
|
|
683
693
|
"type": "string"
|
|
684
694
|
},
|
|
File without changes
|