-
Notifications
You must be signed in to change notification settings - Fork 14
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
feat: bring yaml #250
Closed
feat: bring yaml #250
Changes from all commits
Commits
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 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 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 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,29 @@ | ||
name: yaml-pull | ||
on: | ||
pull_request: | ||
paths: | ||
- yaml/** | ||
jobs: | ||
build-yaml: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
with: | ||
sparse-checkout: yaml | ||
- name: Setup Node.js | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: 20.x | ||
registry-url: https://registry.npmjs.org | ||
- name: Install winglang | ||
run: npm i -g winglang | ||
- name: Install dependencies | ||
run: npm install --include=dev | ||
working-directory: yaml | ||
- name: Test | ||
run: wing test | ||
working-directory: yaml | ||
- name: Pack | ||
run: wing pack | ||
working-directory: yaml |
This file contains 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,54 @@ | ||
name: yaml-release | ||
on: | ||
push: | ||
branches: | ||
- main | ||
paths: | ||
- yaml/** | ||
- "!yaml/package-lock.json" | ||
jobs: | ||
build-yaml: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
with: | ||
sparse-checkout: yaml | ||
- name: Setup Node.js | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: 20.x | ||
registry-url: https://registry.npmjs.org | ||
- name: Install winglang | ||
run: npm i -g winglang | ||
- name: Install dependencies | ||
run: npm install --include=dev | ||
working-directory: yaml | ||
- name: Test | ||
run: wing test | ||
working-directory: yaml | ||
- name: Pack | ||
run: wing pack | ||
working-directory: yaml | ||
- name: Get package version | ||
run: echo WINGLIB_VERSION=$(node -p "require('./package.json').version") >> | ||
"$GITHUB_ENV" | ||
working-directory: yaml | ||
- name: Publish | ||
run: npm publish --access=public --registry https://registry.npmjs.org --tag | ||
latest *.tgz | ||
working-directory: yaml | ||
env: | ||
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | ||
- name: Tag commit | ||
uses: tvdias/[email protected] | ||
with: | ||
repo-token: ${{ secrets.PROJEN_GITHUB_TOKEN }} | ||
tag: yaml-v${{ env.WINGLIB_VERSION }} | ||
- name: GitHub release | ||
uses: softprops/action-gh-release@v1 | ||
with: | ||
name: yaml v${{ env.WINGLIB_VERSION }} | ||
tag_name: yaml-v${{ env.WINGLIB_VERSION }} | ||
files: "*.tgz" | ||
token: ${{ secrets.PROJEN_GITHUB_TOKEN }} |
This file contains 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 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 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,2 @@ | ||
target/ | ||
node_modules/ |
This file contains 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,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2023 Wing | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains 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,34 @@ | ||
# yaml | ||
|
||
A Wing library for working with yaml. | ||
|
||
## Prerequisites | ||
|
||
* [winglang](https://winglang.io). | ||
|
||
## Installation | ||
|
||
```sh | ||
npm i @winglibs/yaml | ||
``` | ||
|
||
## Usage | ||
|
||
```js | ||
bring fs; | ||
bring yaml; | ||
bring cloud; | ||
|
||
let file = fs.readFile("./test.yml"); | ||
let value = yaml.parseValue(file); | ||
yaml.stringifyValue(json); | ||
|
||
new cloud.Function(inflight () => { | ||
let value = yaml.parse(file); | ||
yaml.stringify(json); | ||
}); | ||
``` | ||
|
||
## License | ||
|
||
This library is licensed under the [MIT License](./LICENSE). |
This file contains 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,19 @@ | ||
bring fs; | ||
bring expect; | ||
bring "./lib.w" as yaml; | ||
|
||
let json = { | ||
key1: ["value1", "value2"], | ||
key2: "value3", | ||
}; | ||
|
||
let file = fs.readFile(fs.join(@dirname, "./test.yml")); | ||
let value = yaml.parseValue(file); | ||
expect.equal(value, json); | ||
expect.equal(yaml.stringifyValue(json), file); | ||
|
||
test "can parse and stringify yaml file" { | ||
let value = yaml.parse(file); | ||
expect.equal(value, json); | ||
expect.equal(yaml.stringify(json), file); | ||
} |
This file contains 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,33 @@ | ||
pub struct ParseOptions { | ||
strict: bool?; | ||
} | ||
|
||
pub struct StringifyOptions { | ||
indent: num?; | ||
} | ||
|
||
pub class Util { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. what's the benefit of this duplication? Why not just make the extern methods public? |
||
pub static inflight parse(value: str, options: ParseOptions?): Json { | ||
return Extern._parse(value, options); | ||
} | ||
|
||
pub static inflight stringify(value: Json, options: StringifyOptions?): Json { | ||
return Extern._stringify(value, options); | ||
} | ||
|
||
pub static parseValue(value: str, options: ParseOptions?): Json { | ||
return Extern._preflight_parse(value, options); | ||
} | ||
|
||
pub static stringifyValue(value: Json, options: StringifyOptions?): Json { | ||
return Extern._preflight_stringify(value, options); | ||
} | ||
} | ||
|
||
class Extern { | ||
pub extern "./yaml.mts" static inflight _parse(value: str, options: ParseOptions?): Json; | ||
pub extern "./yaml.mts" static inflight _stringify(value: Json, options: StringifyOptions?): str; | ||
pub extern "./yaml.mts" static _preflight_parse(value: str, options: ParseOptions?): Json; | ||
pub extern "./yaml.mts" static _preflight_stringify(value: Json, options: StringifyOptions?): str; | ||
} | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains 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,23 @@ | ||
{ | ||
"name": "@winglibs/yaml", | ||
"description": "yaml library for Wing", | ||
"version": "0.0.1", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/winglang/winglibs.git", | ||
"directory": "yaml" | ||
}, | ||
"author": { | ||
"email": "[email protected]", | ||
"name": "Elad Cohen" | ||
}, | ||
"wing": { | ||
"platforms": [ | ||
"*" | ||
] | ||
}, | ||
"license": "MIT", | ||
"peerDependencies": { | ||
"yaml": "^2.4.2" | ||
} | ||
} |
This file contains 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,4 @@ | ||
key1: | ||
- value1 | ||
- value2 | ||
key2: value3 |
This file contains 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,12 @@ | ||
export default interface extern { | ||
_parse: (value: string, options?: (ParseOptions) | undefined) => Promise<Readonly<any>>, | ||
_preflight_parse: (value: string, options?: (ParseOptions) | undefined) => Readonly<any>, | ||
_preflight_stringify: (value: Readonly<any>, options?: (StringifyOptions) | undefined) => string, | ||
_stringify: (value: Readonly<any>, options?: (StringifyOptions) | undefined) => Promise<string>, | ||
} | ||
export interface ParseOptions { | ||
readonly strict?: (boolean) | undefined; | ||
} | ||
export interface StringifyOptions { | ||
readonly indent?: (number) | undefined; | ||
} |
This file contains 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,5 @@ | ||
import { parse, stringify } from "yaml"; | ||
export const _parse = parse; | ||
export const _stringify = stringify; | ||
export const _preflight_parse = parse; | ||
export const _preflight_stringify = stringify; |
Oops, something went wrong.
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.
We should totally include this in the built-in standard library!
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.
Don't we already have some yaml stuff in the standard library?
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.
I agree this should be part of the stdlib.
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.
apparently we already have
fs.readYaml
.. was not aware of it