Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use swc for tests and coverage #37

Merged
merged 3 commits into from
Sep 12, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ name: CI

on:
workflow_dispatch:
push:
branches: [master]
pull_request:
branches: [master]
push:
branches:
- main

jobs:
test:
Expand Down
26 changes: 26 additions & 0 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: 'Coverage'

on:
workflow_dispatch:
push:
branches:
- main

jobs:
coverage:
runs-on: ubuntu-latest

steps:
- name: Setup node
uses: volta-cli/action@v1
- uses: actions/checkout@v2
- run: yarn install
- run: yarn test
- name: coverage
uses: paambaati/codeclimate-action@v2.7.5
env:
CC_TEST_REPORTER_ID: ${{secrets.CC_TEST_REPORTER_ID}}
with:
coverageCommand: yarn coverage
coverageLocations: |
${{github.workspace}}/coverage/lcov.info:lcov
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@
.eslintcache
node_modules/
book/
coverage/
dist
16 changes: 16 additions & 0 deletions .swcrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"sourceMaps": true,
"jsc": {
"parser": {
"syntax": "typescript",
"tsx": false,
"decorators": false,
"dynamicImport": true
},
"target": "es2019",
"loose": true
},
"module": {
"type": "es6"
}
}
4 changes: 2 additions & 2 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
module.exports = {
testEnvironment: 'node',
transform: {
'^.+\\.ts$': 'esbuild-jest'
'^.+\\.ts$': '@swc/jest'
},
testPathIgnorePatterns: ['/node_modules/', '/dist/', '/types/'],
extensionsToTreatAsEsm: ['.ts'],
// see: https://github.com/mattphillips/jest-expect-message/issues/39
setupFilesAfterEnv: ['@alex_neo/jest-expect-message']
};
34 changes: 26 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@
"license": "MIT",
"author": "Thomas Gossmann",
"homepage": "https://gossi.github.io/theemo/",
"keywords": [
"figma",
"design tokens",
"automation",
"css"
],
"bugs": "https://github.com/gossi/theemo/issues",
"repository": {
"type": "git",
Expand All @@ -19,19 +25,23 @@
],
"scripts": {
"clean": "rm -rf dist",
"_dts": "tsc -d --declarationDir dist/types --outDir tmp/ src/index.ts; rm -rf tmp/",
"_esbuild": "yarn clean && node scripts/build.js",
"build": "yarn clean && rollup -c",
"start": "rollup -c -w",
"test": "jest --clearCache && jest",
"dts": "tsc -d --declarationDir dist/ --outDir tmp/ src/index.ts; rm -rf tmp/",
"start": "yarn build:rollup -w",
"build": "yarn clean && yarn build:rollup",
"build:rollup": "rollup -c",
"build:swc": "yarn swc src/ --out-dir dist/",
"test": "jest --clearCache && NODE_OPTIONS=--experimental-vm-modules jest",
"test:coverage": "yarn test --coverage=true",
"lint": "npm-run-all --aggregate-output --continue-on-error --parallel 'lint:!(fix)'",
"lint:fix": "npm-run-all --aggregate-output --continue-on-error --parallel lint:*:fix",
"lint:js": "eslint --ext ts,js src --cache",
"lint:js:fix": "eslint --ext ts,js src --fix",
"lint:types": "tsc --noEmit",
"api": "node scripts/make-docs.js",
"prepublishOnly": "yarn build",
"prepack": "yarn dts",
"release": "release-it",
"_esbuild": "yarn clean && node scripts/build.js",
"_vite:dev": "vite",
"_vite:build": "vite build"
},
Expand All @@ -40,10 +50,10 @@
},
"dependencies": {
"color": "^3.1.3",
"commander": "^8.0.0",
"commander": "^8.2.0",
"dotenv": "^10.0.0",
"esm": "3.2.25",
"figma-api": "^1.6.1",
"figma-api": "^1.7.0",
"lodash.isempty": "^4.4.0",
"node-fetch": "^2.6.1",
"style-dictionary": "^3.0.2"
Expand All @@ -52,10 +62,14 @@
"@alex_neo/jest-expect-message": "^1.0.5",
"@clark/eslint-config-node": "^2.2.0",
"@clark/eslint-config-node-typescript": "^2.2.0",
"@jest/globals": "^27.1.1",
"@microsoft/api-documenter": "^7.13.30",
"@microsoft/api-extractor": "^7.18.1",
"@rollup/plugin-json": "^4.1.0",
"@rollup/plugin-node-resolve": "^13.0.0",
"@swc/cli": "^0.1.49",
"@swc/core": "^1.2.85",
"@swc/jest": "^0.2.3",
"@types/color": "^3.0.2",
"@types/jest": "^26.0.24",
"@types/jest-expect-message": "^1.0.3",
Expand All @@ -64,11 +78,12 @@
"@types/node-fetch": "^2.5.11",
"@typescript-eslint/eslint-plugin": "^4.28.2",
"@typescript-eslint/parser": "^4.28.2",
"chokidar": "^3.5.2",
"esbuild": "^0.12.25",
"esbuild-jest": "^0.5.0",
"eslint": "7.30.0",
"eslint-plugin-prettier": "^3.4.0",
"jest": "^27.1.0",
"jest": "^27.1.1",
"jsonpath": "^1.1.1",
"mock-fs": "^5.0.0",
"npm-run-all": "^4.1.5",
Expand Down Expand Up @@ -97,5 +112,8 @@
"release": true,
"tokenRef": "GITHUB_AUTH"
}
},
"volta": {
"node": "14.17.6"
}
}
14 changes: 12 additions & 2 deletions src/generate/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,16 @@ import path from 'path';
import { requireFile } from '../utils';
import GenerateConfig, { SchemeConfig } from './config';

interface Package {
name: string;
keywords: string[];
theemo?: {
name: string;
colorSchemes?: string[];
file?: string;
};
}

export default class GenerateCommand {
private config: GenerateConfig;
private name: string;
Expand All @@ -15,7 +25,7 @@ export default class GenerateCommand {
}

private getThemeName() {
const data = requireFile('package.json');
const data = requireFile('package.json') as Package;
return data.theemo?.name ?? data.name;
}

Expand All @@ -33,7 +43,7 @@ export default class GenerateCommand {

// update package.json with color schemes
if (this.config.colorSchemes) {
const packageJson = requireFile('package.json');
const packageJson = requireFile('package.json') as Package;
if (!packageJson.theemo) {
packageJson.theemo = {
name: packageJson.name
Expand Down
5 changes: 3 additions & 2 deletions src/tools/unknown-tool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ import TokenCollection from '../token-collection';
import { ReaderTool, WriterTool, BuilderTool } from './tool';

export default class UnknownTool
implements ReaderTool, WriterTool, BuilderTool {
implements ReaderTool, WriterTool, BuilderTool
{
async read() {
const tokens = await new TokenCollection();
return tokens;
Expand All @@ -12,7 +13,7 @@ export default class UnknownTool
// void implementation
}

write(_name: string, _tokens: TokenCollection) {
write(_tokens: TokenCollection) {
// void implementation
}
}
6 changes: 6 additions & 0 deletions test/tools/figma/utils.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { jest } from '@jest/globals';

import FigmaReader from '../../../src/tools/figma/reader';
import TheemoPluginReferencer from '../../../src/tools/figma/referencers/theemo-plugin';
import moanaReferencesJson from '../../fixtures/hokulea/moana-references.json';
Expand All @@ -11,6 +13,8 @@ export function mockFigmaReaderReferences(
): void {
// eslint-disable-next-line dot-notation
const referencer = reader['referencer'] as TheemoPluginReferencer;
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
// eslint-disable-next-line dot-notation
referencer['load'] = jest.fn().mockReturnValue(references);
}
Expand All @@ -19,6 +23,8 @@ export function mockFigmaReaderPayload(
reader: FigmaReader,
payload: Record<string, unknown>
): void {
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
// eslint-disable-next-line no-param-reassign, dot-notation
reader['load'] = jest.fn().mockReturnValue(payload);
}
Expand Down
Loading