diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index fb263dc9ee..5c19b0d234 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -22,7 +22,7 @@ jobs: - name: pnpm uses: pnpm/action-setup@v4 with: - version: 9.15.0 + version: 10.18.3 - uses: actions/cache/restore@v4 name: Check for build cache @@ -95,7 +95,7 @@ jobs: - name: pnpm uses: pnpm/action-setup@v4 with: - version: 9.15.0 + version: 10.18.3 - name: Use Node 18 uses: actions/setup-node@v4 @@ -134,7 +134,7 @@ jobs: - name: pnpm uses: pnpm/action-setup@v4 with: - version: 9.15.0 + version: 10.18.3 - name: Use Node 18 uses: actions/setup-node@v4 @@ -182,7 +182,7 @@ jobs: - name: pnpm uses: pnpm/action-setup@v4 with: - version: 9.15.0 + version: 10.18.3 - name: Use Node 18 uses: actions/setup-node@v4 @@ -227,7 +227,7 @@ jobs: - name: pnpm uses: pnpm/action-setup@v4 with: - version: 9.15.0 + version: 10.18.3 - name: Use Node 18 uses: actions/setup-node@v4 diff --git a/.github/workflows/react17.yml b/.github/workflows/react17.yml index 08f461e59f..945f961179 100644 --- a/.github/workflows/react17.yml +++ b/.github/workflows/react17.yml @@ -21,7 +21,7 @@ jobs: - name: pnpm uses: pnpm/action-setup@v4 with: - version: 9.15.0 + version: 10.18.3 cache: false - uses: actions/cache/restore@v4 @@ -75,7 +75,7 @@ jobs: - name: Install pnpm uses: pnpm/action-setup@v4 with: - version: 9.15.0 + version: 10.18.3 cache: false - uses: actions/cache/restore@v4 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 7235f4b006..2b3ec4ef95 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -18,7 +18,7 @@ jobs: - name: pnpm uses: pnpm/action-setup@v4 with: - version: 9.15.0 + version: 10.18.3 # Needed following Github's transition from Node 16 to 20 - name: Install node-gyp @@ -95,7 +95,7 @@ jobs: - name: pnpm uses: pnpm/action-setup@v4 with: - version: 9.15.0 + version: 10.18.3 - name: Use Node 18 uses: actions/setup-node@v4 @@ -148,7 +148,7 @@ jobs: - name: pnpm uses: pnpm/action-setup@v4 with: - version: 9.15.0 + version: 10.18.3 - name: Use Node 18 uses: actions/setup-node@v4 @@ -209,7 +209,7 @@ jobs: - name: pnpm uses: pnpm/action-setup@v4 with: - version: 9.15.0 + version: 10.18.3 - name: Use Node 18 uses: actions/setup-node@v4 @@ -264,7 +264,7 @@ jobs: - name: pnpm uses: pnpm/action-setup@v4 with: - version: 9.15.0 + version: 10.18.3 # Needed following Github's transition from Node 16 to 20 - name: Install node-gyp @@ -309,7 +309,7 @@ jobs: - name: pnpm uses: pnpm/action-setup@v4 with: - version: 9.15.0 + version: 10.18.3 - name: Dispatch to Website repo uses: peter-evans/repository-dispatch@v2 diff --git a/.github/workflows/sizeDiff.yml b/.github/workflows/sizeDiff.yml index 2888119635..1e0a8722a8 100644 --- a/.github/workflows/sizeDiff.yml +++ b/.github/workflows/sizeDiff.yml @@ -14,7 +14,7 @@ jobs: - name: pnpm uses: pnpm/action-setup@v4 with: - version: 9.15.0 + version: 10.18.3 - name: Use Node.js 18 uses: actions/setup-node@v4 diff --git a/.tool-versions b/.tool-versions new file mode 100644 index 0000000000..dbb3005b7b --- /dev/null +++ b/.tool-versions @@ -0,0 +1,2 @@ +nodejs 18.20.8 +pnpm 10.18.3 diff --git a/README.md b/README.md index a92fe7cc8f..bc12657858 100644 --- a/README.md +++ b/README.md @@ -183,15 +183,18 @@ import Button from '@leafygreen-ui/button'; ### Setup -1. Node >= 18.0.0 required. +1. Install [`asdf`](https://asdf-vm.com/guide/getting-started.html) - via [homebrew](https://brew.sh/) with `brew install node` - - via [nodejs installer](https://nodejs.org/en/) +```zsh +brew install asdf; +echo 'export PATH="${ASDF_DATA_DIR:-$HOME/.asdf}/shims:$PATH"' >> ~/.zshrc +``` -2. Install PNPM >= 9.15.0. +2. Install Node & pnpm - [PNPM Installation documentation](https://pnpm.io/installation) +```zsh +asdf install +``` 3. Clone the repository. @@ -360,19 +363,6 @@ To publish a new pre-release version, pull the changes from `new-feature` into b When `new-feature` is merged into `main`, you can safely delete the `pre-release` branch -## Deploy gh-pages - -You can deploy a static build of our Storybook site to gh-pages from the `main` branch. - -1. First be sure you've built a static version of Storybook with the script: `build-storybook` -2. Then deploy to gh-pages: `pnpm release:site` - -### To deploy to your own mirror of leafygreen-ui - -1. Run `pnpm demo:site [your_github_username]`. -2. If you haven't built a static version of Storybook yet, you will be prompted to do so. -3. You will be asked for confirmation before Storybook is published. - ## License The source files in this repository are made available under the terms of the Apache License, version 2.0. diff --git a/package.json b/package.json index b53d3bc9c3..fbcba81d8d 100644 --- a/package.json +++ b/package.json @@ -6,8 +6,9 @@ "private": true, "engines": { "node": ">= 18.20.8", - "pnpm": ">= 9.15.0" + "pnpm": ">= 10.18.3" }, + "packageManager": "pnpm@10.18.3", "scripts": { "init": "pnpm install && pnpm build", "init:react17": "pnpm clean; npx node ./scripts/react17/init.mjs; pnpm run init", @@ -83,7 +84,11 @@ "caniuse-lite": "^1.0.30001585", "jackspeak": "2.1.1", "typescript": "$typescript" - } + }, + "onlyBuiltDependencies": [ + "core-js", + "esbuild" + ] }, "lg": { "scopes": { @@ -108,7 +113,5 @@ }, "bugs": { "url": "https://github.com/mongodb/leafygreen-ui/issues" - }, - "packageManager": "pnpm@9.15.0", - "typesVersions": {} + } } diff --git a/packages/icon/package.json b/packages/icon/package.json index 0da2c10947..757713bd8e 100644 --- a/packages/icon/package.json +++ b/packages/icon/package.json @@ -46,13 +46,13 @@ "@lg-tools/storybook-utils": "workspace:^", "@rollup/plugin-node-resolve": "15.1.0", "@svgr/core": "^5.3.1", - "@types/xml2json": "^0.11.0", "commander": "^11.0.0", + "fast-xml-parser": "^5.3.0", "fs-extra": "11.1.1", "p-queue": "^8.1.0", "rollup": "4.16.1", - "rollup-plugin-node-externals": "7.1.1", "ts-node": "^10.9.2", + "rollup-plugin-node-externals": "7.1.1", "xml2json": "^0.12.0" }, "gitHead": "dd71a2d404218ccec2e657df9c0263dc1c15b9e0", diff --git a/packages/icon/src/Icon.spec.tsx b/packages/icon/src/Icon.spec.tsx index cf6b302cb8..8d322abf35 100644 --- a/packages/icon/src/Icon.spec.tsx +++ b/packages/icon/src/Icon.spec.tsx @@ -1,9 +1,9 @@ import React from 'react'; import { render, screen } from '@testing-library/react'; +import { XMLParser } from 'fast-xml-parser'; import fs from 'fs'; import { axe } from 'jest-axe'; import path from 'path'; -import { toJson } from 'xml2json'; import { typeIs } from '@leafygreen-ui/lib'; @@ -106,8 +106,8 @@ describe('packages/Icon/glyphs/', () => { readonly [K in string]: string | SVGNodeObject; }; - //@ts-expect-error - const rootGlyphObject: SVGNodeObject = toJson(svg, { object: true }); + const parser = new XMLParser({ ignoreAttributes: false }); + const rootGlyphObject: SVGNodeObject = parser.parse(svg); function validateGlyphObject(obj: SVGNodeObject) { Object.keys(obj).forEach(key => { diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 14ac445c17..4e0662398d 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -2122,12 +2122,12 @@ importers: '@svgr/core': specifier: ^5.3.1 version: 5.5.0 - '@types/xml2json': - specifier: ^0.11.0 - version: 0.11.6 commander: specifier: ^11.0.0 version: 11.1.0 + fast-xml-parser: + specifier: ^5.3.0 + version: 5.3.0 fs-extra: specifier: 11.1.1 version: 11.1.1 @@ -4302,7 +4302,7 @@ importers: version: 2.1.0 babel-loader: specifier: 9.2.1 - version: 9.2.1(@babel/core@7.24.3)(webpack@5.88.0) + version: 9.2.1(@babel/core@7.28.0)(webpack@5.88.0) buffer: specifier: 6.0.3 version: 6.0.3 @@ -6904,9 +6904,6 @@ packages: '@types/uuid@9.0.8': resolution: {integrity: sha512-jg+97EGIcY9AGHJJRaaPVgetKDsrTgbRjQ5Msgjh/DQKEFl0DtyRr/VCOyD1T2R1MNeWPK/u7JoGhlDZnKBAfA==} - '@types/xml2json@0.11.6': - resolution: {integrity: sha512-OYZ5cB4zctk4JdK1MGdLmeBMdmg+/AClCUspQ6KtQ2vZLJkSpm0XWE9H0vCfCGlXvbqn9CBqIda2dXX2KAE/5w==} - '@types/yargs-parser@21.0.3': resolution: {integrity: sha512-I4q9QU9MQv4oEOz4tAHJtNz1cwuLxn2F3xcc2iV5WdqLPpUnj30aUuxt1mAxYTG+oe8CZMV/+6rU4S4gRDzqtQ==} @@ -8406,6 +8403,10 @@ packages: fast-uri@3.0.6: resolution: {integrity: sha512-Atfo14OibSv5wAp4VWNsFYE1AchQRTv9cBGWET4pZWHzYshFSS9NQI6I57rdKn9croWVMbYFbLhJ+yJvmZIIHw==} + fast-xml-parser@5.3.0: + resolution: {integrity: sha512-gkWGshjYcQCF+6qtlrqBqELqNqnt4CxruY6UVAWWnqb3DQ6qaNFEIKqzYep1XzHLM/QtrHVCxyPOtTk4LTQ7Aw==} + hasBin: true + fastq@1.19.1: resolution: {integrity: sha512-GwLTyxkCXjXbxqIhTsMI2Nui8huMPtnxg7krajPJAjnEG/iiOS7i+zCtWGZR9G0NBKbXKh6X9m9UIsYX/N6vvQ==} @@ -10947,6 +10948,9 @@ packages: resolution: {integrity: sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig==} engines: {node: '>=8'} + strnum@2.1.1: + resolution: {integrity: sha512-7ZvoFTiCnGxBtDqJ//Cu6fWtZtc7Y3x+QOirG15wztbdngGSkht27o2pyGWrVy0b4WAy3jbKmnoK6g5VlVNUUw==} + style-loader@3.3.4: resolution: {integrity: sha512-0WqXzrsMTyb8yjZJHDqwmnwRJvhALK9LfRtRc6B4UTWe8AijYLZYZ9thuJTZc2VfQWINADW/j+LiJnfy2RoC1w==} engines: {node: '>= 12.13.0'} @@ -15385,10 +15389,6 @@ snapshots: '@types/uuid@9.0.8': {} - '@types/xml2json@0.11.6': - dependencies: - '@types/node': 20.19.9 - '@types/yargs-parser@21.0.3': {} '@types/yargs@17.0.33': @@ -15939,9 +15939,9 @@ snapshots: transitivePeerDependencies: - supports-color - babel-loader@9.2.1(@babel/core@7.24.3)(webpack@5.88.0): + babel-loader@9.2.1(@babel/core@7.28.0)(webpack@5.88.0): dependencies: - '@babel/core': 7.24.3 + '@babel/core': 7.28.0 find-cache-dir: 4.0.0 schema-utils: 4.3.2 webpack: 5.88.0 @@ -17322,6 +17322,10 @@ snapshots: fast-uri@3.0.6: {} + fast-xml-parser@5.3.0: + dependencies: + strnum: 2.1.1 + fastq@1.19.1: dependencies: reusify: 1.1.0 @@ -20579,6 +20583,8 @@ snapshots: strip-json-comments@3.1.1: {} + strnum@2.1.1: {} + style-loader@3.3.4(webpack@5.88.0): dependencies: webpack: 5.88.0 diff --git a/scripts/nvm-to-asdf.sh b/scripts/nvm-to-asdf.sh new file mode 100755 index 0000000000..b522feb844 --- /dev/null +++ b/scripts/nvm-to-asdf.sh @@ -0,0 +1,62 @@ +#!/usr/bin/env bash + +# 1. Disable and clear corepack, +if command -v corepack >/dev/null 2>&1; then + echo "Disabling corepack" + corepack cache clean + corepack disable +fi + +# 1b Disable nvm +if grep -q 'export NVM_DIR="\$HOME/.nvm"' ~/.zshrc; then + echo "Disabling nvm in ~/.zshrc..." + awk ' + BEGIN { skip = 0 } + { + if ($0 ~ /export NVM_DIR="\$HOME\/\.nvm"/) { + skip = 1 + } + if (skip && $0 ~ /^$/) { + skip = 0 + } + if (skip && $0 !~ /^#/) { + print "#" $0 + } else { + print $0 + } + } + ' ~/.zshrc > ~/.zshrc.tmp && mv ~/.zshrc.tmp ~/.zshrc +fi + +# 1c Disable pnpm +if grep -q 'export PNPM_HOME=' ~/.zshrc; then + echo "Disabling PNPM in ~/.zshrc..." + awk ' + BEGIN { skip = 0 } + { + if ($0 ~ /export PNPM_HOME=/) { + skip = 1 + } + if (skip && $0 ~ /^$/) { + skip = 0 + } + if (skip && $0 !~ /^#/) { + print "#" $0 + } else { + print $0 + } + } + ' ~/.zshrc > ~/.zshrc.tmp && mv ~/.zshrc.tmp ~/.zshrc +fi + +# 2. Install ASDF (if not already installed) +if ! command -v asdf >/dev/null 2>&1; then + echo "Installing asdf" + brew install asdf + # ... and add to path + echo 'export PATH="${ASDF_DATA_DIR:-$HOME/.asdf}/shims:$PATH"' >> ~/.zshrc +fi + +# 3 Enable asdf +echo "Setting up asdf" +asdf install