Skip to content

Commit 46fa189

Browse files
authored
feat: mvp (#1)
* wip: docker based suite * wip: worker based plugins * wip: installation * wip: shimmy shim shim * feat: ambient access plugs * feat: plugin deps * feat: wasmedge, lib/include shims support and globs * feat(plug): pnpm * feat(plug): cargo-instal and wasm-tools * feat(plug): wasm-opt & cargo-insta * feat(ci): e2e tests and some new plugs * wip: asdf plug support * fix: missing changes * feat(core): asdf support * fix: formatting * fix(tests): disable asdf-python * feat(plug): protoc * feat(tests): `protoc` * refactor(hooks): move to bash-preexec * fix(hooks): `init_ghjk` directly in hooks.sh * feat(plug): earthly * fix: change installId format to something less problematic * feat(plug): ruff * feat(plug): whiz * refactor: native js `unarchive` * fix: use zipjs * fix: better `unarchive` * fix: get tests working * fix: address feedback * fix: remove dead code * refactor: `install.ts` -> `setup.ts` * refactor: `setup.ts` -> `init.ts` * wip: `modules` * wip: `plugs` -> `ports` * refactor: big un * fix: apply feedback * fix: pin debian pkg versions for test dockerfile * fix: back to aliases and zsh support * refactor(hooks): explicit bash command * feat(ci): ghjk action * fix(ci): missing shell prop * fix(action): improve outputs * refactor: make hooks more efficient
1 parent 56343d4 commit 46fa189

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

80 files changed

+5655
-725
lines changed

.dockerignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
.git
2+
.vscode
3+
tests/
4+
*.md

.github/pull_request_template.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<!--
2+
Pull requests are squash merged using:
3+
- their title as the commit message
4+
- their description as the commit body
5+
6+
Having a good title and description is important for the users to get readable changelog and understand when they need to update his code and how.
7+
-->
8+
9+
### Describe your change
10+
11+
<!-- Explain WHAT the change is -->
12+
13+
### Motivation and context
14+
15+
<!-- Explain WHY the was made or link an issue number -->
16+
17+
### Migration notes
18+
19+
<!-- Explain HOW users should update their code when required -->
20+
21+
### Checklist
22+
23+
- [ ] The change come with new or modified tests
24+
- [ ] Hard-to-understand functions have explanatory comments
25+
- [ ] End-user documentation is updated to reflect the change

.github/workflows/autoupdate.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
on:
2+
schedule:
3+
- cron: "0 2 1 * *"
4+
workflow_dispatch:
5+
6+
jobs:
7+
auto-update:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- uses: actions/checkout@v4
11+
- uses: actions/setup-python@v4
12+
- uses: browniebroke/pre-commit-autoupdate-action@main
13+
- uses: peter-evans/create-pull-request@v5
14+
with:
15+
token: ${{ secrets.GITHUB_TOKEN }}
16+
branch: update/pre-commit-hooks
17+
title: Update pre-commit hooks
18+
commit-message: "chore: update pre-commit hooks"
19+
body: Update versions of pre-commit hooks to latest version.

.github/workflows/pr-title-check.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
on:
2+
pull_request_target:
3+
types:
4+
- opened
5+
- edited
6+
- synchronize
7+
- ready_for_review
8+
9+
jobs:
10+
check:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: amannn/action-semantic-pull-request@v5
14+
env:
15+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/tests.yml

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
on:
2+
push:
3+
branches:
4+
- main
5+
pull_request:
6+
types:
7+
- opened
8+
- synchronize
9+
- ready_for_review
10+
11+
env:
12+
DENO_VERSION: "1.38.2"
13+
14+
jobs:
15+
changes:
16+
runs-on: ubuntu-latest
17+
permissions:
18+
pull-requests: read
19+
steps:
20+
- uses: actions/checkout@v4
21+
22+
test-pre-commit:
23+
runs-on: ubuntu-latest
24+
steps:
25+
- uses: actions/checkout@v4
26+
- uses: denoland/setup-deno@v1
27+
with:
28+
deno-version: ${{ env.DENO_VERSION }}
29+
- uses: pre-commit/[email protected]
30+
31+
test-e2e:
32+
runs-on: ubuntu-latest
33+
steps:
34+
- uses: actions/checkout@v4
35+
- uses: denoland/setup-deno@v1
36+
with:
37+
deno-version: ${{ env.DENO_VERSION }}
38+
- uses: docker/setup-buildx-action@v3
39+
- uses: actions-hub/docker/cli@master
40+
env:
41+
SKIP_LOGIN: true
42+
- run: deno task test
43+
44+
test-action:
45+
runs-on: ubuntu-latest
46+
steps:
47+
- uses: actions/checkout@v4
48+
- uses: denoland/setup-deno@v1
49+
with:
50+
deno-version: ${{ env.DENO_VERSION }}
51+
- uses: ./
52+
id: ghjk-action
53+
env:
54+
GHJK_CONFIG: ./examples/protoc/ghjk.ts
55+
- shell: bash
56+
run: |
57+
cd examples/protoc
58+
. $BASH_ENV
59+
protoc --version

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
.DS_Store
2+
play.ts

.pre-commit-config.yaml

Lines changed: 9 additions & 104 deletions
Original file line numberDiff line numberDiff line change
@@ -13,133 +13,38 @@ repos:
1313
- id: check-merge-conflict
1414
- id: end-of-file-fixer
1515
# exclude all generated files
16-
exclude: (typegate/deno.lock|.*\.snap$|typegate/src/typegraphs/.*\.json|website/docs/reference/)
16+
exclude: (deno.lock)
1717
- repo: https://github.com/python-jsonschema/check-jsonschema
1818
rev: 0.27.0
1919
hooks:
2020
- id: check-dependabot
2121
- id: check-github-workflows
22-
- repo: https://github.com/charliermarsh/ruff-pre-commit
23-
rev: "v0.0.292"
24-
hooks:
25-
- id: ruff
26-
- repo: https://github.com/psf/black
27-
rev: 23.9.1
28-
hooks:
29-
- id: black
3022
- repo: https://github.com/commitizen-tools/commitizen
3123
rev: 3.10.0
3224
hooks:
3325
- id: commitizen
3426
stages:
3527
- commit-msg
36-
- repo: https://github.com/doublify/pre-commit-rust
37-
rev: v1.0
38-
hooks:
39-
- id: fmt
40-
- id: cargo-check
41-
args:
42-
- "--locked"
43-
- id: clippy
44-
args:
45-
- "--locked"
46-
- "--"
47-
- "--deny"
48-
- "warnings"
4928
- repo: local
5029
hooks:
5130
- id: deno-fmt
5231
name: Deno format
5332
language: system
54-
entry: bash -c 'cd typegate && deno fmt --ignore=native,src/typegraphs,tmp && cd ../dev && deno fmt'
33+
entry: bash -c 'deno fmt'
5534
pass_filenames: false
5635
types:
5736
- ts
58-
files: ^(typegate|dev)/
59-
- id: deno-lint
60-
name: Deno lint
37+
- id: deno-check
38+
name: Deno check
6139
language: system
62-
entry: bash -c 'cd typegate && deno lint --rules-exclude=no-explicit-any --ignore=native,tmp && cd ../dev && deno lint'
40+
entry: bash -c 'deno task check'
6341
pass_filenames: false
6442
types:
6543
- ts
66-
files: ^(typegate|dev)/
67-
- id: es-lint
68-
name: Eslint
69-
language: system
70-
entry: bash -c 'cd website && [ -f node_modules/.bin/eslint ] && pnpm lint'
71-
pass_filenames: false
72-
types_or:
73-
- ts
74-
- tsx
75-
files: ^website/
76-
- id: version
77-
name: "Lock versions"
78-
always_run: true
44+
- id: deno-lint
45+
name: Deno lint
7946
language: system
80-
entry: bash -c 'deno run -A dev/lock.ts --check'
47+
entry: bash -c 'deno task lint'
8148
pass_filenames: false
82-
- repo: https://github.com/Lucas-C/pre-commit-hooks
83-
rev: v1.5.4
84-
hooks:
85-
- id: insert-license
86-
name: "License MPL-2.0 python"
87-
args:
88-
#- --remove-header
89-
- --license-filepath=dev/license-header-MPL-2.0.txt
90-
- "--comment-style=#"
91-
- "--skip-license-insertion-comment=no-auto-license-header"
92-
types_or:
93-
- python
94-
files: ^typegraph/
95-
- id: insert-license
96-
name: "License Elastic-2.0 rust"
97-
args:
98-
#- --remove-header
99-
- --license-filepath=dev/license-header-Elastic-2.0.txt
100-
- "--comment-style=//"
101-
- "--skip-license-insertion-comment=no-auto-license-header"
102-
types_or:
103-
- rust
104-
files: ^(typegate|libs)/
105-
- id: insert-license
106-
name: "License MPL-2.0 rust"
107-
args:
108-
#- --remove-header
109-
- --license-filepath=dev/license-header-MPL-2.0.txt
110-
- "--comment-style=//"
111-
- "--skip-license-insertion-comment=no-auto-license-header"
112-
types_or:
113-
- rust
114-
files: ^(meta-cli|typegraph)/
115-
- id: insert-license
116-
name: "License Elastic-2.0 deno"
117-
args:
118-
#- --remove-header
119-
- --license-filepath=dev/license-header-Elastic-2.0.txt
120-
- "--comment-style=//"
121-
- "--skip-license-insertion-comment=no-auto-license-header"
122-
types_or:
123-
- ts
124-
files: ^(typegate|dev)/
125-
- id: insert-license
126-
name: "License MPL-2.0 deno"
127-
args:
128-
#- --remove-header
129-
- --license-filepath=dev/license-header-MPL-2.0.txt
130-
- "--comment-style=//"
131-
- "--skip-license-insertion-comment=no-auto-license-header"
132-
types_or:
133-
- ts
134-
files: ^typegraph/
135-
- id: insert-license
136-
name: "License Elastic-2.0 typescript"
137-
args:
138-
#- --remove-header
139-
- --license-filepath=dev/license-header-Elastic-2.0.txt
140-
- "--comment-style=//"
141-
- "--skip-license-insertion-comment=no-auto-license-header"
142-
types_or:
49+
types:
14350
- ts
144-
- tsx
145-
files: ^website/

.vscode/settings.json

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"deno.enablePaths": [
3-
".",
3+
"."
44
],
55
"deno.suggest.completeFunctionCalls": true,
66
"deno.inlayHints.variableTypes.enabled": true,
@@ -16,5 +16,8 @@
1616
"deno.codeLens.referencesAllFunctions": true,
1717
"[typescript]": {
1818
"editor.defaultFormatter": "denoland.vscode-deno"
19-
}
20-
}
19+
},
20+
"cSpell.words": [
21+
"ghjk"
22+
]
23+
}

LICENSE.md renamed to LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,7 @@ Exhibit A - Source Code Form License Notice
357357

358358
This Source Code Form is subject to the terms of the Mozilla Public
359359
License, v. 2.0. If a copy of the MPL was not distributed with this
360-
file, You can obtain one at http://mozilla.org/MPL/2.0/.
360+
file, You can obtain one at https://mozilla.org/MPL/2.0/.
361361

362362
If it is not possible or desirable to put the notice in a particular
363363
file, then You may include the notice in a location (such as a LICENSE

README.md

Lines changed: 35 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,23 @@ ghjk (jk) is a programmable runtime manager.
55
## Features
66

77
- install and manage tools (e.g. rustup, deno, node, etc.)
8-
- fuzzy match the version
8+
- [ ] fuzzy match the version
99
- support dependencies between tools
10-
- setup runtime helpers (e.g. pre-commit, linting, ignore, etc.)
11-
- provide a general regex based lockfile
10+
- [ ] setup runtime helpers (e.g. pre-commit, linting, ignore, etc.)
11+
- [ ] provide a general regex based lockfile
1212
- enforce custom rules
13-
- create aliases and shortcuts
13+
- [ ] create aliases and shortcuts
1414
- `meta` -> `cargo run -p meta`
1515
- `x meta` -> `cargo run -p meta` (avoid conflicts and provide autocompletion)
16-
- load environment variables and prompt for missing ones
17-
- define build tasks with dependencies
16+
- [ ] load environment variables and prompt for missing ones
17+
- [ ] define build tasks with dependencies
1818
- `task("build", {depends_on: [rust], if: Deno.build.os === "Macos" })`
1919
- `task.bash("ls")`
20-
- compatible with continuous integration (e.g. github actions, gitlab)
20+
- [x] compatible with continuous integration (e.g. github actions, gitlab)
2121

2222
## Getting started
2323

24-
Install the hooks:
24+
Install ghjk:
2525

2626
```bash
2727
deno run -A https://raw.githubusercontent.com/metatypedev/ghjk/main/install.ts
@@ -31,6 +31,7 @@ In your project, create a configuration file `ghjk.ts`:
3131

3232
```ts
3333
export { ghjk } from "https://raw.githubusercontent.com/metatypedev/ghjk/main/mod.ts";
34+
import node from "https://raw.githubusercontent.com/metatypedev/ghjk/ports/node.ts";
3435

3536
node({ version: "14.17.0" });
3637
```
@@ -46,18 +47,19 @@ and looks as follows (abstracting away some implementation details):
4647
- `.config/fish/config.fish`
4748
- for every visited directory, the hook looks for `$PWD/ghjk.ts` in the
4849
directory or its parents, and
49-
- adds the `$HOME/.local/share/ghjk/shims/$PWD` to your `$PATH`
50-
- sources environment variables in `$HOME/.local/share/ghjk/shims/$PWD/loader`
51-
and clear previously loaded ones (if any)
52-
- defines an alias `ghjk` running `deno run -A $PWD/ghjk.ts`
50+
- adds the `$HOME/.local/share/ghjk/envs/$PWD/shims/{bin,lib,include}` to your
51+
paths
52+
- sources environment variables in
53+
`$HOME/.local/share/ghjk/envs/$PWD/loader.{sh,fish}` and clear previously
54+
loaded ones (if any)
5355
- you can then
54-
- sync your runtime with `ghjk sync` which
55-
- installs the missing tools at `$HOME/.local/share/ghjk/installs`
56+
- sync your runtime with `ghjk ports sync` which
57+
- installs the missing tools at `$HOME/.local/share/ghjk/envs/$PWD/installs`
5658
- regenerates the shims with symlinks and environment variables
5759
- detects any violation of the enforced rules
58-
- `ghjk list`: list installed tools and versions
59-
- `ghjk outdated`: list outdated tools
60-
- `ghjk cleanup`: remove unused tools and versions
60+
- [ ] `ghjk list`: list installed tools and versions
61+
- [ ] `ghjk outdated`: list outdated tools
62+
- [ ]`ghjk cleanup`: remove unused tools and versions
6163

6264
## Extending `ghjk`
6365

@@ -66,10 +68,20 @@ and looks as follows (abstracting away some implementation details):
6668

6769
## todo
6870

69-
- multiple version of the same package (e.g. rust stable and rust nightly)
70-
- wasmedge
71-
- python with virtual env dir
72-
- poetry
73-
- pnpm
74-
- mold({ if: Deno.build.os === "Macos" })
71+
- multiple version of the same package (e.g. rust stable and rust nighted)
72+
- [x] wasmedge
73+
- [x] jco
74+
- [ ] python with virtual env dir
75+
- poetry
76+
- pre-commit
77+
- [x] pnpm
78+
- [x] mold
79+
- [x] wasm-tools
80+
- [x] cargo-insta
7581
- hash verifiable dependencies (timestamp)
82+
- hide the `Deno` object in an abstraction
83+
- support windows
84+
- [ ] installation tools
85+
- [ ] untar
86+
- [ ] xz
87+
- [ ] git

0 commit comments

Comments
 (0)