-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* chore: add dev-env * chore: add src * chore: add tests * chore: add package definition * chore: add eslint ignorePatterns * chore: bump libs * ci: add pipeline * ci: use npx for license-check * ci: run in browsertest image * chore: newline * chore: add scripts * chore: use test:ci * chore: simplify token usage * ci: use correct registry * chore: update package.json * chore: add test:local:node script
- Loading branch information
1 parent
5d49508
commit 95fc51c
Showing
96 changed files
with
22,641 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
set -e | ||
set -x | ||
|
||
npm ci | ||
npm run lint:prettier | ||
npm run lint:eslint | ||
npx license-check | ||
npm audit | ||
npm run build:ci |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
set -e | ||
set -x | ||
|
||
npm set //registry.npmjs.org/:_authToken=${NPM_TOKEN} | ||
npm publish |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
set -e | ||
set -x | ||
|
||
npm run test:ci |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#!/usr/bin/env bash | ||
set -e | ||
|
||
if ! command -v jq &>/dev/null; then | ||
echo "jq could not be found" | ||
exit 1 | ||
fi | ||
|
||
sed -i "s/{{dependencies}}/$(jq .dependencies package.json -cr)/" ./dist/ServalBuildInformation.js | ||
sed -i "s/{{version}}/$(jq .version package.json -cr)/" ./dist/ServalBuildInformation.js | ||
sed -i "s/{{build}}/$BITBUCKET_BUILD_NUMBER/" ./dist/ServalBuildInformation.js | ||
sed -i "s/{{commit}}/$(git rev-parse HEAD)/" ./dist/ServalBuildInformation.js | ||
sed -i "s/{{date}}/$(date -u --iso-8601=seconds)/" ./dist/ServalBuildInformation.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"ignorePatterns": ["/*", "!/src", "!/test"], | ||
"extends": ["@js-soft/ts", "@js-soft/ts/mocha"], | ||
"parserOptions": { | ||
"project": ["tsconfig.json", "test/tsconfig.json"] | ||
}, | ||
"rules": { | ||
"jest/expect-expect": [ | ||
"error", | ||
{ | ||
"assertFunctionNames": ["expect", "expectValid*", "expectThrows*"] | ||
} | ||
] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
name: Publish | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
publish-npm: | ||
runs-on: ubuntu-latest | ||
container: jssoft/node_browsertests | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- run: apt-get update && apt-get install jq -y | ||
- run: bash .ci/build.sh | ||
- run: bash .ci/test.sh | ||
- run: bash .ci/publish.sh | ||
env: | ||
NPM_TOKEN: ${{ secrets.NPM_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
name: Test | ||
|
||
on: | ||
push: | ||
branches-ignore: | ||
- main | ||
|
||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
container: jssoft/node_browsertests | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- run: apt-get update && apt-get install jq -y | ||
- run: bash .ci/build.sh | ||
- run: bash .ci/test.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
node_modules | ||
dist-test | ||
dist | ||
lib-web | ||
chromedriver.log |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
dist | ||
dist-test | ||
lib-web | ||
node_modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"endOfLine": "lf", | ||
"printWidth": 120, | ||
"tabWidth": 4, | ||
"trailingComma": "none", | ||
"semi": false, | ||
"overrides": [ | ||
{ | ||
"files": ["*.yaml", "*.yml"], | ||
"options": { | ||
"tabWidth": 2 | ||
} | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
{ | ||
"[jsonc]": { | ||
"editor.defaultFormatter": "esbenp.prettier-vscode" | ||
}, | ||
"[json]": { | ||
"editor.defaultFormatter": "esbenp.prettier-vscode" | ||
}, | ||
"[javascript]": { | ||
"editor.defaultFormatter": "esbenp.prettier-vscode" | ||
}, | ||
"[typescript]": { | ||
"editor.defaultFormatter": "esbenp.prettier-vscode" | ||
}, | ||
"[yaml]": { | ||
"editor.defaultFormatter": "esbenp.prettier-vscode" | ||
}, | ||
"[markdown]": { | ||
"editor.defaultFormatter": "esbenp.prettier-vscode" | ||
}, | ||
"editor.formatOnSave": true, | ||
"editor.formatOnPaste": true, | ||
"files.autoSave": "off", | ||
"editor.codeActionsOnSave": { | ||
"source.organizeImports": true | ||
}, | ||
"files.eol": "\n", | ||
"todo-tree.filtering.excludeGlobs": [ | ||
"**/node_modules/**", | ||
"**/dist/**", | ||
"**/dist-test/**", | ||
"**/lib-web/**", | ||
"**/*.min.*", | ||
"**/*.map" | ||
], | ||
"todo-tree.general.tags": ["TODO:"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
# Development Guide | ||
|
||
Install all dependencies and build/test the current version with these commands: | ||
|
||
``` | ||
npm i | ||
npm run bt | ||
``` | ||
|
||
## Build and Test | ||
|
||
To run all tests and required builds, use the shorthand command `bt` to build and test all assets. `bt` is first running a NodeJS test and afterwards bundling the browser assets to execute the browser tests on them. | ||
|
||
## Build Setup and Assets | ||
|
||
This library is built with `tsc` and `webpack` and outputs the following assets: | ||
|
||
- `/dist` folder - for further development in a non-browser environment (e.g. NodeJS/TypeScript context) | ||
- `tsserval.js` - the uncompressed browser javascript source | ||
- `tsserval.min.js` - the compressed browser javascript source | ||
- Additional files (map files, licenses, ...) | ||
|
||
## Build Scripts | ||
|
||
Various build scripts are available over the `npm run` commands: | ||
|
||
- `bt` builds all assets and runs all tests in a smart order (without doing too many things if tests break) | ||
- `build` compiles all sources, tests to /dist and packs them browser-friendly to /lib-web | ||
- `build:node` compiles all TypeScript sources via `tsc` from /src to /dist and checks circular dependencies on /dist | ||
- `build:test` compiles all TypeScript tests via `tsc` from /test to /dist-test | ||
- `bundle` creates browser-friendly assets | ||
- `bundle:lib` bundles compiled distribution files to a browser-friendly asset via `webpack` from /dist to /lib-web (tsserval.js) | ||
- `bundle:min` bundles compiled distribution files to a compressed/minified browser-friendly asset via `webpack` from /dist to /lib-web (tsserval.min.js) | ||
- `bundle:test` bundles compiled test files to a browser-friendly form via `webpack` from /dist-test to /lib-web | ||
- `build:ci` is meant as build command for the pipeline and effectively runs `build` with a step in between, which replaces the runtime version informations in the respective file | ||
|
||
## Test Setup | ||
|
||
Tests are written in TypeScript and executed in NodeJS and browser environments. | ||
|
||
- NodeJS tests are executed with the `mocha` testrunner and `node-ts` as TypeScript environment. Thus, running the NodeJS tests do not require a `build` step as `node-ts` is coping with the TypeScript compilation internally. | ||
- Browser tests are executed with `bt-runner` which uses `chromedriver` to test the bundled assets in compressed and uncompressed variants within the browser environment. The browser tests do not automatically `bundle` new builds, thus a browser build must be triggered before the browser tests. | ||
|
||
## Test Scripts | ||
|
||
Various test scripts are available over the `npm run` commands: | ||
|
||
- `bt` builds all assets and runs all tests in a smart order (without doing too many things if tests break) | ||
- `test` runs all tests, first NodeJS then browser environment | ||
- `test:node` runs NodeJS tests with `node-ts` | ||
- `test:web` runs the tests on a browser environment with `bt-runner` | ||
- `test:server` runs a keep-alive version of `bt-runner` which can be used for debugging | ||
|
||
## Deployment | ||
|
||
Because of the `files` property within the `package.json`, only the respective build assets are published to the package registry. A license check is done before publishing it to the respective package registry. | ||
|
||
## Runtime Dependencies | ||
|
||
ts-serval only has only one runtime dependency so far, which is `reflect-metadata` to extract the metadata information out of the TypeScript compilation process and make it accessible in the runtime context. | ||
|
||
# Common Mistakes |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"testFolder": "./lib-web", | ||
"runners": [ | ||
{ | ||
"dependencies": ["tsserval.js", "tsserval.test.js"], | ||
"globals": ["TSServal", "TSServalTest"] | ||
}, | ||
{ | ||
"dependencies": ["tsserval.min.js", "tsserval.test.js"], | ||
"globals": ["TSServal", "TSServalTest"] | ||
} | ||
] | ||
} |
Oops, something went wrong.