Skip to content

Commit

Permalink
feat(npm): add theme switcher
Browse files Browse the repository at this point in the history
  • Loading branch information
Julius Osokinas committed May 10, 2021
1 parent 668a891 commit ff7983e
Show file tree
Hide file tree
Showing 16 changed files with 16,095 additions and 8,840 deletions.
30 changes: 30 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Test

on: push

jobs:
unit-tests:
name: Run unit tests
runs-on: ubuntu-latest

steps:
- name: Checkout Git repository
uses: actions/checkout@v2

- name: Setup Node
uses: actions/setup-node@v2.1.4
with:
node-version: 14

- name: Install Node dependencies
run: npm ci --no-audit --no-optional

- name: Test packages
run: npm run test

- name: Keep artifacts
uses: actions/upload-artifact@v2
if: always()
with:
name: coverage
path: coverage
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ node_modules
yarn.lock

# Repository specific
coverage
dist
packages/npm/src/tokens.scss
packages/npm/src/theme-*.scss
4 changes: 4 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
"[handlebars]": {
"editor.formatOnSave": false
},
"[javascript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": true
},
"[json]": {
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": true
Expand Down
35 changes: 29 additions & 6 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,29 +22,52 @@ To install and switch to required version run:

## Make a change

1. Make sure that lint passes:
1. Make sure that tests pass:

`npm run test`

2. Make sure that lint passes:

`npm run lint`

2. Commit according to [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/). We support these tools:
3. Commit according to [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/). We support these tools:

- Commitizen, which runs automatically on a pre-commit Git hook thanks to Husky.

- The [VS Code plugin](https://marketplace.visualstudio.com/items?itemName=vivaxy.vscode-conventional-commits).

3. When opening a pull request, provide as much details as possible for a reviewer to better understand the change.
4. When opening a pull request, provide as much details as possible for a reviewer to better understand the change.

5. Check the change manually locally _before_ you assign reviewers.

6. When a PR is approved - **do not merge** until acceptance testing is done, and the change is ready for a release.

### Run unit tests locally

You can run unit tests as the CI would with:

4. Check the change manually locally _before_ you assign reviewers.
npm run test

5. When a PR is approved - **do not merge** until acceptance testing is done, and the change is ready for a release.
That runs all specs and generates coverage reports.

If you want watch mode for your changes only, use:

npx jest --watch

You can also filter to a single file if you want, like:

npx jest --watch my-file

### Build package locally

You can build a package by running:

npm run build

It generates design tokens and themes, then builds compressed `.css` theme files (without source map) for vanilla integration.
It generates design tokens and themes, then concurrently executes multiple step:

- generating compressed `.css` theme files (without source map) for vanilla integration
- generating ESM compiled `.js` from `.ts` files with `tsc` and `tsconfig.json`

## Publish new version

Expand Down
23 changes: 23 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// https://jestjs.io/docs/en/configuration.html

export default {
collectCoverageFrom: [
'**/*.ts',
'!**/dist/**/*', // distribution files
'!**/index.ts', // index files
],
coverageDirectory: '../coverage',
coverageThreshold: {
global: {
branches: 100,
functions: 100,
lines: 100,
statements: 100,
},
},
preset: 'ts-jest',
rootDir: 'packages',
testEnvironment: 'jsdom',
testMatch: ['**/*.spec.ts'],
verbose: true,
};
Loading

0 comments on commit ff7983e

Please sign in to comment.