Skip to content

Commit

Permalink
fix(cli): make sure generated package.json is well formatted
Browse files Browse the repository at this point in the history
  • Loading branch information
raymondfeng committed Mar 30, 2020
1 parent c30dce3 commit 38be23f
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 15 deletions.
13 changes: 6 additions & 7 deletions packages/cli/generators/project/templates/package.json.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
"scripts": {
"build": "lb-tsc",
"build:watch": "lb-tsc --watch",
"clean": "lb-clean dist *.tsbuildinfo",
<% if (project.prettier && project.eslint) { -%>
"lint": "npm run prettier:check && npm run eslint",
"lint:fix": "npm run eslint:fix && npm run prettier:fix",
Expand Down Expand Up @@ -46,15 +45,15 @@
"test:dev": "lb-mocha --allow-console-logs dist/__tests__/**/*.js",
<% } -%>
<% if (project.projectType === 'application') { -%>
<% if (project.docker) { -%>
<%_ if (project.docker) { -%>
"docker:build": "docker build -t <%= project.name -%> .",
"docker:run": "docker run -p 3000:3000 -d <%= project.name -%>",
<% } -%>
<%_ } -%>
"migrate": "node ./dist/migrate",
"prestart": "npm run build",
"start": "node -r source-map-support/register .",
<% } -%>
"prepublishOnly": "npm run test"
"clean": "lb-clean dist *.tsbuildinfo .eslintcache"
},
"repository": {
"type": "git"
Expand Down Expand Up @@ -91,22 +90,22 @@
<% } else { /* NOT AN APPLICATION */-%>
"@loopback/core": "<%= project.dependencies['@loopback/core'] -%>",
<% } -%>
"tslib": "<%= project.dependencies['tslib'] -%>"
"tslib": "<%= project.dependencies['tslib'] -%>"
},
"devDependencies": {
"@loopback/build": "<%= project.dependencies['@loopback/build'] -%>",
"source-map-support": "<%= project.dependencies['source-map-support'] -%>",
"@loopback/testlab": "<%= project.dependencies['@loopback/testlab'] -%>",
"@types/node": "<%= project.dependencies['@types/node'] -%>",
<% if (project.eslint) { -%>
<% if (project.eslint) { -%>
"@typescript-eslint/parser": "<%= project.dependencies['@typescript-eslint/parser'] -%>",
"@typescript-eslint/eslint-plugin": "<%= project.dependencies['@typescript-eslint/eslint-plugin'] -%>",
"@loopback/eslint-config": "<%= project.dependencies['@loopback/eslint-config'] -%>",
"eslint": "<%= project.dependencies['eslint'] -%>",
"eslint-config-prettier": "<%= project.dependencies['eslint-config-prettier'] -%>",
"eslint-plugin-eslint-plugin": "<%= project.dependencies['eslint-plugin-eslint-plugin'] -%>",
"eslint-plugin-mocha": "<%= project.dependencies['eslint-plugin-mocha'] -%>",
<% } -%>
<% } -%>
"typescript": "<%= project.dependencies['typescript'] -%>"
}
}
10 changes: 5 additions & 5 deletions packages/cli/generators/project/templates/package.plain.json.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"scripts": {
"build": "tsc",
"build:watch": "tsc --watch",
"clean": "rimraf dist *.tsbuildinfo",
"clean": "rimraf dist *.tsbuildinfo .eslintcache",
<% if (project.prettier && project.eslint) { -%>
"lint": "npm run prettier:check && npm run eslint",
"lint:fix": "npm run eslint:fix && npm run prettier:fix",
Expand Down Expand Up @@ -46,10 +46,10 @@
"test:dev": "mocha dist/__tests__/**/*.js",
<% } -%>
<% if (project.projectType === 'application') { -%>
<% if (project.docker) { -%>
<%_ if (project.docker) { -%>
"docker:build": "docker build -t <%= project.name -%> .",
"docker:run": "docker run -p 3000:3000 -d <%= project.name -%>",
<% } -%>
<%_ } -%>
"migrate": "node ./dist/migrate",
"start": "npm run build && node -r source-map-support/register .",
<% } -%>
Expand Down Expand Up @@ -83,7 +83,7 @@
<% } else { -%>
"@loopback/core": "<%= project.dependencies['@loopback/core'] -%>",
<% } -%>
"tslib": "<%= project.dependencies['tslib'] -%>"
"tslib": "<%= project.dependencies['tslib'] -%>"
},
"devDependencies": {
"rimraf": "<%= project.dependencies['rimraf'] -%>",
Expand All @@ -110,7 +110,7 @@
"eslint-config-prettier": "<%= project.dependencies['eslint-config-prettier'] -%>",
"eslint-plugin-eslint-plugin": "<%= project.dependencies['eslint-plugin-eslint-plugin'] -%>",
"eslint-plugin-mocha": "<%= project.dependencies['eslint-plugin-mocha'] -%>",
<% } -%>
<% } -%>
"typescript": "<%= project.dependencies['typescript'] -%>"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ describe('app-generator specific files', () => {
it('creates npm script "clean"', () => {
assert.fileContent(
'package.json',
'"clean": "lb-clean dist *.tsbuildinfo"',
'"clean": "lb-clean dist *.tsbuildinfo .eslintcache"',
);
});

Expand Down
5 changes: 3 additions & 2 deletions packages/cli/test/integration/lib/project-generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -342,8 +342,9 @@ module.exports = function (projGenerator, props, projectType) {
['tsconfig.json', '@loopback/build'],
]);
assert.fileContent([
['package.json', '"clean": "rimraf dist *.tsbuildinfo"'],
['package.json', '"typescript"'],
['package.json', '"clean": "rimraf dist *.tsbuildinfo .eslintcache"'],
['package.json', /^ {4}"typescript"/m],
['package.json', /^ {4}"tslib"/m],
['package.json', '"eslint"'],
['package.json', 'eslint-config-prettier'],
['package.json', 'eslint-plugin-eslint-plugin'],
Expand Down

0 comments on commit 38be23f

Please sign in to comment.