-
Notifications
You must be signed in to change notification settings - Fork 166
normalize-yaml: Prepare for NPM publish #8654
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| *.d.ts |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,65 @@ | ||
| # @18f/identity-normalize-yaml | ||
|
|
||
| Normalizes YAML files to ensure consistency and typographical quality: | ||
|
|
||
| - Alphabetizes keys. | ||
| - Applies improved punctuation. | ||
| - Converts straight quotes `"` and `'` to smart quotes `“`, `”`, and `’` | ||
| - Converts three dots `...` to ellipsis `…` | ||
| - Stylizes content using [Prettier](https://prettier.io/), respecting local project Prettier configuration. | ||
|
|
||
| ## Installation | ||
|
|
||
| Install using npm or Yarn. To reduce conflicts with a project's own Prettier dependency version, you must install Prettier as a separate dependency if not already installed. | ||
|
|
||
| Using npm: | ||
|
|
||
| ``` | ||
| npm install @18f/identity-normalize-yaml prettier | ||
| ``` | ||
|
|
||
| Using Yarn: | ||
|
|
||
| ``` | ||
| yarn add @18f/identity-normalize-yaml prettier | ||
| ``` | ||
|
|
||
| ## Usage | ||
|
|
||
| ### CLI | ||
|
|
||
| The included `normalize-yaml` binary receives files as an argument, with optional flags: | ||
|
|
||
| - `--disable-sort-keys`: Disable the default behavior to sort keys. | ||
| - `--disable-smart-punctuation`: Disable the default behavior to apply smart punctuation. | ||
|
|
||
| **Example:** | ||
|
|
||
| Using npm: | ||
|
|
||
| ``` | ||
| npm exec normalize-yaml path/to/file.yml -- --disable-sort-keys | ||
| ``` | ||
|
|
||
| Using Yarn: | ||
|
|
||
| ``` | ||
| yarn normalize-yaml path/to/file.yml --disable-sort-keys | ||
| ``` | ||
|
|
||
| ### API | ||
|
|
||
| #### `normalize(content: string, config?: Options): string` | ||
|
|
||
| Given an input YAML string and optional options, returns a normalized YAML string. | ||
|
|
||
| **Options:** | ||
|
|
||
| - `prettierConfig` (`Record<string, any>`): Optional Prettier configuration object. | ||
| - `exclude` (`Formatter[]`) Formatters to exclude. | ||
|
|
||
| ## License | ||
|
|
||
| This project is in the public domain within the United States, and copyright and related rights in the work worldwide are waived through the [CC0 1.0 Universal public domain dedication](https://creativecommons.org/publicdomain/zero/1.0/). | ||
|
|
||
| All contributions to this project will be released under the CC0 dedication. By submitting a pull request or issue, you are agreeing to comply with this waiver of copyright interest. | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,14 +1,42 @@ | ||
| { | ||
| "name": "@18f/identity-normalize-yaml", | ||
| "private": true, | ||
| "private": false, | ||
| "description": "Normalizes YAML files to ensure consistency and typographical quality", | ||
| "version": "1.0.0", | ||
| "type": "module", | ||
| "main": "./index.js", | ||
| "types": "./types/index.d.ts", | ||
| "bin": { | ||
| "normalize-yaml": "./cli.js" | ||
| }, | ||
| "scripts": { | ||
| "prebuild:types": "rm -rf types", | ||
| "build:types": "tsc", | ||
| "prepublishOnly": "npm run build:types" | ||
| }, | ||
| "files": [ | ||
| "cli.js", | ||
| "index.js", | ||
| "visitors/index.js", | ||
| "visitors/smart-punctuation.js", | ||
| "visitors/sort-keys.js", | ||
| "types" | ||
| ], | ||
| "license": "CC0-1.0", | ||
| "bugs": { | ||
| "url": "https://github.com/18f/identity-idp/issues" | ||
| }, | ||
| "homepage": "https://github.com/18f/identity-idp", | ||
| "repository": { | ||
| "type": "git", | ||
| "url": "https://github.com/18f/identity-idp.git", | ||
| "directory": "app/javascript/packages/normalize-yaml" | ||
| }, | ||
| "dependencies": { | ||
| "prettier": "^2.6.0", | ||
| "smartquotes": "^2.3.2", | ||
| "yaml": "^2.2.2" | ||
| "yaml": "^2.3.1" | ||
| }, | ||
| "peerDependencies": { | ||
| "prettier": "*" | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| { | ||
| "extends": "../../../../tsconfig.json", | ||
| "compilerOptions": { | ||
| "outDir": "types", | ||
| "noEmit": false, | ||
| "declaration": true, | ||
| "emitDeclarationOnly": true | ||
| }, | ||
| "include": ["./**/*.js"], | ||
| "exclude": ["types", "**/*.spec.js"] | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Of course I'm realizing after publishing that this should have included the left form of the single smart quote
‘🤦