@shuyun-ep-team/scripts v3.0.1
@shuyun-ep-team/scripts
为项目提供相应的脚本,使其减少繁琐的配置。
安装
npm i @shuyun-ep-team/scripts或
yarn add @shuyun-ep-team/scriptsUsage
以下配置都只需要在各个项目 package.json 文件中的 scripts 添加对应的执行脚本即可;
比如校验国际化语言包:
{
"name": "@shuyun-ep-team/scripts",
"version": "0.0.1",
"description": "",
"main": "index.js",
"bin": {
"shuyun-scripts": "bin/index.js"
},
"scripts": {
"i18n": "shuyun-scripts i18n"
},
"dependencies": {
// ....
}
}i18n json 文件 key 值差异比对
用来校验国际化配置文案的 json key 值差异;首先我们看下最简单的配置:
shuyun-scripts i18n
# shuyun-scripts i18n 等同于 shuyun-scripts i18n --base i18n/zh-CN.json --dir i18ni18n 具有三个配置项分别为:
--base,-b : 基准 json 路径;默认值: i18n/zh-CN.json
--dir,-d : 待对比 json 文件夹路径;默认值:i18n
--igonre,-i : 忽略规则,此规则配置支持 glob 语法,glob 语言
例:
# 现有目录(结构如下), 比较 i18n 文件夹下 json 文案差异,但是忽略 ignore.json,对比标准为zh-CN.json
# └── i18n
# ├── en-US.json
# ├── ignore.json
# ├── index.ts
# └── zh-CN.json
shuyun-scripts i18n --base i18n/zh-CN.json --dir i18n --ignore ignore.json
# 运行结果
source/zh-CN.json : dest/en-US.json
+ Title: "",
- Footer: "undefined"
# 通过以上运行结果可得知,en-US.json 中缺少 "Title",同时还存在多余的 "Footer"// zh-CN.json
{
"Name": "张三",
"Title": "个人中心"
}// en-US.json
{
"Name": "zhang san",
"Footer": "footer"
}站点清单
生成项目站点清单,包含 当前 git 提交 id、时间、操作人、提交信息、发布消息等 。
# 获取相关信息,并且在 dist 目录中生成 site-manifest.json 文件
shuyun-scripts manifestmanifest 配置:
--dest : 生成文件地址;(仅支持生成 json )默认值为:dist/site-manifest.json
配置文件
项目 2.0.0 之后支持配置文件 .shuyun-scriptsrc.js,例如:
module.exports = {
jsonKeyDiff: {
base: 'i18n/zh-CN.json',
dir: 'i18n',
ignore: ['!i18n/ignort.json']
},
manifest: {
dest: 'dist/site-manifest.js',
append: {
platform: '应用端'
}
},
dependLint: {
root: '.'
},
entranceLint: {
entrance: 'dist/entrance.js',
rule: mod => mod.mount && mod.unmount
}
};5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago