Skip to content

Commit

Permalink
fix: script
Browse files Browse the repository at this point in the history
  • Loading branch information
RulerChen committed Jun 16, 2024
1 parent 0ab5294 commit 996b200
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
2 changes: 1 addition & 1 deletion packages/package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
10 changes: 5 additions & 5 deletions packages/scripts/createPackageJson.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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) {
Expand All @@ -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';
Expand Down
8 changes: 5 additions & 3 deletions packages/templates/swagger/javascript/src/index.js
Original file line number Diff line number Diff line change
@@ -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();

Expand All @@ -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, () => {
Expand Down

0 comments on commit 996b200

Please sign in to comment.