8000 🔨 Automatically update versions for CDN links (#129) · huggingface/huggingface.js@f24a618 · GitHub
[go: up one dir, main page]

Skip to content

Commit f24a618

Browse files
authored
🔨 Automatically update versions for CDN links (#129)
1 parent 1766706 commit f24a618

File tree

3 files changed

+24
-5
lines changed

3 files changed

+24
-5
lines changed

‎README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ You can run our packages with vanilla JS, without any bundler, by using a CDN or
4747
```html
4848

4949
<script type="module">
50-
import { HfInference } from 'https://cdn.jsdelivr.net/npm/@huggingface/inference@1/+esm';
51-
import { createRepo, commit, deleteRepo, listFiles } from "https://cdn.jsdelivr.net/npm/@huggingface/hub@0/+esm";
50+
import { HfInference } from 'https://cdn.jsdelivr.net/npm/@huggingface/inference@1.6.3/+esm';
51+
import { createRepo, commit, deleteRepo, listFiles } from "https://cdn.jsdelivr.net/npm/@huggingface/hub@0.4.0/+esm";
5252
</script>
5353
```
5454

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { readFileSync, writeFileSync } from "fs";
2+
3+
const hubPackage = JSON.parse(readFileSync("../hub/package.json").toString());
4+
const inferencePackage = JSON.parse(readFileSync("../inference/package.json").toString());
5+
6+
let content = readFileSync("../../README.md").toString();
7+
8+
content = content
9+
.replace(
10+
/https:[/][/]cdn[.]jsdelivr[.]net[/]npm[/]@huggingface[/]inference@\d([.]\d)?([.]\d)?[/][+]esm/,
11+
`https://cdn.jsdelivr.net/npm/@huggingface/inference@${inferencePackage.version}/+esm`
12+
)
13+
.replace(
14+
/https:[/][/]cdn[.]jsdelivr[.]net[/]npm[/]@huggingface[/]hub@\d([.]\d)?([.]\d)?[/][+]esm/,
15+
`https://cdn.jsdelivr.net/npm/@huggingface/hub@${hubPackage.version}/+esm`
16+
);
17+
18+
writeFileSync("../../README.md", Buffer.from(content));

‎packages/doc-internal/package.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,17 @@
44
"description": "Package to generate doc for other @huggingface packages",
55
"private": true,
66
"scripts": {
7-
"start": "npm run doc-hub && npm run doc-inference && cp ../../README.md ../../docs/index.md && npm run update-toc && npm run fix-md-links",
7+
"start": "npm run fix-cdn-versions && npm run doc-hub && npm run doc-inference && cp ../../README.md ../../docs/index.md && npm run update-toc && npm run fix-md-links",
88
"lint": "eslint --quiet --fix --ext .cjs,.ts .",
99
"lint:check": "eslint --ext .cjs,.ts .",
1010
"format": "prettier --write .",
1111
"format:check": "prettier --check .",
12-
"prepublish-hub": "npm run doc-hub && cp ../../README.md ../../docs/index.md && npm run update-toc && npm run fix-md-links",
13-
"prepublish-inference": "npm run doc-inference && cp ../../README.md ../../docs/index.md && npm run update-toc && npm run fix-md-links",
12+
"prepublish-hub": "npm run fix-cdn-versions && npm run doc-hub && cp ../../README.md ../../docs/index.md && npm run update-toc && npm run fix-md-links",
13+
"prepublish-inference": "npm run fix-cdn-versions && npm run doc-inference && cp ../../README.md ../../docs/index.md && npm run update-toc && npm run fix-md-links",
1414
"doc-hub": "typedoc --tsconfig ../hub/tsconfig.json --githubPages false --plugin typedoc-plugin-markdown --out ../../docs/hub --hideBreadcrumbs --hideInPageTOC --sourceLinkTemplate https://github.com/huggingface/huggingface.js/blob/main/{path}#L{line} ../hub/index.ts",
1515
"doc-inference": "typedoc --tsconfig ../inference/tsconfig.json --githubPages false --plugin typedoc-plugin-markdown --out ../../docs/inference --hideBreadcrumbs --hideInPageTOC --sourceLinkTemplate https://github.com/huggingface/huggingface.js/blob/main/{path}#L{line} ../inference/src/index.ts",
1616
"update-toc": "ts-node --esm update-toc.ts",
17+
"fix-cdn-versions": "ts-node --esm fix-cdn-versions.ts",
1718
"fix-md-links": "ts-node --esm fix-md-links.ts"
1819
},
1920
"type": "module",

0 commit comments

Comments
 (0)
0