diff --git a/packages/package.json b/packages/package.json index 31e6a5a..7db89ec 100644 --- a/packages/package.json +++ b/packages/package.json @@ -1,6 +1,6 @@ { "name": "gen-express-cli", - "version": "1.0.5", + "version": "1.0.6", "description": "A simple express cli to generate express app simply by running a command", "main": "index.js", "type": "module", diff --git a/packages/scripts/createPackageJson.js b/packages/scripts/createPackageJson.js index d24a3ca..922ea62 100644 --- a/packages/scripts/createPackageJson.js +++ b/packages/scripts/createPackageJson.js @@ -16,7 +16,7 @@ export async function createPackageJson(projectName, template, linter, unitTest, packageJson.scripts['dev'] = 'cross-env NODE_ENV=development nodemon ./src/index.js'; packageJson.scripts['start'] = 'cross-env NODE_ENV=production node ./src/index.js'; if (linter) { - packageJson.scripts['lint'] = 'eslint ./src/**/*'; + packageJson.scripts['lint'] = 'eslint ./src/**/*.js --fix'; packageJson.scripts['format'] = 'prettier --write ./**/*.{js,json}'; packageJson.devDependencies['eslint'] = '^8'; packageJson.devDependencies['eslint-config-standard'] = '^17'; @@ -28,7 +28,7 @@ export async function createPackageJson(projectName, template, linter, unitTest, if (unitTest === 'jest') { if (linter) packageJson.devDependencies['eslint-plugin-jest'] = '^27'; packageJson.scripts['test'] = - 'jest --coverage=true -w=1 --forceExit --detectOpenHandles --watchAll=false --testPathPattern=src/__tests__'; + 'node --experimental-vm-modules node_modules/jest/bin/jest.js --coverage=true -w=1 --forceExit --detectOpenHandles --watchAll=false --testPathPattern=src/__tests__'; packageJson.devDependencies['jest'] = '^29'; } if (apiDoc) { @@ -41,14 +41,14 @@ export async function createPackageJson(projectName, template, linter, unitTest, if (template === 'typescript') { packageJson.scripts['dev'] = 'cross-env NODE_ENV=development nodemon --exec ts-node ./src/index.ts'; packageJson.scripts['build'] = 'tsc'; - packageJson.scripts['start'] = 'cross-env NODE_ENV=production node ./build/index.js'; - packageJson.devDependencies['typescript'] = '^5'; + packageJson.scripts['start'] = 'cross-env NODE_ENV=production node ./build/src/index.js'; + packageJson.devDependencies['typescript'] = '~5.3'; packageJson.devDependencies['ts-node'] = '^10'; packageJson.devDependencies['@types/cors'] = '^2'; packageJson.devDependencies['@types/express'] = '^4'; packageJson.devDependencies['@types/node'] = '^20'; if (linter) { - packageJson.scripts['lint'] = 'eslint ./src/**/*'; + packageJson.scripts['lint'] = 'eslint ./src/**/* --fix'; packageJson.scripts['format'] = 'prettier --write ./**/*.{ts,json}'; packageJson.devDependencies['eslint'] = '^8'; packageJson.devDependencies['@typescript-eslint/eslint-plugin'] = '^6'; diff --git a/packages/templates/swagger/javascript/src/index.js b/packages/templates/swagger/javascript/src/index.js index afd640f..d59ad72 100644 --- a/packages/templates/swagger/javascript/src/index.js +++ b/packages/templates/swagger/javascript/src/index.js @@ -1,11 +1,11 @@ +import fs from 'fs'; + import express from 'express'; import dotenv from 'dotenv'; import cors from 'cors'; - import swaggerUi from 'swagger-ui-express'; -import swaggerDocument from '../apidoc.json'; -import routes from './routes/index'; +import routes from './routes/index.js'; dotenv.config(); @@ -17,6 +17,8 @@ app.use(express.urlencoded({ extended: true })); app.use(express.json()); app.use(`/api`, routes); + +const swaggerDocument = JSON.parse(fs.readFileSync('./apidoc.json', 'utf8')); app.use('/api-docs', swaggerUi.serve, swaggerUi.setup(swaggerDocument)); app.listen(PORT, () => {