Skip to content

Commit

Permalink
chore: add pre-release script (#7)
Browse files Browse the repository at this point in the history
  • Loading branch information
kagol authored Aug 16, 2024
1 parent 147c913 commit b47eb21
Show file tree
Hide file tree
Showing 8 changed files with 87 additions and 17 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ Write html:
Import style:

```css
@import '@opentiny/fluent-editor/dist/style.css'
@import '@opentiny/fluent-editor/style.css'
```

Initialize the FluentEditor editor:
Expand Down
2 changes: 1 addition & 1 deletion README.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ npm i @opentiny/fluent-editor
引入样式:

```css
@import '@opentiny/fluent-editor/dist/style.css'
@import '@opentiny/fluent-editor/style.css'
```

初始化 FluentEditor 编辑器:
Expand Down
2 changes: 1 addition & 1 deletion packages/docs/fluent-editor/.vitepress/theme/vars.css
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@
}

/* 隐藏 Playground 和全屏按钮 */
._example-tooltip_18ews_2:nth-child(1) svg {
.example-actions-playground, .example-actions-fullscreen {
display: none;
}
2 changes: 1 addition & 1 deletion packages/docs/fluent-editor/docs/quick-start.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ npm i @opentiny/fluent-editor
引入样式:

```css
@import '@opentiny/fluent-editor/dist/style.css'
@import '@opentiny/fluent-editor/style.css'
```

初始化 Fluent Editor 编辑器:
Expand Down
2 changes: 1 addition & 1 deletion packages/docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"preview": "vitepress preview fluent-editor"
},
"devDependencies": {
"@vitepress-code-preview/container": "^1.0.7",
"@vitepress-code-preview/container": "^1.0.8",
"@vitepress-code-preview/plugin": "^1.0.4",
"vite": "^2.3.0",
"vitepress": "^1.3.2"
Expand Down
15 changes: 7 additions & 8 deletions packages/fluent-editor/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@opentiny/fluent-editor",
"version": "3.17.1",
"version": "3.17.2",
"description": "A rich text editor based on Quill 2.0, which extends rich modules and formats on the basis of Quill. It's powerful and out-of-the-box.",
"homepage": "https://opentiny.github.io/fluent-editor/",
"keywords": [
Expand All @@ -23,24 +23,21 @@
"url": "https://github.com/opentiny/fluent-editor/issues"
},
"main": "src/index.ts",
"files": [
"dist/*"
],
"module": "src/index.ts",
"exports": {
".": {
"import": "./src/index.ts",
"require": "./src/index.ts"
},
"./dist/style.css": {
"import": "./dist/style.css",
"require": "./dist/style.css"
"./style.css": {
"import": "./style.css",
"require": "./style.css"
}
},
"scripts": {
"start": "vite build && vite",
"dev": "vite",
"build": "vite build",
"build": "vite build && node scripts/pre-release.js",
"test": "jest",
"format": "prettier './{src,test}/**/*.{js,ts,tsx,vue}' --write"
},
Expand All @@ -60,12 +57,14 @@
"@types/quill": "^2.0.9",
"@typescript-eslint/eslint-plugin": "^5.7.0",
"@typescript-eslint/parser": "^5.7.0",
"commander": "^6.2.0",
"eslint": "^8.5.0",
"jest": "^26.6.3",
"lint-staged": "^12.1.4",
"lodash-es": "^4.17.15",
"prettier": "^2.3.0",
"sass": "^1.47.0",
"shelljs": "^0.8.4",
"ts-jest": "^26.5.6",
"ts-node": "^9.1.1",
"typescript": "^4.2.4",
Expand Down
38 changes: 38 additions & 0 deletions packages/fluent-editor/scripts/pre-release.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
const path = require('path')
const shelljs = require('shelljs')
const program = require('commander')

shelljs.cp('-rf', 'package.json', 'dist')
const targetFile = path.resolve(__dirname, '../dist/package.json')
const packagejson = require(targetFile)
const currentVersion = packagejson.version
const versionArr = currentVersion.split('.')
const [mainVersion, subVersion, phaseVersion] = versionArr

// 默认版本号
const defaultVersion = `${mainVersion}.${subVersion}.${+phaseVersion+1}`

let newVersion = defaultVersion

// 从命令行参数中取版本号
program
.option('-v, --versions <type>', 'Add release version number', defaultVersion)

program.parse(process.argv)

if (program.versions) {
newVersion = program.versions
}

console.log('newVersion:', newVersion)

function preRelease() {
shelljs.sed('-i', `"version": "${currentVersion}"`, `"version": "${newVersion}"`, targetFile)
shelljs.sed('-i', `"main": "src/index.ts"`, `"main": "index.cjs.js"`, targetFile)
shelljs.sed('-i', `"module": "src/index.ts"`, `"module": "index.es.js"`, targetFile)
shelljs.sed('-i', `"import": "./src/index.ts"`, `"import": "./index.es.js"`, targetFile)
shelljs.sed('-i', `"require": "./src/index.ts"`, `"require": "./index.cjs.js"`, targetFile)
shelljs.cp('-rf', '../../README.md', 'dist')
}

preRelease()
41 changes: 37 additions & 4 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit b47eb21

Please sign in to comment.