Skip to content

Commit

Permalink
fix: rename functions to api and update setup code.
Browse files Browse the repository at this point in the history
  • Loading branch information
Pavel910 committed Oct 10, 2019
1 parent 4268ca5 commit 3167bb8
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions packages/cli/src/create/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,20 +23,27 @@ module.exports = async ({ name }) => {
process.chdir(root);

fs.ensureDirSync("apps");
fs.ensureDirSync("functions");
fs.ensureDirSync("api");
fs.ensureDirSync("packages");

// Copy project files
const files = ["README.md", ".gitignore", ".prettierrc.js", "babel.config.js", "package.json"];
const files = [
"README.md",
".gitignore.example",
".prettierrc.js",
"babel.config.js",
"package.json"
];
files.forEach(file => copyFile(`template/${file}`, file));
fs.renameSync("api/.gitignore.example", "api/.gitignore");

// Setup monorepo packages
await setupFolder("apps/code");
fs.renameSync("apps/code/admin/.gitignore.example", "apps/code/admin/.gitignore");
fs.renameSync("apps/code/site/.gitignore.example", "apps/code/site/.gitignore");

await setupFolder("apps/prod");
await setupFolder("functions/prod");
await setupFolder("api/prod");
await setupFolder("packages/theme");

// Update config
Expand All @@ -45,12 +52,12 @@ module.exports = async ({ name }) => {
.toString("base64")
.slice(0, 60);

const envExample = resolve("functions/prod/.env.example");
const envExample = resolve("api/prod/.env.example");
if (fs.existsSync(envExample)) {
fs.renameSync(envExample, "functions/prod/.env");
fs.renameSync(envExample, "api/prod/.env");
}

const envFile = resolve("functions/prod/.env");
const envFile = resolve("api/prod/.env");
let env = fs.readFileSync(envFile, "utf-8");
env = env.replace("[JWT_SECRET]", jwtSecret);
await fs.writeFile(envFile, env);
Expand Down
File renamed without changes.

0 comments on commit 3167bb8

Please sign in to comment.