From 1250f0d0332ee96e874774db060a79efcaef3421 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B1=9F=E5=A4=8F=E5=B0=A7?= <3446798488@qq.com> Date: Thu, 23 May 2024 19:35:11 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E5=8F=91=E7=89=88?= =?UTF-8?q?=E8=84=9A=E6=9C=AC=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/release.yml | 45 +++++++++++++------------- README.md | 4 +-- packages/font-sharp/package.json | 1 + packages/subsets/bin/cn-font-split.mjs | 38 +++++++++------------- packages/subsets/package.json | 2 +- 5 files changed, 43 insertions(+), 47 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 11332668..2bc343a2 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,27 +1,28 @@ name: release on: - push: - tags: - - '*' - workflow_dispatch: # 添加 workflow_dispatch 触发器 + push: + tags: + - '*' + workflow_dispatch: # 添加 workflow_dispatch 触发器 jobs: - publish: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - uses: actions/setup-node@v2 - with: - node-version: 18 - registry-url: 'https://registry.npmjs.org' - - run: npm install pnpm -g - - run: pnpm install --no-frozen-lockfile - - run: npm pkg set name=cn-font-split - working-directory: packages/subsets - - run: npm run prepublish - working-directory: packages/subsets - - run: npm publish --access public - working-directory: packages/subsets - env: - NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} + publish: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-node@v2 + with: + node-version: 18 + registry-url: 'https://registry.npmjs.org' + - run: npm install pnpm -g + - run: pnpm install --no-frozen-lockfile + - run: pnpm -C ./packages/font-sharp build + - run: npm pkg set name=cn-font-split + working-directory: packages/subsets + - run: npm run prepublish + working-directory: packages/subsets + - run: npm publish --access public + working-directory: packages/subsets + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} diff --git a/README.md b/README.md index 709e2cf2..a76632bb 100644 --- a/README.md +++ b/README.md @@ -68,7 +68,7 @@ npm install @konghayao/cn-font-split -g # 如果使用命令行,推荐全局 cn-font-split -i=../demo/public/SmileySans-Oblique.ttf -o=./temp # 参数与正常 js 操作是一样的,深层json则需要使用 . 来赋值 -cn-font-split -i=../demo/public/SmileySans-Oblique.ttf -o=./temp --renameOutputFont=[hash:10][ext] --css.fontWeight=700 +cn-font-split -i=../demo/public/SmileySans-Oblique.ttf -o=./temp --renameOutputFont='[hash:10][ext]' --css.fontWeight=700 # 显示输入参数说明,虽然会显示 typescript 类型。。。 cn-font-split -h @@ -82,7 +82,7 @@ import { fontSplit } from '@konghayao/cn-font-split'; // import { fontSplit } from "https://cdn.jsdelivr.net/npm/@konghayao/cn-font-split@4.8.3/dist/browser/index.js"; fontSplit({ - FontPath: './fonts/SourceHanSerifCN-Bold.ttf', // 部分 otf 文件会报错,最好使用 ttf 版本的字体 + FontPath: './fonts/SourceHanSerifCN-Bold.ttf', // 推荐使用 otf、ttf 字体 destFold: './build', chunkSize: 70 * 1024, // 如果需要的话,自己定制吧 testHTML: true, // 输出一份 html 报告文件 diff --git a/packages/font-sharp/package.json b/packages/font-sharp/package.json index 4eb69f79..621b87c4 100644 --- a/packages/font-sharp/package.json +++ b/packages/font-sharp/package.json @@ -9,6 +9,7 @@ "url": "https://github.com/KonghaYao/cn-font-split/tree/ts/packages/font-sharp" }, "scripts": { + "build": "tsc", "prepublish": "rm -r dist && tsc" }, "keywords": [ diff --git a/packages/subsets/bin/cn-font-split.mjs b/packages/subsets/bin/cn-font-split.mjs index f2943b79..1201fd68 100755 --- a/packages/subsets/bin/cn-font-split.mjs +++ b/packages/subsets/bin/cn-font-split.mjs @@ -2,43 +2,37 @@ import { fontSplit, VERSION_CN_FONT_SPLIT } from '../dist/index.js'; import fs from 'fs'; import mri from 'mri'; -import path from 'path'; const temp = mri(process.argv.slice(2), { alias: { - i: "FontPath", - input: "FontPath", - output: "destFold", - o: "destFold", - d: "destFold", - h: "help" - } + i: 'FontPath', + input: 'FontPath', + output: 'destFold', + o: 'destFold', + d: 'destFold', + h: 'help', + }, }); const input = {}; -const ensurePath = (pathArr, obj) => { - -} - Object.entries(temp).map(([k, v]) => { if (k.includes('.')) { - const paths = k.split('.') - let tempInput = input + const paths = k.split('.'); + let tempInput = input; paths.forEach((i, index) => { if (!tempInput[i]) { - tempInput[i] = {} + tempInput[i] = {}; } if (index === paths.length - 1) { - tempInput[i] = stringToValue(v) + tempInput[i] = stringToValue(v); } else { - tempInput = tempInput[i] + tempInput = tempInput[i]; } - }) + }); } else { - input[k] = stringToValue(v) + input[k] = stringToValue(v); } -}) +}); -console.log(input) if (input.help) { console.log( `//========== cn-font-split help ${VERSION_CN_FONT_SPLIT} ===========`, @@ -60,7 +54,7 @@ if (input.help) { } else { console.log(VERSION_CN_FONT_SPLIT); if (input.FontPath && input.destFold) { - fontSplit(input).catch(e => console.log('error !!!!!: ', e.message)) + fontSplit(input).catch((e) => console.log('error !!!!!: ', e.message)); } else { console.log('Error: -i or -o must be filled!'); } diff --git a/packages/subsets/package.json b/packages/subsets/package.json index 530373f5..1fb09397 100644 --- a/packages/subsets/package.json +++ b/packages/subsets/package.json @@ -1,6 +1,6 @@ { "name": "@konghayao/cn-font-split", - "version": "4.13.0", + "version": "4.14.0", "description": "中文 web font 切割工具", "main": "dist/index.js", "browser": "dist/browser/index.js",