@zentered/issue-forms-body-parser 2.0.0 → 2.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,11 +1,11 @@
1
- name: "CodeQL"
1
+ name: 'CodeQL'
2
2
 
3
3
  on:
4
4
  push:
5
- branches: [ main ]
5
+ branches: [main]
6
6
  pull_request:
7
7
  # The branches below must be a subset of the branches above
8
- branches: [ main ]
8
+ branches: [main]
9
9
  schedule:
10
10
  - cron: '29 21 * * 5'
11
11
 
@@ -21,39 +21,39 @@ jobs:
21
21
  strategy:
22
22
  fail-fast: false
23
23
  matrix:
24
- language: [ 'javascript' ]
24
+ language: ['javascript']
25
25
  # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
26
26
  # Learn more about CodeQL language support at https://git.io/codeql-language-support
27
27
 
28
28
  steps:
29
- - name: Checkout repository
30
- uses: actions/checkout@v3
31
-
32
- # Initializes the CodeQL tools for scanning.
33
- - name: Initialize CodeQL
34
- uses: github/codeql-action/init@v2
35
- with:
36
- languages: ${{ matrix.language }}
37
- # If you wish to specify custom queries, you can do so here or in a config file.
38
- # By default, queries listed here will override any specified in a config file.
39
- # Prefix the list here with "+" to use these queries and those in the config file.
40
- # queries: ./path/to/local/query, your-org/your-repo/queries@main
41
-
42
- # Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
43
- # If this step fails, then you should remove it and run the build manually (see below)
44
- - name: Autobuild
45
- uses: github/codeql-action/autobuild@v2
46
-
47
- # ℹ️ Command-line programs to run using the OS shell.
48
- # 📚 https://git.io/JvXDl
49
-
50
- # ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
51
- # and modify them (or add more) to build your code if your project
52
- # uses a compiled language
53
-
54
- #- run: |
55
- # make bootstrap
56
- # make release
57
-
58
- - name: Perform CodeQL Analysis
59
- uses: github/codeql-action/analyze@v2
29
+ - name: Checkout repository
30
+ uses: actions/checkout@v3
31
+
32
+ # Initializes the CodeQL tools for scanning.
33
+ - name: Initialize CodeQL
34
+ uses: github/codeql-action/init@v2
35
+ with:
36
+ languages: ${{ matrix.language }}
37
+ # If you wish to specify custom queries, you can do so here or in a config file.
38
+ # By default, queries listed here will override any specified in a config file.
39
+ # Prefix the list here with "+" to use these queries and those in the config file.
40
+ # queries: ./path/to/local/query, your-org/your-repo/queries@main
41
+
42
+ # Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
43
+ # If this step fails, then you should remove it and run the build manually (see below)
44
+ - name: Autobuild
45
+ uses: github/codeql-action/autobuild@v2
46
+
47
+ # ℹ️ Command-line programs to run using the OS shell.
48
+ # 📚 https://git.io/JvXDl
49
+
50
+ # ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
51
+ # and modify them (or add more) to build your code if your project
52
+ # uses a compiled language
53
+
54
+ #- run: |
55
+ # make bootstrap
56
+ # make release
57
+
58
+ - name: Perform CodeQL Analysis
59
+ uses: github/codeql-action/analyze@v2
@@ -10,4 +10,17 @@ jobs:
10
10
  - name: Issue Forms Body Parser
11
11
  id: parse
12
12
  uses: ./
13
- - run: echo "${{ toJSON(steps.parse.outputs.data) }}"
13
+ - run: echo ${{ toJSON(steps.parse.outputs.data) }}
14
+
15
+ - name: Read an issue content
16
+ id: read_issue
17
+ run: |
18
+ echo "body<<EOF" >> $GITHUB_OUTPUT
19
+ cat ./test/test-issue-3.md >> $GITHUB_OUTPUT
20
+ echo "EOF" >> $GITHUB_OUTPUT
21
+ - name: Issue Forms Body Parser With Provided Body
22
+ id: parse_with_body
23
+ uses: ./
24
+ with:
25
+ body: ${{ steps.read_issue.outputs.body }}
26
+ - run: echo ${{ toJSON(steps.parse_with_body.outputs.data) }}
@@ -19,6 +19,10 @@ jobs:
19
19
  runs-on: ubuntu-latest
20
20
  steps:
21
21
  - uses: actions/checkout@v3
22
+ - uses: actions/setup-node@v3
23
+ with:
24
+ node-version: 18
25
+ cache: 'npm'
22
26
  - run: npm ci
23
27
  - run: npm test
24
28
  - run: npm run release
@@ -17,8 +17,33 @@ jobs:
17
17
  runs-on: ubuntu-latest
18
18
  steps:
19
19
  - uses: actions/checkout@v3
20
+ - uses: actions/setup-node@v3
20
21
  with:
21
- fetch-depth: 0
22
+ node-version: 18
23
+ cache: 'npm'
22
24
  - run: npm ci
23
25
  - run: npm run lint
24
26
  - run: npm test
27
+
28
+ - run: npm run build
29
+
30
+ - name: Read an issue content
31
+ id: read_issue
32
+ run: |
33
+ echo "body<<EOF" >> $GITHUB_OUTPUT
34
+ cat ./test/test-issue-3.md >> $GITHUB_OUTPUT
35
+ echo "EOF" >> $GITHUB_OUTPUT
36
+ - name: Issue Forms Body Parser With Provided Body
37
+ id: parse_with_body
38
+ uses: ./
39
+ with:
40
+ body: ${{ steps.read_issue.outputs.body }}
41
+
42
+ - name: Test input body parsed
43
+ run: |
44
+ expected="Event Description"
45
+ title=$(echo ${{ toJSON(steps.parse_with_body.outputs.data) }} | jq -r '.["event-description"].title')
46
+ if [[ $title != $expected ]]; then
47
+ echo "Title \"${title}\" does not match \"${expected}\""
48
+ exit 1
49
+ fi
@@ -0,0 +1 @@
1
+ {"parent":null,"pid":1823,"argv":["/opt/hostedtoolcache/node/18.13.0/x64/bin/node","/home/runner/work/issue-forms-body-parser/issue-forms-body-parser/node_modules/.bin/tap","--node-arg=--experimental-json-modules","--test-env=GITHUB_REPOSITORY=zentered/issue-forms-body-parser-test","-J","test/parse-issue.test.js"],"execArgv":[],"cwd":"/home/runner/work/issue-forms-body-parser/issue-forms-body-parser","time":1673864641514,"ppid":1812,"coverageFilename":"/home/runner/work/issue-forms-body-parser/issue-forms-body-parser/.nyc_output/182604fc-3245-46df-92b3-32625abb4267.json","externalId":"","uuid":"182604fc-3245-46df-92b3-32625abb4267","files":[]}
@@ -0,0 +1 @@
1
+ {"parent":"182604fc-3245-46df-92b3-32625abb4267","pid":1835,"argv":["/opt/hostedtoolcache/node/18.13.0/x64/bin/node","/home/runner/work/issue-forms-body-parser/issue-forms-body-parser/test/parse-issue.test.js"],"execArgv":["--experimental-json-modules"],"cwd":"/home/runner/work/issue-forms-body-parser/issue-forms-body-parser","time":1673864641856,"ppid":1823,"coverageFilename":"/home/runner/work/issue-forms-body-parser/issue-forms-body-parser/.nyc_output/da1c3cfe-7c8a-4d2a-9350-accc36357a09.json","externalId":"test/parse-issue.test.js","uuid":"da1c3cfe-7c8a-4d2a-9350-accc36357a09","files":[]}
@@ -1 +1 @@
1
- {"processes":{"78e2aab5-e45b-4d92-a67a-363ff5cbfcf8":{"parent":"97cfe5ec-7f32-43f6-a236-732be371a17f","externalId":"test/parse-issue.test.js","children":[]},"97cfe5ec-7f32-43f6-a236-732be371a17f":{"parent":null,"children":["78e2aab5-e45b-4d92-a67a-363ff5cbfcf8"]}},"files":{},"externalIds":{"test/parse-issue.test.js":{"root":"78e2aab5-e45b-4d92-a67a-363ff5cbfcf8","children":[]}}}
1
+ {"processes":{"182604fc-3245-46df-92b3-32625abb4267":{"parent":null,"children":["da1c3cfe-7c8a-4d2a-9350-accc36357a09"]},"da1c3cfe-7c8a-4d2a-9350-accc36357a09":{"parent":"182604fc-3245-46df-92b3-32625abb4267","externalId":"test/parse-issue.test.js","children":[]}},"files":{},"externalIds":{"test/parse-issue.test.js":{"root":"da1c3cfe-7c8a-4d2a-9350-accc36357a09","children":[]}}}
@@ -6,8 +6,8 @@ We as members, contributors, and leaders pledge to make participation in our
6
6
  community a harassment-free experience for everyone, regardless of age, body
7
7
  size, visible or invisible disability, ethnicity, sex characteristics, gender
8
8
  identity and expression, level of experience, education, socio-economic status,
9
- nationality, personal appearance, race, religion, or sexual identity
10
- and orientation.
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
11
 
12
12
  We pledge to act and interact in ways that contribute to an open, welcoming,
13
13
  diverse, inclusive, and healthy community.
@@ -17,23 +17,23 @@ diverse, inclusive, and healthy community.
17
17
  Examples of behavior that contributes to a positive environment for our
18
18
  community include:
19
19
 
20
- * Demonstrating empathy and kindness toward other people
21
- * Being respectful of differing opinions, viewpoints, and experiences
22
- * Giving and gracefully accepting constructive feedback
23
- * Accepting responsibility and apologizing to those affected by our mistakes,
20
+ - Demonstrating empathy and kindness toward other people
21
+ - Being respectful of differing opinions, viewpoints, and experiences
22
+ - Giving and gracefully accepting constructive feedback
23
+ - Accepting responsibility and apologizing to those affected by our mistakes,
24
24
  and learning from the experience
25
- * Focusing on what is best not just for us as individuals, but for the
26
- overall community
25
+ - Focusing on what is best not just for us as individuals, but for the overall
26
+ community
27
27
 
28
28
  Examples of unacceptable behavior include:
29
29
 
30
- * The use of sexualized language or imagery, and sexual attention or
31
- advances of any kind
32
- * Trolling, insulting or derogatory comments, and personal or political attacks
33
- * Public or private harassment
34
- * Publishing others' private information, such as a physical or email
35
- address, without their explicit permission
36
- * Other conduct which could reasonably be considered inappropriate in a
30
+ - The use of sexualized language or imagery, and sexual attention or advances of
31
+ any kind
32
+ - Trolling, insulting or derogatory comments, and personal or political attacks
33
+ - Public or private harassment
34
+ - Publishing others' private information, such as a physical or email address,
35
+ without their explicit permission
36
+ - Other conduct which could reasonably be considered inappropriate in a
37
37
  professional setting
38
38
 
39
39
  ## Enforcement Responsibilities
@@ -60,8 +60,8 @@ representative at an online or offline event.
60
60
 
61
61
  Instances of abusive, harassing, or otherwise unacceptable behavior may be
62
62
  reported to the community leaders responsible for enforcement at
63
- contact@zentered.co.
64
- All complaints will be reviewed and investigated promptly and fairly.
63
+ contact@zentered.co. All complaints will be reviewed and investigated promptly
64
+ and fairly.
65
65
 
66
66
  All community leaders are obligated to respect the privacy and security of the
67
67
  reporter of any incident.
@@ -82,15 +82,15 @@ behavior was inappropriate. A public apology may be requested.
82
82
 
83
83
  ### 2. Warning
84
84
 
85
- **Community Impact**: A violation through a single incident or series
86
- of actions.
85
+ **Community Impact**: A violation through a single incident or series of
86
+ actions.
87
87
 
88
88
  **Consequence**: A warning with consequences for continued behavior. No
89
89
  interaction with the people involved, including unsolicited interaction with
90
90
  those enforcing the Code of Conduct, for a specified period of time. This
91
91
  includes avoiding interactions in community spaces as well as external channels
92
- like social media. Violating these terms may lead to a temporary or
93
- permanent ban.
92
+ like social media. Violating these terms may lead to a temporary or permanent
93
+ ban.
94
94
 
95
95
  ### 3. Temporary Ban
96
96
 
@@ -106,11 +106,11 @@ Violating these terms may lead to a permanent ban.
106
106
  ### 4. Permanent Ban
107
107
 
108
108
  **Community Impact**: Demonstrating a pattern of violation of community
109
- standards, including sustained inappropriate behavior, harassment of an
109
+ standards, including sustained inappropriate behavior, harassment of an
110
110
  individual, or aggression toward or disparagement of classes of individuals.
111
111
 
112
- **Consequence**: A permanent ban from any sort of public interaction within
113
- the community.
112
+ **Consequence**: A permanent ban from any sort of public interaction within the
113
+ community.
114
114
 
115
115
  ## Attribution
116
116
 
@@ -118,8 +118,8 @@ This Code of Conduct is adapted from the [Contributor Covenant][homepage],
118
118
  version 2.0, available at
119
119
  https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
120
120
 
121
- Community Impact Guidelines were inspired by [Mozilla's code of conduct
122
- enforcement ladder](https://github.com/mozilla/diversity).
121
+ Community Impact Guidelines were inspired by
122
+ [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity).
123
123
 
124
124
  [homepage]: https://www.contributor-covenant.org
125
125
 
package/CONTRIBUTING.md CHANGED
@@ -1,11 +1,15 @@
1
1
  # How to contribute
2
2
 
3
- We'd love to accept your patches and contributions to this project. There are just a few small guidelines you need to follow.
3
+ We'd love to accept your patches and contributions to this project. There are
4
+ just a few small guidelines you need to follow.
4
5
 
5
6
  ## Code reviews
6
7
 
7
- All submissions require review. We use GitHub pull requests for this purpose. Consult [GitHub Help](https://help.github.com/articles/about-pull-requests/) for more information on using pull requests.
8
+ All submissions require review. We use GitHub pull requests for this purpose.
9
+ Consult [GitHub Help](https://help.github.com/articles/about-pull-requests/) for
10
+ more information on using pull requests.
8
11
 
9
12
  ## Style Guide
10
13
 
11
- This project provides a prettier configuration. All submitted PRs will be required to conform to this style guide before being merged.
14
+ This project provides a prettier configuration. All submitted PRs will be
15
+ required to conform to this style guide before being merged.
package/README.md CHANGED
@@ -117,7 +117,40 @@ jobs:
117
117
  steps:
118
118
  - name: Issue Forms Body Parser
119
119
  id: parse
120
- uses: zentered/issue-forms-body-parser@v1.4.3
120
+ uses: zentered/issue-forms-body-parser@v2.0.0
121
+ - run: echo "${{ JSON.stringify(steps.parse.outputs.data) }}"
122
+ ```
123
+
124
+ You can also provide a custom `body` input:
125
+
126
+ ```yml
127
+ name: Issue Forms Body Parser
128
+
129
+ on:
130
+ workflow_dispatch:
131
+ inputs:
132
+ issue_number:
133
+ type: string
134
+ required: true
135
+ env:
136
+ GH_TOKEN: ${{ github.token }}
137
+
138
+ jobs:
139
+ process:
140
+ runs-on: ubuntu-latest
141
+ steps:
142
+ - name: Fetch the issue
143
+ id: read_issue_body
144
+ run:
145
+ echo "body=$(gh issue view ${{ inputs.issue_number }} --repo ${{
146
+ github.repo }} --json body --jq '.body')" >> $GITHUB_OUTPUT
147
+
148
+ - name: Issue Forms Body Parser
149
+ id: parse
150
+ uses: zentered/issue-forms-body-parser@v2.0.0
151
+ with:
152
+ body: ${{ steps.read_issue_body.output.body }}
153
+
121
154
  - run: echo "${{ JSON.stringify(steps.parse.outputs.data) }}"
122
155
  ```
123
156
 
@@ -141,7 +174,7 @@ const issueData = await bodyParser(issue.body)
141
174
 
142
175
  You can use [act](https://github.com/nektos/act) to test this Action locally.
143
176
 
144
- `npm run build && act issue -e test/issue.json`
177
+ `npm run build && act issues -e test/issue.json`
145
178
 
146
179
  or run:
147
180
 
package/action.yml CHANGED
@@ -6,6 +6,9 @@ description:
6
6
  branding:
7
7
  color: blue
8
8
  icon: chevron-right
9
+ inputs:
10
+ body:
11
+ description: 'The body to parse.'
9
12
  outputs:
10
13
  data:
11
14
  description:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zentered/issue-forms-body-parser",
3
- "version": "2.0.0",
3
+ "version": "2.1.1",
4
4
  "private": false,
5
5
  "description": "Parser for GitHub Issue Form body, also available as GitHub Action",
6
6
  "keywords": [
@@ -25,6 +25,10 @@
25
25
  "name": "Patrick Heneise",
26
26
  "url": "https://zentered.co",
27
27
  "author": true
28
+ },
29
+ {
30
+ "name": "Benjamin Grandfond",
31
+ "url": "https://github.com/benja-M-1"
28
32
  }
29
33
  ],
30
34
  "type": "module",
@@ -39,9 +43,7 @@
39
43
  "license-checker": "license-checker --production --onlyAllow=\"MIT;ISC;BSD-3-Clause;BSD-2-Clause;Apache-2.0\"",
40
44
  "test": "tap --node-arg=--experimental-json-modules --test-env=GITHUB_REPOSITORY=zentered/issue-forms-body-parser-test -J test/*.test.js",
41
45
  "test:report": "tap --test-env=GITHUB_REPOSITORY=zentered/issue-forms-body-parser-test -J test/*.test.js --cov",
42
- "_postinstall": "husky install",
43
- "prepublishOnly": "pinst --disable",
44
- "postpublish": "pinst --enable"
46
+ "prepare": "is-ci || husky install"
45
47
  },
46
48
  "commitlint": {
47
49
  "extends": [
@@ -67,6 +69,7 @@
67
69
  "@sindresorhus/slugify": "^2.1.1",
68
70
  "date-fns": "^2.29.3",
69
71
  "date-fns-tz": "^1.3.7",
72
+ "is-ci": "^3.0.1",
70
73
  "remark-gfm": "^3.0.1",
71
74
  "remark-parse": "^10.0.1",
72
75
  "remark-stringify": "^10.0.2",
@@ -74,19 +77,19 @@
74
77
  "unified": "^10.1.2"
75
78
  },
76
79
  "devDependencies": {
77
- "@commitlint/config-conventional": "^17.3.0",
80
+ "@commitlint/config-conventional": "^17.4.2",
78
81
  "@vercel/ncc": "^0.36.0",
79
- "commitlint": "^17.3.0",
80
- "eslint": "^8.31.0",
82
+ "commitlint": "^17.4.2",
83
+ "eslint": "^8.32.0",
81
84
  "eslint-plugin-json": "^3.1.0",
82
85
  "eslint-plugin-node": "^11.1.0",
83
- "husky": "^8.0.2",
86
+ "husky": "^8.0.3",
84
87
  "license-checker": "^25.0.1",
85
88
  "microbundle": "^0.15.1",
86
89
  "npm-run-all": "^4.1.5",
87
90
  "pinst": "^3.0.0",
88
- "prettier": "^2.8.1",
89
- "tap": "^16.3.2"
91
+ "prettier": "^2.8.3",
92
+ "tap": "^16.3.4"
90
93
  },
91
94
  "src": "src/parse.js"
92
95
  }
package/src/index.js CHANGED
@@ -7,8 +7,14 @@ import parse from './parse.js'
7
7
  async function run() {
8
8
  core.info('Parsing issue body ...')
9
9
 
10
+ let content = core.getInput('body')
11
+
12
+ if (content === '' && Object.hasOwn(github.context.payload, 'issue')) {
13
+ content = github.context.payload.issue.body
14
+ }
15
+
10
16
  try {
11
- const parsedContent = await parse(github.context.payload.issue.body)
17
+ const parsedContent = await parse(content)
12
18
 
13
19
  if (parsedContent !== undefined) {
14
20
  core.setOutput('data', parsedContent)
@@ -1 +0,0 @@
1
- {"parent":"97cfe5ec-7f32-43f6-a236-732be371a17f","pid":2031,"argv":["/usr/local/bin/node","/home/runner/work/issue-forms-body-parser/issue-forms-body-parser/test/parse-issue.test.js"],"execArgv":["--experimental-json-modules"],"cwd":"/home/runner/work/issue-forms-body-parser/issue-forms-body-parser","time":1672678697041,"ppid":2020,"coverageFilename":"/home/runner/work/issue-forms-body-parser/issue-forms-body-parser/.nyc_output/78e2aab5-e45b-4d92-a67a-363ff5cbfcf8.json","externalId":"test/parse-issue.test.js","uuid":"78e2aab5-e45b-4d92-a67a-363ff5cbfcf8","files":[]}
@@ -1 +0,0 @@
1
- {"parent":null,"pid":2020,"argv":["/usr/local/bin/node","/home/runner/work/issue-forms-body-parser/issue-forms-body-parser/node_modules/.bin/tap","--node-arg=--experimental-json-modules","--test-env=GITHUB_REPOSITORY=zentered/issue-forms-body-parser-test","-J","test/parse-issue.test.js"],"execArgv":[],"cwd":"/home/runner/work/issue-forms-body-parser/issue-forms-body-parser","time":1672678696683,"ppid":2009,"coverageFilename":"/home/runner/work/issue-forms-body-parser/issue-forms-body-parser/.nyc_output/97cfe5ec-7f32-43f6-a236-732be371a17f.json","externalId":"","uuid":"97cfe5ec-7f32-43f6-a236-732be371a17f","files":[]}