ship-gh 1.0.0__tar.gz
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.
- ship_gh-1.0.0/LICENSE +21 -0
- ship_gh-1.0.0/PKG-INFO +98 -0
- ship_gh-1.0.0/README.md +85 -0
- ship_gh-1.0.0/pyproject.toml +22 -0
- ship_gh-1.0.0/setup.cfg +4 -0
- ship_gh-1.0.0/ship/__init__.py +0 -0
- ship_gh-1.0.0/ship/cli.py +260 -0
- ship_gh-1.0.0/ship_gh.egg-info/PKG-INFO +98 -0
- ship_gh-1.0.0/ship_gh.egg-info/SOURCES.txt +11 -0
- ship_gh-1.0.0/ship_gh.egg-info/dependency_links.txt +1 -0
- ship_gh-1.0.0/ship_gh.egg-info/entry_points.txt +2 -0
- ship_gh-1.0.0/ship_gh.egg-info/requires.txt +1 -0
- ship_gh-1.0.0/ship_gh.egg-info/top_level.txt +1 -0
ship_gh-1.0.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Shesanth
|
|
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.
|
ship_gh-1.0.0/PKG-INFO
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: ship-gh
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: Check and publish project to github with just one command.
|
|
5
|
+
Author: Shesanth
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/myxghty/shipper
|
|
8
|
+
Requires-Python: >=3.10
|
|
9
|
+
Description-Content-Type: text/markdown
|
|
10
|
+
License-File: LICENSE
|
|
11
|
+
Requires-Dist: rich
|
|
12
|
+
Dynamic: license-file
|
|
13
|
+
|
|
14
|
+
## Shipper
|
|
15
|
+
Shipper is a CLI tool I created to make commiting/creating a repo/hosting simplier and easier. The unique features include checking for a readme, making sure readme has atleast over 200 letters, making sure no secrets such as .env are also commited and with shipper there will be no need for checking and commiting manually.
|
|
16
|
+
|
|
17
|
+
## Cons of shipper
|
|
18
|
+
Shipper cannot write commit messages so they just come out as "ship it" rather than actually stating the change.
|
|
19
|
+
It's still in development so Im expecting a few several errors
|
|
20
|
+
That's about it for shipper everything else shipper takes care of it
|
|
21
|
+
|
|
22
|
+
## How to use
|
|
23
|
+
### 1. Install (one time)
|
|
24
|
+
|
|
25
|
+
You need **Python 3.10+**, **git**, and the **GitHub CLI** (`gh`).
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
pipx install git+https://github.com/myxghty/shipper
|
|
29
|
+
gh auth login
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
> No pipx? replace pipx with pip
|
|
33
|
+
|
|
34
|
+
### 2. Go to your project
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
cd my-project
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
### 3. Check it
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
ship check
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
runs only the checks without commiting:
|
|
47
|
+
|
|
48
|
+
```
|
|
49
|
+
Checking project...
|
|
50
|
+
✅ README.md found
|
|
51
|
+
✅ README.md has setup/run instructions
|
|
52
|
+
⚠️ No screenshot/video in README, reviewers want to see it working
|
|
53
|
+
✅ index.html found, so GitHub Pages can host this
|
|
54
|
+
✅ No secrets found
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
### 4. Ship it
|
|
58
|
+
|
|
59
|
+
```bash
|
|
60
|
+
ship
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
`ship` will:
|
|
64
|
+
1. Run all the checks. **❌ problems stop it**, and for ⚠️ warnings it asks before continuing.
|
|
65
|
+
2. Commit your files.
|
|
66
|
+
3. Create a GitHub repo named after the folder and push your code. If the repo already exists, it just pushes.
|
|
67
|
+
4. Turn on GitHub Pages (if there's an `index.html`).
|
|
68
|
+
5. Wait until the site is live and print the link.
|
|
69
|
+
|
|
70
|
+
```
|
|
71
|
+
Shipped! https://yourname.github.io/my-project/
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
### Commands
|
|
75
|
+
|
|
76
|
+
| Command | What it does |
|
|
77
|
+
|---|---|
|
|
78
|
+
| `ship` | Check, then publish to GitHub + Pages |
|
|
79
|
+
| `ship check` | Only run the checks |
|
|
80
|
+
| `ship open` | Open the live site (or the repo) in your browser |
|
|
81
|
+
| `ship --private` | Publish as a private repo (Pages is skipped) |
|
|
82
|
+
| `ship --help` | Show help |
|
|
83
|
+
|
|
84
|
+
## Try it in seconds
|
|
85
|
+
1. Click **Open in Codespaces** below
|
|
86
|
+
2. In the terminal:
|
|
87
|
+
```bash
|
|
88
|
+
pip install -e .
|
|
89
|
+
cd demo
|
|
90
|
+
ship check
|
|
91
|
+
ship --dry-run
|
|
92
|
+
```
|
|
93
|
+
[](https://codespaces.new/myxghty/shipper)
|
|
94
|
+
|
|
95
|
+
## AI Disclosue
|
|
96
|
+
AI was used in assissting for the making of the git commands.
|
|
97
|
+
|
|
98
|
+
Made by [Shesanth M](https://github.com/myxghty)
|
ship_gh-1.0.0/README.md
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
## Shipper
|
|
2
|
+
Shipper is a CLI tool I created to make commiting/creating a repo/hosting simplier and easier. The unique features include checking for a readme, making sure readme has atleast over 200 letters, making sure no secrets such as .env are also commited and with shipper there will be no need for checking and commiting manually.
|
|
3
|
+
|
|
4
|
+
## Cons of shipper
|
|
5
|
+
Shipper cannot write commit messages so they just come out as "ship it" rather than actually stating the change.
|
|
6
|
+
It's still in development so Im expecting a few several errors
|
|
7
|
+
That's about it for shipper everything else shipper takes care of it
|
|
8
|
+
|
|
9
|
+
## How to use
|
|
10
|
+
### 1. Install (one time)
|
|
11
|
+
|
|
12
|
+
You need **Python 3.10+**, **git**, and the **GitHub CLI** (`gh`).
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
pipx install git+https://github.com/myxghty/shipper
|
|
16
|
+
gh auth login
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
> No pipx? replace pipx with pip
|
|
20
|
+
|
|
21
|
+
### 2. Go to your project
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
cd my-project
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
### 3. Check it
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
ship check
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
runs only the checks without commiting:
|
|
34
|
+
|
|
35
|
+
```
|
|
36
|
+
Checking project...
|
|
37
|
+
✅ README.md found
|
|
38
|
+
✅ README.md has setup/run instructions
|
|
39
|
+
⚠️ No screenshot/video in README, reviewers want to see it working
|
|
40
|
+
✅ index.html found, so GitHub Pages can host this
|
|
41
|
+
✅ No secrets found
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
### 4. Ship it
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
ship
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
`ship` will:
|
|
51
|
+
1. Run all the checks. **❌ problems stop it**, and for ⚠️ warnings it asks before continuing.
|
|
52
|
+
2. Commit your files.
|
|
53
|
+
3. Create a GitHub repo named after the folder and push your code. If the repo already exists, it just pushes.
|
|
54
|
+
4. Turn on GitHub Pages (if there's an `index.html`).
|
|
55
|
+
5. Wait until the site is live and print the link.
|
|
56
|
+
|
|
57
|
+
```
|
|
58
|
+
Shipped! https://yourname.github.io/my-project/
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
### Commands
|
|
62
|
+
|
|
63
|
+
| Command | What it does |
|
|
64
|
+
|---|---|
|
|
65
|
+
| `ship` | Check, then publish to GitHub + Pages |
|
|
66
|
+
| `ship check` | Only run the checks |
|
|
67
|
+
| `ship open` | Open the live site (or the repo) in your browser |
|
|
68
|
+
| `ship --private` | Publish as a private repo (Pages is skipped) |
|
|
69
|
+
| `ship --help` | Show help |
|
|
70
|
+
|
|
71
|
+
## Try it in seconds
|
|
72
|
+
1. Click **Open in Codespaces** below
|
|
73
|
+
2. In the terminal:
|
|
74
|
+
```bash
|
|
75
|
+
pip install -e .
|
|
76
|
+
cd demo
|
|
77
|
+
ship check
|
|
78
|
+
ship --dry-run
|
|
79
|
+
```
|
|
80
|
+
[](https://codespaces.new/myxghty/shipper)
|
|
81
|
+
|
|
82
|
+
## AI Disclosue
|
|
83
|
+
AI was used in assissting for the making of the git commands.
|
|
84
|
+
|
|
85
|
+
Made by [Shesanth M](https://github.com/myxghty)
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "ship-gh"
|
|
3
|
+
version = "1.0.0"
|
|
4
|
+
description = "Check and publish project to github with just one command."
|
|
5
|
+
readme = "README.md"
|
|
6
|
+
requires-python = ">=3.10"
|
|
7
|
+
license = "MIT"
|
|
8
|
+
authors = [{ name = "Shesanth" }]
|
|
9
|
+
dependencies = ["rich"]
|
|
10
|
+
|
|
11
|
+
[project.urls]
|
|
12
|
+
Homepage = "https://github.com/myxghty/shipper"
|
|
13
|
+
|
|
14
|
+
[project.scripts]
|
|
15
|
+
ship = "ship.cli:main"
|
|
16
|
+
|
|
17
|
+
[build-system]
|
|
18
|
+
requires = ["setuptools>=77"]
|
|
19
|
+
build-backend = "setuptools.build_meta"
|
|
20
|
+
|
|
21
|
+
[tool.setuptools]
|
|
22
|
+
packages = ["ship"]
|
ship_gh-1.0.0/setup.cfg
ADDED
|
File without changes
|
|
@@ -0,0 +1,260 @@
|
|
|
1
|
+
import argparse
|
|
2
|
+
import re
|
|
3
|
+
import shutil
|
|
4
|
+
import subprocess
|
|
5
|
+
import time
|
|
6
|
+
import urllib.request
|
|
7
|
+
import webbrowser
|
|
8
|
+
from pathlib import Path
|
|
9
|
+
|
|
10
|
+
from rich.console import Console
|
|
11
|
+
from rich.markup import escape
|
|
12
|
+
|
|
13
|
+
console = Console()
|
|
14
|
+
icons = {"ok": "✅", "warn": "⚠️ ", "fail": "❌"}
|
|
15
|
+
colors = {"ok": "green", "warn": "yellow", "fail": "red"}
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
# ---------- helpers ----------
|
|
19
|
+
|
|
20
|
+
def run(cmd, check=True):
|
|
21
|
+
"""Run a command like ["git", "status"] and return its output."""
|
|
22
|
+
result = subprocess.run(cmd, capture_output=True, text=True)
|
|
23
|
+
if check and result.returncode != 0:
|
|
24
|
+
raise RuntimeError(f"`{' '.join(cmd)}` failed:\n{result.stderr.strip()}")
|
|
25
|
+
return result.stdout.strip()
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
def basic_check():
|
|
29
|
+
if not shutil.which("git") or not shutil.which("gh"):
|
|
30
|
+
console.print("[red]❌ git and gh must be installed.[/]")
|
|
31
|
+
return False
|
|
32
|
+
if subprocess.run(["gh", "auth", "status"], capture_output=True).returncode != 0:
|
|
33
|
+
console.print("[red]❌ Not logged in. Run: gh auth login[/]")
|
|
34
|
+
return False
|
|
35
|
+
return True
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
# ---------- publishing ----------
|
|
39
|
+
|
|
40
|
+
def commit_everything(folder: Path):
|
|
41
|
+
if not (folder / ".git").exists():
|
|
42
|
+
run(["git", "init"])
|
|
43
|
+
run(["git", "add", "-A"])
|
|
44
|
+
if run(["git", "status", "--porcelain"]):
|
|
45
|
+
run(["git", "commit", "-m", "Ship it"])
|
|
46
|
+
run(["git", "branch", "-M", "main"])
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
def push_to_github(folder: Path, private: bool):
|
|
50
|
+
remotes = run(["git", "remote"], check=False)
|
|
51
|
+
if "origin" in remotes.split():
|
|
52
|
+
run(["git", "push", "-u", "origin", "main"])
|
|
53
|
+
else:
|
|
54
|
+
name = folder.name.lower().replace(" ", "-")
|
|
55
|
+
visibility = "--private" if private else "--public"
|
|
56
|
+
run(["gh", "repo", "create", name, visibility, "--source", ".", "--push"])
|
|
57
|
+
return run(["gh", "repo", "view", "--json", "nameWithOwner", "--jq", ".nameWithOwner"])
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
def host_pages(full_name: str):
|
|
61
|
+
result = subprocess.run(
|
|
62
|
+
["gh", "api", "-X", "POST", f"repos/{full_name}/pages",
|
|
63
|
+
"-f", "source[branch]=main", "-f", "source[path]=/"],
|
|
64
|
+
capture_output=True, text=True,
|
|
65
|
+
)
|
|
66
|
+
# 409 = Pages is already enabled, which is fine
|
|
67
|
+
if result.returncode != 0 and "409" not in result.stderr:
|
|
68
|
+
raise RuntimeError(f"Couldn't enable Pages:\n{result.stderr.strip()}")
|
|
69
|
+
return run(["gh", "api", f"repos/{full_name}/pages", "--jq", ".html_url"])
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
def wait(url: str, timeout=180):
|
|
73
|
+
start = time.time()
|
|
74
|
+
while time.time() - start < timeout:
|
|
75
|
+
try:
|
|
76
|
+
if urllib.request.urlopen(url, timeout=10).status == 200:
|
|
77
|
+
return True
|
|
78
|
+
except Exception:
|
|
79
|
+
pass
|
|
80
|
+
time.sleep(5)
|
|
81
|
+
return False
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
def open_site():
|
|
85
|
+
try:
|
|
86
|
+
full_name = run(["gh", "repo", "view", "--json", "nameWithOwner", "--jq", ".nameWithOwner"])
|
|
87
|
+
except RuntimeError:
|
|
88
|
+
console.print("[red]❌ This folder isn't on GitHub yet. Run `ship` first.[/]")
|
|
89
|
+
return
|
|
90
|
+
pages = subprocess.run(["gh", "api", f"repos/{full_name}/pages", "--jq", ".html_url"],
|
|
91
|
+
capture_output=True, text=True)
|
|
92
|
+
url = pages.stdout.strip() if pages.returncode == 0 else f"https://github.com/{full_name}"
|
|
93
|
+
console.print(f"Opening {escape(url)}")
|
|
94
|
+
webbrowser.open(url)
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
# ---------- checks ----------
|
|
98
|
+
|
|
99
|
+
def check_readme_exists(folder: Path):
|
|
100
|
+
readme = folder / "README.md"
|
|
101
|
+
if readme.exists():
|
|
102
|
+
return ("ok", "README.md found")
|
|
103
|
+
return ("fail", "No README.md, so add one before shipping")
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
def check_readme_length(folder: Path):
|
|
107
|
+
readme = folder / "README.md"
|
|
108
|
+
if not readme.exists():
|
|
109
|
+
return ("fail", "No README.md, so add one before shipping")
|
|
110
|
+
content = readme.read_text(encoding="utf-8")
|
|
111
|
+
if len(content) < 100:
|
|
112
|
+
return ("fail", "README.md is too short, so add more content before shipping")
|
|
113
|
+
return ("ok", "README.md length is sufficient")
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
def check_readme_instructions(folder: Path):
|
|
117
|
+
readme = folder / "README.md"
|
|
118
|
+
if not readme.exists():
|
|
119
|
+
return ("fail", "No README.md, so add one before shipping")
|
|
120
|
+
lower = readme.read_text(encoding="utf-8").lower()
|
|
121
|
+
keywords = ["setup", "install", "how to run", "usage", "getting started"]
|
|
122
|
+
if any(word in lower for word in keywords):
|
|
123
|
+
return ("ok", "README.md has setup/run instructions")
|
|
124
|
+
return ("warn", "No setup instructions in README, so tell people how to run it")
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
def check_media(folder: Path):
|
|
128
|
+
readme = folder / "README.md"
|
|
129
|
+
if not readme.exists():
|
|
130
|
+
return ("fail", "No README.md")
|
|
131
|
+
lower = readme.read_text(encoding="utf-8").lower()
|
|
132
|
+
markers = ["![", ".png", ".jpg", ".gif", ".mp4", ".webm", "user-attachments", "youtube.com", "youtu.be"]
|
|
133
|
+
if any(m in lower for m in markers):
|
|
134
|
+
return ("ok", "README shows a screenshot or video")
|
|
135
|
+
return ("warn", "No screenshot/video in README, reviewers want to see it working")
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
def check_hostable(folder: Path):
|
|
139
|
+
if (folder / "index.html").exists():
|
|
140
|
+
return ("ok", "index.html found, so GitHub Pages can host this")
|
|
141
|
+
return ("warn", "No index.html, so GitHub Pages won't have a page to show")
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
def check_safety(folder: Path):
|
|
145
|
+
skip = {".git", "node_modules", "venv", ".venv", "__pycache__","demo"}
|
|
146
|
+
secrets = {
|
|
147
|
+
"Google/Firebase API key": r"AIza[0-9A-Za-z_\-]{35}",
|
|
148
|
+
"OpenAI key": r"sk-[A-Za-z0-9_\-]{20,}",
|
|
149
|
+
"GitHub token": r"gh[pousr]_[A-Za-z0-9]{36,}",
|
|
150
|
+
"AWS access key": r"AKIA[0-9A-Z]{16}",
|
|
151
|
+
"Private key": r"-----BEGIN [A-Z ]*PRIVATE KEY-----",
|
|
152
|
+
}
|
|
153
|
+
problems = []
|
|
154
|
+
|
|
155
|
+
for path in folder.rglob("*"):
|
|
156
|
+
rel = path.relative_to(folder)
|
|
157
|
+
if any(skip_dir in rel.parts for skip_dir in skip):
|
|
158
|
+
continue
|
|
159
|
+
if not path.is_file():
|
|
160
|
+
continue
|
|
161
|
+
if path.name == ".env" or (path.name.startswith(".env.") and path.name != ".env.example"):
|
|
162
|
+
problems.append(f".env file: {rel}")
|
|
163
|
+
continue
|
|
164
|
+
if path.stat().st_size > 1_000_000:
|
|
165
|
+
continue
|
|
166
|
+
try:
|
|
167
|
+
content = path.read_text(encoding="utf-8")
|
|
168
|
+
except (UnicodeDecodeError, OSError):
|
|
169
|
+
continue
|
|
170
|
+
for name, pattern in secrets.items():
|
|
171
|
+
if re.search(pattern, content):
|
|
172
|
+
problems.append(f"{name} in {rel}")
|
|
173
|
+
|
|
174
|
+
if problems:
|
|
175
|
+
return ("fail", "Possible secrets found:\n " + "\n ".join(problems))
|
|
176
|
+
return ("ok", "No secrets found")
|
|
177
|
+
|
|
178
|
+
|
|
179
|
+
ALL_CHECKS = [check_readme_exists, check_readme_length, check_readme_instructions,
|
|
180
|
+
check_media, check_hostable, check_safety]
|
|
181
|
+
|
|
182
|
+
|
|
183
|
+
def run_checks(folder: Path):
|
|
184
|
+
return [check(folder) for check in ALL_CHECKS]
|
|
185
|
+
|
|
186
|
+
|
|
187
|
+
def show_results(results):
|
|
188
|
+
for status, message in results:
|
|
189
|
+
console.print(f" {icons[status]} [{colors[status]}]{escape(message)}[/]")
|
|
190
|
+
|
|
191
|
+
|
|
192
|
+
def ready_to_ship(results):
|
|
193
|
+
statuses = [status for status, _ in results]
|
|
194
|
+
if "fail" in statuses:
|
|
195
|
+
console.print("\n[bold red]✋ Fix the ❌ items before shipping.[/]")
|
|
196
|
+
return False
|
|
197
|
+
if "warn" in statuses:
|
|
198
|
+
answer = console.input("\n[yellow]There are warnings. Ship anyway? \\[y/N] [/]")
|
|
199
|
+
return answer.strip().lower() == "y"
|
|
200
|
+
console.print("\n[bold green]All checks passed![/]")
|
|
201
|
+
return True
|
|
202
|
+
|
|
203
|
+
|
|
204
|
+
# ---------- main ----------
|
|
205
|
+
|
|
206
|
+
def main():
|
|
207
|
+
parser = argparse.ArgumentParser(prog="ship", description="Check a project is ready, then publish it to GitHub.")
|
|
208
|
+
parser.add_argument("--version", action="version", version="ship 1.0")
|
|
209
|
+
parser.add_argument("command", nargs="?", default="ship", choices=["ship", "check", "open"], help="what to do (default: ship)")
|
|
210
|
+
parser.add_argument("--private", action="store_true", help="create the GitHub repo as private")
|
|
211
|
+
parser.add_argument("--dry-run", action="store_true", help="see what would happen without changing anything")
|
|
212
|
+
args = parser.parse_args()
|
|
213
|
+
|
|
214
|
+
if args.command == "check":
|
|
215
|
+
console.print("[bold]Checking project...[/]")
|
|
216
|
+
show_results(run_checks(Path.cwd()))
|
|
217
|
+
|
|
218
|
+
elif args.command == "open":
|
|
219
|
+
open_site()
|
|
220
|
+
|
|
221
|
+
else:
|
|
222
|
+
folder = Path.cwd()
|
|
223
|
+
console.print("[bold]Checking project...[/]")
|
|
224
|
+
results = run_checks(folder)
|
|
225
|
+
show_results(results)
|
|
226
|
+
if not ready_to_ship(results) or not basic_check():
|
|
227
|
+
return
|
|
228
|
+
if args.dry_run:
|
|
229
|
+
name = folder.name.lower().replace(" ", "-")
|
|
230
|
+
console.print("\n[bold cyan]Dry run, so nothing will be changed:[/]")
|
|
231
|
+
console.print(f"would commit all files")
|
|
232
|
+
console.print(f"would create repo '{escape(name)}' ({'private' if args.private else 'public'}) and push")
|
|
233
|
+
if (folder / "index.html").exists() and not args.private:
|
|
234
|
+
console.print(f"would enable GitHub Pages at https://<you>.github.io/{escape(name)}/")
|
|
235
|
+
return
|
|
236
|
+
|
|
237
|
+
try:
|
|
238
|
+
with console.status("Committing..."):
|
|
239
|
+
commit_everything(folder)
|
|
240
|
+
with console.status("Pushing to GitHub..."):
|
|
241
|
+
full_name = push_to_github(folder, args.private)
|
|
242
|
+
console.print(f"Repo: https://github.com/{escape(full_name)}")
|
|
243
|
+
|
|
244
|
+
if (folder / "index.html").exists() and not args.private:
|
|
245
|
+
with console.status("Enabling GitHub Pages..."):
|
|
246
|
+
url = host_pages(full_name)
|
|
247
|
+
with console.status("Waiting for the site to go live..."):
|
|
248
|
+
live = wait(url)
|
|
249
|
+
if live:
|
|
250
|
+
console.print(f"\n[bold green]Shipped! {escape(url)}[/]")
|
|
251
|
+
else:
|
|
252
|
+
console.print(f"[yellow]Still deploying, so check in a minute: {escape(url)}[/]")
|
|
253
|
+
else:
|
|
254
|
+
console.print("\n[bold green]Shipped![/]")
|
|
255
|
+
except RuntimeError as e:
|
|
256
|
+
console.print(f"[red]{escape(str(e))}[/]")
|
|
257
|
+
|
|
258
|
+
|
|
259
|
+
if __name__ == "__main__":
|
|
260
|
+
main()
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: ship-gh
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: Check and publish project to github with just one command.
|
|
5
|
+
Author: Shesanth
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/myxghty/shipper
|
|
8
|
+
Requires-Python: >=3.10
|
|
9
|
+
Description-Content-Type: text/markdown
|
|
10
|
+
License-File: LICENSE
|
|
11
|
+
Requires-Dist: rich
|
|
12
|
+
Dynamic: license-file
|
|
13
|
+
|
|
14
|
+
## Shipper
|
|
15
|
+
Shipper is a CLI tool I created to make commiting/creating a repo/hosting simplier and easier. The unique features include checking for a readme, making sure readme has atleast over 200 letters, making sure no secrets such as .env are also commited and with shipper there will be no need for checking and commiting manually.
|
|
16
|
+
|
|
17
|
+
## Cons of shipper
|
|
18
|
+
Shipper cannot write commit messages so they just come out as "ship it" rather than actually stating the change.
|
|
19
|
+
It's still in development so Im expecting a few several errors
|
|
20
|
+
That's about it for shipper everything else shipper takes care of it
|
|
21
|
+
|
|
22
|
+
## How to use
|
|
23
|
+
### 1. Install (one time)
|
|
24
|
+
|
|
25
|
+
You need **Python 3.10+**, **git**, and the **GitHub CLI** (`gh`).
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
pipx install git+https://github.com/myxghty/shipper
|
|
29
|
+
gh auth login
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
> No pipx? replace pipx with pip
|
|
33
|
+
|
|
34
|
+
### 2. Go to your project
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
cd my-project
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
### 3. Check it
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
ship check
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
runs only the checks without commiting:
|
|
47
|
+
|
|
48
|
+
```
|
|
49
|
+
Checking project...
|
|
50
|
+
✅ README.md found
|
|
51
|
+
✅ README.md has setup/run instructions
|
|
52
|
+
⚠️ No screenshot/video in README, reviewers want to see it working
|
|
53
|
+
✅ index.html found, so GitHub Pages can host this
|
|
54
|
+
✅ No secrets found
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
### 4. Ship it
|
|
58
|
+
|
|
59
|
+
```bash
|
|
60
|
+
ship
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
`ship` will:
|
|
64
|
+
1. Run all the checks. **❌ problems stop it**, and for ⚠️ warnings it asks before continuing.
|
|
65
|
+
2. Commit your files.
|
|
66
|
+
3. Create a GitHub repo named after the folder and push your code. If the repo already exists, it just pushes.
|
|
67
|
+
4. Turn on GitHub Pages (if there's an `index.html`).
|
|
68
|
+
5. Wait until the site is live and print the link.
|
|
69
|
+
|
|
70
|
+
```
|
|
71
|
+
Shipped! https://yourname.github.io/my-project/
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
### Commands
|
|
75
|
+
|
|
76
|
+
| Command | What it does |
|
|
77
|
+
|---|---|
|
|
78
|
+
| `ship` | Check, then publish to GitHub + Pages |
|
|
79
|
+
| `ship check` | Only run the checks |
|
|
80
|
+
| `ship open` | Open the live site (or the repo) in your browser |
|
|
81
|
+
| `ship --private` | Publish as a private repo (Pages is skipped) |
|
|
82
|
+
| `ship --help` | Show help |
|
|
83
|
+
|
|
84
|
+
## Try it in seconds
|
|
85
|
+
1. Click **Open in Codespaces** below
|
|
86
|
+
2. In the terminal:
|
|
87
|
+
```bash
|
|
88
|
+
pip install -e .
|
|
89
|
+
cd demo
|
|
90
|
+
ship check
|
|
91
|
+
ship --dry-run
|
|
92
|
+
```
|
|
93
|
+
[](https://codespaces.new/myxghty/shipper)
|
|
94
|
+
|
|
95
|
+
## AI Disclosue
|
|
96
|
+
AI was used in assissting for the making of the git commands.
|
|
97
|
+
|
|
98
|
+
Made by [Shesanth M](https://github.com/myxghty)
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
LICENSE
|
|
2
|
+
README.md
|
|
3
|
+
pyproject.toml
|
|
4
|
+
ship/__init__.py
|
|
5
|
+
ship/cli.py
|
|
6
|
+
ship_gh.egg-info/PKG-INFO
|
|
7
|
+
ship_gh.egg-info/SOURCES.txt
|
|
8
|
+
ship_gh.egg-info/dependency_links.txt
|
|
9
|
+
ship_gh.egg-info/entry_points.txt
|
|
10
|
+
ship_gh.egg-info/requires.txt
|
|
11
|
+
ship_gh.egg-info/top_level.txt
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
rich
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
ship
|