mirror of
https://github.com/foomo/posh.git
synced 2025-10-16 12:45:38 +00:00
Compare commits
6 Commits
68b1491a6d
...
09dec1320f
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
09dec1320f | ||
|
|
4743cc08cc | ||
|
|
6bd3e40e5d | ||
|
|
3d66e427c9 | ||
|
|
ef3e93d992 | ||
|
|
d2619ef68b |
4
.github/workflows/test.yml
vendored
4
.github/workflows/test.yml
vendored
@ -4,6 +4,7 @@ on:
|
||||
push:
|
||||
branches: [ main ]
|
||||
pull_request:
|
||||
merge_group:
|
||||
workflow_dispatch:
|
||||
|
||||
permissions:
|
||||
@ -31,6 +32,9 @@ jobs:
|
||||
with:
|
||||
install-mode: none
|
||||
|
||||
- name: Run tidy
|
||||
run: make tidy && git diff --exit-code
|
||||
|
||||
- name: Run lint
|
||||
run: make lint
|
||||
|
||||
|
||||
@ -1,7 +1,8 @@
|
||||
# https://golangci-lint.run/usage/configuration/
|
||||
version: "2"
|
||||
|
||||
run:
|
||||
build-tags: [safe]
|
||||
build-tags: [ safe ]
|
||||
modules-download-mode: readonly
|
||||
|
||||
linters:
|
||||
|
||||
@ -12,6 +12,7 @@ builds:
|
||||
env:
|
||||
- CGO_ENABLED=0
|
||||
flags:
|
||||
- -trimpath
|
||||
- -tags=safe
|
||||
ldflags:
|
||||
- -s -w
|
||||
@ -60,7 +61,7 @@ dockers:
|
||||
- '--pull'
|
||||
# https://github.com/opencontainers/image-spec/blob/main/annotations.md#pre-defined-annotation-keys
|
||||
- '--label=org.opencontainers.image.title={{.ProjectName}}'
|
||||
- '--label=org.opencontainers.image.description=CLI utility manage infrastructure as code with helm'
|
||||
- '--label=org.opencontainers.image.description=Project Oriented SHELL (posh)'
|
||||
- '--label=org.opencontainers.image.source={{.GitURL}}'
|
||||
- '--label=org.opencontainers.image.url={{.GitURL}}'
|
||||
- '--label=org.opencontainers.image.documentation={{.GitURL}}'
|
||||
|
||||
19
Makefile
19
Makefile
@ -32,8 +32,8 @@ endif
|
||||
### Tasks
|
||||
|
||||
.PHONY: check
|
||||
## Run tests and linters
|
||||
check: tidy lint test
|
||||
## Run lint & test
|
||||
check: tidy lint test test.demo
|
||||
|
||||
.PHONY: tidy
|
||||
## Run go mod tidy
|
||||
@ -46,7 +46,7 @@ lint:
|
||||
@golangci-lint run
|
||||
|
||||
.PHONY: lint.fix
|
||||
## Fix lint violations
|
||||
## Run linter and fix
|
||||
lint.fix:
|
||||
@golangci-lint run --fix
|
||||
|
||||
@ -68,6 +68,18 @@ test.demo: install
|
||||
make shell.build && \
|
||||
bin/posh execute welcome demo
|
||||
|
||||
.PHONY: build
|
||||
## Build binary
|
||||
build:
|
||||
@rm -f bin/posh
|
||||
@go build -o bin/posh main.go
|
||||
|
||||
.PHONY: build.debug
|
||||
## Build binary in debug mode
|
||||
build.debug:
|
||||
@rm -f bin/posh
|
||||
@go build -gcflags "all=-N -l" -o bin/posh main.go
|
||||
|
||||
.PHONY: install
|
||||
## Run go install
|
||||
install: GOPATH=${shell go env GOPATH}
|
||||
@ -100,4 +112,3 @@ help:
|
||||
print "\n " help "\n"; help=""; \
|
||||
} \
|
||||
}' $(MAKEFILE_LIST)
|
||||
|
||||
|
||||
111
README.md
111
README.md
@ -62,16 +62,123 @@ Use "posh [command] --help" for more information about a command.
|
||||
|
||||
To start using posh, go into your project and run:
|
||||
|
||||
```bash
|
||||
```shell
|
||||
$ cd your/project
|
||||
$ posh init
|
||||
```
|
||||
|
||||
This will generate the standard layout for posh which can be changed as required through `.posh.yml`.
|
||||
|
||||
```yaml
|
||||
version: v1.0
|
||||
|
||||
## Prompt settings
|
||||
prompt:
|
||||
title: "Posh"
|
||||
prefix: "posh >"
|
||||
history:
|
||||
limit: 100
|
||||
filename: .posh/.history
|
||||
lockFilename: .posh/.history.lock
|
||||
|
||||
## Environment variables
|
||||
env:
|
||||
- name: PATH
|
||||
value: "${PROJECT_ROOT}/bin:${PATH}"
|
||||
|
||||
## Ownbrew settings
|
||||
ownbrew:
|
||||
binDir: "bin"
|
||||
tapDir: ".posh/scripts/ownbrew"
|
||||
tempDir: ".posh/tmp"
|
||||
cellarDir: ".posh/bin"
|
||||
packages: []
|
||||
## Remote package
|
||||
## See `https://github.com/foomo/ownbrew-tap`
|
||||
#- name: gotsrpc
|
||||
# tap: foomo/tap/foomo/gotsrpc
|
||||
# version: 2.6.2
|
||||
## Local package `.posh/scripts/ownbrew`
|
||||
#- name: example
|
||||
# version: 0.0.0
|
||||
|
||||
## Requirement settings
|
||||
require:
|
||||
## Required environment variables
|
||||
envs: []
|
||||
## Example: require VOLTA_HOME
|
||||
#- name: VOLTA_HOME
|
||||
# help: |
|
||||
# Missing required $VOLTA_HOME env var.
|
||||
#
|
||||
# Please initialize volta and ensure $VOLTA_HOME is set:
|
||||
#
|
||||
# $ volta setup
|
||||
|
||||
## Required scripts that need to succeed
|
||||
scripts: []
|
||||
## Example: git
|
||||
#- name: git
|
||||
# command: |
|
||||
# git status && exit 0 || exit 1
|
||||
# help: |
|
||||
# This is not a git repo. Please clone the repository
|
||||
|
||||
## Example: npm
|
||||
#- name: npm
|
||||
# command: npm whoami --registry=https://npm.pkg.github.com > /dev/null 2>&1
|
||||
# help: |
|
||||
# You're not yet logged into the github npm registry!
|
||||
#
|
||||
# $ npm login --scope=@<SCOPE> --registry=https://npm.pkg.github.com
|
||||
# Username: [GITHUB_USERNAME]
|
||||
# Password: [GITHUB_TOKEN]
|
||||
# Email: [EMAIL]
|
||||
|
||||
## Required packages to be installed on the host
|
||||
packages: []
|
||||
## Example: git
|
||||
#- name: git
|
||||
# version: '~2'
|
||||
# command: git version | awk '{print $3}'
|
||||
# help: |
|
||||
# Please ensure you have 'git' installed in the required version: %s!
|
||||
#
|
||||
# $ brew update
|
||||
# $ brew install git
|
||||
|
||||
## Example: go
|
||||
#- name: go
|
||||
# version: '>=1.23'
|
||||
# command: go env GOVERSION | cut -c3-
|
||||
# help: |
|
||||
# Please ensure you have 'go' installed in the required version: %s!
|
||||
#
|
||||
# $ brew update
|
||||
# $ brew install go
|
||||
|
||||
#- name: volta
|
||||
# version: '>=2'
|
||||
# command: volta --version
|
||||
# help: |
|
||||
# Please ensure you have 'volta' installed in a recent version: %s!
|
||||
#
|
||||
# $ curl https://get.volta.sh | bash
|
||||
#
|
||||
# Or see the documentation: https://docs.volta.sh/guide/getting-started
|
||||
|
||||
|
||||
## Integrations
|
||||
|
||||
## Example: Custom
|
||||
welcome:
|
||||
message: Hi, thanks for using POSH!
|
||||
|
||||
```
|
||||
|
||||
Once initialized, you can start posh through:
|
||||
|
||||
```bash
|
||||
```shell
|
||||
$ make shell
|
||||
```
|
||||
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
Version: v1.0
|
||||
# yaml-language-server: $schema=https://raw.githubusercontent.com/foomo/posh/refs/heads/main/posh.schema.json
|
||||
version: v1.0
|
||||
|
||||
## Prompt settings
|
||||
prompt:
|
||||
@ -105,5 +106,5 @@ require:
|
||||
|
||||
|
||||
## Example: Custom
|
||||
#welcome:
|
||||
# message: Hi, thanks for using POSH!
|
||||
welcome:
|
||||
message: Hi, thanks for using POSH!
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
# yaml-language-server: $schema=config.schema.json
|
||||
# yaml-language-server: $schema=posh.schema.json
|
||||
version: '1.0'
|
||||
|
||||
# Prompt settings
|
||||
@ -19,13 +19,9 @@
|
||||
"$ref": "#/$defs/Require"
|
||||
}
|
||||
},
|
||||
"additionalProperties": false,
|
||||
"type": "object",
|
||||
"required": [
|
||||
"version",
|
||||
"env",
|
||||
"prompt",
|
||||
"require"
|
||||
"version"
|
||||
]
|
||||
},
|
||||
"Env": {
|
||||
@ -38,12 +34,7 @@
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"additionalProperties": false,
|
||||
"type": "object",
|
||||
"required": [
|
||||
"name",
|
||||
"value"
|
||||
]
|
||||
"type": "object"
|
||||
},
|
||||
"type": "array"
|
||||
},
|
||||
@ -68,15 +59,7 @@
|
||||
"type": "object"
|
||||
}
|
||||
},
|
||||
"additionalProperties": false,
|
||||
"type": "object",
|
||||
"required": [
|
||||
"title",
|
||||
"prefix",
|
||||
"prefixGit",
|
||||
"history",
|
||||
"aliases"
|
||||
]
|
||||
"type": "object"
|
||||
},
|
||||
"PromptHistory": {
|
||||
"properties": {
|
||||
@ -90,13 +73,7 @@
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"additionalProperties": false,
|
||||
"type": "object",
|
||||
"required": [
|
||||
"limit",
|
||||
"filename",
|
||||
"lockFilename"
|
||||
]
|
||||
"type": "object"
|
||||
},
|
||||
"Require": {
|
||||
"properties": {
|
||||
@ -119,13 +96,7 @@
|
||||
"type": "array"
|
||||
}
|
||||
},
|
||||
"additionalProperties": false,
|
||||
"type": "object",
|
||||
"required": [
|
||||
"envs",
|
||||
"scripts",
|
||||
"packages"
|
||||
]
|
||||
"type": "object"
|
||||
},
|
||||
"RequireEnv": {
|
||||
"properties": {
|
||||
@ -136,12 +107,7 @@
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"additionalProperties": false,
|
||||
"type": "object",
|
||||
"required": [
|
||||
"name",
|
||||
"help"
|
||||
]
|
||||
"type": "object"
|
||||
},
|
||||
"RequirePackage": {
|
||||
"properties": {
|
||||
@ -158,14 +124,7 @@
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"additionalProperties": false,
|
||||
"type": "object",
|
||||
"required": [
|
||||
"name",
|
||||
"version",
|
||||
"command",
|
||||
"help"
|
||||
]
|
||||
"type": "object"
|
||||
},
|
||||
"RequireScript": {
|
||||
"properties": {
|
||||
@ -179,13 +138,7 @@
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"additionalProperties": false,
|
||||
"type": "object",
|
||||
"required": [
|
||||
"name",
|
||||
"command",
|
||||
"help"
|
||||
]
|
||||
"type": "object"
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -26,7 +26,7 @@ type Config struct {
|
||||
Require config.Require `json:"require"`
|
||||
}
|
||||
|
||||
func TestConfig(t *testing.T) {
|
||||
func TestSchema(t *testing.T) {
|
||||
t.Parallel()
|
||||
testingx.Tags(t, tagx.Short)
|
||||
|
||||
@ -34,12 +34,14 @@ func TestConfig(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
|
||||
reflector := new(jsonschema.Reflector)
|
||||
reflector.AllowAdditionalProperties = true
|
||||
reflector.RequiredFromJSONSchemaTags = true
|
||||
require.NoError(t, reflector.AddGoComments("github.com/foomo/posh", "./"))
|
||||
schema := reflector.Reflect(&Config{})
|
||||
actual, err := json.MarshalIndent(schema, "", " ")
|
||||
require.NoError(t, err)
|
||||
|
||||
filename := path.Join(cwd, "config.schema.json")
|
||||
filename := path.Join(cwd, "posh.schema.json")
|
||||
expected, err := os.ReadFile(filename)
|
||||
if !errors.Is(err, os.ErrNotExist) {
|
||||
require.NoError(t, err)
|
||||
Loading…
Reference in New Issue
Block a user