Skip to content

Commit

Permalink
feat: mvp (#1)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
Yohe-Am authored Dec 5, 2023
1 parent 56343d4 commit 46fa189
Show file tree
Hide file tree
Showing 80 changed files with 5,655 additions and 725 deletions.
4 changes: 4 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.git
.vscode
tests/
*.md
25 changes: 25 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<!--
Pull requests are squash merged using:
- their title as the commit message
- their description as the commit body
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.
-->

### Describe your change

<!-- Explain WHAT the change is -->

### Motivation and context

<!-- Explain WHY the was made or link an issue number -->

### Migration notes

<!-- Explain HOW users should update their code when required -->

### Checklist

- [ ] The change come with new or modified tests
- [ ] Hard-to-understand functions have explanatory comments
- [ ] End-user documentation is updated to reflect the change
19 changes: 19 additions & 0 deletions .github/workflows/autoupdate.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
on:
schedule:
- cron: "0 2 1 * *"
workflow_dispatch:

jobs:
auto-update:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
- uses: browniebroke/pre-commit-autoupdate-action@main
- uses: peter-evans/create-pull-request@v5
with:
token: ${{ secrets.GITHUB_TOKEN }}
branch: update/pre-commit-hooks
title: Update pre-commit hooks
commit-message: "chore: update pre-commit hooks"
body: Update versions of pre-commit hooks to latest version.
15 changes: 15 additions & 0 deletions .github/workflows/pr-title-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
on:
pull_request_target:
types:
- opened
- edited
- synchronize
- ready_for_review

jobs:
check:
runs-on: ubuntu-latest
steps:
- uses: amannn/action-semantic-pull-request@v5
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
59 changes: 59 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
on:
push:
branches:
- main
pull_request:
types:
- opened
- synchronize
- ready_for_review

env:
DENO_VERSION: "1.38.2"

jobs:
changes:
runs-on: ubuntu-latest
permissions:
pull-requests: read
steps:
- uses: actions/checkout@v4

test-pre-commit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: denoland/setup-deno@v1
with:
deno-version: ${{ env.DENO_VERSION }}
- uses: pre-commit/[email protected]

test-e2e:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: denoland/setup-deno@v1
with:
deno-version: ${{ env.DENO_VERSION }}
- uses: docker/setup-buildx-action@v3
- uses: actions-hub/docker/cli@master
env:
SKIP_LOGIN: true
- run: deno task test

test-action:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: denoland/setup-deno@v1
with:
deno-version: ${{ env.DENO_VERSION }}
- uses: ./
id: ghjk-action
env:
GHJK_CONFIG: ./examples/protoc/ghjk.ts
- shell: bash
run: |
cd examples/protoc
. $BASH_ENV
protoc --version
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
.DS_Store
play.ts
113 changes: 9 additions & 104 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,133 +13,38 @@ repos:
- id: check-merge-conflict
- id: end-of-file-fixer
# exclude all generated files
exclude: (typegate/deno.lock|.*\.snap$|typegate/src/typegraphs/.*\.json|website/docs/reference/)
exclude: (deno.lock)
- repo: https://github.com/python-jsonschema/check-jsonschema
rev: 0.27.0
hooks:
- id: check-dependabot
- id: check-github-workflows
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: "v0.0.292"
hooks:
- id: ruff
- repo: https://github.com/psf/black
rev: 23.9.1
hooks:
- id: black
- repo: https://github.com/commitizen-tools/commitizen
rev: 3.10.0
hooks:
- id: commitizen
stages:
- commit-msg
- repo: https://github.com/doublify/pre-commit-rust
rev: v1.0
hooks:
- id: fmt
- id: cargo-check
args:
- "--locked"
- id: clippy
args:
- "--locked"
- "--"
- "--deny"
- "warnings"
- repo: local
hooks:
- id: deno-fmt
name: Deno format
language: system
entry: bash -c 'cd typegate && deno fmt --ignore=native,src/typegraphs,tmp && cd ../dev && deno fmt'
entry: bash -c 'deno fmt'
pass_filenames: false
types:
- ts
files: ^(typegate|dev)/
- id: deno-lint
name: Deno lint
- id: deno-check
name: Deno check
language: system
entry: bash -c 'cd typegate && deno lint --rules-exclude=no-explicit-any --ignore=native,tmp && cd ../dev && deno lint'
entry: bash -c 'deno task check'
pass_filenames: false
types:
- ts
files: ^(typegate|dev)/
- id: es-lint
name: Eslint
language: system
entry: bash -c 'cd website && [ -f node_modules/.bin/eslint ] && pnpm lint'
pass_filenames: false
types_or:
- ts
- tsx
files: ^website/
- id: version
name: "Lock versions"
always_run: true
- id: deno-lint
name: Deno lint
language: system
entry: bash -c 'deno run -A dev/lock.ts --check'
entry: bash -c 'deno task lint'
pass_filenames: false
- repo: https://github.com/Lucas-C/pre-commit-hooks
rev: v1.5.4
hooks:
- id: insert-license
name: "License MPL-2.0 python"
args:
#- --remove-header
- --license-filepath=dev/license-header-MPL-2.0.txt
- "--comment-style=#"
- "--skip-license-insertion-comment=no-auto-license-header"
types_or:
- python
files: ^typegraph/
- id: insert-license
name: "License Elastic-2.0 rust"
args:
#- --remove-header
- --license-filepath=dev/license-header-Elastic-2.0.txt
- "--comment-style=//"
- "--skip-license-insertion-comment=no-auto-license-header"
types_or:
- rust
files: ^(typegate|libs)/
- id: insert-license
name: "License MPL-2.0 rust"
args:
#- --remove-header
- --license-filepath=dev/license-header-MPL-2.0.txt
- "--comment-style=//"
- "--skip-license-insertion-comment=no-auto-license-header"
types_or:
- rust
files: ^(meta-cli|typegraph)/
- id: insert-license
name: "License Elastic-2.0 deno"
args:
#- --remove-header
- --license-filepath=dev/license-header-Elastic-2.0.txt
- "--comment-style=//"
- "--skip-license-insertion-comment=no-auto-license-header"
types_or:
- ts
files: ^(typegate|dev)/
- id: insert-license
name: "License MPL-2.0 deno"
args:
#- --remove-header
- --license-filepath=dev/license-header-MPL-2.0.txt
- "--comment-style=//"
- "--skip-license-insertion-comment=no-auto-license-header"
types_or:
- ts
files: ^typegraph/
- id: insert-license
name: "License Elastic-2.0 typescript"
args:
#- --remove-header
- --license-filepath=dev/license-header-Elastic-2.0.txt
- "--comment-style=//"
- "--skip-license-insertion-comment=no-auto-license-header"
types_or:
types:
- ts
- tsx
files: ^website/
9 changes: 6 additions & 3 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"deno.enablePaths": [
".",
"."
],
"deno.suggest.completeFunctionCalls": true,
"deno.inlayHints.variableTypes.enabled": true,
Expand All @@ -16,5 +16,8 @@
"deno.codeLens.referencesAllFunctions": true,
"[typescript]": {
"editor.defaultFormatter": "denoland.vscode-deno"
}
}
},
"cSpell.words": [
"ghjk"
]
}
2 changes: 1 addition & 1 deletion LICENSE.md → LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ Exhibit A - Source Code Form License Notice

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

If it is not possible or desirable to put the notice in a particular
file, then You may include the notice in a location (such as a LICENSE
Expand Down
58 changes: 35 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,23 @@ ghjk (jk) is a programmable runtime manager.
## Features

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

## Getting started

Install the hooks:
Install ghjk:

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

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

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

## Extending `ghjk`

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

## todo

- multiple version of the same package (e.g. rust stable and rust nightly)
- wasmedge
- python with virtual env dir
- poetry
- pnpm
- mold({ if: Deno.build.os === "Macos" })
- multiple version of the same package (e.g. rust stable and rust nighted)
- [x] wasmedge
- [x] jco
- [ ] python with virtual env dir
- poetry
- pre-commit
- [x] pnpm
- [x] mold
- [x] wasm-tools
- [x] cargo-insta
- hash verifiable dependencies (timestamp)
- hide the `Deno` object in an abstraction
- support windows
- [ ] installation tools
- [ ] untar
- [ ] xz
- [ ] git
Loading

0 comments on commit 46fa189

Please sign in to comment.