Skip to content

Commit 0abdd40

Browse files
committed
chore: synchronizing with typescript-demo-lib
1 parent 8bb5fcd commit 0abdd40

15 files changed

+267
-40
lines changed

.editorconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ end_of_line = lf
55
indent_style = space
66
indent_size = 2
77
insert_final_newline = true
8-
trim_trailing_whitespace = true
8+
trim_trailing_whitespace = true

.eslintrc

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
},
2323
"rules": {
2424
"linebreak-style": ["error", "unix"],
25-
"no-empty": 0,
25+
"no-empty": 1,
2626
"no-useless-catch": 1,
2727
"no-prototype-builtins": 1,
2828
"no-constant-condition": 0,
@@ -142,6 +142,10 @@
142142
"format": ["PascalCase"],
143143
"trailingUnderscore": "allowSingleOrDouble"
144144
},
145+
{
146+
"selector": "enumMember",
147+
"format": ["PascalCase", "UPPER_CASE"]
148+
},
145149
{
146150
"selector": "objectLiteralProperty",
147151
"format": null
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
on:
2+
push:
3+
branches:
4+
- master
5+
pull_request_target:
6+
types: [opened, synchronize, reopened]
7+
8+
name: CodeSee Map
9+
10+
jobs:
11+
test_map_action:
12+
runs-on: ubuntu-latest
13+
continue-on-error: true
14+
name: Run CodeSee Map Analysis
15+
steps:
16+
- name: checkout
17+
id: checkout
18+
uses: actions/checkout@v2
19+
with:
20+
repository: ${{ github.event.pull_request.head.repo.full_name }}
21+
ref: ${{ github.event.pull_request.head.ref }}
22+
fetch-depth: 0
23+
24+
# codesee-detect-languages has an output with id languages.
25+
- name: Detect Languages
26+
id: detect-languages
27+
uses: Codesee-io/codesee-detect-languages-action@latest
28+
29+
- name: Configure JDK 16
30+
uses: actions/setup-java@v2
31+
if: ${{ fromJSON(steps.detect-languages.outputs.languages).java }}
32+
with:
33+
java-version: '16'
34+
distribution: 'zulu'
35+
36+
# CodeSee Maps Go support uses a static binary so there's no setup step required.
37+
38+
- name: Configure Node.js 14
39+
uses: actions/setup-node@v2
40+
if: ${{ fromJSON(steps.detect-languages.outputs.languages).javascript }}
41+
with:
42+
node-version: '14'
43+
44+
- name: Configure Python 3.x
45+
uses: actions/setup-python@v2
46+
if: ${{ fromJSON(steps.detect-languages.outputs.languages).python }}
47+
with:
48+
python-version: '3.10'
49+
architecture: 'x64'
50+
51+
- name: Configure Ruby '3.x'
52+
uses: ruby/setup-ruby@v1
53+
if: ${{ fromJSON(steps.detect-languages.outputs.languages).ruby }}
54+
with:
55+
ruby-version: '3.0'
56+
57+
# We need the rust toolchain because it uses rustc and cargo to inspect the package
58+
- name: Configure Rust 1.x stable
59+
uses: actions-rs/toolchain@v1
60+
if: ${{ fromJSON(steps.detect-languages.outputs.languages).rust }}
61+
with:
62+
toolchain: stable
63+
64+
- name: Generate Map
65+
id: generate-map
66+
uses: Codesee-io/codesee-map-action@latest
67+
with:
68+
step: map
69+
api_token: ${{ secrets.CODESEE_ARCH_DIAG_API_TOKEN }}
70+
github_ref: ${{ github.ref }}
71+
languages: ${{ steps.detect-languages.outputs.languages }}
72+
73+
- name: Upload Map
74+
id: upload-map
75+
uses: Codesee-io/codesee-map-action@latest
76+
with:
77+
step: mapUpload
78+
api_token: ${{ secrets.CODESEE_ARCH_DIAG_API_TOKEN }}
79+
github_ref: ${{ github.ref }}
80+
81+
- name: Insights
82+
id: insights
83+
uses: Codesee-io/codesee-map-action@latest
84+
with:
85+
step: insights
86+
api_token: ${{ secrets.CODESEE_ARCH_DIAG_API_TOKEN }}
87+
github_ref: ${{ github.ref }}

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,13 @@
22
/dist
33
.env*
44
!.env.example
5+
# nix
56
/result*
7+
/builds
8+
# node-gyp
9+
/build
10+
# prebuildify
11+
/prebuilds
612

713
# Logs
814
logs

.npmignore

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
.*
2+
/*.nix
23
/nix
3-
/pkgs.nix
4-
/default.nix
5-
/shell.nix
6-
/release.nix
74
/tsconfig.json
85
/tsconfig.build.json
96
/jest.config.js
7+
/scripts
108
/src
119
/tests
1210
/tmp
1311
/docs
1412
/benches
13+
/build
14+
/builds
1515
/dist/tsbuildinfo

jest.config.js

Lines changed: 49 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,58 @@
1+
const path = require('path');
12
const { pathsToModuleNameMapper } = require('ts-jest');
23
const { compilerOptions } = require('./tsconfig');
34

5+
const moduleNameMapper = pathsToModuleNameMapper(compilerOptions.paths, {
6+
prefix: '<rootDir>/src/',
7+
});
8+
9+
// Global variables that are shared across the jest worker pool
10+
// These variables must be static and serializable
11+
const globals = {
12+
// Absolute directory to the project root
13+
projectDir: __dirname,
14+
// Absolute directory to the test root
15+
testDir: path.join(__dirname, 'tests'),
16+
// Default asynchronous test timeout
17+
defaultTimeout: 20000,
18+
// Timeouts rely on setTimeout which takes 32 bit numbers
19+
maxTimeout: Math.pow(2, 31) - 1,
20+
};
21+
22+
// The `globalSetup` and `globalTeardown` cannot access the `globals`
23+
// They run in their own process context
24+
// They can however receive the process environment
25+
// Use `process.env` to set variables
26+
427
module.exports = {
28+
testEnvironment: 'node',
529
verbose: true,
6-
roots: [
7-
"<rootDir>/tests"
8-
],
9-
testMatch: [
10-
"**/?(*.)+(spec|test|unit.test).+(ts|tsx|js)"
11-
],
30+
collectCoverage: false,
31+
cacheDirectory: '<rootDir>/tmp/jest',
32+
coverageDirectory: '<rootDir>/tmp/coverage',
33+
roots: ['<rootDir>/tests'],
34+
testMatch: ['**/?(*.)+(spec|test|unit.test).+(ts|tsx|js|jsx)'],
1235
transform: {
13-
"^.+\\.tsx?$": "ts-jest"
36+
'^.+\\.tsx?$': 'ts-jest',
37+
'^.+\\.jsx?$': 'babel-jest',
1438
},
15-
setupFiles: [
16-
"<rootDir>/tests/setup.ts"
39+
reporters: [
40+
'default',
41+
['jest-junit', { outputDirectory: '<rootDir>/tmp/junit' }],
1742
],
18-
globalSetup: "<rootDir>/tests/globalSetup.ts",
19-
globalTeardown: "<rootDir>/tests/globalTeardown.ts",
20-
moduleNameMapper: pathsToModuleNameMapper(
21-
compilerOptions.paths,
22-
{ prefix: "<rootDir>/src/" }
23-
)
43+
collectCoverageFrom: ['src/**/*.{ts,tsx,js,jsx}', '!src/**/*.d.ts'],
44+
coverageReporters: ['text', 'cobertura'],
45+
globals,
46+
// Global setup script executed once before all test files
47+
globalSetup: '<rootDir>/tests/globalSetup.ts',
48+
// Global teardown script executed once after all test files
49+
globalTeardown: '<rootDir>/tests/globalTeardown.ts',
50+
// Setup files are executed before each test file
51+
// Can access globals
52+
setupFiles: ['<rootDir>/tests/setup.ts'],
53+
// Setup files after env are executed before each test file
54+
// after the jest test environment is installed
55+
// Can access globals
56+
setupFilesAfterEnv: ['<rootDir>/tests/setupAfterEnv.ts'],
57+
moduleNameMapper: moduleNameMapper,
2458
};

package-lock.json

Lines changed: 74 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,13 @@
1212
"types": "dist/index.d.ts",
1313
"scripts": {
1414
"prepare": "tsc -p ./tsconfig.build.json",
15-
"build": "rm -r ./dist || true; tsc -p ./tsconfig.build.json",
15+
"build": "rimraf ./dist && tsc -p ./tsconfig.build.json",
16+
"postversion": "npm install --package-lock-only --ignore-scripts --silent",
1617
"ts-node": "ts-node -r tsconfig-paths/register",
1718
"test": "jest",
1819
"lint": "eslint '{src,tests,benches}/**/*.{js,ts}'",
1920
"lintfix": "eslint '{src,tests,benches}/**/*.{js,ts}' --fix",
20-
"docs": "rm -r ./docs || true; typedoc --gitRevision master --tsconfig ./tsconfig.build.json --out ./docs src"
21+
"docs": "rimraf ./docs && typedoc --gitRevision master --tsconfig ./tsconfig.build.json --out ./docs src"
2122
},
2223
"dependencies": {
2324
"@matrixai/async-locks": "^2.3.1",
@@ -34,7 +35,9 @@
3435
"eslint-plugin-import": "^2.26.0",
3536
"eslint-plugin-prettier": "^4.0.0",
3637
"jest": "^27.2.5",
38+
"jest-junit": "^13.2.0",
3739
"prettier": "^2.6.2",
40+
"rimraf": "^3.0.2",
3841
"ts-jest": "^27.0.5",
3942
"ts-node": "^10.4.0",
4043
"tsconfig-paths": "^3.9.0",

0 commit comments

Comments
 (0)