firebase-tools 11.14.2 → 11.14.3-canary.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/deploy/hosting/convertConfig.js +3 -3
- package/lib/deploy/hosting/release.js +6 -2
- package/lib/emulator/constants.js +1 -1
- package/lib/emulator/hostingEmulator.js +7 -2
- package/lib/emulator/portUtils.js +23 -3
- package/lib/frameworks/next/index.js +1 -1
- package/lib/gcp/cloudfunctions.js +1 -0
- package/lib/hosting/api.js +2 -6
- package/lib/serve/hosting.js +26 -34
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
|
@@ -70,9 +70,9 @@ async function convertConfig(context, deploy) {
|
|
|
70
70
|
if (err.status === 403) {
|
|
71
71
|
logger_1.logger.debug(`Deploying hosting site ${deploy.config.site}, did not have permissions to check for backends: `, err);
|
|
72
72
|
}
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
73
|
+
}
|
|
74
|
+
else {
|
|
75
|
+
throw err;
|
|
76
76
|
}
|
|
77
77
|
}
|
|
78
78
|
}
|
|
@@ -6,7 +6,7 @@ const logger_1 = require("../../logger");
|
|
|
6
6
|
const utils = require("../../utils");
|
|
7
7
|
const convertConfig_1 = require("./convertConfig");
|
|
8
8
|
const error_1 = require("../../error");
|
|
9
|
-
async function release(context) {
|
|
9
|
+
async function release(context, options) {
|
|
10
10
|
if (!context.hosting || !context.hosting.deploys) {
|
|
11
11
|
return;
|
|
12
12
|
}
|
|
@@ -28,7 +28,11 @@ async function release(context) {
|
|
|
28
28
|
if (context.hostingChannel) {
|
|
29
29
|
logger_1.logger.debug("[hosting] releasing to channel:", context.hostingChannel);
|
|
30
30
|
}
|
|
31
|
-
const
|
|
31
|
+
const otherReleaseOpts = {};
|
|
32
|
+
if (options.message) {
|
|
33
|
+
otherReleaseOpts.message = options.message;
|
|
34
|
+
}
|
|
35
|
+
const release = await api.createRelease(deploy.config.site, context.hostingChannel || "live", deploy.version, otherReleaseOpts);
|
|
32
36
|
logger_1.logger.debug("[hosting] release:", release);
|
|
33
37
|
utils.logLabeledSuccess(`hosting[${deploy.config.site}]`, "release complete");
|
|
34
38
|
}));
|
|
@@ -8,10 +8,14 @@ class HostingEmulator {
|
|
|
8
8
|
constructor(args) {
|
|
9
9
|
this.args = args;
|
|
10
10
|
}
|
|
11
|
-
start() {
|
|
11
|
+
async start() {
|
|
12
12
|
this.args.options.host = this.args.host;
|
|
13
13
|
this.args.options.port = this.args.port;
|
|
14
|
-
|
|
14
|
+
const { ports } = await serveHosting.start(this.args.options);
|
|
15
|
+
this.args.port = ports[0];
|
|
16
|
+
if (ports.length > 1) {
|
|
17
|
+
this.reservedPorts = ports.slice(1);
|
|
18
|
+
}
|
|
15
19
|
}
|
|
16
20
|
connect() {
|
|
17
21
|
return Promise.resolve();
|
|
@@ -26,6 +30,7 @@ class HostingEmulator {
|
|
|
26
30
|
name: this.getName(),
|
|
27
31
|
host,
|
|
28
32
|
port,
|
|
33
|
+
reservedPorts: this.reservedPorts,
|
|
29
34
|
};
|
|
30
35
|
}
|
|
31
36
|
getName() {
|
|
@@ -10,6 +10,7 @@ const dns_1 = require("./dns");
|
|
|
10
10
|
const types_1 = require("./types");
|
|
11
11
|
const constants_1 = require("./constants");
|
|
12
12
|
const emulatorLogger_1 = require("./emulatorLogger");
|
|
13
|
+
const node_child_process_1 = require("node:child_process");
|
|
13
14
|
const RESTRICTED_PORTS = new Set([
|
|
14
15
|
1,
|
|
15
16
|
7,
|
|
@@ -95,8 +96,15 @@ function suggestUnrestricted(port) {
|
|
|
95
96
|
async function checkListenable(arg1, port) {
|
|
96
97
|
const addr = port === undefined ? arg1 : listenSpec(arg1, port);
|
|
97
98
|
return new Promise((resolve, reject) => {
|
|
98
|
-
|
|
99
|
-
|
|
99
|
+
if (process.platform === "darwin") {
|
|
100
|
+
try {
|
|
101
|
+
(0, node_child_process_1.execSync)(`lsof -i :${addr.port} -sTCP:LISTEN`);
|
|
102
|
+
return resolve(false);
|
|
103
|
+
}
|
|
104
|
+
catch (e) {
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
const dummyServer = (0, node_net_1.createServer)();
|
|
100
108
|
dummyServer.once("error", (err) => {
|
|
101
109
|
dummyServer.removeAllListeners();
|
|
102
110
|
const e = err;
|
|
@@ -189,13 +197,25 @@ async function resolveHostAndAssignPorts(listenConfig) {
|
|
|
189
197
|
emuLogger.logLabeled("DEBUG", name, `portUtils: skipping restricted port ${p}`);
|
|
190
198
|
continue;
|
|
191
199
|
}
|
|
200
|
+
if (p === 5001 && /^hosting/i.exec(name)) {
|
|
201
|
+
continue;
|
|
202
|
+
}
|
|
192
203
|
const available = [];
|
|
193
204
|
const unavailable = [];
|
|
194
205
|
let i;
|
|
195
206
|
for (i = 0; i < addrs.length; i++) {
|
|
196
207
|
const addr = addrs[i];
|
|
197
208
|
const listen = listenSpec(addr, p);
|
|
198
|
-
|
|
209
|
+
let listenable;
|
|
210
|
+
try {
|
|
211
|
+
listenable = await checkListenable(listen);
|
|
212
|
+
}
|
|
213
|
+
catch (err) {
|
|
214
|
+
emuLogger.logLabeled("WARN", name, `Error when trying to check port ${p} on ${addr.address}: ${err}`);
|
|
215
|
+
unavailable.push(addr.address);
|
|
216
|
+
continue;
|
|
217
|
+
}
|
|
218
|
+
if (listenable) {
|
|
199
219
|
available.push(listen);
|
|
200
220
|
}
|
|
201
221
|
else {
|
|
@@ -85,7 +85,7 @@ async function init(setup) {
|
|
|
85
85
|
message: "What language would you like to use?",
|
|
86
86
|
choices: ["JavaScript", "TypeScript"],
|
|
87
87
|
});
|
|
88
|
-
(0, child_process_1.execSync)(`npx --yes create-next-app@latest ${setup.hosting.source} ${language === "TypeScript" ? "--ts" : ""}`, { stdio: "inherit" });
|
|
88
|
+
(0, child_process_1.execSync)(`npx --yes create-next-app@latest -e hello-world ${setup.hosting.source} ${language === "TypeScript" ? "--ts" : ""}`, { stdio: "inherit" });
|
|
89
89
|
}
|
|
90
90
|
exports.init = init;
|
|
91
91
|
async function ɵcodegenPublicDirectory(sourceDir, destDir) {
|
|
@@ -177,6 +177,7 @@ async function list(projectId, region) {
|
|
|
177
177
|
logger_1.logger.debug(`[functions] ${err === null || err === void 0 ? void 0 : err.message}`);
|
|
178
178
|
throw new error_1.FirebaseError(`Failed to list functions for ${projectId}`, {
|
|
179
179
|
original: err,
|
|
180
|
+
status: err instanceof error_1.FirebaseError ? err.status : undefined,
|
|
180
181
|
});
|
|
181
182
|
}
|
|
182
183
|
}
|
package/lib/hosting/api.js
CHANGED
|
@@ -124,12 +124,8 @@ async function cloneVersion(site, versionName, finalize = false) {
|
|
|
124
124
|
return pollRes;
|
|
125
125
|
}
|
|
126
126
|
exports.cloneVersion = cloneVersion;
|
|
127
|
-
async function createRelease(site, channel, version) {
|
|
128
|
-
const res = await apiClient.
|
|
129
|
-
method: "POST",
|
|
130
|
-
path: `/projects/-/sites/${site}/channels/${channel}/releases`,
|
|
131
|
-
queryParams: { versionName: version },
|
|
132
|
-
});
|
|
127
|
+
async function createRelease(site, channel, version, partialRelease) {
|
|
128
|
+
const res = await apiClient.post(`/projects/-/sites/${site}/channels/${channel}/releases`, partialRelease, { queryParams: { versionName: version } });
|
|
133
129
|
return res.body;
|
|
134
130
|
}
|
|
135
131
|
exports.createRelease = createRelease;
|
package/lib/serve/hosting.js
CHANGED
|
@@ -4,6 +4,7 @@ exports.connect = exports.start = exports.stop = void 0;
|
|
|
4
4
|
const morgan = require("morgan");
|
|
5
5
|
const superstatic_1 = require("superstatic");
|
|
6
6
|
const clc = require("colorette");
|
|
7
|
+
const net_1 = require("net");
|
|
7
8
|
const detectProjectRoot_1 = require("../detectProjectRoot");
|
|
8
9
|
const error_1 = require("../error");
|
|
9
10
|
const implicitInit_1 = require("../hosting/implicitInit");
|
|
@@ -15,10 +16,9 @@ const stream_1 = require("stream");
|
|
|
15
16
|
const emulatorLogger_1 = require("../emulator/emulatorLogger");
|
|
16
17
|
const types_1 = require("../emulator/types");
|
|
17
18
|
const utils_1 = require("../utils");
|
|
18
|
-
const child_process_1 = require("child_process");
|
|
19
19
|
const requireHostingSite_1 = require("../requireHostingSite");
|
|
20
|
-
const
|
|
21
|
-
|
|
20
|
+
const projectUtils_1 = require("../projectUtils");
|
|
21
|
+
const portUtils_1 = require("../emulator/portUtils");
|
|
22
22
|
let destroyServer = undefined;
|
|
23
23
|
const logger = emulatorLogger_1.EmulatorLogger.forEmulator(types_1.Emulators.HOSTING);
|
|
24
24
|
function startServer(options, config, port, init) {
|
|
@@ -33,29 +33,6 @@ function startServer(options, config, port, init) {
|
|
|
33
33
|
const morganMiddleware = morgan("combined", {
|
|
34
34
|
stream: morganStream,
|
|
35
35
|
});
|
|
36
|
-
const portInUse = () => {
|
|
37
|
-
const message = "Port " + options.port + " is not available.";
|
|
38
|
-
logger.log("WARN", clc.yellow("hosting: ") + message + " Trying another port...");
|
|
39
|
-
if (attempts < MAX_PORT_ATTEMPTS) {
|
|
40
|
-
attempts++;
|
|
41
|
-
startServer(options, config, port + 5, init);
|
|
42
|
-
}
|
|
43
|
-
else {
|
|
44
|
-
logger.log("WARN", message);
|
|
45
|
-
throw new error_1.FirebaseError("Could not find an open port for hosting development server.", {
|
|
46
|
-
exit: 1,
|
|
47
|
-
});
|
|
48
|
-
}
|
|
49
|
-
};
|
|
50
|
-
if (process.platform === "darwin") {
|
|
51
|
-
try {
|
|
52
|
-
(0, child_process_1.execSync)(`lsof -i :${port} -sTCP:LISTEN`);
|
|
53
|
-
portInUse();
|
|
54
|
-
return;
|
|
55
|
-
}
|
|
56
|
-
catch (e) {
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
36
|
const after = options.frameworksDevModeHandle && {
|
|
60
37
|
files: options.frameworksDevModeHandle,
|
|
61
38
|
};
|
|
@@ -88,12 +65,8 @@ function startServer(options, config, port, init) {
|
|
|
88
65
|
});
|
|
89
66
|
destroyServer = (0, utils_1.createDestroyer)(server);
|
|
90
67
|
server.on("error", (err) => {
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
}
|
|
94
|
-
else {
|
|
95
|
-
throw new error_1.FirebaseError("An error occurred while starting the hosting development server:\n\n" + err.toString(), { exit: 1 });
|
|
96
|
-
}
|
|
68
|
+
logger.log("DEBUG", `Error from superstatic server: ${err.stack || ""}`);
|
|
69
|
+
throw new error_1.FirebaseError(`An error occurred while starting the hosting development server:\n\n${err.message}`);
|
|
97
70
|
});
|
|
98
71
|
}
|
|
99
72
|
function stop() {
|
|
@@ -107,17 +80,36 @@ async function start(options) {
|
|
|
107
80
|
await (0, requireHostingSite_1.requireHostingSite)(options);
|
|
108
81
|
}
|
|
109
82
|
catch (_a) {
|
|
110
|
-
|
|
83
|
+
if (init.json) {
|
|
84
|
+
options.site = JSON.parse(init.json).projectId;
|
|
85
|
+
}
|
|
86
|
+
else {
|
|
87
|
+
options.site = (0, projectUtils_1.getProjectId)(options) || "site";
|
|
88
|
+
}
|
|
111
89
|
}
|
|
112
90
|
}
|
|
113
91
|
const configs = config.hostingConfig(options);
|
|
92
|
+
const assignedPorts = new Set([5001]);
|
|
114
93
|
for (let i = 0; i < configs.length; i++) {
|
|
115
|
-
|
|
94
|
+
let port = i === 0 ? options.port : options.port + 4 + i;
|
|
95
|
+
while (assignedPorts.has(port) || !(await availablePort(options.host, port))) {
|
|
96
|
+
port += 1;
|
|
97
|
+
}
|
|
98
|
+
assignedPorts.add(port);
|
|
116
99
|
startServer(options, configs[i], port, init);
|
|
117
100
|
}
|
|
101
|
+
assignedPorts.delete(5001);
|
|
102
|
+
return { ports: Array.from(assignedPorts) };
|
|
118
103
|
}
|
|
119
104
|
exports.start = start;
|
|
120
105
|
async function connect() {
|
|
121
106
|
await Promise.resolve();
|
|
122
107
|
}
|
|
123
108
|
exports.connect = connect;
|
|
109
|
+
function availablePort(host, port) {
|
|
110
|
+
return (0, portUtils_1.checkListenable)({
|
|
111
|
+
address: host,
|
|
112
|
+
port,
|
|
113
|
+
family: (0, net_1.isIPv4)(host) ? "IPv4" : "IPv6",
|
|
114
|
+
});
|
|
115
|
+
}
|
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "firebase-tools",
|
|
3
|
-
"version": "11.14.
|
|
3
|
+
"version": "11.14.3-canary.0",
|
|
4
4
|
"lockfileVersion": 2,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "firebase-tools",
|
|
9
|
-
"version": "11.14.
|
|
9
|
+
"version": "11.14.3-canary.0",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@google-cloud/pubsub": "^3.0.1",
|