Skip to content

Commit

Permalink
chore: update devDependencies.
Browse files Browse the repository at this point in the history
  • Loading branch information
jaywcjlove committed May 17, 2021
1 parent a6d062f commit bb961d8
Show file tree
Hide file tree
Showing 11 changed files with 1,222 additions and 957 deletions.
34 changes: 12 additions & 22 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,27 +7,17 @@ jobs:
build-deploy:
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@master
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: '14'

- name: Setup Node
uses: actions/setup-node@v1
with:
node-version: '10.x'
- run: npm install
- run: npm run create:html
- run: npm run create:ast

# - name: Cache dependencies
# uses: actions/cache@v1
# with:
# path: ~/.npm
# key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
# restore-keys: |
# ${{ runner.os }}-node-

- run: npm install
- run: npm run start

- name: Build and Deploy
uses: peaceiris/[email protected]
env:
ACTIONS_DEPLOY_KEY: ${{ secrets.ACTIONS_DEPLOY_KEY }}
PUBLISH_BRANCH: gh-pages
PUBLISH_DIR: ./dist
- name: Deploy
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./dist
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
node_modules/
dist
dist/*.html
dist/*.json
npm-debug.log*
package-lock.json

Expand Down
5 changes: 4 additions & 1 deletion README-zh.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
Awesome Mac
----
<!--rehype:style=font-size: 38px; border-bottom: 0; padding-bottom: 20px; padding-top: 26px;-->

[![jaywcjlove/sb](https://jaywcjlove.github.io/sb/ico/awesome.svg)](https://github.com/sindresorhus/awesome) [![jaywcjlove/sb](https://jaywcjlove.github.io/sb/lang/english.svg)](README.md) [![Gitter](https://jaywcjlove.github.io/sb/ico/gitter.svg)](https://gitter.im/awesome-mac/en?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=body_badge) [![SegmentFault](https://jaywcjlove.github.io/sb/ico/segmentfault.svg)](https://segmentfault.com/g/1570000010622746) [![](https://jaywcjlove.github.io/sb/ico/weibo.svg)](http://weibo.com/pc175) [![Backers on Open Collective](https://opencollective.com/awesome-mac/backers/badge.svg)](#backers) [![Sponsors on Open Collective](https://opencollective.com/awesome-mac/sponsors/badge.svg)](#sponsors)

Expand Down Expand Up @@ -77,7 +78,7 @@ Awesome Mac
- [Sponsors](#sponsors)
- [License](#license)


<!--start-->

## 开发者工具

Expand Down Expand Up @@ -968,6 +969,8 @@ Awesome Mac
* 威锋网:~~`https://bbs.feng.com/forum.php?mod=forumdisplay&fid=19&page=`~~
* MAC萌新网:~~`https://www.macxin.com`~~

<!--end-->

**[⬆ 返回顶部](#目录)**


Expand Down
13 changes: 9 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
Awesome Mac
----
<!--rehype:style=font-size: 38px; border-bottom: 0; padding-bottom: 20px; padding-top: 26px;-->

[![jaywcjlove/sb](https://jaywcjlove.github.io/sb/ico/awesome.svg)](https://github.com/sindresorhus/awesome) [![jaywcjlove/sb](https://jaywcjlove.github.io/sb/lang/chinese.svg)](README-zh.md) [![Gitter](https://jaywcjlove.github.io/sb/ico/gitter.svg)](https://gitter.im/awesome-mac/en?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=body_badge)
[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2Fjaywcjlove%2Fawesome-mac.svg?type=shield)](https://app.fossa.io/projects/git%2Bgithub.com%2Fjaywcjlove%2Fawesome-mac?ref=badge_shield)
Expand Down Expand Up @@ -93,6 +94,8 @@ Any comments, suggestions? [Let us know!](https://github.com/jaywcjlove/awesome-
- [Sponsors](#sponsors)
- [License](#license)

<!--start-->

## Reading and Writing Tools

*Applications to edit text, I suggest the open-source editors*
Expand Down Expand Up @@ -1001,10 +1004,7 @@ If you come across websites offering pirated software or cracks, please post [HE

**[⬆ back to top](#contents)**

[OSS Icon]: https://jaywcjlove.github.io/sb/ico/min-oss.svg "Open Source Software"
[Freeware Icon]: https://jaywcjlove.github.io/sb/ico/min-free.svg "Freeware"
[app-store Icon]: https://jaywcjlove.github.io/sb/ico/min-app-store.svg "App Store Software"
[awesome-list Icon]: https://jaywcjlove.github.io/sb/ico/min-awesome.svg "Awesome List"
<!--end-->

## Contributors

Expand All @@ -1031,3 +1031,8 @@ Support this project by becoming a sponsor. Your logo will show up here with a l
[![Creative Commons License](http://i.creativecommons.org/l/by/4.0/88x31.png)](https://creativecommons.org/licenses/by/4.0/)

This work is licensed under a [Creative Commons Attribution 4.0 International License](http://creativecommons.org/licenses/by/4.0/).

[OSS Icon]: https://jaywcjlove.github.io/sb/ico/min-oss.svg "Open Source Software"
[Freeware Icon]: https://jaywcjlove.github.io/sb/ico/min-free.svg "Freeware"
[app-store Icon]: https://jaywcjlove.github.io/sb/ico/min-app-store.svg "App Store Software"
[awesome-list Icon]: https://jaywcjlove.github.io/sb/ico/min-awesome.svg "Awesome List"
135 changes: 135 additions & 0 deletions build/ast.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
import { toVFile } from 'to-vfile'
import remark from 'remark'
import gfm from 'remark-gfm'
import FS from 'fs-extra'

const getHeadingText = (arr = [], title = '') => {
arr.forEach(child => {
title += child.value
if (child.children && Array.isArray(child.children)) {
title += getHeadingText(child.children, title)
}
})
return title;
}

const getSoftwareName = (obj, result = { title: '' }) => {
if (obj.value) {
result.title += obj.value
}
if (obj.url) {
result.url = obj.url
}
if (obj.type === 'delete') {
result.delete = true
}
if (obj.children && Array.isArray(obj.children)) {
obj.children.forEach(child => {
result = getSoftwareName(child, result)
})
}
return result
}

const getIconDetail = (data, url = '') => {
if (data.type === 'imageReference' && data.identifier && /^(freeware\s+icon|oss\s+icon|app-store\s+icon|awesome-list\s+icon)/.test(data.identifier.toLocaleLowerCase())) {
let type = ''
if (/^(freeware\s+icon)/.test(data.identifier.toLocaleLowerCase())) {
type = 'freeware'
}
if (/^(oss\s+icon)/.test(data.identifier.toLocaleLowerCase())) {
type = 'oss'
}
if (/^(app-store\s+icon)/.test(data.identifier.toLocaleLowerCase())) {
type = 'app-store'
}
if (/^(awesome-list\s+icon)/.test(data.identifier.toLocaleLowerCase())) {
type = 'awesome-list'
}
return { type, url }
}
return false
}

/**
* ```markdown
* * [Atom](https://atom.io) - xxxxxxx. [![Open-Source Software][OSS Icon]](https://xxx) ![Freeware][Freeware Icon] [![Awesome List][awesome-list Icon]](https://xxx)
* ```
*/
const getMarkIcons = (arr = [], parent = {}) => {
let mark = { icons: [] }
if (arr && Array.isArray(arr) && arr[1] && arr[1].type === 'text' && /^([\s]+)?-\s/.test(arr[1].value)) {
mark = { ...mark, ...getSoftwareName(arr[0]) }
arr = arr.filter(child => {
const data = getIconDetail(child)
if (data) {
mark.icons.push(data)
return false
}
if (child.type === 'link' && child.children && Array.isArray(child.children)) {
const childArr = child.children.filter(d => getIconDetail(d))
if (childArr.length > 0) {
childArr.forEach((item) => {
mark.icons.push(getIconDetail(item, child.url))
})
return false
}
}
if (child.type === 'text' && child.value.replace(/\s/g, '') === '') {
return false
}
return true
});
}
return { children: [...arr], mark: { ...mark } }
}

const getMdToAST = (data = [], parent = {}) => {
data = data.map((child) => {
if (child.position) {
delete child.position
if (child.type === 'listItem') {
delete child.checked
delete child.spread;
}
if (child.type === 'paragraph' && parent.type === 'listItem') {
const result = getMarkIcons(child.children, child)
child = { ...child, ...result }
}
if (child.type === 'heading') {
child.value = getHeadingText(child.children)
delete child.children
}
}
if (child.children && Array.isArray(child.children)) {
child.children = getMdToAST(child.children, child)
}
return child
})
return data
}

remark()
.use(gfm)
.use(() => (tree) => {
const startIndex = tree.children.findIndex(item => item.type === 'html' && /<!--start-->/.test(item.value))
const endIndex = tree.children.findIndex(item => item.type === 'html' && /<!--end-->/.test(item.value))
const data = tree.children.slice(startIndex + 1, endIndex)
const dataAST = getMdToAST([...data])
FS.outputJsonSync('./dist/awesome-mac.json', dataAST)
console.log(' create file: ./dist/awesome-mac.json')
})
.processSync(toVFile.readSync('README.md'))


remark()
.use(gfm)
.use(() => (tree) => {
const startIndex = tree.children.findIndex(item => item.type === 'html' && /<!--start-->/.test(item.value))
const endIndex = tree.children.findIndex(item => item.type === 'html' && /<!--end-->/.test(item.value))
const data = tree.children.slice(startIndex + 1, endIndex)
const dataAST = getMdToAST([...data])
FS.outputJsonSync('./dist/awesome-mac.zh.json', dataAST)
console.log(' create file: ./dist/awesome-mac.zh.json')
})
.processSync(toVFile.readSync('README-zh.md'))
Loading

0 comments on commit bb961d8

Please sign in to comment.