firebase-tools-with-isolate 12.9.1-9 → 13.0.2-0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +14 -8
- package/lib/api.js +2 -2
- package/lib/apiv2.js +7 -0
- package/lib/auth.js +8 -4
- package/lib/commands/{frameworks-backends-create.js → apphosting-backends-create.js} +6 -3
- package/lib/commands/{frameworks-backends-delete.js → apphosting-backends-delete.js} +9 -7
- package/lib/commands/{frameworks-backends-get.js → apphosting-backends-get.js} +16 -27
- package/lib/commands/{frameworks-backends-list.js → apphosting-backends-list.js} +9 -19
- package/lib/commands/apphosting-builds-create.js +31 -0
- package/lib/commands/apphosting-builds-get.js +18 -0
- package/lib/commands/apphosting-rollouts-create.js +26 -0
- package/lib/commands/apphosting-rollouts-list.js +18 -0
- package/lib/commands/index.js +12 -7
- package/lib/commands/login-use.js +25 -6
- package/lib/config.js +10 -8
- package/lib/deploy/functions/runtimes/node/parseRuntimeAndValidateSDK.js +2 -2
- package/lib/deploy/functions/services/firestore.js +11 -1
- package/lib/deploy/lifecycleHooks.js +5 -0
- package/lib/fetchMOTD.js +1 -1
- package/lib/firestore/api.js +6 -6
- package/lib/frameworks/angular/index.js +5 -3
- package/lib/frameworks/angular/utils.js +33 -4
- package/lib/frameworks/astro/index.js +5 -2
- package/lib/frameworks/astro/utils.js +3 -2
- package/lib/frameworks/constants.js +37 -10
- package/lib/frameworks/index.js +12 -7
- package/lib/frameworks/next/index.js +28 -8
- package/lib/frameworks/next/utils.js +7 -3
- package/lib/frameworks/nuxt/index.js +15 -5
- package/lib/frameworks/nuxt2/index.js +5 -4
- package/lib/frameworks/sveltekit/index.js +2 -1
- package/lib/frameworks/utils.js +13 -9
- package/lib/frameworks/vite/index.js +18 -5
- package/lib/functionsShellCommandAction.js +3 -3
- package/lib/gcp/apphosting.js +89 -0
- package/lib/gcp/cloudbuild.js +28 -3
- package/lib/gcp/storage.js +11 -5
- package/lib/hosting/api.js +19 -1
- package/lib/hosting/runTags.js +2 -1
- package/lib/init/features/{frameworks → apphosting}/constants.js +1 -2
- package/lib/init/features/apphosting/index.js +147 -0
- package/lib/init/features/apphosting/repo.js +225 -0
- package/lib/init/features/hosting/index.js +1 -1
- package/lib/init/features/index.js +3 -3
- package/lib/init/index.js +0 -4
- package/lib/localFunction.js +77 -14
- package/lib/utils.js +50 -1
- package/package.json +10 -8
- package/templates/popup.html +64 -0
- package/lib/commands/ext-dev-publish.js +0 -32
- package/lib/gcp/frameworks.js +0 -40
- package/lib/init/features/frameworks/index.js +0 -120
- package/lib/init/features/frameworks/repo.js +0 -132
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.listAppHostingConnections = exports.getOrCreateRepository = exports.getOrCreateConnection = exports.createConnection = exports.linkGitHubRepository = exports.parseConnectionName = void 0;
|
|
4
|
+
const clc = require("colorette");
|
|
5
|
+
const gcb = require("../../../gcp/cloudbuild");
|
|
6
|
+
const rm = require("../../../gcp/resourceManager");
|
|
7
|
+
const poller = require("../../../operation-poller");
|
|
8
|
+
const utils = require("../../../utils");
|
|
9
|
+
const api_1 = require("../../../api");
|
|
10
|
+
const error_1 = require("../../../error");
|
|
11
|
+
const prompt_1 = require("../../../prompt");
|
|
12
|
+
const getProjectNumber_1 = require("../../../getProjectNumber");
|
|
13
|
+
const APPHOSTING_CONN_PATTERN = /.+\/apphosting-github-conn-.+$/;
|
|
14
|
+
const APPHOSTING_OAUTH_CONN_NAME = "apphosting-github-oauth";
|
|
15
|
+
const CONNECTION_NAME_REGEX = /^projects\/(?<projectId>[^\/]+)\/locations\/(?<location>[^\/]+)\/connections\/(?<id>[^\/]+)$/;
|
|
16
|
+
function parseConnectionName(name) {
|
|
17
|
+
const match = name.match(CONNECTION_NAME_REGEX);
|
|
18
|
+
if (!match || typeof match.groups === undefined) {
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
const { projectId, location, id } = match.groups;
|
|
22
|
+
return {
|
|
23
|
+
projectId,
|
|
24
|
+
location,
|
|
25
|
+
id,
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
exports.parseConnectionName = parseConnectionName;
|
|
29
|
+
const gcbPollerOptions = {
|
|
30
|
+
apiOrigin: api_1.cloudbuildOrigin,
|
|
31
|
+
apiVersion: "v2",
|
|
32
|
+
masterTimeout: 25 * 60 * 1000,
|
|
33
|
+
maxBackoff: 10000,
|
|
34
|
+
};
|
|
35
|
+
function extractRepoSlugFromUri(remoteUri) {
|
|
36
|
+
const match = /github.com\/(.+).git/.exec(remoteUri);
|
|
37
|
+
if (!match) {
|
|
38
|
+
return undefined;
|
|
39
|
+
}
|
|
40
|
+
return match[1];
|
|
41
|
+
}
|
|
42
|
+
function generateRepositoryId(remoteUri) {
|
|
43
|
+
return extractRepoSlugFromUri(remoteUri)?.replaceAll("/", "-");
|
|
44
|
+
}
|
|
45
|
+
function generateConnectionId() {
|
|
46
|
+
const randomHash = Math.random().toString(36).slice(6);
|
|
47
|
+
return `apphosting-github-conn-${randomHash}`;
|
|
48
|
+
}
|
|
49
|
+
async function linkGitHubRepository(projectId, location) {
|
|
50
|
+
utils.logBullet(clc.bold(`${clc.yellow("===")} Set up a GitHub connection`));
|
|
51
|
+
const existingConns = await listAppHostingConnections(projectId);
|
|
52
|
+
if (existingConns.length < 1) {
|
|
53
|
+
const grantSuccess = await promptSecretManagerAdminGrant(projectId);
|
|
54
|
+
if (!grantSuccess) {
|
|
55
|
+
throw new error_1.FirebaseError("Insufficient IAM permissions to create a new connection to GitHub");
|
|
56
|
+
}
|
|
57
|
+
let oauthConn = await getOrCreateConnection(projectId, location, APPHOSTING_OAUTH_CONN_NAME);
|
|
58
|
+
while (oauthConn.installationState.stage === "PENDING_USER_OAUTH") {
|
|
59
|
+
oauthConn = await promptConnectionAuth(oauthConn);
|
|
60
|
+
}
|
|
61
|
+
const connectionId = generateConnectionId();
|
|
62
|
+
const conn = await createConnection(projectId, location, connectionId, {
|
|
63
|
+
authorizerCredential: oauthConn.githubConfig?.authorizerCredential,
|
|
64
|
+
});
|
|
65
|
+
let refreshedConn = conn;
|
|
66
|
+
while (refreshedConn.installationState.stage !== "COMPLETE") {
|
|
67
|
+
refreshedConn = await promptAppInstall(conn);
|
|
68
|
+
}
|
|
69
|
+
existingConns.push(refreshedConn);
|
|
70
|
+
}
|
|
71
|
+
let { remoteUri, connection } = await promptRepositoryUri(projectId, existingConns);
|
|
72
|
+
while (remoteUri === "") {
|
|
73
|
+
await utils.openInBrowser("https://github.com/apps/google-cloud-build/installations/new");
|
|
74
|
+
await (0, prompt_1.promptOnce)({
|
|
75
|
+
type: "input",
|
|
76
|
+
message: "Press ENTER once you have finished configuring your installation's access settings.",
|
|
77
|
+
});
|
|
78
|
+
const selection = await promptRepositoryUri(projectId, existingConns);
|
|
79
|
+
remoteUri = selection.remoteUri;
|
|
80
|
+
connection = selection.connection;
|
|
81
|
+
}
|
|
82
|
+
const { id: connectionId } = parseConnectionName(connection.name);
|
|
83
|
+
await getOrCreateConnection(projectId, location, connectionId, {
|
|
84
|
+
authorizerCredential: connection.githubConfig?.authorizerCredential,
|
|
85
|
+
appInstallationId: connection.githubConfig?.appInstallationId,
|
|
86
|
+
});
|
|
87
|
+
const repo = await getOrCreateRepository(projectId, location, connectionId, remoteUri);
|
|
88
|
+
utils.logSuccess(`Successfully linked GitHub repository at remote URI`);
|
|
89
|
+
utils.logSuccess(`\t${remoteUri}`);
|
|
90
|
+
return repo;
|
|
91
|
+
}
|
|
92
|
+
exports.linkGitHubRepository = linkGitHubRepository;
|
|
93
|
+
async function promptRepositoryUri(projectId, connections) {
|
|
94
|
+
const remoteUriToConnection = {};
|
|
95
|
+
for (const conn of connections) {
|
|
96
|
+
const { location, id } = parseConnectionName(conn.name);
|
|
97
|
+
const resp = await gcb.fetchLinkableRepositories(projectId, location, id);
|
|
98
|
+
if (resp.repositories && resp.repositories.length > 0) {
|
|
99
|
+
for (const repo of resp.repositories) {
|
|
100
|
+
remoteUriToConnection[repo.remoteUri] = conn;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
const choices = Object.keys(remoteUriToConnection).map((remoteUri) => ({
|
|
105
|
+
name: extractRepoSlugFromUri(remoteUri) || remoteUri,
|
|
106
|
+
value: remoteUri,
|
|
107
|
+
}));
|
|
108
|
+
choices.push({
|
|
109
|
+
name: "Missing a repo? Select this option to configure your installation's access settings",
|
|
110
|
+
value: "",
|
|
111
|
+
});
|
|
112
|
+
const remoteUri = await (0, prompt_1.promptOnce)({
|
|
113
|
+
type: "list",
|
|
114
|
+
message: "Which of the following repositories would you like to deploy?",
|
|
115
|
+
choices,
|
|
116
|
+
});
|
|
117
|
+
return { remoteUri, connection: remoteUriToConnection[remoteUri] };
|
|
118
|
+
}
|
|
119
|
+
async function promptSecretManagerAdminGrant(projectId) {
|
|
120
|
+
const projectNumber = await (0, getProjectNumber_1.getProjectNumber)({ projectId });
|
|
121
|
+
const cbsaEmail = gcb.serviceAgentEmail(projectNumber);
|
|
122
|
+
const alreadyGranted = await rm.serviceAccountHasRoles(projectId, cbsaEmail, ["roles/secretmanager.admin"], true);
|
|
123
|
+
if (alreadyGranted) {
|
|
124
|
+
return true;
|
|
125
|
+
}
|
|
126
|
+
utils.logBullet("To create a new GitHub connection, Secret Manager Admin role (roles/secretmanager.admin) is required on the Cloud Build Service Agent.");
|
|
127
|
+
const grant = await (0, prompt_1.promptOnce)({
|
|
128
|
+
type: "confirm",
|
|
129
|
+
message: "Grant the required role to the Cloud Build Service Agent?",
|
|
130
|
+
});
|
|
131
|
+
if (!grant) {
|
|
132
|
+
utils.logBullet("You, or your project administrator, should run the following command to grant the required role:\n\n" +
|
|
133
|
+
"You, or your project adminstrator, can run the following command to grant the required role manually:\n\n" +
|
|
134
|
+
`\tgcloud projects add-iam-policy-binding ${projectId} \\\n` +
|
|
135
|
+
`\t --member="serviceAccount:${cbsaEmail} \\\n` +
|
|
136
|
+
`\t --role="roles/secretmanager.admin\n`);
|
|
137
|
+
return false;
|
|
138
|
+
}
|
|
139
|
+
await rm.addServiceAccountToRoles(projectId, cbsaEmail, ["roles/secretmanager.admin"], true);
|
|
140
|
+
utils.logSuccess("Successfully granted the required role to the Cloud Build Service Agent!");
|
|
141
|
+
return true;
|
|
142
|
+
}
|
|
143
|
+
async function promptConnectionAuth(conn) {
|
|
144
|
+
utils.logBullet("You must authorize the Cloud Build GitHub app.");
|
|
145
|
+
utils.logBullet("Sign in to GitHub and authorize Cloud Build GitHub app:");
|
|
146
|
+
const { url, cleanup } = await utils.openInBrowserPopup(conn.installationState.actionUri, "Authorize the GitHub app");
|
|
147
|
+
utils.logBullet(`\t${url}`);
|
|
148
|
+
await (0, prompt_1.promptOnce)({
|
|
149
|
+
type: "input",
|
|
150
|
+
message: "Press Enter once you have authorized the app",
|
|
151
|
+
});
|
|
152
|
+
cleanup();
|
|
153
|
+
const { projectId, location, id } = parseConnectionName(conn.name);
|
|
154
|
+
return await gcb.getConnection(projectId, location, id);
|
|
155
|
+
}
|
|
156
|
+
async function promptAppInstall(conn) {
|
|
157
|
+
utils.logBullet("Install the Cloud Build GitHub app to enable access to GitHub repositories");
|
|
158
|
+
const targetUri = conn.installationState.actionUri.replace("install_v2", "direct_install_v2");
|
|
159
|
+
utils.logBullet(targetUri);
|
|
160
|
+
await utils.openInBrowser(targetUri);
|
|
161
|
+
await (0, prompt_1.promptOnce)({
|
|
162
|
+
type: "input",
|
|
163
|
+
message: "Press Enter once you have installed or configured the Cloud Build GitHub app to access your GitHub repo.",
|
|
164
|
+
});
|
|
165
|
+
const { projectId, location, id } = parseConnectionName(conn.name);
|
|
166
|
+
return await gcb.getConnection(projectId, location, id);
|
|
167
|
+
}
|
|
168
|
+
async function createConnection(projectId, location, connectionId, githubConfig) {
|
|
169
|
+
const op = await gcb.createConnection(projectId, location, connectionId, githubConfig);
|
|
170
|
+
const conn = await poller.pollOperation({
|
|
171
|
+
...gcbPollerOptions,
|
|
172
|
+
pollerName: `create-${location}-${connectionId}`,
|
|
173
|
+
operationResourceName: op.name,
|
|
174
|
+
});
|
|
175
|
+
return conn;
|
|
176
|
+
}
|
|
177
|
+
exports.createConnection = createConnection;
|
|
178
|
+
async function getOrCreateConnection(projectId, location, connectionId, githubConfig) {
|
|
179
|
+
let conn;
|
|
180
|
+
try {
|
|
181
|
+
conn = await gcb.getConnection(projectId, location, connectionId);
|
|
182
|
+
}
|
|
183
|
+
catch (err) {
|
|
184
|
+
if (err.status === 404) {
|
|
185
|
+
conn = await createConnection(projectId, location, connectionId, githubConfig);
|
|
186
|
+
}
|
|
187
|
+
else {
|
|
188
|
+
throw err;
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
return conn;
|
|
192
|
+
}
|
|
193
|
+
exports.getOrCreateConnection = getOrCreateConnection;
|
|
194
|
+
async function getOrCreateRepository(projectId, location, connectionId, remoteUri) {
|
|
195
|
+
const repositoryId = generateRepositoryId(remoteUri);
|
|
196
|
+
if (!repositoryId) {
|
|
197
|
+
throw new error_1.FirebaseError(`Failed to generate repositoryId for URI "${remoteUri}".`);
|
|
198
|
+
}
|
|
199
|
+
let repo;
|
|
200
|
+
try {
|
|
201
|
+
repo = await gcb.getRepository(projectId, location, connectionId, repositoryId);
|
|
202
|
+
}
|
|
203
|
+
catch (err) {
|
|
204
|
+
if (err.status === 404) {
|
|
205
|
+
const op = await gcb.createRepository(projectId, location, connectionId, repositoryId, remoteUri);
|
|
206
|
+
repo = await poller.pollOperation({
|
|
207
|
+
...gcbPollerOptions,
|
|
208
|
+
pollerName: `create-${location}-${connectionId}-${repositoryId}`,
|
|
209
|
+
operationResourceName: op.name,
|
|
210
|
+
});
|
|
211
|
+
}
|
|
212
|
+
else {
|
|
213
|
+
throw err;
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
return repo;
|
|
217
|
+
}
|
|
218
|
+
exports.getOrCreateRepository = getOrCreateRepository;
|
|
219
|
+
async function listAppHostingConnections(projectId) {
|
|
220
|
+
const conns = await gcb.listConnections(projectId, "-");
|
|
221
|
+
return conns.filter((conn) => APPHOSTING_CONN_PATTERN.test(conn.name) &&
|
|
222
|
+
conn.installationState.stage === "COMPLETE" &&
|
|
223
|
+
!conn.disabled);
|
|
224
|
+
}
|
|
225
|
+
exports.listAppHostingConnections = listAppHostingConnections;
|
|
@@ -123,7 +123,7 @@ async function doSetup(setup, config, options) {
|
|
|
123
123
|
type: "list",
|
|
124
124
|
message: "In which region would you like to host server-side content, if applicable?",
|
|
125
125
|
default: constants_1.DEFAULT_REGION,
|
|
126
|
-
choices: constants_1.ALLOWED_SSR_REGIONS,
|
|
126
|
+
choices: constants_1.ALLOWED_SSR_REGIONS.filter((region) => region.recommended),
|
|
127
127
|
}, setup.hosting);
|
|
128
128
|
setup.config.hosting = {
|
|
129
129
|
source: setup.hosting.source,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.apphosting = exports.hostingGithub = exports.remoteconfig = exports.project = exports.extensions = exports.emulators = exports.storage = exports.hosting = exports.functions = exports.firestore = exports.database = exports.account = void 0;
|
|
4
4
|
var account_1 = require("./account");
|
|
5
5
|
Object.defineProperty(exports, "account", { enumerable: true, get: function () { return account_1.doSetup; } });
|
|
6
6
|
var database_1 = require("./database");
|
|
@@ -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
|
|
27
|
-
Object.defineProperty(exports, "
|
|
26
|
+
var apphosting_1 = require("./apphosting");
|
|
27
|
+
Object.defineProperty(exports, "apphosting", { enumerable: true, get: function () { return apphosting_1.doSetup; } });
|
package/lib/init/index.js
CHANGED
|
@@ -6,7 +6,6 @@ const clc = require("colorette");
|
|
|
6
6
|
const error_1 = require("../error");
|
|
7
7
|
const logger_1 = require("../logger");
|
|
8
8
|
const features = require("./features");
|
|
9
|
-
const experiments_1 = require("../experiments");
|
|
10
9
|
const featureFns = new Map([
|
|
11
10
|
["account", features.account],
|
|
12
11
|
["database", features.database],
|
|
@@ -20,9 +19,6 @@ const featureFns = new Map([
|
|
|
20
19
|
["remoteconfig", features.remoteconfig],
|
|
21
20
|
["hosting:github", features.hostingGithub],
|
|
22
21
|
]);
|
|
23
|
-
if ((0, experiments_1.isEnabled)("internalframeworks")) {
|
|
24
|
-
featureFns.set("internalframeworks", features.frameworks);
|
|
25
|
-
}
|
|
26
22
|
async function init(setup, config, options) {
|
|
27
23
|
const nextFeature = setup.features?.shift();
|
|
28
24
|
if (nextFeature) {
|
package/lib/localFunction.js
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.HTTPS_SENTINEL = void 0;
|
|
3
4
|
const uuid = require("uuid");
|
|
4
|
-
const request = require("request");
|
|
5
5
|
const encodeFirestoreValue_1 = require("./firestore/encodeFirestoreValue");
|
|
6
6
|
const utils = require("./utils");
|
|
7
|
+
const apiv2_1 = require("./apiv2");
|
|
8
|
+
exports.HTTPS_SENTINEL = "Request sent to function.";
|
|
7
9
|
class LocalFunction {
|
|
8
10
|
constructor(trigger, urls, controller) {
|
|
9
11
|
this.trigger = trigger;
|
|
@@ -27,15 +29,73 @@ class LocalFunction {
|
|
|
27
29
|
if (opts.instanceIdToken) {
|
|
28
30
|
headers["Firebase-Instance-ID-Token"] = opts.instanceIdToken;
|
|
29
31
|
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
32
|
+
if (!this.url) {
|
|
33
|
+
throw new Error("No URL provided");
|
|
34
|
+
}
|
|
35
|
+
const client = new apiv2_1.Client({ urlPrefix: this.url, auth: false });
|
|
36
|
+
void client
|
|
37
|
+
.post("", data, { headers })
|
|
38
|
+
.then((res) => {
|
|
39
|
+
this.requestCallBack(undefined, res, res.body);
|
|
40
|
+
})
|
|
41
|
+
.catch((err) => {
|
|
42
|
+
this.requestCallBack(err);
|
|
37
43
|
});
|
|
38
44
|
}
|
|
45
|
+
constructHttpsFunc() {
|
|
46
|
+
if (!this.url) {
|
|
47
|
+
throw new Error("No URL provided");
|
|
48
|
+
}
|
|
49
|
+
const callClient = new apiv2_1.Client({ urlPrefix: this.url, auth: false });
|
|
50
|
+
const verbFactory = (hasRequestBody, method) => {
|
|
51
|
+
return async (pathOrOptions, options) => {
|
|
52
|
+
const { path, opts } = this.extractArgs(pathOrOptions, options);
|
|
53
|
+
try {
|
|
54
|
+
const res = hasRequestBody
|
|
55
|
+
? await method(path, opts.body, toClientVerbOptions(opts))
|
|
56
|
+
: await method(path, toClientVerbOptions(opts));
|
|
57
|
+
this.requestCallBack(undefined, res, res.body);
|
|
58
|
+
}
|
|
59
|
+
catch (err) {
|
|
60
|
+
this.requestCallBack(err);
|
|
61
|
+
}
|
|
62
|
+
return exports.HTTPS_SENTINEL;
|
|
63
|
+
};
|
|
64
|
+
};
|
|
65
|
+
const shim = verbFactory(true, (path, json, opts) => {
|
|
66
|
+
const req = Object.assign(opts || {}, {
|
|
67
|
+
path: path,
|
|
68
|
+
body: json,
|
|
69
|
+
method: opts?.method || "GET",
|
|
70
|
+
});
|
|
71
|
+
return callClient.request(req);
|
|
72
|
+
});
|
|
73
|
+
const verbs = {
|
|
74
|
+
post: verbFactory(true, (path, json, opts) => callClient.post(path, json, opts)),
|
|
75
|
+
put: verbFactory(true, (path, json, opts) => callClient.put(path, json, opts)),
|
|
76
|
+
patch: verbFactory(true, (path, json, opts) => callClient.patch(path, json, opts)),
|
|
77
|
+
get: verbFactory(false, (path, opts) => callClient.get(path, opts)),
|
|
78
|
+
del: verbFactory(false, (path, opts) => callClient.delete(path, opts)),
|
|
79
|
+
delete: verbFactory(false, (path, opts) => callClient.delete(path, opts)),
|
|
80
|
+
options: verbFactory(false, (path, opts) => callClient.options(path, opts)),
|
|
81
|
+
};
|
|
82
|
+
return Object.assign(shim, verbs);
|
|
83
|
+
}
|
|
84
|
+
extractArgs(pathOrOptions, options) {
|
|
85
|
+
if (!pathOrOptions && !options) {
|
|
86
|
+
return { path: "/", opts: {} };
|
|
87
|
+
}
|
|
88
|
+
if (typeof pathOrOptions === "string") {
|
|
89
|
+
return { path: pathOrOptions, opts: options || {} };
|
|
90
|
+
}
|
|
91
|
+
if (typeof pathOrOptions !== "string" && !!pathOrOptions && !options) {
|
|
92
|
+
return { path: "/", opts: pathOrOptions };
|
|
93
|
+
}
|
|
94
|
+
if (typeof pathOrOptions !== "string" || !options) {
|
|
95
|
+
throw new Error(`Invalid argument combination: Expected a string and/or HttpsOptions, got ${typeof pathOrOptions} and ${typeof options}`);
|
|
96
|
+
}
|
|
97
|
+
return { path: "/", opts: {} };
|
|
98
|
+
}
|
|
39
99
|
constructAuth(auth, authType) {
|
|
40
100
|
if (auth?.admin || auth?.variable) {
|
|
41
101
|
return {
|
|
@@ -98,7 +158,7 @@ class LocalFunction {
|
|
|
98
158
|
if (err) {
|
|
99
159
|
return console.warn("\nERROR SENDING REQUEST: " + err);
|
|
100
160
|
}
|
|
101
|
-
const status = response ? response.
|
|
161
|
+
const status = response ? response.status + ", " : "";
|
|
102
162
|
let bodyString = body;
|
|
103
163
|
if (typeof bodyString === "string") {
|
|
104
164
|
try {
|
|
@@ -206,11 +266,7 @@ class LocalFunction {
|
|
|
206
266
|
return (data, opt) => this.constructCallableFunc(data, opt);
|
|
207
267
|
}
|
|
208
268
|
else {
|
|
209
|
-
return
|
|
210
|
-
callback: (...args) => this.requestCallBack(...args),
|
|
211
|
-
baseUrl: this.url,
|
|
212
|
-
uri: "",
|
|
213
|
-
});
|
|
269
|
+
return this.constructHttpsFunc();
|
|
214
270
|
}
|
|
215
271
|
}
|
|
216
272
|
else {
|
|
@@ -219,3 +275,10 @@ class LocalFunction {
|
|
|
219
275
|
}
|
|
220
276
|
}
|
|
221
277
|
exports.default = LocalFunction;
|
|
278
|
+
function toClientVerbOptions(opts) {
|
|
279
|
+
return {
|
|
280
|
+
method: opts.method,
|
|
281
|
+
headers: opts.headers,
|
|
282
|
+
queryParams: opts.qs,
|
|
283
|
+
};
|
|
284
|
+
}
|
package/lib/utils.js
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.openInBrowser = exports.connectableHostname = exports.randomInt = exports.debounce = exports.last = exports.cloneDeep = exports.groupBy = exports.assertIsStringOrUndefined = exports.assertIsNumber = exports.assertIsString = exports.thirtyDaysFromNow = exports.isRunningInWSL = exports.isVSCodeExtension = exports.isCloudEnvironment = exports.datetimeString = exports.createDestroyer = exports.promiseWithSpinner = exports.setupLoggers = exports.tryParse = exports.tryStringify = exports.promiseProps = exports.withTimeout = exports.promiseWhile = exports.promiseAllSettled = exports.getFunctionsEventProvider = exports.endpoint = exports.makeActiveProject = exports.streamToString = exports.stringToStream = exports.explainStdin = exports.allSettled = exports.reject = exports.logLabeledError = exports.logLabeledWarning = exports.logWarning = exports.logLabeledBullet = exports.logBullet = exports.logLabeledSuccess = exports.logSuccess = exports.addSubdomain = exports.addDatabaseNamespace = exports.getDatabaseViewDataUrl = exports.getDatabaseUrl = exports.envOverride = exports.getInheritedOption = exports.consoleUrl = exports.envOverrides = void 0;
|
|
3
|
+
exports.generateId = exports.getHostnameFromUrl = exports.openInBrowserPopup = exports.openInBrowser = exports.connectableHostname = exports.randomInt = exports.debounce = exports.last = exports.cloneDeep = exports.groupBy = exports.assertIsStringOrUndefined = exports.assertIsNumber = exports.assertIsString = exports.thirtyDaysFromNow = exports.isRunningInWSL = exports.isVSCodeExtension = exports.isCloudEnvironment = exports.datetimeString = exports.createDestroyer = exports.promiseWithSpinner = exports.setupLoggers = exports.tryParse = exports.tryStringify = exports.promiseProps = exports.withTimeout = exports.promiseWhile = exports.promiseAllSettled = exports.getFunctionsEventProvider = exports.endpoint = exports.makeActiveProject = exports.streamToString = exports.stringToStream = exports.explainStdin = exports.allSettled = exports.reject = exports.logLabeledError = exports.logLabeledWarning = exports.logWarning = exports.logLabeledBullet = exports.logBullet = exports.logLabeledSuccess = exports.logSuccess = exports.addSubdomain = exports.addDatabaseNamespace = exports.getDatabaseViewDataUrl = exports.getDatabaseUrl = exports.envOverride = exports.getInheritedOption = exports.consoleUrl = exports.envOverrides = void 0;
|
|
4
|
+
const fs = require("node:fs");
|
|
5
|
+
const path = require("node:path");
|
|
4
6
|
const _ = require("lodash");
|
|
5
7
|
const url = require("url");
|
|
8
|
+
const http = require("http");
|
|
6
9
|
const clc = require("colorette");
|
|
7
10
|
const open = require("open");
|
|
8
11
|
const ora = require("ora");
|
|
@@ -12,6 +15,7 @@ const winston = require("winston");
|
|
|
12
15
|
const triple_beam_1 = require("triple-beam");
|
|
13
16
|
const assert_1 = require("assert");
|
|
14
17
|
const stripAnsi = require("strip-ansi");
|
|
18
|
+
const portfinder_1 = require("portfinder");
|
|
15
19
|
const configstore_1 = require("./configstore");
|
|
16
20
|
const error_1 = require("./error");
|
|
17
21
|
const logger_1 = require("./logger");
|
|
@@ -486,3 +490,48 @@ async function openInBrowser(url) {
|
|
|
486
490
|
await open(url);
|
|
487
491
|
}
|
|
488
492
|
exports.openInBrowser = openInBrowser;
|
|
493
|
+
async function openInBrowserPopup(url, buttonText) {
|
|
494
|
+
const popupPage = fs
|
|
495
|
+
.readFileSync(path.join(__dirname, "../templates/popup.html"), { encoding: "utf-8" })
|
|
496
|
+
.replace("${url}", url)
|
|
497
|
+
.replace("${buttonText}", buttonText);
|
|
498
|
+
const port = await (0, portfinder_1.getPortPromise)();
|
|
499
|
+
const server = http.createServer((req, res) => {
|
|
500
|
+
res.writeHead(200, {
|
|
501
|
+
"Content-Length": popupPage.length,
|
|
502
|
+
"Content-Type": "text/html",
|
|
503
|
+
});
|
|
504
|
+
res.end(popupPage);
|
|
505
|
+
req.socket.destroy();
|
|
506
|
+
});
|
|
507
|
+
server.listen(port);
|
|
508
|
+
const popupPageUri = `http://localhost:${port}`;
|
|
509
|
+
await openInBrowser(popupPageUri);
|
|
510
|
+
return {
|
|
511
|
+
url: popupPageUri,
|
|
512
|
+
cleanup: () => {
|
|
513
|
+
server.close();
|
|
514
|
+
},
|
|
515
|
+
};
|
|
516
|
+
}
|
|
517
|
+
exports.openInBrowserPopup = openInBrowserPopup;
|
|
518
|
+
function getHostnameFromUrl(url) {
|
|
519
|
+
try {
|
|
520
|
+
return new URL(url).hostname;
|
|
521
|
+
}
|
|
522
|
+
catch (e) {
|
|
523
|
+
return null;
|
|
524
|
+
}
|
|
525
|
+
}
|
|
526
|
+
exports.getHostnameFromUrl = getHostnameFromUrl;
|
|
527
|
+
function generateId(n = 6) {
|
|
528
|
+
const letters = "abcdefghijklmnopqrstuvwxyz";
|
|
529
|
+
const allChars = "01234567890-abcdefghijklmnopqrstuvwxyz";
|
|
530
|
+
let id = letters[Math.floor(Math.random() * letters.length)];
|
|
531
|
+
for (let i = 1; i < n; i++) {
|
|
532
|
+
const idx = Math.floor(Math.random() * allChars.length);
|
|
533
|
+
id += allChars[idx];
|
|
534
|
+
}
|
|
535
|
+
return id;
|
|
536
|
+
}
|
|
537
|
+
exports.generateId = generateId;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "firebase-tools-with-isolate",
|
|
3
|
-
"version": "
|
|
4
|
-
"description": "Command-Line Interface for Firebase with
|
|
3
|
+
"version": "13.0.2-0",
|
|
4
|
+
"description": "Command-Line Interface for Firebase with monorepo support",
|
|
5
5
|
"main": "./lib/index.js",
|
|
6
6
|
"bin": {
|
|
7
7
|
"firebase": "lib/bin/firebase.js"
|
|
@@ -64,12 +64,16 @@
|
|
|
64
64
|
"websockets",
|
|
65
65
|
"synchronization"
|
|
66
66
|
],
|
|
67
|
-
"preferGlobal":
|
|
67
|
+
"preferGlobal": true,
|
|
68
68
|
"engines": {
|
|
69
|
-
"node": ">=18.0.0"
|
|
69
|
+
"node": ">=18.0.0 || >=20.0.0"
|
|
70
70
|
},
|
|
71
|
-
"author": "
|
|
71
|
+
"author": "Firebase (https://firebase.google.com/)",
|
|
72
72
|
"license": "MIT",
|
|
73
|
+
"bugs": {
|
|
74
|
+
"url": "https://github.com/firebase/firebase-tools/issues"
|
|
75
|
+
},
|
|
76
|
+
"homepage": "https://github.com/firebase/firebase-tools",
|
|
73
77
|
"nyc": {
|
|
74
78
|
"require": [
|
|
75
79
|
"ts-node/register"
|
|
@@ -113,7 +117,7 @@
|
|
|
113
117
|
"glob": "^7.1.2",
|
|
114
118
|
"google-auth-library": "^7.11.0",
|
|
115
119
|
"inquirer": "^8.2.0",
|
|
116
|
-
"isolate-package": "^1.
|
|
120
|
+
"isolate-package": "^1.8.0",
|
|
117
121
|
"js-yaml": "^3.13.1",
|
|
118
122
|
"jsonwebtoken": "^9.0.0",
|
|
119
123
|
"leven": "^3.1.0",
|
|
@@ -131,7 +135,6 @@
|
|
|
131
135
|
"portfinder": "^1.0.32",
|
|
132
136
|
"progress": "^2.0.3",
|
|
133
137
|
"proxy-agent": "^6.3.0",
|
|
134
|
-
"request": "^2.87.0",
|
|
135
138
|
"retry": "^0.13.1",
|
|
136
139
|
"rimraf": "^3.0.0",
|
|
137
140
|
"semver": "^7.5.2",
|
|
@@ -185,7 +188,6 @@
|
|
|
185
188
|
"@types/puppeteer": "^5.4.2",
|
|
186
189
|
"@types/react": "^18.0.20",
|
|
187
190
|
"@types/react-dom": "^18.0.6",
|
|
188
|
-
"@types/request": "^2.48.1",
|
|
189
191
|
"@types/retry": "^0.12.1",
|
|
190
192
|
"@types/rimraf": "^2.0.3",
|
|
191
193
|
"@types/semver": "^6.0.0",
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
<head>
|
|
2
|
+
<style>
|
|
3
|
+
div {
|
|
4
|
+
font-family: sans-serif;
|
|
5
|
+
}
|
|
6
|
+
#popup {
|
|
7
|
+
display: flex;
|
|
8
|
+
flex-direction: column;
|
|
9
|
+
justify-content: center;
|
|
10
|
+
align-items: center;
|
|
11
|
+
height: 100vh;
|
|
12
|
+
width: 100vw;
|
|
13
|
+
text-align: center;
|
|
14
|
+
}
|
|
15
|
+
#popup button {
|
|
16
|
+
display: inline-flex;
|
|
17
|
+
align-items: center;
|
|
18
|
+
justify-content: center;
|
|
19
|
+
border-radius: 0.375rem;
|
|
20
|
+
font-size: 1.5rem;
|
|
21
|
+
font-weight: 500;
|
|
22
|
+
height: 2.5rem;
|
|
23
|
+
padding: 0.5rem 1rem;
|
|
24
|
+
background-color: black;
|
|
25
|
+
color: white;
|
|
26
|
+
outline: none;
|
|
27
|
+
transition: background-color 150ms ease-in-out;
|
|
28
|
+
margin-bottom: 20px;
|
|
29
|
+
}
|
|
30
|
+
#popup button:hover {
|
|
31
|
+
background-color: #333;
|
|
32
|
+
}
|
|
33
|
+
#popup button:disabled {
|
|
34
|
+
opacity: 0.5;
|
|
35
|
+
pointer-events: none;
|
|
36
|
+
}
|
|
37
|
+
#message {
|
|
38
|
+
height: 20px;
|
|
39
|
+
margin-bottom: 20px;
|
|
40
|
+
color: gray;
|
|
41
|
+
font-size: 1.5rem;
|
|
42
|
+
}
|
|
43
|
+
</style>
|
|
44
|
+
</head>
|
|
45
|
+
<body>
|
|
46
|
+
<div id="popup">
|
|
47
|
+
<button id="popupBtn" onclick="openPopup()">${buttonText}</button>
|
|
48
|
+
<div id="message">(Close this window after authorizing the app)</div>
|
|
49
|
+
</div>
|
|
50
|
+
<script>
|
|
51
|
+
function openPopup() {
|
|
52
|
+
var w = window.open("${url}", "newwindow", "popup=1");
|
|
53
|
+
var m = document.getElementById("message");
|
|
54
|
+
var d = document.getElementById("popupBtn");
|
|
55
|
+
var timer = setInterval(function () {
|
|
56
|
+
if (w.closed) {
|
|
57
|
+
m.innerText = "You can close this page now";
|
|
58
|
+
d.disabled = true;
|
|
59
|
+
clearInterval(timer);
|
|
60
|
+
}
|
|
61
|
+
}, 1000);
|
|
62
|
+
}
|
|
63
|
+
</script>
|
|
64
|
+
</body>
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.command = void 0;
|
|
4
|
-
const marked_1 = require("marked");
|
|
5
|
-
const TerminalRenderer = require("marked-terminal");
|
|
6
|
-
const command_1 = require("../command");
|
|
7
|
-
const requireAuth_1 = require("../requireAuth");
|
|
8
|
-
const ext_dev_upload_1 = require("./ext-dev-upload");
|
|
9
|
-
const utils_1 = require("../utils");
|
|
10
|
-
const extensionsHelper_1 = require("../extensions/extensionsHelper");
|
|
11
|
-
marked_1.marked.setOptions({
|
|
12
|
-
renderer: new TerminalRenderer(),
|
|
13
|
-
});
|
|
14
|
-
exports.command = new command_1.Command("ext:dev:publish <extensionRef>")
|
|
15
|
-
.description(`Deprecated. Use ext:dev:upload instead`)
|
|
16
|
-
.option(`-s, --stage <stage>`, `release stage (supports "alpha", "beta", "rc", and "stable")`)
|
|
17
|
-
.option(`--repo <repo>`, `Public GitHub repo URI that contains the extension source`)
|
|
18
|
-
.option(`--ref <ref>`, `commit hash, branch, or tag to build from the repo (defaults to HEAD)`)
|
|
19
|
-
.option(`--root <root>`, `root directory that contains this extension (defaults to last uploaded root or "/" if none set)`)
|
|
20
|
-
.withForce()
|
|
21
|
-
.help("if you have not previously uploaded a version of this extension, this will " +
|
|
22
|
-
"create the extension. If you have previously uploaded a version of this extension, this version must " +
|
|
23
|
-
"be greater than previous versions.")
|
|
24
|
-
.before(requireAuth_1.requireAuth)
|
|
25
|
-
.before(extensionsHelper_1.ensureExtensionsPublisherApiEnabled)
|
|
26
|
-
.action(async (extensionRef, options) => {
|
|
27
|
-
(0, utils_1.logLabeledWarning)("Extensions", "ext:dev:publish has been deprecated and will be removed in the future. Please use ext:dev:upload instead.");
|
|
28
|
-
if (!options.repo && !options.ref && !options.root) {
|
|
29
|
-
options.local = true;
|
|
30
|
-
}
|
|
31
|
-
return (0, ext_dev_upload_1.uploadExtensionAction)(extensionRef, options);
|
|
32
|
-
});
|
package/lib/gcp/frameworks.js
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createBuild = exports.deleteBackend = exports.listBackends = exports.getBackend = exports.createBackend = exports.API_VERSION = void 0;
|
|
4
|
-
const apiv2_1 = require("../apiv2");
|
|
5
|
-
const api_1 = require("../api");
|
|
6
|
-
exports.API_VERSION = "v1alpha";
|
|
7
|
-
const client = new apiv2_1.Client({
|
|
8
|
-
urlPrefix: api_1.frameworksOrigin,
|
|
9
|
-
auth: true,
|
|
10
|
-
apiVersion: exports.API_VERSION,
|
|
11
|
-
});
|
|
12
|
-
async function createBackend(projectId, location, backendReqBoby, backendId) {
|
|
13
|
-
const res = await client.post(`projects/${projectId}/locations/${location}/backends`, backendReqBoby, { queryParams: { backendId } });
|
|
14
|
-
return res.body;
|
|
15
|
-
}
|
|
16
|
-
exports.createBackend = createBackend;
|
|
17
|
-
async function getBackend(projectId, location, backendId) {
|
|
18
|
-
const name = `projects/${projectId}/locations/${location}/backends/${backendId}`;
|
|
19
|
-
const res = await client.get(name);
|
|
20
|
-
return res.body;
|
|
21
|
-
}
|
|
22
|
-
exports.getBackend = getBackend;
|
|
23
|
-
async function listBackends(projectId, location) {
|
|
24
|
-
const name = `projects/${projectId}/locations/${location}/backends`;
|
|
25
|
-
const res = await client.get(name);
|
|
26
|
-
return res.body;
|
|
27
|
-
}
|
|
28
|
-
exports.listBackends = listBackends;
|
|
29
|
-
async function deleteBackend(projectId, location, backendId) {
|
|
30
|
-
const name = `projects/${projectId}/locations/${location}/backends/${backendId}`;
|
|
31
|
-
const res = await client.delete(name);
|
|
32
|
-
return res.body;
|
|
33
|
-
}
|
|
34
|
-
exports.deleteBackend = deleteBackend;
|
|
35
|
-
async function createBuild(projectId, location, backendId, buildInput) {
|
|
36
|
-
const buildId = buildInput.name;
|
|
37
|
-
const res = await client.post(`projects/${projectId}/locations/${location}/backends/${backendId}/builds`, buildInput, { queryParams: { buildId } });
|
|
38
|
-
return res.body;
|
|
39
|
-
}
|
|
40
|
-
exports.createBuild = createBuild;
|