Skip to content

Commit 97d9300

Browse files
committed
build(npm): watch script
Adds a top level watch script that invokes the package level scripts for watching all Typescript sources and automatically recompiling them whenever their contents change. It also watches the openapi.json files so if you edit one of those the API client code will automatically get regenerated as well. The big deal here with this feature is that it reduces the time it takes for a change to compile from minutes to seconds on average which is great, especially when you are working from a machine with weaker hardware not the top of the line stuff. Future possible improvement is to also run the unit tests upon every successful compilation as well. To use it, just run this in the project root directory: ```sh npm run watch ``` Fixes #149 Signed-off-by: Peter Somogyvari <[email protected]>
1 parent 6dcdb8a commit 97d9300

File tree

21 files changed

+753
-1
lines changed

21 files changed

+753
-1
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,4 @@ lerna-debug.log
4040
cactus-openapi-spec.json
4141
cactus-openapi-spec-*.json
4242
.npmrc
43+
*.log

examples/cactus-example-supply-chain-backend/package.json

+16
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
"bin": "./dist/lib/main/typescript/supply-chain-app-cli.js",
1515
"scripts": {
1616
"tsc": "tsc --project ./tsconfig.json",
17+
"watch": "npm-watch",
1718
"webpack": "npm-run-all webpack:dev webpack:prod",
1819
"webpack:dev": "npm-run-all webpack:dev:node webpack:dev:web",
1920
"webpack:dev:web": "webpack --env=dev --target=web --config ../../webpack.config.js",
@@ -22,6 +23,21 @@
2223
"webpack:prod:web": "webpack --env=prod --target=web --config ../../webpack.config.js",
2324
"webpack:prod:node": "webpack --env=prod --target=node --config ../../webpack.config.js"
2425
},
26+
"watch": {
27+
"tsc": {
28+
"patterns": [
29+
"src/",
30+
"src/*/json/**/openapi*"
31+
],
32+
"ignore": [
33+
"src/**/generated/*"
34+
],
35+
"extensions": ["ts", "json"],
36+
"quiet": true,
37+
"verbose": false,
38+
"runOnChangeOnly": true
39+
}
40+
},
2541
"engines": {
2642
"node": ">=10",
2743
"npm": ">=6"

examples/cactus-example-supply-chain-business-logic-plugin/package.json

+16
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
"generate-sdk": "openapi-generator generate --input-spec src/main/json/openapi.json -g typescript-axios -o ./src/main/typescript/generated/openapi/typescript-axios/",
1616
"tsc": "tsc --project ./tsconfig.json",
1717
"pretsc": "npm run generate-sdk",
18+
"watch": "npm-watch",
1819
"webpack": "npm-run-all webpack:dev webpack:prod",
1920
"webpack:dev": "npm-run-all webpack:dev:node webpack:dev:web",
2021
"webpack:dev:web": "webpack --env=dev --target=web --config ../../webpack.config.js",
@@ -23,6 +24,21 @@
2324
"webpack:prod:web": "webpack --env=prod --target=web --config ../../webpack.config.js",
2425
"webpack:prod:node": "webpack --env=prod --target=node --config ../../webpack.config.js"
2526
},
27+
"watch": {
28+
"tsc": {
29+
"patterns": [
30+
"src/",
31+
"src/*/json/**/openapi*"
32+
],
33+
"ignore": [
34+
"src/**/generated/*"
35+
],
36+
"extensions": ["ts", "json"],
37+
"quiet": true,
38+
"verbose": false,
39+
"runOnChangeOnly": true
40+
}
41+
},
2642
"engines": {
2743
"node": ">=10",
2844
"npm": ">=6"

0 commit comments

Comments
 (0)