@anthonylzq/simba.js 1.7.0 → 1.8.0

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/CHANGELOG.md CHANGED
@@ -2,6 +2,21 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
4
 
5
+ ## [1.8.0](https://github.com/AnthonyLzq/simba.js/compare/v1.7.0...v1.8.0) (2021-12-13)
6
+
7
+
8
+ ### Features
9
+
10
+ * implemented baseUrl config with ts and webpack to avoid "../../.. ..." ([9b9e9d2](https://github.com/AnthonyLzq/simba.js/commit/9b9e9d20cae8b4bbdaef58364220512514dac1a4))
11
+ * updated docker file and ignored git folder to be generated manually by docker ([33c1b0d](https://github.com/AnthonyLzq/simba.js/commit/33c1b0df9cfac4e686ece884aa3102e9ad49e6ab))
12
+ * updated docs ([ba72b64](https://github.com/AnthonyLzq/simba.js/commit/ba72b643ea45af7ce7dd7a9adaf8b4f27eacd266))
13
+
14
+
15
+ ### Bug Fixes
16
+
17
+ * fixed eslint ignore ([1405884](https://github.com/AnthonyLzq/simba.js/commit/1405884ab10cf869d6811fbf588ba0b0efb04de2))
18
+ * fixed mongo connection ([57f8580](https://github.com/AnthonyLzq/simba.js/commit/57f85803701253be2308b1c45f537db5b59c92d4))
19
+
5
20
  ## [1.7.0](https://github.com/AnthonyLzq/simba.js/compare/v1.6.0...v1.7.0) (2021-12-12)
6
21
 
7
22
 
package/README.md CHANGED
@@ -192,6 +192,7 @@ simba -N myProject -D 'This is a test' -a myName -e myEmail@email.com -H
192
192
  - To check the content of the files generated, please check the `example` folder.
193
193
  - If you provide a project name that contains spaces, something like 'My awesome Project', every space will be replaced with a hyphen. So at the end your project name will be 'My-awesome-project', but in its README.md file, the hyphens will be removed and the project name will be parsed to title case (My Awesome Project).
194
194
  - Finally, `git` will be initialized and a list of libraries will be installed. Check the [**notes**](#notes).
195
+ - Relative imports is already configured, you do not need to import a file using `../../../some/very/nested/stuff/in/other/folder`, you can use `some/very/nested/stuff/in/other/folder` assuming that your folder is under the `src` folder.
195
196
 
196
197
  ## What is new?
197
198
 
@@ -221,6 +222,8 @@ Here is the list of the packages that are being installed, as `devDependencies`:
221
222
  - [`standard-version`](https://www.npmjs.com/package/standard-version)
222
223
  - [`ts-loader`](https://www.npmjs.com/package/ts-loader)
223
224
  - [`ts-node`](https://www.npmjs.com/package/ts-node)
225
+ - [`tsconfig-paths`](https://www.npmjs.com/package/tsconfig-paths)
226
+ - [`tsconfig-paths-webpack-plugin`](https://www.npmjs.com/package/tsconfig-paths-webpack-plugin)
224
227
  - [`typescript`](https://www.npmjs.com/package/typescript)
225
228
  - [`webpack`](https://www.npmjs.com/package/webpack)
226
229
  - [`webpack-cli`](https://www.npmjs.com/package/webpack-cli)
@@ -14,6 +14,12 @@ COPY package.json ./
14
14
 
15
15
  RUN yarn install --prod
16
16
 
17
+ RUN yarn add webpack webpack-node-externals -D
18
+
19
+ RUN yarn build
20
+
21
+ RUN yarn remove webpack webpack-node-externals
22
+
17
23
  COPY dist /app/dist
18
24
 
19
25
  CMD [ "yarn", "start" ]
@@ -87,10 +87,7 @@ module.exports = async projectName => {
87
87
  }
88
88
  `,
89
89
  eslintFile: '.eslintrc.js',
90
- eslintIgnoreContent: `/dist
91
- .eslintrc.js
92
- webpack.config.js
93
- `,
90
+ eslintIgnoreContent: '/dist',
94
91
  eslintIgnoreFile: '.eslintignore'
95
92
  }
96
93
 
@@ -35,7 +35,6 @@ const writeFile = require('../utils/writeFile')
35
35
  * | |- index.http: content, file
36
36
  * |- utils:
37
37
  * | |- docs.json: content, file
38
- * | |- response: content, file
39
38
  * | |- index: content, file
40
39
  * |- .env: content, file
41
40
  * |- index: content, file
@@ -54,7 +53,7 @@ module.exports = async (projectName, projectVersion, email) => {
54
53
  import { IncomingHttpHeaders } from 'http'
55
54
  import { Request, Response } from 'express'
56
55
 
57
- import { DtoUser } from '../dto-interfaces'
56
+ import { DtoUser } from 'dto-interfaces'
58
57
 
59
58
  declare global {
60
59
  // This variable is global, so it will be available everywhere in the code
@@ -101,8 +100,8 @@ export { User }
101
100
  user: {
102
101
  content: `import httpErrors from 'http-errors'
103
102
 
104
- import { DtoUser } from '../dto-interfaces'
105
- import { IUser, UserModel } from '../models'
103
+ import { DtoUser } from 'dto-interfaces'
104
+ import { IUser, UserModel } from 'models'
106
105
  import { EFU, MFU, GE, errorHandling } from './utils'
107
106
 
108
107
  type Process = {
@@ -353,8 +352,8 @@ export { IUser, UserModel }
353
352
  import swaggerUi from 'swagger-ui-express'
354
353
  import httpErrors from 'http-errors'
355
354
 
356
- import { Home, User } from '../routes'
357
- import { docs } from '../utils'
355
+ import { Home, User } from 'routes'
356
+ import { docs } from 'utils'
358
357
 
359
358
  const routers = [User]
360
359
 
@@ -429,8 +428,6 @@ class Server {
429
428
  this._connection = mongoose.connection
430
429
  const connection = {
431
430
  keepAlive: true,
432
- useCreateIndex: true,
433
- useFindAndModify: false,
434
431
  useNewUrlParser: true,
435
432
  useUnifiedTopology: true
436
433
  }
@@ -516,9 +513,9 @@ export { Home, User }
516
513
  import httpErrors from 'http-errors'
517
514
  import { ValidationError } from 'joi'
518
515
 
519
- import { User as UserC } from '../controllers/user'
520
- import { DtoUser } from '../dto-interfaces'
521
- import { idSchema, userSchema } from '../schemas'
516
+ import { User as UserC } from 'controllers/user'
517
+ import { DtoUser } from 'dto-interfaces'
518
+ import { idSchema, userSchema } from 'schemas'
522
519
 
523
520
  const User = Router()
524
521
 
@@ -1148,22 +1145,6 @@ DELETE http://localhost:1996/api/user/60e7e3b93b01c1a7aa74cd6b
1148
1145
  export { docs }
1149
1146
  `,
1150
1147
  file: `${projectName}/src/utils/index.ts`
1151
- },
1152
- response: {
1153
- content: `import { Response } from 'express'
1154
-
1155
- const response = (
1156
- error: boolean,
1157
- message: unknown,
1158
- res: Response,
1159
- status: number
1160
- ): void => {
1161
- res.status(status).send({ error, message })
1162
- }
1163
-
1164
- export { response }
1165
- `,
1166
- file: `${projectName}/src/utils/response.ts`
1167
1148
  }
1168
1149
  },
1169
1150
  '.env': {
@@ -1249,7 +1230,6 @@ ${projectName}/src/utils
1249
1230
 
1250
1231
  // /utils
1251
1232
  await writeFile(data.utils.docs.file, data.utils.docs.content)
1252
- await writeFile(data.utils.response.file, data.utils.response.content)
1253
1233
  await writeFile(data.utils.index.file, data.utils.index.content)
1254
1234
 
1255
1235
  // .env
@@ -132,6 +132,8 @@ typings/
132
132
  # .pnp.*
133
133
 
134
134
  # End of https://www.toptal.com/developers/gitignore/api/node,yarn
135
+
136
+ dist
135
137
  `,
136
138
  gitignoreFile: '.gitignore'
137
139
  }
@@ -8,7 +8,8 @@ module.exports = async projectName => {
8
8
  const data = {
9
9
  tsconfigContent: `{
10
10
  "ts-node": {
11
- "files": true
11
+ "files": true,
12
+ "require": ["tsconfig-paths/register"]
12
13
  },
13
14
  "compilerOptions": {
14
15
  /* Visit https://aka.ms/tsconfig.json to read more about this file */
@@ -52,7 +53,7 @@ module.exports = async projectName => {
52
53
 
53
54
  /* Module Resolution Options */
54
55
  "moduleResolution": "node" /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */,
55
- // "baseUrl": "./", /* Base directory to resolve non-absolute module names. */
56
+ "baseUrl": "./src", /* Base directory to resolve non-absolute module names. */
56
57
  // "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */
57
58
  // "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */
58
59
  // "typeRoots": [], /* List of folders to include type definitions from. */
@@ -8,6 +8,7 @@ module.exports = async projectName => {
8
8
  const data = {
9
9
  webpackContent: `const path = require('path')
10
10
  const nodeExternals = require('webpack-node-externals')
11
+ const TsconfigPathsPlugin = require('tsconfig-paths-webpack-plugin')
11
12
 
12
13
  module.exports = {
13
14
  context: __dirname,
@@ -28,7 +29,12 @@ module.exports = {
28
29
  __dirname: false
29
30
  },
30
31
  resolve: {
31
- extensions: ['.ts', '.js']
32
+ extensions: ['.ts', '.js'],
33
+ plugins: [
34
+ new TsconfigPathsPlugin({
35
+ baseUrl: './src'
36
+ })
37
+ ]
32
38
  },
33
39
  output: {
34
40
  filename: 'index.js',
@@ -78,6 +78,8 @@ prettier \
78
78
  standard-version \
79
79
  ts-loader \
80
80
  ts-node \
81
+ tsconfig-paths \
82
+ tsconfig-paths-webpack-plugin \
81
83
  typescript \
82
84
  webpack \
83
85
  webpack-cli \
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@anthonylzq/simba.js",
3
- "version": "1.7.0",
3
+ "version": "1.8.0",
4
4
  "description": "set up a modern backend app by running one command",
5
5
  "main": "lib/index.js",
6
6
  "directories": {