Skip to content

Commit

Permalink
Merge pull request #21 from longkai/v2
Browse files Browse the repository at this point in the history
Release the brand new v2 version 🎉
  • Loading branch information
longkai authored Nov 4, 2024
2 parents 5dd5fae + bdc9be8 commit c88b270
Show file tree
Hide file tree
Showing 13 changed files with 4,162 additions and 3,371 deletions.
97 changes: 23 additions & 74 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -1,91 +1,40 @@
name: release to visual studio code extension marketplace
name: Release to Visual Studio Code Extension Marketplace

on:
push:
tags:
- "*"
release:
types:
- published

jobs:
build:
name: build yamlfmt binary
runs-on: ubuntu-latest
steps:
- name: Checkout forked yamlfmt repo
uses: actions/checkout@v3
with:
fetch-depth: 0
repository: longkai/yamlfmt
ref: vscode
- name: setup golang
uses: actions/setup-go@v3
with:
go-version: '>=1.19'
check-latest: true
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v3
with:
distribution: goreleaser
version: latest
args: --snapshot --rm-dist
- name: rm tar.gz
run: rm -rf *.tar.gz
- name: upload
uses: actions/upload-artifact@v3
with:
name: binaries
path: "dist/yamlfmt_*"

package:
name: package vscode extension
name: Package VS Code Extension and Publish to the Marketplace
runs-on: ubuntu-latest
needs: build
if: success() && startsWith(github.ref, 'refs/tags/')
steps:
- uses: actions/download-artifact@v3
with:
name: binaries
path: /tmp
- name: checkout extension repo
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.ref }}
- name: Set up Git configuration
run: |
git config --global user.name "${{ github.actor }}"
git config --global user.email "${{ github.event.pusher.email }}"
- name: setup nodejs
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: 18
node-version: 22
- name: npm install
run: npm install
- name: package multi-platforms
shell: bash
- name: Publish Pre-release to the Marketplace
run: |
declare -A map
map["win32-x64"]=windows_amd64_v1
map["win32-arm64"]=windows_arm64
map["linux-x64"]=linux_amd64_v1
map["linux-arm64"]=linux_arm64
map["darwin-x64"]=darwin_amd64_v1
map["darwin-arm64"]=darwin_arm64
for arch in ${!map[*]}; do
rm -rf bin/
mv "/tmp/yamlfmt_${map[$arch]}" bin/
chmod +x -R bin/
npx vsce package --target $arch
done
- name: upload
uses: actions/upload-artifact@v3
with:
name: packages
path: "*.vsix"

release:
name: publish vscode extension to marketplace
runs-on: ubuntu-latest
needs: package
if: success() && startsWith(github.ref, 'refs/tags/')
steps:
- uses: actions/download-artifact@v3
with:
name: packages
- run: npx vsce publish --packagePath $(find . -iname '*.vsix')
npx vsce publish ${{ github.ref_name }} --pre-release
if: "github.event.release.prerelease"
env:
VSCE_PAT: ${{ secrets.VSCE_PAT }}
- name: Publish to the Marketplace
run: |
npx vsce publish ${{ github.ref_name }}
if: "!github.event.release.prerelease"
env:
VSCE_PAT: ${{ secrets.VSCE_PAT }}
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -131,4 +131,5 @@ dist

.vscode/

bin/
bin/
.vsix
3 changes: 3 additions & 0 deletions .vscode-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
const { defineConfig } = require('@vscode/test-cli');

module.exports = defineConfig({ files: 'out/test/**/*.test.js' });
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,19 @@ All notable changes to the "kubernetes-yaml-formatter" extension will be documen

Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how to structure this file.

## 2.0.0 (03 Nov 2024)

Rename to **Better YAML Formatter** since it works well with what you think about YAML :)

- Rewrite from grounding with **Correct**, **Consistent** and **Customized** result.
- Add universal platform support where VS Code runs including web browser!
- Add extension preview support staring this version.
- Add range formatting support!
- Add builtin helm and ansible support(with range formatting or valid content).
- Add comment string customization support.
- Add fine grained directives support.
- Bug fixes.

## 1.1.0 (20 Oct 2022)

This release is brought you from my work place, [Shenzhen](https://en.wikipedia.org/wiki/Shenzhen).
Expand Down
40 changes: 18 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,22 @@
# Kubernetes Style YAML Formatter for Visual Studio Code
# Better YAML Formatter for Visual Studio Code

A [Visual Studio Code extension](https://marketplace.visualstudio.com/items?itemName=kennylong.kubernetes-yaml-formatter) that provides format support for [YAML](https://yaml.org) language.

You find the right format extension if you come from DevOps world, e.g., [Kubernetes](https://kubernetes.io/docs/concepts/), [Ansible Playbooks](https://docs.ansible.com/ansible/latest/user_guide/playbooks_intro.html) or CI workflow like [Github Actions](https://docs.github.com/en/actions) and so on.
Frustrated of the builtin formatter with its own [option philosophy](https://prettier.io/docs/en/option-philosophy.html)?

**We all love Emojis, and yes, it has builtin support!**
Or you guys comes from devops world where dealing with a lot of yaml everyday like kubernetes, ansible or helm template.

And you have your own prefer style of YAML, e.g., **do not indent sequence elements** or other customization settings.

This extension is made for you :)

## Features

![Format YAML](images/showcase.gif)
Format **correct**, **consistent** and **customized** yaml text with **Better YAML Formatter**.

As a Kubernetes developer, aka YAML engineer, you deal with a lot of yaml files everyday. Take the k8s yaml for example:
https://github.com/user-attachments/assets/dfdec44b-221f-436d-9d90-413f0c0effe6

Take the k8s yaml for example:

```yaml
apiVersion: apps/v1
Expand All @@ -29,7 +35,7 @@ spec:
spec:
containers:
- name: nginx
image: nginx:1.14.2
image: nginx:latest
ports:
- containerPort: 80
```
Expand All @@ -40,33 +46,23 @@ Unluckily, the builtin yaml format has its own [option philosophy](https://prett

It's useless. I have to keep the style manually every time editing yaml files, or you will end up with a non-idiomatic one.

It's tedious. So I create this extension to make life easier. Now you can control which way you prefer and everyone is happy.

**Enjoy!**
It's tedious. So I create this extension to make life easier.

## Extension Settings

This extension contributes the following settings:

* `kubernetes-yaml-formatter.compactSequenceIndent`: Enable compact sequence indent, i.e. no indent (default `true`).
* `kubernetes-yaml-formatter.includeDocumentStart`: Include `---` at document start (default `false`).

It makes format yaml on save default to `true`, you can disable it:

```json
"[yaml]": {
"editor.formatOnSave": false
}
```
* `better-yaml.directives`: Whether block sequences should be indented.
* `better-yaml.directives`: Include directives in the output. If true, at least the document-start marker --- is always included. If false, no directives or marker is ever included. If null, directives and marker may be included if required.
* `better-yaml.commentString`: Change the comment prefix string. By default, empty comment lines are left empty, lines consisting of a single space are replaced by `#`, and all other lines are prefixed with a `#`.

## Thanks

Thanks [lupengpeng](https://github.com/iamlupeng1991) for the icon design. It's great!

Thanks the following projects:
Many thanks the following projects:

* [google/yamlfmt](https://github.com/google/yamlfmt)
* [go-yaml](github.com/natasha41575/yaml)
* [eemeli/yaml](https://github.com/eemeli/yaml)

Without them there wouldn't be this extension.

Expand Down
Loading

0 comments on commit c88b270

Please sign in to comment.