From 6d403034d03d101dc3aaf30a938d5f9f61b0730e Mon Sep 17 00:00:00 2001 From: Neko Ayaka Date: Thu, 26 Dec 2024 23:36:49 +0800 Subject: [PATCH] refactor: rename to hfup --- cspell.config.yaml | 2 + packages/elevenlabs/package.json | 1 - packages/elevenlabs/tsconfig.json | 5 +- packages/hfsup/README.md | 52 ---------- packages/hfup/README.md | 95 +++++++++++++++++++ packages/{hfsup => hfup}/package.json | 4 +- packages/{hfsup => hfup}/src/utils/fs.ts | 0 packages/{hfsup => hfup}/src/vite/index.ts | 0 packages/{hfsup => hfup}/src/vite/lfs.ts | 0 .../src/vite/space-card/index.ts | 12 ++- .../src/vite/space-card/types.ts | 0 packages/{hfsup => hfup}/tsconfig.json | 5 +- packages/moonshine-web/package.json | 2 +- packages/moonshine-web/vite.config.ts | 6 +- packages/stage/package.json | 2 +- packages/stage/src/typed-router.d.ts | 1 + packages/stage/vite.config.ts | 6 +- packages/whisper-webgpu/package.json | 2 +- packages/whisper-webgpu/vite.config.ts | 6 +- pnpm-lock.yaml | 17 ++-- 20 files changed, 141 insertions(+), 77 deletions(-) delete mode 100644 packages/hfsup/README.md create mode 100644 packages/hfup/README.md rename packages/{hfsup => hfup}/package.json (95%) rename packages/{hfsup => hfup}/src/utils/fs.ts (100%) rename packages/{hfsup => hfup}/src/vite/index.ts (100%) rename packages/{hfsup => hfup}/src/vite/lfs.ts (100%) rename packages/{hfsup => hfup}/src/vite/space-card/index.ts (93%) rename packages/{hfsup => hfup}/src/vite/space-card/types.ts (100%) rename packages/{hfsup => hfup}/tsconfig.json (88%) diff --git a/cspell.config.yaml b/cspell.config.yaml index 4e44203..d632475 100644 --- a/cspell.config.yaml +++ b/cspell.config.yaml @@ -32,6 +32,7 @@ words: - gltf - hfspaceup - hfsup + - hfup - histoire - hiyori - huggingface @@ -80,5 +81,6 @@ words: - webgpu - worklet - xsai + - hfup ignoreWords: [] import: [] diff --git a/packages/elevenlabs/package.json b/packages/elevenlabs/package.json index b10658b..4e21fc2 100644 --- a/packages/elevenlabs/package.json +++ b/packages/elevenlabs/package.json @@ -14,7 +14,6 @@ "url": "https://github.com/moeru-ai/airi.git", "directory": "packages/elevenlabs" }, - "sideEffects": false, "exports": { "./types": { "types": "./dist/types/index.d.ts" diff --git a/packages/elevenlabs/tsconfig.json b/packages/elevenlabs/tsconfig.json index c84f5b0..00dcfd8 100644 --- a/packages/elevenlabs/tsconfig.json +++ b/packages/elevenlabs/tsconfig.json @@ -11,5 +11,8 @@ "isolatedModules": true, "verbatimModuleSyntax": true, "skipLibCheck": true - } + }, + "include": [ + "src/**/*.ts" + ] } diff --git a/packages/hfsup/README.md b/packages/hfsup/README.md deleted file mode 100644 index e33cb50..0000000 --- a/packages/hfsup/README.md +++ /dev/null @@ -1,52 +0,0 @@ -

🧑‍🚀 hfsup

- -> `hfsup` stands for HuggingFace Space up, where the `up` is coming from `rollup`, `tsup`, you may think of "to make your work up and running". -> -> A collection of tools to help you deploy, bundle HuggingFace Spaces and related assets with ease. - -```shell -pnpm i hfsup -D -``` - -```ts -import { LFS, SpaceCard } from 'hfsup/vite' -import { defineConfig } from 'vite' - -export default defineConfig({ - plugins: [ - LFS(), - SpaceCard({ - title: 'Real-time Whisper WebGPU (Vue)', - emoji: '🎤', - colorFrom: 'gray', - colorTo: 'green', - sdk: 'static', - pinned: false, - license: 'mit', - models: ['onnx-community/whisper-base'], - short_description: 'Yet another Real-time Whisper with WebGPU, written in Vue', - thumbnail: 'https://raw.githubusercontent.com/moeru-ai/airi/refs/heads/main/packages/whisper-webgpu/public/banner.png' - }) - ] -}) -``` - -After bundling, a dedicated README with merged front-matter header will be generated in the root of your project: - -```md ---- -title: Real-time Whisper WebGPU (Vue) -emoji: 🎤 -colorFrom: gray -colorTo: green -sdk: static -pinned: false -license: mit -models: -- onnx-community/whisper-base -short_description: Yet another Real-time Whisper with WebGPU, written in Vue -thumbnail: https://raw.githubusercontent.com/moeru-ai/airi/refs/heads/main/packages/whisper-webgpu/public/banner.png ---- - -# Real-time Whisper WebGPU (Vue) -``` diff --git a/packages/hfup/README.md b/packages/hfup/README.md new file mode 100644 index 0000000..40cfd49 --- /dev/null +++ b/packages/hfup/README.md @@ -0,0 +1,95 @@ +

🧑‍🚀 hfup

+ +

+ A collection of tools to help you deploy, bundle HuggingFace Spaces and related assets with ease. +

+ +> Where `hfup` stands for HuggingFace up, and the word `up` was inspired from `rollup`, `tsup`, you may think it means "to make your HuggingFace work up and running". + +## Features + +- Still manually writing HuggingFace Spaces configurations? +- Having trouble to quickly handle and edit the `.gitattributes` file for Git LFS? +- Don't want any of the HuggingFace Spaces front-matter appear in `README.md`? +- Fighting against annoying errors when deploying your HuggingFace Spaces? + +`hfup` is here to help you! + +- 🚀 Automatically... + - generate `.gitattributes` file for Git LFS. + - generate HuggingFace Spaces front-matter in `README.md`. + - search for your `README.md` file and merge the front-matter header. + - generate a dedicated `README.md` file right inside the `outDir` of build. +- 🔐 Intellisense ready, type safe for Spaces configurations. +- 📦 Out of the box support for Vite. + +## Installation + +[`pnpm`](https://pnpm.io/) + +```shell +pnpm i hfup -D +``` + +[`@antfu/ni`](https://www.npmjs.com/package/@antfu/ni) + +```shell +ni hfup -D +``` + +`npm` + +```shell +npm i hfup -D +``` + +Yarn + +```shell +yarn i hfup -D +``` + +## Usage + +```ts +import { LFS, SpaceCard } from 'hfup/vite' +import { defineConfig } from 'vite' + +export default defineConfig({ + plugins: [ + LFS(), + SpaceCard({ + title: 'Real-time Whisper WebGPU (Vue)', + emoji: '🎤', + colorFrom: 'gray', + colorTo: 'green', + sdk: 'static', + pinned: false, + license: 'mit', + models: ['onnx-community/whisper-base'], + short_description: 'Yet another Real-time Whisper with WebGPU, written in Vue', + thumbnail: 'https://raw.githubusercontent.com/moeru-ai/airi/refs/heads/main/packages/whisper-webgpu/public/banner.png' + }) + ] +}) +``` + +After bundling, a dedicated README with merged front-matter header will be generated in the root of your project: + +```md +--- +title: Real-time Whisper WebGPU (Vue) +emoji: 🎤 +colorFrom: gray +colorTo: green +sdk: static +pinned: false +license: mit +models: +- onnx-community/whisper-base +short_description: Yet another Real-time Whisper with WebGPU, written in Vue +thumbnail: https://raw.githubusercontent.com/moeru-ai/airi/refs/heads/main/packages/whisper-webgpu/public/banner.png +--- + +# Real-time Whisper WebGPU (Vue) +``` diff --git a/packages/hfsup/package.json b/packages/hfup/package.json similarity index 95% rename from packages/hfsup/package.json rename to packages/hfup/package.json index ac8bacf..7cdbc71 100644 --- a/packages/hfsup/package.json +++ b/packages/hfup/package.json @@ -1,5 +1,5 @@ { - "name": "hfsup", + "name": "hfup", "type": "module", "private": false, "description": "A collection of tools to help you deploy, bundle HuggingFace Spaces and related assets with ease.", @@ -14,7 +14,6 @@ "url": "https://github.com/moeru-ai/airi.git", "directory": "packages/huggingspace" }, - "sideEffects": false, "exports": { "./vite": { "types": "./dist/vite/index.d.ts", @@ -36,6 +35,7 @@ "build": "unbuild" }, "dependencies": { + "defu": "^6.1.4", "gray-matter": "^4.0.3", "vite": "^6.0.5" } diff --git a/packages/hfsup/src/utils/fs.ts b/packages/hfup/src/utils/fs.ts similarity index 100% rename from packages/hfsup/src/utils/fs.ts rename to packages/hfup/src/utils/fs.ts diff --git a/packages/hfsup/src/vite/index.ts b/packages/hfup/src/vite/index.ts similarity index 100% rename from packages/hfsup/src/vite/index.ts rename to packages/hfup/src/vite/index.ts diff --git a/packages/hfsup/src/vite/lfs.ts b/packages/hfup/src/vite/lfs.ts similarity index 100% rename from packages/hfsup/src/vite/lfs.ts rename to packages/hfup/src/vite/lfs.ts diff --git a/packages/hfsup/src/vite/space-card/index.ts b/packages/hfup/src/vite/space-card/index.ts similarity index 93% rename from packages/hfsup/src/vite/space-card/index.ts rename to packages/hfup/src/vite/space-card/index.ts index 20e8c63..ffdfa55 100644 --- a/packages/hfsup/src/vite/space-card/index.ts +++ b/packages/hfup/src/vite/space-card/index.ts @@ -1,7 +1,9 @@ import type { Plugin, ResolvedConfig } from 'vite' import { readFile } from 'node:fs/promises' import { join } from 'node:path' +import { defu } from 'defu' import grayMatter from 'gray-matter' + import { exists } from '../../utils/fs' import { type License, licenseValues, type SpaceConfiguration } from './types' @@ -11,7 +13,15 @@ import { type License, licenseValues, type SpaceConfiguration } from './types' // https://huggingface.co/docs/hub/model-cards#model-card-metadata export function SpaceCard(configuration?: SpaceConfiguration): Plugin { let _config: ResolvedConfig - const _configuration: SpaceConfiguration = configuration ?? { emoji: '🚀', sdk: 'static' } + const _configuration = defu( + configuration, + { + emoji: '🚀', + sdk: 'static', + pinned: false, + license: 'unknown', + }, + ) let packageJSON: Record = {} let readme = '' diff --git a/packages/hfsup/src/vite/space-card/types.ts b/packages/hfup/src/vite/space-card/types.ts similarity index 100% rename from packages/hfsup/src/vite/space-card/types.ts rename to packages/hfup/src/vite/space-card/types.ts diff --git a/packages/hfsup/tsconfig.json b/packages/hfup/tsconfig.json similarity index 88% rename from packages/hfsup/tsconfig.json rename to packages/hfup/tsconfig.json index c84f5b0..00dcfd8 100644 --- a/packages/hfsup/tsconfig.json +++ b/packages/hfup/tsconfig.json @@ -11,5 +11,8 @@ "isolatedModules": true, "verbatimModuleSyntax": true, "skipLibCheck": true - } + }, + "include": [ + "src/**/*.ts" + ] } diff --git a/packages/moonshine-web/package.json b/packages/moonshine-web/package.json index 9ccebe9..8f5e892 100644 --- a/packages/moonshine-web/package.json +++ b/packages/moonshine-web/package.json @@ -32,7 +32,7 @@ "@types/three": "^0.171.0", "@vitejs/plugin-vue": "^5.2.1", "@webgpu/types": "^0.1.52", - "hfsup": "workspace:^", + "hfup": "workspace:^", "vue-tsc": "^2.2.0" } } diff --git a/packages/moonshine-web/vite.config.ts b/packages/moonshine-web/vite.config.ts index 1af3182..6e11581 100644 --- a/packages/moonshine-web/vite.config.ts +++ b/packages/moonshine-web/vite.config.ts @@ -1,6 +1,6 @@ import { templateCompilerOptions } from '@tresjs/core' import Vue from '@vitejs/plugin-vue' -import { LFS, SpaceCard } from 'hfsup/vite' +import { LFS, SpaceCard } from 'hfup/vite' import Unocss from 'unocss/vite' import { defineConfig } from 'vite' @@ -19,8 +19,8 @@ export default defineConfig({ SpaceCard({ title: 'Moonshine Web (Vue)', emoji: '🌙', - colorFrom: 'blue', - colorTo: 'pink', + colorFrom: 'yellow', + colorTo: 'yellow', sdk: 'static', pinned: false, license: 'mit', diff --git a/packages/stage/package.json b/packages/stage/package.json index 2ad983d..1129eb9 100644 --- a/packages/stage/package.json +++ b/packages/stage/package.json @@ -88,7 +88,7 @@ "@vitejs/plugin-vue": "^5.2.1", "@vue-macros/volar": "^0.30.8", "@vueuse/motion": "^2.2.6", - "hfsup": "workspace:^", + "hfup": "workspace:^", "markdown-it-link-attributes": "^4.0.1", "unocss-preset-theme": "^0.14.1", "unplugin-auto-import": "^0.19.0", diff --git a/packages/stage/src/typed-router.d.ts b/packages/stage/src/typed-router.d.ts index c64db10..315da15 100644 --- a/packages/stage/src/typed-router.d.ts +++ b/packages/stage/src/typed-router.d.ts @@ -19,6 +19,7 @@ declare module 'vue-router/auto-routes' { */ export interface RouteNamedMap { '/': RouteRecordInfo<'/', '/', Record, Record>, + '/[...all]': RouteRecordInfo<'/[...all]', '/:all(.*)', { all: ParamValue }, { all: ParamValue }>, '/audio': RouteRecordInfo<'/audio', '/audio', Record, Record>, '/devtools/image': RouteRecordInfo<'/devtools/image', '/devtools/image', Record, Record>, '/queue': RouteRecordInfo<'/queue', '/queue', Record, Record>, diff --git a/packages/stage/vite.config.ts b/packages/stage/vite.config.ts index 7cda274..8199d87 100644 --- a/packages/stage/vite.config.ts +++ b/packages/stage/vite.config.ts @@ -6,7 +6,7 @@ import { env } from 'node:process' import VueI18n from '@intlify/unplugin-vue-i18n/vite' import { templateCompilerOptions } from '@tresjs/core' import Vue from '@vitejs/plugin-vue' -import { LFS, SpaceCard } from 'hfsup/vite' +import { LFS, SpaceCard } from 'hfup/vite' import { ofetch } from 'ofetch' import Unocss from 'unocss/vite' import Components from 'unplugin-vue-components/vite' @@ -297,9 +297,9 @@ export default defineConfig({ }), SpaceCard({ title: 'アイリ VTuber', - emoji: '🌙', + emoji: '🧸', colorFrom: 'pink', - colorTo: 'yellow', + colorTo: 'pink', sdk: 'static', pinned: false, license: 'mit', diff --git a/packages/whisper-webgpu/package.json b/packages/whisper-webgpu/package.json index 34802db..34e040f 100644 --- a/packages/whisper-webgpu/package.json +++ b/packages/whisper-webgpu/package.json @@ -27,7 +27,7 @@ "@huggingface/transformers": "^3.2.3", "@vitejs/plugin-vue": "^5.2.1", "@webgpu/types": "^0.1.52", - "hfsup": "workspace:^", + "hfup": "workspace:^", "vue-tsc": "^2.2.0" } } diff --git a/packages/whisper-webgpu/vite.config.ts b/packages/whisper-webgpu/vite.config.ts index caa1322..d38a483 100644 --- a/packages/whisper-webgpu/vite.config.ts +++ b/packages/whisper-webgpu/vite.config.ts @@ -1,5 +1,5 @@ import Vue from '@vitejs/plugin-vue' -import { LFS, SpaceCard } from 'hfsup/vite' +import { LFS, SpaceCard } from 'hfup/vite' import Unocss from 'unocss/vite' import { defineConfig } from 'vite' @@ -15,8 +15,8 @@ export default defineConfig({ SpaceCard({ title: 'Real-time Whisper WebGPU (Vue)', emoji: '🎤', - colorFrom: 'gray', - colorTo: 'green', + colorFrom: 'blue', + colorTo: 'blue', sdk: 'static', pinned: false, license: 'mit', diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 0ec229a..2297bb6 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -86,8 +86,11 @@ importers: specifier: ^1.50.2 version: 1.50.2 - packages/hfsup: + packages/hfup: dependencies: + defu: + specifier: ^6.1.4 + version: 6.1.4 gray-matter: specifier: ^4.0.3 version: 4.0.3 @@ -150,9 +153,9 @@ importers: '@webgpu/types': specifier: ^0.1.52 version: 0.1.52 - hfsup: + hfup: specifier: workspace:^ - version: link:../hfsup + version: link:../hfup vue-tsc: specifier: ^2.2.0 version: 2.2.0(typescript@5.7.2) @@ -364,9 +367,9 @@ importers: '@vueuse/motion': specifier: ^2.2.6 version: 2.2.6(rollup@2.79.1)(vue@3.5.13(typescript@5.7.2)) - hfsup: + hfup: specifier: workspace:^ - version: link:../hfsup + version: link:../hfup markdown-it-link-attributes: specifier: ^4.0.1 version: 4.0.1 @@ -431,9 +434,9 @@ importers: '@webgpu/types': specifier: ^0.1.52 version: 0.1.52 - hfsup: + hfup: specifier: workspace:^ - version: link:../hfsup + version: link:../hfup vue-tsc: specifier: ^2.2.0 version: 2.2.0(typescript@5.7.2)