Skip to content

Commit 2669bb9

Browse files
authored
feat(style-dictionary): upgrade to v4 and esm [KHCP-12846] (#332)
* feat(style-dictionary): upgrade to v4 and esm * refactor: stylelint plugin * feat: switch to pnpm * fix: ci command * docs: change yarn to pnpm * chore: config options * feat: add type * fix: exports
1 parent 7e59416 commit 2669bb9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+2338
-8742
lines changed

.github/CODEOWNERS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@
44
# Allow Kongponents BOT to approve renovate updates
55
# These rules MUST remain at the bottom as the last entry
66
package.json @kongponents-bot @adamdehaven @jillztom @portikM
7-
yarn.lock @kongponents-bot @adamdehaven @jillztom @portikM
7+
pnpm-lock.yaml @kongponents-bot @Kong/team-core-ui
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
name: Setup PNPM with Dependencies
2+
description: Reusable composition of setup-node, cache, and pnpm install actions
3+
inputs:
4+
nodejs-version:
5+
description: 'Version of NodeJS to use (ex: 20.16.0)'
6+
default: '20.16.0'
7+
force-install:
8+
description: When 'true', pnpm install will be executed regardless of a cache hit
9+
required: false
10+
default: 'false'
11+
frozen-lockfile:
12+
description: When false, pnpm install will use the --no-frozen-lockfile flag
13+
required: false
14+
default: 'true'
15+
outputs:
16+
cache-hit:
17+
description: Whether or not there was a cache hit
18+
value: ${{ steps.dependency-cache.outputs.cache-hit }}
19+
runs:
20+
using: composite
21+
steps:
22+
23+
- name: get Node version
24+
id: node-version
25+
shell: bash
26+
run: |
27+
voltaNodeVersion=$(cat package.json|jq -r ".volta.node")
28+
if [[ $voltaNodeVersion == null ]]; then
29+
voltaNodeVersion="${{ inputs.nodejs-version }}"
30+
fi
31+
voltaPnpmVersion=$(cat package.json|jq -r ".volta.pnpm")
32+
if [[ $voltaPnpmVersion == null ]]; then
33+
voltaPnpmVersion="9.3.0"
34+
fi
35+
36+
echo "node-version=${voltaNodeVersion}">> $GITHUB_OUTPUT
37+
echo "pnpm-version=${voltaPnpmVersion}">> $GITHUB_OUTPUT
38+
39+
- name: Setup Node
40+
uses: actions/setup-node@v4
41+
with:
42+
node-version: ${{ steps.node-version.outputs.node-version }}
43+
44+
- name: Install PNPM
45+
shell: bash
46+
run: |
47+
npm i -g pnpm@${{ steps.node-version.outputs.pnpm-version }}
48+
pnpm --version
49+
50+
- name: Dependency Cache
51+
id: dependency-cache
52+
uses: actions/cache@v4
53+
with:
54+
path: '**/node_modules'
55+
key: pnpm-${{ steps.node-version.outputs.pnpm-version }}-${{ steps.node-version.outputs.node-version }}-${{ runner.os }}-${{ hashFiles('**/pnpm-lock.yaml') }}
56+
57+
- name: Install Dependencies
58+
if: ${{ inputs.force-install == 'true' || steps.dependency-cache.outputs.cache-hit != 'true' }}
59+
shell: bash
60+
run: pnpm i${{ inputs.frozen-lockfile == 'false' && ' --no-frozen-lockfile' || '' }}

.github/workflows/publish.yaml

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,11 @@ jobs:
2424
with:
2525
token: ${{ secrets.KONGPONENTS_BOT_PAT }}
2626

27-
- name: Use Node.js
28-
uses: actions/setup-node@v4
29-
with:
30-
node-version-file: '.nvmrc'
31-
32-
- name: Install dependencies
33-
run: yarn install --frozen-lockfile
27+
- name: Setup PNPM with Dependencies
28+
uses: ./.github/actions/setup-pnpm-with-dependencies/
3429

3530
- name: Build
36-
run: yarn build
31+
run: pnpm build
3732

3833
- name: Semantic Release
3934
uses: cycjimmy/semantic-release-action@v4

.github/workflows/test.yaml

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -34,19 +34,16 @@ jobs:
3434
with:
3535
fetch-depth: 0
3636

37-
- name: Use Node.js
38-
uses: actions/setup-node@v4
37+
- name: Setup PNPM with Dependencies
38+
uses: ./.github/actions/setup-pnpm-with-dependencies/
3939
with:
40-
node-version-file: '.nvmrc'
41-
42-
- name: Install dependencies
43-
run: yarn install --frozen-lockfile
40+
force-install: true
4441

4542
- name: Lint
46-
run: yarn lint
43+
run: pnpm lint
4744

4845
- name: Build style dictionary
49-
run: yarn build
46+
run: pnpm build
5047

5148
- name: Publish package preview
5249
id: package-preview
@@ -64,7 +61,7 @@ jobs:
6461
6562
echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > .npmrc
6663
67-
yarn version --prerelease --preid ${preid} --allow-branch ${{ github.head_ref }} --no-git-tag-version --yes --amend
64+
pnpm version prerelease --preid ${preid} --no-git-tag-version --yes --amend
6865
6966
package_version=$(jq -r ".version" package.json)
7067
package=@kong/design-tokens@"${package_version}"

.npmrc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
shamefully-hoist=true
2+
strict-peer-dependencies=false
3+
auto-install-peers=true
4+
side-effects-cache=false # Ensure the postinstall script of the lefthook package is executed and hooks are installed

README.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ The package also exports a JSON file of all tokens from `@kong/design-tokens/tok
160160
In your host project, install the package **only** as a `devDependency`:
161161

162162
```shell
163-
yarn add -D @kong/design-tokens
163+
pnpm add -D @kong/design-tokens
164164
```
165165

166166
#### Why a `devDependency`?
@@ -294,7 +294,7 @@ export default defineConfig({
294294
To get started, install the package dependencies
295295

296296
```sh
297-
yarn install --frozen-lockfile
297+
pnpm install
298298
```
299299

300300
### Token Requirements
@@ -357,7 +357,7 @@ This repository includes a Vue sandbox (see the `/sandbox` directory) to allow y
357357
To start the sandbox:
358358

359359
```sh
360-
yarn sandbox
360+
pnpm sandbox
361361
```
362362

363363
This command will simultaneously start the Vite dev server and initialize a watcher on the `/tokens` directory. If any files in the `/tokens` directory are modified, the sandbox will automatically run the build command to update the tokens and then restart the Vite dev server (simulating hot module reload).
@@ -370,18 +370,18 @@ Lint package files, and optionally auto-fix detected issues.
370370

371371
```sh
372372
# Lint only
373-
yarn lint
373+
pnpm lint
374374

375375
# Lint and fix
376-
yarn lint:fix
376+
pnpm lint:fix
377377
```
378378

379379
### Build for production
380380

381381
Utilize the `style-dictionary` CLI to build the token assets for production based on the configuration in `/config.js`.
382382

383383
```sh
384-
yarn build
384+
pnpm build
385385
```
386386

387387
If additional sub-directories (other than `dist/tokens`) are added to the `dist/` directory in `/config.js`, you will also need to create a new corresponding entry in the `package.json > exports` section to allow for importing into the host project without `dist/` in the path.
@@ -401,8 +401,8 @@ For example, if I want to add a new `my-feature` folder, I'd update the `exports
401401
1. Ensure you are on the `main` branch, then pull down the latest code by running `git checkout main && git pull origin main`
402402
2. Checkout a new branch for your changes with `git checkout -b {type}/{jira-ticket}-{description}` - as an example, `git checkout feat/khcp-1234-add-color-tokens`
403403
3. Add/edit the tokens in the `/tokens` directory as needed, ensuring to adhere to the [Token Requirements](#token-requirements)
404-
4. Before committing your changes, locally run `yarn lint` to ensure you do not have any linting errors. If you have errors, you can try running `yarn lint:fix` to resolve
405-
5. Commit your changes, adhering to [Conventional Commits](#committing-changes). To make this easier, you're encouraged to run `yarn commit` to help build your commit message
404+
4. Before committing your changes, locally run `pnpm lint` to ensure you do not have any linting errors. If you have errors, you can try running `pnpm lint:fix` to resolve
405+
5. Commit your changes, adhering to [Conventional Commits](#committing-changes). To make this easier, you're encouraged to run `pnpm commit` to help build your commit message
406406
6. Push your branch up to the remote with `git push origin {branch-name}`
407407
7. Open a pull request and request a review
408408

@@ -417,7 +417,7 @@ This repo uses [Conventional Commits](https://www.conventionalcommits.org/en/v1.
417417
It is **highly recommended** to use the following command in order to create your commits:
418418

419419
```sh
420-
yarn commit
420+
pnpm commit
421421
```
422422

423423
This will trigger the Commitizen interactive prompt for building your commit message.

0 commit comments

Comments
 (0)