Skip to content

Commit 515fbdc

Browse files
authored
Merge branch 'develop' into develop
2 parents db4a103 + 63b2535 commit 515fbdc

File tree

102 files changed

+40106
-11541
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

102 files changed

+40106
-11541
lines changed

.codesandbox/ci.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{
22
"sandboxes": ["2d17z"],
3-
"packages": [".", "packages/docsify-server-renderer"]
3+
"packages": [".", "packages/docsify-server-renderer"],
4+
"node": "16"
45
}

.eslintignore

+5-6
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
.git
2-
packages/docsify-server-renderer/build.js
3-
node_modules
2+
**/*.md
43
build
5-
server.js
4+
docs
65
lib
6+
node_modules
7+
packages/docsify-server-renderer/build.js
8+
server.js
79
themes
8-
build
9-
docs/
10-
**/*.md

.eslintrc.js

+24-10
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,28 @@
1+
const prettierConfig = require('./.prettierrc');
2+
13
module.exports = {
24
root: true,
3-
parser: 'babel-eslint',
5+
extends: [
6+
'eslint:recommended',
7+
'plugin:import/recommended',
8+
'plugin:prettier/recommended', // Must be last
9+
],
10+
parser: '@babel/eslint-parser',
411
parserOptions: {
512
sourceType: 'module',
613
ecmaVersion: 2019,
714
},
15+
plugins: ['prettier', 'import'],
816
env: {
917
browser: true,
10-
node: true,
1118
es6: true,
19+
node: true,
1220
},
13-
plugins: ['prettier', 'import'],
14-
extends: ['eslint:recommended', 'plugin:import/recommended'],
1521
settings: {
1622
'import/ignore': ['node_modules', '.json$'],
1723
},
1824
rules: {
19-
'prettier/prettier': ['error'],
2025
camelcase: ['warn'],
21-
'no-useless-escape': ['warn'],
2226
curly: ['error', 'all'],
2327
'dot-notation': ['error'],
2428
eqeqeq: ['error'],
@@ -33,9 +37,16 @@ module.exports = {
3337
'no-proto': ['error'],
3438
'no-return-assign': ['error'],
3539
'no-self-compare': ['error'],
36-
'no-shadow': ['warn'],
3740
'no-shadow-restricted-names': ['error'],
41+
'no-shadow': [
42+
'error',
43+
{
44+
allow: ['Events', 'Fetch', 'Lifecycle', 'Render', 'Router'],
45+
},
46+
],
47+
'no-unused-vars': ['error', { args: 'none' }],
3848
'no-useless-call': ['error'],
49+
'no-useless-escape': ['warn'],
3950
'no-var': ['error'],
4051
'no-void': ['error'],
4152
'no-with': ['error'],
@@ -46,18 +57,21 @@ module.exports = {
4657

4758
// Import rules
4859
// Search way how integrate with `lerna`
49-
'import/no-unresolved': 'off',
5060
'import/imports-first': ['error'],
5161
'import/newline-after-import': ['error'],
5262
'import/no-duplicates': ['error'],
5363
'import/no-mutable-exports': ['error'],
54-
'import/no-named-as-default': ['error'],
5564
'import/no-named-as-default-member': ['error'],
65+
'import/no-named-as-default': ['error'],
66+
'import/no-unresolved': 'off',
5667
'import/order': ['warn'],
68+
69+
// Prettier (Must be last)
70+
'prettier/prettier': ['warn', prettierConfig],
5771
},
5872
globals: {
59-
Docsify: 'writable',
6073
$docsify: 'writable',
74+
Docsify: 'writable',
6175
dom: 'writable',
6276
},
6377
};

.github/workflows/lint.yml

-30
This file was deleted.

.github/workflows/test.yml

+59-22
Original file line numberDiff line numberDiff line change
@@ -2,41 +2,78 @@ name: Build & Test
22

33
on:
44
push:
5-
branches:
6-
- master
7-
- develop
5+
branches: [master, develop]
86
pull_request:
9-
branches:
10-
- master
11-
- develop
7+
branches: [master, develop]
128

139
jobs:
14-
build:
10+
lint:
11+
runs-on: ubuntu-latest
12+
strategy:
13+
matrix:
14+
node-version: ['lts/*']
15+
steps:
16+
- uses: actions/checkout@v2
17+
- name: Setup Node.js ${{ matrix.node-version }}
18+
uses: actions/setup-node@v2
19+
with:
20+
node-version: ${{ matrix.node-version }}
21+
cache: 'npm'
22+
- name: Install dependencies
23+
run: npm ci --ignore-scripts
24+
- name: Build
25+
run: npm run build
26+
- name: Lint
27+
run: npm run lint
28+
29+
test-jest:
1530
runs-on: ${{ matrix.os }}
1631
strategy:
1732
fail-fast: false
1833
matrix:
19-
node-version: [12.x, 14.x]
34+
node-version: ['lts/*']
2035
os: ['macos-latest', 'ubuntu-latest', 'windows-latest']
36+
steps:
37+
- uses: actions/checkout@v2
38+
- name: Setup Node.js ${{ matrix.node-version }}
39+
uses: actions/setup-node@v2
40+
with:
41+
node-version: ${{ matrix.node-version }}
42+
cache: 'npm'
43+
- name: Install dependencies
44+
run: npm ci --ignore-scripts
45+
- name: Build
46+
run: npm run build
47+
- name: Unit Tests
48+
run: npm run test:unit -- --ci --runInBand
49+
- name: Integration Tests
50+
run: npm run test:integration -- --ci --runInBand
2151

52+
test-playwright:
53+
runs-on: ubuntu-latest
54+
strategy:
55+
matrix:
56+
node-version: ['lts/*']
2257
steps:
2358
- uses: actions/checkout@v2
24-
- name: Use Node.js ${{ matrix.node-version }}
25-
uses: actions/setup-node@v1
59+
- name: Setup Node.js ${{ matrix.node-version }}
60+
uses: actions/setup-node@v2
2661
with:
2762
node-version: ${{ matrix.node-version }}
28-
- name: bootstrap
29-
run: npm run bootstrap
30-
- name: unit tests
31-
run: npm run test:unit -- -ci --runInBand
32-
- name: integration tests
33-
run: npm run test:integration -- -ci --runInBand
34-
- uses: microsoft/playwright-github-action@v1
35-
- name: e2e tests
36-
run: npm run test:e2e -- --ci --runInBand
37-
- name: Upload artifacts (diff output)
63+
cache: 'npm'
64+
- name: Install dependencies
65+
run: npm ci --ignore-scripts
66+
- name: Build
67+
run: npm run build
68+
- name: Install Playwright
69+
run: npx playwright install --with-deps
70+
- name: E2E Tests (Playwright)
71+
run: npm run test:e2e
72+
- name: Store artifacts
3873
uses: actions/upload-artifact@v2
3974
if: failure()
4075
with:
41-
name: ${{ matrix.os }}-${{ matrix.node-version }}-diff-output
42-
path: ${{ github.workspace }}/test/**/__diff_output__/*
76+
name: ${{ matrix.os }}-${{ matrix.node-version }}-artifacts
77+
path: |
78+
_playwright-results/
79+
_playwright-report/

.gitignore

+6-5
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
*.log
21
.DS_Store
32
.idea
4-
__diff_output__
5-
lib/
6-
node_modules
7-
themes/
3+
*.log
4+
/_playwright-report
5+
/_playwright-results
6+
/lib
7+
/node_modules
8+
/themes
89

910
# exceptions
1011
!.gitkeep

.npmignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
.eslintignore
22
.eslintrc
3-
.github/
3+
.github
44
.gitignore
55
.travis.yml

.prettierrc.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
module.exports = {
2+
arrowParens: 'avoid',
23
singleQuote: true,
3-
trailingComma: 'es5',
44
};

.vscode/settings.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
{
2-
"editor.defaultFormatter": "esbenp.prettier-vscode"
2+
"editor.defaultFormatter": "esbenp.prettier-vscode",
3+
"cSpell.words": ["coverpage"]
34
}

README.md

+2-4
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,7 @@
1212
<a href="#backers"><img alt="Backers on Open Collective" src="https://opencollective.com/docsify/backers/badge.svg?style=flat-square"></a>
1313
<a href="#sponsors">
1414
<img alt="Sponsors on Open Collective" src="https://opencollective.com/docsify/sponsors/badge.svg?style=flat-square"></a>
15-
<a><img src="https://github.com/docsifyjs/docsify/workflows/Unit%20tests%20Suite/badge.svg?branch=develop&amp;event=push" alt="Unit tests Suite"></a>
16-
<a><img src="https://github.com/docsifyjs/docsify/workflows/Linting%20Checks/badge.svg?branch=develop&amp;event=push" alt="Linting Checks"></a>
17-
<a><img src="https://github.com/docsifyjs/docsify/workflows/Testing%20the%20e2e%20test%20suites/badge.svg?branch=develop&amp;event=push" alt="Testing the e2e test suites"></a>
15+
<a href="https://github.com/docsifyjs/docsify/actions/workflows/test.yml"><img src="https://github.com/docsifyjs/docsify/actions/workflows/test.yml/badge.svg" alt="Build & Test"></a>
1816
<a href="https://www.npmjs.com/package/docsify"><img alt="npm" src="https://img.shields.io/npm/v/docsify.svg?style=flat-square"></a>
1917
<a href="https://github.com/QingWei-Li/donate"><img alt="donate" src="https://img.shields.io/badge/%24-donate-ff69b4.svg?style=flat-square"></a>
2018
<a href="https://discord.gg/3NwKFyR"><img alt="Join Discord community and chat about Docsify" src="https://img.shields.io/discord/713647066802421792.svg?label=&logo=discord&logoColor=ffffff&color=7389D8&labelColor=6A7EC2&cacheSeconds=60"></a>
@@ -31,7 +29,7 @@
3129

3230
## Links
3331

34-
- [`develop` branch preview](https://docsifyjs.netlify.com/)
32+
- [`develop` branch preview](https://docsify-preview.vercel.app/)
3533
- [Documentation](https://docsify.js.org)
3634
- [CLI](https://github.com/docsifyjs/docsify-cli)
3735
- CDN: [UNPKG](https://unpkg.com/docsify/) | [jsDelivr](https://cdn.jsdelivr.net/npm/docsify/) | [cdnjs](https://cdnjs.com/libraries/docsify)

build/emoji.js

+109
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
const axios = require('axios');
2+
const fs = require('fs');
3+
const path = require('path');
4+
5+
const filePaths = {
6+
emojiMarkdown: path.resolve(process.cwd(), 'docs', 'emoji.md'),
7+
emojiJS: path.resolve(
8+
process.cwd(),
9+
'src',
10+
'core',
11+
'render',
12+
'emoji-data.js'
13+
),
14+
};
15+
16+
async function getEmojiData() {
17+
const emojiDataURL = 'https://api.github.com/emojis';
18+
19+
console.info(`- Fetching emoji data from ${emojiDataURL}`);
20+
21+
const response = await axios.get(emojiDataURL);
22+
const baseURL = Object.values(response.data)
23+
.find(url => /unicode\//)
24+
.split('unicode/')[0];
25+
const data = { ...response.data };
26+
27+
// Remove base URL from emoji URLs
28+
Object.entries(data).forEach(
29+
([key, value]) => (data[key] = value.replace(baseURL, ''))
30+
);
31+
32+
console.info(`- Retrieved ${Object.keys(data).length} emoji entries`);
33+
34+
return {
35+
baseURL,
36+
data,
37+
};
38+
}
39+
40+
function writeEmojiPage(emojiData) {
41+
const isExistingPage = fs.existsSync(filePaths.emojiMarkdown);
42+
const emojiPage =
43+
(isExistingPage && fs.readFileSync(filePaths.emojiMarkdown, 'utf8')) ||
44+
`<!-- START -->\n\n<!-- END -->`;
45+
const emojiRegEx = /(<!--\s*START.*-->\n)([\s\S]*)(\n<!--\s*END.*-->)/;
46+
const emojiMatch = emojiPage.match(emojiRegEx);
47+
const emojiMarkdownStart = emojiMatch[1].trim();
48+
const emojiMarkdown = emojiMatch[2].trim();
49+
const emojiMarkdownEnd = emojiMatch[3].trim();
50+
const newEmojiMarkdown = Object.keys(emojiData.data)
51+
.reduce(
52+
(preVal, curVal) =>
53+
(preVal += `:${curVal}: ` + '`' + `:${curVal}:` + '`' + '\n\n'),
54+
''
55+
)
56+
.trim();
57+
58+
if (emojiMarkdown !== newEmojiMarkdown) {
59+
const newEmojiPage = emojiPage.replace(
60+
emojiMatch[0],
61+
`${emojiMarkdownStart}\n\n${newEmojiMarkdown}\n\n${emojiMarkdownEnd}`
62+
);
63+
64+
fs.writeFileSync(filePaths.emojiMarkdown, newEmojiPage);
65+
66+
console.info(
67+
`- ${!isExistingPage ? 'Created' : 'Updated'}: ${filePaths.emojiMarkdown}`
68+
);
69+
} else {
70+
console.info(`- No changes: ${filePaths.emojiMarkdown}`);
71+
}
72+
}
73+
74+
function writeEmojiJS(emojiData) {
75+
const isExistingPage = fs.existsSync(filePaths.emojiJS);
76+
const emojiJS = isExistingPage && fs.readFileSync(filePaths.emojiJS, 'utf8');
77+
const newEmojiJS = [
78+
'/* eslint-disable */\n',
79+
'// =============================================================================',
80+
'// DO NOT EDIT: This file is auto-generated by an /build/emoji.js',
81+
'// =============================================================================\n',
82+
`export default ${JSON.stringify(emojiData, {}, 2)}`,
83+
].join('\n');
84+
85+
if (!emojiJS || emojiJS !== newEmojiJS) {
86+
fs.writeFileSync(filePaths.emojiJS, newEmojiJS);
87+
88+
console.info(
89+
`- ${!isExistingPage ? 'Created' : 'Updated'}: ${filePaths.emojiJS}`
90+
);
91+
} else {
92+
console.info(`- No changes: ${filePaths.emojiJS}`);
93+
}
94+
}
95+
96+
(async () => {
97+
console.info('Build emoji');
98+
99+
try {
100+
const emojiData = await getEmojiData();
101+
102+
if (emojiData) {
103+
writeEmojiPage(emojiData);
104+
writeEmojiJS(emojiData);
105+
}
106+
} catch (err) {
107+
console.warn(`- Error: ${err.message}`);
108+
}
109+
})();

0 commit comments

Comments
 (0)