Skip to content

Commit 85d96b1

Browse files
committed
update for npm
1 parent 0a77081 commit 85d96b1

File tree

10 files changed

+1878
-22
lines changed

10 files changed

+1878
-22
lines changed

CHANGELOG.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Changelog
2+
3+
All notable changes to this project will be documented in this file.
4+
5+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7+
8+
## [0.1.0] - YYYY-MM-DD
9+
10+
### Added
11+
12+
- Initial release of the `go-prettier-format` plugin.
13+
- Formats Go code using `go/format` compiled to WebAssembly.
14+
- Support for both CJS and ESM environments.
15+
- CLI and editor integration support.

CONTRIBUTING.md

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# Contributing to go-prettier-format
2+
3+
First off, thank you for considering contributing! Your help is appreciated.
4+
5+
## How Can I Contribute?
6+
7+
### Reporting Bugs
8+
9+
If you find a bug, please make sure to include the following:
10+
- A clear and descriptive title.
11+
- Steps to reproduce the bug.
12+
- The expected behavior and what happened instead.
13+
- Your environment details (Node.js version, OS, etc.).
14+
15+
Please check the existing issues to see if a similar bug has already been reported.
16+
17+
### Suggesting Enhancements
18+
19+
If you have an idea for a new feature or an improvement, feel free to open an issue to discuss it. This lets us coordinate our efforts and prevent duplication of work.
20+
21+
### Pull Requests
22+
23+
We welcome pull requests! For major changes, please open an issue first to discuss what you would like to change.
24+
25+
When submitting a pull request, please make sure to:
26+
- Update the `README.md` if any user-facing changes were made.
27+
- Ensure the tests pass (`npm test`).
28+
- Follow the existing code style.
29+
30+
## Development Setup
31+
32+
To get your development environment set up, please follow these steps. You will need to have Go installed to build the WebAssembly module.
33+
34+
1. **Clone the repository:**
35+
```bash
36+
git clone https://github.com/gitdog01/go-prettier-format.git
37+
cd go-prettier-format
38+
```
39+
40+
2. **Install dependencies:**
41+
```bash
42+
npm install
43+
```
44+
45+
3. **Build the project:**
46+
The project needs to be built before you can test your changes. This includes compiling the Go source to WASM and bundling the JavaScript.
47+
```bash
48+
npm run build
49+
```
50+
51+
4. **Run tests:**
52+
To make sure everything is working correctly, run the test suite:
53+
```bash
54+
npm test
55+
```

README.md

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
# Prettier Plugin for Go (using WASM)
22

3-
This is a Prettier plugin for the Go programming language. It formats Go code using the official `go/format` package, which is compiled to WebAssembly (WASM) to run in a Node.js environment.
3+
[![npm version](https://img.shields.io/npm/v/go-prettier-format.svg)](https://www.npmjs.com/package/go-prettier-format)
4+
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
5+
6+
This is a [Prettier](https://prettier.io/) v3 plugin for the Go programming language. It formats Go code using the official `go/format` package, which is compiled to WebAssembly (WASM) to run in a Node.js environment.
47

58
## Background
69

@@ -10,7 +13,7 @@ This project was born out of the desire to have a single, unified formatting too
1013

1114
## Installation
1215

13-
First, install Prettier and this plugin from NPM:
16+
First, install Prettier (v3 or later) and this plugin from NPM:
1417

1518
```bash
1619
npm install --save-dev prettier go-prettier-format
@@ -32,14 +35,16 @@ npx prettier --write your-file.go
3235
npx prettier --write "**/*.go"
3336
```
3437

38+
> Note: For cross-platform compatibility in npm scripts, it's recommended to use single quotes: `'**/*.go'`.
39+
3540
### package.json Script
3641

3742
For convenience, you can add a script to your `package.json`:
3843

3944
```json
4045
{
4146
"scripts": {
42-
"format": "prettier --write \"**/*.go\""
47+
"format": "prettier --write '**/*.go'"
4348
}
4449
}
4550
```
@@ -79,6 +84,7 @@ npm test
7984
```
8085
8186
This command will:
87+
- Build the latest version of the plugin from source.
8288
- Create a `test_result` directory.
8389
- Copy the sample files from the `tests/` directory into it.
8490
- Run the Prettier formatter on the files inside `test_result/`.
@@ -89,11 +95,12 @@ You can then compare the original files in `tests/` with the formatted files in
8995
9096
## Publishing to NPM
9197
92-
To publish a new version to NPM:
98+
This package is configured to build automatically before publishing.
99+
100+
1. Update the version number in `package.json` using `npm version <patch|minor|major>`.
101+
2. Run `npm publish`.
93102
94-
1. Build the latest WASM binary: `npm run build:wasm`.
95-
2. Update the version number in `package.json`.
96-
3. Run `npm publish`.
103+
The `prepublishOnly` script will handle building the Wasm and JavaScript bundles before the package is uploaded to the registry.
97104
98105
## How it Works
99106

0 commit comments

Comments
 (0)