Skip to content

Commit 8e6267a

Browse files
committed
feat: bootstrap
1 parent b087b20 commit 8e6267a

10 files changed

+175
-160
lines changed

.env .env.example

File renamed without changes.

.eslintrc.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"extends": ["next/core-web-vitals", "prettier", "plugin:@next/next/recommended"],
2+
"extends": ["next/core-web-vitals", "prettier"],
33
"rules": {
44
"import/no-anonymous-default-export": 0
55
}

.gitignore

+1-10
Original file line numberDiff line numberDiff line change
@@ -54,22 +54,13 @@ yarn-debug.log*
5454
yarn-error.log*
5555

5656
# local env files
57-
.env.local
58-
.env.development.local
59-
.env.test.local
60-
.env.production.local
57+
.env
6158

6259
# vercel
6360
.vercel
6461

6562
# vscode
6663
*.code-workspace
6764

68-
# apollo
69-
graphql-schema.json
70-
71-
# prisma
72-
prisma/migrations
73-
7465
# lhci
7566
.lighthouseci

README.md

+10-2
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,13 @@ You should, with this boilerplate only focus on coding rocking react components!
2121

2222
Start by cloning this repository, then use either `yarn install` or `npm install` to download the dependencies.
2323

24+
## Quick start
25+
26+
Want an easy way yo start the project with everything setup ? launch `yarn bootstrap` or `npm run bootstrap`
27+
2428
## Getting Started
2529

26-
First look at the `.env` file. (you can start with the default)
30+
First look at the `.env.example` file. (you can start with the default) by copying it into `.env`.
2731

2832
Then, run the development server:
2933

@@ -39,6 +43,7 @@ Open [http://localhost:3000](http://localhost:3000) with your browser to see the
3943

4044
| Commands | Info | Description |
4145
| --------------- | :---------------------------------------------: | -------------------------------------------------------------------------: |
46+
| bootstrap | node scripts/bootstrap.js | run and setup the project |
4247
| dev | next dev | Launch app in dev mode |
4348
| dev:test | jest --watch | Launch test |
4449
| dev:coverage | jest --coverage --watch | Generate a coverage from test |
@@ -127,11 +132,13 @@ At this point your should be able to execute `yarn prisma:migrate` or `npm run p
127132

128133
You could also seed your database with `yarn prisma:seed` or `npm run prisma:seed`.
129134

135+
:warning: by default you wont have the access for doing it, use your own database.
136+
130137
## Generate typing from graphql schema
131138

132139
You may need to look at [apollo-tooling](https://github.com/apollographql/apollo-tooling)
133140

134-
With the graphql endpoint running launch `yarn codegen`, this will create under `types` a typing file for each query under `apollo/operations`.
141+
With the graphql endpoint running launch `yarn codegen`, this will create a typing file `schema.ts` under `types`.
135142

136143
## Hosting
137144

@@ -146,6 +153,7 @@ Kirby use [vercel](https://vercel.com/docs) however you can use any other hostin
146153
- [ ] Monorepo
147154
- [ ] Without server / api (remove apollo)
148155
- [ ] More installer ??
156+
- [ ] improve changelog generation
149157
- [ ] Better doc ?
150158
- [ ] Feature projects build with Kirby
151159
- [ ] Feature contributors

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
"github-actions"
2727
],
2828
"scripts": {
29+
"bootstrap": "node scripts/bootstrap.js",
2930
"dev": "next dev",
3031
"dev:test": "jest --watch",
3132
"dev:coverage": "jest --coverage --watch",

scripts/bootstrap.js

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
const { join } = require('path');
2+
const exec = require('./exec');
3+
const fs = require('fs');
4+
5+
(async () => {
6+
console.log(
7+
`%c
8+
██╗ ██╗██╗██████╗ ██████╗ ██╗ ██╗ ██████╗ ██████╗ ██╗██╗ ███████╗██████╗ ██████╗ ██╗ █████╗ ████████╗███████╗
9+
██║ ██╔╝██║██╔══██╗██╔══██╗╚██╗ ██╔╝ ██╔══██╗██╔═══██╗██║██║ ██╔════╝██╔══██╗██╔══██╗██║ ██╔══██╗╚══██╔══╝██╔════╝
10+
█████╔╝ ██║██████╔╝██████╔╝ ╚████╔╝█████╗██████╔╝██║ ██║██║██║ █████╗ ██████╔╝██████╔╝██║ ███████║ ██║ █████╗
11+
██╔═██╗ ██║██╔══██╗██╔══██╗ ╚██╔╝ ╚════╝██╔══██╗██║ ██║██║██║ ██╔══╝ ██╔══██╗██╔═══╝ ██║ ██╔══██║ ██║ ██╔══╝
12+
██║ ██╗██║██║ ██║██████╔╝ ██║ ██████╔╝╚██████╔╝██║███████╗███████╗██║ ██║██║ ███████╗██║ ██║ ██║ ███████╗
13+
╚═╝ ╚═╝╚═╝╚═╝ ╚═╝╚═════╝ ╚═╝ ╚═════╝ ╚═════╝ ╚═╝╚══════╝╚══════╝╚═╝ ╚═╝╚═╝ ╚══════╝╚═╝ ╚═╝ ╚═╝ ╚══════╝
14+
`,
15+
'font-family:monospace',
16+
);
17+
await exec('yarn clear', { echo: true });
18+
await exec('yarn install', { echo: true });
19+
if (!fs.existsSync(join(__dirname, '/../.env'))) {
20+
await exec(`cp ${join(__dirname, '/../.env.example')} ${join(__dirname, '/../.env')}`, { echo: true });
21+
}
22+
await exec('yarn dev', { echo: true });
23+
})();

scripts/clear.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ const exec = require('./exec');
55
(async () => {
66
console.log('--- CLEAR ---');
77
await Promise.all([
8-
exec('rm', ['-rf', `${join(__dirname, '/../node_modules')}`], { echo: true }),
9-
exec('rm', ['-rf', `${join(__dirname, '/../*lock*')}`], { echo: true }),
10-
exec('rm', ['-rf', `${join(__dirname, '/.next')}`], { echo: true }),
8+
exec(`rm -rf ${join(__dirname, '/../node_modules')}`, { echo: true }),
9+
exec(`rm -rf ${join(__dirname, '/../*lock*')}`, { echo: true }),
10+
exec(`rm -rf ${join(__dirname, '/.next')}`, { echo: true }),
1111
]);
1212
console.log('--- DONE ---');
1313
})();

scripts/exec.js

+11-7
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,24 @@
1-
/* eslint-disable no-console */
2-
const { spawn } = require('child_process');
1+
const { spawn, exec } = require('child_process');
2+
const os = require('os');
33

4-
module.exports = (command, args, { capture = false, echo = false } = {}) => {
5-
if (echo) console.log(command, ...args);
4+
module.exports = (command, { capture = false, echo = false } = {}) => {
5+
if (echo) {
6+
console.log(command);
7+
}
68

7-
const childProcess = spawn(command, args, { stdio: capture ? 'pipe' : 'inherit' });
9+
const childProcess =
10+
os.platform() === 'win32' ? exec(command) : spawn('bash', ['-c', command], { stdio: capture ? 'pipe' : 'inherit' });
811

912
return new Promise((resolve, reject) => {
1013
let stdout = '';
1114

12-
if (capture)
15+
if (capture) {
1316
childProcess.stdout.on('data', data => {
1417
stdout += data;
1518
});
19+
}
1620

17-
childProcess.on('error', error => reject(new Error(error)));
21+
childProcess.on('error', error => reject(new Error({ code: 1, error })));
1822

1923
childProcess.on('close', code =>
2024
code > 0

tsconfig.tsbuildinfo

+1-1
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)