Skip to content

Commit

Permalink
Merge pull request #9 from sineverba/refactor-repository
Browse files Browse the repository at this point in the history
Refactor repository
  • Loading branch information
sineverba committed Jun 4, 2024
2 parents dafae28 + aa850a2 commit e6bbded
Show file tree
Hide file tree
Showing 17 changed files with 2,203 additions and 522 deletions.
19 changes: 14 additions & 5 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,24 @@
version: 2.1
jobs:

test:
docker:
- image: cimg/node:20.10.0

resource_class: medium
environment:
NPM_VERSION: 10.2.5
steps:
- checkout
- run: npm ci
- run: npx jest

- run:
name: "Setup NPM version"
command: npm install npm@${NPM_VERSION}
- run:
name: "Setup project"
command: npm ci
- run:
name: "Run test"
command: npx jest
- store_test_results:
path: ./.test_report
workflows:
version: 2
test:
Expand Down
15 changes: 5 additions & 10 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
coverage
node_modules
build
npm-debug.log
.env
.DS_Store
.npmrc
.nyc_output
.scannerwork
dist/
.scannerwork/
.test_report/
coverage/
dist/
node_modules/
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__tests__/
4 changes: 4 additions & 0 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"tabWidth": 2,
"trailingComma": "none"
}
10 changes: 7 additions & 3 deletions .semaphore/build-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,21 @@ agent:
os_image: ubuntu2004

global_job_config:
env_vars:
- name: NPM_VERSION
value: 10.2.5
secrets:
- name: ACCESS_TOKENS

blocks:
- name: Deploy
- name: Deploy to NPM
task:
jobs:
- name: Deploy
- name: Deploy to NPM
commands:
- checkout
- npm install npm@$NPM_VERSION
- npm ci
- npm run build
- mv npmrc.txt .npmrc
- npm publish
- npm publish
19 changes: 15 additions & 4 deletions .semaphore/semaphore.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ agent:
global_job_config:
env_vars:
- name: SONARSCANNER_VERSION
value: 5.0.1
value: 10.0.2.1398_5.0.1
- name: NPM_VERSION
value: 10.2.5
secrets:
- name: ACCESS_TOKENS

Expand All @@ -35,21 +37,30 @@ blocks:
- checkout
- cache restore
jobs:
- name: Test
- name: Test previous Node versions
matrix:
- env_var: NODE_VERSION
values: [ "14", "16", "18", "20" ]
values: [ "14","16", "18" ]
commands:
- sem-version node $NODE_VERSION
- npx jest
- name: Test current Node versions
commands:
- rm -r node_modules/
- nvm install
- nvm use
- npm install npm@$NPM_VERSION
- npm ci
- npx jest
- '[[ -f ./.test_report/junit.xml ]] && test-results publish ./.test_report/junit.xml'
- test-results gen-pipeline-report
- name: Prettier
commands:
- rm -r node_modules/
- nvm install
- nvm use
- npm ci
- npm run prettier

- name: Coverage
skip:
when: "tag =~ '.*'"
Expand Down
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Next version
+ Refactor repository

## 1.2.0
+ Upgrade dependencies

Expand Down
14 changes: 9 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
SONARSCANNER_VERSION=5.0.1
SONARSCANNER_VERSION=10.0.2.1398_5.0.1

sonar:
docker run --rm -it \
docker run \
--rm \
-it \
--name sonarscanner \
-v $(PWD):/usr/src \
-e SONAR_HOST_URL=$(SONAR_HOST_URL) \
-e SONAR_TOKEN=$(SONAR_TOKEN) \
sonarsource/sonar-scanner-cli:$(SONARSCANNER_VERSION)

upgrade:
npx ncu -u
npm install
npx ncu \
-x eslint \
-u
npx update-browserslist-db@latest
npm audit fix
npm install
npm audit fix || exit 0;
6 changes: 0 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,3 @@ console.log(newData);
*/

```

#### Tests

`npm run test` for simple test

`npm run cover` for coverage
14 changes: 14 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// @ts-check

import eslint from "@eslint/js";
import prettierConfig from "eslint-config-prettier";
import tseslint from "typescript-eslint";

export default tseslint.config({
files: ["src/index.ts"],
extends: [
eslint.configs.recommended,
...tseslint.configs.recommended,
prettierConfig
]
});
12 changes: 9 additions & 3 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
/** @type {import('ts-jest').JestConfigWithTsJest} */
module.exports = {
preset: 'ts-jest',
testEnvironment: 'node',
};
preset: "ts-jest",
reporters: ["default", ["jest-junit", { outputDirectory: ".test_report" }]],
setupFilesAfterEnv: ["<rootDir>/setupTest.js"],
testEnvironment: "jsdom",
moduleNameMapper: {
// Force module uuid to resolve with the CJS entry point, because Jest does not support package.json.exports. See https://github.com/uuidjs/uuid/issues/451
uuid: require.resolve("uuid")
}
};
Loading

0 comments on commit e6bbded

Please sign in to comment.