firebase-tools 13.5.2 → 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/accountExporter.js +1 -1
- package/lib/accountImporter.js +1 -1
- package/lib/api.js +112 -58
- package/lib/apiv2.js +3 -1
- package/lib/appdistribution/client.js +4 -4
- package/lib/apphosting/config.js +31 -0
- package/lib/apphosting/githubConnections.js +261 -0
- package/lib/{init/features/apphosting → apphosting}/index.js +26 -22
- package/lib/{init/features/apphosting → apphosting}/repo.js +25 -13
- package/lib/apphosting/secrets/dialogs.js +169 -0
- package/lib/apphosting/secrets/index.js +98 -0
- package/lib/auth.js +17 -17
- 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/hosting-disable.js +1 -1
- package/lib/commands/index.js +5 -0
- package/lib/commands/open.js +1 -1
- package/lib/database/metadata.js +3 -3
- package/lib/defaultCredentials.js +2 -2
- package/lib/deploy/extensions/v2FunctionHelper.js +1 -1
- package/lib/deploy/functions/build.js +1 -1
- package/lib/deploy/functions/checkIam.js +3 -6
- package/lib/deploy/functions/containerCleaner.js +5 -15
- package/lib/deploy/functions/deploy.js +8 -2
- package/lib/deploy/functions/ensure.js +1 -1
- package/lib/deploy/functions/params.js +2 -2
- package/lib/deploy/functions/prepare.js +16 -7
- package/lib/deploy/functions/release/fabricator.js +8 -8
- package/lib/deploy/functions/runtimes/discovery/index.js +2 -2
- 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/node/parseTriggers.js +2 -2
- package/lib/deploy/functions/runtimes/python/index.js +11 -7
- package/lib/deploy/functions/runtimes/supported.js +135 -0
- package/lib/deploy/hosting/uploader.js +1 -1
- package/lib/deploy/index.js +1 -1
- package/lib/deploy/remoteconfig/functions.js +1 -1
- package/lib/emulator/adminSdkConfig.js +1 -1
- package/lib/emulator/controller.js +8 -1
- package/lib/emulator/downloadableEmulators.js +6 -6
- package/lib/emulator/functionsEmulator.js +2 -2
- package/lib/emulator/hub.js +5 -0
- package/lib/ensureApiEnabled.js +1 -1
- package/lib/extensions/emulator/specHelper.js +4 -3
- package/lib/extensions/extensionsApi.js +5 -5
- package/lib/extensions/extensionsHelper.js +4 -4
- package/lib/extensions/provisioningHelper.js +2 -2
- package/lib/extensions/publishHelpers.js +1 -1
- package/lib/extensions/publisherApi.js +3 -3
- package/lib/extensions/resolveSource.js +1 -1
- package/lib/extensions/secretsUtils.js +1 -1
- package/lib/extensions/tos.js +1 -1
- package/lib/fetchMOTD.js +1 -1
- package/lib/fetchWebSetup.js +2 -2
- package/lib/firestore/api-sort.js +17 -0
- package/lib/firestore/api.js +9 -2
- package/lib/firestore/checkDatabaseType.js +1 -1
- package/lib/firestore/delete.js +1 -1
- package/lib/firestore/pretty-print.js +11 -2
- package/lib/functional.js +2 -2
- package/lib/functions/secrets.js +42 -24
- package/lib/functionsConfig.js +1 -1
- package/lib/gcp/apphosting.js +17 -4
- package/lib/gcp/artifactregistry.js +1 -1
- package/lib/gcp/auth.js +1 -1
- package/lib/gcp/cloudbilling.js +1 -1
- package/lib/gcp/cloudbuild.js +8 -4
- package/lib/gcp/cloudfunctions.js +6 -6
- package/lib/gcp/cloudfunctionsv2.js +4 -4
- package/lib/gcp/cloudlogging.js +1 -1
- package/lib/gcp/cloudmonitoring.js +1 -1
- package/lib/gcp/cloudscheduler.js +3 -3
- package/lib/gcp/cloudtasks.js +1 -1
- package/lib/gcp/computeEngine.js +7 -0
- package/lib/gcp/devConnect.js +45 -22
- package/lib/gcp/eventarc.js +1 -1
- package/lib/gcp/firestore.js +2 -2
- package/lib/gcp/iam.js +11 -3
- package/lib/gcp/identityPlatform.js +1 -1
- package/lib/gcp/pubsub.js +1 -1
- package/lib/gcp/resourceManager.js +2 -1
- package/lib/gcp/rules.js +1 -1
- package/lib/gcp/run.js +1 -1
- package/lib/gcp/runtimeconfig.js +1 -1
- package/lib/gcp/secretManager.js +54 -14
- package/lib/gcp/serviceusage.js +21 -5
- package/lib/gcp/storage.js +12 -8
- package/lib/hosting/api.js +2 -2
- package/lib/hosting/cloudRunProxy.js +1 -1
- package/lib/init/features/database.js +1 -1
- package/lib/init/features/extensions/index.js +1 -1
- package/lib/init/features/functions/index.js +2 -2
- package/lib/init/features/functions/python.js +4 -3
- package/lib/init/features/hosting/github.js +4 -3
- package/lib/init/features/index.js +1 -1
- package/lib/management/apps.js +4 -4
- package/lib/management/database.js +1 -1
- package/lib/management/projects.js +4 -4
- package/lib/remoteconfig/get.js +1 -1
- package/lib/remoteconfig/rollback.js +1 -1
- package/lib/remoteconfig/versionslist.js +1 -1
- package/lib/shortenUrl.js +2 -2
- package/lib/utils.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,32 +1,40 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.serviceAgentEmail = exports.getGitRepositoryLink = exports.createGitRepositoryLink = exports.
|
|
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
|
|
6
|
+
const serviceusage_1 = require("./serviceusage");
|
|
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
|
-
urlPrefix: api_1.developerConnectOrigin,
|
|
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
|
}
|
|
25
33
|
exports.getConnection = getConnection;
|
|
26
|
-
async function
|
|
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,
|
|
@@ -42,30 +50,45 @@ async function listConnections(projectId, location) {
|
|
|
42
50
|
await getNextPage();
|
|
43
51
|
return conns;
|
|
44
52
|
}
|
|
45
|
-
exports.
|
|
46
|
-
async function
|
|
47
|
-
const name = `projects/${projectId}/locations/${location}/connections/${connectionId}:
|
|
48
|
-
const
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
53
|
+
exports.listAllConnections = listAllConnections;
|
|
54
|
+
async function listAllLinkableGitRepositories(projectId, location, connectionId) {
|
|
55
|
+
const name = `projects/${projectId}/locations/${LOCATION_OVERRIDE !== null && LOCATION_OVERRIDE !== void 0 ? LOCATION_OVERRIDE : location}/connections/${connectionId}:fetchLinkableGitRepositories`;
|
|
56
|
+
const repos = [];
|
|
57
|
+
const getNextPage = async (pageToken = "") => {
|
|
58
|
+
const res = await exports.client.get(name, {
|
|
59
|
+
queryParams: {
|
|
60
|
+
pageSize: PAGE_SIZE_MAX,
|
|
61
|
+
pageToken,
|
|
62
|
+
},
|
|
63
|
+
});
|
|
64
|
+
if (Array.isArray(res.body.linkableGitRepositories)) {
|
|
65
|
+
repos.push(...res.body.linkableGitRepositories);
|
|
66
|
+
}
|
|
67
|
+
if (res.body.nextPageToken) {
|
|
68
|
+
await getNextPage(res.body.nextPageToken);
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
await getNextPage();
|
|
72
|
+
return repos;
|
|
55
73
|
}
|
|
56
|
-
exports.
|
|
74
|
+
exports.listAllLinkableGitRepositories = listAllLinkableGitRepositories;
|
|
57
75
|
async function createGitRepositoryLink(projectId, location, connectionId, gitRepositoryLinkId, cloneUri) {
|
|
58
|
-
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 } });
|
|
59
77
|
return res.body;
|
|
60
78
|
}
|
|
61
79
|
exports.createGitRepositoryLink = createGitRepositoryLink;
|
|
62
80
|
async function getGitRepositoryLink(projectId, location, connectionId, gitRepositoryLinkId) {
|
|
63
|
-
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}`;
|
|
64
82
|
const res = await exports.client.get(name);
|
|
65
83
|
return res.body;
|
|
66
84
|
}
|
|
67
85
|
exports.getGitRepositoryLink = getGitRepositoryLink;
|
|
68
86
|
function serviceAgentEmail(projectNumber) {
|
|
69
|
-
return `service-${projectNumber}@${api_1.developerConnectP4SAOrigin}`;
|
|
87
|
+
return `service-${projectNumber}@${(0, api_1.developerConnectP4SAOrigin)()}`;
|
|
70
88
|
}
|
|
71
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/eventarc.js
CHANGED
|
@@ -7,7 +7,7 @@ const lodash_1 = require("lodash");
|
|
|
7
7
|
const proto_1 = require("./proto");
|
|
8
8
|
exports.API_VERSION = "v1";
|
|
9
9
|
const client = new apiv2_1.Client({
|
|
10
|
-
urlPrefix: api_1.eventarcOrigin,
|
|
10
|
+
urlPrefix: (0, api_1.eventarcOrigin)(),
|
|
11
11
|
auth: true,
|
|
12
12
|
apiVersion: exports.API_VERSION,
|
|
13
13
|
});
|
package/lib/gcp/firestore.js
CHANGED
|
@@ -9,12 +9,12 @@ const error_1 = require("../error");
|
|
|
9
9
|
const prodOnlyClient = new apiv2_1.Client({
|
|
10
10
|
auth: true,
|
|
11
11
|
apiVersion: "v1",
|
|
12
|
-
urlPrefix: api_1.firestoreOrigin,
|
|
12
|
+
urlPrefix: (0, api_1.firestoreOrigin)(),
|
|
13
13
|
});
|
|
14
14
|
const emuOrProdClient = new apiv2_1.Client({
|
|
15
15
|
auth: true,
|
|
16
16
|
apiVersion: "v1",
|
|
17
|
-
urlPrefix: api_1.firestoreOriginOrEmulator,
|
|
17
|
+
urlPrefix: (0, api_1.firestoreOriginOrEmulator)(),
|
|
18
18
|
});
|
|
19
19
|
var DayOfWeek;
|
|
20
20
|
(function (DayOfWeek) {
|
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
|
-
const apiClient = new apiv2_1.Client({ urlPrefix: api_1.iamOrigin, apiVersion: "v1" });
|
|
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,
|
|
@@ -71,6 +79,6 @@ async function testResourceIamPermissions(origin, apiVersion, resourceName, perm
|
|
|
71
79
|
}
|
|
72
80
|
exports.testResourceIamPermissions = testResourceIamPermissions;
|
|
73
81
|
async function testIamPermissions(projectId, permissions) {
|
|
74
|
-
return testResourceIamPermissions(api_1.resourceManagerOrigin, "v1", `projects/${projectId}`, permissions, `projects/${projectId}`);
|
|
82
|
+
return testResourceIamPermissions((0, api_1.resourceManagerOrigin)(), "v1", `projects/${projectId}`, permissions, `projects/${projectId}`);
|
|
75
83
|
}
|
|
76
84
|
exports.testIamPermissions = testIamPermissions;
|
|
@@ -6,7 +6,7 @@ const api_1 = require("../api");
|
|
|
6
6
|
const apiv2_1 = require("../apiv2");
|
|
7
7
|
const API_VERSION = "v2";
|
|
8
8
|
const adminApiClient = new apiv2_1.Client({
|
|
9
|
-
urlPrefix: api_1.identityOrigin + "/admin",
|
|
9
|
+
urlPrefix: (0, api_1.identityOrigin)() + "/admin",
|
|
10
10
|
apiVersion: API_VERSION,
|
|
11
11
|
});
|
|
12
12
|
async function getBlockingFunctionsConfig(project) {
|
package/lib/gcp/pubsub.js
CHANGED
|
@@ -6,13 +6,14 @@ const api_1 = require("../api");
|
|
|
6
6
|
const apiv2_1 = require("../apiv2");
|
|
7
7
|
const iam_1 = require("./iam");
|
|
8
8
|
const API_VERSION = "v1";
|
|
9
|
-
const apiClient = new apiv2_1.Client({ urlPrefix: api_1.resourceManagerOrigin, apiVersion: API_VERSION });
|
|
9
|
+
const apiClient = new apiv2_1.Client({ urlPrefix: (0, api_1.resourceManagerOrigin)(), apiVersion: API_VERSION });
|
|
10
10
|
exports.firebaseRoles = {
|
|
11
11
|
apiKeysViewer: "roles/serviceusage.apiKeysViewer",
|
|
12
12
|
authAdmin: "roles/firebaseauth.admin",
|
|
13
13
|
functionsDeveloper: "roles/cloudfunctions.developer",
|
|
14
14
|
hostingAdmin: "roles/firebasehosting.admin",
|
|
15
15
|
runViewer: "roles/run.viewer",
|
|
16
|
+
serviceUsageConsumer: "roles/serviceusage.serviceUsageConsumer",
|
|
16
17
|
};
|
|
17
18
|
async function getIamPolicy(projectIdOrNumber) {
|
|
18
19
|
const response = await apiClient.post(`/projects/${projectIdOrNumber}:getIamPolicy`);
|
package/lib/gcp/rules.js
CHANGED
|
@@ -6,7 +6,7 @@ const apiv2_1 = require("../apiv2");
|
|
|
6
6
|
const logger_1 = require("../logger");
|
|
7
7
|
const utils = require("../utils");
|
|
8
8
|
const API_VERSION = "v1";
|
|
9
|
-
const apiClient = new apiv2_1.Client({ urlPrefix: api_1.rulesOrigin, apiVersion: API_VERSION });
|
|
9
|
+
const apiClient = new apiv2_1.Client({ urlPrefix: (0, api_1.rulesOrigin)(), apiVersion: API_VERSION });
|
|
10
10
|
function _handleErrorResponse(response) {
|
|
11
11
|
if (response.body && response.body.error) {
|
|
12
12
|
return utils.reject(response.body.error, { code: 2 });
|
package/lib/gcp/run.js
CHANGED
|
@@ -9,7 +9,7 @@ const throttler_1 = require("../throttler/throttler");
|
|
|
9
9
|
const logger_1 = require("../logger");
|
|
10
10
|
const API_VERSION = "v1";
|
|
11
11
|
const client = new apiv2_1.Client({
|
|
12
|
-
urlPrefix: api_1.runOrigin,
|
|
12
|
+
urlPrefix: (0, api_1.runOrigin)(),
|
|
13
13
|
auth: true,
|
|
14
14
|
apiVersion: API_VERSION,
|
|
15
15
|
});
|
package/lib/gcp/runtimeconfig.js
CHANGED
|
@@ -6,7 +6,7 @@ const api_1 = require("../api");
|
|
|
6
6
|
const apiv2_1 = require("../apiv2");
|
|
7
7
|
const logger_1 = require("../logger");
|
|
8
8
|
const API_VERSION = "v1beta1";
|
|
9
|
-
const apiClient = new apiv2_1.Client({ urlPrefix: api_1.runtimeconfigOrigin, apiVersion: API_VERSION });
|
|
9
|
+
const apiClient = new apiv2_1.Client({ urlPrefix: (0, api_1.runtimeconfigOrigin)(), apiVersion: API_VERSION });
|
|
10
10
|
function listConfigs(projectId) {
|
|
11
11
|
return apiClient
|
|
12
12
|
.get(`/projects/${projectId}/configs`, {
|
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\\/" +
|
|
@@ -13,17 +15,18 @@ const SECRET_VERSION_NAME_REGEX = new RegExp(SECRET_NAME_REGEX.source + "\\/vers
|
|
|
13
15
|
const secretManagerConsoleUri = (projectId) => `https://console.cloud.google.com/security/secret-manager?project=${projectId}`;
|
|
14
16
|
exports.secretManagerConsoleUri = secretManagerConsoleUri;
|
|
15
17
|
const API_VERSION = "v1";
|
|
16
|
-
const client = new apiv2_1.Client({ urlPrefix: api_1.secretManagerOrigin, apiVersion: API_VERSION });
|
|
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;
|
package/lib/gcp/storage.js
CHANGED
|
@@ -10,9 +10,12 @@ const logger_1 = require("../logger");
|
|
|
10
10
|
const ensureApiEnabled_1 = require("../ensureApiEnabled");
|
|
11
11
|
async function getDefaultBucket(projectId) {
|
|
12
12
|
var _a;
|
|
13
|
-
await (0, ensureApiEnabled_1.ensure)(projectId, api_1.firebaseStorageOrigin, "storage", false);
|
|
13
|
+
await (0, ensureApiEnabled_1.ensure)(projectId, (0, api_1.firebaseStorageOrigin)(), "storage", false);
|
|
14
14
|
try {
|
|
15
|
-
const localAPIClient = new apiv2_1.Client({
|
|
15
|
+
const localAPIClient = new apiv2_1.Client({
|
|
16
|
+
urlPrefix: (0, api_1.firebaseStorageOrigin)(),
|
|
17
|
+
apiVersion: "v1alpha",
|
|
18
|
+
});
|
|
16
19
|
const response = await localAPIClient.get(`/projects/${projectId}/defaultBucket`);
|
|
17
20
|
if (!((_a = response.body) === null || _a === void 0 ? void 0 : _a.bucket.name)) {
|
|
18
21
|
logger_1.logger.debug("Default storage bucket is undefined.");
|
|
@@ -29,7 +32,7 @@ async function getDefaultBucket(projectId) {
|
|
|
29
32
|
}
|
|
30
33
|
}
|
|
31
34
|
exports.getDefaultBucket = getDefaultBucket;
|
|
32
|
-
async function upload(source, uploadUrl, extraHeaders) {
|
|
35
|
+
async function upload(source, uploadUrl, extraHeaders, ignoreQuotaProject) {
|
|
33
36
|
const url = new URL(uploadUrl);
|
|
34
37
|
const localAPIClient = new apiv2_1.Client({ urlPrefix: url.origin, auth: false });
|
|
35
38
|
const res = await localAPIClient.request({
|
|
@@ -40,6 +43,7 @@ async function upload(source, uploadUrl, extraHeaders) {
|
|
|
40
43
|
headers: Object.assign({ "content-type": "application/zip" }, extraHeaders),
|
|
41
44
|
body: source.stream,
|
|
42
45
|
skipLog: { resBody: true },
|
|
46
|
+
ignoreQuotaProject,
|
|
43
47
|
});
|
|
44
48
|
return {
|
|
45
49
|
generation: res.response.headers.get("x-goog-generation"),
|
|
@@ -50,7 +54,7 @@ async function uploadObject(source, bucketName) {
|
|
|
50
54
|
if (path.extname(source.file) !== ".zip") {
|
|
51
55
|
throw new error_1.FirebaseError(`Expected a file name ending in .zip, got ${source.file}`);
|
|
52
56
|
}
|
|
53
|
-
const localAPIClient = new apiv2_1.Client({ urlPrefix: api_1.storageOrigin });
|
|
57
|
+
const localAPIClient = new apiv2_1.Client({ urlPrefix: (0, api_1.storageOrigin)() });
|
|
54
58
|
const location = `/${bucketName}/${path.basename(source.file)}`;
|
|
55
59
|
const res = await localAPIClient.request({
|
|
56
60
|
method: "PUT",
|
|
@@ -69,13 +73,13 @@ async function uploadObject(source, bucketName) {
|
|
|
69
73
|
}
|
|
70
74
|
exports.uploadObject = uploadObject;
|
|
71
75
|
function deleteObject(location) {
|
|
72
|
-
const localAPIClient = new apiv2_1.Client({ urlPrefix: api_1.storageOrigin });
|
|
76
|
+
const localAPIClient = new apiv2_1.Client({ urlPrefix: (0, api_1.storageOrigin)() });
|
|
73
77
|
return localAPIClient.delete(location);
|
|
74
78
|
}
|
|
75
79
|
exports.deleteObject = deleteObject;
|
|
76
80
|
async function getBucket(bucketName) {
|
|
77
81
|
try {
|
|
78
|
-
const localAPIClient = new apiv2_1.Client({ urlPrefix: api_1.storageOrigin });
|
|
82
|
+
const localAPIClient = new apiv2_1.Client({ urlPrefix: (0, api_1.storageOrigin)() });
|
|
79
83
|
const result = await localAPIClient.get(`/storage/v1/b/${bucketName}`);
|
|
80
84
|
return result.body;
|
|
81
85
|
}
|
|
@@ -89,7 +93,7 @@ async function getBucket(bucketName) {
|
|
|
89
93
|
exports.getBucket = getBucket;
|
|
90
94
|
async function listBuckets(projectId) {
|
|
91
95
|
try {
|
|
92
|
-
const localAPIClient = new apiv2_1.Client({ urlPrefix: api_1.storageOrigin });
|
|
96
|
+
const localAPIClient = new apiv2_1.Client({ urlPrefix: (0, api_1.storageOrigin)() });
|
|
93
97
|
const result = await localAPIClient.get(`/storage/v1/b?project=${projectId}`);
|
|
94
98
|
return result.body.items.map((bucket) => bucket.name);
|
|
95
99
|
}
|
|
@@ -103,7 +107,7 @@ async function listBuckets(projectId) {
|
|
|
103
107
|
exports.listBuckets = listBuckets;
|
|
104
108
|
async function getServiceAccount(projectId) {
|
|
105
109
|
try {
|
|
106
|
-
const localAPIClient = new apiv2_1.Client({ urlPrefix: api_1.storageOrigin });
|
|
110
|
+
const localAPIClient = new apiv2_1.Client({ urlPrefix: (0, api_1.storageOrigin)() });
|
|
107
111
|
const response = await localAPIClient.get(`/storage/v1/projects/${projectId}/serviceAccount`);
|
|
108
112
|
return response.body;
|
|
109
113
|
}
|
package/lib/hosting/api.js
CHANGED
|
@@ -28,7 +28,7 @@ function normalizeName(s) {
|
|
|
28
28
|
}
|
|
29
29
|
exports.normalizeName = normalizeName;
|
|
30
30
|
const apiClient = new apiv2_1.Client({
|
|
31
|
-
urlPrefix: api_1.hostingApiOrigin,
|
|
31
|
+
urlPrefix: (0, api_1.hostingApiOrigin)(),
|
|
32
32
|
apiVersion: "v1beta1",
|
|
33
33
|
auth: true,
|
|
34
34
|
});
|
|
@@ -122,7 +122,7 @@ async function cloneVersion(site, versionName, finalize = false) {
|
|
|
122
122
|
});
|
|
123
123
|
const { name: operationName } = res.body;
|
|
124
124
|
const pollRes = await operationPoller.pollOperation({
|
|
125
|
-
apiOrigin: api_1.hostingApiOrigin,
|
|
125
|
+
apiOrigin: (0, api_1.hostingApiOrigin)(),
|
|
126
126
|
apiVersion: "v1beta1",
|
|
127
127
|
operationResourceName: operationName,
|
|
128
128
|
masterTimeout: 600000,
|
|
@@ -7,7 +7,7 @@ const error_1 = require("../error");
|
|
|
7
7
|
const logger_1 = require("../logger");
|
|
8
8
|
const projectUtils_1 = require("../projectUtils");
|
|
9
9
|
const cloudRunCache = {};
|
|
10
|
-
const apiClient = new apiv2_1.Client({ urlPrefix: api_1.cloudRunApiOrigin, apiVersion: "v1" });
|
|
10
|
+
const apiClient = new apiv2_1.Client({ urlPrefix: (0, api_1.cloudRunApiOrigin)(), apiVersion: "v1" });
|
|
11
11
|
async function getCloudRunUrl(rewrite, projectId) {
|
|
12
12
|
var _a;
|
|
13
13
|
const alreadyFetched = cloudRunCache[`${rewrite.run.region}/${rewrite.run.serviceId}`];
|
|
@@ -71,7 +71,7 @@ async function doSetup(setup, config) {
|
|
|
71
71
|
setup.config = setup.config || {};
|
|
72
72
|
let instanceDetails;
|
|
73
73
|
if (setup.projectId) {
|
|
74
|
-
await (0, ensureApiEnabled_1.ensure)(setup.projectId, api_1.rtdbManagementOrigin, "database", false);
|
|
74
|
+
await (0, ensureApiEnabled_1.ensure)(setup.projectId, (0, api_1.rtdbManagementOrigin)(), "database", false);
|
|
75
75
|
logger_1.logger.info();
|
|
76
76
|
setup.instance =
|
|
77
77
|
setup.instance || (await (0, getDefaultDatabaseInstance_1.getDefaultDatabaseInstance)({ project: setup.projectId }));
|
|
@@ -10,7 +10,7 @@ async function doSetup(setup, config, options) {
|
|
|
10
10
|
const projectId = (_b = (_a = setup === null || setup === void 0 ? void 0 : setup.rcfile) === null || _a === void 0 ? void 0 : _a.projects) === null || _b === void 0 ? void 0 : _b.default;
|
|
11
11
|
if (projectId) {
|
|
12
12
|
await (0, requirePermissions_1.requirePermissions)(Object.assign(Object.assign({}, options), { project: projectId }));
|
|
13
|
-
await Promise.all([(0, ensureApiEnabled_1.ensure)(projectId, api_1.extensionsOrigin, "unused", true)]);
|
|
13
|
+
await Promise.all([(0, ensureApiEnabled_1.ensure)(projectId, (0, api_1.extensionsOrigin)(), "unused", true)]);
|
|
14
14
|
}
|
|
15
15
|
return manifest.writeEmptyManifest(config, options);
|
|
16
16
|
}
|
|
@@ -16,8 +16,8 @@ async function doSetup(setup, config, options) {
|
|
|
16
16
|
if (projectId) {
|
|
17
17
|
await (0, requirePermissions_1.requirePermissions)(Object.assign(Object.assign({}, options), { project: projectId }));
|
|
18
18
|
await Promise.all([
|
|
19
|
-
(0, ensureApiEnabled_1.ensure)(projectId, api_1.functionsOrigin, "unused", true),
|
|
20
|
-
(0, ensureApiEnabled_1.ensure)(projectId, api_1.runtimeconfigOrigin, "unused", true),
|
|
19
|
+
(0, ensureApiEnabled_1.ensure)(projectId, (0, api_1.functionsOrigin)(), "unused", true),
|
|
20
|
+
(0, ensureApiEnabled_1.ensure)(projectId, (0, api_1.runtimeconfigOrigin)(), "unused", true),
|
|
21
21
|
]);
|
|
22
22
|
}
|
|
23
23
|
setup.functions = {};
|
|
@@ -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);
|
|
@@ -28,7 +28,7 @@ const YML_MERGE_FILENAME = "firebase-hosting-merge.yml";
|
|
|
28
28
|
const CHECKOUT_GITHUB_ACTION_NAME = "actions/checkout@v4";
|
|
29
29
|
const HOSTING_GITHUB_ACTION_NAME = "FirebaseExtended/action-hosting-deploy@v0";
|
|
30
30
|
const SERVICE_ACCOUNT_MAX_KEY_NUMBER = 10;
|
|
31
|
-
const githubApiClient = new apiv2_1.Client({ urlPrefix: api_1.githubApiOrigin, auth: false });
|
|
31
|
+
const githubApiClient = new apiv2_1.Client({ urlPrefix: (0, api_1.githubApiOrigin)(), auth: false });
|
|
32
32
|
async function initGitHub(setup) {
|
|
33
33
|
if (!setup.projectId) {
|
|
34
34
|
return (0, utils_1.reject)("Could not determine Project ID, can't set up GitHub workflow.", { exit: 1 });
|
|
@@ -109,7 +109,7 @@ async function initGitHub(setup) {
|
|
|
109
109
|
}
|
|
110
110
|
logger_1.logger.info();
|
|
111
111
|
(0, utils_1.logLabeledBullet)("Action required", `Visit this URL to revoke authorization for the Firebase CLI GitHub OAuth App:`);
|
|
112
|
-
logger_1.logger.info((0, colorette_1.bold)((0, colorette_1.underline)(`https://github.com/settings/connections/applications/${api_1.githubClientId}`)));
|
|
112
|
+
logger_1.logger.info((0, colorette_1.bold)((0, colorette_1.underline)(`https://github.com/settings/connections/applications/${(0, api_1.githubClientId)()}`)));
|
|
113
113
|
(0, utils_1.logLabeledBullet)("Action required", `Push any new workflow file(s) to your repo`);
|
|
114
114
|
}
|
|
115
115
|
exports.initGitHub = initGitHub;
|
|
@@ -260,7 +260,7 @@ async function promptForRepo(options, ghAccessToken) {
|
|
|
260
260
|
(0, utils_1.logWarning)("The provided authorization cannot be used with this repository. If this repository is in an organization, did you remember to grant access?", "error");
|
|
261
261
|
logger_1.logger.info();
|
|
262
262
|
(0, utils_1.logLabeledBullet)("Action required", `Visit this URL to ensure access has been granted to the appropriate organization(s) for the Firebase CLI GitHub OAuth App:`);
|
|
263
|
-
logger_1.logger.info((0, colorette_1.bold)((0, colorette_1.underline)(`https://github.com/settings/connections/applications/${api_1.githubClientId}`)));
|
|
263
|
+
logger_1.logger.info((0, colorette_1.bold)((0, colorette_1.underline)(`https://github.com/settings/connections/applications/${(0, api_1.githubClientId)()}`)));
|
|
264
264
|
logger_1.logger.info();
|
|
265
265
|
}
|
|
266
266
|
return false;
|
|
@@ -378,6 +378,7 @@ async function createServiceAccountAndKey(options, repo, accountId) {
|
|
|
378
378
|
}
|
|
379
379
|
const requiredRoles = [
|
|
380
380
|
resourceManager_1.firebaseRoles.authAdmin,
|
|
381
|
+
resourceManager_1.firebaseRoles.serviceUsageConsumer,
|
|
381
382
|
resourceManager_1.firebaseRoles.apiKeysViewer,
|
|
382
383
|
resourceManager_1.firebaseRoles.hostingAdmin,
|
|
383
384
|
resourceManager_1.firebaseRoles.runViewer,
|