Skip to content

Commit

Permalink
fix: 修复发版脚本错误
Browse files Browse the repository at this point in the history
  • Loading branch information
KonghaYao committed May 23, 2024
1 parent 99d527c commit 1250f0d
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 47 deletions.
45 changes: 23 additions & 22 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -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 }}
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -82,7 +82,7 @@ import { fontSplit } from '@konghayao/cn-font-split';
// import { fontSplit } from "https://cdn.jsdelivr.net/npm/@konghayao/[email protected]/dist/browser/index.js";

fontSplit({
FontPath: './fonts/SourceHanSerifCN-Bold.ttf', // 部分 otf 文件会报错,最好使用 ttf 版本的字体
FontPath: './fonts/SourceHanSerifCN-Bold.ttf', // 推荐使用 otfttf 字体
destFold: './build',
chunkSize: 70 * 1024, // 如果需要的话,自己定制吧
testHTML: true, // 输出一份 html 报告文件
Expand Down
1 change: 1 addition & 0 deletions packages/font-sharp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": [
Expand Down
38 changes: 16 additions & 22 deletions packages/subsets/bin/cn-font-split.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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} ===========`,
Expand All @@ -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!');
}
Expand Down
2 changes: 1 addition & 1 deletion packages/subsets/package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down

0 comments on commit 1250f0d

Please sign in to comment.