firebase-tools-with-isolate 13.11.2 → 13.16.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/api.js +4 -2
- package/lib/apphosting/githubConnections.js +125 -37
- package/lib/apphosting/index.js +3 -8
- package/lib/auth.js +14 -15
- package/lib/bin/firebase.js +7 -5
- package/lib/commands/dataconnect-sdk-generate.js +5 -9
- package/lib/commands/dataconnect-services-list.js +1 -1
- package/lib/commands/deploy.js +10 -2
- package/lib/commands/ext-configure.js +1 -6
- package/lib/commands/ext-dev-init.js +27 -30
- package/lib/commands/ext-dev-upload.js +4 -6
- package/lib/commands/ext-info.js +3 -5
- package/lib/commands/ext-install.js +0 -5
- package/lib/commands/ext-uninstall.js +0 -5
- package/lib/commands/ext-update.js +0 -5
- package/lib/commands/firestore-backups-schedules-create.js +11 -14
- package/lib/commands/firestore-backups-schedules-list.js +1 -1
- package/lib/commands/firestore-backups-schedules-update.js +4 -3
- package/lib/commands/firestore-databases-create.js +24 -7
- package/lib/commands/firestore-databases-restore.js +4 -4
- package/lib/commands/firestore-databases-update.js +5 -6
- package/lib/commands/functions-secrets-set.js +9 -6
- package/lib/commands/help.js +2 -0
- package/lib/commands/hosting-channel-create.js +1 -1
- package/lib/commands/hosting-channel-delete.js +1 -1
- package/lib/commands/hosting-channel-deploy.js +1 -1
- package/lib/commands/hosting-clone.js +1 -2
- package/lib/commands/index.js +9 -11
- package/lib/commands/init.js +16 -12
- package/lib/commands/login.js +1 -2
- package/lib/commands/setup-emulators-dataconnect.js +22 -3
- package/lib/config.js +5 -0
- package/lib/crashlytics/buildToolsJarHelper.js +1 -1
- package/lib/dataconnect/client.js +57 -9
- package/lib/dataconnect/fileUtils.js +71 -7
- package/lib/dataconnect/filters.js +12 -1
- package/lib/dataconnect/load.js +9 -7
- package/lib/dataconnect/provisionCloudSql.js +5 -1
- package/lib/dataconnect/schemaMigration.js +21 -0
- package/lib/dataconnect/types.js +8 -1
- package/lib/deploy/dataconnect/prepare.js +16 -2
- package/lib/deploy/extensions/planner.js +52 -1
- package/lib/deploy/extensions/prepare.js +98 -23
- package/lib/deploy/extensions/release.js +6 -0
- package/lib/deploy/functions/build.js +15 -6
- package/lib/deploy/functions/deploy.js +12 -12
- package/lib/deploy/functions/params.js +5 -3
- package/lib/deploy/functions/prepare.js +8 -1
- package/lib/deploy/functions/release/index.js +4 -0
- package/lib/deploy/functions/runtimes/discovery/parsing.js +1 -1
- package/lib/deploy/functions/runtimes/discovery/v1alpha1.js +46 -0
- package/lib/emulator/adminSdkConfig.test.js +16 -0
- package/lib/emulator/constants.js +8 -0
- package/lib/emulator/controller.js +14 -10
- package/lib/emulator/dataconnectEmulator.js +122 -18
- package/lib/emulator/downloadableEmulators.js +24 -25
- package/lib/emulator/env.js +3 -0
- package/lib/emulator/eventarcEmulator.js +68 -18
- package/lib/emulator/functionsEmulator.js +119 -1
- package/lib/emulator/functionsEmulatorShared.js +20 -0
- package/lib/emulator/hub.js +1 -1
- package/lib/emulator/portUtils.js +10 -0
- package/lib/emulator/pubsubEmulator.js +1 -1
- package/lib/emulator/registry.js +2 -1
- package/lib/emulator/storage/apis/shared.js +2 -1
- package/lib/emulator/storage/persistence.js +5 -13
- package/lib/emulator/storage/rfc.js +9 -0
- package/lib/emulator/storage/rules/config.js +4 -2
- package/lib/emulator/taskQueue.js +348 -0
- package/lib/emulator/tasksEmulator.js +237 -0
- package/lib/emulator/types.js +3 -0
- package/lib/experiments.js +8 -3
- package/lib/extensions/askUserForEventsConfig.js +18 -8
- package/lib/extensions/askUserForParam.js +3 -2
- package/lib/extensions/change-log.js +2 -4
- package/lib/extensions/displayExtensionInfo.js +5 -10
- package/lib/extensions/extensionsApi.js +1 -1
- package/lib/extensions/extensionsHelper.js +30 -10
- package/lib/extensions/localHelper.js +1 -1
- package/lib/extensions/provisioningHelper.js +1 -1
- package/lib/extensions/refs.js +26 -11
- package/lib/extensions/runtimes/common.js +75 -0
- package/lib/extensions/types.js +56 -1
- package/lib/extensions/updateHelper.js +1 -2
- package/lib/extensions/warnings.js +2 -7
- package/lib/firestore/api-sort.test.js +74 -0
- package/lib/firestore/api.js +8 -7
- package/lib/firestore/backupUtils.test.js +18 -0
- package/lib/firestore/pretty-print.js +21 -1
- package/lib/firestore/pretty-print.test.js +61 -0
- package/lib/firestore/util.test.js +42 -0
- package/lib/frameworks/angular/utils.js +13 -5
- package/lib/frameworks/compose/discover/mockFileSystem.js +36 -0
- package/lib/frameworks/constants.js +1 -1
- package/lib/frameworks/index.js +2 -6
- package/lib/frameworks/next/constants.js +1 -1
- package/lib/frameworks/next/index.js +35 -15
- package/lib/frameworks/next/utils.js +53 -9
- package/lib/frameworks/nuxt/index.js +3 -3
- package/lib/functions/events/v2.js +2 -1
- package/lib/gcp/cloudsql/cloudsqladmin.js +6 -1
- package/lib/gcp/devConnect.js +36 -1
- package/lib/hosting/implicitInit.js +2 -2
- package/lib/init/features/dataconnect/index.js +104 -32
- package/lib/init/features/dataconnect/sdk.js +147 -0
- package/lib/init/features/firestore/indexes.js +2 -2
- package/lib/init/features/firestore/rules.js +2 -2
- package/lib/init/features/functions/javascript.js +6 -8
- package/lib/init/features/functions/python.js +4 -6
- package/lib/init/features/functions/typescript.js +8 -10
- package/lib/init/features/hosting/github.js +43 -21
- package/lib/init/features/hosting/index.js +3 -3
- package/lib/init/features/index.js +3 -1
- package/lib/init/features/storage.js +2 -2
- package/lib/init/index.js +1 -0
- package/lib/listFiles.js +1 -1
- package/lib/management/apps.js +2 -2
- package/lib/prompt.js +22 -1
- package/lib/rc.js +1 -0
- package/lib/requireAuth.js +8 -3
- package/lib/rulesDeploy.js +14 -12
- package/lib/templates.js +23 -0
- package/lib/utils.js +2 -2
- package/package.json +25 -24
- package/schema/connector-yaml.json +36 -4
- package/schema/dataconnect-yaml.json +4 -0
- package/schema/firebase-config.json +12 -8
- package/templates/_gitignore +3 -0
- package/templates/init/dataconnect/connector.yaml +15 -2
- package/templates/init/dataconnect/dataconnect.yaml +5 -4
- package/templates/init/dataconnect/mutations.gql +45 -25
- package/templates/init/dataconnect/queries.gql +69 -36
- package/templates/init/dataconnect/schema.gql +38 -21
- package/lib/extensions/billingMigrationHelper.js +0 -61
package/lib/api.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
exports.setScopes = exports.getScopes = exports.vertexAIOrigin = exports.cloudSQLAdminOrigin = exports.dataConnectLocalConnString = exports.dataconnectOrigin = exports.githubClientSecret = exports.githubClientId = exports.computeOrigin = exports.secretManagerOrigin = exports.githubApiOrigin = exports.githubOrigin = void 0;
|
|
3
|
+
exports.cloudRunApiOrigin = exports.hostingApiOrigin = exports.firebaseStorageOrigin = exports.storageOrigin = exports.runtimeconfigOrigin = exports.rulesOrigin = exports.resourceManagerOrigin = exports.remoteConfigApiOrigin = exports.rtdbMetadataOrigin = exports.rtdbManagementOrigin = exports.realtimeOrigin = exports.extensionsTOSOrigin = exports.extensionsPublisherOrigin = exports.extensionsOrigin = exports.iamOrigin = exports.identityOrigin = exports.hostingOrigin = exports.googleOrigin = exports.pubsubOrigin = exports.cloudTasksOrigin = exports.cloudschedulerOrigin = exports.cloudbuildOrigin = exports.functionsDefaultRegion = exports.runOrigin = exports.functionsV2Origin = exports.functionsOrigin = exports.firestoreOrigin = exports.firestoreOriginOrEmulator = exports.firedataOrigin = exports.firebaseExtensionsRegistryOrigin = exports.firebaseApiOrigin = exports.eventarcOrigin = exports.dynamicLinksKey = exports.dynamicLinksOrigin = exports.consoleOrigin = exports.authOrigin = exports.apphostingGitHubAppInstallationURL = exports.apphostingP4SADomain = exports.apphostingOrigin = exports.appDistributionOrigin = exports.artifactRegistryDomain = exports.developerConnectP4SADomain = exports.developerConnectOrigin = exports.containerRegistryDomain = exports.cloudMonitoringOrigin = exports.cloudloggingOrigin = exports.cloudbillingOrigin = exports.clientSecret = exports.clientId = exports.authProxyOrigin = void 0;
|
|
4
|
+
exports.setScopes = exports.getScopes = exports.vertexAIOrigin = exports.cloudSQLAdminOrigin = exports.dataConnectLocalConnString = exports.dataconnectOrigin = exports.githubClientSecret = exports.githubClientId = exports.computeOrigin = exports.secretManagerOrigin = exports.githubApiOrigin = exports.githubOrigin = exports.serviceUsageOrigin = void 0;
|
|
5
5
|
const constants_1 = require("./emulator/constants");
|
|
6
6
|
const logger_1 = require("./logger");
|
|
7
7
|
const scopes = require("./scopes");
|
|
@@ -33,6 +33,8 @@ const apphostingOrigin = () => utils.envOverride("FIREBASE_APPHOSTING_URL", "htt
|
|
|
33
33
|
exports.apphostingOrigin = apphostingOrigin;
|
|
34
34
|
const apphostingP4SADomain = () => utils.envOverride("FIREBASE_APPHOSTING_P4SA_DOMAIN", "gcp-sa-firebaseapphosting.iam.gserviceaccount.com");
|
|
35
35
|
exports.apphostingP4SADomain = apphostingP4SADomain;
|
|
36
|
+
const apphostingGitHubAppInstallationURL = () => utils.envOverride("FIREBASE_APPHOSTING_GITHUB_INSTALLATION_URL", "https://github.com/apps/firebase-app-hosting/installations/new");
|
|
37
|
+
exports.apphostingGitHubAppInstallationURL = apphostingGitHubAppInstallationURL;
|
|
36
38
|
const authOrigin = () => utils.envOverride("FIREBASE_AUTH_URL", "https://accounts.google.com");
|
|
37
39
|
exports.authOrigin = authOrigin;
|
|
38
40
|
const consoleOrigin = () => utils.envOverride("FIREBASE_CONSOLE_URL", "https://console.firebase.google.com");
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.fetchRepositoryCloneUris = exports.listAppHostingConnections = exports.getOrCreateRepository = exports.getOrCreateConnection = exports.createConnection = exports.ensureSecretManagerAdminGrant = exports.promptGitHubBranch = exports.getOrCreateOauthConnection = exports.listValidInstallations = exports.promptGitHubInstallation = exports.getConnectionForInstallation = exports.linkGitHubRepository = exports.generateRepositoryId = exports.extractRepoSlugFromUri = exports.parseConnectionName = void 0;
|
|
4
4
|
const clc = require("colorette");
|
|
5
5
|
const devConnect = require("../gcp/devConnect");
|
|
6
6
|
const rm = require("../gcp/resourceManager");
|
|
@@ -13,7 +13,7 @@ const api_1 = require("../api");
|
|
|
13
13
|
const fuzzy = require("fuzzy");
|
|
14
14
|
const inquirer = require("inquirer");
|
|
15
15
|
const APPHOSTING_CONN_PATTERN = /.+\/apphosting-github-conn-.+$/;
|
|
16
|
-
const APPHOSTING_OAUTH_CONN_NAME = "
|
|
16
|
+
const APPHOSTING_OAUTH_CONN_NAME = "firebase-app-hosting-github-oauth";
|
|
17
17
|
const CONNECTION_NAME_REGEX = /^projects\/(?<projectId>[^\/]+)\/locations\/(?<location>[^\/]+)\/connections\/(?<id>[^\/]+)$/;
|
|
18
18
|
function parseConnectionName(name) {
|
|
19
19
|
const match = CONNECTION_NAME_REGEX.exec(name);
|
|
@@ -50,51 +50,128 @@ function generateConnectionId() {
|
|
|
50
50
|
const randomHash = Math.random().toString(36).slice(6);
|
|
51
51
|
return `apphosting-github-conn-${randomHash}`;
|
|
52
52
|
}
|
|
53
|
-
const
|
|
53
|
+
const ADD_ACCOUNT_CHOICE = "@ADD_ACCOUNT";
|
|
54
|
+
const MANAGE_INSTALLATION_CHOICE = "@MANAGE_INSTALLATION";
|
|
54
55
|
async function linkGitHubRepository(projectId, location) {
|
|
55
56
|
utils.logBullet(clc.bold(`${clc.yellow("===")} Import a GitHub repository`));
|
|
56
57
|
const oauthConn = await getOrCreateOauthConnection(projectId, location);
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
58
|
+
let installationId = await promptGitHubInstallation(projectId, location, oauthConn);
|
|
59
|
+
while (installationId === ADD_ACCOUNT_CHOICE) {
|
|
60
|
+
utils.logBullet("Install the Firebase App Hosting GitHub app on a new account to enable access to those repositories");
|
|
61
|
+
const apphostingGitHubInstallationURL = (0, api_1.apphostingGitHubAppInstallationURL)();
|
|
62
|
+
utils.logBullet(apphostingGitHubInstallationURL);
|
|
63
|
+
await utils.openInBrowser(apphostingGitHubInstallationURL);
|
|
64
|
+
await (0, prompt_1.promptOnce)({
|
|
65
|
+
type: "input",
|
|
66
|
+
message: "Press Enter once you have installed or configured the Firebase App Hosting GitHub app to access your GitHub repo.",
|
|
67
|
+
});
|
|
68
|
+
installationId = await promptGitHubInstallation(projectId, location, oauthConn);
|
|
69
|
+
}
|
|
70
|
+
let connectionMatchingInstallation = await getConnectionForInstallation(projectId, location, installationId);
|
|
71
|
+
if (!connectionMatchingInstallation) {
|
|
72
|
+
connectionMatchingInstallation = await createFullyInstalledConnection(projectId, location, generateConnectionId(), oauthConn, installationId);
|
|
60
73
|
}
|
|
61
74
|
let repoCloneUri;
|
|
62
|
-
let connection;
|
|
63
75
|
do {
|
|
64
|
-
if (repoCloneUri ===
|
|
65
|
-
|
|
76
|
+
if (repoCloneUri === MANAGE_INSTALLATION_CHOICE) {
|
|
77
|
+
await manageInstallation(connectionMatchingInstallation);
|
|
66
78
|
}
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
} while (repoCloneUri === ADD_CONN_CHOICE);
|
|
71
|
-
const { id: connectionId } = parseConnectionName(connection.name);
|
|
79
|
+
repoCloneUri = await promptCloneUri(projectId, connectionMatchingInstallation);
|
|
80
|
+
} while (repoCloneUri === MANAGE_INSTALLATION_CHOICE);
|
|
81
|
+
const { id: connectionId } = parseConnectionName(connectionMatchingInstallation.name);
|
|
72
82
|
await getOrCreateConnection(projectId, location, connectionId, {
|
|
73
|
-
authorizerCredential:
|
|
74
|
-
appInstallationId:
|
|
83
|
+
authorizerCredential: connectionMatchingInstallation.githubConfig?.authorizerCredential,
|
|
84
|
+
appInstallationId: connectionMatchingInstallation.githubConfig?.appInstallationId,
|
|
75
85
|
});
|
|
76
86
|
const repo = await getOrCreateRepository(projectId, location, connectionId, repoCloneUri);
|
|
77
87
|
return repo;
|
|
78
88
|
}
|
|
79
89
|
exports.linkGitHubRepository = linkGitHubRepository;
|
|
80
|
-
async function createFullyInstalledConnection(projectId, location, connectionId, oauthConn,
|
|
90
|
+
async function createFullyInstalledConnection(projectId, location, connectionId, oauthConn, installationId) {
|
|
81
91
|
let conn = await createConnection(projectId, location, connectionId, {
|
|
82
|
-
appInstallationId:
|
|
92
|
+
appInstallationId: installationId,
|
|
83
93
|
authorizerCredential: oauthConn.githubConfig?.authorizerCredential,
|
|
84
94
|
});
|
|
85
95
|
while (conn.installationState.stage !== "COMPLETE") {
|
|
86
|
-
utils.logBullet("Install the Firebase GitHub app to enable access to GitHub repositories");
|
|
96
|
+
utils.logBullet("Install the Firebase App Hosting GitHub app to enable access to GitHub repositories");
|
|
87
97
|
const targetUri = conn.installationState.actionUri;
|
|
88
98
|
utils.logBullet(targetUri);
|
|
89
99
|
await utils.openInBrowser(targetUri);
|
|
90
100
|
await (0, prompt_1.promptOnce)({
|
|
91
101
|
type: "input",
|
|
92
|
-
message: "Press Enter once you have installed or configured the Firebase GitHub app to access your GitHub repo.",
|
|
102
|
+
message: "Press Enter once you have installed or configured the Firebase App Hosting GitHub app to access your GitHub repo.",
|
|
93
103
|
});
|
|
94
104
|
conn = await devConnect.getConnection(projectId, location, connectionId);
|
|
95
105
|
}
|
|
96
106
|
return conn;
|
|
97
107
|
}
|
|
108
|
+
async function manageInstallation(connection) {
|
|
109
|
+
utils.logBullet("Manage the Firebase App Hosting GitHub app to enable access to GitHub repositories");
|
|
110
|
+
const targetUri = connection.githubConfig?.installationUri;
|
|
111
|
+
if (!targetUri) {
|
|
112
|
+
throw new error_1.FirebaseError("Failed to get Installation URI. Please try again.");
|
|
113
|
+
}
|
|
114
|
+
utils.logBullet(targetUri);
|
|
115
|
+
await utils.openInBrowser(targetUri);
|
|
116
|
+
await (0, prompt_1.promptOnce)({
|
|
117
|
+
type: "input",
|
|
118
|
+
message: "Press Enter once you have installed or configured the Firebase App Hosting GitHub app to access your GitHub repo.",
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
async function getConnectionForInstallation(projectId, location, installationId) {
|
|
122
|
+
const connections = await listAppHostingConnections(projectId, location);
|
|
123
|
+
const connectionsMatchingInstallation = connections.filter((conn) => conn.githubConfig?.appInstallationId === installationId);
|
|
124
|
+
if (connectionsMatchingInstallation.length === 0) {
|
|
125
|
+
return null;
|
|
126
|
+
}
|
|
127
|
+
if (connectionsMatchingInstallation.length > 1) {
|
|
128
|
+
const sorted = devConnect.sortConnectionsByCreateTime(connectionsMatchingInstallation);
|
|
129
|
+
return sorted[0];
|
|
130
|
+
}
|
|
131
|
+
return connectionsMatchingInstallation[0];
|
|
132
|
+
}
|
|
133
|
+
exports.getConnectionForInstallation = getConnectionForInstallation;
|
|
134
|
+
async function promptGitHubInstallation(projectId, location, connection) {
|
|
135
|
+
const installations = await listValidInstallations(projectId, location, connection);
|
|
136
|
+
const installationName = await (0, prompt_1.promptOnce)({
|
|
137
|
+
type: "autocomplete",
|
|
138
|
+
name: "installation",
|
|
139
|
+
message: "Which GitHub account do you want to use?",
|
|
140
|
+
source: (_, input = "") => {
|
|
141
|
+
return new Promise((resolve) => resolve([
|
|
142
|
+
new inquirer.Separator(),
|
|
143
|
+
{
|
|
144
|
+
name: "Missing an account? Select this option to add a GitHub account",
|
|
145
|
+
value: ADD_ACCOUNT_CHOICE,
|
|
146
|
+
},
|
|
147
|
+
new inquirer.Separator(),
|
|
148
|
+
...fuzzy
|
|
149
|
+
.filter(input, installations, {
|
|
150
|
+
extract: (installation) => installation.name || "",
|
|
151
|
+
})
|
|
152
|
+
.map((result) => {
|
|
153
|
+
return {
|
|
154
|
+
name: result.original.name || "",
|
|
155
|
+
value: result.original.id,
|
|
156
|
+
};
|
|
157
|
+
}),
|
|
158
|
+
]));
|
|
159
|
+
},
|
|
160
|
+
});
|
|
161
|
+
return installationName;
|
|
162
|
+
}
|
|
163
|
+
exports.promptGitHubInstallation = promptGitHubInstallation;
|
|
164
|
+
async function listValidInstallations(projectId, location, connection) {
|
|
165
|
+
const { id: connId } = parseConnectionName(connection.name);
|
|
166
|
+
let installations = await devConnect.fetchGitHubInstallations(projectId, location, connId);
|
|
167
|
+
installations = installations.filter((installation) => {
|
|
168
|
+
return ((installation.type === "user" &&
|
|
169
|
+
installation.name === connection.githubConfig?.authorizerCredential?.username) ||
|
|
170
|
+
installation.type === "organization");
|
|
171
|
+
});
|
|
172
|
+
return installations;
|
|
173
|
+
}
|
|
174
|
+
exports.listValidInstallations = listValidInstallations;
|
|
98
175
|
async function getOrCreateOauthConnection(projectId, location) {
|
|
99
176
|
let conn;
|
|
100
177
|
try {
|
|
@@ -125,8 +202,8 @@ async function getOrCreateOauthConnection(projectId, location) {
|
|
|
125
202
|
return conn;
|
|
126
203
|
}
|
|
127
204
|
exports.getOrCreateOauthConnection = getOrCreateOauthConnection;
|
|
128
|
-
async function promptCloneUri(projectId,
|
|
129
|
-
const
|
|
205
|
+
async function promptCloneUri(projectId, connection) {
|
|
206
|
+
const cloneUris = await fetchRepositoryCloneUris(projectId, connection);
|
|
130
207
|
const cloneUri = await (0, prompt_1.promptOnce)({
|
|
131
208
|
type: "autocomplete",
|
|
132
209
|
name: "cloneUri",
|
|
@@ -136,7 +213,7 @@ async function promptCloneUri(projectId, connections) {
|
|
|
136
213
|
new inquirer.Separator(),
|
|
137
214
|
{
|
|
138
215
|
name: "Missing a repo? Select this option to configure your GitHub connection settings",
|
|
139
|
-
value:
|
|
216
|
+
value: MANAGE_INSTALLATION_CHOICE,
|
|
140
217
|
},
|
|
141
218
|
new inquirer.Separator(),
|
|
142
219
|
...fuzzy
|
|
@@ -152,8 +229,24 @@ async function promptCloneUri(projectId, connections) {
|
|
|
152
229
|
]));
|
|
153
230
|
},
|
|
154
231
|
});
|
|
155
|
-
return
|
|
232
|
+
return cloneUri;
|
|
156
233
|
}
|
|
234
|
+
async function promptGitHubBranch(repoLink) {
|
|
235
|
+
const branches = await devConnect.listAllBranches(repoLink.name);
|
|
236
|
+
while (true) {
|
|
237
|
+
const branch = await (0, prompt_1.promptOnce)({
|
|
238
|
+
name: "branch",
|
|
239
|
+
type: "input",
|
|
240
|
+
default: "main",
|
|
241
|
+
message: "Pick a branch for continuous deployment",
|
|
242
|
+
});
|
|
243
|
+
if (branches.has(branch)) {
|
|
244
|
+
return branch;
|
|
245
|
+
}
|
|
246
|
+
utils.logWarning(`The branch "${branch}" does not exist on "${extractRepoSlugFromUri(repoLink.cloneUri)}". Please enter a valid branch for this repo.`);
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
exports.promptGitHubBranch = promptGitHubBranch;
|
|
157
250
|
async function ensureSecretManagerAdminGrant(projectId) {
|
|
158
251
|
const projectNumber = await (0, getProjectNumber_1.getProjectNumber)({ projectId });
|
|
159
252
|
const dcsaEmail = devConnect.serviceAgentEmail(projectNumber);
|
|
@@ -242,22 +335,17 @@ async function getOrCreateRepository(projectId, location, connectionId, cloneUri
|
|
|
242
335
|
return repo;
|
|
243
336
|
}
|
|
244
337
|
exports.getOrCreateRepository = getOrCreateRepository;
|
|
245
|
-
async function listAppHostingConnections(projectId) {
|
|
246
|
-
const conns = await devConnect.listAllConnections(projectId,
|
|
338
|
+
async function listAppHostingConnections(projectId, location) {
|
|
339
|
+
const conns = await devConnect.listAllConnections(projectId, location);
|
|
247
340
|
return conns.filter((conn) => APPHOSTING_CONN_PATTERN.test(conn.name) &&
|
|
248
341
|
conn.installationState.stage === "COMPLETE" &&
|
|
249
342
|
!conn.disabled);
|
|
250
343
|
}
|
|
251
344
|
exports.listAppHostingConnections = listAppHostingConnections;
|
|
252
|
-
async function
|
|
253
|
-
const
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
connectionRepos.forEach((repo) => {
|
|
258
|
-
cloneUriToConnection[repo.cloneUri] = conn;
|
|
259
|
-
});
|
|
260
|
-
}
|
|
261
|
-
return { cloneUris: Object.keys(cloneUriToConnection), cloneUriToConnection };
|
|
345
|
+
async function fetchRepositoryCloneUris(projectId, connection) {
|
|
346
|
+
const { location, id } = parseConnectionName(connection.name);
|
|
347
|
+
const connectionRepos = await devConnect.listAllLinkableGitRepositories(projectId, location, id);
|
|
348
|
+
const cloneUris = connectionRepos.map((conn) => conn.cloneUri);
|
|
349
|
+
return cloneUris;
|
|
262
350
|
}
|
|
263
|
-
exports.
|
|
351
|
+
exports.fetchRepositoryCloneUris = fetchRepositoryCloneUris;
|
package/lib/apphosting/index.js
CHANGED
|
@@ -65,19 +65,14 @@ async function doSetup(projectId, webAppName, location, serviceAccount) {
|
|
|
65
65
|
}
|
|
66
66
|
location =
|
|
67
67
|
location || (await promptLocation(projectId, "Select a location to host your backend:\n"));
|
|
68
|
-
const
|
|
68
|
+
const gitRepositoryLink = await githubConnections.linkGitHubRepository(projectId, location);
|
|
69
69
|
const rootDir = await (0, prompt_1.promptOnce)({
|
|
70
70
|
name: "rootDir",
|
|
71
71
|
type: "input",
|
|
72
72
|
default: "/",
|
|
73
73
|
message: "Specify your app's root directory relative to your repository",
|
|
74
74
|
});
|
|
75
|
-
const branch = await (
|
|
76
|
-
name: "branch",
|
|
77
|
-
type: "input",
|
|
78
|
-
default: "main",
|
|
79
|
-
message: "Pick a branch for continuous deployment",
|
|
80
|
-
});
|
|
75
|
+
const branch = await githubConnections.promptGitHubBranch(gitRepositoryLink);
|
|
81
76
|
(0, utils_1.logSuccess)(`Repo linked successfully!\n`);
|
|
82
77
|
(0, utils_1.logBullet)(`${clc.yellow("===")} Set up your backend`);
|
|
83
78
|
const backendId = await promptNewBackendId(projectId, location, {
|
|
@@ -92,7 +87,7 @@ async function doSetup(projectId, webAppName, location, serviceAccount) {
|
|
|
92
87
|
(0, utils_1.logWarning)(`Firebase web app not set`);
|
|
93
88
|
}
|
|
94
89
|
const createBackendSpinner = ora("Creating your new backend...").start();
|
|
95
|
-
const backend = await createBackend(projectId, location, backendId,
|
|
90
|
+
const backend = await createBackend(projectId, location, backendId, gitRepositoryLink, serviceAccount, webApp?.id, rootDir);
|
|
96
91
|
createBackendSpinner.succeed(`Successfully created backend!\n\t${backend.name}\n`);
|
|
97
92
|
await setDefaultTrafficPolicy(projectId, location, backendId, branch);
|
|
98
93
|
const confirmRollout = await (0, prompt_1.promptOnce)({
|
package/lib/auth.js
CHANGED
|
@@ -3,14 +3,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.addAdditionalAccount = exports.logout = exports.getAccessToken = exports.findAccountByEmail = exports.loginGithub = exports.loginGoogle = exports.setGlobalDefaultAccount = exports.setProjectAccount = exports.loginAdditionalAccount = exports.selectAccount = exports.setRefreshToken = exports.setActiveAccount = exports.getAllAccounts = exports.getAdditionalAccounts = exports.getProjectDefaultAccount = exports.getGlobalDefaultAccount = void 0;
|
|
4
4
|
const clc = require("colorette");
|
|
5
5
|
const FormData = require("form-data");
|
|
6
|
-
const fs = require("fs");
|
|
7
6
|
const http = require("http");
|
|
8
7
|
const jwt = require("jsonwebtoken");
|
|
9
8
|
const opn = require("open");
|
|
10
|
-
const path = require("path");
|
|
11
9
|
const portfinder = require("portfinder");
|
|
12
10
|
const url = require("url");
|
|
13
|
-
const util = require("util");
|
|
14
11
|
const apiv2 = require("./apiv2");
|
|
15
12
|
const configstore_1 = require("./configstore");
|
|
16
13
|
const error_1 = require("./error");
|
|
@@ -23,6 +20,7 @@ const uuid_1 = require("uuid");
|
|
|
23
20
|
const crypto_1 = require("crypto");
|
|
24
21
|
const track_1 = require("./track");
|
|
25
22
|
const api_1 = require("./api");
|
|
23
|
+
const templates_1 = require("./templates");
|
|
26
24
|
portfinder.setBasePort(9005);
|
|
27
25
|
function getGlobalDefaultAccount() {
|
|
28
26
|
const user = configstore_1.configstore.get("user");
|
|
@@ -261,13 +259,12 @@ async function getGithubTokensFromAuthorizationCode(code, callbackUrl) {
|
|
|
261
259
|
});
|
|
262
260
|
return res.body.access_token;
|
|
263
261
|
}
|
|
264
|
-
|
|
265
|
-
const response = await util.promisify(fs.readFile)(path.join(__dirname, filename));
|
|
262
|
+
function respondHtml(req, res, statusCode, html) {
|
|
266
263
|
res.writeHead(statusCode, {
|
|
267
|
-
"Content-Length":
|
|
264
|
+
"Content-Length": html.length,
|
|
268
265
|
"Content-Type": "text/html",
|
|
269
266
|
});
|
|
270
|
-
res.end(
|
|
267
|
+
res.end(html);
|
|
271
268
|
req.socket.destroy();
|
|
272
269
|
}
|
|
273
270
|
function urlsafeBase64(base64string) {
|
|
@@ -318,8 +315,8 @@ async function loginRemotely() {
|
|
|
318
315
|
async function loginWithLocalhostGoogle(port, userHint) {
|
|
319
316
|
const callbackUrl = getCallbackUrl(port);
|
|
320
317
|
const authUrl = getLoginUrl(callbackUrl, userHint);
|
|
321
|
-
const
|
|
322
|
-
const tokens = await loginWithLocalhost(port, callbackUrl, authUrl,
|
|
318
|
+
const successHtml = await (0, templates_1.readTemplate)("loginSuccess.html");
|
|
319
|
+
const tokens = await loginWithLocalhost(port, callbackUrl, authUrl, successHtml, getTokensFromAuthorizationCode);
|
|
323
320
|
void (0, track_1.trackGA4)("login", { method: "google_localhost" });
|
|
324
321
|
return {
|
|
325
322
|
user: jwt.decode(tokens.id_token, { json: true }),
|
|
@@ -330,30 +327,32 @@ async function loginWithLocalhostGoogle(port, userHint) {
|
|
|
330
327
|
async function loginWithLocalhostGitHub(port) {
|
|
331
328
|
const callbackUrl = getCallbackUrl(port);
|
|
332
329
|
const authUrl = getGithubLoginUrl(callbackUrl);
|
|
333
|
-
const
|
|
334
|
-
const tokens = await loginWithLocalhost(port, callbackUrl, authUrl,
|
|
330
|
+
const successHtml = await (0, templates_1.readTemplate)("loginSuccessGithub.html");
|
|
331
|
+
const tokens = await loginWithLocalhost(port, callbackUrl, authUrl, successHtml, getGithubTokensFromAuthorizationCode);
|
|
335
332
|
void (0, track_1.trackGA4)("login", { method: "github_localhost" });
|
|
336
333
|
return tokens;
|
|
337
334
|
}
|
|
338
|
-
async function loginWithLocalhost(port, callbackUrl, authUrl,
|
|
335
|
+
async function loginWithLocalhost(port, callbackUrl, authUrl, successHtml, getTokens) {
|
|
339
336
|
return new Promise((resolve, reject) => {
|
|
340
337
|
const server = http.createServer(async (req, res) => {
|
|
341
338
|
const query = url.parse(`${req.url}`, true).query || {};
|
|
342
339
|
const queryState = query.state;
|
|
343
340
|
const queryCode = query.code;
|
|
344
341
|
if (queryState !== _nonce || typeof queryCode !== "string") {
|
|
345
|
-
await
|
|
342
|
+
const html = await (0, templates_1.readTemplate)("loginFailure.html");
|
|
343
|
+
respondHtml(req, res, 400, html);
|
|
346
344
|
reject(new error_1.FirebaseError("Unexpected error while logging in"));
|
|
347
345
|
server.close();
|
|
348
346
|
return;
|
|
349
347
|
}
|
|
350
348
|
try {
|
|
351
349
|
const tokens = await getTokens(queryCode, callbackUrl);
|
|
352
|
-
|
|
350
|
+
respondHtml(req, res, 200, successHtml);
|
|
353
351
|
resolve(tokens);
|
|
354
352
|
}
|
|
355
353
|
catch (err) {
|
|
356
|
-
await
|
|
354
|
+
const html = await (0, templates_1.readTemplate)("loginFailure.html");
|
|
355
|
+
respondHtml(req, res, 400, html);
|
|
357
356
|
reject(err);
|
|
358
357
|
}
|
|
359
358
|
server.close();
|
package/lib/bin/firebase.js
CHANGED
|
@@ -10,12 +10,10 @@ if (!semver.satisfies(nodeVersion, pkg.engines.node)) {
|
|
|
10
10
|
}
|
|
11
11
|
const updateNotifierPkg = require("update-notifier-cjs");
|
|
12
12
|
const clc = require("colorette");
|
|
13
|
-
const
|
|
13
|
+
const marked_terminal_1 = require("marked-terminal");
|
|
14
14
|
const updateNotifier = updateNotifierPkg({ pkg });
|
|
15
15
|
const marked_1 = require("marked");
|
|
16
|
-
marked_1.marked.
|
|
17
|
-
renderer: new TerminalRenderer(),
|
|
18
|
-
});
|
|
16
|
+
marked_1.marked.use((0, marked_terminal_1.markedTerminal)());
|
|
19
17
|
const node_path_1 = require("node:path");
|
|
20
18
|
const triple_beam_1 = require("triple-beam");
|
|
21
19
|
const stripAnsi = require("strip-ansi");
|
|
@@ -105,8 +103,12 @@ process.on("exit", (code) => {
|
|
|
105
103
|
configstore_1.configstore.delete("lastError");
|
|
106
104
|
}
|
|
107
105
|
try {
|
|
106
|
+
const installMethod = !process.env.FIREPIT_VERSION ? "npm" : "automatic script";
|
|
107
|
+
const updateCommand = !process.env.FIREPIT_VERSION
|
|
108
|
+
? "npm install -g firebase-tools"
|
|
109
|
+
: "curl -sL https://firebase.tools | upgrade=true bash";
|
|
108
110
|
const updateMessage = `Update available ${clc.gray("{currentVersion}")} → ${clc.green("{latestVersion}")}\n` +
|
|
109
|
-
`To update to the latest version using
|
|
111
|
+
`To update to the latest version using ${installMethod}, run\n${clc.cyan(updateCommand)}\n` +
|
|
110
112
|
`For other CLI management options, visit the ${(0, marked_1.marked)("[CLI documentation](https://firebase.google.com/docs/cli#update-cli)")}`;
|
|
111
113
|
updateNotifier.notify({ defer: false, isGlobal: true, message: updateMessage });
|
|
112
114
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.command = void 0;
|
|
4
|
-
const
|
|
4
|
+
const clc = require("colorette");
|
|
5
5
|
const command_1 = require("../command");
|
|
6
6
|
const dataconnectEmulator_1 = require("../emulator/dataconnectEmulator");
|
|
7
7
|
const projectUtils_1 = require("../projectUtils");
|
|
@@ -14,12 +14,8 @@ exports.command = new command_1.Command("dataconnect:sdk:generate")
|
|
|
14
14
|
const projectId = (0, projectUtils_1.needProjectId)(options);
|
|
15
15
|
const services = (0, fileUtils_1.readFirebaseJson)(options.config);
|
|
16
16
|
for (const service of services) {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
const cwd = options.cwd || process.cwd();
|
|
20
|
-
configDir = path.resolve(path.join(cwd), configDir);
|
|
21
|
-
}
|
|
22
|
-
const serviceInfo = await (0, load_1.load)(projectId, service.location, configDir);
|
|
17
|
+
const configDir = service.source;
|
|
18
|
+
const serviceInfo = await (0, load_1.load)(projectId, options.config, configDir);
|
|
23
19
|
const hasGeneratables = serviceInfo.connectorInfo.some((c) => {
|
|
24
20
|
return (c.connectorYaml.generate?.javascriptSdk ||
|
|
25
21
|
c.connectorYaml.generate?.kotlinSdk ||
|
|
@@ -27,13 +23,13 @@ exports.command = new command_1.Command("dataconnect:sdk:generate")
|
|
|
27
23
|
});
|
|
28
24
|
if (!hasGeneratables) {
|
|
29
25
|
logger_1.logger.warn("No generated SDKs have been declared in connector.yaml files.");
|
|
30
|
-
logger_1.logger.warn("
|
|
26
|
+
logger_1.logger.warn(`Run ${clc.bold("firebase init dataconnect:sdk")} to configure a generated SDK.`);
|
|
27
|
+
logger_1.logger.warn(`See https://firebase.google.com/docs/data-connect/gp/web-sdk for more details of how to configure generated SDKs.`);
|
|
31
28
|
return;
|
|
32
29
|
}
|
|
33
30
|
for (const conn of serviceInfo.connectorInfo) {
|
|
34
31
|
const output = await dataconnectEmulator_1.DataConnectEmulator.generate({
|
|
35
32
|
configDir,
|
|
36
|
-
locationId: service.location,
|
|
37
33
|
connectorId: conn.connectorYaml.connectorId,
|
|
38
34
|
});
|
|
39
35
|
logger_1.logger.info(output);
|
|
@@ -43,7 +43,7 @@ exports.command = new command_1.Command("dataconnect:services:list")
|
|
|
43
43
|
const instanceName = schema?.primaryDatasource.postgresql?.cloudSql.instance ?? "";
|
|
44
44
|
const instanceId = instanceName.split("/").pop();
|
|
45
45
|
const dbId = schema?.primaryDatasource.postgresql?.database ?? "";
|
|
46
|
-
const dbName = `CloudSQL Instance: ${instanceId}\nDatabase
|
|
46
|
+
const dbName = `CloudSQL Instance: ${instanceId}\nDatabase: ${dbId}`;
|
|
47
47
|
table.push([
|
|
48
48
|
serviceName.serviceId,
|
|
49
49
|
serviceName.location,
|
package/lib/commands/deploy.js
CHANGED
|
@@ -80,7 +80,9 @@ exports.command = new command_1.Command("deploy")
|
|
|
80
80
|
.option("--only <targets>", 'only deploy to specified, comma-separated targets (e.g. "hosting,storage"). For functions, ' +
|
|
81
81
|
'can specify filters with colons to scope function deploys to only those functions (e.g. "--only functions:func1,functions:func2"). ' +
|
|
82
82
|
"When filtering based on export groups (the exported module object keys), use dots to specify group names " +
|
|
83
|
-
'(e.g. "--only functions:group1.subgroup1,functions:group2)
|
|
83
|
+
'(e.g. "--only functions:group1.subgroup1,functions:group2"). ' +
|
|
84
|
+
"When filtering based on codebases, use colons to specify codebase names " +
|
|
85
|
+
'(e.g. "--only functions:codebase1:func1,functions:codebase2:group1.subgroup1"). ' +
|
|
84
86
|
"For data connect, can specify filters with colons to deploy only a service, connector, or schema" +
|
|
85
87
|
'(e.g. "--only dataconnect:serviceId,dataconnect:serviceId:connectorId,dataconnect:serviceId:schema"). ')
|
|
86
88
|
.option("--except <targets>", 'deploy to all targets except specified (e.g. "database")')
|
|
@@ -107,7 +109,13 @@ exports.command = new command_1.Command("deploy")
|
|
|
107
109
|
await (0, requireHostingSite_1.requireHostingSite)(options);
|
|
108
110
|
}
|
|
109
111
|
catch (err) {
|
|
110
|
-
|
|
112
|
+
const isPermissionError = err instanceof error_1.FirebaseError &&
|
|
113
|
+
err.original instanceof error_1.FirebaseError &&
|
|
114
|
+
err.original.status === 403;
|
|
115
|
+
if (isPermissionError) {
|
|
116
|
+
throw err;
|
|
117
|
+
}
|
|
118
|
+
else if (err === getDefaultHostingSite_1.errNoDefaultSite) {
|
|
111
119
|
createSite = true;
|
|
112
120
|
}
|
|
113
121
|
}
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.command = void 0;
|
|
4
|
-
const marked_1 = require("marked");
|
|
5
|
-
const TerminalRenderer = require("marked-terminal");
|
|
6
4
|
const checkMinRequiredVersion_1 = require("../checkMinRequiredVersion");
|
|
7
5
|
const command_1 = require("../command");
|
|
8
6
|
const error_1 = require("../error");
|
|
@@ -19,9 +17,6 @@ const functional_1 = require("../functional");
|
|
|
19
17
|
const paramHelper_1 = require("../extensions/paramHelper");
|
|
20
18
|
const askUserForEventsConfig = require("../extensions/askUserForEventsConfig");
|
|
21
19
|
const tos_1 = require("../extensions/tos");
|
|
22
|
-
marked_1.marked.setOptions({
|
|
23
|
-
renderer: new TerminalRenderer(),
|
|
24
|
-
});
|
|
25
20
|
exports.command = new command_1.Command("ext:configure <extensionInstanceId>")
|
|
26
21
|
.description("configure an existing extension instance")
|
|
27
22
|
.withForce()
|
|
@@ -101,7 +96,7 @@ function infoImmutableParams(immutableParams, paramValues) {
|
|
|
101
96
|
return;
|
|
102
97
|
}
|
|
103
98
|
const plural = immutableParams.length > 1;
|
|
104
|
-
utils.logLabeledWarning(extensionsHelper_1.logPrefix,
|
|
99
|
+
utils.logLabeledWarning(extensionsHelper_1.logPrefix, `The following param${plural ? "s are" : " is"} immutable and won't be changed:`);
|
|
105
100
|
for (const { param } of immutableParams) {
|
|
106
101
|
logger_1.logger.info(`param: ${param}, value: ${paramValues[param]}`);
|
|
107
102
|
}
|