Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/commands/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,11 @@ const choices = [
name: "Extensions: Set up an empty Extensions manifest",
checked: false,
},
{
value: "frameworkstack",
name: "Frameworkstack: Get started with Frameworks project",
checked: false,
},
];
const featureNames = choices.map((choice) => choice.value);

Expand Down
15 changes: 15 additions & 0 deletions src/init/features/frameworkstack/constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
export const DEFAULT_REGION = "us-central1";
export const ALLOWED_REGIONS = [
{ name: "us-east1 (South California)", value: "us-east1" },
{ name: "us-east4 (Northern Virginia)", value: "us-east4" },
{ name: "us-east5 (Columbus)", value: "us-east5" },
{ name: "us-central1 (Iowa)", value: "us-central1" },
{ name: "us-central2 (Chicago, IL)", value: "us-central2" },
{ name: "us-south1 (Dallas)", value: "us-south1" },
{ name: "us-west1 (Oregon)", value: "us-west1" },
];
export const DEFAULT_DEPLOY_METHOD = "github";
export const ALLOWED_DEPLOY_METHODS = [
{ name: "Deploy using github", value: "github" },
{ name: "Deploy manual", value: "manually" },
];
66 changes: 66 additions & 0 deletions src/init/features/frameworkstack/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
import * as clc from "colorette";
import { Options } from "../../../options";
import { Config } from "../../../config";
import { requirePermissions } from "../../../requirePermissions";
import { ensure } from "../../../ensureApiEnabled";
import * as utils from "../../../utils";
import { logger } from "../../../logger";
import { promptOnce } from "../../../prompt";
import {
DEFAULT_REGION,
ALLOWED_REGIONS,
DEFAULT_DEPLOY_METHOD,
ALLOWED_DEPLOY_METHODS,
} from "./constants";

/**
* Setup new Frameworkstack project.
*/
export async function doSetup(setup: any, config: Config, options: Options): Promise<void> {
const projectId = setup?.rcfile?.projects?.default;
if (projectId) {
await requirePermissions({ ...options, project: projectId });
await Promise.all([ensure(projectId, "firebaseextensions.googleapis.com", "unused", true)]);
}
setup.frameworkstack = {};

utils.logBullet("First we need a few details to create your service.");

await promptOnce(
{
name: "serviceName",
type: "input",
default: "acme-inc-web",
message: "Create a name for your service [1-64 characters]",
},
setup.frameworkstack
);

await promptOnce(
{
name: "regionName",
type: "list",
default: DEFAULT_REGION,
message:
"Please select a region " +
`(${clc.yellow("info")}: Your region determines where your backend is located):\n`,
choices: ALLOWED_REGIONS,
},
setup.frameworkstack
);

utils.logSuccess(`Region set to ${setup.frameworkstack.regionName}.`);

logger.info(clc.bold(`\n${clc.white("===")} Deploy Setup`));

await promptOnce(
{
name: "deployMethod",
type: "list",
default: DEFAULT_DEPLOY_METHOD,
message: "How do you want to deploy",
choices: ALLOWED_DEPLOY_METHODS,
},
setup.frameworkstack
);
}
1 change: 1 addition & 0 deletions src/init/features/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ export { doSetup as extensions } from "./extensions";
export { doSetup as project } from "./project";
export { doSetup as remoteconfig } from "./remoteconfig";
export { initGitHub as hostingGithub } from "./hosting/github";
export { doSetup as frameworkstack } from "./frameworkstack";
1 change: 1 addition & 0 deletions src/init/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ const featureFns = new Map<string, (setup: any, config: any, options?: any) => P
["project", features.project], // always runs, sets up .firebaserc
["remoteconfig", features.remoteconfig],
["hosting:github", features.hostingGithub],
["frameworkstack", features.frameworkstack],
]);

export async function init(setup: Setup, config: any, options: any): Promise<any> {
Expand Down