From 2b7fd7851e5a1e2f85b7fa01ae70b1dc250c8142 Mon Sep 17 00:00:00 2001 From: taoliujun Date: Wed, 24 Jan 2024 13:22:59 +0800 Subject: [PATCH 1/5] fix: develop --- packages/cli/README.md | 1 - packages/cli/src/index.ts | 2 +- packages/cli/src/log.ts | 2 +- packages/cli/src/preview.ts | 4 ++-- packages/parse/package.json | 1 + packages/preview/.gitignore | 3 ++- packages/preview/config/webpack.config.ts | 1 + packages/preview/package.json | 1 + pnpm-lock.yaml | 2 +- 9 files changed, 10 insertions(+), 7 deletions(-) delete mode 100644 packages/cli/README.md diff --git a/packages/cli/README.md b/packages/cli/README.md deleted file mode 100644 index a61e081..0000000 --- a/packages/cli/README.md +++ /dev/null @@ -1 +0,0 @@ -# svg-to-component \ No newline at end of file diff --git a/packages/cli/src/index.ts b/packages/cli/src/index.ts index e149cdb..c0a987d 100644 --- a/packages/cli/src/index.ts +++ b/packages/cli/src/index.ts @@ -5,7 +5,7 @@ import pkg from '../package.json'; const program = new Command(); -program.name('svg-to-component').description('svg file parse and preview.').version(pkg.version); +program.name(pkg.name).description(pkg.description).version(pkg.version); program.addCommand(commandParse); program.addCommand(commandPreview); diff --git a/packages/cli/src/log.ts b/packages/cli/src/log.ts index 4fb61b1..3a54656 100644 --- a/packages/cli/src/log.ts +++ b/packages/cli/src/log.ts @@ -1,6 +1,6 @@ import chalk from 'chalk'; -export const log = console.log; +export const { log } = console; export const outputMain = chalk.white; export const outputSecond = chalk.gray; export const outputSuccess = chalk.green; diff --git a/packages/cli/src/preview.ts b/packages/cli/src/preview.ts index 5da5bec..a07e6f4 100644 --- a/packages/cli/src/preview.ts +++ b/packages/cli/src/preview.ts @@ -1,9 +1,9 @@ import path from 'path'; import { Command } from 'commander'; import { packagePath as previewPackagePath, componentsPath } from 'svg-to-component.preview'; +import { spawn } from 'child_process'; import { log, outputMain } from './log'; import { generateComponentFiles } from './parse'; -import { spawn } from 'child_process'; const cwdPath = path.resolve(); @@ -22,7 +22,7 @@ const program = new Command('preview') log(outputMain(`> run ${previewPackagePath} server...`)); - const wp = spawn(`pnpm`, ['run', 'dev'], { + const wp = spawn(`pnpm`, ['run', 'start'], { cwd: previewPackagePath, stdio: 'inherit', }); diff --git a/packages/parse/package.json b/packages/parse/package.json index e7d23fc..2cf09b3 100644 --- a/packages/parse/package.json +++ b/packages/parse/package.json @@ -5,6 +5,7 @@ "node": "^20" }, "main": "./lib/index.js", + "types": "./lib/index.d.ts", "files": [ "lib", "/*.md", diff --git a/packages/preview/.gitignore b/packages/preview/.gitignore index 04e38ce..97e5ee3 100644 --- a/packages/preview/.gitignore +++ b/packages/preview/.gitignore @@ -1 +1,2 @@ -src/svgComponents/ \ No newline at end of file +src/svgComponents/ +script/lib/ \ No newline at end of file diff --git a/packages/preview/config/webpack.config.ts b/packages/preview/config/webpack.config.ts index 479cf2c..d1969c8 100644 --- a/packages/preview/config/webpack.config.ts +++ b/packages/preview/config/webpack.config.ts @@ -90,6 +90,7 @@ const webpackConfig = (): Configuration & { }, devServer: { ...devServer, + open: true, }, devtool: isWebpackDev ? 'eval-source-map' : false, module: { diff --git a/packages/preview/package.json b/packages/preview/package.json index 836d3c2..b21cf70 100644 --- a/packages/preview/package.json +++ b/packages/preview/package.json @@ -6,6 +6,7 @@ "pnpm": ">=8" }, "main": "./script/lib/index.js", + "types": "./script/lib/index.d.ts", "scripts": { "lint": "eslint --cache src", "lint:ts": "tsc --noEmit", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index f27da26..4c0b4ea 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -5191,7 +5191,7 @@ packages: dependencies: confusing-browser-globals: 1.0.11 eslint: 8.56.0 - eslint-plugin-import: 2.29.1(@typescript-eslint/parser@5.62.0)(eslint-import-resolver-typescript@2.7.1)(eslint@8.56.0) + eslint-plugin-import: 2.29.1(@typescript-eslint/parser@6.19.0)(eslint-import-resolver-typescript@3.6.1)(eslint@8.56.0) object.assign: 4.1.5 object.entries: 1.1.7 semver: 6.3.1 From 18264f843db34108a25bd59de9ed51f85f04d699 Mon Sep 17 00:00:00 2001 From: taoliujun Date: Wed, 24 Jan 2024 13:24:02 +0800 Subject: [PATCH 2/5] docs(changeset): feat: release 1.0 --- .changeset/eight-jokes-live.md | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 .changeset/eight-jokes-live.md diff --git a/.changeset/eight-jokes-live.md b/.changeset/eight-jokes-live.md new file mode 100644 index 0000000..a24de90 --- /dev/null +++ b/.changeset/eight-jokes-live.md @@ -0,0 +1,7 @@ +--- +'svg-to-component.preview': major +'svg-to-component.parse': major +'svg-to-component': major +--- + +feat: release 1.0 From a6ccf93c06bdbf172983d2e769c3dfa266901cf6 Mon Sep 17 00:00:00 2001 From: taoliujun Date: Wed, 24 Jan 2024 13:24:23 +0800 Subject: [PATCH 3/5] RELEASING: Releasing 3 package(s) Releases: svg-to-component.preview@1.0.0 svg-to-component.parse@1.0.0 svg-to-component@1.0.0 [skip ci] --- .changeset/eight-jokes-live.md | 7 ------- .changeset/hip-zoos-agree.md | 5 ----- .changeset/slimy-cobras-smash.md | 5 ----- packages/cli/CHANGELOG.md | 15 +++++++++++++++ packages/cli/package.json | 2 +- packages/parse/CHANGELOG.md | 11 +++++++++++ packages/parse/package.json | 2 +- packages/preview/CHANGELOG.md | 11 +++++++++++ packages/preview/package.json | 2 +- 9 files changed, 40 insertions(+), 20 deletions(-) delete mode 100644 .changeset/eight-jokes-live.md delete mode 100644 .changeset/hip-zoos-agree.md delete mode 100644 .changeset/slimy-cobras-smash.md create mode 100644 packages/cli/CHANGELOG.md create mode 100644 packages/parse/CHANGELOG.md create mode 100644 packages/preview/CHANGELOG.md diff --git a/.changeset/eight-jokes-live.md b/.changeset/eight-jokes-live.md deleted file mode 100644 index a24de90..0000000 --- a/.changeset/eight-jokes-live.md +++ /dev/null @@ -1,7 +0,0 @@ ---- -'svg-to-component.preview': major -'svg-to-component.parse': major -'svg-to-component': major ---- - -feat: release 1.0 diff --git a/.changeset/hip-zoos-agree.md b/.changeset/hip-zoos-agree.md deleted file mode 100644 index 83fe6c0..0000000 --- a/.changeset/hip-zoos-agree.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'svg-to-component.parse': minor ---- - -feat: beta1 diff --git a/.changeset/slimy-cobras-smash.md b/.changeset/slimy-cobras-smash.md deleted file mode 100644 index f991268..0000000 --- a/.changeset/slimy-cobras-smash.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'svg-to-component.preview': minor ---- - -feat: beta1 diff --git a/packages/cli/CHANGELOG.md b/packages/cli/CHANGELOG.md new file mode 100644 index 0000000..b4f189a --- /dev/null +++ b/packages/cli/CHANGELOG.md @@ -0,0 +1,15 @@ +# svg-to-component + +## 1.0.0 + +### Major Changes + +- 337b0c5: feat: release 1.0 + +### Patch Changes + +- Updated dependencies [337b0c5] +- Updated dependencies [688affa] +- Updated dependencies [b2f2ea5] + - svg-to-component.preview@1.0.0 + - svg-to-component.parse@1.0.0 diff --git a/packages/cli/package.json b/packages/cli/package.json index bfa750f..107ce18 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -1,6 +1,6 @@ { "name": "svg-to-component", - "version": "0.0.0", + "version": "1.0.0", "description": "parse svg files into react components, support dynamic colors and preview.", "keywords": [ "svg", diff --git a/packages/parse/CHANGELOG.md b/packages/parse/CHANGELOG.md new file mode 100644 index 0000000..6dda8be --- /dev/null +++ b/packages/parse/CHANGELOG.md @@ -0,0 +1,11 @@ +# svg-to-component.parse + +## 1.0.0 + +### Major Changes + +- 337b0c5: feat: release 1.0 + +### Minor Changes + +- 688affa: feat: beta1 diff --git a/packages/parse/package.json b/packages/parse/package.json index 2cf09b3..aa2eb00 100644 --- a/packages/parse/package.json +++ b/packages/parse/package.json @@ -1,6 +1,6 @@ { "name": "svg-to-component.parse", - "version": "0.0.0", + "version": "1.0.0", "engines": { "node": "^20" }, diff --git a/packages/preview/CHANGELOG.md b/packages/preview/CHANGELOG.md new file mode 100644 index 0000000..3f273c6 --- /dev/null +++ b/packages/preview/CHANGELOG.md @@ -0,0 +1,11 @@ +# svg-to-component.preview + +## 1.0.0 + +### Major Changes + +- 337b0c5: feat: release 1.0 + +### Minor Changes + +- b2f2ea5: feat: beta1 diff --git a/packages/preview/package.json b/packages/preview/package.json index b21cf70..d488541 100644 --- a/packages/preview/package.json +++ b/packages/preview/package.json @@ -1,6 +1,6 @@ { "name": "svg-to-component.preview", - "version": "0.0.0", + "version": "1.0.0", "engines": { "node": "^20", "pnpm": ">=8" From 8f0246d9040b9bad80ec5adb0ec6107df4f42c41 Mon Sep 17 00:00:00 2001 From: taoliujun Date: Wed, 24 Jan 2024 13:38:42 +0800 Subject: [PATCH 4/5] chore: add release action --- .github/workflows/check-pull-request.yml | 2 +- .github/workflows/release.yml | 34 ++++++++++++++++++++++++ 2 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/check-pull-request.yml b/.github/workflows/check-pull-request.yml index c039fa3..aef68d8 100644 --- a/.github/workflows/check-pull-request.yml +++ b/.github/workflows/check-pull-request.yml @@ -22,7 +22,7 @@ jobs: run: echo "result=$(TZ=Asia/Shanghai date)" >> "$GITHUB_OUTPUT" - name: Create or update a comment - uses: taoliujun/action-unique-comment@v1 + uses: taoliujun/action-unique-comment@master with: uniqueIdentifier: ${{ github.workflow }} body: | diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..dcc5d87 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,34 @@ +name: release +run-name: '${{github.workflow}}' +on: workflow_dispatch + +jobs: + release: + runs-on: ubuntu-latest + steps: + - name: checkout + uses: actions/checkout@v4 + + - name: init pnpm + uses: pnpm/action-setup@v2 + with: + version: 8 + + - name: init node + uses: actions/setup-node@v4 + with: + node-version: 20 + cache: 'pnpm' + cache-dependency-path: | + src/pnpm-lock.yaml + .github/actions/issue-to-hexo/pnpm-lock.yaml + + - name: install dependencies + run: pnpm install + + - name: build + run: pnpm run build + + - name: release + run: | + NPM_TOKEN=${{secrets.NPM_TOKEN}} pnpm run release:token From 1379f0ff4eca7b2c37eaad16ffb5ebb6391f1005 Mon Sep 17 00:00:00 2001 From: taoliujun Date: Wed, 24 Jan 2024 14:22:29 +0800 Subject: [PATCH 5/5] fix: v maybe undefined --- packages/preview/.eslintignore | 3 ++- .../index/components/Colors/components/ColorControl/index.tsx | 2 +- packages/preview/tsconfig.json | 1 + 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/preview/.eslintignore b/packages/preview/.eslintignore index d17d448..e410c7d 100644 --- a/packages/preview/.eslintignore +++ b/packages/preview/.eslintignore @@ -1 +1,2 @@ -script/ \ No newline at end of file +script/ +src/svgComponents \ No newline at end of file diff --git a/packages/preview/src/pages/index/components/Colors/components/ColorControl/index.tsx b/packages/preview/src/pages/index/components/Colors/components/ColorControl/index.tsx index af20e5e..92add44 100644 --- a/packages/preview/src/pages/index/components/Colors/components/ColorControl/index.tsx +++ b/packages/preview/src/pages/index/components/Colors/components/ColorControl/index.tsx @@ -136,7 +136,7 @@ const useActiveElement = () => { const styles = findElement .filter((v) => Boolean(v)) .map((v) => { - const { width, height, left, top } = v.getBoundingClientRect(); + const { width, height, left, top } = (v as HTMLElement).getBoundingClientRect(); return { width: `${width}px`, height: `${height}px`, diff --git a/packages/preview/tsconfig.json b/packages/preview/tsconfig.json index c0ed295..8518bd3 100644 --- a/packages/preview/tsconfig.json +++ b/packages/preview/tsconfig.json @@ -1,6 +1,7 @@ { "extends": "@tsconfig/create-react-app/tsconfig.json", "compilerOptions": { + "target": "ES2022", "baseUrl": ".", "paths": { "@/*": [