Skip to content

Commit 025191a

Browse files
committed
👍 First commit
1 parent 3f2e91c commit 025191a

11 files changed

+423
-0
lines changed

.github/workflows/jsr.yml

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: jsr
2+
3+
env:
4+
DENO_VERSION: 1.x
5+
6+
on:
7+
push:
8+
tags:
9+
- "v*"
10+
11+
permissions:
12+
contents: read
13+
id-token: write
14+
15+
jobs:
16+
publish:
17+
runs-on: ubuntu-latest
18+
steps:
19+
- uses: actions/checkout@v4
20+
with:
21+
fetch-depth: 0
22+
- uses: denoland/setup-deno@v1
23+
with:
24+
deno-version: ${{ env.DENO_VERSION }}
25+
- name: Publish
26+
run: |
27+
deno run -A jsr:@david/publish-on-tag@0.1.3

.github/workflows/test.yml

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: Test
2+
3+
env:
4+
DENO_VERSION: 1.x
5+
6+
on:
7+
push:
8+
branches:
9+
- main
10+
pull_request:
11+
workflow_dispatch:
12+
13+
jobs:
14+
check:
15+
runs-on: ubuntu-latest
16+
steps:
17+
- uses: actions/checkout@v4
18+
- uses: denoland/setup-deno@v1
19+
with:
20+
deno-version: ${{ env.DENO_VERSION }}
21+
- name: Format
22+
run: |
23+
deno fmt --check
24+
- name: Lint
25+
run: deno lint
26+
- name: Type check
27+
run: deno task check
28+
29+
test:
30+
runs-on: ubuntu-latest
31+
steps:
32+
- uses: actions/checkout@v4
33+
with:
34+
fetch-depth: 0
35+
- uses: denoland/setup-deno@v1
36+
with:
37+
deno-version: ${{ env.DENO_VERSION }}
38+
- name: Test
39+
run: |
40+
deno task test
41+
timeout-minutes: 5
42+
- name: JSR publish (dry-run)
43+
run: |
44+
deno publish --dry-run

.github/workflows/udd.yml

+50
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
name: Update
2+
3+
on:
4+
schedule:
5+
- cron: "0 0 * * *"
6+
workflow_dispatch:
7+
8+
jobs:
9+
udd:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v3
13+
- uses: denoland/setup-deno@v1
14+
with:
15+
deno-version: "1.x"
16+
- name: Update dependencies
17+
run: |
18+
deno task upgrade > ../output.txt
19+
env:
20+
NO_COLOR: 1
21+
- name: Read ../output.txt
22+
id: log
23+
uses: juliangruber/read-file-action@v1
24+
with:
25+
path: ../output.txt
26+
- name: Commit changes
27+
run: |
28+
git config user.name '${{ github.actor }}'
29+
git config user.email '${{ github.actor }}@users.noreply.github.com'
30+
git commit -a -F- <<EOM
31+
:package: Update Deno dependencies
32+
33+
Update dependencies by udd:
34+
35+
${{ steps.log.outputs.content }}
36+
37+
EOM
38+
- uses: peter-evans/create-pull-request@v4
39+
with:
40+
title: ":package: Update Deno dependencies"
41+
body: |
42+
The output of `make update` is
43+
44+
```
45+
${{ steps.log.outputs.content }}
46+
```
47+
labels: automation
48+
branch: automation/update-dependencies
49+
delete-branch: true
50+
token: "${{ secrets.PA_TOKEN }}"

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/npm
2+
deno.lock

.gitmessage

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
2+
3+
# Guide (v1.0)
4+
#
5+
# 👍 :+1: Apply changes.
6+
#
7+
# 🌿 :herb: Add or update things for tests.
8+
# ☕ :coffee: Add or update things for developments.
9+
# 📦 :package: Add or update dependencies.
10+
# 📝 :memo: Add or update documentations.
11+
#
12+
# 🐛 :bug: Bugfixes.
13+
# 💋 :kiss: Critical hotfixes.
14+
# 🚿 :shower: Remove features, codes, or files.
15+
#
16+
# 🚀 :rocket: Improve performance.
17+
# 💪 :muscle: Refactor codes.
18+
# 💥 :boom: Breaking changes.
19+
# 💩 :poop: Bad codes needs to be improved.
20+
#
21+
# How to use:
22+
# git config commit.template .gitmessage
23+
#
24+
# Reference:
25+
# https://github.com/lambdalisue/emojiprefix

LICENSE

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
Copyright 2024 Alisue <lambdalisue@gmail.com>
2+
3+
Permission is hereby granted, free of charge, to any person obtaining a copy
4+
of this software and associated documentation files (the "Software"), to deal
5+
in the Software without restriction, including without limitation the rights
6+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7+
copies of the Software, and to permit persons to whom the Software is
8+
furnished to do so, subject to the following conditions:
9+
10+
The above copyright notice and this permission notice shall be included in all
11+
copies or substantial portions of the Software.
12+
13+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19+
SOFTWARE.
20+

README.md

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# 🪨 ogh
2+
3+
[![jsr](https://img.shields.io/jsr/v/%40lambdalisue/ogh?logo=javascript&logoColor=white)](https://jsr.io/@lambdalisue/ogh)
4+
[![Test](https://github.com/lambdalisue/ogh/workflows/Test/badge.svg)](https://github.com/lambdalisue/ogh/actions?query=workflow%3ATest)
5+
6+
Organize GitHub repositories. Similar to [`ghq`] but use [`gh`] command
7+
internally and options are limited.
8+
9+
[`ghq`]: https://github.com/x-motemen/ghq
10+
[`gh`]: https://github.com/cli/cli
11+
12+
## Usage
13+
14+
```console
15+
$ ogh root
16+
#=> Print the root directory of the ogh root
17+
18+
$ ogh list
19+
#=> Print the list of the repositories in the ogh root
20+
21+
$ ogh clone dotfiles
22+
#=> Clone the "dotfiles" repository of the authenticated user into the ogh root
23+
24+
$ ogh clone denoland/deno_std
25+
#=> Clone the "denoland/deno_std" repository into the ogh root
26+
```
27+
28+
## Install
29+
30+
Use `deno install` command to install the command.
31+
32+
```console
33+
$ deno install --allow-net --allow-run --allow-read jsr:@lambdalisue/ogh
34+
```
35+
36+
Then use it as `ogh` like
37+
38+
```console
39+
$ ogh --help
40+
```
41+
42+
## License
43+
44+
The code follows MIT license written in [LICENSE](./LICENSE). Contributors need
45+
to agree that any modifications sent in this repository follow the license.

deno.jsonc

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"name": "@lambdalisue/ogh",
3+
"version": "0.0.0",
4+
"exports": "./mod.ts",
5+
"tasks": {
6+
"test": "deno test -A --parallel --doc",
7+
"check": "deno check **/*.ts"
8+
},
9+
"imports": {
10+
"@core/unknownutil": "jsr:@core/unknownutil@^3.18.0",
11+
"@std/flags": "jsr:@std/flags@^0.224.0",
12+
"@std/fs": "jsr:@std/fs@^0.224.0",
13+
"@std/path": "jsr:@std/path@^0.224.0"
14+
}
15+
}

mod.ts

+68
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
#!/usr/bin/env -S deno run --allow-run --allow-read --allow-env
2+
import { parse } from "@std/flags";
3+
import { ensure, is } from "@core/unknownutil";
4+
import * as ogh from "./ogh.ts";
5+
6+
async function main(args: string[]): Promise<void> {
7+
const opts = parse(args, {
8+
boolean: [
9+
"json",
10+
"help",
11+
],
12+
alias: {
13+
"help": ["h"],
14+
},
15+
});
16+
if (opts.help) {
17+
const resp = await fetch(new URL("./usage.txt", import.meta.url));
18+
const text = await resp.text();
19+
console.log(text);
20+
return;
21+
}
22+
23+
const config = await ogh.getConfig();
24+
const command = ensure(opts._.at(0), is.String, {
25+
message: "<command> must be a string",
26+
});
27+
switch (command) {
28+
case "root": {
29+
if (opts.json) {
30+
console.log(JSON.stringify(config.root.href));
31+
} else {
32+
console.log(config.root.href);
33+
}
34+
break;
35+
}
36+
case "list": {
37+
const repositories = await ogh.list(config);
38+
if (opts.json) {
39+
console.log(JSON.stringify(repositories));
40+
} else {
41+
console.log(repositories.join("\n"));
42+
}
43+
break;
44+
}
45+
case "clone": {
46+
const repository = ensure(opts._.at(1), is.String, {
47+
message: "[<owner>/]<repo> must be a string",
48+
});
49+
await ogh.clone(repository, config);
50+
break;
51+
}
52+
default:
53+
throw new Error(`Unknown command: ${command}`);
54+
}
55+
}
56+
57+
if (import.meta.main) {
58+
try {
59+
await main(Deno.args);
60+
} catch (err) {
61+
if (err instanceof Error) {
62+
console.error(err.message);
63+
} else {
64+
console.error(err);
65+
}
66+
Deno.exit(1);
67+
}
68+
}

0 commit comments

Comments
 (0)