firebase-tools 12.9.1 → 13.0.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/apiv2.js +7 -0
- package/lib/auth.js +8 -4
- package/lib/commands/frameworks-backends-delete.js +66 -6
- package/lib/commands/frameworks-backends-get.js +57 -18
- package/lib/commands/frameworks-backends-list.js +42 -15
- package/lib/commands/index.js +0 -1
- 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/lifecycleHooks.js +5 -0
- package/lib/fetchMOTD.js +1 -1
- package/lib/firestore/api.js +6 -6
- package/lib/frameworks/angular/index.js +22 -24
- package/lib/frameworks/angular/utils.js +217 -97
- package/lib/frameworks/constants.js +6 -3
- package/lib/frameworks/next/index.js +4 -0
- package/lib/frameworks/next/utils.js +6 -2
- package/lib/functionsShellCommandAction.js +3 -3
- package/lib/gcp/cloudbuild.js +24 -3
- package/lib/gcp/storage.js +11 -5
- package/lib/hosting/runTags.js +2 -1
- package/lib/init/features/frameworks/index.js +24 -22
- package/lib/init/features/frameworks/repo.js +108 -36
- package/lib/localFunction.js +77 -14
- package/lib/utils.js +28 -1
- package/package.json +2 -3
- package/templates/popup.html +64 -0
- package/lib/commands/ext-dev-publish.js +0 -32
package/lib/apiv2.js
CHANGED
|
@@ -81,6 +81,13 @@ class Client {
|
|
|
81
81
|
});
|
|
82
82
|
return this.request(reqOptions);
|
|
83
83
|
}
|
|
84
|
+
options(path, options = {}) {
|
|
85
|
+
const reqOptions = Object.assign(options, {
|
|
86
|
+
method: "OPTIONS",
|
|
87
|
+
path,
|
|
88
|
+
});
|
|
89
|
+
return this.request(reqOptions);
|
|
90
|
+
}
|
|
84
91
|
async request(reqOptions) {
|
|
85
92
|
if (!reqOptions.responseType) {
|
|
86
93
|
reqOptions.responseType = "json";
|
package/lib/auth.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
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;
|
|
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
6
|
const fs = require("fs");
|
|
@@ -110,9 +110,7 @@ async function loginAdditionalAccount(useLocalhost, email) {
|
|
|
110
110
|
updateAccount(newAccount);
|
|
111
111
|
}
|
|
112
112
|
else {
|
|
113
|
-
|
|
114
|
-
additionalAccounts.push(newAccount);
|
|
115
|
-
configstore_1.configstore.set("additionalAccounts", additionalAccounts);
|
|
113
|
+
addAdditionalAccount(newAccount);
|
|
116
114
|
}
|
|
117
115
|
return newAccount;
|
|
118
116
|
}
|
|
@@ -533,3 +531,9 @@ async function logout(refreshToken) {
|
|
|
533
531
|
}
|
|
534
532
|
}
|
|
535
533
|
exports.logout = logout;
|
|
534
|
+
function addAdditionalAccount(account) {
|
|
535
|
+
const additionalAccounts = getAdditionalAccounts();
|
|
536
|
+
additionalAccounts.push(account);
|
|
537
|
+
configstore_1.configstore.set("additionalAccounts", additionalAccounts);
|
|
538
|
+
}
|
|
539
|
+
exports.addAdditionalAccount = addAdditionalAccount;
|
|
@@ -7,26 +7,64 @@ const error_1 = require("../error");
|
|
|
7
7
|
const gcp = require("../gcp/frameworks");
|
|
8
8
|
const prompt_1 = require("../prompt");
|
|
9
9
|
const utils = require("../utils");
|
|
10
|
+
const logger_1 = require("../logger");
|
|
11
|
+
const constants_1 = require("../init/features/frameworks/constants");
|
|
12
|
+
const Table = require("cli-table");
|
|
13
|
+
const COLUMN_LENGTH = 20;
|
|
14
|
+
const TABLE_HEAD = [
|
|
15
|
+
"Backend Id",
|
|
16
|
+
"Repository Name",
|
|
17
|
+
"Location",
|
|
18
|
+
"URL",
|
|
19
|
+
"Created Date",
|
|
20
|
+
"Updated Date",
|
|
21
|
+
];
|
|
10
22
|
exports.command = new command_1.Command("backends:delete")
|
|
11
23
|
.description("Delete a backend from a Firebase project")
|
|
12
|
-
.option("-l, --location <location>", "App Backend location", "
|
|
13
|
-
.option("-s, --
|
|
24
|
+
.option("-l, --location <location>", "App Backend location", "")
|
|
25
|
+
.option("-s, --backend <backend>", "Backend Id", "")
|
|
14
26
|
.withForce()
|
|
15
27
|
.action(async (options) => {
|
|
16
28
|
const projectId = (0, projectUtils_1.needProjectId)(options);
|
|
17
|
-
|
|
18
|
-
const backendId = options.
|
|
29
|
+
let location = options.location;
|
|
30
|
+
const backendId = options.backend;
|
|
19
31
|
if (!backendId) {
|
|
20
32
|
throw new error_1.FirebaseError("Backend id can't be empty.");
|
|
21
33
|
}
|
|
34
|
+
if (!location) {
|
|
35
|
+
location = await (0, prompt_1.promptOnce)({
|
|
36
|
+
name: "region",
|
|
37
|
+
type: "list",
|
|
38
|
+
default: constants_1.DEFAULT_REGION,
|
|
39
|
+
message: "Please select the region of the backend you'd like to delete:",
|
|
40
|
+
choices: constants_1.ALLOWED_REGIONS,
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
const table = new Table({
|
|
44
|
+
head: TABLE_HEAD,
|
|
45
|
+
style: { head: ["green"] },
|
|
46
|
+
});
|
|
47
|
+
table.colWidths = COLUMN_LENGTH;
|
|
48
|
+
let backend;
|
|
49
|
+
try {
|
|
50
|
+
backend = await gcp.getBackend(projectId, location, backendId);
|
|
51
|
+
populateTable(backend, table);
|
|
52
|
+
}
|
|
53
|
+
catch (err) {
|
|
54
|
+
throw new error_1.FirebaseError(`No backends found with given parameters. Command aborted.`, {
|
|
55
|
+
original: err,
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
utils.logWarning("You are about to permanently delete the backend:");
|
|
59
|
+
logger_1.logger.info(table.toString());
|
|
22
60
|
const confirmDeletion = await (0, prompt_1.promptOnce)({
|
|
23
61
|
type: "confirm",
|
|
24
62
|
name: "force",
|
|
25
63
|
default: false,
|
|
26
|
-
message: "
|
|
64
|
+
message: "Are you sure?",
|
|
27
65
|
}, options);
|
|
28
66
|
if (!confirmDeletion) {
|
|
29
|
-
throw new error_1.FirebaseError("Deletion
|
|
67
|
+
throw new error_1.FirebaseError("Deletion Aborted");
|
|
30
68
|
}
|
|
31
69
|
try {
|
|
32
70
|
await gcp.deleteBackend(projectId, location, backendId);
|
|
@@ -35,4 +73,26 @@ exports.command = new command_1.Command("backends:delete")
|
|
|
35
73
|
catch (err) {
|
|
36
74
|
throw new error_1.FirebaseError(`Failed to delete backend: ${backendId}. Please check the parameters you have provided.`, { original: err });
|
|
37
75
|
}
|
|
76
|
+
return backend;
|
|
38
77
|
});
|
|
78
|
+
function populateTable(backend, table) {
|
|
79
|
+
var _a;
|
|
80
|
+
const [location, , backendId] = backend.name.split("/").slice(3, 6);
|
|
81
|
+
const entry = [
|
|
82
|
+
backendId,
|
|
83
|
+
(_a = backend.codebase.repository) === null || _a === void 0 ? void 0 : _a.split("/").pop(),
|
|
84
|
+
location,
|
|
85
|
+
backend.uri,
|
|
86
|
+
backend.createTime,
|
|
87
|
+
backend.updateTime,
|
|
88
|
+
];
|
|
89
|
+
const newRow = entry.map((name) => {
|
|
90
|
+
const maxCellWidth = COLUMN_LENGTH - 2;
|
|
91
|
+
const chunks = [];
|
|
92
|
+
for (let i = 0; name && i < name.length; i += maxCellWidth) {
|
|
93
|
+
chunks.push(name.substring(i, i + maxCellWidth));
|
|
94
|
+
}
|
|
95
|
+
return chunks.join("\n");
|
|
96
|
+
});
|
|
97
|
+
table.push(newRow);
|
|
98
|
+
}
|
|
@@ -7,35 +7,74 @@ const gcp = require("../gcp/frameworks");
|
|
|
7
7
|
const error_1 = require("../error");
|
|
8
8
|
const logger_1 = require("../logger");
|
|
9
9
|
const Table = require("cli-table");
|
|
10
|
+
const COLUMN_LENGTH = 20;
|
|
11
|
+
const TABLE_HEAD = [
|
|
12
|
+
"Backend Id",
|
|
13
|
+
"Repository Name",
|
|
14
|
+
"Location",
|
|
15
|
+
"URL",
|
|
16
|
+
"Created Date",
|
|
17
|
+
"Updated Date",
|
|
18
|
+
];
|
|
10
19
|
exports.command = new command_1.Command("backends:get")
|
|
11
20
|
.description("Get backend details of a Firebase project")
|
|
12
|
-
.option("-l, --location <location>", "App Backend location", "
|
|
13
|
-
.option("
|
|
21
|
+
.option("-l, --location <location>", "App Backend location", "-")
|
|
22
|
+
.option("-b, --backend <backend>", "Backend Id", "")
|
|
14
23
|
.action(async (options) => {
|
|
15
24
|
const projectId = (0, projectUtils_1.needProjectId)(options);
|
|
16
25
|
const location = options.location;
|
|
17
|
-
const backendId = options.
|
|
26
|
+
const backendId = options.backend;
|
|
18
27
|
if (!backendId) {
|
|
19
28
|
throw new error_1.FirebaseError("Backend id can't be empty.");
|
|
20
29
|
}
|
|
21
|
-
let
|
|
30
|
+
let backendsList = [];
|
|
31
|
+
const table = new Table({
|
|
32
|
+
head: TABLE_HEAD,
|
|
33
|
+
style: { head: ["green"] },
|
|
34
|
+
});
|
|
35
|
+
table.colWidths = COLUMN_LENGTH;
|
|
22
36
|
try {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
37
|
+
if (location !== "-") {
|
|
38
|
+
const backendInRegion = await gcp.getBackend(projectId, location, backendId);
|
|
39
|
+
backendsList.push(backendInRegion);
|
|
40
|
+
populateTable(backendInRegion, table);
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
const allBackend = await gcp.listBackends(projectId, location);
|
|
44
|
+
backendsList = allBackend.backends.filter((bkd) => bkd.name.split("/").pop() === backendId);
|
|
45
|
+
backendsList.forEach((bkd) => populateTable(bkd, table));
|
|
46
|
+
}
|
|
47
|
+
if (backendsList.length !== 0) {
|
|
48
|
+
logger_1.logger.info(table.toString());
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
logger_1.logger.info();
|
|
52
|
+
logger_1.logger.info(`There are no backends with id: ${backendId}`);
|
|
53
|
+
}
|
|
36
54
|
}
|
|
37
55
|
catch (err) {
|
|
38
56
|
throw new error_1.FirebaseError(`Failed to get backend: ${backendId}. Please check the parameters you have provided.`, { original: err });
|
|
39
57
|
}
|
|
40
|
-
return
|
|
58
|
+
return backendsList;
|
|
41
59
|
});
|
|
60
|
+
function populateTable(backend, table) {
|
|
61
|
+
var _a;
|
|
62
|
+
const [location, , backendId] = backend.name.split("/").slice(3, 6);
|
|
63
|
+
const entry = [
|
|
64
|
+
backendId,
|
|
65
|
+
(_a = backend.codebase.repository) === null || _a === void 0 ? void 0 : _a.split("/").pop(),
|
|
66
|
+
location,
|
|
67
|
+
backend.uri,
|
|
68
|
+
backend.createTime,
|
|
69
|
+
backend.updateTime,
|
|
70
|
+
];
|
|
71
|
+
const newRow = entry.map((name) => {
|
|
72
|
+
const maxCellWidth = COLUMN_LENGTH - 2;
|
|
73
|
+
const chunks = [];
|
|
74
|
+
for (let i = 0; name && i < name.length; i += maxCellWidth) {
|
|
75
|
+
chunks.push(name.substring(i, i + maxCellWidth));
|
|
76
|
+
}
|
|
77
|
+
return chunks.join("\n");
|
|
78
|
+
});
|
|
79
|
+
table.push(newRow);
|
|
80
|
+
}
|
|
@@ -8,34 +8,61 @@ const error_1 = require("../error");
|
|
|
8
8
|
const logger_1 = require("../logger");
|
|
9
9
|
const colorette_1 = require("colorette");
|
|
10
10
|
const Table = require("cli-table");
|
|
11
|
+
const COLUMN_LENGTH = 20;
|
|
12
|
+
const TABLE_HEAD = [
|
|
13
|
+
"Backend Id",
|
|
14
|
+
"Repository Name",
|
|
15
|
+
"Location",
|
|
16
|
+
"URL",
|
|
17
|
+
"Created Date",
|
|
18
|
+
"Updated Date",
|
|
19
|
+
];
|
|
11
20
|
exports.command = new command_1.Command("backends:list")
|
|
12
21
|
.description("List backends of a Firebase project.")
|
|
13
|
-
.option("-l, --location <location>", "App Backend location", "
|
|
22
|
+
.option("-l, --location <location>", "App Backend location", "-")
|
|
14
23
|
.action(async (options) => {
|
|
15
24
|
const projectId = (0, projectUtils_1.needProjectId)(options);
|
|
16
25
|
const location = options.location;
|
|
17
26
|
const table = new Table({
|
|
18
|
-
head:
|
|
27
|
+
head: TABLE_HEAD,
|
|
19
28
|
style: { head: ["green"] },
|
|
20
29
|
});
|
|
21
|
-
|
|
30
|
+
table.colWidths = COLUMN_LENGTH;
|
|
31
|
+
const backendsList = [];
|
|
22
32
|
try {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
backend.codebase.repository,
|
|
28
|
-
backend.uri,
|
|
29
|
-
backend.createTime,
|
|
30
|
-
backend.updateTime,
|
|
31
|
-
];
|
|
32
|
-
table.push(entry);
|
|
33
|
-
}
|
|
33
|
+
const backendsPerRegion = await gcp.listBackends(projectId, location);
|
|
34
|
+
backendsList.push(backendsPerRegion);
|
|
35
|
+
populateTable(backendsPerRegion, location, table);
|
|
36
|
+
logger_1.logger.info();
|
|
34
37
|
logger_1.logger.info(`Backends for project ${(0, colorette_1.bold)(projectId)}`);
|
|
38
|
+
logger_1.logger.info();
|
|
35
39
|
logger_1.logger.info(table.toString());
|
|
36
40
|
}
|
|
37
41
|
catch (err) {
|
|
38
|
-
throw new error_1.FirebaseError(`Unable to list backends present
|
|
42
|
+
throw new error_1.FirebaseError(`Unable to list backends present for project: ${projectId}. Please check the parameters you have provided.`, { original: err });
|
|
39
43
|
}
|
|
40
44
|
return backendsList;
|
|
41
45
|
});
|
|
46
|
+
function populateTable(backendsLists, location, table) {
|
|
47
|
+
var _a;
|
|
48
|
+
for (const backend of backendsLists.backends) {
|
|
49
|
+
const [location, , backendId] = backend.name.split("/").slice(3, 6);
|
|
50
|
+
const entry = [
|
|
51
|
+
backendId,
|
|
52
|
+
(_a = backend.codebase.repository) === null || _a === void 0 ? void 0 : _a.split("/").pop(),
|
|
53
|
+
location,
|
|
54
|
+
backend.uri,
|
|
55
|
+
backend.createTime,
|
|
56
|
+
backend.updateTime,
|
|
57
|
+
];
|
|
58
|
+
const newRow = entry.map((name) => {
|
|
59
|
+
const maxCellWidth = COLUMN_LENGTH - 2;
|
|
60
|
+
const chunks = [];
|
|
61
|
+
for (let i = 0; name && i < name.length; i += maxCellWidth) {
|
|
62
|
+
chunks.push(name.substring(i, i + maxCellWidth));
|
|
63
|
+
}
|
|
64
|
+
return chunks.join("\n");
|
|
65
|
+
});
|
|
66
|
+
table.push(newRow);
|
|
67
|
+
}
|
|
68
|
+
}
|
package/lib/commands/index.js
CHANGED
|
@@ -90,7 +90,6 @@ function load(client) {
|
|
|
90
90
|
client.ext.dev.deprecate = loadCommand("ext-dev-deprecate");
|
|
91
91
|
client.ext.dev.undeprecate = loadCommand("ext-dev-undeprecate");
|
|
92
92
|
client.ext.dev.upload = loadCommand("ext-dev-upload");
|
|
93
|
-
client.ext.dev.publish = loadCommand("ext-dev-publish");
|
|
94
93
|
client.ext.dev.usage = loadCommand("ext-dev-usage");
|
|
95
94
|
client.firestore = {};
|
|
96
95
|
client.firestore.delete = loadCommand("firestore-delete");
|
|
@@ -7,7 +7,7 @@ const utils = require("../utils");
|
|
|
7
7
|
const auth = require("../auth");
|
|
8
8
|
const error_1 = require("../error");
|
|
9
9
|
exports.command = new command_1.Command("login:use <email>")
|
|
10
|
-
.description("set the default account to use for this project directory")
|
|
10
|
+
.description("set the default account to use for this project directory or the global default account if not in a Firebase project directory")
|
|
11
11
|
.action((email, options) => {
|
|
12
12
|
const allAccounts = auth.getAllAccounts();
|
|
13
13
|
const accountExists = allAccounts.some((a) => a.user.email === email);
|
|
@@ -15,10 +15,29 @@ exports.command = new command_1.Command("login:use <email>")
|
|
|
15
15
|
throw new error_1.FirebaseError(`Account ${email} does not exist, run "${clc.bold("firebase login:list")}" to see valid accounts`);
|
|
16
16
|
}
|
|
17
17
|
const projectDir = options.projectRoot;
|
|
18
|
-
if (
|
|
19
|
-
|
|
18
|
+
if (projectDir) {
|
|
19
|
+
if (options.user.email === email) {
|
|
20
|
+
throw new error_1.FirebaseError(`Already using account ${email} for this project directory.`);
|
|
21
|
+
}
|
|
22
|
+
auth.setProjectAccount(projectDir, email);
|
|
23
|
+
utils.logSuccess(`Set default account ${email} for current project directory.`);
|
|
24
|
+
return email;
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
if (options.user.email === email) {
|
|
28
|
+
throw new error_1.FirebaseError(`Already using account ${email} for the global default account.`);
|
|
29
|
+
}
|
|
30
|
+
const newDefaultAccount = allAccounts.find((a) => a.user.email === email);
|
|
31
|
+
if (!newDefaultAccount) {
|
|
32
|
+
throw new error_1.FirebaseError(`Account ${email} does not exist, run "${clc.bold("firebase login:list")}" to see valid accounts`);
|
|
33
|
+
}
|
|
34
|
+
const oldDefaultAccount = auth.getGlobalDefaultAccount();
|
|
35
|
+
if (!oldDefaultAccount) {
|
|
36
|
+
throw new error_1.FirebaseError("Could not determine global default account");
|
|
37
|
+
}
|
|
38
|
+
auth.setGlobalDefaultAccount(newDefaultAccount);
|
|
39
|
+
auth.addAdditionalAccount(oldDefaultAccount);
|
|
40
|
+
utils.logSuccess(`Set global default account to ${email}.`);
|
|
41
|
+
return email;
|
|
20
42
|
}
|
|
21
|
-
auth.setProjectAccount(projectDir, email);
|
|
22
|
-
utils.logSuccess(`Set default account ${email} for current project directory.`);
|
|
23
|
-
return email;
|
|
24
43
|
});
|
package/lib/config.js
CHANGED
|
@@ -40,15 +40,17 @@ class Config {
|
|
|
40
40
|
_.set(this.data, target, this.materialize(target));
|
|
41
41
|
}
|
|
42
42
|
});
|
|
43
|
-
if (this.
|
|
44
|
-
if (
|
|
45
|
-
if (
|
|
46
|
-
this.
|
|
43
|
+
if (this.get("functions")) {
|
|
44
|
+
if (this.projectDir && fsutils.dirExistsSync(this.path(Config.DEFAULT_FUNCTIONS_SOURCE))) {
|
|
45
|
+
if (Array.isArray(this.get("functions"))) {
|
|
46
|
+
if (!this.get("functions.[0].source")) {
|
|
47
|
+
this.set("functions.[0].source", Config.DEFAULT_FUNCTIONS_SOURCE);
|
|
48
|
+
}
|
|
47
49
|
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
50
|
+
else {
|
|
51
|
+
if (!this.get("functions.source")) {
|
|
52
|
+
this.set("functions.source", Config.DEFAULT_FUNCTIONS_SOURCE);
|
|
53
|
+
}
|
|
52
54
|
}
|
|
53
55
|
}
|
|
54
56
|
}
|
|
@@ -21,9 +21,9 @@ exports.RUNTIME_NOT_SET = "`runtime` field is required but was not found in fire
|
|
|
21
21
|
"To fix this, add the following lines to the `functions` section of your firebase.json:\n" +
|
|
22
22
|
'"runtime": "nodejs18"\n';
|
|
23
23
|
exports.UNSUPPORTED_NODE_VERSION_FIREBASE_JSON_MSG = clc.bold(`functions.runtime value is unsupported. ` +
|
|
24
|
-
`Valid choices are: ${clc.bold("nodejs{10|12|14|16|18}")}.`);
|
|
24
|
+
`Valid choices are: ${clc.bold("nodejs{10|12|14|16|18|20}")}.`);
|
|
25
25
|
exports.UNSUPPORTED_NODE_VERSION_PACKAGE_JSON_MSG = clc.bold(`package.json in functions directory has an engines field which is unsupported. ` +
|
|
26
|
-
`Valid choices are: ${clc.bold('{"node": 10|12|14|16|18}')}`);
|
|
26
|
+
`Valid choices are: ${clc.bold('{"node": 10|12|14|16|18|20}')}`);
|
|
27
27
|
exports.DEPRECATED_NODE_VERSION_INFO = `\n\nDeploys to runtimes below Node.js 10 are now disabled in the Firebase CLI. ` +
|
|
28
28
|
`${clc.bold(`Existing Node.js 8 functions ${clc.underline("will stop executing at a future date")}`)}. Update existing functions to Node.js 10 or greater as soon as possible.`;
|
|
29
29
|
function getRuntimeChoiceFromPackageJson(sourceDir) {
|
|
@@ -18,6 +18,11 @@ function runCommand(command, childOptions) {
|
|
|
18
18
|
const translatedCommand = '"' + nodeExecutable + '" "' + crossEnvShellPath + '" "' + escapedCommand + '"';
|
|
19
19
|
return new Promise((resolve, reject) => {
|
|
20
20
|
logger_1.logger.info("Running command: " + command);
|
|
21
|
+
if (command.includes("=")) {
|
|
22
|
+
utils.logWarning(clc.yellow(clc.bold("Warning: ")) +
|
|
23
|
+
"Your command contains '=', it may result in the command not running." +
|
|
24
|
+
" Please consider removing it.");
|
|
25
|
+
}
|
|
21
26
|
if (translatedCommand === "") {
|
|
22
27
|
return resolve();
|
|
23
28
|
}
|
package/lib/fetchMOTD.js
CHANGED
|
@@ -38,7 +38,7 @@ function fetchMOTD() {
|
|
|
38
38
|
configstore_1.configstore.set("motd.fetched", Date.now());
|
|
39
39
|
})
|
|
40
40
|
.catch((err) => {
|
|
41
|
-
utils.logWarning("Unable to fetch the CLI MOTD and remote config.");
|
|
41
|
+
utils.logWarning("Unable to fetch the CLI MOTD and remote config. This is not a fatal error, but may indicate an issue with your network connection.");
|
|
42
42
|
logger_1.logger.debug(`Failed to fetch MOTD ${err}`);
|
|
43
43
|
});
|
|
44
44
|
}
|
package/lib/firestore/api.js
CHANGED
|
@@ -54,9 +54,9 @@ class FirestoreApi {
|
|
|
54
54
|
utils.logLabeledBullet("firestore", `The following indexes are defined in your project but are not present in your firestore indexes file:\n\t${indexesString}`);
|
|
55
55
|
}
|
|
56
56
|
if (!shouldDeleteIndexes) {
|
|
57
|
-
shouldDeleteIndexes = await (0, prompt_1.
|
|
58
|
-
|
|
59
|
-
|
|
57
|
+
shouldDeleteIndexes = await (0, prompt_1.confirm)({
|
|
58
|
+
nonInteractive: options.nonInteractive,
|
|
59
|
+
force: options.force,
|
|
60
60
|
default: false,
|
|
61
61
|
message: "Would you like to delete these indexes? Selecting no will continue the rest of the deployment.",
|
|
62
62
|
});
|
|
@@ -91,9 +91,9 @@ class FirestoreApi {
|
|
|
91
91
|
utils.logLabeledBullet("firestore", `The following field overrides are defined in your project but are not present in your firestore indexes file:\n\t${indexesString}`);
|
|
92
92
|
}
|
|
93
93
|
if (!shouldDeleteFields) {
|
|
94
|
-
shouldDeleteFields = await (0, prompt_1.
|
|
95
|
-
|
|
96
|
-
|
|
94
|
+
shouldDeleteFields = await (0, prompt_1.confirm)({
|
|
95
|
+
nonInteractive: options.nonInteractive,
|
|
96
|
+
force: options.force,
|
|
97
97
|
default: false,
|
|
98
98
|
message: "Would you like to delete these field overrides? Selecting no will continue the rest of the deployment.",
|
|
99
99
|
});
|
|
@@ -6,7 +6,6 @@ const child_process_1 = require("child_process");
|
|
|
6
6
|
const cross_spawn_1 = require("cross-spawn");
|
|
7
7
|
const fs_extra_1 = require("fs-extra");
|
|
8
8
|
const promises_1 = require("fs/promises");
|
|
9
|
-
const prompt_1 = require("../../prompt");
|
|
10
9
|
const utils_1 = require("../utils");
|
|
11
10
|
const utils_2 = require("./utils");
|
|
12
11
|
const constants_1 = require("../constants");
|
|
@@ -24,27 +23,16 @@ async function discover(dir) {
|
|
|
24
23
|
return { mayWantBackend: true, publicDirectory: (0, path_1.join)(dir, "src", "assets") };
|
|
25
24
|
}
|
|
26
25
|
exports.discover = discover;
|
|
27
|
-
|
|
26
|
+
function init(setup, config) {
|
|
28
27
|
(0, child_process_1.execSync)(`npx --yes -p @angular/cli@latest ng new ${setup.projectId} --directory ${setup.hosting.source} --skip-git`, {
|
|
29
28
|
stdio: "inherit",
|
|
30
29
|
cwd: config.projectDir,
|
|
31
30
|
});
|
|
32
|
-
|
|
33
|
-
name: "useAngularUniversal",
|
|
34
|
-
type: "confirm",
|
|
35
|
-
default: false,
|
|
36
|
-
message: `Would you like to setup Angular Universal?`,
|
|
37
|
-
});
|
|
38
|
-
if (useAngularUniversal) {
|
|
39
|
-
(0, child_process_1.execSync)("ng add @nguniversal/express-engine --skip-confirmation", {
|
|
40
|
-
stdio: "inherit",
|
|
41
|
-
cwd: (0, path_1.join)(config.projectDir, setup.hosting.source),
|
|
42
|
-
});
|
|
43
|
-
}
|
|
31
|
+
return Promise.resolve();
|
|
44
32
|
}
|
|
45
33
|
exports.init = init;
|
|
46
34
|
async function build(dir, configuration) {
|
|
47
|
-
const { targets,
|
|
35
|
+
const { targets, serveOptimizedImages, locales, baseHref: baseUrl, ssr, } = await (0, utils_2.getBuildConfig)(dir, configuration);
|
|
48
36
|
await (0, utils_1.warnIfCustomBuildScript)(dir, exports.name, DEFAULT_BUILD_SCRIPT);
|
|
49
37
|
for (const target of targets) {
|
|
50
38
|
const cli = (0, utils_1.getNodeModuleBin)("ng", dir);
|
|
@@ -55,8 +43,8 @@ async function build(dir, configuration) {
|
|
|
55
43
|
if (result.status !== 0)
|
|
56
44
|
throw new error_1.FirebaseError(`Unable to build ${target}`);
|
|
57
45
|
}
|
|
58
|
-
const wantsBackend =
|
|
59
|
-
const rewrites =
|
|
46
|
+
const wantsBackend = ssr || serveOptimizedImages;
|
|
47
|
+
const rewrites = ssr
|
|
60
48
|
? []
|
|
61
49
|
: [
|
|
62
50
|
{
|
|
@@ -114,8 +102,11 @@ exports.ɵcodegenPublicDirectory = ɵcodegenPublicDirectory;
|
|
|
114
102
|
async function getValidBuildTargets(purpose, dir) {
|
|
115
103
|
const validTargetNames = new Set(["development", "production"]);
|
|
116
104
|
try {
|
|
117
|
-
const { workspaceProject, browserTarget,
|
|
118
|
-
const { target } = ((purpose === "emulate" && serveTarget) ||
|
|
105
|
+
const { workspaceProject, buildTarget, browserTarget, prerenderTarget, serveTarget } = await (0, utils_2.getContext)(dir);
|
|
106
|
+
const { target } = ((purpose === "emulate" && serveTarget) ||
|
|
107
|
+
buildTarget ||
|
|
108
|
+
prerenderTarget ||
|
|
109
|
+
browserTarget);
|
|
119
110
|
const workspaceTarget = workspaceProject.targets.get(target);
|
|
120
111
|
Object.keys(workspaceTarget.configurations || {}).forEach((it) => validTargetNames.add(it));
|
|
121
112
|
}
|
|
@@ -135,7 +126,7 @@ exports.shouldUseDevModeHandle = shouldUseDevModeHandle;
|
|
|
135
126
|
async function ɵcodegenFunctionsDirectory(sourceDir, destDir, configuration) {
|
|
136
127
|
var _a;
|
|
137
128
|
var _b;
|
|
138
|
-
const { packageJson, serverOutputPath, browserOutputPath, defaultLocale, serverLocales, browserLocales, bundleDependencies, externalDependencies, baseHref, serveOptimizedImages, } = await (0, utils_2.getServerConfig)(sourceDir, configuration);
|
|
129
|
+
const { packageJson, serverOutputPath, browserOutputPath, defaultLocale, serverLocales, browserLocales, bundleDependencies, externalDependencies, baseHref, serveOptimizedImages, serverEntry, } = await (0, utils_2.getServerConfig)(sourceDir, configuration);
|
|
139
130
|
const dotEnv = { __NG_BROWSER_OUTPUT_PATH__: browserOutputPath };
|
|
140
131
|
let rewriteSource = undefined;
|
|
141
132
|
await Promise.all([
|
|
@@ -176,15 +167,22 @@ exports.handle = function(req,res) {
|
|
|
176
167
|
if (localizedApps.has(locale)) {
|
|
177
168
|
localizedApps.get(locale)(req,res);
|
|
178
169
|
} else {
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
170
|
+
${(serverEntry === null || serverEntry === void 0 ? void 0 : serverEntry.endsWith(".mjs"))
|
|
171
|
+
? `import(\`./${serverOutputPath}/\${locale}/${serverEntry}\`)`
|
|
172
|
+
: `Promise.resolve(require(\`./${serverOutputPath}/\${locale}/${serverEntry}\`))`}.then(server => {
|
|
173
|
+
const app = server.app(locale);
|
|
174
|
+
localizedApps.set(locale, app);
|
|
175
|
+
app(req,res);
|
|
176
|
+
});
|
|
182
177
|
}
|
|
183
178
|
});
|
|
184
179
|
};\n`;
|
|
185
180
|
}
|
|
186
181
|
else if (serverOutputPath) {
|
|
187
|
-
bootstrapScript = `
|
|
182
|
+
bootstrapScript = `const app = ${(serverEntry === null || serverEntry === void 0 ? void 0 : serverEntry.endsWith(".mjs"))
|
|
183
|
+
? `import(\`./${serverOutputPath}/${serverEntry}\`)`
|
|
184
|
+
: `Promise.resolve(require('./${serverOutputPath}/${serverEntry}'))`}.then(server => server.app());
|
|
185
|
+
exports.handle = (req,res) => app.then(it => it(req,res));\n`;
|
|
188
186
|
}
|
|
189
187
|
else {
|
|
190
188
|
bootstrapScript = `exports.handle = (res, req) => req.sendStatus(404);\n`;
|