Skip to content

Commit

Permalink
refactor: rename to hfup
Browse files Browse the repository at this point in the history
  • Loading branch information
nekomeowww committed Dec 26, 2024
1 parent de29371 commit 6d40303
Show file tree
Hide file tree
Showing 20 changed files with 141 additions and 77 deletions.
2 changes: 2 additions & 0 deletions cspell.config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ words:
- gltf
- hfspaceup
- hfsup
- hfup
- histoire
- hiyori
- huggingface
Expand Down Expand Up @@ -80,5 +81,6 @@ words:
- webgpu
- worklet
- xsai
- hfup
ignoreWords: []
import: []
1 change: 0 additions & 1 deletion packages/elevenlabs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
5 changes: 4 additions & 1 deletion packages/elevenlabs/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,8 @@
"isolatedModules": true,
"verbatimModuleSyntax": true,
"skipLibCheck": true
}
},
"include": [
"src/**/*.ts"
]
}
52 changes: 0 additions & 52 deletions packages/hfsup/README.md

This file was deleted.

95 changes: 95 additions & 0 deletions packages/hfup/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
<h1 align="center">🧑‍🚀 hfup</h1>

<p align="center">
A collection of tools to help you deploy, bundle HuggingFace Spaces and related assets with ease.
</p>

> 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)
```
4 changes: 2 additions & 2 deletions packages/hfsup/package.json → packages/hfup/package.json
Original file line number Diff line number Diff line change
@@ -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.",
Expand All @@ -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",
Expand All @@ -36,6 +35,7 @@
"build": "unbuild"
},
"dependencies": {
"defu": "^6.1.4",
"gray-matter": "^4.0.3",
"vite": "^6.0.5"
}
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -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'

Expand All @@ -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<SpaceConfiguration, SpaceConfiguration[]>(
configuration,
{
emoji: '🚀',
sdk: 'static',
pinned: false,
license: 'unknown',
},
)
let packageJSON: Record<string, any> = {}
let readme = ''

Expand Down
File renamed without changes.
5 changes: 4 additions & 1 deletion packages/hfsup/tsconfig.json → packages/hfup/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,8 @@
"isolatedModules": true,
"verbatimModuleSyntax": true,
"skipLibCheck": true
}
},
"include": [
"src/**/*.ts"
]
}
2 changes: 1 addition & 1 deletion packages/moonshine-web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
6 changes: 3 additions & 3 deletions packages/moonshine-web/vite.config.ts
Original file line number Diff line number Diff line change
@@ -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'

Expand All @@ -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',
Expand Down
2 changes: 1 addition & 1 deletion packages/stage/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
1 change: 1 addition & 0 deletions packages/stage/src/typed-router.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ declare module 'vue-router/auto-routes' {
*/
export interface RouteNamedMap {
'/': RouteRecordInfo<'/', '/', Record<never, never>, Record<never, never>>,
'/[...all]': RouteRecordInfo<'/[...all]', '/:all(.*)', { all: ParamValue<true> }, { all: ParamValue<false> }>,
'/audio': RouteRecordInfo<'/audio', '/audio', Record<never, never>, Record<never, never>>,
'/devtools/image': RouteRecordInfo<'/devtools/image', '/devtools/image', Record<never, never>, Record<never, never>>,
'/queue': RouteRecordInfo<'/queue', '/queue', Record<never, never>, Record<never, never>>,
Expand Down
6 changes: 3 additions & 3 deletions packages/stage/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -297,9 +297,9 @@ export default defineConfig({
}),
SpaceCard({
title: 'アイリ VTuber',
emoji: '🌙',
emoji: '🧸',
colorFrom: 'pink',
colorTo: 'yellow',
colorTo: 'pink',
sdk: 'static',
pinned: false,
license: 'mit',
Expand Down
2 changes: 1 addition & 1 deletion packages/whisper-webgpu/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
6 changes: 3 additions & 3 deletions packages/whisper-webgpu/vite.config.ts
Original file line number Diff line number Diff line change
@@ -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'

Expand All @@ -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',
Expand Down
17 changes: 10 additions & 7 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 6d40303

Please sign in to comment.