♻️(tokens) expose default tokens in a lib and various config

This allow to use the default tokens from Typescript or Javascript file
of dependents repos. For instance this wîll be used by packages/react
to aggregate components tokens files.
This commit is contained in:
Nathan Vasse
2023-01-04 15:51:06 +01:00
committed by NathanVss
parent be2f220624
commit 67dd0048d0
11 changed files with 57 additions and 17 deletions

View File

@@ -1,2 +1,4 @@
node_modules node_modules
dist dist
src/bin/tests/assets
src/lib/cunningham-tokens.ts

View File

@@ -4,10 +4,7 @@
"custom" "custom"
], ],
"parserOptions": { "parserOptions": {
"project": [ "project": "./tsconfig.eslint.json"
"./tsconfig.json",
"./tsconfig.node.json"
]
}, },
"rules": { "rules": {
"no-console": "off", "no-console": "off",

View File

@@ -4,10 +4,17 @@
"version": "0.0.0", "version": "0.0.0",
"license": "MIT", "license": "MIT",
"bin": { "bin": {
"cunningham": "dist/bin/Main.js" "cunningham": "./dist/bin/Main.js"
}, },
"main": "./dist/lib/index.js",
"types": "./dist/lib/index.d.ts",
"exports": { "exports": {
"./default-tokens": "./dist/cunningham-tokens.css" "./default-tokens": "./dist/cunningham-tokens.css",
".": {
"require": "./dist/lib/index.js",
"import": "./dist/lib/index.js",
"types": "./dist/lib/index.d.ts"
}
}, },
"files": [ "files": [
"dist/" "dist/"
@@ -15,16 +22,18 @@
"scripts": { "scripts": {
"lint": "eslint . 'src/**/*.{ts,tsx}'", "lint": "eslint . 'src/**/*.{ts,tsx}'",
"dev": "nodemon --watch 'src/bin' --ext '*' --exec 'yarn build'", "dev": "nodemon --watch 'src/bin' --ext '*' --exec 'yarn build'",
"build": "tsc -p tsconfig.json && tsc-alias && cp src/bin/cunningham.dist.js dist/bin && chmod +x dist/bin/Main.js && yarn build-default-theme", "build-bin": "cd src/bin && tsc -p tsconfig.json && tsc-alias && cp ./cunningham.dist.js ../../dist/bin && chmod +x ../../dist/bin/Main.js",
"build-default-theme": "./dist/bin/Main.js -o dist -s html -g css,js", "build-lib": "cp dist/cunningham-tokens.ts src/lib && cd src/lib && tsc -p tsconfig.json",
"test": "FORCE_COLOR=1 jest --verbose src/bin" "build": "yarn build-bin && yarn build-default-theme && yarn build-lib && cd ../.. && ln -sf ../../packages/tokens/dist/bin/Main.js node_modules/.bin/cunningham",
"build-default-theme": "./dist/bin/Main.js -o dist -s html -g css,js,ts",
"test": "FORCE_COLOR=1 jest --runInBand --verbose src"
}, },
"dependencies": { "dependencies": {
"chalk": "4.1.2", "chalk": "4.1.2",
"commander": "9.4.1", "commander": "9.4.1",
"deepmerge": "4.2.2", "deepmerge": "4.2.2",
"figlet": "1.5.2", "figlet": "1.5.2",
"tsc-alias": "^1.8.2" "ts-node": "10.9.1"
}, },
"devDependencies": { "devDependencies": {
"@types/figlet": "1.5.5", "@types/figlet": "1.5.5",
@@ -35,7 +44,7 @@
"nodemon": "2.0.20", "nodemon": "2.0.20",
"prettier": "2.8.1", "prettier": "2.8.1",
"ts-jest": "29.0.3", "ts-jest": "29.0.3",
"ts-node": "10.9.1", "tsc-alias": "1.8.2",
"typescript": "4.9.4" "typescript": "4.9.4"
}, },
"engines": { "engines": {

View File

@@ -1,7 +1,8 @@
module.exports = { module.exports = {
theme: { theme: {
colors: { colors: {
primary: "#055FD2", primary: "#002d7f",
"primary-gradient": "linear-gradient(90deg,#002d7f,#0069b3)",
secondary: "#DA0000", secondary: "#DA0000",
}, },
}, },

View File

@@ -0,0 +1,7 @@
export default {
theme: {
colors: {
primary: "typescript",
},
},
};

View File

@@ -1,14 +1,14 @@
{ {
"extends": "@openfun/typescript-configs/node.json", "extends": "@openfun/typescript-configs/node.json",
"include": [ "include": [
"./src/**/*" "**/*",
], ],
"compilerOptions": { "compilerOptions": {
"baseUrl": "./src/bin", "baseUrl": "./",
"paths": { "paths": {
"*": ["*"] "*": ["*"]
}, },
"resolveJsonModule": true, "resolveJsonModule": true,
"outDir": "./dist/bin", "outDir": "../../dist/bin",
} }
} }

View File

@@ -0,0 +1 @@
export const tokens = {"theme":{"colors":{"primary":"#002d7f","primary-gradient":"linear-gradient(90deg,#002d7f,#0069b3)","secondary":"#DA0000"}}};

View File

@@ -0,0 +1,4 @@
import { tokens } from "./cunningham-tokens";
export type DefaultTokens = typeof tokens;
export const defaultTokens = tokens;

View File

@@ -0,0 +1,11 @@
{
"extends": "@openfun/typescript-configs/node.json",
"include": [
"./*"
],
"compilerOptions": {
"baseUrl": "./",
"outDir": "../../dist/lib",
"declaration": true
}
}

View File

@@ -0,0 +1,6 @@
{
"include": [
"**/*.ts",
"**/*.js",
]
}

View File

@@ -1,3 +1,5 @@
{ {
"include": ["jest.config.ts"] "include": [
"./jest.config.ts"
]
} }