firebase-tools 13.31.2 → 13.33.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/commands/apphosting-backends-create.js +6 -1
- package/lib/commands/apphosting-backends-delete.js +6 -2
- package/lib/commands/apphosting-backends-get.js +6 -2
- package/lib/commands/apphosting-backends-list.js +8 -4
- package/lib/commands/apphosting-builds-create.js +8 -4
- package/lib/commands/apphosting-builds-get.js +7 -1
- package/lib/commands/apphosting-rollouts-create.js +7 -2
- package/lib/commands/apphosting-rollouts-list.js +7 -2
- package/lib/commands/apps-init.js +1 -1
- package/lib/commands/emulators-start.js +3 -2
- package/lib/dataconnect/client.js +5 -16
- package/lib/dataconnect/schemaMigration.js +1 -1
- package/lib/deploy/dataconnect/deploy.js +13 -4
- package/lib/deploy/functions/release/planner.js +1 -0
- package/lib/deploy/functions/runtimes/discovery/index.js +8 -3
- package/lib/deploy/functions/runtimes/python/index.js +1 -1
- package/lib/deploy/index.js +25 -10
- package/lib/deploy/lifecycleHooks.js +2 -3
- package/lib/emulator/constants.js +1 -0
- package/lib/emulator/downloadableEmulators.js +9 -9
- package/lib/emulator/env.js +2 -0
- package/lib/emulator/hub.js +1 -1
- package/lib/frameworks/vite/index.js +1 -1
- package/lib/gcp/cloudfunctions.js +15 -0
- package/lib/gcp/cloudfunctionsv2.js +3 -2
- package/lib/hosting/implicitInit.js +7 -3
- package/lib/init/features/dataconnect/index.js +24 -11
- package/lib/management/apps.js +4 -1
- package/lib/vsCodeUtils.js +7 -3
- package/package.json +1 -1
|
@@ -8,15 +8,20 @@ const backend_1 = require("../apphosting/backend");
|
|
|
8
8
|
const apphosting_1 = require("../gcp/apphosting");
|
|
9
9
|
const firedata_1 = require("../gcp/firedata");
|
|
10
10
|
const requireTosAcceptance_1 = require("../requireTosAcceptance");
|
|
11
|
+
const utils_1 = require("../utils");
|
|
11
12
|
exports.command = new command_1.Command("apphosting:backends:create")
|
|
12
13
|
.description("create a Firebase App Hosting backend")
|
|
13
14
|
.option("-a, --app <webAppId>", "specify an existing Firebase web app's ID to associate your App Hosting backend with")
|
|
14
|
-
.option("-l, --location <location>", "specify the location of the backend"
|
|
15
|
+
.option("-l, --location <location>", "specify the location of the backend")
|
|
15
16
|
.option("-s, --service-account <serviceAccount>", "specify the service account used to run the server", "")
|
|
16
17
|
.before(apphosting_1.ensureApiEnabled)
|
|
17
18
|
.before(requireInteractive_1.default)
|
|
18
19
|
.before((0, requireTosAcceptance_1.requireTosAcceptance)(firedata_1.APPHOSTING_TOS_ID))
|
|
19
20
|
.action(async (options) => {
|
|
21
|
+
if (options.location !== undefined) {
|
|
22
|
+
(0, utils_1.logWarning)("--location is being removed in the next major release. " +
|
|
23
|
+
"The CLI will prompt for a Primary Region where appropriate.");
|
|
24
|
+
}
|
|
20
25
|
const projectId = (0, projectUtils_1.needProjectId)(options);
|
|
21
26
|
const webAppId = options.app;
|
|
22
27
|
const location = options.location;
|
|
@@ -12,12 +12,16 @@ const backend_1 = require("../apphosting/backend");
|
|
|
12
12
|
const ora = require("ora");
|
|
13
13
|
exports.command = new command_1.Command("apphosting:backends:delete <backend>")
|
|
14
14
|
.description("delete a Firebase App Hosting backend")
|
|
15
|
-
.option("-l, --location <location>", "specify the location of the backend"
|
|
15
|
+
.option("-l, --location <location>", "specify the location of the backend")
|
|
16
16
|
.withForce()
|
|
17
17
|
.before(apphosting.ensureApiEnabled)
|
|
18
18
|
.action(async (backendId, options) => {
|
|
19
|
+
var _a;
|
|
19
20
|
const projectId = (0, projectUtils_1.needProjectId)(options);
|
|
20
|
-
|
|
21
|
+
if (options.location !== undefined) {
|
|
22
|
+
utils.logWarning("--location is being removed in the next major release.");
|
|
23
|
+
}
|
|
24
|
+
let location = (_a = options.location) !== null && _a !== void 0 ? _a : "-";
|
|
21
25
|
let backend;
|
|
22
26
|
if (location === "-" || location === "") {
|
|
23
27
|
backend = await (0, backend_1.getBackendForAmbiguousLocation)(projectId, backendId, "Please select the location of the backend you'd like to delete:");
|
|
@@ -9,11 +9,15 @@ const apphosting = require("../gcp/apphosting");
|
|
|
9
9
|
const apphosting_backends_list_1 = require("./apphosting-backends-list");
|
|
10
10
|
exports.command = new command_1.Command("apphosting:backends:get <backend>")
|
|
11
11
|
.description("print info about a Firebase App Hosting backend")
|
|
12
|
-
.option("-l, --location <location>", "backend location"
|
|
12
|
+
.option("-l, --location <location>", "backend location")
|
|
13
13
|
.before(apphosting.ensureApiEnabled)
|
|
14
14
|
.action(async (backend, options) => {
|
|
15
|
+
var _a;
|
|
15
16
|
const projectId = (0, projectUtils_1.needProjectId)(options);
|
|
16
|
-
|
|
17
|
+
if (options.location !== undefined) {
|
|
18
|
+
(0, utils_1.logWarning)("--location is being removed in the next major release.");
|
|
19
|
+
}
|
|
20
|
+
const location = (_a = options.location) !== null && _a !== void 0 ? _a : "-";
|
|
17
21
|
let backendsList = [];
|
|
18
22
|
try {
|
|
19
23
|
if (location !== "-") {
|
|
@@ -8,15 +8,19 @@ const logger_1 = require("../logger");
|
|
|
8
8
|
const projectUtils_1 = require("../projectUtils");
|
|
9
9
|
const apphosting = require("../gcp/apphosting");
|
|
10
10
|
const Table = require("cli-table3");
|
|
11
|
+
const utils_2 = require("../utils");
|
|
11
12
|
const TABLE_HEAD = ["Backend", "Repository", "URL", "Location", "Updated Date"];
|
|
12
13
|
exports.command = new command_1.Command("apphosting:backends:list")
|
|
13
14
|
.description("list Firebase App Hosting backends")
|
|
14
|
-
.option("-l, --location <location>", "list backends in the specified location"
|
|
15
|
+
.option("-l, --location <location>", "list backends in the specified location")
|
|
15
16
|
.before(apphosting.ensureApiEnabled)
|
|
16
17
|
.action(async (options) => {
|
|
17
|
-
var _a;
|
|
18
|
+
var _a, _b;
|
|
19
|
+
if (options.location !== undefined) {
|
|
20
|
+
(0, utils_2.logWarning)("--location is being removed in the next major release.");
|
|
21
|
+
}
|
|
18
22
|
const projectId = (0, projectUtils_1.needProjectId)(options);
|
|
19
|
-
const location = options.location;
|
|
23
|
+
const location = (_a = options.location) !== null && _a !== void 0 ? _a : "-";
|
|
20
24
|
let backendRes;
|
|
21
25
|
try {
|
|
22
26
|
backendRes = await apphosting.listBackends(projectId, location);
|
|
@@ -24,7 +28,7 @@ exports.command = new command_1.Command("apphosting:backends:list")
|
|
|
24
28
|
catch (err) {
|
|
25
29
|
throw new error_1.FirebaseError(`Unable to list backends present for project: ${projectId}. Please check the parameters you have provided.`, { original: err });
|
|
26
30
|
}
|
|
27
|
-
const backends = (
|
|
31
|
+
const backends = (_b = backendRes.backends) !== null && _b !== void 0 ? _b : [];
|
|
28
32
|
printBackendsTable(backends);
|
|
29
33
|
return backends;
|
|
30
34
|
});
|
|
@@ -5,19 +5,23 @@ const apphosting = require("../gcp/apphosting");
|
|
|
5
5
|
const logger_1 = require("../logger");
|
|
6
6
|
const command_1 = require("../command");
|
|
7
7
|
const projectUtils_1 = require("../projectUtils");
|
|
8
|
+
const utils_1 = require("../utils");
|
|
8
9
|
exports.command = new command_1.Command("apphosting:builds:create <backendId>")
|
|
9
10
|
.description("create a build for an App Hosting backend")
|
|
10
|
-
.option("-l, --location <location>", "specify the region of the backend"
|
|
11
|
+
.option("-l, --location <location>", "specify the region of the backend")
|
|
11
12
|
.option("-i, --id <buildId>", "id of the build (defaults to autogenerating a random id)", "")
|
|
12
13
|
.option("-b, --branch <branch>", "repository branch to deploy (defaults to 'main')", "main")
|
|
13
14
|
.before(apphosting.ensureApiEnabled)
|
|
14
15
|
.action(async (backendId, options) => {
|
|
15
|
-
var _a;
|
|
16
|
+
var _a, _b;
|
|
16
17
|
const projectId = (0, projectUtils_1.needProjectId)(options);
|
|
17
|
-
|
|
18
|
+
if (options.location !== undefined) {
|
|
19
|
+
(0, utils_1.logWarning)("--location is being removed in the next major release.");
|
|
20
|
+
}
|
|
21
|
+
const location = (_a = options.location) !== null && _a !== void 0 ? _a : "us-central1";
|
|
18
22
|
const buildId = options.buildId ||
|
|
19
23
|
(await apphosting.getNextRolloutId(projectId, location, backendId));
|
|
20
|
-
const branch = (
|
|
24
|
+
const branch = (_b = options.branch) !== null && _b !== void 0 ? _b : "main";
|
|
21
25
|
const op = await apphosting.createBuild(projectId, location, backendId, buildId, {
|
|
22
26
|
source: {
|
|
23
27
|
codebase: {
|
|
@@ -5,11 +5,17 @@ const apphosting = require("../gcp/apphosting");
|
|
|
5
5
|
const logger_1 = require("../logger");
|
|
6
6
|
const command_1 = require("../command");
|
|
7
7
|
const projectUtils_1 = require("../projectUtils");
|
|
8
|
+
const utils_1 = require("../utils");
|
|
8
9
|
exports.command = new command_1.Command("apphosting:builds:get <backendId> <buildId>")
|
|
9
10
|
.description("get a build for an App Hosting backend")
|
|
10
|
-
.option("-l, --location <location>", "specify the region of the backend"
|
|
11
|
+
.option("-l, --location <location>", "specify the region of the backend")
|
|
11
12
|
.before(apphosting.ensureApiEnabled)
|
|
12
13
|
.action(async (backendId, buildId, options) => {
|
|
14
|
+
var _a;
|
|
15
|
+
if (options.location !== undefined) {
|
|
16
|
+
(0, utils_1.logWarning)("--location is being removed in the next major release.");
|
|
17
|
+
}
|
|
18
|
+
options.location = (_a = options.location) !== null && _a !== void 0 ? _a : "us-central";
|
|
13
19
|
const projectId = (0, projectUtils_1.needProjectId)(options);
|
|
14
20
|
const location = options.location;
|
|
15
21
|
const build = await apphosting.getBuild(projectId, location, backendId, buildId);
|
|
@@ -6,16 +6,21 @@ const command_1 = require("../command");
|
|
|
6
6
|
const projectUtils_1 = require("../projectUtils");
|
|
7
7
|
const error_1 = require("../error");
|
|
8
8
|
const rollout_1 = require("../apphosting/rollout");
|
|
9
|
+
const utils_1 = require("../utils");
|
|
9
10
|
exports.command = new command_1.Command("apphosting:rollouts:create <backendId>")
|
|
10
11
|
.description("create a rollout using a build for an App Hosting backend")
|
|
11
|
-
.option("-l, --location <location>", "specify the region of the backend"
|
|
12
|
+
.option("-l, --location <location>", "specify the region of the backend")
|
|
12
13
|
.option("-b, --git-branch <gitBranch>", "repository branch to deploy (mutually exclusive with -g)")
|
|
13
14
|
.option("-g, --git-commit <gitCommit>", "git commit to deploy (mutually exclusive with -b)")
|
|
14
15
|
.withForce("Skip confirmation before creating rollout")
|
|
15
16
|
.before(apphosting.ensureApiEnabled)
|
|
16
17
|
.action(async (backendId, options) => {
|
|
18
|
+
var _a;
|
|
17
19
|
const projectId = (0, projectUtils_1.needProjectId)(options);
|
|
18
|
-
|
|
20
|
+
if (options.location !== undefined) {
|
|
21
|
+
(0, utils_1.logWarning)("--location is being removed in the next major release.");
|
|
22
|
+
}
|
|
23
|
+
const location = (_a = options.location) !== null && _a !== void 0 ? _a : "-";
|
|
19
24
|
const branch = options.gitBranch;
|
|
20
25
|
const commit = options.gitCommit;
|
|
21
26
|
if (branch && commit) {
|
|
@@ -5,13 +5,18 @@ const apphosting = require("../gcp/apphosting");
|
|
|
5
5
|
const logger_1 = require("../logger");
|
|
6
6
|
const command_1 = require("../command");
|
|
7
7
|
const projectUtils_1 = require("../projectUtils");
|
|
8
|
+
const utils_1 = require("../utils");
|
|
8
9
|
exports.command = new command_1.Command("apphosting:rollouts:list <backendId>")
|
|
9
10
|
.description("list rollouts of an App Hosting backend")
|
|
10
|
-
.option("-l, --location <location>", "region of the rollouts (defaults to listing rollouts from all regions)"
|
|
11
|
+
.option("-l, --location <location>", "region of the rollouts (defaults to listing rollouts from all regions)")
|
|
11
12
|
.before(apphosting.ensureApiEnabled)
|
|
12
13
|
.action(async (backendId, options) => {
|
|
14
|
+
var _a;
|
|
15
|
+
if (options.location !== undefined) {
|
|
16
|
+
(0, utils_1.logWarning)("--location is being removed in the next major release.");
|
|
17
|
+
}
|
|
13
18
|
const projectId = (0, projectUtils_1.needProjectId)(options);
|
|
14
|
-
const location = options.location;
|
|
19
|
+
const location = (_a = options.location) !== null && _a !== void 0 ? _a : "-";
|
|
15
20
|
const rollouts = await apphosting.listRollouts(projectId, location, backendId);
|
|
16
21
|
if (rollouts.unreachable) {
|
|
17
22
|
logger_1.logger.error(`WARNING: the following locations were unreachable: ${rollouts.unreachable.join(", ")}`);
|
|
@@ -71,7 +71,7 @@ exports.command = new command_1.Command("apps:init [platform] [appId]")
|
|
|
71
71
|
catch (e) {
|
|
72
72
|
if (e.message.includes("associated with this Firebase project")) {
|
|
73
73
|
const projectId = (0, projectUtils_1.needProjectId)(options);
|
|
74
|
-
await (0, apps_1.sdkInit)(
|
|
74
|
+
await (0, apps_1.sdkInit)(detectedPlatform, Object.assign(Object.assign({}, options), { project: projectId }));
|
|
75
75
|
}
|
|
76
76
|
else {
|
|
77
77
|
throw e;
|
|
@@ -105,11 +105,12 @@ function printEmulatorOverview(options) {
|
|
|
105
105
|
const extensionsEmulatorInstance = registry_1.EmulatorRegistry.get(types_1.Emulators.EXTENSIONS);
|
|
106
106
|
extensionsTable = extensionsEmulatorInstance.extensionsInfoTable();
|
|
107
107
|
}
|
|
108
|
+
const hubInfo = registry_1.EmulatorRegistry.getInfo(types_1.Emulators.HUB);
|
|
108
109
|
logger_1.logger.info(`\n${successMessageTable}
|
|
109
110
|
|
|
110
111
|
${emulatorsTable}
|
|
111
|
-
${
|
|
112
|
-
? clc.blackBright(
|
|
112
|
+
${hubInfo
|
|
113
|
+
? clc.blackBright(` Emulator Hub host: ${hubInfo.host} port: ${hubInfo.port}`)
|
|
113
114
|
: clc.blackBright(" Emulator Hub not running.")}
|
|
114
115
|
${clc.blackBright(" Other reserved ports:")} ${reservedPortsString}
|
|
115
116
|
${extensionsTable}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.upsertConnector = exports.listConnectors = exports.deleteConnector = exports.getConnector = exports.deleteSchema = exports.upsertSchema = exports.getSchema = exports.
|
|
3
|
+
exports.upsertConnector = exports.listConnectors = exports.deleteConnector = exports.getConnector = exports.deleteSchema = exports.upsertSchema = exports.getSchema = exports.deleteService = exports.createService = exports.listAllServices = exports.getService = exports.listLocations = void 0;
|
|
4
4
|
const api_1 = require("../api");
|
|
5
5
|
const apiv2_1 = require("../apiv2");
|
|
6
6
|
const operationPoller = require("../operation-poller");
|
|
@@ -46,7 +46,9 @@ async function createService(projectId, locationId, serviceId) {
|
|
|
46
46
|
}
|
|
47
47
|
exports.createService = createService;
|
|
48
48
|
async function deleteService(serviceName) {
|
|
49
|
-
const op = await dataconnectClient().delete(serviceName
|
|
49
|
+
const op = await dataconnectClient().delete(serviceName, {
|
|
50
|
+
queryParams: { force: "true" },
|
|
51
|
+
});
|
|
50
52
|
const pollRes = await operationPoller.pollOperation({
|
|
51
53
|
apiOrigin: (0, api_1.dataconnectOrigin)(),
|
|
52
54
|
apiVersion: DATACONNECT_API_VERSION,
|
|
@@ -54,20 +56,7 @@ async function deleteService(serviceName) {
|
|
|
54
56
|
});
|
|
55
57
|
return pollRes;
|
|
56
58
|
}
|
|
57
|
-
|
|
58
|
-
const connectors = await listConnectors(serviceName);
|
|
59
|
-
await Promise.all(connectors.map(async (c) => deleteConnector(c.name)));
|
|
60
|
-
try {
|
|
61
|
-
await deleteSchema(serviceName);
|
|
62
|
-
}
|
|
63
|
-
catch (err) {
|
|
64
|
-
if (err.status !== 404) {
|
|
65
|
-
throw err;
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
await deleteService(serviceName);
|
|
69
|
-
}
|
|
70
|
-
exports.deleteServiceAndChildResources = deleteServiceAndChildResources;
|
|
59
|
+
exports.deleteService = deleteService;
|
|
71
60
|
async function getSchema(serviceName) {
|
|
72
61
|
try {
|
|
73
62
|
const res = await dataconnectClient().get(`${serviceName}/schemas/${types.SCHEMA_ID}`);
|
|
@@ -314,7 +314,7 @@ async function promptForInvalidConnectorError(options, serviceName, invalidConne
|
|
|
314
314
|
return true;
|
|
315
315
|
}
|
|
316
316
|
if (!options.nonInteractive &&
|
|
317
|
-
(await (0, prompt_1.confirm)(Object.assign(Object.assign({}, options), { message: `Would you like to delete and recreate these connectors? This will cause ${clc.red(`downtime
|
|
317
|
+
(await (0, prompt_1.confirm)(Object.assign(Object.assign({}, options), { message: `Would you like to delete and recreate these connectors? This will cause ${clc.red(`downtime`)}.` })))) {
|
|
318
318
|
return true;
|
|
319
319
|
}
|
|
320
320
|
const cmd = suggestedCommand(serviceName, invalidConnectors);
|
|
@@ -9,6 +9,7 @@ const names_1 = require("../../dataconnect/names");
|
|
|
9
9
|
const api_1 = require("../../api");
|
|
10
10
|
const ensureApiEnabled = require("../../ensureApiEnabled");
|
|
11
11
|
const node_path_1 = require("node:path");
|
|
12
|
+
const prompt_1 = require("../../prompt");
|
|
12
13
|
async function default_1(context, options) {
|
|
13
14
|
const projectId = (0, projectUtils_1.needProjectId)(options);
|
|
14
15
|
const serviceInfos = context.dataconnect.serviceInfos;
|
|
@@ -33,10 +34,18 @@ async function default_1(context, options) {
|
|
|
33
34
|
utils.logLabeledSuccess("dataconnect", `Created service ${s.serviceName}`);
|
|
34
35
|
}));
|
|
35
36
|
if (servicesToDelete.length) {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
.
|
|
39
|
-
|
|
37
|
+
if (await (0, prompt_1.confirm)({
|
|
38
|
+
force: options.force,
|
|
39
|
+
nonInteractive: options.nonInteractive,
|
|
40
|
+
message: `The following services exist on ${projectId} but are not listed in your 'firebase.json'\n${servicesToDelete
|
|
41
|
+
.map((s) => s.name)
|
|
42
|
+
.join("\n")}\nWould you like to delete these services?`,
|
|
43
|
+
})) {
|
|
44
|
+
await Promise.all(servicesToDelete.map(async (s) => {
|
|
45
|
+
await client.deleteService(s.name);
|
|
46
|
+
utils.logLabeledSuccess("dataconnect", `Deleted service ${s.name}`);
|
|
47
|
+
}));
|
|
48
|
+
}
|
|
40
49
|
}
|
|
41
50
|
utils.logLabeledBullet("dataconnect", "Checking for CloudSQL resources...");
|
|
42
51
|
await Promise.all(serviceInfos
|
|
@@ -16,6 +16,7 @@ function calculateChangesets(want, have, keyFn, deleteAll) {
|
|
|
16
16
|
.filter((id) => deleteAll || (0, deploymentTool_1.isFirebaseManaged)(have[id].labels || {}))
|
|
17
17
|
.map((id) => have[id]), keyFn);
|
|
18
18
|
const toSkipPredicate = (id) => !!(!want[id].targetedByOnly &&
|
|
19
|
+
have[id].state === "ACTIVE" &&
|
|
19
20
|
have[id].hash &&
|
|
20
21
|
want[id].hash &&
|
|
21
22
|
want[id].hash === have[id].hash);
|
|
@@ -50,20 +50,25 @@ async function detectFromYaml(directory, project, runtime) {
|
|
|
50
50
|
return yamlToBuild(parsed, project, api.functionsDefaultRegion(), runtime);
|
|
51
51
|
}
|
|
52
52
|
exports.detectFromYaml = detectFromYaml;
|
|
53
|
-
async function detectFromPort(port, project, runtime, timeout = 10000) {
|
|
53
|
+
async function detectFromPort(port, project, runtime, initialDelay = 0, timeout = 10000) {
|
|
54
54
|
let res;
|
|
55
55
|
const timedOut = new Promise((resolve, reject) => {
|
|
56
56
|
setTimeout(() => {
|
|
57
57
|
reject(new error_1.FirebaseError("User code failed to load. Cannot determine backend specification"));
|
|
58
58
|
}, getFunctionDiscoveryTimeout() || timeout);
|
|
59
59
|
});
|
|
60
|
+
if (initialDelay > 0) {
|
|
61
|
+
await new Promise((resolve) => setTimeout(resolve, initialDelay));
|
|
62
|
+
}
|
|
63
|
+
const url = `http://127.0.0.1:${port}/__/functions.yaml`;
|
|
60
64
|
while (true) {
|
|
61
65
|
try {
|
|
62
|
-
res = await Promise.race([(0, node_fetch_1.default)(
|
|
66
|
+
res = await Promise.race([(0, node_fetch_1.default)(url), timedOut]);
|
|
63
67
|
break;
|
|
64
68
|
}
|
|
65
69
|
catch (err) {
|
|
66
|
-
if ((err === null || err === void 0 ? void 0 : err.
|
|
70
|
+
if ((err === null || err === void 0 ? void 0 : err.name) === "FetchError" ||
|
|
71
|
+
["ECONNREFUSED", "ECONNRESET", "ETIMEDOUT"].includes(err === null || err === void 0 ? void 0 : err.code)) {
|
|
67
72
|
continue;
|
|
68
73
|
}
|
|
69
74
|
throw err;
|
|
@@ -149,7 +149,7 @@ class Delegate {
|
|
|
149
149
|
});
|
|
150
150
|
const killProcess = await this.serveAdmin(adminPort, envs);
|
|
151
151
|
try {
|
|
152
|
-
discovered = await discovery.detectFromPort(adminPort, this.projectId, this.runtime);
|
|
152
|
+
discovered = await discovery.detectFromPort(adminPort, this.projectId, this.runtime, 500);
|
|
153
153
|
}
|
|
154
154
|
finally {
|
|
155
155
|
await killProcess();
|
package/lib/deploy/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.deploy = void 0;
|
|
3
|
+
exports.deploy = exports.prepareFrameworksIfNeeded = exports.matchesHostingTarget = void 0;
|
|
4
4
|
const clc = require("colorette");
|
|
5
5
|
const logger_1 = require("../logger");
|
|
6
6
|
const api_1 = require("../api");
|
|
@@ -40,8 +40,27 @@ const chain = async function (fns, context, options, payload) {
|
|
|
40
40
|
await latest(context, options, payload);
|
|
41
41
|
}
|
|
42
42
|
};
|
|
43
|
+
const matchesHostingTarget = (only, target) => {
|
|
44
|
+
if (!only)
|
|
45
|
+
return true;
|
|
46
|
+
if (!only.includes("hosting:"))
|
|
47
|
+
return true;
|
|
48
|
+
const targetStr = `hosting:${target !== null && target !== void 0 ? target : ""}`;
|
|
49
|
+
return only.split(",").some((t) => t === targetStr);
|
|
50
|
+
};
|
|
51
|
+
exports.matchesHostingTarget = matchesHostingTarget;
|
|
52
|
+
const prepareFrameworksIfNeeded = async function (targetNames, options, context) {
|
|
53
|
+
const config = options.config.get("hosting");
|
|
54
|
+
if (Array.isArray(config)
|
|
55
|
+
? config.some((it) => it.source && (0, exports.matchesHostingTarget)(options.only, it.target))
|
|
56
|
+
: config.source) {
|
|
57
|
+
experiments.assertEnabled("webframeworks", "deploy a web framework from source");
|
|
58
|
+
await (0, frameworks_1.prepareFrameworks)("deploy", targetNames, context, options);
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
exports.prepareFrameworksIfNeeded = prepareFrameworksIfNeeded;
|
|
43
62
|
const deploy = async function (targetNames, options, customContext = {}) {
|
|
44
|
-
var _a;
|
|
63
|
+
var _a, _b, _c;
|
|
45
64
|
const projectId = (0, projectUtils_1.needProjectId)(options);
|
|
46
65
|
const payload = {};
|
|
47
66
|
const context = Object.assign({ projectId }, customContext);
|
|
@@ -52,11 +71,7 @@ const deploy = async function (targetNames, options, customContext = {}) {
|
|
|
52
71
|
const postdeploys = [];
|
|
53
72
|
const startTime = Date.now();
|
|
54
73
|
if (targetNames.includes("hosting")) {
|
|
55
|
-
|
|
56
|
-
if (Array.isArray(config) ? config.some((it) => it.source) : config.source) {
|
|
57
|
-
experiments.assertEnabled("webframeworks", "deploy a web framework from source");
|
|
58
|
-
await (0, frameworks_1.prepareFrameworks)("deploy", targetNames, context, options);
|
|
59
|
-
}
|
|
74
|
+
await (0, exports.prepareFrameworksIfNeeded)(targetNames, options, context);
|
|
60
75
|
}
|
|
61
76
|
if (targetNames.includes("hosting") && (0, prepare_1.hasPinnedFunctions)(options)) {
|
|
62
77
|
experiments.assertEnabled("pintags", "deploy a tagged function as a hosting rewrite");
|
|
@@ -120,11 +135,11 @@ const deploy = async function (targetNames, options, customContext = {}) {
|
|
|
120
135
|
const deployedHosting = (0, lodash_1.includes)(targetNames, "hosting");
|
|
121
136
|
logger_1.logger.info((0, colorette_1.bold)("Project Console:"), (0, utils_1.consoleUrl)((_a = options.project) !== null && _a !== void 0 ? _a : "_", "/overview"));
|
|
122
137
|
if (deployedHosting) {
|
|
123
|
-
(0, lodash_1.each)(context.hosting.deploys, (deploy) => {
|
|
138
|
+
(0, lodash_1.each)((_b = context.hosting) === null || _b === void 0 ? void 0 : _b.deploys, (deploy) => {
|
|
124
139
|
logger_1.logger.info((0, colorette_1.bold)("Hosting URL:"), (0, utils_1.addSubdomain)((0, api_1.hostingOrigin)(), deploy.config.site));
|
|
125
140
|
});
|
|
126
|
-
const versionNames = context.hosting.deploys.map((deploy) => deploy.version);
|
|
127
|
-
return { hosting: versionNames.length === 1 ? versionNames[0] : versionNames };
|
|
141
|
+
const versionNames = (_c = context.hosting) === null || _c === void 0 ? void 0 : _c.deploys.map((deploy) => deploy.version);
|
|
142
|
+
return { hosting: (versionNames === null || versionNames === void 0 ? void 0 : versionNames.length) === 1 ? versionNames[0] : versionNames };
|
|
128
143
|
}
|
|
129
144
|
else {
|
|
130
145
|
return { hosting: undefined };
|
|
@@ -11,9 +11,8 @@ const path = require("path");
|
|
|
11
11
|
const vsCodeUtils_1 = require("../vsCodeUtils");
|
|
12
12
|
function runCommand(command, childOptions) {
|
|
13
13
|
const escapedCommand = command.replace(/\"/g, '\\"');
|
|
14
|
-
const
|
|
15
|
-
const
|
|
16
|
-
const crossEnvShellPath = isVSCode
|
|
14
|
+
const nodeExecutable = (0, vsCodeUtils_1.isVSCodeExtension)() ? "node" : process.execPath;
|
|
15
|
+
const crossEnvShellPath = (0, vsCodeUtils_1.isVSCodeExtension)()
|
|
17
16
|
? path.resolve(__dirname, "./cross-env/dist/bin/cross-env-shell.js")
|
|
18
17
|
: path.resolve(require.resolve("cross-env"), "..", "bin", "cross-env-shell.js");
|
|
19
18
|
const translatedCommand = '"' + nodeExecutable + '" "' + crossEnvShellPath + '" "' + escapedCommand + '"';
|
|
@@ -103,6 +103,7 @@ Constants.FIREBASE_ENABLED_EXPERIMENTS = "FIREBASE_ENABLED_EXPERIMENTS";
|
|
|
103
103
|
Constants.FIRESTORE_EMULATOR_HOST = "FIRESTORE_EMULATOR_HOST";
|
|
104
104
|
Constants.FIRESTORE_EMULATOR_ENV_ALT = "FIREBASE_FIRESTORE_EMULATOR_ADDRESS";
|
|
105
105
|
Constants.FIREBASE_DATABASE_EMULATOR_HOST = "FIREBASE_DATABASE_EMULATOR_HOST";
|
|
106
|
+
Constants.FIREBASE_DATACONNECT_EMULATOR_HOST = "FIREBASE_DATACONNECT_EMULATOR_HOST";
|
|
106
107
|
Constants.FIREBASE_AUTH_EMULATOR_HOST = "FIREBASE_AUTH_EMULATOR_HOST";
|
|
107
108
|
Constants.FIREBASE_STORAGE_EMULATOR_HOST = "FIREBASE_STORAGE_EMULATOR_HOST";
|
|
108
109
|
Constants.CLOUD_STORAGE_EMULATOR_HOST = "STORAGE_EMULATOR_HOST";
|
|
@@ -48,20 +48,20 @@ const EMULATOR_UPDATE_DETAILS = {
|
|
|
48
48
|
},
|
|
49
49
|
dataconnect: process.platform === "darwin"
|
|
50
50
|
? {
|
|
51
|
-
version: "1.8.
|
|
52
|
-
expectedSize:
|
|
53
|
-
expectedChecksum: "
|
|
51
|
+
version: "1.8.4",
|
|
52
|
+
expectedSize: 25588480,
|
|
53
|
+
expectedChecksum: "421f6226a0433b824642c03eb0b6862d",
|
|
54
54
|
}
|
|
55
55
|
: process.platform === "win32"
|
|
56
56
|
? {
|
|
57
|
-
version: "1.8.
|
|
58
|
-
expectedSize:
|
|
59
|
-
expectedChecksum: "
|
|
57
|
+
version: "1.8.4",
|
|
58
|
+
expectedSize: 26020352,
|
|
59
|
+
expectedChecksum: "b78c95a7f071f127acda3a76cdcc8c48",
|
|
60
60
|
}
|
|
61
61
|
: {
|
|
62
|
-
version: "1.8.
|
|
63
|
-
expectedSize:
|
|
64
|
-
expectedChecksum: "
|
|
62
|
+
version: "1.8.4",
|
|
63
|
+
expectedSize: 25501848,
|
|
64
|
+
expectedChecksum: "0aabd622b1a99b2a0d9c9dec4c7404fc",
|
|
65
65
|
},
|
|
66
66
|
};
|
|
67
67
|
exports.DownloadDetails = {
|
package/lib/emulator/env.js
CHANGED
|
@@ -34,6 +34,8 @@ function setEnvVarsForEmulators(env, emulators) {
|
|
|
34
34
|
case types_1.Emulators.TASKS:
|
|
35
35
|
env[constants_1.Constants.CLOUD_TASKS_EMULATOR_HOST] = host;
|
|
36
36
|
break;
|
|
37
|
+
case types_1.Emulators.DATACONNECT:
|
|
38
|
+
env[constants_1.Constants.FIREBASE_DATACONNECT_EMULATOR_HOST] = host;
|
|
37
39
|
}
|
|
38
40
|
}
|
|
39
41
|
}
|
package/lib/emulator/hub.js
CHANGED
|
@@ -20,7 +20,7 @@ class EmulatorHub extends ExpressBasedEmulator_1.ExpressBasedEmulator {
|
|
|
20
20
|
}
|
|
21
21
|
const data = fs.readFileSync(locatorPath, "utf8").toString();
|
|
22
22
|
const locator = JSON.parse(data);
|
|
23
|
-
if (!vsCodeUtils_1.isVSCodeExtension && locator.version !== this.CLI_VERSION) {
|
|
23
|
+
if (!(0, vsCodeUtils_1.isVSCodeExtension)() && locator.version !== this.CLI_VERSION) {
|
|
24
24
|
logger_1.logger.debug(`Found locator with mismatched version, ignoring: ${JSON.stringify(locator)}`);
|
|
25
25
|
return undefined;
|
|
26
26
|
}
|
|
@@ -12,7 +12,7 @@ const utils_1 = require("../utils");
|
|
|
12
12
|
exports.name = "Vite";
|
|
13
13
|
exports.support = "experimental";
|
|
14
14
|
exports.type = 4;
|
|
15
|
-
exports.supportedRange = "3 -
|
|
15
|
+
exports.supportedRange = "3 - 6";
|
|
16
16
|
exports.DEFAULT_BUILD_SCRIPT = ["vite build", "tsc && vite build"];
|
|
17
17
|
const initViteTemplate = (template) => async (setup, config) => await init(setup, config, template);
|
|
18
18
|
exports.initViteTemplate = initViteTemplate;
|
|
@@ -265,6 +265,21 @@ function endpointFromFunction(gcfFunction) {
|
|
|
265
265
|
if ((_h = gcfFunction.labels) === null || _h === void 0 ? void 0 : _h[constants_1.HASH_LABEL]) {
|
|
266
266
|
endpoint.hash = gcfFunction.labels[constants_1.HASH_LABEL];
|
|
267
267
|
}
|
|
268
|
+
proto.convertIfPresent(endpoint, gcfFunction, "state", "status", (status) => {
|
|
269
|
+
if (status === "ACTIVE") {
|
|
270
|
+
return "ACTIVE";
|
|
271
|
+
}
|
|
272
|
+
else if (status === "OFFLINE") {
|
|
273
|
+
return "FAILED";
|
|
274
|
+
}
|
|
275
|
+
else if (status === "DEPLOY_IN_PROGRESS") {
|
|
276
|
+
return "DEPLOYING";
|
|
277
|
+
}
|
|
278
|
+
else if (status === "DELETE_IN_PROGRESS") {
|
|
279
|
+
return "DELETING";
|
|
280
|
+
}
|
|
281
|
+
return "UNKONWN";
|
|
282
|
+
});
|
|
268
283
|
return endpoint;
|
|
269
284
|
}
|
|
270
285
|
exports.endpointFromFunction = endpointFromFunction;
|
|
@@ -91,7 +91,7 @@ async function createFunction(cloudFunction) {
|
|
|
91
91
|
const components = cloudFunction.name.split("/");
|
|
92
92
|
const functionId = components.splice(-1, 1)[0];
|
|
93
93
|
cloudFunction.buildConfig.environmentVariables = Object.assign(Object.assign({}, cloudFunction.buildConfig.environmentVariables), { GOOGLE_NODE_RUN_SCRIPTS: "" });
|
|
94
|
-
cloudFunction.serviceConfig.environmentVariables = Object.assign(Object.assign({}, cloudFunction.serviceConfig.environmentVariables), { FUNCTION_TARGET: cloudFunction.buildConfig.entryPoint.replaceAll("-", ".") });
|
|
94
|
+
cloudFunction.serviceConfig.environmentVariables = Object.assign(Object.assign({}, cloudFunction.serviceConfig.environmentVariables), { FUNCTION_TARGET: cloudFunction.buildConfig.entryPoint.replaceAll("-", "."), LOG_EXECUTION_ID: "true" });
|
|
95
95
|
try {
|
|
96
96
|
const res = await client.post(components.join("/"), cloudFunction, { queryParams: { functionId } });
|
|
97
97
|
return res.body;
|
|
@@ -147,7 +147,7 @@ async function updateFunction(cloudFunction) {
|
|
|
147
147
|
const fieldMasks = proto.fieldMasks(cloudFunction, "labels", "serviceConfig.environmentVariables", "serviceConfig.secretEnvironmentVariables");
|
|
148
148
|
cloudFunction.buildConfig.environmentVariables = Object.assign(Object.assign({}, cloudFunction.buildConfig.environmentVariables), { GOOGLE_NODE_RUN_SCRIPTS: "" });
|
|
149
149
|
fieldMasks.push("buildConfig.buildEnvironmentVariables");
|
|
150
|
-
cloudFunction.serviceConfig.environmentVariables = Object.assign(Object.assign({}, cloudFunction.serviceConfig.environmentVariables), { FUNCTION_TARGET: cloudFunction.buildConfig.entryPoint.replaceAll("-", ".") });
|
|
150
|
+
cloudFunction.serviceConfig.environmentVariables = Object.assign(Object.assign({}, cloudFunction.serviceConfig.environmentVariables), { FUNCTION_TARGET: cloudFunction.buildConfig.entryPoint.replaceAll("-", "."), LOG_EXECUTION_ID: "true" });
|
|
151
151
|
try {
|
|
152
152
|
const queryParams = {
|
|
153
153
|
updateMask: fieldMasks.join(","),
|
|
@@ -389,6 +389,7 @@ function endpointFromFunction(gcfFunction) {
|
|
|
389
389
|
if ((_f = gcfFunction.labels) === null || _f === void 0 ? void 0 : _f[constants_1.HASH_LABEL]) {
|
|
390
390
|
endpoint.hash = gcfFunction.labels[constants_1.HASH_LABEL];
|
|
391
391
|
}
|
|
392
|
+
proto.copyIfPresent(endpoint, gcfFunction, "state");
|
|
392
393
|
return endpoint;
|
|
393
394
|
}
|
|
394
395
|
exports.endpointFromFunction = endpointFromFunction;
|
|
@@ -9,7 +9,6 @@ const logger_1 = require("../logger");
|
|
|
9
9
|
const registry_1 = require("../emulator/registry");
|
|
10
10
|
const types_1 = require("../emulator/types");
|
|
11
11
|
const templates_1 = require("../templates");
|
|
12
|
-
const INIT_TEMPLATE = (0, templates_1.readTemplateSync)("hosting/init.js");
|
|
13
12
|
async function implicitInit(options) {
|
|
14
13
|
let config;
|
|
15
14
|
try {
|
|
@@ -47,8 +46,13 @@ async function implicitInit(options) {
|
|
|
47
46
|
}
|
|
48
47
|
}
|
|
49
48
|
const emulatorsJson = JSON.stringify(emulators, null, 2);
|
|
50
|
-
const
|
|
51
|
-
const
|
|
49
|
+
const initTemplate = (0, templates_1.readTemplateSync)("hosting/init.js");
|
|
50
|
+
const js = initTemplate
|
|
51
|
+
.replace("/*--CONFIG--*/", `var firebaseConfig = ${configJson};`)
|
|
52
|
+
.replace("/*--EMULATORS--*/", "var firebaseEmulators = undefined;");
|
|
53
|
+
const emulatorsJs = initTemplate
|
|
54
|
+
.replace("/*--CONFIG--*/", `var firebaseConfig = ${configJson};`)
|
|
55
|
+
.replace("/*--EMULATORS--*/", `var firebaseEmulators = ${emulatorsJson};`);
|
|
52
56
|
return {
|
|
53
57
|
js,
|
|
54
58
|
emulatorsJs,
|
|
@@ -23,6 +23,7 @@ const CONNECTOR_YAML_TEMPLATE = (0, templates_1.readTemplateSync)("init/dataconn
|
|
|
23
23
|
const SCHEMA_TEMPLATE = (0, templates_1.readTemplateSync)("init/dataconnect/schema.gql");
|
|
24
24
|
const QUERIES_TEMPLATE = (0, templates_1.readTemplateSync)("init/dataconnect/queries.gql");
|
|
25
25
|
const MUTATIONS_TEMPLATE = (0, templates_1.readTemplateSync)("init/dataconnect/mutations.gql");
|
|
26
|
+
const serviceEnvVar = () => (0, utils_1.envOverride)("FDC_SERVICE", "");
|
|
26
27
|
const emptyConnector = {
|
|
27
28
|
id: "default",
|
|
28
29
|
path: "./connector",
|
|
@@ -192,19 +193,31 @@ async function promptForExistingServices(setup, info, isBillingEnabled) {
|
|
|
192
193
|
};
|
|
193
194
|
}));
|
|
194
195
|
if (existingServicesAndSchemas.length) {
|
|
195
|
-
|
|
196
|
+
let choice;
|
|
197
|
+
const [serviceLocationFromEnvVar, serviceIdFromEnvVar] = serviceEnvVar().split("/");
|
|
198
|
+
const serviceFromEnvVar = existingServicesAndSchemas.find((s) => {
|
|
196
199
|
const serviceName = (0, names_1.parseServiceName)(s.service.name);
|
|
197
|
-
return
|
|
198
|
-
|
|
199
|
-
value: s,
|
|
200
|
-
};
|
|
201
|
-
});
|
|
202
|
-
choices.push({ name: "Create a new service", value: undefined });
|
|
203
|
-
const choice = await (0, prompt_1.promptOnce)({
|
|
204
|
-
message: "Your project already has existing services. Which would you like to set up local files for?",
|
|
205
|
-
type: "list",
|
|
206
|
-
choices,
|
|
200
|
+
return (serviceName.serviceId === serviceIdFromEnvVar &&
|
|
201
|
+
serviceName.location === serviceLocationFromEnvVar);
|
|
207
202
|
});
|
|
203
|
+
if (serviceFromEnvVar) {
|
|
204
|
+
choice = serviceFromEnvVar;
|
|
205
|
+
}
|
|
206
|
+
else {
|
|
207
|
+
const choices = existingServicesAndSchemas.map((s) => {
|
|
208
|
+
const serviceName = (0, names_1.parseServiceName)(s.service.name);
|
|
209
|
+
return {
|
|
210
|
+
name: `${serviceName.location}/${serviceName.serviceId}`,
|
|
211
|
+
value: s,
|
|
212
|
+
};
|
|
213
|
+
});
|
|
214
|
+
choices.push({ name: "Create a new service", value: undefined });
|
|
215
|
+
choice = await (0, prompt_1.promptOnce)({
|
|
216
|
+
message: "Your project already has existing services. Which would you like to set up local files for?",
|
|
217
|
+
type: "list",
|
|
218
|
+
choices,
|
|
219
|
+
});
|
|
220
|
+
}
|
|
208
221
|
if (choice) {
|
|
209
222
|
const serviceName = (0, names_1.parseServiceName)(choice.service.name);
|
|
210
223
|
info.serviceId = serviceName.serviceId;
|
package/lib/management/apps.js
CHANGED
|
@@ -566,13 +566,16 @@ async function findIntelligentPathForAndroid(appDir, options) {
|
|
|
566
566
|
const dirs = [];
|
|
567
567
|
for (const fileOrDir of currentFiles) {
|
|
568
568
|
if (fileOrDir.isDirectory()) {
|
|
569
|
+
if (fileOrDir.name !== "gradle") {
|
|
570
|
+
dirs.push(fileOrDir.name);
|
|
571
|
+
}
|
|
569
572
|
if (fileOrDir.name === "src") {
|
|
570
573
|
return appDir;
|
|
571
574
|
}
|
|
572
575
|
}
|
|
573
576
|
}
|
|
574
577
|
let module = path.join(appDir, "app");
|
|
575
|
-
if (dirs.length === 1) {
|
|
578
|
+
if (dirs.length === 1 && dirs[0] === "app") {
|
|
576
579
|
return module;
|
|
577
580
|
}
|
|
578
581
|
if (!options.nonInteractive) {
|
package/lib/vsCodeUtils.js
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isVSCodeExtension = void 0;
|
|
4
|
-
|
|
3
|
+
exports.setIsVSCodeExtension = exports.isVSCodeExtension = void 0;
|
|
4
|
+
let _IS_WEBPACKED_FOR_VSCE = false;
|
|
5
5
|
function isVSCodeExtension() {
|
|
6
|
-
return
|
|
6
|
+
return _IS_WEBPACKED_FOR_VSCE;
|
|
7
7
|
}
|
|
8
8
|
exports.isVSCodeExtension = isVSCodeExtension;
|
|
9
|
+
function setIsVSCodeExtension(v) {
|
|
10
|
+
_IS_WEBPACKED_FOR_VSCE = v;
|
|
11
|
+
}
|
|
12
|
+
exports.setIsVSCodeExtension = setIsVSCodeExtension;
|