From 6a6a4099daf762183c1ec922521944181e1cac32 Mon Sep 17 00:00:00 2001 From: jorenbroekema Date: Thu, 14 Nov 2024 14:18:22 +0100 Subject: [PATCH 1/3] fix: prettier direct dependency --- .changeset/rich-cars-unite.md | 5 +++++ package-lock.json | 9 +++------ package.json | 6 ++---- 3 files changed, 10 insertions(+), 10 deletions(-) create mode 100644 .changeset/rich-cars-unite.md diff --git a/.changeset/rich-cars-unite.md b/.changeset/rich-cars-unite.md new file mode 100644 index 000000000..55b113437 --- /dev/null +++ b/.changeset/rich-cars-unite.md @@ -0,0 +1,5 @@ +--- +'style-dictionary': patch +--- + +Move prettier to dependencies since style-dictionary isn't really a prettier plugin and a direct dependency seems more accurate here. diff --git a/package-lock.json b/package-lock.json index 6e9bdf0b6..08be34963 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "style-dictionary", - "version": "4.1.4", + "version": "4.2.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "style-dictionary", - "version": "4.1.4", + "version": "4.2.0", "hasInstallScript": true, "license": "Apache-2.0", "dependencies": { @@ -21,6 +21,7 @@ "json5": "^2.2.2", "patch-package": "^8.0.0", "path-unified": "^0.1.0", + "prettier": "^3.0.0", "tinycolor2": "^1.6.0" }, "bin": { @@ -75,9 +76,6 @@ }, "engines": { "node": ">=18.0.0" - }, - "peerDependencies": { - "prettier": "3.x" } }, "node_modules/@75lb/deep-merge": { @@ -19435,7 +19433,6 @@ "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.3.3.tgz", "integrity": "sha512-i2tDNA0O5IrMO757lfrdQZCc2jPNDVntV0m/+4whiDfWaTKfMNgR7Qz0NAeGz/nRqF4m5/6CLzbP4/liHt12Ew==", "license": "MIT", - "peer": true, "bin": { "prettier": "bin/prettier.cjs" }, diff --git a/package.json b/package.json index 3c4af8415..6d1de0b21 100644 --- a/package.json +++ b/package.json @@ -112,7 +112,8 @@ "is-plain-obj": "^4.1.0", "json5": "^2.2.2", "patch-package": "^8.0.0", - "path-unified": "^0.1.0", + "path-unified": "^0.2.0", + "prettier": "^3.3.3", "tinycolor2": "^1.6.0" }, "devDependencies": { @@ -161,8 +162,5 @@ "unist-util-visit": "^5.0.0", "uuid": "^9.0.1", "yaml": "^2.3.4" - }, - "peerDependencies": { - "prettier": "3.x" } } From bf3ed0a179dce5b5eff1e8bc08ccb9d4c8a383d7 Mon Sep 17 00:00:00 2001 From: jorenbroekema Date: Thu, 14 Nov 2024 14:35:56 +0100 Subject: [PATCH 2/3] chore: upgrade path-unified, optimize imports --- __tests__/common/transforms.test.js | 3 +-- docs/src/components/sd-playground.ts | 6 +++--- lib/StyleDictionary.js | 3 +-- package-lock.json | 11 ++++++----- 4 files changed, 11 insertions(+), 12 deletions(-) diff --git a/__tests__/common/transforms.test.js b/__tests__/common/transforms.test.js index 7edeb8834..c699cc6f7 100644 --- a/__tests__/common/transforms.test.js +++ b/__tests__/common/transforms.test.js @@ -11,7 +11,6 @@ * and limitations under the License. */ import { expect } from 'chai'; -import { join } from 'path-unified'; import Color from 'tinycolor2'; import transforms, { isColor } from '../../lib/common/transforms.js'; @@ -1391,7 +1390,7 @@ describe('common', () => { {}, {}, ); - expect(value).to.equal(join('foo.json')); + expect(value).to.equal('foo.json'); }); }); }); diff --git a/docs/src/components/sd-playground.ts b/docs/src/components/sd-playground.ts index 80f1b4c41..63b826039 100644 --- a/docs/src/components/sd-playground.ts +++ b/docs/src/components/sd-playground.ts @@ -1,7 +1,7 @@ import StyleDictionary from 'style-dictionary'; import { Volume } from '@bundled-es-modules/memfs'; import { LitElement, html, css } from 'lit'; -import { posix as path } from 'path-unified'; +import { extname, join } from 'path-unified/posix'; import '@shoelace-style/shoelace/dist/components/radio-button/radio-button.js'; import '@shoelace-style/shoelace/dist/components/radio-group/radio-group.js'; import '@shoelace-style/shoelace/dist/components/select/select.js'; @@ -377,7 +377,7 @@ class SdPlayground extends LitElement { changeOutputs(filePath: string, changeCurrentFile = false) { this.output = JSON.stringify({ value: this.volume.readFileSync(filePath, 'utf-8'), - lang: path.extname(filePath).replace(/^\./g, ''), + lang: extname(filePath).replace(/^\./g, ''), }); // call the setter so the editor value updates to the new output selection if (this.currentFile === 'output' || changeCurrentFile) { @@ -389,7 +389,7 @@ class SdPlayground extends LitElement { traverseDir(dir = '/', files: string[] = []) { let _files = files; (this.volume.readdirSync(dir) as string[]).forEach((file: string) => { - const fullPath = path.join(dir, file); + const fullPath = join(dir, file); if (this.volume.lstatSync(fullPath).isDirectory()) { _files = [..._files, ...this.traverseDir(fullPath, _files)]; } else { diff --git a/lib/StyleDictionary.js b/lib/StyleDictionary.js index 3e5b977ee..fe8394331 100644 --- a/lib/StyleDictionary.js +++ b/lib/StyleDictionary.js @@ -12,10 +12,9 @@ */ import JSON5 from 'json5'; -import { extname } from 'path-unified'; +import { extname, dirname } from 'path-unified'; import { fs } from 'style-dictionary/fs'; import chalk from 'chalk'; -import { dirname } from 'path-unified'; import combineJSON from './utils/combineJSON.js'; import deepExtend from './utils/deepExtend.js'; diff --git a/package-lock.json b/package-lock.json index 08be34963..85d9fec0b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -20,8 +20,8 @@ "is-plain-obj": "^4.1.0", "json5": "^2.2.2", "patch-package": "^8.0.0", - "path-unified": "^0.1.0", - "prettier": "^3.0.0", + "path-unified": "^0.2.0", + "prettier": "^3.3.3", "tinycolor2": "^1.6.0" }, "bin": { @@ -19060,9 +19060,10 @@ } }, "node_modules/path-unified": { - "version": "0.1.0", - "resolved": "https://registry.npmjs.org/path-unified/-/path-unified-0.1.0.tgz", - "integrity": "sha512-/Oaz9ZJforrkmFrwkR/AcvjVsCAwGSJHO0X6O6ISj8YeFbATjIEBXLDcZfnK3MO4uvCBrJTdVIxdOc79PMqSdg==" + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/path-unified/-/path-unified-0.2.0.tgz", + "integrity": "sha512-MNKqvrKbbbb5p7XHXV6ZAsf/1f/yJQa13S/fcX0uua8ew58Tgc6jXV+16JyAbnR/clgCH+euKDxrF2STxMHdrg==", + "license": "MIT" }, "node_modules/path/node_modules/inherits": { "version": "2.0.3", From 64f636f7a1ecb2f3f2a774f2d5942a6e437a9efb Mon Sep 17 00:00:00 2001 From: jorenbroekema Date: Thu, 14 Nov 2024 14:51:12 +0100 Subject: [PATCH 3/3] chore: attempt to use treeshakeable entrypoints path-unified --- lib/resolve.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/resolve.js b/lib/resolve.js index bdf8bcd57..e21875d53 100644 --- a/lib/resolve.js +++ b/lib/resolve.js @@ -1,4 +1,5 @@ -import { posix, win32 } from 'path-unified'; +import { resolve as resolvePosix } from 'path-unified/posix'; +import { resolve as resolveWin32 } from 'path-unified/win32'; import { isNode } from './utils/isNode.js'; /** @@ -13,7 +14,7 @@ export const resolve = (path, customVolumeUsed = false) => { return path; } if (isNode && process?.platform === 'win32') { - return win32.resolve(path); + return resolveWin32(path); } - return posix.resolve(path); + return resolvePosix(path); };