Browse Source

chore: Re-work build, watch, test scripts

Makes better use of Lerna's run capabilities.
Michael Bromley 6 years ago
parent
commit
ffc8bc86ca

+ 5 - 3
.github/workflows/build_and_test.yml

@@ -27,8 +27,10 @@ jobs:
       run: |
         yarn install
         yarn bootstrap
-        yarn lerna run build
+        yarn build
       env:
         CI: true
-    - name: Test
-      run: yarn test:all
+    - name: Unit tests
+      run: yarn test
+    - name: e2e tests
+      run: yarn e2e

+ 2 - 2
.lintstagedrc.json

@@ -1,6 +1,6 @@
 {
   "admin-ui/**/*.ts": [
-    "yarn lint:admin-ui",
+    "yarn lint",
     "yarn format",
     "git add"
   ],
@@ -9,7 +9,7 @@
     "git add"
   ],
   "packages/**/*.ts": [
-    "yarn lint:packages",
+    "yarn lint",
     "yarn format",
     "git add"
   ]

+ 6 - 13
package.json

@@ -6,7 +6,9 @@
     "node": ">= 10.12.0 < 11 || >= 12.00"
   },
   "scripts": {
-    "core:watch": "concurrently -n tsc,gulp,common \"cd packages/core && yarn tsc:watch\" \"cd packages/core && yarn gulp:watch\" \"cd packages/common && yarn watch\"",
+    "watch": "lerna run watch --parallel",
+    "lint": "yarn tslint --fix",
+    "format": "prettier --write --html-whitespace-sensitivity ignore",
     "bootstrap": "lerna bootstrap",
     "docs:watch": "concurrently --restart-tries 5 -n docgen,hugo,webpack -c green,blue,cyan \"yarn generate-graphql-docs && yarn generate-typescript-docs -w\" \"cd docs && hugo server\" \"cd docs && yarn webpack -w\"",
     "docs:build": "yarn generate-graphql-docs && yarn generate-typescript-docs && cd docs && yarn webpack --prod && node build.js && hugo",
@@ -14,19 +16,10 @@
     "codegen": "ts-node scripts/codegen/generate-graphql-types.ts",
     "generate-typescript-docs": "ts-node scripts/docs/generate-typescript-docs.ts",
     "generate-graphql-docs": "ts-node scripts/docs/generate-graphql-docs.ts --api=shop && ts-node scripts/docs/generate-graphql-docs.ts --api=admin",
-    "format": "prettier --write --html-whitespace-sensitivity ignore",
-    "lint:packages": "yarn tslint --fix",
-    "lint:admin-ui": "cd packages/admin-ui && yarn lint --fix",
     "version": "yarn check-imports && yarn build && yarn generate-changelog && git add CHANGELOG.md",
     "dev-server:start": "cd packages/dev-server && yarn start",
-    "dev-server:populate": "cd packages/dev-server && yarn populate",
-    "test:all": "yarn test:admin-ui && yarn test:common && yarn test:core && yarn test:email-plugin && yarn test:elasticsearch-plugin && yarn test:e2e",
-    "test:common": "jest --config packages/common/jest.config.js",
-    "test:core": "jest --config packages/core/jest.config.js",
-    "test:email-plugin": "jest --config packages/email-plugin/jest.config.js --maxWorkers=1",
-    "test:elasticsearch-plugin": "jest --config packages/elasticsearch-plugin/jest.config.js",
-    "test:e2e": "jest --config packages/core/e2e/config/jest-e2e.json --runInBand",
-    "test:admin-ui": "cd packages/admin-ui && yarn test --watch=false --browsers=ChromeHeadlessCI --progress=false",
+    "test": "lerna run test --stream --no-bail",
+    "e2e": "lerna run e2e --stream --no-bail",
     "build": "lerna run build",
     "check-imports": "ts-node scripts/check-imports.ts",
     "generate-changelog": "ts-node scripts/changelogs/generate-changelog.ts",
@@ -89,7 +82,7 @@
       "commit-msg": "commitlint -e $HUSKY_GIT_PARAMS",
       "post-commit": "git update-index --again",
       "pre-commit": "lint-staged",
-      "pre-push": "yarn test:all && cd packages/admin-ui && yarn build"
+      "pre-push": "yarn build && yarn test && yarn e2e"
     }
   }
 }

+ 1 - 0
packages/admin-ui-plugin/package.json

@@ -10,6 +10,7 @@
   "scripts": {
     "build": "rimraf lib && node -r ts-node/register build.ts && yarn compile",
     "watch": "tsc -p ./tsconfig.build.json --watch",
+    "lint": "tslint --fix --project ./",
     "compile": "tsc -p ./tsconfig.build.json"
   },
   "publishConfig": {

+ 2 - 1
packages/admin-ui/package.json

@@ -5,8 +5,9 @@
     "ng": "ng",
     "start": "ng serve",
     "build": "yarn reset-extensions && ng build --prod && yarn build:devkit",
+    "watch": "ng build --watch=true",
     "build:devkit": "tsc -p tsconfig.devkit.json",
-    "test": "ng test",
+    "test": "ng test --watch=false --browsers=ChromeHeadlessCI --progress=false",
     "lint": "tslint --fix",
     "reset-extensions": "rimraf ./src/app/extensions/modules && rimraf ./src/app/extensions/*.generated && rimraf ./src/app/extensions/*.temp",
     "extract-translations": "ngx-translate-extract --input ./src --output ./src/i18n-messages/en.json --clean --sort --format namespaced-json --format-indentation \"  \" -m _"

+ 2 - 1
packages/asset-server-plugin/package.json

@@ -9,7 +9,8 @@
   "license": "MIT",
   "scripts": {
     "watch": "tsc -p ./tsconfig.build.json --watch",
-    "build": "rimraf lib && tsc -p ./tsconfig.build.json"
+    "build": "rimraf lib && tsc -p ./tsconfig.build.json",
+    "lint": "tslint --fix --project ./"
   },
   "publishConfig": {
     "access": "public"

+ 3 - 1
packages/common/package.json

@@ -5,7 +5,9 @@
   "license": "MIT",
   "scripts": {
     "watch": "tsc -p ./tsconfig.build.json -w",
-    "build": "rimraf dist && tsc -p ./tsconfig.build.json"
+    "build": "rimraf dist && tsc -p ./tsconfig.build.json",
+    "lint": "tslint --fix --project ./",
+    "test": "jest --config ./jest.config.js"
   },
   "publishConfig": {
     "access": "public"

+ 5 - 2
packages/core/package.json

@@ -18,7 +18,11 @@
   "scripts": {
     "tsc:watch": "tsc -p ./build/tsconfig.build.json --watch",
     "gulp:watch": "gulp -f ./build/gulpfile.ts watch",
-    "build": "rimraf dist && tsc -p ./build/tsconfig.build.json && tsc -p ./build/tsconfig.cli.json && gulp -f ./build/gulpfile.ts build"
+    "build": "rimraf dist && tsc -p ./build/tsconfig.build.json && tsc -p ./build/tsconfig.cli.json && gulp -f ./build/gulpfile.ts build",
+    "watch": "concurrently yarn:tsc:watch yarn:gulp:watch",
+    "lint": "tslint --fix --project ./",
+    "test": "jest --config ./jest.config.js",
+    "e2e": "jest --config ./e2e/config/jest-e2e.json --runInBand"
   },
   "publishConfig": {
     "access": "public"
@@ -70,7 +74,6 @@
     "typeorm": "0.2.20"
   },
   "devDependencies": {
-    "@vendure/testing": "0.5.0",
     "@types/bcrypt": "^3.0.0",
     "@types/cookie-session": "^2.0.36",
     "@types/csv-parse": "^1.1.11",

+ 3 - 1
packages/create/package.json

@@ -12,7 +12,9 @@
   ],
   "scripts": {
     "copy-assets": "rimraf assets && ts-node ./build.ts",
-    "build": "yarn copy-assets && rimraf lib && tsc -p ./tsconfig.build.json"
+    "build": "yarn copy-assets && rimraf lib && tsc -p ./tsconfig.build.json",
+    "watch": "yarn copy-assets && rimraf lib && tsc -p ./tsconfig.build.json -w",
+    "lint": "tslint --fix --project ./"
   },
   "publishConfig": {
     "access": "public"

+ 3 - 1
packages/elasticsearch-plugin/package.json

@@ -9,7 +9,9 @@
   ],
   "scripts": {
     "watch": "tsc -p ./tsconfig.build.json --watch",
-    "build": "rimraf lib && tsc -p ./tsconfig.build.json"
+    "build": "rimraf lib && tsc -p ./tsconfig.build.json",
+    "lint": "tslint --fix --project ./",
+    "test": "jest --config ./jest.config.js"
   },
   "publishConfig": {
     "access": "public"

+ 3 - 1
packages/email-plugin/package.json

@@ -11,7 +11,9 @@
   ],
   "scripts": {
     "watch": "tsc -p ./tsconfig.build.json --watch",
-    "build": "rimraf lib && tsc -p ./tsconfig.build.json"
+    "build": "rimraf lib && tsc -p ./tsconfig.build.json",
+    "lint": "tslint --fix --project ./",
+    "test": "jest --config ./jest.config.js"
   },
   "publishConfig": {
     "access": "public"

+ 3 - 4
packages/testing/package.json

@@ -24,7 +24,8 @@
   },
   "scripts": {
     "build": "tsc -p ./tsconfig.build.json",
-    "watch": "tsc -p ./tsconfig.build.json -w"
+    "watch": "tsc -p ./tsconfig.build.json -w",
+    "lint": "tslint --fix --project ./"
   },
   "bugs": {
     "url": "https://github.com/vendure-ecommerce/vendure/issues"
@@ -35,12 +36,10 @@
     "graphql-tag": "^2.10.1"
   },
   "devDependencies": {
+    "@vendure/core": "^0.5.0",
     "node-fetch": "^2.6.0",
     "node-libcurl": "^2.0.2",
     "rimraf": "^3.0.0",
     "typescript": "^3.6.4"
-  },
-  "peerDependencies": {
-    "@vendure/core": "^0.5.0"
   }
 }