firebase-tools 10.3.1 → 10.4.2
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/accountExporter.js +95 -84
- package/lib/commands/deploy.js +1 -1
- package/lib/commands/experimental-functions-shell.js +1 -1
- package/lib/commands/ext-configure.js +7 -6
- package/lib/commands/ext-export.js +7 -1
- package/lib/commands/ext-install.js +7 -6
- package/lib/commands/ext-update.js +4 -3
- package/lib/commands/functions-config-export.js +5 -3
- package/lib/commands/functions-shell.js +1 -1
- package/lib/commands/hosting-channel-create.js +2 -2
- package/lib/commands/hosting-channel-delete.js +2 -2
- package/lib/commands/hosting-channel-deploy.js +2 -2
- package/lib/commands/hosting-channel-list.js +2 -2
- package/lib/commands/hosting-channel-open.js +2 -2
- package/lib/commands/hosting-sites-delete.js +2 -2
- package/lib/commands/serve.js +1 -1
- package/lib/commands/target-apply.js +2 -2
- package/lib/commands/target-clear.js +2 -2
- package/lib/commands/target-remove.js +2 -2
- package/lib/commands/target.js +2 -2
- package/lib/config.js +14 -4
- package/lib/deploy/extensions/planner.js +9 -3
- package/lib/deploy/functions/checkIam.js +44 -1
- package/lib/deploy/functions/deploy.js +3 -7
- package/lib/deploy/functions/prepare.js +7 -5
- package/lib/deploy/functions/prepareFunctionsUpload.js +7 -13
- package/lib/deploy/functions/release/fabricator.js +13 -1
- package/lib/deploy/functions/release/index.js +1 -1
- package/lib/deploy/functions/services/firebaseAlerts.js +1 -17
- package/lib/deploy/functions/services/index.js +2 -1
- package/lib/deploy/hosting/deploy.js +10 -0
- package/lib/emulator/auth/apiSpec.js +37 -0
- package/lib/emulator/commandUtils.js +2 -2
- package/lib/emulator/controller.js +14 -8
- package/lib/emulator/downloadableEmulators.js +5 -5
- package/lib/emulator/extensionsEmulator.js +3 -0
- package/lib/emulator/functionsEmulator.js +8 -18
- package/lib/emulator/functionsEmulatorShared.js +31 -1
- package/lib/emulator/storage/apis/firebase.js +4 -6
- package/lib/emulator/storage/files.js +5 -5
- package/lib/emulator/storage/index.js +6 -9
- package/lib/emulator/storage/rules/config.js +6 -5
- package/lib/emulator/storage/rules/manager.js +49 -32
- package/lib/emulator/storage/rules/runtime.js +4 -0
- package/lib/emulator/storage/rules/utils.js +2 -2
- package/lib/emulator/storage/server.js +1 -1
- package/lib/extensions/askUserForParam.js +87 -16
- package/lib/extensions/extensionsHelper.js +11 -2
- package/lib/extensions/manifest.js +36 -4
- package/lib/extensions/paramHelper.js +11 -6
- package/lib/fsutils.js +14 -1
- package/lib/functions/projectConfig.js +34 -0
- package/lib/init/features/functions/index.js +4 -2
- package/lib/init/features/hosting/index.js +32 -41
- package/lib/init/features/index.js +22 -12
- package/lib/init/index.js +28 -11
- package/lib/requireConfig.js +11 -9
- package/lib/requirePermissions.js +4 -1
- package/lib/serve/functions.js +5 -5
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
- package/schema/firebase-config.json +93 -36
- package/lib/prepareUpload.js +0 -44
|
@@ -57,14 +57,19 @@ async function getParams(args) {
|
|
|
57
57
|
}
|
|
58
58
|
else if (args.paramsEnvPath) {
|
|
59
59
|
params = getParamsFromFile({
|
|
60
|
-
projectId: args.projectId,
|
|
61
60
|
paramSpecs: args.paramSpecs,
|
|
62
61
|
paramsEnvPath: args.paramsEnvPath,
|
|
63
62
|
});
|
|
64
63
|
}
|
|
65
64
|
else {
|
|
66
65
|
const firebaseProjectParams = await (0, extensionsHelper_1.getFirebaseProjectParams)(args.projectId);
|
|
67
|
-
params = await askUserForParam.ask(
|
|
66
|
+
params = await askUserForParam.ask({
|
|
67
|
+
projectId: args.projectId,
|
|
68
|
+
instanceId: args.instanceId,
|
|
69
|
+
paramSpecs: args.paramSpecs,
|
|
70
|
+
firebaseProjectParams,
|
|
71
|
+
reconfiguring: !!args.reconfiguring,
|
|
72
|
+
});
|
|
68
73
|
}
|
|
69
74
|
void track("Extension Params", _.isEmpty(params) ? "Not Present" : "Present", _.size(params));
|
|
70
75
|
return params;
|
|
@@ -85,7 +90,6 @@ async function getParamsForUpdate(args) {
|
|
|
85
90
|
}
|
|
86
91
|
else if (args.paramsEnvPath) {
|
|
87
92
|
params = getParamsFromFile({
|
|
88
|
-
projectId: args.projectId,
|
|
89
93
|
paramSpecs: args.newSpec.params,
|
|
90
94
|
paramsEnvPath: args.paramsEnvPath,
|
|
91
95
|
});
|
|
@@ -104,6 +108,7 @@ async function getParamsForUpdate(args) {
|
|
|
104
108
|
}
|
|
105
109
|
exports.getParamsForUpdate = getParamsForUpdate;
|
|
106
110
|
async function promptForNewParams(args) {
|
|
111
|
+
const newParamBindingOptions = buildBindingOptionsWithBaseValue(args.currentParams);
|
|
107
112
|
const firebaseProjectParams = await (0, extensionsHelper_1.getFirebaseProjectParams)(args.projectId);
|
|
108
113
|
const comparer = (param1, param2) => {
|
|
109
114
|
return param1.type === param2.type && param1.param === param2.param;
|
|
@@ -117,7 +122,7 @@ async function promptForNewParams(args) {
|
|
|
117
122
|
logger_1.logger.info("The following params will no longer be used:");
|
|
118
123
|
paramsDiffDeletions.forEach((param) => {
|
|
119
124
|
logger_1.logger.info(clc.red(`- ${param.param}: ${args.currentParams[param.param.toUpperCase()]}`));
|
|
120
|
-
delete
|
|
125
|
+
delete newParamBindingOptions[param.param.toUpperCase()];
|
|
121
126
|
});
|
|
122
127
|
}
|
|
123
128
|
if (paramsDiffAdditions.length) {
|
|
@@ -129,10 +134,10 @@ async function promptForNewParams(args) {
|
|
|
129
134
|
paramSpec: param,
|
|
130
135
|
reconfiguring: false,
|
|
131
136
|
});
|
|
132
|
-
|
|
137
|
+
newParamBindingOptions[param.param] = chosenValue;
|
|
133
138
|
}
|
|
134
139
|
}
|
|
135
|
-
return
|
|
140
|
+
return newParamBindingOptions;
|
|
136
141
|
}
|
|
137
142
|
exports.promptForNewParams = promptForNewParams;
|
|
138
143
|
function getParamsFromFile(args) {
|
package/lib/fsutils.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.dirExistsSync = exports.fileExistsSync = void 0;
|
|
3
|
+
exports.readFile = exports.dirExistsSync = exports.fileExistsSync = void 0;
|
|
4
4
|
const fs_1 = require("fs");
|
|
5
|
+
const error_1 = require("./error");
|
|
5
6
|
function fileExistsSync(path) {
|
|
6
7
|
try {
|
|
7
8
|
return (0, fs_1.statSync)(path).isFile();
|
|
@@ -20,3 +21,15 @@ function dirExistsSync(path) {
|
|
|
20
21
|
}
|
|
21
22
|
}
|
|
22
23
|
exports.dirExistsSync = dirExistsSync;
|
|
24
|
+
function readFile(path) {
|
|
25
|
+
try {
|
|
26
|
+
return (0, fs_1.readFileSync)(path).toString();
|
|
27
|
+
}
|
|
28
|
+
catch (e) {
|
|
29
|
+
if (e.code === "ENOENT") {
|
|
30
|
+
throw new error_1.FirebaseError(`File not found: ${path}`);
|
|
31
|
+
}
|
|
32
|
+
throw e;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
exports.readFile = readFile;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.normalizeAndValidate = exports.validate = exports.normalize = void 0;
|
|
4
|
+
const error_1 = require("../error");
|
|
5
|
+
function normalize(config) {
|
|
6
|
+
if (!config) {
|
|
7
|
+
throw new error_1.FirebaseError("No valid functions configuration detected in firebase.json");
|
|
8
|
+
}
|
|
9
|
+
if (Array.isArray(config)) {
|
|
10
|
+
if (config.length < 1) {
|
|
11
|
+
throw new error_1.FirebaseError("Requires at least one functions.source in firebase.json.");
|
|
12
|
+
}
|
|
13
|
+
return config;
|
|
14
|
+
}
|
|
15
|
+
return [config];
|
|
16
|
+
}
|
|
17
|
+
exports.normalize = normalize;
|
|
18
|
+
function validateSingle(config) {
|
|
19
|
+
if (!config.source) {
|
|
20
|
+
throw new error_1.FirebaseError("functions.source must be specified");
|
|
21
|
+
}
|
|
22
|
+
return Object.assign(Object.assign({}, config), { source: config.source });
|
|
23
|
+
}
|
|
24
|
+
function validate(config) {
|
|
25
|
+
if (config.length > 1) {
|
|
26
|
+
throw new error_1.FirebaseError("More than one functions.source detected in firebase.json.");
|
|
27
|
+
}
|
|
28
|
+
return [validateSingle(config[0])];
|
|
29
|
+
}
|
|
30
|
+
exports.validate = validate;
|
|
31
|
+
function normalizeAndValidate(config) {
|
|
32
|
+
return validate(normalize(config));
|
|
33
|
+
}
|
|
34
|
+
exports.normalizeAndValidate = normalizeAndValidate;
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.doSetup = void 0;
|
|
3
4
|
const clc = require("cli-color");
|
|
4
5
|
const logger_1 = require("../../../logger");
|
|
5
6
|
const prompt_1 = require("../../../prompt");
|
|
6
7
|
const requirePermissions_1 = require("../../../requirePermissions");
|
|
7
8
|
const previews_1 = require("../../../previews");
|
|
8
9
|
const ensureApiEnabled_1 = require("../../../ensureApiEnabled");
|
|
9
|
-
|
|
10
|
+
async function doSetup(setup, config, options) {
|
|
10
11
|
var _a, _b;
|
|
11
12
|
logger_1.logger.info();
|
|
12
13
|
logger_1.logger.info("A " + clc.bold("functions") + " directory will be created in your project with sample code");
|
|
@@ -44,4 +45,5 @@ module.exports = async function (setup, config, options) {
|
|
|
44
45
|
choices,
|
|
45
46
|
});
|
|
46
47
|
return require("./" + language)(setup, config);
|
|
47
|
-
}
|
|
48
|
+
}
|
|
49
|
+
exports.doSetup = doSetup;
|
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.doSetup = void 0;
|
|
2
4
|
const clc = require("cli-color");
|
|
3
5
|
const fs = require("fs");
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
const
|
|
6
|
+
const apiv2_1 = require("../../../apiv2");
|
|
7
|
+
const github_1 = require("./github");
|
|
8
|
+
const prompt_1 = require("../../../prompt");
|
|
9
|
+
const logger_1 = require("../../../logger");
|
|
8
10
|
const INDEX_TEMPLATE = fs.readFileSync(__dirname + "/../../../../templates/init/hosting/index.html", "utf8");
|
|
9
11
|
const MISSING_TEMPLATE = fs.readFileSync(__dirname + "/../../../../templates/init/hosting/404.html", "utf8");
|
|
10
12
|
const DEFAULT_IGNORES = ["firebase.json", "**/.*", "**/node_modules/**"];
|
|
11
|
-
|
|
13
|
+
async function doSetup(setup, config, options) {
|
|
12
14
|
setup.hosting = {};
|
|
13
|
-
logger.info();
|
|
14
|
-
logger.info(
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
logger.info(
|
|
18
|
-
|
|
19
|
-
logger.info();
|
|
20
|
-
return prompt(setup.hosting, [
|
|
15
|
+
logger_1.logger.info();
|
|
16
|
+
logger_1.logger.info(`Your ${clc.bold("public")} directory is the folder (relative to your project directory) that`);
|
|
17
|
+
logger_1.logger.info(`will contain Hosting assets to be uploaded with ${clc.bold("firebase deploy")}. If you`);
|
|
18
|
+
logger_1.logger.info("have a build process for your assets, use your build's output directory.");
|
|
19
|
+
logger_1.logger.info();
|
|
20
|
+
await (0, prompt_1.prompt)(setup.hosting, [
|
|
21
21
|
{
|
|
22
22
|
name: "public",
|
|
23
23
|
type: "input",
|
|
@@ -36,31 +36,22 @@ module.exports = function (setup, config, options) {
|
|
|
36
36
|
default: false,
|
|
37
37
|
message: "Set up automatic builds and deploys with GitHub?",
|
|
38
38
|
},
|
|
39
|
-
])
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
return config.askWriteProjectFile(setup.hosting.public + "/index.html", INDEX_TEMPLATE.replace(/{{VERSION}}/g, response.body.current.version));
|
|
59
|
-
})
|
|
60
|
-
.then(() => {
|
|
61
|
-
if (setup.hosting.github) {
|
|
62
|
-
return initGitHub(setup, config, options);
|
|
63
|
-
}
|
|
64
|
-
});
|
|
65
|
-
});
|
|
66
|
-
};
|
|
39
|
+
]);
|
|
40
|
+
setup.config.hosting = {
|
|
41
|
+
public: setup.hosting.public,
|
|
42
|
+
ignore: DEFAULT_IGNORES,
|
|
43
|
+
};
|
|
44
|
+
if (setup.hosting.spa) {
|
|
45
|
+
setup.config.hosting.rewrites = [{ source: "**", destination: "/index.html" }];
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
await config.askWriteProjectFile(`${setup.hosting.public}/404.html`, MISSING_TEMPLATE);
|
|
49
|
+
}
|
|
50
|
+
const c = new apiv2_1.Client({ urlPrefix: "https://www.gstatic.com", auth: false });
|
|
51
|
+
const response = await c.get("/firebasejs/releases.json");
|
|
52
|
+
await config.askWriteProjectFile(`${setup.hosting.public}/index.html`, INDEX_TEMPLATE.replace(/{{VERSION}}/g, response.body.current.version));
|
|
53
|
+
if (setup.hosting.github) {
|
|
54
|
+
return (0, github_1.initGitHub)(setup, config, options);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
exports.doSetup = doSetup;
|
|
@@ -1,13 +1,23 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
};
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.hostingGithub = exports.remoteconfig = exports.project = exports.emulators = exports.storage = exports.hosting = exports.functions = exports.firestore = exports.database = exports.account = void 0;
|
|
4
|
+
var account_1 = require("./account");
|
|
5
|
+
Object.defineProperty(exports, "account", { enumerable: true, get: function () { return account_1.doSetup; } });
|
|
6
|
+
var database_1 = require("./database");
|
|
7
|
+
Object.defineProperty(exports, "database", { enumerable: true, get: function () { return database_1.doSetup; } });
|
|
8
|
+
var firestore_1 = require("./firestore");
|
|
9
|
+
Object.defineProperty(exports, "firestore", { enumerable: true, get: function () { return firestore_1.doSetup; } });
|
|
10
|
+
var functions_1 = require("./functions");
|
|
11
|
+
Object.defineProperty(exports, "functions", { enumerable: true, get: function () { return functions_1.doSetup; } });
|
|
12
|
+
var hosting_1 = require("./hosting");
|
|
13
|
+
Object.defineProperty(exports, "hosting", { enumerable: true, get: function () { return hosting_1.doSetup; } });
|
|
14
|
+
var storage_1 = require("./storage");
|
|
15
|
+
Object.defineProperty(exports, "storage", { enumerable: true, get: function () { return storage_1.doSetup; } });
|
|
16
|
+
var emulators_1 = require("./emulators");
|
|
17
|
+
Object.defineProperty(exports, "emulators", { enumerable: true, get: function () { return emulators_1.doSetup; } });
|
|
18
|
+
var project_1 = require("./project");
|
|
19
|
+
Object.defineProperty(exports, "project", { enumerable: true, get: function () { return project_1.doSetup; } });
|
|
20
|
+
var remoteconfig_1 = require("./remoteconfig");
|
|
21
|
+
Object.defineProperty(exports, "remoteconfig", { enumerable: true, get: function () { return remoteconfig_1.doSetup; } });
|
|
22
|
+
var github_1 = require("./hosting/github");
|
|
23
|
+
Object.defineProperty(exports, "hostingGithub", { enumerable: true, get: function () { return github_1.initGitHub; } });
|
package/lib/init/index.js
CHANGED
|
@@ -1,22 +1,39 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.init = void 0;
|
|
4
|
-
const
|
|
4
|
+
const lodash_1 = require("lodash");
|
|
5
5
|
const clc = require("cli-color");
|
|
6
|
+
const error_1 = require("../error");
|
|
6
7
|
const logger_1 = require("../logger");
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
|
|
8
|
+
const features = require("./features");
|
|
9
|
+
const featureFns = new Map([
|
|
10
|
+
["account", features.account],
|
|
11
|
+
["database", features.database],
|
|
12
|
+
["firestore", features.firestore],
|
|
13
|
+
["functions", features.functions],
|
|
14
|
+
["hosting", features.hosting],
|
|
15
|
+
["storage", features.storage],
|
|
16
|
+
["emulators", features.emulators],
|
|
17
|
+
["project", features.project],
|
|
18
|
+
["remoteconfig", features.remoteconfig],
|
|
19
|
+
["hosting:github", features.hostingGithub],
|
|
20
|
+
]);
|
|
10
21
|
async function init(setup, config, options) {
|
|
11
|
-
|
|
22
|
+
var _a;
|
|
23
|
+
const nextFeature = (_a = setup.features) === null || _a === void 0 ? void 0 : _a.shift();
|
|
12
24
|
if (nextFeature) {
|
|
13
|
-
if (!
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
25
|
+
if (!featureFns.has(nextFeature)) {
|
|
26
|
+
const availableFeatures = Object.keys(features)
|
|
27
|
+
.filter((f) => f !== "project")
|
|
28
|
+
.join(", ");
|
|
29
|
+
throw new error_1.FirebaseError(`${clc.bold(nextFeature)} is not a valid feature. Must be one of ${availableFeatures}`);
|
|
17
30
|
}
|
|
18
|
-
logger_1.logger.info(clc.bold(
|
|
19
|
-
|
|
31
|
+
logger_1.logger.info(clc.bold(`\n${clc.white("===")} ${(0, lodash_1.capitalize)(nextFeature)} Setup`));
|
|
32
|
+
const fn = featureFns.get(nextFeature);
|
|
33
|
+
if (!fn) {
|
|
34
|
+
throw new error_1.FirebaseError(`We've lost the function to init ${nextFeature}`, { exit: 2 });
|
|
35
|
+
}
|
|
36
|
+
await fn(setup, config, options);
|
|
20
37
|
return init(setup, config, options);
|
|
21
38
|
}
|
|
22
39
|
}
|
package/lib/requireConfig.js
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.requireConfig = void 0;
|
|
4
|
+
const error_1 = require("./error");
|
|
5
|
+
async function requireConfig(options) {
|
|
6
|
+
await Promise.resolve();
|
|
7
|
+
if (!options.config) {
|
|
8
|
+
throw options.configError
|
|
9
|
+
? options.configError
|
|
10
|
+
: new error_1.FirebaseError("Not in a Firebase project directory (could not locate firebase.json)");
|
|
6
11
|
}
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
exit: 1,
|
|
10
|
-
}));
|
|
11
|
-
};
|
|
12
|
+
}
|
|
13
|
+
exports.requireConfig = requireConfig;
|
|
@@ -9,7 +9,10 @@ const error_1 = require("./error");
|
|
|
9
9
|
const iam_1 = require("./gcp/iam");
|
|
10
10
|
const BASE_PERMISSIONS = ["firebase.projects.get"];
|
|
11
11
|
async function requirePermissions(options, permissions = []) {
|
|
12
|
-
const projectId = (0, projectUtils_1.
|
|
12
|
+
const projectId = (0, projectUtils_1.getProjectId)(options);
|
|
13
|
+
if (!projectId) {
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
13
16
|
const requiredPermissions = BASE_PERMISSIONS.concat(permissions).sort();
|
|
14
17
|
await (0, requireAuth_1.requireAuth)(options);
|
|
15
18
|
logger_1.logger.debug(`[iam] checking project ${projectId} for permissions ${JSON.stringify(requiredPermissions)}`);
|
package/lib/serve/functions.js
CHANGED
|
@@ -7,6 +7,7 @@ const emulatorServer_1 = require("../emulator/emulatorServer");
|
|
|
7
7
|
const functionsEmulatorUtils_1 = require("../emulator/functionsEmulatorUtils");
|
|
8
8
|
const projectUtils_1 = require("../projectUtils");
|
|
9
9
|
const auth_1 = require("../auth");
|
|
10
|
+
const projectConfig = require("../functions/projectConfig");
|
|
10
11
|
const utils = require("../utils");
|
|
11
12
|
class FunctionsServer {
|
|
12
13
|
constructor() {
|
|
@@ -20,11 +21,10 @@ class FunctionsServer {
|
|
|
20
21
|
}
|
|
21
22
|
async start(options, partialArgs) {
|
|
22
23
|
const projectId = (0, projectUtils_1.needProjectId)(options);
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
const functionsDir = path.join(options.config.projectDir, options.config.src.functions.source);
|
|
24
|
+
const config = projectConfig.normalizeAndValidate(options.config.src.functions)[0];
|
|
25
|
+
const functionsDir = path.join(options.config.projectDir, config.source);
|
|
26
26
|
const account = (0, auth_1.getProjectDefaultAccount)(options.config.projectDir);
|
|
27
|
-
const nodeMajorVersion = (0, functionsEmulatorUtils_1.parseRuntimeVersion)(
|
|
27
|
+
const nodeMajorVersion = (0, functionsEmulatorUtils_1.parseRuntimeVersion)(config.runtime);
|
|
28
28
|
this.backend = {
|
|
29
29
|
functionsDir,
|
|
30
30
|
nodeMajorVersion,
|
|
@@ -40,7 +40,7 @@ class FunctionsServer {
|
|
|
40
40
|
utils.assertIsNumber(options.port);
|
|
41
41
|
const targets = options.targets;
|
|
42
42
|
const port = options.port;
|
|
43
|
-
const hostingRunning = targets && targets.
|
|
43
|
+
const hostingRunning = targets && targets.includes("hosting");
|
|
44
44
|
if (hostingRunning) {
|
|
45
45
|
args.port = port + 1;
|
|
46
46
|
}
|
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "firebase-tools",
|
|
3
|
-
"version": "10.
|
|
3
|
+
"version": "10.4.2",
|
|
4
4
|
"lockfileVersion": 2,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "firebase-tools",
|
|
9
|
-
"version": "10.
|
|
9
|
+
"version": "10.4.2",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@google-cloud/pubsub": "^2.18.4",
|
package/package.json
CHANGED
|
@@ -326,54 +326,111 @@
|
|
|
326
326
|
"type": "object"
|
|
327
327
|
},
|
|
328
328
|
"functions": {
|
|
329
|
-
"
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
"
|
|
333
|
-
"
|
|
334
|
-
},
|
|
335
|
-
"type": "array"
|
|
336
|
-
},
|
|
337
|
-
"postdeploy": {
|
|
338
|
-
"anyOf": [
|
|
339
|
-
{
|
|
329
|
+
"anyOf": [
|
|
330
|
+
{
|
|
331
|
+
"additionalProperties": false,
|
|
332
|
+
"properties": {
|
|
333
|
+
"ignore": {
|
|
340
334
|
"items": {
|
|
341
335
|
"type": "string"
|
|
342
336
|
},
|
|
343
337
|
"type": "array"
|
|
344
338
|
},
|
|
345
|
-
{
|
|
339
|
+
"postdeploy": {
|
|
340
|
+
"anyOf": [
|
|
341
|
+
{
|
|
342
|
+
"items": {
|
|
343
|
+
"type": "string"
|
|
344
|
+
},
|
|
345
|
+
"type": "array"
|
|
346
|
+
},
|
|
347
|
+
{
|
|
348
|
+
"type": "string"
|
|
349
|
+
}
|
|
350
|
+
]
|
|
351
|
+
},
|
|
352
|
+
"predeploy": {
|
|
353
|
+
"anyOf": [
|
|
354
|
+
{
|
|
355
|
+
"items": {
|
|
356
|
+
"type": "string"
|
|
357
|
+
},
|
|
358
|
+
"type": "array"
|
|
359
|
+
},
|
|
360
|
+
{
|
|
361
|
+
"type": "string"
|
|
362
|
+
}
|
|
363
|
+
]
|
|
364
|
+
},
|
|
365
|
+
"runtime": {
|
|
366
|
+
"enum": [
|
|
367
|
+
"nodejs10",
|
|
368
|
+
"nodejs12",
|
|
369
|
+
"nodejs14",
|
|
370
|
+
"nodejs16"
|
|
371
|
+
],
|
|
372
|
+
"type": "string"
|
|
373
|
+
},
|
|
374
|
+
"source": {
|
|
346
375
|
"type": "string"
|
|
347
376
|
}
|
|
348
|
-
|
|
377
|
+
},
|
|
378
|
+
"type": "object"
|
|
349
379
|
},
|
|
350
|
-
|
|
351
|
-
"
|
|
352
|
-
|
|
353
|
-
|
|
380
|
+
{
|
|
381
|
+
"items": {
|
|
382
|
+
"additionalProperties": false,
|
|
383
|
+
"properties": {
|
|
384
|
+
"ignore": {
|
|
385
|
+
"items": {
|
|
386
|
+
"type": "string"
|
|
387
|
+
},
|
|
388
|
+
"type": "array"
|
|
389
|
+
},
|
|
390
|
+
"postdeploy": {
|
|
391
|
+
"anyOf": [
|
|
392
|
+
{
|
|
393
|
+
"items": {
|
|
394
|
+
"type": "string"
|
|
395
|
+
},
|
|
396
|
+
"type": "array"
|
|
397
|
+
},
|
|
398
|
+
{
|
|
399
|
+
"type": "string"
|
|
400
|
+
}
|
|
401
|
+
]
|
|
402
|
+
},
|
|
403
|
+
"predeploy": {
|
|
404
|
+
"anyOf": [
|
|
405
|
+
{
|
|
406
|
+
"items": {
|
|
407
|
+
"type": "string"
|
|
408
|
+
},
|
|
409
|
+
"type": "array"
|
|
410
|
+
},
|
|
411
|
+
{
|
|
412
|
+
"type": "string"
|
|
413
|
+
}
|
|
414
|
+
]
|
|
415
|
+
},
|
|
416
|
+
"runtime": {
|
|
417
|
+
"enum": [
|
|
418
|
+
"nodejs10",
|
|
419
|
+
"nodejs12",
|
|
420
|
+
"nodejs14",
|
|
421
|
+
"nodejs16"
|
|
422
|
+
],
|
|
354
423
|
"type": "string"
|
|
355
424
|
},
|
|
356
|
-
"
|
|
425
|
+
"source": {
|
|
426
|
+
"type": "string"
|
|
427
|
+
}
|
|
357
428
|
},
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
]
|
|
362
|
-
},
|
|
363
|
-
"runtime": {
|
|
364
|
-
"enum": [
|
|
365
|
-
"nodejs10",
|
|
366
|
-
"nodejs12",
|
|
367
|
-
"nodejs14",
|
|
368
|
-
"nodejs16"
|
|
369
|
-
],
|
|
370
|
-
"type": "string"
|
|
371
|
-
},
|
|
372
|
-
"source": {
|
|
373
|
-
"type": "string"
|
|
429
|
+
"type": "object"
|
|
430
|
+
},
|
|
431
|
+
"type": "array"
|
|
374
432
|
}
|
|
375
|
-
|
|
376
|
-
"type": "object"
|
|
433
|
+
]
|
|
377
434
|
},
|
|
378
435
|
"hosting": {
|
|
379
436
|
"anyOf": [
|
package/lib/prepareUpload.js
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var fs = require("fs");
|
|
3
|
-
var path = require("path");
|
|
4
|
-
var tar = require("tar");
|
|
5
|
-
var tmp = require("tmp");
|
|
6
|
-
var { listFiles } = require("./listFiles");
|
|
7
|
-
var { FirebaseError } = require("./error");
|
|
8
|
-
var fsutils = require("./fsutils");
|
|
9
|
-
module.exports = function (options) {
|
|
10
|
-
var hostingConfig = options.config.get("hosting");
|
|
11
|
-
var publicDir = options.config.path(hostingConfig.public);
|
|
12
|
-
var indexPath = path.join(publicDir, "index.html");
|
|
13
|
-
var tmpFile = tmp.fileSync({
|
|
14
|
-
prefix: "firebase-upload-",
|
|
15
|
-
postfix: ".tar.gz",
|
|
16
|
-
});
|
|
17
|
-
var manifest = listFiles(publicDir, hostingConfig.ignore);
|
|
18
|
-
return tar
|
|
19
|
-
.c({
|
|
20
|
-
gzip: true,
|
|
21
|
-
file: tmpFile.name,
|
|
22
|
-
cwd: publicDir,
|
|
23
|
-
prefix: "public",
|
|
24
|
-
follow: true,
|
|
25
|
-
noDirRecurse: true,
|
|
26
|
-
portable: true,
|
|
27
|
-
}, manifest.slice(0))
|
|
28
|
-
.then(function () {
|
|
29
|
-
var stats = fs.statSync(tmpFile.name);
|
|
30
|
-
return {
|
|
31
|
-
file: tmpFile.name,
|
|
32
|
-
stream: fs.createReadStream(tmpFile.name),
|
|
33
|
-
manifest: manifest,
|
|
34
|
-
foundIndex: fsutils.fileExistsSync(indexPath),
|
|
35
|
-
size: stats.size,
|
|
36
|
-
};
|
|
37
|
-
})
|
|
38
|
-
.catch(function (err) {
|
|
39
|
-
return Promise.reject(new FirebaseError("There was an issue preparing Hosting files for upload.", {
|
|
40
|
-
original: err,
|
|
41
|
-
exit: 2,
|
|
42
|
-
}));
|
|
43
|
-
});
|
|
44
|
-
};
|