mirror of
https://github.com/ecomfe/vue-echarts.git
synced 2025-08-15 03:33:19 +08:00
docs: update version, deps and docs for 8.0 beta (#849)
* chore: up version and deps * chore: use pnpm CLI to get versions * add note for echarts 6 upgrade guide * remove docs script let cdn to redirect for us * Revert "remove docs script" This reverts commit 3bc237db9100864f2813249ac1693735a658e646. * update demo links
This commit is contained in:
51
scripts/docs.ts
Normal file
51
scripts/docs.ts
Normal file
@ -0,0 +1,51 @@
|
||||
import { readFileSync, writeFileSync } from "node:fs";
|
||||
import { commentMark } from "comment-mark";
|
||||
import { getPackageVersions, resolvePath } from "./utils";
|
||||
|
||||
const { name, version, devDependencies } = getPackageVersions([
|
||||
"echarts",
|
||||
"vue",
|
||||
]);
|
||||
|
||||
const CDN_PREFIX = "https://cdn.jsdelivr.net/npm/";
|
||||
|
||||
const DEP_VERSIONS = {
|
||||
...Object.fromEntries(
|
||||
Object.entries(devDependencies).map(([name, { version }]) => [
|
||||
name,
|
||||
version,
|
||||
]),
|
||||
),
|
||||
[name]: version,
|
||||
};
|
||||
|
||||
function getScripts() {
|
||||
return Object.entries(DEP_VERSIONS)
|
||||
.map(([dep, version]) => {
|
||||
const [, name] = dep.match(/^(.+?)(?:@.+)?$/) || [];
|
||||
return `<script src="${CDN_PREFIX}${name}@${version}"></script>`;
|
||||
})
|
||||
.join("\n");
|
||||
}
|
||||
|
||||
function getCodeBlock(code: string) {
|
||||
return "\n```html\n" + code + "\n```\n";
|
||||
}
|
||||
|
||||
const README_FILES = ["README.md", "README.zh-Hans.md"].map((name) =>
|
||||
resolvePath(import.meta.url, "..", name),
|
||||
);
|
||||
|
||||
README_FILES.forEach((file) => {
|
||||
const content = readFileSync(file, "utf8");
|
||||
|
||||
writeFileSync(
|
||||
file,
|
||||
commentMark(content, {
|
||||
vue3Scripts: getCodeBlock(getScripts()),
|
||||
}),
|
||||
"utf8",
|
||||
);
|
||||
});
|
||||
|
||||
console.log("README files updated.");
|
Reference in New Issue
Block a user