Skip to content

Commit f925d99

Browse files
enzostvscoyotte508
andauthored
core: ✨ add new package space-header (#752)
Add the `mini header` into your project if running on a custom/sub domain <img width="443" alt="Screenshot 2024-06-13 at 11 24 02 AM" src="https://github.com/huggingface/huggingface.js/assets/15983122/f7bb8817-b883-412c-8384-44b748998940"> Example: ```js import { init } from "@huggingface/space-header" // ... init("enzostvs/lora-studio") ``` Must be called once the page has been mounted. If this is not the case, a log error is displayed to prevent the user we've decided to stick with vanilla JS, which may evolve if necessary. (web component, etc) --------- Co-authored-by: coyotte508 <[email protected]>
1 parent 536cc86 commit f925d99

23 files changed

+1553
-0
lines changed
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
name: Space-header - Version and Release
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
newversion:
7+
type: choice
8+
description: "Semantic Version Bump Type"
9+
default: patch
10+
options:
11+
- patch
12+
- minor
13+
- major
14+
15+
concurrency:
16+
group: "push-to-main"
17+
18+
defaults:
19+
run:
20+
working-directory: packages/space-header
21+
22+
jobs:
23+
version_and_release:
24+
runs-on: ubuntu-latest
25+
steps:
26+
- uses: actions/checkout@v3
27+
with:
28+
# Needed to push the tag and the commit on the main branch, otherwise we get:
29+
# > Run git push --follow-tags
30+
# remote: error: GH006: Protected branch update failed for refs/heads/main.
31+
# remote: error: Changes must be made through a pull request. Required status check "lint" is expected.
32+
token: ${{ secrets.BOT_ACCESS_TOKEN }}
33+
- run: corepack enable
34+
- uses: actions/setup-node@v3
35+
with:
36+
node-version: "20"
37+
cache: "pnpm"
38+
cache-dependency-path: |
39+
packages/space-header/pnpm-lock.yaml
40+
# setting a registry enables the NODE_AUTH_TOKEN env variable where we can set an npm token. REQUIRED
41+
registry-url: "https://registry.npmjs.org"
42+
- run: pnpm install
43+
- run: git config --global user.name machineuser
44+
- run: git config --global user.email [email protected]
45+
- run: |
46+
PACKAGE_VERSION=$(node -p "require('./package.json').version")
47+
BUMPED_VERSION=$(node -p "require('semver').inc('$PACKAGE_VERSION', '${{ github.event.inputs.newversion }}')")
48+
# Update package.json with the new version
49+
node -e "const fs = require('fs'); const package = JSON.parse(fs.readFileSync('./package.json')); package.version = '$BUMPED_VERSION'; fs.writeFileSync('./package.json', JSON.stringify(package, null, '\t') + '\n');"
50+
git commit . -m "🔖 @hugginface/space-header $BUMPED_VERSION"
51+
git tag "space-header-v$BUMPED_VERSION"
52+
- run: pnpm publish --no-git-checks .
53+
env:
54+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
55+
- run: git pull --rebase && git push --follow-tags
56+
# hack - reuse actions/setup-node@v3 just to set a new registry
57+
- uses: actions/setup-node@v3
58+
with:
59+
node-version: "20"
60+
registry-url: "https://npm.pkg.github.com"
61+
- run: pnpm publish --no-git-checks .
62+
env:
63+
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
64+
- name: "Update Doc"
65+
uses: peter-evans/repository-dispatch@v2
66+
with:
67+
event-type: doc-build

packages/space-header/.eslintignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
dist

packages/space-header/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
dist/*
2+
node_modules/*

packages/space-header/.prettierignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
pnpm-lock.yaml
2+
# In order to avoid code samples to have tabs, they don't display well on npm
3+
README.md
4+
dist

packages/space-header/package.json

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
"name": "@huggingface/space-header",
3+
"version": "1.0.0",
4+
"description": "",
5+
"main": "index.js",
6+
"type": "module",
7+
"types": "dist/index.d.ts",
8+
"module": "dist/index.js",
9+
"scripts": {
10+
"build": "tsup ./src",
11+
"lint": "eslint --quiet --fix --ext .cjs,.ts .",
12+
"lint:check": "eslint --ext .cjs,.ts .",
13+
"format": "prettier --write .",
14+
"format:check": "prettier --check .",
15+
"prepublishOnly": "pnpm run build"
16+
},
17+
"keywords": [],
18+
"author": "",
19+
"license": "ISC",
20+
"devDependencies": {
21+
"tsup": "^8.1.0",
22+
"typescript": "^5.4.5"
23+
}
24+
}

0 commit comments

Comments
 (0)