@anthonylzq/simba.js 6.2.0 → 6.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -41,9 +41,9 @@ By doing this your prompt will ask you the following questions:
41
41
  - `Select your license [1...7]:`, the license you have chosen for the project.
42
42
  - `License year (current year):`, the year where your license starts, current year as default.
43
43
  - `Will this project use GraphQL? [y/n]:`, yes or no question, only **y** or **n** is accepted. This is not case sensitive.
44
- - `Will this project be deployed with Heroku? [y/n]:`, yes or no question, only **y** or **n** is accepted. This is not case sensitive.
45
- - `Would you want to have a basic suit of tests with Jest? [y/n]:`, yes or no question, only **y** or **n** is accepted. This is not case sensitive.
46
- - `Would you want to have a basic GitHub Action for the suit of tests? [y/n]:`, yes or no question, only **y** or **n** is accepted. This is not case sensitive.
44
+ - `Will this project be deployed with Heroku? [y/n]:`.
45
+ - `Would you want to have a basic suit of tests with Jest? [y/n]:`.
46
+ - `Would you want to have a basic GitHub Action for the suit of tests and linting? [y/n]:`.
47
47
 
48
48
  The second option you have is by passing flags in one single command. If you need help, please run:
49
49
 
package/lib/index.js CHANGED
@@ -62,7 +62,7 @@ const argv = yargs(hideBin(process.argv))
62
62
  .alias('ghat', 'gh-action-tests')
63
63
  .describe(
64
64
  'ghat',
65
- 'Whether or not you want to have a GitHub Action with a CI for your tests. If this option is set to true, the tests flag must be set to true.'
65
+ 'Whether or not you want to have a GitHub Action with a CI for your tests and linting. If this option is set to true, the tests flag must be set to true.'
66
66
  )
67
67
  .default({
68
68
  H: false,
@@ -239,7 +239,7 @@ const main = async () => {
239
239
 
240
240
  if (config.tests)
241
241
  config.ghat = readLineSync.keyInYNStrict(
242
- '> Would you want to have a basic GitHub Action for the suit of tests?',
242
+ '> Would you want to have a basic GitHub Action for the suit of tests and linting?',
243
243
  {
244
244
  caseSensitive: false
245
245
  }
@@ -93,12 +93,11 @@ interface CustomResponse extends ExpressResponse {
93
93
  writeFile(types.models.user.file, types.models.user.content)
94
94
  ]
95
95
 
96
- if (express) {
96
+ if (express)
97
97
  processes.concat([
98
98
  writeFile(types.custom.request.file, types.custom.request.content),
99
99
  writeFile(types.custom.response.file, types.custom.response.content)
100
100
  ])
101
- }
102
101
 
103
102
  if (graphql)
104
103
  processes.push(
@@ -4,20 +4,18 @@ const writeFile = require('../utils/writeFile')
4
4
  * @param {String} projectName
5
5
  * @returns {Promise<void>}
6
6
  */
7
- module.exports = async projectName => {
7
+ module.exports = async (projectName, tests) => {
8
8
  const data = {
9
9
  eslintContent: `{
10
10
  "env": {
11
- "node": true,
12
- "jest/globals": true
11
+ "node": true${tests ? ',\n "jest": true' : ''}
13
12
  },
14
13
  "root": true,
15
14
  "parser": "@typescript-eslint/parser",
16
15
  "plugins": [
17
16
  "@typescript-eslint",
18
17
  "import",
19
- "prettier",
20
- "jest"
18
+ "prettier"${tests ? ',\n "jest"' : ''}
21
19
  ],
22
20
  "extends": [
23
21
  "standard",
@@ -46,8 +44,7 @@ module.exports = async projectName => {
46
44
  {
47
45
  "devDependencies": [
48
46
  "**/*.test.ts",
49
- "webpack.config.js",
50
- "jest.config.ts"
47
+ "webpack.config.js"${tests ? ',\n "jest.config.ts"' : ''}
51
48
  ],
52
49
  "optionalDependencies": [
53
50
  "**/*.test.ts"
@@ -99,6 +96,10 @@ module.exports = async projectName => {
99
96
  "spaced-comment": [
100
97
  "error",
101
98
  "always"
99
+ ],
100
+ "curly": [
101
+ "error",
102
+ "multi"
102
103
  ]
103
104
  }
104
105
  }`,
@@ -18,6 +18,48 @@ ${projectName}/.github/workflows`
18
18
  else await exec(createFoldersCommand)
19
19
 
20
20
  const data = {
21
+ linting: {
22
+ content: `name: Lint - ${projectName}
23
+
24
+ on: [push]
25
+
26
+ jobs:
27
+ run-linters:
28
+ name: Run linters
29
+ runs-on: ubuntu-latest
30
+
31
+ steps:
32
+ - name: Check out Git repository
33
+ uses: actions/checkout@v3
34
+ with:
35
+ fetch-depth: 0
36
+
37
+ - name: Set up Node.js
38
+ uses: actions/setup-node@v3
39
+ with:
40
+ node-version: 16.x
41
+
42
+ - name: Install Node.js dependencies
43
+ run: ${
44
+ managerName === 'yarn' ? 'yarn install --frozen-lockfile' : 'npm ci'
45
+ }
46
+
47
+ - name: Revert changes into the ${
48
+ managerName === 'yarn' ? 'yarn.lock' : 'package-lock.json'
49
+ } file
50
+ run: git checkout -- ${
51
+ managerName === 'yarn' ? 'yarn.lock' : 'package-lock.json'
52
+ }
53
+
54
+ - name: Run linters
55
+ uses: wearerequired/lint-action@v1
56
+ with:
57
+ auto_fix: true
58
+ eslint: true
59
+ eslint_extensions: js
60
+ `,
61
+ file: `${projectName}/.github/workflows/lint.yml`
62
+ },
21
63
  test: {
22
64
  content: `name: Tests - ${projectName}
23
65
 
@@ -61,5 +103,8 @@ jobs:
61
103
  }
62
104
  }
63
105
 
64
- await writeFile(data.test.file, data.test.content)
106
+ await Promise.all([
107
+ writeFile(data.linting.file, data.linting.content),
108
+ writeFile(data.test.file, data.test.content)
109
+ ])
65
110
  }
package/lib/src/index.js CHANGED
@@ -103,9 +103,10 @@ webpack-node-externals`
103
103
  devPackages += ` ${fastify ? fastifyDevPackages : expressDevPackages}`
104
104
 
105
105
  if (tests)
106
- devPackages += ` @jest/types @types/jest eslint-plugin-jest jest jest-unit ts-jest`
106
+ devPackages +=
107
+ ' @jest/types @types/jest eslint-plugin-jest jest jest-unit ts-jest'
107
108
 
108
- if (manager === 'yarn add') devPackages += ` eslint-plugin-n`
109
+ if (manager === 'yarn add') devPackages += ' eslint-plugin-n'
109
110
 
110
111
  bar.start(process, i)
111
112
 
@@ -128,7 +129,7 @@ webpack-node-externals`
128
129
  gitignore(projectName),
129
130
  tsconfig(projectName),
130
131
  nodemon(projectName),
131
- eslint(projectName),
132
+ eslint(projectName, tests),
132
133
  webpack(projectName),
133
134
  docker(projectName),
134
135
  api({ projectName, version, email, fastify, graphql }),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@anthonylzq/simba.js",
3
- "version": "6.2.0",
3
+ "version": "6.2.1",
4
4
  "description": "set up a modern backend app by running one command",
5
5
  "main": "lib/index.js",
6
6
  "scripts": {
@@ -15,6 +15,7 @@
15
15
  "build:fastify": "npm run rm:fastify && npm run cd:mv:example && node -r dotenv/config ./bin -N example/fastify -D 'This is a test using fastify' -a AnthonyLzq -e sluzquinosa@uni.pe -l mit -H -F --tests --ghat && npm run rm:git:fastify",
16
16
  "build:express:graphql": "npm run rm:express:graphql && npm run cd:mv:example && node -r dotenv/config ./bin -N example/express-graphql -D 'This is a test using express with GraphQL' -a AnthonyLzq -e sluzquinosa@uni.pe -l mit -H -g && npm run rm:git:express:graphql",
17
17
  "build:fastify:graphql": "npm run rm:fastify:graphql && npm run cd:mv:example && node -r dotenv/config ./bin -N example/fastify-graphql -D 'This is a test using fastify with GraphQL' -a AnthonyLzq -e sluzquinosa@uni.pe -l mit -H -F -g && npm run rm:git:fastify:graphql",
18
+ "build:and:test:only": "npm run build && npm run test:only",
18
19
  "lint": "eslint --ext js lib/ --fix",
19
20
  "rm": "if [ -d \"example\" ]; then rm -rf example; fi",
20
21
  "rm:express": "if [ -d \"example/express\" ]; then rm -rf example/express; fi",