Skip to content

Commit 87968f0

Browse files
authored
Init flow frameworks cli. (#6010)
* Added init flow commands * change region name * Enable frameworkstacks api * Added code review changes * Revert unwanted changes * Revert unwanted changes * Revert unwanted changes * change according to project id * Removed unwanted statements related to projectId
1 parent 8530334 commit 87968f0

File tree

6 files changed

+83
-0
lines changed

6 files changed

+83
-0
lines changed

src/commands/init.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import { requireAuth } from "../requireAuth";
1313
import * as fsutils from "../fsutils";
1414
import * as utils from "../utils";
1515
import { Options } from "../options";
16+
import { isEnabled } from "../experiments";
1617

1718
const homeDir = os.homedir();
1819

@@ -71,6 +72,15 @@ const choices = [
7172
checked: false,
7273
},
7374
];
75+
76+
if (isEnabled("frameworks")) {
77+
choices.push({
78+
value: "frameworks",
79+
name: "Frameworks: Get started with Frameworks projects.",
80+
checked: false,
81+
});
82+
}
83+
7484
const featureNames = choices.map((choice) => choice.value);
7585

7686
const DESCRIPTION = `Interactively configure the current directory as a Firebase project or initialize new features in an already configured Firebase project directory.

src/experiments.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,12 @@ export const ALL_EXPERIMENTS = experiments({
9797
"These commands are not meant for public consumption and may break or disappear " +
9898
"without a notice.",
9999
},
100+
101+
frameworks: {
102+
shortDescription: "Allow CLI option for Frameworks",
103+
default: true,
104+
public: false,
105+
},
100106
});
101107

102108
export type ExperimentName = keyof typeof ALL_EXPERIMENTS;
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
export const DEFAULT_REGION = "us-central1";
2+
export const ALLOWED_REGIONS = [{ name: "us-central1 (Iowa)", value: "us-central1" }];
3+
export const DEFAULT_DEPLOY_METHOD = "github";
4+
export const ALLOWED_DEPLOY_METHODS = [{ name: "Deploy using github", value: "github" }];
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
import * as clc from "colorette";
2+
import * as utils from "../../../utils";
3+
import { logger } from "../../../logger";
4+
import { promptOnce } from "../../../prompt";
5+
import {
6+
DEFAULT_REGION,
7+
ALLOWED_REGIONS,
8+
DEFAULT_DEPLOY_METHOD,
9+
ALLOWED_DEPLOY_METHODS,
10+
} from "./constants";
11+
12+
/**
13+
* Setup new frameworks project.
14+
*/
15+
export async function doSetup(setup: any): Promise<void> {
16+
setup.frameworks = {};
17+
18+
utils.logBullet("First we need a few details to create your service.");
19+
20+
await promptOnce(
21+
{
22+
name: "serviceName",
23+
type: "input",
24+
default: "acme-inc-web",
25+
message: "Create a name for your service [6-32 characters]",
26+
},
27+
setup.frameworks
28+
);
29+
30+
await promptOnce(
31+
{
32+
name: "region",
33+
type: "list",
34+
default: DEFAULT_REGION,
35+
message:
36+
"Please select a region " +
37+
`(${clc.yellow("info")}: Your region determines where your backend is located):\n`,
38+
choices: ALLOWED_REGIONS,
39+
},
40+
setup.frameworks
41+
);
42+
43+
utils.logSuccess(`Region set to ${setup.frameworks.region}.`);
44+
45+
logger.info(clc.bold(`\n${clc.white("===")} Deploy Setup`));
46+
47+
await promptOnce(
48+
{
49+
name: "deployMethod",
50+
type: "list",
51+
default: DEFAULT_DEPLOY_METHOD,
52+
message: "How do you want to deploy",
53+
choices: ALLOWED_DEPLOY_METHODS,
54+
},
55+
setup.frameworks
56+
);
57+
}

src/init/features/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,4 @@ export { doSetup as extensions } from "./extensions";
1010
export { doSetup as project } from "./project";
1111
export { doSetup as remoteconfig } from "./remoteconfig";
1212
export { initGitHub as hostingGithub } from "./hosting/github";
13+
export { doSetup as frameworks } from "./frameworks";

src/init/index.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import * as clc from "colorette";
44
import { FirebaseError } from "../error";
55
import { logger } from "../logger";
66
import * as features from "./features";
7+
import { isEnabled } from "../experiments";
78

89
export interface Setup {
910
config: Record<string, any>;
@@ -31,6 +32,10 @@ const featureFns = new Map<string, (setup: any, config: any, options?: any) => P
3132
["hosting:github", features.hostingGithub],
3233
]);
3334

35+
if (isEnabled("frameworks")) {
36+
featureFns.set("frameworks", features.frameworks);
37+
}
38+
3439
export async function init(setup: Setup, config: any, options: any): Promise<any> {
3540
const nextFeature = setup.features?.shift();
3641
if (nextFeature) {

0 commit comments

Comments
 (0)