Jhernandez has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/371513 )

Change subject: POC: Change the structure of npm scripts
......................................................................

POC: Change the structure of npm scripts

* Organize them by sections
  * Main scripts for development
  * Git hooks
  * Helpers & tools
* Reduce number of scripts from 21 to 15
  * There may be some loss of flexibility because of some hardcoded
    paths
* Switch many scripts to run parallel for better speedups
* Clean up dist/ before 'npm run build'

Groups the main development scripts under this use cases:

* Want to develop:
  * npm start # Run the program and compilers
  * npm test  # Run linting & tests
* Other main actions:
  * npm run build      # Build production artifacts in dist/
  * npm run format     # Auto-fix my code style and linting problems
  * npm run lint       # Find problems with my code
  * npm run test:watch # Run linting and tests in watch mode

The rest of the scripts are considered secondary.

TODO:
- Discuss this patch
- Document the main scripts in the readme or in docs/ in the development
  guide
- Removed 'build' from 'test' because in dev you would have 2 build
  scripts running in parallel by 'start' and 'test', which could lead
  to weird conditions.
  - Need to figure out how to run a build in CI, without running it in
    development in 'test'

Example npm run output:

    Lifecycle scripts included in marvin:
      start
        run-p -sn 'client:build -- -w' 'server:build -- -w' server:watch
      test
        run-p -sn lint mocha

    available via `npm run-script`:
      //
        MAIN SCRIPTS
      build
        NODE_ENV=production npm-run-all --silent clean --parallel server:build 
'client:build -- -p'
      format
        run-p -s 'eslint -- --fix .' 'prettier -- --write'
      lint
        run-p -sn 'eslint -- .' 'prettier -- -l'
      test:watch
        nodemon -e js,json,ts,tsx -q -x 'npm test'
      //-
        HOOKS
      precommit
        npm test -s
      //--
        HELPERS
      server:watch
        nodemon -e js,json,ts,tsx -q -x 'npm run server:run'
      server:build
        tsc -p src/server/tsconfig.json
      server:run
        node dist/server/index.js
      client:build
        webpack --display minimal
      //---
        TOOLS
      prettier
        prettier --parser typescript '{src,test}/**/*.{ts,tsx}'
      eslint
        eslint --cache --max-warnings 0 --ext js,json
      mocha
        mocha '{src,test}/**/*.test.{ts,js}'
      clean
        rm -rf dist/

Change-Id: Ifa7adc79d3a1cda82fee0c3bd5534ddff403f6ff
---
M package.json
1 file changed, 21 insertions(+), 20 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/marvin refs/changes/13/371513/1

diff --git a/package.json b/package.json
index f52ba40..dbacfe5 100644
--- a/package.json
+++ b/package.json
@@ -3,27 +3,28 @@
   "version": "0.0.0",
   "description": "An API driven skin for MediaWiki",
   "scripts": {
-    "start": "run-p -sn dev:\\*",
-    "dev:client": "webpack -w",
-    "dev:server": "run-p -sn dev:server:\\*",
-    "dev:server:build": "npm run -s server:build -- -w",
-    "dev:server:watch": "nodemon -e js,json,ts,tsx -q dist/server/index.js",
-    "server:build": "tsc -p src/server/tsconfig.json",
-    "client:build": "webpack -p",
-    "prod:build": "NODE_ENV=production run-s -s server:build client:build",
-    "format:ts": "prettier --write --parser typescript",
-    "format:ts:all": "npm run -s format:ts -- '{src,test}/**/*.{ts,tsx}'",
-    "format:js": "npm run -s lint -- --fix",
-    "format:js:all": "npm run -s format:js -- .",
-    "format:all": "run-s -s format:js:all format:ts:all",
-    "lint": "eslint --cache --max-warnings 0 --ext js,json",
-    "lint:ts": "prettier --parser typescript -l",
-    "lint:ts:all": "npm run -s lint:ts -- '{src,test}/**/*.{ts,tsx}'",
-    "lint:all": "npm run -s lint -- . && npm run -s lint:ts:all",
-    "pretest": "run-s -s lint:all prod:build",
-    "test": "mocha '{src,test}/**/*.test.{ts,js}'",
+    "//": "MAIN SCRIPTS",
+    "start": "run-p -sn 'client:build -- -w' 'server:build -- -w' 
server:watch",
+    "build": "NODE_ENV=production npm-run-all --silent clean --parallel 
server:build 'client:build -- -p'",
+    "format": "run-p -s 'eslint -- --fix .' 'prettier -- --write'",
+    "lint": "run-p -sn 'eslint -- .' 'prettier -- -l'",
+    "test": "run-p -sn lint mocha",
     "test:watch": "nodemon -e js,json,ts,tsx -q -x 'npm test'",
-    "precommit": "npm run -s test"
+
+    "//-": "HOOKS",
+    "precommit": "npm test -s",
+
+    "//--": "HELPERS",
+    "server:watch": "nodemon -e js,json,ts,tsx -q -x 'npm run server:run'",
+    "server:build": "tsc -p src/server/tsconfig.json",
+    "server:run": "node dist/server/index.js",
+    "client:build": "webpack --display minimal",
+
+    "//---": "TOOLS",
+    "prettier": "prettier --parser typescript '{src,test}/**/*.{ts,tsx}'",
+    "eslint": "eslint --cache --max-warnings 0 --ext js,json",
+    "mocha": "mocha '{src,test}/**/*.test.{ts,js}'",
+    "clean": "rm -rf dist/"
   },
   "repository": {
     "type": "git",

-- 
To view, visit https://gerrit.wikimedia.org/r/371513
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ifa7adc79d3a1cda82fee0c3bd5534ddff403f6ff
Gerrit-PatchSet: 1
Gerrit-Project: marvin
Gerrit-Branch: master
Gerrit-Owner: Jhernandez <jhernan...@wikimedia.org>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to