diff --git a/.dockerignore b/.dockerignore index 36a775ebc8..5f681d2c85 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,7 +1,9 @@ .git # dependencies +node_modules **/node_modules +npm-debug.log # we are using pnpm here **/package-lock.json @@ -17,5 +19,3 @@ dist/ coverage # storybook-static .reports - - diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6b7d05f3ea..035ca057cd 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -11,6 +11,9 @@ on: jobs: typecheck: runs-on: ubuntu-22.04 + env: + TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }} + TURBO_REMOTE_ONLY: true steps: - uses: actions/checkout@v4 # v4.1.4 - uses: pnpm/action-setup@v4.0.0 @@ -19,12 +22,15 @@ jobs: with: node-version: 20 cache: "pnpm" - - run: pnpm install - - run: pnpm run build - - run: pnpm install - - run: pnpm typecheck + - run: | + pnpm install + pnpm typecheck + lint: runs-on: ubuntu-22.04 + env: + TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }} + TURBO_REMOTE_ONLY: true steps: - uses: actions/checkout@v4 - uses: pnpm/action-setup@v4.0.0 @@ -33,12 +39,17 @@ jobs: with: node-version: 20 cache: "pnpm" - - run: pnpm install - - run: pnpm run build - - run: pnpm install - - run: pnpm run lint + - run: | + pnpm install + pnpm run build + pnpm run lint + + format: runs-on: ubuntu-22.04 + env: + TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }} + TURBO_REMOTE_ONLY: true steps: - uses: actions/checkout@v4 - uses: pnpm/action-setup@v4.0.0 @@ -47,12 +58,17 @@ jobs: with: node-version: 20 cache: "pnpm" - - run: pnpm install - - run: pnpm run build - - run: pnpm install - - run: pnpm run format:ci + - run: | + pnpm install + pnpm run build + pnpm run lint + pnpm run format:ci + test: runs-on: ubuntu-22.04 + env: + TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }} + TURBO_REMOTE_ONLY: true needs: [lint, typecheck, format] strategy: matrix: @@ -67,10 +83,10 @@ jobs: with: node-version: ${{ matrix.node }} cache: "pnpm" - - run: pnpm install - - run: pnpm run build - - run: pnpm install - - run: pnpm run test:unit:coverage + - run: | + pnpm install + pnpm run build + pnpm run test:unit:coverage - uses: codecov/codecov-action@v4.5.0 with: # files: packages/**/coverage/cobertura-coverage.xmls @@ -98,6 +114,9 @@ jobs: matrix: node: ["20"] runs-on: ubuntu-22.04 + env: + TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }} + TURBO_REMOTE_ONLY: true needs: [lint, typecheck, format] steps: - uses: actions/checkout@v4 # v4.1.4 @@ -106,13 +125,17 @@ jobs: uses: actions/setup-node@v4.0.3 with: node-version: ${{ matrix.node }} - - run: pnpm install - - run: pnpm run build + - run: | + pnpm install + pnpm run build build-examples: # This will build all projects in the examples folder, it assures that all examples are working strategy: matrix: node: ["20"] runs-on: ubuntu-22.04 + env: + TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }} + TURBO_REMOTE_ONLY: true needs: [lint, test, format] steps: - uses: actions/checkout@v4 # v4.1.4 @@ -121,7 +144,6 @@ jobs: uses: actions/setup-node@v4.0.3 with: node-version: ${{ matrix.node }} - - run: pnpm install - - run: pnpm build - - run: pnpm install - - run: pnpm run build:examples + - run: | + pnpm install + pnpm run build:examples diff --git a/.github/workflows/deploy-storybook.yml b/.github/workflows/deploy-storybook.yml index cdde1eae03..dbeca9f327 100644 --- a/.github/workflows/deploy-storybook.yml +++ b/.github/workflows/deploy-storybook.yml @@ -14,6 +14,8 @@ jobs: IMAGE_NAME: rg.fr-par.scw.cloud/ultraviolet/storybook DEPLOYMENT_NAME: "storybook" SCW_DNS: ${{ github.ref_name == 'main' && 'storybook.ultraviolet.scaleway.com' || '' }} + TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }} + TURBO_REMOTE_ONLY: true steps: - uses: actions/checkout@v4 - name: Inject slug/short variables diff --git a/.github/workflows/pull_request_title.yml b/.github/workflows/pull_request_title.yml index b360afb5ee..68898a6d1c 100644 --- a/.github/workflows/pull_request_title.yml +++ b/.github/workflows/pull_request_title.yml @@ -7,14 +7,14 @@ jobs: check-title: runs-on: ubuntu-22.04 steps: - - uses: actions/checkout@v4 # v4.1.4 + - uses: actions/checkout@v4 - uses: pnpm/action-setup@v4.0.0 - name: Use Node.js uses: actions/setup-node@v4.0.3 with: node-version: 20 cache: "pnpm" - - run: pnpm install + - run: pnpm install --prod - name: Check PR title env: TITLE: ${{ github.event.pull_request.title }} diff --git a/.github/workflows/size-limit.yml b/.github/workflows/size-limit.yml index b09265c144..a559b2e20f 100644 --- a/.github/workflows/size-limit.yml +++ b/.github/workflows/size-limit.yml @@ -15,6 +15,8 @@ jobs: uses: actions/setup-node@v4.0.3 with: node-version: ${{ matrix.node }} - - run: pnpm install - - run: pnpm run build - - run: pnpm run size:packages + - run: | + pnpm install + pnpm run size + env: + TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }} diff --git a/.gitignore b/.gitignore index 249ca39684..e67a454539 100644 --- a/.gitignore +++ b/.gitignore @@ -35,3 +35,10 @@ out #vite vite.config.ts.* vitest.config.ts.* + +# turbo +.turbo +!.turbo/config.json +examples/*/.turbo +packages/*/.turbo +tools/*/.turbo diff --git a/Dockerfile b/Dockerfile index 809ff66eea..5eae22d1cc 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,7 +5,7 @@ COPY . . RUN corepack enable RUN pnpm install --frozen-lockfile -RUN pnpm build:storybook:stats +RUN pnpm turbo storybook:build RUN pnpm add serve -w diff --git a/eslint.config.mjs b/eslint.config.mjs index ca5550693e..f0faa940fd 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -4,6 +4,7 @@ import { FlatCompat } from '@eslint/eslintrc' import scwEmotion from '@scaleway/eslint-config-react/emotion' import scwJavascript from '@scaleway/eslint-config-react/javascript' import scwTypescript from '@scaleway/eslint-config-react/typescript' +import turboConfig from 'eslint-config-turbo' import globals from 'globals' import path from 'node:path' import { fileURLToPath } from 'node:url' diff --git a/package.json b/package.json index 01305bf156..6fcdf88c39 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,7 @@ "examples/*", "utils/*" ], - "packageManager": "pnpm@9.4.0", + "packageManager": "pnpm@9.5.0", "engines": { "node": ">=18.x", "pnpm": ">=9.x" @@ -17,11 +17,13 @@ "linux" ], "scripts": { - "build": "pnpm --filter '@ultraviolet/*' recursive run build", - "build:example": "pnpm --filter '@examples/*' recursive run build", + "build": "turbo run build", + "size": "turbo run size", + "typecheck": "turbo run typecheck", + "build:examples": "turbo run build --filter '@examples/*' ", + "storybook:build": "STORYBOOK_ENVIRONMENT=production storybook build", + "storybook:build:stats": "pnpm turbo storybook:build -- --webpack-stats-json", "build:storybook": "pnpm run build && STORYBOOK_ENVIRONMENT=production storybook build", - "build:storybook:stats": "pnpm run build:storybook --webpack-stats-json", - "build:examples": "pnpm --filter '{examples/**}' recursive exec -- pnpm run build", "check:deps": "npx depcheck . --skip-missing=true --ignores='bin,eslint,vite,jest,husky,@commitlint/*,@babel/*,babel-*'", "commit": "npx git-cz -a --disable-emoji", "start": "STORYBOOK_ENVIRONMENT=development storybook dev -p 6006", @@ -31,16 +33,13 @@ "lint:fix": "pnpm run lint --fix", "lint": "eslint --report-unused-disable-directives --cache .", "prebuild": "pnpm --filter '@ultraviolet/*' recursive run prebuild", - "test:unit": "pnpm --filter '@ultraviolet/*' recursive run test:unit", - "test:unit:coverage": "pnpm --filter '@ultraviolet/*' recursive run test:unit:coverage", + "test:unit": "turbo test:unit --filter='@ultraviolet/*' ", + "test:unit:coverage": "turbo test:unit:coverage --filter='@ultraviolet/*' ", "prepare": "husky", - "size": "pnpm run build && size-limit", - "size:packages": "pnpm --filter '@ultraviolet/*' recursive run size", "tokens:update": "node ./scripts/figma-synchronise-tokens.mjs && pnpm run format packages/themes/src/themes/console", "release": "pnpm build && pnpm changeset publish", "svg": "npx svgo --pretty --multipass", "svg:all": "pnpm run svg -r -f .", - "typecheck": "pnpm --filter '@ultraviolet/*' recursive run typecheck", "illustrations:update": "BUCKET_NAME=ultraviolet BUCKET_REGION=fr-par node utils/illustrations/uploadIllustrations.js && pnpm format packages/illustrations/src/" }, "lint-staged": { @@ -68,20 +67,6 @@ "@commitlint/config-conventional" ] }, - "size-limit": [ - { - "path": [ - "packages/*/dist/**/*.js", - "!packages/illustrations", - "!packages/plus", - "!packages/icons" - ], - "limit": "500 kB", - "webpack": false, - "brotli": true, - "running": false - } - ], "pnpm": { "overrides": { "vite": "$vite" @@ -159,6 +144,7 @@ "emoji-toolkit": "8.0.0", "esbuild-plugin-browserslist": "0.13.0", "eslint": "9.6.0", + "eslint-config-turbo": "^2.0.6", "eslint-plugin-testing-library": "6.2.2", "expect": "29.7.0", "file-loader": "6.2.0", @@ -179,6 +165,7 @@ "size-limit": "11.1.4", "storybook": "8.1.11", "timekeeper": "2.3.1", + "turbo": "2.0.6", "typescript": "5.5.3", "vite": "5.3.3", "vitest": "1.6.0", diff --git a/packages/form/package.json b/packages/form/package.json index 2ef94c7594..93b1410cf8 100644 --- a/packages/form/package.json +++ b/packages/form/package.json @@ -12,7 +12,7 @@ "build:profile": "npx vite-bundle-visualizer -c vite.config.ts", "build": "vite build --config vite.config.ts && pnpm run type:generate", "prebuild": "shx rm -rf dist", - "size": "pnpm run build && size-limit", + "size": "size-limit", "test:unit:coverage": "pnpm test:unit --coverage", "test:unit": "LC_ALL=en_US.UTF-8 pnpm vitest --run --config vite.config.ts", "type:generate": "tsc --declaration -p tsconfig.build.json", diff --git a/packages/icons/package.json b/packages/icons/package.json index 214210e6c0..bec9f5539b 100644 --- a/packages/icons/package.json +++ b/packages/icons/package.json @@ -16,7 +16,7 @@ "build": "vite build --config vite.config.ts && pnpm run type:generate", "build:profile": "npx vite-bundle-visualizer -c vite.config.ts", "typecheck": "tsc --noEmit", - "size": "pnpm run build && size-limit" + "size": "size-limit" }, "keywords": [ "react", diff --git a/packages/illustrations/package.json b/packages/illustrations/package.json index 0e9f7602a6..f554502fcd 100644 --- a/packages/illustrations/package.json +++ b/packages/illustrations/package.json @@ -16,7 +16,7 @@ "build": "vite build --config vite.config.ts && pnpm run type:generate", "build:profile": "npx vite-bundle-visualizer -c vite.config.ts", "typecheck": "tsc --noEmit", - "size": "pnpm run build && size-limit", + "size": "size-limit", "test:unit": "LC_ALL=en_US.UTF-8 pnpm vitest --run --config vite.config.ts", "test:unit:coverage": "pnpm test:unit --coverage" }, diff --git a/packages/plus/package.json b/packages/plus/package.json index 26242e5e30..ecfb841826 100644 --- a/packages/plus/package.json +++ b/packages/plus/package.json @@ -16,7 +16,7 @@ "build": "vite build --config vite.config.ts && pnpm run type:generate", "build:profile": "npx vite-bundle-visualizer -c vite.config.ts", "typecheck": "tsc --noEmit", - "size": "pnpm run build && size-limit", + "size": "size-limit", "test:unit": "LC_ALL=en_US.UTF-8 pnpm vitest --run --config vite.config.ts", "test:unit:coverage": "pnpm test:unit --coverage" }, diff --git a/packages/ui/package.json b/packages/ui/package.json index 64a1cb540e..4e4c9d6bcc 100644 --- a/packages/ui/package.json +++ b/packages/ui/package.json @@ -16,7 +16,7 @@ "build": "vite build --config vite.config.ts && pnpm run type:generate", "build:profile": "npx vite-bundle-visualizer -c vite.config.ts", "typecheck": "tsc --noEmit", - "size": "pnpm run build && size-limit", + "size": "size-limit", "test:unit": "LC_ALL=en_US.UTF-8 pnpm vitest --run --config vite.config.ts", "test:unit:coverage": "pnpm test:unit --coverage" }, diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 0768a67a8c..2fb9a5f457 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -206,6 +206,9 @@ importers: eslint: specifier: 9.6.0 version: 9.6.0 + eslint-config-turbo: + specifier: ^2.0.6 + version: 2.0.6(eslint@9.6.0) eslint-plugin-testing-library: specifier: 6.2.2 version: 6.2.2(eslint@9.6.0)(typescript@5.5.3) @@ -266,6 +269,9 @@ importers: timekeeper: specifier: 2.3.1 version: 2.3.1 + turbo: + specifier: 2.0.6 + version: 2.0.6 typescript: specifier: 5.5.3 version: 5.5.3 @@ -4878,6 +4884,10 @@ packages: resolution: {integrity: sha512-GopVGCpVS1UKH75VKHGuQFqS1Gusej0z4FyQkPdwjil2gNIv+LNsqBlboOzpJFZKVT95GkCyWJbBSdFEFUWI2A==} engines: {node: '>=12'} + dotenv@16.0.3: + resolution: {integrity: sha512-7GO6HghkA5fYG9TYnNxi14/7K9f5occMlp3zXAuSxn7CKCxt9xbNWG7yF8hTCSUchlfWSe3uLmlPfigevRItzQ==} + engines: {node: '>=12'} + dotenv@16.4.5: resolution: {integrity: sha512-ZmdL2rui+eB2YwhsWzjInR8LldtZHGDoQ1ugH85ppHKwpUHL7j7rN0Ti9NCnGiQbhaZ11FpR+7ao1dNsmduNUg==} engines: {node: '>=12'} @@ -5077,6 +5087,11 @@ packages: peerDependencies: eslint: '>=7.0.0' + eslint-config-turbo@2.0.6: + resolution: {integrity: sha512-PkRjFnZUZWPcrYT4Xoi5OWOUtnn6xVGh88I6TsayiH4AQZuLs/MDmzfJRK+PiWIrI7Q7sbsVEQP+nUyyRE3uAw==} + peerDependencies: + eslint: '>6.6.0' + eslint-import-resolver-node@0.3.9: resolution: {integrity: sha512-WFj2isz22JahUv+B788TlO3N6zL3nNJGU8CcZbPZvVEkBPaJdCV4vy5wyghty5ROFbCRnm132v8BScu5/1BQ8g==} @@ -5147,6 +5162,11 @@ packages: peerDependencies: eslint: ^7.5.0 || ^8.0.0 + eslint-plugin-turbo@2.0.6: + resolution: {integrity: sha512-yGnpMvyBxI09ZrF5bGpaniBz57MiExTCsRnNxP+JnbMFD+xU3jG3ukRzehVol8LYNdC/G7E4HoH+x7OEpoSGAQ==} + peerDependencies: + eslint: '>6.6.0' + eslint-scope@5.1.1: resolution: {integrity: sha512-2NxwbF/hZ0KpepYN0cNbo+FN6XoK7GaHlQhgx/hIZl6Va0bF45RQOOwhLIy8lQDbuCiadSLCBnH2CFYquit5bw==} engines: {node: '>=8.0.0'} @@ -8468,6 +8488,40 @@ packages: peerDependencies: typescript: '>=2.8.0 || >= 3.2.0-dev || >= 3.3.0-dev || >= 3.4.0-dev || >= 3.5.0-dev || >= 3.6.0-dev || >= 3.6.0-beta || >= 3.7.0-dev || >= 3.7.0-beta' + turbo-darwin-64@2.0.6: + resolution: {integrity: sha512-XpgBwWj3Ggmz/gQVqXdMKXHC1iFPMDiuwugLwSzE7Ih0O13JuNtYZKhQnopvbDQnFQCeRq2Vsm5OTWabg/oB/g==} + cpu: [x64] + os: [darwin] + + turbo-darwin-arm64@2.0.6: + resolution: {integrity: sha512-RfeZYXIAkiA21E8lsvfptGTqz/256YD+eI1x37fedfvnHFWuIMFZGAOwJxtZc6QasQunDZ9TRRREbJNI68tkIw==} + cpu: [arm64] + os: [darwin] + + turbo-linux-64@2.0.6: + resolution: {integrity: sha512-92UDa0xNQQbx0HdSp9ag3YSS3xPdavhc7q9q9mxIAcqyjjD6VElA4Y85m4F/DDGE5SolCrvBz2sQhVmkOd6Caw==} + cpu: [x64] + os: [linux] + + turbo-linux-arm64@2.0.6: + resolution: {integrity: sha512-eQKu6utCVUkIH2kqOzD8OS6E0ba6COjWm6PRDTNCHQRljZW503ycaTUIdMOiJrVg1MkEjDyOReUg8s8D18aJ4Q==} + cpu: [arm64] + os: [linux] + + turbo-windows-64@2.0.6: + resolution: {integrity: sha512-+9u4EPrpoeHYCQ46dRcou9kbkSoelhOelHNcbs2d86D6ruYD/oIAHK9qgYK8LeARRz0jxhZIA/dWYdYsxJJWkw==} + cpu: [x64] + os: [win32] + + turbo-windows-arm64@2.0.6: + resolution: {integrity: sha512-rdrKL+p+EjtdDVg0wQ/7yTbzkIYrnb0Pw4IKcjsy3M0RqUM9UcEi67b94XOAyTa5a0GqJL1+tUj2ebsFGPgZbg==} + cpu: [arm64] + os: [win32] + + turbo@2.0.6: + resolution: {integrity: sha512-/Ftmxd5Mq//a9yMonvmwENNUN65jOVTwhhBPQjEtNZutYT9YKyzydFGLyVM1nzhpLWahQSMamRc/RDBv5EapzA==} + hasBin: true + type-check@0.4.0: resolution: {integrity: sha512-XleUoc9uwGXqjWwXaUTZAmzMcFZ5858QA2vvx1Ur5xIcixXIP+8LnFDgRplU30us6teqdlskFfu+ae4K79Ooew==} engines: {node: '>= 0.8.0'} @@ -14531,6 +14585,8 @@ snapshots: dotenv-expand@10.0.0: {} + dotenv@16.0.3: {} + dotenv@16.4.5: {} dotenv@8.6.0: {} @@ -14822,6 +14878,11 @@ snapshots: dependencies: eslint: 9.6.0 + eslint-config-turbo@2.0.6(eslint@9.6.0): + dependencies: + eslint: 9.6.0 + eslint-plugin-turbo: 2.0.6(eslint@9.6.0) + eslint-import-resolver-node@0.3.9: dependencies: debug: 3.2.7 @@ -14937,6 +14998,11 @@ snapshots: - supports-color - typescript + eslint-plugin-turbo@2.0.6(eslint@9.6.0): + dependencies: + dotenv: 16.0.3 + eslint: 9.6.0 + eslint-scope@5.1.1: dependencies: esrecurse: 4.3.0 @@ -18930,6 +18996,33 @@ snapshots: tslib: 1.14.1 typescript: 5.5.3 + turbo-darwin-64@2.0.6: + optional: true + + turbo-darwin-arm64@2.0.6: + optional: true + + turbo-linux-64@2.0.6: + optional: true + + turbo-linux-arm64@2.0.6: + optional: true + + turbo-windows-64@2.0.6: + optional: true + + turbo-windows-arm64@2.0.6: + optional: true + + turbo@2.0.6: + optionalDependencies: + turbo-darwin-64: 2.0.6 + turbo-darwin-arm64: 2.0.6 + turbo-linux-64: 2.0.6 + turbo-linux-arm64: 2.0.6 + turbo-windows-64: 2.0.6 + turbo-windows-arm64: 2.0.6 + type-check@0.4.0: dependencies: prelude-ls: 1.2.1 diff --git a/turbo.json b/turbo.json new file mode 100644 index 0000000000..25451fa0c9 --- /dev/null +++ b/turbo.json @@ -0,0 +1,46 @@ +{ + "$schema": "https://turbo.build/schema.json", + "globalDependencies": ["tsconfig.json"], + "ui": "stream", + "globalEnv": ["STORYBOOK_ENVIRONMENT", "ENVIRONMENT"], + "tasks": { + "//#format": {}, + "//#lint:fix": { + "cache": false + }, + "//#storybook:build": { + "dependsOn": ["^build"], + "passThroughEnv": ["STORYBOOK_ENVIRONMENT"] + }, + "//#storybook:build:stats": { + "dependsOn": ["^build"], + "passThroughEnv": ["STORYBOOK_ENVIRONMENT"] + }, + "build": { + "dependsOn": ["^build"], + "outputs": [ + "build/**", + "dist/**", + ".next/**", + "!.next/cache/**", + "out/**", + "storybook-static/**" + ] + }, + "size": { + "dependsOn": ["^build"] + }, + "typecheck": { + "dependsOn": ["^build"], + "inputs": ["**/*.{ts,tsx}"] + }, + "test:unit": { + "dependsOn": ["^build"], + "passThroughEnv": ["VITEST_*"] + }, + "test:unit:coverage": { + "dependsOn": ["^build"], + "passThroughEnv": ["VITEST_*"] + } + } +}