firebase-tools 11.19.0 → 11.21.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/bin/firebase.js +1 -1
- package/lib/commands/appdistribution-distribute.js +3 -0
- package/lib/commands/ext-configure.js +2 -1
- package/lib/commands/ext-install.js +2 -2
- package/lib/commands/functions-delete.js +1 -1
- package/lib/deploy/extensions/planner.js +16 -9
- package/lib/deploy/extensions/tasks.js +6 -0
- package/lib/deploy/functions/prepareFunctionsUpload.js +13 -2
- package/lib/deploy/functions/runtimes/index.js +1 -2
- package/lib/deploy/functions/runtimes/node/index.js +3 -1
- package/lib/emulator/auth/operations.js +4 -4
- package/lib/emulator/downloadableEmulators.js +6 -6
- package/lib/emulator/extensionsEmulator.js +14 -9
- package/lib/emulator/functionsEmulator.js +1 -1
- package/lib/emulator/pubsubEmulator.js +13 -1
- package/lib/emulator/storage/apis/firebase.js +1 -0
- package/lib/emulator/storage/rules/manager.js +1 -1
- package/lib/emulator/storage/server.js +1 -1
- package/lib/emulator/storage/upload.js +3 -3
- package/lib/extensions/emulator/triggerHelper.js +12 -2
- package/lib/extensions/extensionsApi.js +16 -3
- package/lib/extensions/paramHelper.js +6 -1
- package/lib/functional.js +10 -3
- package/lib/functions/env.js +1 -1
- package/lib/serve/hosting.js +5 -5
- package/npm-shrinkwrap.json +843 -1403
- package/package.json +4 -4
- package/lib/deploy/functions/runtimes/golang/gomod.js +0 -74
- package/lib/deploy/functions/runtimes/golang/index.js +0 -106
- package/lib/init/features/functions/golang.js +0 -57
- package/templates/init/functions/golang/_gitignore +0 -12
- package/templates/init/functions/golang/functions.go +0 -38
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "firebase-tools",
|
|
3
|
-
"version": "11.
|
|
3
|
+
"version": "11.21.0",
|
|
4
4
|
"description": "Command-Line Interface for Firebase",
|
|
5
5
|
"main": "./lib/index.js",
|
|
6
6
|
"bin": {
|
|
@@ -84,7 +84,7 @@
|
|
|
84
84
|
"google-auth-library": "^7.11.0",
|
|
85
85
|
"inquirer": "^8.2.0",
|
|
86
86
|
"js-yaml": "^3.13.1",
|
|
87
|
-
"jsonwebtoken": "^
|
|
87
|
+
"jsonwebtoken": "^9.0.0",
|
|
88
88
|
"leven": "^3.1.0",
|
|
89
89
|
"libsodium-wrappers": "^0.7.10",
|
|
90
90
|
"lodash": "^4.17.21",
|
|
@@ -106,14 +106,14 @@
|
|
|
106
106
|
"stream-chain": "^2.2.4",
|
|
107
107
|
"stream-json": "^1.7.3",
|
|
108
108
|
"strip-ansi": "^6.0.1",
|
|
109
|
-
"superstatic": "^
|
|
109
|
+
"superstatic": "^9.0.2",
|
|
110
110
|
"tar": "^6.1.11",
|
|
111
111
|
"tcp-port-used": "^1.0.2",
|
|
112
112
|
"tmp": "^0.2.1",
|
|
113
113
|
"triple-beam": "^1.3.0",
|
|
114
114
|
"universal-analytics": "^0.5.3",
|
|
115
115
|
"unzipper": "^0.10.10",
|
|
116
|
-
"update-notifier": "^5.1.
|
|
116
|
+
"update-notifier-cjs": "^5.1.6",
|
|
117
117
|
"uuid": "^8.3.2",
|
|
118
118
|
"winston": "^3.0.0",
|
|
119
119
|
"winston-transport": "^4.4.0",
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.parseModule = void 0;
|
|
4
|
-
const logger_1 = require("../../../../logger");
|
|
5
|
-
function parseModule(mod) {
|
|
6
|
-
const module = {
|
|
7
|
-
module: "",
|
|
8
|
-
version: "",
|
|
9
|
-
dependencies: {},
|
|
10
|
-
replaces: {},
|
|
11
|
-
};
|
|
12
|
-
const lines = mod.split("\n");
|
|
13
|
-
let inBlock = undefined;
|
|
14
|
-
for (const line of lines) {
|
|
15
|
-
if (inBlock) {
|
|
16
|
-
const endRequireMatch = /\)/.exec(line);
|
|
17
|
-
if (endRequireMatch) {
|
|
18
|
-
inBlock = undefined;
|
|
19
|
-
continue;
|
|
20
|
-
}
|
|
21
|
-
let regex;
|
|
22
|
-
if (inBlock === module.dependencies) {
|
|
23
|
-
regex = /([^ ]+) ([^ ]+)/;
|
|
24
|
-
}
|
|
25
|
-
else {
|
|
26
|
-
regex = /([^ ]+) => ([^ ]+)/;
|
|
27
|
-
}
|
|
28
|
-
const mapping = regex.exec(line);
|
|
29
|
-
if (mapping) {
|
|
30
|
-
inBlock[mapping[1]] = mapping[2];
|
|
31
|
-
continue;
|
|
32
|
-
}
|
|
33
|
-
if (line.trim()) {
|
|
34
|
-
logger_1.logger.debug("Don't know how to handle line", line, "inside a mod.go require block");
|
|
35
|
-
}
|
|
36
|
-
continue;
|
|
37
|
-
}
|
|
38
|
-
const modMatch = /^module (.*)$/.exec(line);
|
|
39
|
-
if (modMatch) {
|
|
40
|
-
module.module = modMatch[1];
|
|
41
|
-
continue;
|
|
42
|
-
}
|
|
43
|
-
const versionMatch = /^go (\d+\.\d+)$/.exec(line);
|
|
44
|
-
if (versionMatch) {
|
|
45
|
-
module.version = versionMatch[1];
|
|
46
|
-
continue;
|
|
47
|
-
}
|
|
48
|
-
const requireMatch = /^require ([^ ]+) ([^ ]+)/.exec(line);
|
|
49
|
-
if (requireMatch) {
|
|
50
|
-
module.dependencies[requireMatch[1]] = requireMatch[2];
|
|
51
|
-
continue;
|
|
52
|
-
}
|
|
53
|
-
const replaceMatch = /^replace ([^ ]+) => ([^ ]+)$/.exec(line);
|
|
54
|
-
if (replaceMatch) {
|
|
55
|
-
module.replaces[replaceMatch[1]] = replaceMatch[2];
|
|
56
|
-
continue;
|
|
57
|
-
}
|
|
58
|
-
const requireBlockMatch = /^require +\(/.exec(line);
|
|
59
|
-
if (requireBlockMatch) {
|
|
60
|
-
inBlock = module.dependencies;
|
|
61
|
-
continue;
|
|
62
|
-
}
|
|
63
|
-
const replaceBlockMatch = /^replace +\(/.exec(line);
|
|
64
|
-
if (replaceBlockMatch) {
|
|
65
|
-
inBlock = module.replaces;
|
|
66
|
-
continue;
|
|
67
|
-
}
|
|
68
|
-
if (line.trim()) {
|
|
69
|
-
logger_1.logger.debug("Don't know how to handle line", line, "in mod.go");
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
return module;
|
|
73
|
-
}
|
|
74
|
-
exports.parseModule = parseModule;
|
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Delegate = exports.tryCreateDelegate = exports.FUNCTIONS_RUNTIME = exports.FUNCTIONS_CODEGEN = exports.FUNCTIONS_SDK = exports.ADMIN_SDK = void 0;
|
|
4
|
-
const util_1 = require("util");
|
|
5
|
-
const node_fetch_1 = require("node-fetch");
|
|
6
|
-
const fs = require("fs");
|
|
7
|
-
const path = require("path");
|
|
8
|
-
const spawn = require("cross-spawn");
|
|
9
|
-
const error_1 = require("../../../../error");
|
|
10
|
-
const logger_1 = require("../../../../logger");
|
|
11
|
-
const gomod = require("./gomod");
|
|
12
|
-
const VERSION_TO_RUNTIME = {
|
|
13
|
-
"1.13": "go113",
|
|
14
|
-
};
|
|
15
|
-
exports.ADMIN_SDK = "firebase.google.com/go/v4";
|
|
16
|
-
exports.FUNCTIONS_SDK = "github.com/FirebaseExtended/firebase-functions-go";
|
|
17
|
-
exports.FUNCTIONS_CODEGEN = exports.FUNCTIONS_SDK + "/support/codegen";
|
|
18
|
-
exports.FUNCTIONS_RUNTIME = exports.FUNCTIONS_SDK + "/support/runtime";
|
|
19
|
-
async function tryCreateDelegate(context) {
|
|
20
|
-
const goModPath = path.join(context.sourceDir, "go.mod");
|
|
21
|
-
let module;
|
|
22
|
-
try {
|
|
23
|
-
const modBuffer = await (0, util_1.promisify)(fs.readFile)(goModPath);
|
|
24
|
-
module = gomod.parseModule(modBuffer.toString("utf8"));
|
|
25
|
-
}
|
|
26
|
-
catch (err) {
|
|
27
|
-
logger_1.logger.debug("Customer code is not Golang code (or they aren't using gomod)");
|
|
28
|
-
return;
|
|
29
|
-
}
|
|
30
|
-
let runtime = context.runtime;
|
|
31
|
-
if (!runtime) {
|
|
32
|
-
if (!module.version) {
|
|
33
|
-
throw new error_1.FirebaseError("Could not detect Golang version from go.mod");
|
|
34
|
-
}
|
|
35
|
-
if (!VERSION_TO_RUNTIME[module.version]) {
|
|
36
|
-
throw new error_1.FirebaseError(`go.mod specifies Golang version ${module.version} which is unsupported by Google Cloud Functions. Valid values are ${Object.keys(VERSION_TO_RUNTIME).join(", ")}`);
|
|
37
|
-
}
|
|
38
|
-
runtime = VERSION_TO_RUNTIME[module.version];
|
|
39
|
-
}
|
|
40
|
-
return new Delegate(context.projectId, context.sourceDir, runtime, module);
|
|
41
|
-
}
|
|
42
|
-
exports.tryCreateDelegate = tryCreateDelegate;
|
|
43
|
-
class Delegate {
|
|
44
|
-
constructor(projectId, sourceDir, runtime, module) {
|
|
45
|
-
this.projectId = projectId;
|
|
46
|
-
this.sourceDir = sourceDir;
|
|
47
|
-
this.runtime = runtime;
|
|
48
|
-
this.module = module;
|
|
49
|
-
this.name = "golang";
|
|
50
|
-
}
|
|
51
|
-
validate() {
|
|
52
|
-
return Promise.resolve();
|
|
53
|
-
}
|
|
54
|
-
async build() {
|
|
55
|
-
try {
|
|
56
|
-
await (0, util_1.promisify)(fs.mkdir)(path.join(this.sourceDir, "autogen"));
|
|
57
|
-
}
|
|
58
|
-
catch (err) {
|
|
59
|
-
if ((err === null || err === void 0 ? void 0 : err.code) !== "EEXIST") {
|
|
60
|
-
throw new error_1.FirebaseError("Failed to create codegen directory", { children: [err] });
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
const genBinary = spawn.sync("go", ["run", exports.FUNCTIONS_CODEGEN, this.module.module], {
|
|
64
|
-
cwd: this.sourceDir,
|
|
65
|
-
env: Object.assign(Object.assign({}, process.env), { HOME: process.env.HOME, PATH: process.env.PATH, GOPATH: process.env.GOPATH }),
|
|
66
|
-
stdio: ["ignore", "pipe", "pipe"],
|
|
67
|
-
});
|
|
68
|
-
if (genBinary.status !== 0) {
|
|
69
|
-
throw new error_1.FirebaseError("Failed to run codegen", {
|
|
70
|
-
children: [new Error(genBinary.stderr.toString())],
|
|
71
|
-
});
|
|
72
|
-
}
|
|
73
|
-
await (0, util_1.promisify)(fs.writeFile)(path.join(this.sourceDir, "autogen", "main.go"), genBinary.stdout);
|
|
74
|
-
}
|
|
75
|
-
watch() {
|
|
76
|
-
return Promise.resolve(() => Promise.resolve());
|
|
77
|
-
}
|
|
78
|
-
serve(port, adminPort, envs) {
|
|
79
|
-
var _a;
|
|
80
|
-
const childProcess = spawn("go", ["run", "./autogen"], {
|
|
81
|
-
env: Object.assign(Object.assign(Object.assign({}, process.env), envs), { PORT: port.toString(), ADMIN_PORT: adminPort.toString(), HOME: process.env.HOME, PATH: process.env.PATH, GOPATH: process.env.GOPATH }),
|
|
82
|
-
cwd: this.sourceDir,
|
|
83
|
-
stdio: ["ignore", "pipe", "inherit"],
|
|
84
|
-
});
|
|
85
|
-
(_a = childProcess.stdout) === null || _a === void 0 ? void 0 : _a.on("data", (chunk) => {
|
|
86
|
-
logger_1.logger.debug(chunk.toString());
|
|
87
|
-
});
|
|
88
|
-
return Promise.resolve(async () => {
|
|
89
|
-
const p = new Promise((resolve, reject) => {
|
|
90
|
-
childProcess.once("exit", resolve);
|
|
91
|
-
childProcess.once("error", reject);
|
|
92
|
-
});
|
|
93
|
-
await (0, node_fetch_1.default)(`http://localhost:${adminPort}/__/quitquitquit`);
|
|
94
|
-
setTimeout(() => {
|
|
95
|
-
if (!childProcess.killed) {
|
|
96
|
-
childProcess.kill("SIGKILL");
|
|
97
|
-
}
|
|
98
|
-
}, 10000);
|
|
99
|
-
return p;
|
|
100
|
-
});
|
|
101
|
-
}
|
|
102
|
-
async discoverBuild() {
|
|
103
|
-
return Promise.resolve({ requiredAPIs: [], endpoints: {}, params: [] });
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
exports.Delegate = Delegate;
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const util_1 = require("util");
|
|
4
|
-
const fs = require("fs");
|
|
5
|
-
const path = require("path");
|
|
6
|
-
const spawn = require("cross-spawn");
|
|
7
|
-
const clc = require("colorette");
|
|
8
|
-
const error_1 = require("../../../error");
|
|
9
|
-
const prompt_1 = require("../../../prompt");
|
|
10
|
-
const utils = require("../../../utils");
|
|
11
|
-
const go = require("../../../deploy/functions/runtimes/golang");
|
|
12
|
-
const logger_1 = require("../../../logger");
|
|
13
|
-
const RUNTIME_VERSION = "1.13";
|
|
14
|
-
const TEMPLATE_ROOT = path.resolve(__dirname, "../../../../templates/init/functions/golang");
|
|
15
|
-
const MAIN_TEMPLATE = fs.readFileSync(path.join(TEMPLATE_ROOT, "functions.go"), "utf8");
|
|
16
|
-
const GITIGNORE_TEMPLATE = fs.readFileSync(path.join(TEMPLATE_ROOT, "_gitignore"), "utf8");
|
|
17
|
-
async function init(setup, config) {
|
|
18
|
-
await writeModFile(config);
|
|
19
|
-
const modName = config.get("functions.go.module");
|
|
20
|
-
const [pkg] = modName.split("/").slice(-1);
|
|
21
|
-
await config.askWriteProjectFile("functions/functions.go", MAIN_TEMPLATE.replace("PACKAGE", pkg));
|
|
22
|
-
await config.askWriteProjectFile("functions/.gitignore", GITIGNORE_TEMPLATE);
|
|
23
|
-
}
|
|
24
|
-
async function writeModFile(config) {
|
|
25
|
-
const modPath = config.path("functions/go.mod");
|
|
26
|
-
if (await (0, util_1.promisify)(fs.exists)(modPath)) {
|
|
27
|
-
const shoudlWriteModFile = await (0, prompt_1.promptOnce)({
|
|
28
|
-
type: "confirm",
|
|
29
|
-
message: "File " + clc.underline("functions/go.mod") + " already exists. Overwrite?",
|
|
30
|
-
default: false,
|
|
31
|
-
});
|
|
32
|
-
if (!shoudlWriteModFile) {
|
|
33
|
-
return;
|
|
34
|
-
}
|
|
35
|
-
await (0, util_1.promisify)(fs.unlink)(modPath);
|
|
36
|
-
}
|
|
37
|
-
const modName = await (0, prompt_1.promptOnce)({
|
|
38
|
-
type: "input",
|
|
39
|
-
message: "What would you like to name your module?",
|
|
40
|
-
default: "acme.com/functions",
|
|
41
|
-
});
|
|
42
|
-
config.set("functions.go.module", modName);
|
|
43
|
-
config.writeProjectFile("functions/go.mod", `module ${modName} \n\ngo ${RUNTIME_VERSION}\n\n`);
|
|
44
|
-
utils.logSuccess("Wrote " + clc.bold("functions/go.mod"));
|
|
45
|
-
for (const dep of [go.FUNCTIONS_SDK, go.ADMIN_SDK, go.FUNCTIONS_CODEGEN, go.FUNCTIONS_RUNTIME]) {
|
|
46
|
-
const result = spawn.sync("go", ["get", dep], {
|
|
47
|
-
cwd: config.path("functions"),
|
|
48
|
-
stdio: "inherit",
|
|
49
|
-
});
|
|
50
|
-
if (result.error) {
|
|
51
|
-
logger_1.logger.debug("Full output from go get command:", JSON.stringify(result, null, 2));
|
|
52
|
-
throw new error_1.FirebaseError("Error installing dependencies", { children: [result.error] });
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
utils.logSuccess("Installed dependencies");
|
|
56
|
-
}
|
|
57
|
-
module.exports = init;
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
package PACKAGE
|
|
2
|
-
|
|
3
|
-
// Welcome to Cloud Functions for Firebase for Golang!
|
|
4
|
-
// To get started, uncomment the below code or create your own.
|
|
5
|
-
// Deploy with `firebase deploy`
|
|
6
|
-
|
|
7
|
-
/*
|
|
8
|
-
import (
|
|
9
|
-
"context"
|
|
10
|
-
"fmt"
|
|
11
|
-
|
|
12
|
-
"github.com/FirebaseExtended/firebase-functions-go/https"
|
|
13
|
-
"github.com/FirebaseExtended/firebase-functions-go/pubsub"
|
|
14
|
-
"github.com/FirebaseExtended/firebase-functions-go/runwith"
|
|
15
|
-
)
|
|
16
|
-
|
|
17
|
-
var HelloWorld = https.Function{
|
|
18
|
-
RunWith: https.Options{
|
|
19
|
-
AvailableMemoryMB: 256,
|
|
20
|
-
},
|
|
21
|
-
Callback: func(w https.ResponseWriter, req *https.Request) {
|
|
22
|
-
fmt.Println("Hello, world!")
|
|
23
|
-
fmt.Fprintf(w, "Hello, world!\n")
|
|
24
|
-
},
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
var PubSubFunction = pubsub.Function{
|
|
28
|
-
EventType: pubsub.MessagePublished,
|
|
29
|
-
Topic: "topic",
|
|
30
|
-
RunWith: runwith.Options{
|
|
31
|
-
AvailableMemoryMB: 256,
|
|
32
|
-
},
|
|
33
|
-
Callback: func(ctx context.Context, message pubsub.Message) error {
|
|
34
|
-
fmt.Printf("Got Pub/Sub event %+v", message)
|
|
35
|
-
return nil
|
|
36
|
-
},
|
|
37
|
-
}
|
|
38
|
-
*/
|