vite-on-github 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Foisalislambd
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,169 @@
1
+ # vite-on-github
2
+
3
+ ![vite-on-github banner](./assets/vite-on-github-banner.png)
4
+
5
+ [![npm version](https://img.shields.io/npm/v/vite-on-github.svg)](https://www.npmjs.com/package/vite-on-github)
6
+ [![license](https://img.shields.io/npm/l/vite-on-github.svg)](LICENSE)
7
+
8
+ > **One command** to prepare any Vite project for **GitHub Pages** — auto config, base paths, CI, and router setup.
9
+
10
+ No more fighting with `base` paths, broken assets, or manual GitHub Actions YAML.
11
+
12
+ **Live demo:** [foisalislambd.github.io/vite-on-github](https://foisalislambd.github.io/vite-on-github/) (built from `/demo`)
13
+
14
+ ---
15
+
16
+ ## The Problem
17
+
18
+ Deploying a Vite app to GitHub Pages usually means:
19
+
20
+ - Setting the correct `base` URL (`/repo-name/` vs `/`)
21
+ - Fixing broken asset paths when the app lives in a subfolder
22
+ - Configuring React Router / Vue Router `basename`
23
+ - Writing a GitHub Actions workflow from scratch
24
+ - Adding SPA fallback (`404.html`) for client-side routing
25
+
26
+ That's a lot of steps — and easy to get wrong.
27
+
28
+ ## The Solution
29
+
30
+ Run **one command** inside your Vite project:
31
+
32
+ ```bash
33
+ npx vite-on-github
34
+ ```
35
+
36
+ It automatically:
37
+
38
+ 1. Installs [`vite-basepath`](https://www.npmjs.com/package/vite-basepath) — relative asset paths that work in **any** subfolder
39
+ 2. Patches your `vite.config.ts` / `vite.config.js` to add the plugin
40
+ 3. Updates React Router / Vue Router with `getBase()` when detected
41
+ 4. Creates `.github/workflows/deploy.yml` for GitHub Pages
42
+ 5. Adds SPA `404.html` fallback in the CI build step
43
+
44
+ Your app works at:
45
+
46
+ - `https://username.github.io/` (user site)
47
+ - `https://username.github.io/my-repo/` (project site)
48
+ - **Any nested path** — no config changes needed
49
+
50
+ ---
51
+
52
+ ## Quick Start
53
+
54
+ ```bash
55
+ # Inside your Vite project folder
56
+ npx vite-on-github
57
+ ```
58
+
59
+ Follow the prompts, then:
60
+
61
+ 1. Push to GitHub
62
+ 2. Go to **Settings → Pages → Build and deployment**
63
+ 3. Set **Source** to **GitHub Actions**
64
+ 4. Done — your site deploys on every push to `main` / `master`
65
+
66
+ ---
67
+
68
+ ## CLI Reference
69
+
70
+ ```
71
+ vite-on-github [command] [options]
72
+
73
+ Commands:
74
+ init Set up everything (default)
75
+ help Show help
76
+
77
+ Options:
78
+ -y, --yes Skip prompts
79
+ --skip-install Don't install vite-basepath
80
+ --skip-vite-config Don't patch vite.config
81
+ --skip-router Don't patch router files
82
+ --skip-ci Don't create workflow
83
+ --node <version> Node version for CI (default: 22)
84
+ --out-dir <dir> Build output (default: dist)
85
+ ```
86
+
87
+ ### Examples
88
+
89
+ ```bash
90
+ # Interactive setup
91
+ npx vite-on-github
92
+
93
+ # Non-interactive (CI / scripts)
94
+ npx vite-on-github init -y
95
+
96
+ # Custom Node version and output dir
97
+ npx vite-on-github init --node 20 --out-dir dist
98
+ ```
99
+
100
+ ---
101
+
102
+ ## What Gets Changed
103
+
104
+ | File | Change |
105
+ |------|--------|
106
+ | `package.json` | Adds `vite-basepath` dev dependency |
107
+ | `vite.config.*` | Adds `viteBasepath()` plugin |
108
+ | `src/main.*` or router | Adds `getBase()` for React/Vue Router |
109
+ | `.github/workflows/deploy.yml` | GitHub Pages deploy workflow |
110
+
111
+ Existing config is **patched**, not replaced. Safe to run again — skips what's already done.
112
+
113
+ ---
114
+
115
+ ## Programmatic API
116
+
117
+ Use in scripts or other tools:
118
+
119
+ ```ts
120
+ import { init } from 'vite-on-github';
121
+
122
+ const result = await init({
123
+ cwd: '/path/to/vite-project',
124
+ yes: true,
125
+ });
126
+
127
+ console.log(result.pagesUrl); // https://user.github.io/repo/
128
+ ```
129
+
130
+ ---
131
+
132
+ ## How Base Paths Work
133
+
134
+ This package uses **[vite-basepath](https://www.npmjs.com/package/vite-basepath)** under the hood:
135
+
136
+ - Build-time: sets Vite `base` to `./` (relative paths)
137
+ - Runtime: detects the real deploy path automatically
138
+ - Routers: `getBase()` returns the correct `basename` / `history` base
139
+
140
+ Same build works everywhere — root, subfolder, or nested path.
141
+
142
+ ---
143
+
144
+ ## Demo site
145
+
146
+ The `/demo` folder is a full documentation site (same design as [vite-basepath](https://github.com/Foisalislambd/vite-basepath)) adapted for **vite-on-github**. It deploys to GitHub Pages via `.github/workflows/deploy-demo.yml`.
147
+
148
+ ```bash
149
+ cd demo
150
+ npm install
151
+ npm run dev # local preview
152
+ npm run build # production build + 404.html for Pages
153
+ ```
154
+
155
+ After pushing to GitHub, enable **Settings → Pages → GitHub Actions** as the source.
156
+
157
+ ---
158
+
159
+ ## Requirements
160
+
161
+ - Node.js 18+
162
+ - A Vite project (`vite` in `package.json`)
163
+ - Git repository with GitHub remote (optional — for URL preview)
164
+
165
+ ---
166
+
167
+ ## License
168
+
169
+ MIT
Binary file
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ import '../dist/cli.js';
package/dist/cli.d.ts ADDED
@@ -0,0 +1,2 @@
1
+
2
+ export { }