Skip to content

Commit

Permalink
chore: apply our format to the whole code base
Browse files Browse the repository at this point in the history
  • Loading branch information
trusktr committed Jul 17, 2023
1 parent 5591849 commit 3bef45b
Show file tree
Hide file tree
Showing 20 changed files with 477 additions and 445 deletions.
8 changes: 4 additions & 4 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
version: 2
updates:
- package-ecosystem: npm # See documentation for possible values
directory: "/" # Location of package manifests
directory: '/' # Location of package manifests
open-pull-requests-limit: 10
schedule:
interval: "weekly"
- package-ecosystem: "github-actions"
directory: "/"
interval: 'weekly'
- package-ecosystem: 'github-actions'
directory: '/'
open-pull-requests-limit: 10
schedule:
interval: monthly
2 changes: 1 addition & 1 deletion .gitpod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ ports:
onOpen: ignore
vscode:
extensions:
- sysoev.language-stylus@1.11.0:xX39oruAJ5UQzTNVRdbBaQ==
- sysoev.language-stylus@1.11.0:xX39oruAJ5UQzTNVRdbBaQ==
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,12 @@ Move to [awesome-docsify](https://github.com/docsifyjs/awesome-docsify#showcase)

## Similar projects

| Project | Description |
| ------------------------------------------------ | ---------------------------------------- |
| [Docusaurus](https://docusaurus.io) | Docusaurus makes it easy to maintain Open Source documentation websites |
| [GitBook](https://www.gitbook.com) | Where technical teams document |
| [MkDocs](https://www.mkdocs.org) | Project documentation with Markdown |
| [VuePress](https://vuepress.vuejs.org) | Vue-powered Static Site Generator |
| Project | Description |
| -------------------------------------- | ----------------------------------------------------------------------- |
| [Docusaurus](https://docusaurus.io) | Docusaurus makes it easy to maintain Open Source documentation websites |
| [GitBook](https://www.gitbook.com) | Where technical teams document |
| [MkDocs](https://www.mkdocs.org) | Project documentation with Markdown |
| [VuePress](https://vuepress.vuejs.org) | Vue-powered Static Site Generator |

## Contributing

Expand Down
2 changes: 1 addition & 1 deletion SECURITY.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ If you believe you have found a security vulnerability in docsify, please report

**Please do not report security vulnerabilities through our public GitHub issues.**

Send email via :email: maintainers@docsifyjs.org to us.
Send email to us via :email: maintainers@docsifyjs.org.

Please include as much of the following information as possible to help us better understand the possible issue:

Expand Down
134 changes: 68 additions & 66 deletions build/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,83 +32,89 @@ async function build(opts) {
nodeResolve(),
replace({
__VERSION__: version,
})
}),
],
onwarn(message) {
if (message.code === 'UNRESOLVED_IMPORT') {
throw new Error(
`Could not resolve module ` +
message.source +
`. Try running 'npm install' or using rollup's 'external' option if this is an external dependency. ` +
`Module ${message.source} is imported in ${message.importer}`
)
message.source +
`. Try running 'npm install' or using rollup's 'external' option if this is an external dependency. ` +
`Module ${message.source} is imported in ${message.importer}`
);
}
}
},
})
.then(bundle => {
const dest = 'lib/' + (opts.output || opts.input)
const dest = 'lib/' + (opts.output || opts.input);

console.log(dest)
console.log(dest);
return bundle.write({
format: 'iife',
output: opts.globalName ? {name: opts.globalName} : {},
output: opts.globalName ? { name: opts.globalName } : {},
file: dest,
strict: false
})
})
strict: false,
});
});
}

async function buildCore() {
const promises = []
const promises = [];

promises.push(build({
input: 'src/core/index.js',
output: 'docsify.js',
}))
promises.push(
build({
input: 'src/core/index.js',
output: 'docsify.js',
})
);

if (isProd) {
promises.push(build({
input: 'src/core/index.js',
output: 'docsify.min.js',
plugins: [uglify()]
}))
promises.push(
build({
input: 'src/core/index.js',
output: 'docsify.min.js',
plugins: [uglify()],
})
);
}

await Promise.all(promises)
await Promise.all(promises);
}

async function buildAllPlugin() {
const plugins = [
{name: 'search', input: 'search/index.js'},
{name: 'ga', input: 'ga.js'},
{name: 'gtag', input: 'gtag.js'},
{name: 'matomo', input: 'matomo.js'},
{name: 'emoji', input: 'emoji.js'},
{name: 'external-script', input: 'external-script.js'},
{name: 'front-matter', input: 'front-matter/index.js'},
{name: 'zoom-image', input: 'zoom-image.js'},
{name: 'disqus', input: 'disqus.js'},
{name: 'gitalk', input: 'gitalk.js'}
]
{ name: 'search', input: 'search/index.js' },
{ name: 'ga', input: 'ga.js' },
{ name: 'gtag', input: 'gtag.js' },
{ name: 'matomo', input: 'matomo.js' },
{ name: 'emoji', input: 'emoji.js' },
{ name: 'external-script', input: 'external-script.js' },
{ name: 'front-matter', input: 'front-matter/index.js' },
{ name: 'zoom-image', input: 'zoom-image.js' },
{ name: 'disqus', input: 'disqus.js' },
{ name: 'gitalk', input: 'gitalk.js' },
];

const promises = plugins.map(item => {
return build({
input: 'src/plugins/' + item.input,
output: 'plugins/' + item.name + '.js'
})
})
output: 'plugins/' + item.name + '.js',
});
});

if (isProd) {
plugins.forEach(item => {
promises.push(build({
input: 'src/plugins/' + item.input,
output: 'plugins/' + item.name + '.min.js',
plugins: [uglify()]
}))
})
promises.push(
build({
input: 'src/plugins/' + item.input,
output: 'plugins/' + item.name + '.min.js',
plugins: [uglify()],
})
);
});
}

await Promise.all(promises)
await Promise.all(promises);
}

async function main() {
Expand All @@ -118,41 +124,37 @@ async function main() {
atomic: true,
awaitWriteFinish: {
stabilityThreshold: 1000,
pollInterval: 100
}
pollInterval: 100,
},
})
.on('change', p => {
console.log('[watch] ', p)
const dirs = p.split(path.sep)
console.log('[watch] ', p);
const dirs = p.split(path.sep);
if (dirs[1] === 'core') {
buildCore()
buildCore();
} else if (dirs[2]) {
const name = path.basename(dirs[2], '.js')
const name = path.basename(dirs[2], '.js');
const input = `src/plugins/${name}${
/\.js/.test(dirs[2]) ? '' : '/index'
}.js`
}.js`;

build({
input,
output: 'plugins/' + name + '.js'
})
output: 'plugins/' + name + '.js',
});
}
})
.on('ready', () => {
console.log('[start]')
buildCore()
buildAllPlugin()
})
console.log('[start]');
buildCore();
buildAllPlugin();
});
} else {
await Promise.all([
buildCore(),
buildAllPlugin()
])
await Promise.all([buildCore(), buildAllPlugin()]);
}
}

main().catch((e) => {
console.error(e)
process.exit(1)
})

main().catch(e => {
console.error(e);
process.exit(1);
});
77 changes: 39 additions & 38 deletions build/css.js
Original file line number Diff line number Diff line change
@@ -1,47 +1,48 @@
import fs from 'fs'
import path from 'path'
import {spawn} from 'child_process'
import fs from 'fs';
import path from 'path';
import { spawn } from 'child_process';

const relative = path => new URL(path, import.meta.url);
const args = process.argv.slice(2)
const args = process.argv.slice(2);
fs.readdir(relative('../src/themes'), (err, files) => {
if (err) {
console.error('err', err)
process.exit(1)
}
files.map(async (file) => {
if (/\.styl/g.test(file)) {
const stylusBin = ['node_modules', 'stylus', 'bin', 'stylus'].join(path.sep)
let cmdargs = [
stylusBin,
`src/themes/${file}`,
'-u',
'autoprefixer-stylus'
]
cmdargs = [...cmdargs, ...args]
if (err) {
console.error('err', err);
process.exit(1);
}
files.map(async file => {
if (/\.styl/g.test(file)) {
const stylusBin = ['node_modules', 'stylus', 'bin', 'stylus'].join(
path.sep
);
let cmdargs = [
stylusBin,
`src/themes/${file}`,
'-u',
'autoprefixer-stylus',
];
cmdargs = [...cmdargs, ...args];

const stylusCMD = spawn('node', cmdargs, { shell: true })
const stylusCMD = spawn('node', cmdargs, { shell: true });

stylusCMD.stdout.on('data', (data) => {
console.log(`[Stylus Build ] stdout: ${data}`);
});
stylusCMD.stdout.on('data', data => {
console.log(`[Stylus Build ] stdout: ${data}`);
});

stylusCMD.stderr.on('data', (data) => {
console.error(`[Stylus Build ] stderr: ${data}`);
});
stylusCMD.stderr.on('data', data => {
console.error(`[Stylus Build ] stderr: ${data}`);
});

stylusCMD.on('close', (code) => {
const message = `[Stylus Build ] child process exited with code ${code}`
stylusCMD.on('close', code => {
const message = `[Stylus Build ] child process exited with code ${code}`;

if (code !== 0) {
console.error(message);
process.exit(code)
}
console.log(message);
});
} else {
return
if (code !== 0) {
console.error(message);
process.exit(code);
}

})
})
console.log(message);
});
} else {
return;
}
});
});
25 changes: 14 additions & 11 deletions build/mincss.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
import cssnano from 'cssnano';
import path from 'path'
import fs from 'fs'
import path from 'path';
import fs from 'fs';

const files = fs.readdirSync(path.resolve('lib/themes'))
const files = fs.readdirSync(path.resolve('lib/themes'));

files.forEach(file => {
file = path.resolve('lib/themes', file)
cssnano.process(fs.readFileSync(file)).then(result => {
fs.writeFileSync(file, result.css)
}).catch(e => {
console.error(e)
process.exit(1)
})
})
file = path.resolve('lib/themes', file);
cssnano
.process(fs.readFileSync(file))
.then(result => {
fs.writeFileSync(file, result.css);
})
.catch(e => {
console.error(e);
process.exit(1);
});
});
2 changes: 1 addition & 1 deletion docs/_media/example.html
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<h1>To infinity and Beyond!</h1>
<h1>To infinity and Beyond!</h1>
Loading

0 comments on commit 3bef45b

Please sign in to comment.