-
Notifications
You must be signed in to change notification settings - Fork 899
/
index.ts
52 lines (49 loc) · 1.47 KB
/
index.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import * as clc from "cli-color";
import { logger } from "../../../logger";
import { promptOnce } from "../../../prompt";
import { requirePermissions } from "../../../requirePermissions";
import { previews } from "../../../previews";
import { Options } from "../../../options";
import { ensure } from "../../../ensureApiEnabled";
module.exports = async function (setup: any, config: any, options: Options) {
logger.info();
logger.info(
"A " + clc.bold("functions") + " directory will be created in your project with sample code"
);
logger.info(
"pre-configured. Functions can be deployed with " + clc.bold("firebase deploy") + "."
);
logger.info();
setup.functions = {};
const projectId = setup?.rcfile?.projects?.default;
if (projectId) {
await requirePermissions({ ...options, project: projectId });
await Promise.all([
ensure(projectId, "cloudfunctions.googleapis.com", "unused", true),
ensure(projectId, "runtimeconfig.googleapis.com", "unused", true),
]);
}
const choices = [
{
name: "JavaScript",
value: "javascript",
},
{
name: "TypeScript",
value: "typescript",
},
];
if (previews.golang) {
choices.push({
name: "Go",
value: "golang",
});
}
const language = await promptOnce({
type: "list",
message: "What language would you like to use to write Cloud Functions?",
default: "javascript",
choices,
});
return require("./" + language)(setup, config);
};