mirror of
https://github.com/zhw2590582/ArtPlayer.git
synced 2026-10-08 19:06:15 -08:00
Artplayer vitepress (#446)
* init * init * update * update * update * update * update * update * add i18n option * update * update * update * update * update * update * update * update * update * update * update * update * update * update * update * update * update * update * update * update * update * update * update * update * update * update * update * update * update * update * update * update * update * update * update * update * update * update * update * update * update * update * update * update * update * update * update * update * update * update * update * update * update * update * update * update * update * update
This commit is contained in:
1 parent
6a866f88c3
commit
fa7954de0d
295 files changed
+18695
-36337
No files matched your search
@@ -0,0 +1,8 @@
|
||||
import spawn from 'cross-spawn';
|
||||
|
||||
const proc = spawn('npm', ['run', 'docs:build'], {
|
||||
cwd: './packages/artplayer-vitepress/',
|
||||
});
|
||||
|
||||
proc.stdout.pipe(process.stdout);
|
||||
proc.stderr.pipe(process.stderr);
|
||||
@@ -1,82 +0,0 @@
|
||||
import glob from 'glob';
|
||||
import { join } from 'path';
|
||||
import { parse } from 'node-html-parser';
|
||||
import { format as _format } from 'prettier';
|
||||
import { readFileSync, writeFileSync } from 'fs';
|
||||
|
||||
const htmls = glob
|
||||
.sync(join(process.cwd(), 'docs/document/zh-cn/**/*.html'))
|
||||
.filter((item) => !item.includes('libraries'))
|
||||
.map((item) => readFileSync(item, 'utf-8'))
|
||||
.map((item) =>
|
||||
parse(item, {
|
||||
lowerCaseTagName: false,
|
||||
comment: true,
|
||||
blockTextElements: {
|
||||
script: false,
|
||||
noscript: false,
|
||||
style: false,
|
||||
pre: true,
|
||||
},
|
||||
}),
|
||||
)
|
||||
.map((item) => item.querySelectorAll('pre'))
|
||||
.map((item) => item.map((pre) => parse(pre.innerHTML).textContent))
|
||||
.flat(Infinity)
|
||||
.filter((item) => item.trim().startsWith('var art'))
|
||||
.map((item) => item.replace(/\/assets/g, './assets'))
|
||||
.map((item) => item.replace(/\s{3}/g, '\n'));
|
||||
|
||||
const tests = `
|
||||
describe('Document', function() {
|
||||
afterEach(function() {
|
||||
[...Artplayer.instances].forEach(art => {
|
||||
art.destroy(true);
|
||||
});
|
||||
});
|
||||
|
||||
function testAll(art, done) {
|
||||
let isDone = false;
|
||||
art.on('ready', () => {
|
||||
expect(art.id).to.be.an('number');
|
||||
|
||||
if (!isDone) {
|
||||
isDone = true;
|
||||
done();
|
||||
}
|
||||
});
|
||||
|
||||
art.on('video:error', () => {
|
||||
expect(art.id).to.be.an('number');
|
||||
|
||||
if (!isDone) {
|
||||
isDone = true;
|
||||
done();
|
||||
}
|
||||
});
|
||||
|
||||
setTimeout(() => {
|
||||
expect(art.id).to.be.an('number');
|
||||
|
||||
if (!isDone) {
|
||||
isDone = true;
|
||||
done();
|
||||
}
|
||||
}, 1000);
|
||||
}
|
||||
|
||||
${htmls
|
||||
.map((item, index) => {
|
||||
return `
|
||||
it('Test${index}', function(done) {
|
||||
${item}
|
||||
|
||||
testAll(art, done);
|
||||
});`;
|
||||
})
|
||||
.join('\n\n')}
|
||||
});
|
||||
`;
|
||||
|
||||
const format = _format(tests, { semi: true, parser: 'babel' });
|
||||
writeFileSync(join(process.cwd(), 'test/document.test.js'), format);
|
||||
+1
-1
@@ -15,7 +15,7 @@ export function formatDate(date) {
|
||||
export function getProjects() {
|
||||
return glob
|
||||
.sync('packages/*')
|
||||
.filter((item) => !item.endsWith('artplayer-document') && !item.endsWith('artplayer-template'))
|
||||
.filter((item) => !item.endsWith('artplayer-template') && !item.endsWith('artplayer-vitepress'))
|
||||
.reduce((result, item) => {
|
||||
const name = item.split(/\/|\\/g).pop();
|
||||
result[name] = path.resolve(process.cwd(), item);
|
||||
|
||||
Reference in new issue
Block a user