Skip to content
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: v2, added delete mode #5

Merged
merged 1 commit into from
Oct 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/live-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ jobs:
timeout-minutes: 30
steps:
- name: Checkout code
uses: actions/checkout@v3
uses: actions/checkout@v4

- uses: actions/setup-node@v3
- uses: actions/setup-node@v4
with:
node-version: 16
node-version: 20
cache: 'npm'

- name: Print environment variables
Expand Down
25 changes: 0 additions & 25 deletions .github/workflows/manual-tests.yml

This file was deleted.

4 changes: 2 additions & 2 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
timeout-minutes: 30
steps:
- name: Checkout code
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Install modules
run: npm install
Expand All @@ -25,4 +25,4 @@ jobs:
run: npm run build

- name: Create release
uses: softprops/action-gh-release@v1
uses: softprops/action-gh-release@v2
6 changes: 3 additions & 3 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@ jobs:
os:
- ubuntu-latest
- windows-latest
node: [14.x, 16.x, 18.x]
node: [18.x, 20.x, 22.x]

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- name: Set up Node.js
uses: actions/setup-node@v1
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node }}

Expand Down
4 changes: 0 additions & 4 deletions .husky/commit-msg

This file was deleted.

4 changes: 0 additions & 4 deletions .husky/pre-commit

This file was deleted.

178 changes: 178 additions & 0 deletions .idea/LNKD.tech Editor.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
20
26 changes: 25 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ GitHub Action to read and write values from JSON files during workflow run.
|---------------------------------------------------|----------------|-----------------------------------------------------------------------------------------------|
| `property`<span style="color:red">*</span> | - | Property to read or write. Example: `a.b.c` |
| `file` | `package.json` | Path to JSON file relative to workspace. |
| `mode` | `read` | Mode of operation. Possible values: `read` or `write`. |
| `mode` | `read` | Mode of operation. Possible values: `read`, `write` or `delete`. |
| `fallback` | - | Fallback value to use if property is not set. |
| `value`<span style="color:red">**</span> | - | Value to write to property. |
| `value_type` | `string` | Value type to write to property. Valid types: `string`, `number`, `object`, `boolean`, `null` |
Expand Down Expand Up @@ -157,3 +157,27 @@ jobs:
run: cat test.json
shell: bash
```

### Delete value

### 1. Delete `version` property from `package.json`

```yaml
jobs:
create-release:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Write version to package.json
uses: amochkin/action-json@v1
id: delete_version
with:
mode: delete
property: version

- name: Output modified package.json
run: cat package.json
shell: bash
```
2 changes: 1 addition & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ inputs:
description: "Path to JSON file; default is `package.json`"
default: "package.json"
mode:
description: "Mode of operation (`read`/`write`); default is `read`"
description: "Mode of operation (`read`/`write`/`delete`); default is `read`"
default: "read"
property:
description: "Dot-separated path to property (for example `a.b`)`"
Expand Down
6 changes: 6 additions & 0 deletions commitlint.config.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/* eslint-disable */
module.exports = {
extends: [
"@commitlint/config-conventional"
]
}
2 changes: 1 addition & 1 deletion dist/index.js

Large diffs are not rendered by default.

9 changes: 9 additions & 0 deletions eslint.config.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/* eslint-disable */

/** @type {import('@p8ec/shared').EslintConfigOverride} */
const override = {
copyright: '2024 A. Mochkin',
// eslintConfig: { languageOptions: { globals: { ...globals.node} } },
}

module.exports = require('@p8ec/shared').eslintConfigRecommended(override);
7 changes: 7 additions & 0 deletions lefthook.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Refer for explanation to following link:
# https://github.com/evilmartians/lefthook/blob/master/docs/configuration.md

commit-msg:
commands:
commitlint:
run: npx --no -- commitlint --edit {1}
Loading