create-node-lib 2.6.0 → 2.7.0

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.
Files changed (36) hide show
  1. package/.github/workflows/main.yml +4 -4
  2. package/__tests__/generator.test.js +6 -6
  3. package/package.json +5 -5
  4. package/saofile.js +15 -11
  5. package/template/.github/.markdownlint.yml +9 -0
  6. package/template/.github/CODEOWNERS +1 -0
  7. package/template/{CONTRIBUTING.md → .github/CONTRIBUTING.md} +9 -5
  8. package/template/.github/ISSUE_TEMPLATE/1-bug-report.yml +31 -0
  9. package/template/.github/ISSUE_TEMPLATE/2-feature-request.yml +23 -0
  10. package/template/.github/dependabot.yml +38 -0
  11. package/template/.github/labeler.yml +20 -0
  12. package/template/.github/workflows/ci.yml +49 -0
  13. package/template/.github/workflows/labeler.yml +12 -0
  14. package/template/.github/workflows/links-checker-schedule.yml +28 -0
  15. package/template/.github/workflows/lock-threads.yml +34 -0
  16. package/template/.github/workflows/markdown-lint.yml +26 -0
  17. package/template/.github/workflows/release.yml +38 -0
  18. package/template/.husky/commit-msg +1 -1
  19. package/template/README.md +8 -17
  20. package/template/RELEASE.md +42 -0
  21. package/template/SECURITY.md +14 -5
  22. package/template/__tests__/app.test.ts +17 -0
  23. package/template/eslint.config.js +32 -0
  24. package/template/package.json +51 -185
  25. package/template/src/bin/cli.ts +12 -0
  26. package/template/src/main.ts +3 -0
  27. package/template/tsconfig.json +37 -0
  28. package/template/tsup.config.ts +29 -0
  29. package/template/.github/ISSUE_TEMPLATE/1-bug-report.md +0 -44
  30. package/template/.github/ISSUE_TEMPLATE/2-feature-request.md +0 -19
  31. package/template/.github/workflows/main.yml +0 -53
  32. package/template/__tests__/app.test.js +0 -5
  33. package/template/bin/cli.js +0 -4
  34. package/template/gitignore +0 -111
  35. package/template/src/main.js +0 -5
  36. /package/template/{CODE_OF_CONDUCT.md → .github/CODE_OF_CONDUCT.md} +0 -0
@@ -32,10 +32,10 @@ jobs:
32
32
  run: npm ci --ignore-engines --audit false
33
33
  - name: run tests
34
34
  run: npm run test
35
- - name: code coverage report
36
- run: npx codecov
37
- env:
38
- CODECOV_TOKEN: ${{secrets.CODECOV_TOKEN}}
35
+ # - name: code coverage report
36
+ # run: npx codecov
37
+ # env:
38
+ # CODECOV_TOKEN: ${{secrets.CODECOV_TOKEN}}
39
39
 
40
40
  release:
41
41
  name: do semantic release
@@ -8,10 +8,12 @@ describe('all the template files are accountable for', () => {
8
8
  jest.setTimeout(15000)
9
9
  const stream = await sao.mock({ generator: template })
10
10
  expect(stream.fileList).toContain('.github/ISSUE_TEMPLATE.md')
11
- expect(stream.fileList).toContain('.github/ISSUE_TEMPLATE/1-bug-report.md')
12
- expect(stream.fileList).toContain('.github/ISSUE_TEMPLATE/2-feature-request.md')
11
+ expect(stream.fileList).toContain('.github/ISSUE_TEMPLATE/1-bug-report.yml')
12
+ expect(stream.fileList).toContain('.github/ISSUE_TEMPLATE/2-feature-request.yml')
13
13
  expect(stream.fileList).toContain('.github/ISSUE_TEMPLATE/3-help.md')
14
14
  expect(stream.fileList).toContain('.github/PULL_REQUEST_TEMPLATE.md')
15
+ expect(stream.fileList).toContain('.github/CODE_OF_CONDUCT.md')
16
+ expect(stream.fileList).toContain('.github/CONTRIBUTING.md')
15
17
  })
16
18
 
17
19
  test('generator contains project files', async () => {
@@ -26,12 +28,10 @@ describe('all the template files are accountable for', () => {
26
28
  expect(stream.fileList).toContain('.gitignore')
27
29
  expect(stream.fileList).toContain('.prettierignore')
28
30
  expect(stream.fileList).toContain('.prettierrc.json')
29
- expect(stream.fileList).toContain('.github/workflows/main.yml')
30
- expect(stream.fileList).toContain('CODE_OF_CONDUCT.md')
31
- expect(stream.fileList).toContain('CONTRIBUTING.md')
31
+ expect(stream.fileList).toContain('.github/workflows/ci.yml')
32
32
  expect(stream.fileList).toContain('LICENSE')
33
33
  expect(stream.fileList).toContain('README.md')
34
- expect(stream.fileList).toContain('__tests__/app.test.js')
34
+ expect(stream.fileList).toContain('__tests__/app.test.ts')
35
35
  expect(stream.fileList).toContain('package.json')
36
36
  })
37
37
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-node-lib",
3
- "version": "2.6.0",
3
+ "version": "2.7.0",
4
4
  "description": "Scaffolding out a Node.js library module",
5
5
  "bin": "./bin/cli.js",
6
6
  "engines": {
@@ -81,10 +81,10 @@
81
81
  "collectCoverage": true,
82
82
  "coverageThreshold": {
83
83
  "global": {
84
- "branches": 70,
85
- "functions": 70,
86
- "lines": 70,
87
- "statements": 70
84
+ "branches": 50,
85
+ "functions": 50,
86
+ "lines": 50,
87
+ "statements": 50
88
88
  }
89
89
  },
90
90
  "testPathIgnorePatterns": [
package/saofile.js CHANGED
@@ -6,7 +6,10 @@ const SUPPORTED_NPM_CLIENTS = ['npm', 'yarn']
6
6
  module.exports = {
7
7
  description: 'Scaffolding out a node library.',
8
8
  templateData: {
9
- year: new Date().getFullYear()
9
+ year: new Date().getFullYear(),
10
+ npmClientInstall: ({ npmClient }) => {
11
+ return npmClient === 'npm' ? 'install' : 'add'
12
+ }
10
13
  },
11
14
  prompts() {
12
15
  return [
@@ -30,12 +33,12 @@ module.exports = {
30
33
  {
31
34
  name: 'description',
32
35
  message: 'How would you describe the new project',
33
- default: ``
36
+ default: ''
34
37
  },
35
38
  {
36
39
  name: 'keywords',
37
40
  message: 'Comma-separated list of package keywords for npm',
38
- default: ``
41
+ default: ''
39
42
  },
40
43
  {
41
44
  name: 'author',
@@ -90,14 +93,15 @@ module.exports = {
90
93
  ] = `lockfile-lint --path ${lockfile} --validate-https --allowed-hosts npm yarn`
91
94
  return data
92
95
  }
93
- },
94
- {
95
- type: 'move',
96
- patterns: {
97
- gitignore: '.gitignore'
98
- // '_package.json': 'package.json'
99
- }
100
96
  }
97
+ // we already have the .gitignore file as part of the template/ directory
98
+ // {
99
+ // type: 'move',
100
+ // patterns: {
101
+ // gitignore: '.gitignore'
102
+ // // '_package.json': 'package.json'
103
+ // }
104
+ // }
101
105
  ]
102
106
  },
103
107
  async completed() {
@@ -105,6 +109,6 @@ module.exports = {
105
109
  await this.npmInstall({ npmClient: this.answers.npmClient })
106
110
  this.showProjectTips()
107
111
 
108
- this.logger.tip(`You're all setup. hack away!`)
112
+ this.logger.tip('You\'re all setup. hack away!')
109
113
  }
110
114
  }
@@ -0,0 +1,9 @@
1
+ default: true
2
+
3
+ # Line length - https://github.com/DavidAnson/markdownlint/blob/master/doc/Rules.md#md013---line-length
4
+ MD013:
5
+ code_blocks: false
6
+ tables: false
7
+
8
+ # Do not enforce line length in markdown files
9
+ line_length: false
@@ -0,0 +1 @@
1
+ * @<%= username %>
@@ -2,14 +2,17 @@
2
2
 
3
3
  :+1::tada: First off, thanks for taking the time to contribute! :tada::+1:
4
4
 
5
- The following is a set of guidelines for contributing to <%= projectName %>.
6
- These are mostly guidelines, not rules. Use your best judgment, and feel free to propose changes to this document in a pull request.
5
+ The following is a set of guidelines for contributing to this project.
6
+ These are mostly guidelines, not rules. Use your best judgment, and feel free
7
+ to propose changes to this document in a pull request.
7
8
 
8
9
  ## Code of Conduct
9
10
 
10
- This project and everyone participating in it is governed by a [Code of Conduct](./CODE_OF_CONDUCT.md). By participating, you are expected to uphold this code.
11
+ This project and everyone participating in it is governed by a
12
+ [Code of Conduct](./CODE_OF_CONDUCT.md). By participating, you are expected to
13
+ uphold this code.
11
14
 
12
- ## How to contribute to <%= projectName %>
15
+ ## How to contribute to this project
13
16
 
14
17
  <!-- TODO -->
15
18
 
@@ -25,4 +28,5 @@ npm run test
25
28
 
26
29
  ### Commit Guidelines
27
30
 
28
- The project uses the commitizen tool for standardizing changelog style commit and a git pre-commit hook to enforce them.
31
+ The project uses the commitizen tool for standardizing changelog style commit
32
+ and a git pre-commit hook to enforce them.
@@ -0,0 +1,31 @@
1
+ body:
2
+ - attributes:
3
+ description: If any of these required steps are not taken, we may not be able to review your issue. Help us to help you!
4
+ label: Bug Report Checklist
5
+ options:
6
+ - label: I have pulled the latest `main` branch of the repository.
7
+ required: true
8
+ - label: I have [searched for related issues](https://github.com/<%= username %>/<%= projectName %>/issues?q=is%3Aissue) and found none that matched my issue.
9
+ required: true
10
+ type: checkboxes
11
+ - attributes:
12
+ description: What did you expect to happen?
13
+ label: Expected
14
+ type: textarea
15
+ validations:
16
+ required: true
17
+ - attributes:
18
+ description: What happened instead?
19
+ label: Actual
20
+ type: textarea
21
+ validations:
22
+ required: true
23
+ - attributes:
24
+ description: Any additional info you'd like to provide.
25
+ label: Additional Info
26
+ type: textarea
27
+ description: Report a bug trying to run the code
28
+ labels:
29
+ - "type: bug"
30
+ name: 🐛 Bug
31
+ title: "🐛 Bug: <short description of the bug>"
@@ -0,0 +1,23 @@
1
+ body:
2
+ - attributes:
3
+ description: If any of these required steps are not taken, we may not be able to review your issue. Help us to help you!
4
+ label: Bug Report Checklist
5
+ options:
6
+ - label: I have pulled the latest `main` branch of the repository.
7
+ required: true
8
+ type: checkboxes
9
+ - attributes:
10
+ description: What did you expect to be able to do? Please describe the problem you are trying to solve.
11
+ label: Overview
12
+ type: textarea
13
+ validations:
14
+ required: true
15
+ - attributes:
16
+ description: Any additional info you'd like to provide.
17
+ label: Additional Info
18
+ type: textarea
19
+ description: Request that a new feature be added or an existing feature improved
20
+ labels:
21
+ - "type: feature"
22
+ name: 🚀 Feature
23
+ title: "🚀 Feature: <short description of the feature>"
@@ -0,0 +1,38 @@
1
+ version: 2
2
+ updates:
3
+ - package-ecosystem: "github-actions"
4
+ directory: ".github/workflows"
5
+ schedule:
6
+ interval: "monthly"
7
+ commit-message:
8
+ # Prefix all commit messages with "chore: "
9
+ prefix: "chore"
10
+ open-pull-requests-limit: 10
11
+
12
+ - package-ecosystem: "npm"
13
+ directory: "/"
14
+ commit-message:
15
+ # Prefix all commit messages with "chore: "
16
+ prefix: "chore"
17
+ schedule:
18
+ interval: "weekly"
19
+ open-pull-requests-limit: 10
20
+ groups:
21
+ # Production dependencies without breaking changes
22
+ dependencies:
23
+ dependency-type: "production"
24
+ update-types:
25
+ - "minor"
26
+ - "patch"
27
+ # Production dependencies with breaking changes
28
+ dependencies-major:
29
+ dependency-type: "production"
30
+ update-types:
31
+ - "major"
32
+ # Development dependencies
33
+ dev-dependencies:
34
+ dependency-type: "development"
35
+ # example for ignoring dependencies:
36
+ # ignore:
37
+ # - dependency-name: tap
38
+ # update-types: ["version-update:semver-major"]
@@ -0,0 +1,20 @@
1
+ documentation:
2
+ - changed-files:
3
+ - any-glob-to-any-file:
4
+ - "docs/*"
5
+ - "**/*.md"
6
+ - "guides/*"
7
+
8
+ build:
9
+ - changed-files:
10
+ - any-glob-to-any-file: ".github/workflows/*"
11
+
12
+ typescript:
13
+ - changed-files:
14
+ - any-glob-to-any-file: "**/*[.|-]d.ts"
15
+
16
+ cli:
17
+ - any: ["bin/**/*", "cli/**/*"]
18
+
19
+ test:
20
+ - any: ["test/**/*", "__tests__/**/*"]
@@ -0,0 +1,49 @@
1
+ name: CI
2
+
3
+ on: [push, pull_request]
4
+
5
+ jobs:
6
+ test:
7
+ strategy:
8
+ matrix:
9
+ node: ["18.x", "20.x", "22.0.0"]
10
+ platform: [ubuntu-latest]
11
+ name: Node v${{matrix.node}} ((${{matrix.platform}}))
12
+ runs-on: ${{matrix.platform}}
13
+ steps:
14
+ - uses: actions/checkout@v4
15
+ - uses: actions/setup-node@v4
16
+ with:
17
+ node-version: ${{matrix.node}}
18
+ - name: install dependencies
19
+ run: npm ci
20
+ - name: lint code
21
+ run: npm run lint
22
+ - name: build project
23
+ run: npm run build
24
+ - name: run tests
25
+ run: npm run test
26
+ - name: coverage
27
+ uses: codecov/codecov-action@v4
28
+ if: github.actor != 'dependabot[bot]'
29
+ with:
30
+ fail_ci_if_error: true
31
+ verbose: false
32
+ token: ${{ secrets.CODECOV_TOKEN }}
33
+ env:
34
+ CI: true
35
+
36
+ release-preview:
37
+ runs-on: ubuntu-latest
38
+ needs: test
39
+ steps:
40
+ - uses: actions/checkout@v4
41
+ - uses: actions/setup-node@v4
42
+ with:
43
+ node-version: "22.0.0"
44
+ - name: install dependencies
45
+ run: npm ci
46
+ - name: build project
47
+ run: npm run build
48
+ - name: release preview with pkr-pr-new
49
+ run: npx pkg-pr-new publish
@@ -0,0 +1,12 @@
1
+ name: "Pull Request Labeler"
2
+
3
+ on: pull_request_target
4
+
5
+ jobs:
6
+ label:
7
+ permissions:
8
+ contents: read
9
+ pull-requests: write
10
+ runs-on: ubuntu-latest
11
+ steps:
12
+ - uses: actions/labeler@v5
@@ -0,0 +1,28 @@
1
+ name: Links Checker (On Schedule)
2
+
3
+ on:
4
+ repository_dispatch:
5
+ workflow_dispatch:
6
+ schedule:
7
+ - cron: "00 18 * * *"
8
+
9
+ jobs:
10
+ linkChecker:
11
+ runs-on: ubuntu-latest
12
+ steps:
13
+ - name: Check out repo
14
+ uses: actions/checkout@v4
15
+ with:
16
+ persist-credentials: false
17
+
18
+ - name: Link Checker
19
+ id: lychee
20
+ uses: lycheeverse/lychee-action@2b973e86fc7b1f6b36a93795fe2c9c6ae1118621 # v1.10.0
21
+
22
+ - name: Create Issue From File
23
+ if: env.lychee_exit_code != 0
24
+ uses: peter-evans/create-issue-from-file@24452a72d85239eacf1468b0f1982a9f3fec4c94 # v5.0.0
25
+ with:
26
+ title: Link Checker Report
27
+ content-filepath: ./lychee/out.md
28
+ labels: report, automated issue
@@ -0,0 +1,34 @@
1
+ ---
2
+ name: stale
3
+
4
+ on:
5
+ workflow_dispatch:
6
+ schedule:
7
+ - cron: "9 9 * * *"
8
+
9
+ permissions:
10
+ issues: write
11
+ pull-requests: write
12
+
13
+ jobs:
14
+ stale:
15
+ runs-on: ubuntu-latest
16
+ steps:
17
+ - uses: actions/stale@28ca1036281a5e5922ead5184a1bbf96e5fc984e # v9.0.0
18
+ with:
19
+ close-issue-message: |
20
+ This issue has not seen any activity since it was marked stale.
21
+ Closing.
22
+ close-pr-message: |
23
+ This pull request has not seen any activity since it was marked stale.
24
+ Closing.
25
+ exempt-issue-labels: good-first-issue,need-help,no-stale,pinned,security
26
+ exempt-pr-labels: "autorelease: pending,good-first-issue,need-help,no-stale,pinned,security"
27
+ stale-issue-label: stale
28
+ stale-issue-message: |
29
+ This issue is stale because it has been open 60 days with no activity.
30
+ Remove stale label or comment or this will be closed in 7 days
31
+ stale-pr-label: stale
32
+ stale-pr-message: |
33
+ This PR is stale because it has been open 60 days with no activity.
34
+ Remove stale label or comment or this will be closed in 7 days.
@@ -0,0 +1,26 @@
1
+ name: Markdown Lint
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - main
7
+ pull_request:
8
+
9
+ jobs:
10
+ markdown_lint:
11
+ name: Lint Markdown files
12
+ runs-on: ubuntu-latest
13
+ steps:
14
+ - uses: actions/checkout@v4
15
+
16
+ - name: Markdown Lint
17
+ uses: ruzickap/action-my-markdown-linter@26b4129bf0352527e60b5bd739357af63df1b7bf
18
+ with:
19
+ debug: true
20
+ config_file: .github/.markdownlint.yml
21
+ exclude: |
22
+ .changeset/
23
+ .github/
24
+ CODE_OF_CONDUCT.md
25
+ LICENSE
26
+ CHANGELOG.md
@@ -0,0 +1,38 @@
1
+ name: release
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - main
7
+
8
+ concurrency: ${{ github.workflow }}-${{ github.ref }}
9
+
10
+ jobs:
11
+ release:
12
+ permissions:
13
+ contents: write # to create release (changesets/action)
14
+ issues: write # to post issue comments (changesets/action)
15
+ pull-requests: write # to create pull request (changesets/action)
16
+ id-token: write # to create release (changesets/action)
17
+ packages: write # to publish to npm (changesets/action)
18
+ timeout-minutes: 20
19
+ runs-on: ubuntu-latest
20
+ steps:
21
+ - uses: actions/checkout@v4
22
+ - uses: actions/setup-node@v4
23
+ with:
24
+ node-version: 20.x
25
+ - name: install dependencies
26
+ run: npm ci
27
+ - name: build project
28
+ run: npm run build
29
+ - name: Create Release Pull Request or Publish to npm
30
+ uses: changesets/action@v1
31
+ with:
32
+ publish: npm run release
33
+ version: npm run version
34
+ commit: "chore: new release"
35
+ title: "chore: new release candidate"
36
+ env:
37
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
38
+ NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
@@ -1,4 +1,4 @@
1
1
  #!/bin/sh
2
2
  . "$(dirname "$0")/_/husky.sh"
3
3
 
4
- npx --no-install commitlint --edit ""
4
+ npx --no validate-conventional-commit < .git/COMMIT_EDITMSG
@@ -1,4 +1,4 @@
1
- <% const npmClientInstall = context.npmClient === 'npm' ? 'install --save' : 'add' -%>
1
+ <!-- markdownlint-disable -->
2
2
 
3
3
  <p align="center"><h1 align="center">
4
4
  <%= projectName %>
@@ -18,31 +18,22 @@
18
18
  <a href="./SECURITY.md"><img src="https://img.shields.io/badge/Security-Responsible%20Disclosure-yellow.svg" alt="Responsible Disclosure Policy" /></a>
19
19
  </p>
20
20
 
21
- # About
22
-
23
- <%= description %>
24
-
25
- # Install
21
+ ## Install
26
22
 
27
23
  ```bash
28
24
  <%= npmClient %> <%= npmClientInstall %> <%= projectName %>
29
25
  ```
26
+ ## Usage: CLI
30
27
 
31
- # Usage
32
-
33
- ```js
28
+ ```bash
34
29
  // @TODO
35
30
  const {} = require('<%= projectName %>')
36
31
  ```
37
32
 
38
- # Example
39
-
40
- <!-- TODO -->
41
-
42
- # Contributing
33
+ ## Contributing
43
34
 
44
- Please consult [CONTRIBUTING](./CONTRIBUTING.md) for guidelines on contributing to this project.
35
+ Please consult [CONTRIBUTING](./.github/CONTRIBUTING.md) for guidelines on contributing to this project.
45
36
 
46
- # Author
37
+ ## Author
47
38
 
48
- **<%= projectName %>** © [<%= author %>](https://github.com/<%= username %>), Released under the [Apache-2.0](./LICENSE) License.
39
+ **<%= projectName %>** © [<%= author %>](https://github.com/<%= username %>), Released under the [Apache-2.0](./LICENSE) License.
@@ -0,0 +1,42 @@
1
+ # Managing Package Releases
2
+
3
+ This project uses the [Changesets](https://github.com/changesets/changesets)
4
+ tool to manage semantic versioning and release notes.
5
+
6
+ ## Pre-requisites
7
+
8
+ Permit GitHub Actions to create and approve pull requests:
9
+
10
+ 1. Go to Actions -> General in the repository settings: (`https://github.com/<user>/<repo>/settings/actions`)
11
+ 2. In `Workflow permissions` enable the toggle for
12
+ `Allow GitHub Actions to create and approve pull requests` (it is not required
13
+ to also toggle the `Read and write permission` option)
14
+
15
+ ## How to release a new version of the package
16
+
17
+ ### Step 1: Create a new changeset
18
+
19
+ ```sh
20
+ npx changeset
21
+ ```
22
+
23
+ Follow the prompt to choose the major/minor/patch version and affected
24
+ packages (if a monorepo).
25
+
26
+ ### Step 2: Commit the changeset file(s) to the repository
27
+
28
+ ```sh
29
+ git add .changeset/
30
+ git commit -m "chore: add changeset for release"
31
+ git push origin HEAD
32
+ ```
33
+
34
+ ### Step 3: A new Pull Request for versioning
35
+
36
+ The Changesets GitHub Action will pick up the new changeset in the repository
37
+ and open a new pull request with the versioning changes in the relevant package
38
+ manifest files. Review the changes and merge the pull request.
39
+
40
+ ### Step 4: Publish the package
41
+
42
+ The GitHub Action will automatically publish the package to the npm registry.
@@ -4,16 +4,25 @@
4
4
 
5
5
  ## Responsible disclosure security policy
6
6
 
7
- A responsible disclosure policy helps protect users of the project from public disclosure of security vulnerabilities without a fix available. We achieve that by following the process where vulnerabilities are first triaged in a private manner, and are only publicly disclosed after a reasonable time period of the patch being available for users.
7
+ A responsible disclosure policy helps protect users of the project from public
8
+ disclosure of security vulnerabilities without a fix available. We achieve
9
+ that by following the process where vulnerabilities are first triaged in a
10
+ private manner, and are only publicly disclosed after a reasonable time period
11
+ of the patch being available for users.
8
12
 
9
- We kindly ask you to refrain from malicious acts that put our users, the project, or any of the project’s team members at risk.
13
+ We kindly ask you to refrain from malicious acts that put our users, the
14
+ project, or any of the project’s team members at risk.
10
15
 
11
16
  ## Reporting a security issue
12
17
 
13
18
  We consider the security of the project a top priority.
14
19
 
15
- If you discover a security vulnerability, please use one of the following means of communications to report it to us:
20
+ If you discover a security vulnerability, please use one of the following
21
+ means of communications to report it to us:
16
22
 
17
- - Report the security issue to the [Snyk Security Team](https://snyk.io/vulnerability-disclosure). They will help triage the security issue and work with all involved parties to remediate and release a fix.
23
+ - Report the security issue to the [Snyk Security Team](https://snyk.io/vulnerability-disclosure).
24
+ - They will help triage the security issue and work with all involved parties
25
+ - to remediate and release a fix.
18
26
 
19
- We sincerely appreciate your efforts to responsibly disclose your findings with us.
27
+ We sincerely appreciate your efforts to responsibly disclose your findings
28
+ with us.
@@ -0,0 +1,17 @@
1
+ import { test, describe, beforeEach, mock } from 'node:test'
2
+ import assert from 'node:assert'
3
+ import { add } from '../src/main.ts'
4
+
5
+ describe('CLI program', () => {
6
+
7
+ beforeEach(() => {
8
+ // Reset the mocks before each test
9
+ mock.reset()
10
+ });
11
+
12
+ test('Program sums two arguments', async (t) => {
13
+ const result = await add(1, 1);
14
+ assert.strictEqual(result, 2);
15
+ })
16
+
17
+ });
@@ -0,0 +1,32 @@
1
+ import pluginSecurity from 'eslint-plugin-security'
2
+ import neostandard, { resolveIgnoresFromGitignore, plugins } from 'neostandard'
3
+
4
+ export default [
5
+ ...neostandard({ ignores: resolveIgnoresFromGitignore() }),
6
+ plugins.n.configs['flat/recommended-script'],
7
+ pluginSecurity.configs.recommended,
8
+ {
9
+ rules: {
10
+ 'no-process-exit': 'warn',
11
+ 'node/no-unsupported-features': 'off',
12
+ 'node/no-unpublished-require': 'off',
13
+ 'security/detect-non-literal-fs-filename': 'error',
14
+ 'security/detect-unsafe-regex': 'error',
15
+ 'security/detect-buffer-noassert': 'error',
16
+ 'security/detect-child-process': 'error',
17
+ 'security/detect-disable-mustache-escape': 'error',
18
+ 'security/detect-eval-with-expression': 'error',
19
+ 'security/detect-no-csrf-before-method-override': 'error',
20
+ 'security/detect-non-literal-regexp': 'error',
21
+ 'security/detect-object-injection': 'warn',
22
+ 'security/detect-possible-timing-attacks': 'error',
23
+ 'security/detect-pseudoRandomBytes': 'error',
24
+ 'space-before-function-paren': 'off',
25
+ 'object-curly-spacing': 'off',
26
+ },
27
+ languageOptions: {
28
+ ecmaVersion: 2024,
29
+ sourceType: 'module',
30
+ },
31
+ },
32
+ ]
@@ -1,37 +1,57 @@
1
1
  {
2
2
  "name": "<%= projectName %>",
3
- "version": "0.0.0-development",
3
+ "version": "0.0.1",
4
4
  "description": "<%= description %>",
5
- "main": "main.js",
6
- "bin": {
7
- "cli": "bin/cli.js"
8
- },
5
+ "types": "dist/main.d.ts",
6
+ "type": "module",
7
+ "bin": "./dist/bin/cli.cjs",
9
8
  "exports": {
10
- ".": "./src/main.js"
9
+ ".": {
10
+ "import": {
11
+ "types": "./dist/main.d.ts",
12
+ "default": "./dist/main.mjs"
13
+ },
14
+ "require": {
15
+ "types": "./dist/main.d.cts",
16
+ "default": "./dist/main.cjs"
17
+ },
18
+ "default": "./dist/main.mjs"
19
+ },
20
+ "./dist/*": {
21
+ "types": "./dist/*.d.ts",
22
+ "import": "./dist/*.mjs",
23
+ "require": "./dist/*.cjs"
24
+ }
11
25
  },
12
26
  "engines": {
13
- "node": ">=14.0.0"
27
+ "node": ">=20.0.0"
14
28
  },
15
- "type": "module",
29
+ "packageManager": "npm@8.4.0",
16
30
  "files": [
31
+ "dist",
17
32
  "src",
18
33
  "bin"
19
34
  ],
20
35
  "scripts": {
21
- "lint": "eslint . && <%= npmClient %> run lint:lockfile",
36
+ "build": "tsc && tsup",
37
+ "lint": "eslint . && npm run lint:lockfile",
22
38
  "lint:fix": "eslint . --fix",
23
- "format": "prettier --config .prettierrc.json --write '**/*.js'",
24
- "test": "NODE_OPTIONS=--experimental-vm-modules npx jest",
25
- "test:watch": "NODE_OPTIONS=--experimental-vm-modules npx jest --watch",
26
- "coverage:view": "open-cli coverage/lcov-report/index.html",
27
- "semantic-release": "npx semantic-release",
28
- "prepare": "husky install && chmod 755 .husky/*"
39
+ "lint:lockfile": "lockfile-lint --path package-lock.json --validate-https --allowed-hosts npm yarn",
40
+ "test": "c8 node --loader ts-node/esm --test __tests__/**",
41
+ "test:watch": "c8 node --loader ts-node/esm --test --watch __tests__/**",
42
+ "coverage:view": "open coverage/lcov-report/index.html",
43
+ "version": "changeset version",
44
+ "release": "changeset publish"
29
45
  },
30
46
  "author": {
31
47
  "name": "<%= author %>",
32
48
  "email": "<%= email %>",
33
49
  "url": "https://github.com/<%= username %>"
34
50
  },
51
+ "publishConfig": {
52
+ "provenance": true,
53
+ "access": "public"
54
+ },
35
55
  "license": "Apache-2.0",
36
56
  "keywords": [
37
57
  "<%= keywords %>"
@@ -44,179 +64,25 @@
44
64
  "type": "git",
45
65
  "url": "<%= projectRepository %>.git"
46
66
  },
47
- "dependencies": {},
48
67
  "devDependencies": {
49
- "@babel/core": "^7.20.12",
50
- "@babel/eslint-parser": "^7.19.1",
51
- "@babel/plugin-syntax-top-level-await": "^7.14.5",
52
- "@commitlint/cli": "^17.4.2",
53
- "@commitlint/config-conventional": "^17.4.2",
54
- "@semantic-release/changelog": "^6.0.2",
55
- "@semantic-release/commit-analyzer": "^9.0.2",
56
- "@semantic-release/git": "^10.0.1",
57
- "@semantic-release/github": "^8.0.7",
58
- "@semantic-release/npm": "^9.0.2",
59
- "@semantic-release/release-notes-generator": "^10.0.3",
60
- "eslint": "^8.33.0",
61
- "eslint-plugin-jest": "^27.2.1",
62
- "eslint-plugin-node": "^11.1.0",
63
- "eslint-plugin-security": "^1.7.1",
64
- "eslint-plugin-standard": "^4.1.0",
65
- "husky": "^8.0.3",
66
- "jest": "^29.4.1",
67
- "lint-staged": "^13.1.0",
68
- "lockfile-lint": "^4.10.0",
69
- "open-cli": "^7.1.0",
70
- "prettier": "^2.8.3"
71
- },
72
- "jest": {
73
- "testEnvironment": "node",
74
- "verbose": true,
75
- "collectCoverage": true,
76
- "coverageThreshold": {
77
- "global": {
78
- "branches": 80,
79
- "functions": 80,
80
- "lines": 80,
81
- "statements": 80
82
- }
83
- },
84
- "testPathIgnorePatterns": [
85
- "/__tests__/.*/__fixtures__/.*"
86
- ],
87
- "collectCoverageFrom": [
88
- "index.js",
89
- "src/**/*.{js,ts}"
90
- ],
91
- "testMatch": [
92
- "**/*.test.js"
93
- ]
68
+ "@changesets/changelog-github": "^0.5.0",
69
+ "@changesets/cli": "^2.27.7",
70
+ "@types/node": "^20.14.10",
71
+ "c8": "^10.1.2",
72
+ "eslint": "^9.6.0",
73
+ "eslint-plugin-security": "^3.0.1",
74
+ "husky": "^9.0.11",
75
+ "lint-staged": "^15.2.7",
76
+ "lockfile-lint": "^4.14.0",
77
+ "neostandard": "^0.11.0",
78
+ "ts-node": "^10.9.2",
79
+ "tsup": "^8.1.0",
80
+ "typescript": "^5.5.3",
81
+ "validate-conventional-commit": "^1.0.4"
94
82
  },
95
83
  "lint-staged": {
96
84
  "**/*.{js,json}": [
97
- "<%= npmClient %> run format"
98
- ]
99
- },
100
- "husky": {
101
- "hooks": {
102
- "commit-msg": "commitlint --env HUSKY_GIT_PARAMS",
103
- "pre-commit": "lint-staged",
104
- "pre-push": "<%= npmClient %> run lint && <%= npmClient %> run test",
105
- "post-commit": "git status",
106
- "post-checkout": "git status",
107
- "post-merge": "<%= npmClient %> install"
108
- }
109
- },
110
- "commitlint": {
111
- "extends": [
112
- "@commitlint/config-conventional"
113
- ]
114
- },
115
- "standard": {
116
- "env": [
117
- "jest"
118
- ],
119
- "parser": "babel-eslint",
120
- "ignore": [
121
- "**/out/"
122
- ]
123
- },
124
- "eslintIgnore": [
125
- "coverage/**"
126
- ],
127
- "babel": {
128
- "plugins": [
129
- "@babel/plugin-syntax-top-level-await"
85
+ "npm run lint:fix"
130
86
  ]
131
- },
132
- "eslintConfig": {
133
- "plugins": [
134
- "node",
135
- "security",
136
- "jest"
137
- ],
138
- "extends": [
139
- "plugin:node/recommended"
140
- ],
141
- "rules": {
142
- "node/no-unsupported-features/es-syntax": [
143
- "error",
144
- {
145
- "ignores": [
146
- "dynamicImport",
147
- "modules"
148
- ]
149
- }
150
- ],
151
- "no-process-exit": "warn",
152
- "jest/no-disabled-tests": "error",
153
- "jest/no-focused-tests": "error",
154
- "jest/no-identical-title": "error",
155
- "node/no-unsupported-features": "off",
156
- "node/no-unpublished-require": "off",
157
- "security/detect-non-literal-fs-filename": "error",
158
- "security/detect-unsafe-regex": "error",
159
- "security/detect-buffer-noassert": "error",
160
- "security/detect-child-process": "error",
161
- "security/detect-disable-mustache-escape": "error",
162
- "security/detect-eval-with-expression": "error",
163
- "security/detect-no-csrf-before-method-override": "error",
164
- "security/detect-non-literal-regexp": "error",
165
- "security/detect-object-injection": "warn",
166
- "security/detect-possible-timing-attacks": "error",
167
- "security/detect-pseudoRandomBytes": "error",
168
- "space-before-function-paren": "off",
169
- "object-curly-spacing": "off"
170
- },
171
- "parser": "@babel/eslint-parser",
172
- "parserOptions": {
173
- "sourceType": "module",
174
- "ecmaFeatures": {
175
- "impliedStrict": true
176
- }
177
- }
178
- },
179
- "release": {
180
- "branches": [
181
- "main",
182
- "master"
183
- ],
184
- "analyzeCommits": {
185
- "preset": "angular",
186
- "releaseRules": [
187
- {
188
- "type": "docs",
189
- "release": "patch"
190
- },
191
- {
192
- "type": "refactor",
193
- "release": "patch"
194
- },
195
- {
196
- "type": "style",
197
- "release": "patch"
198
- }
199
- ]
200
- }
201
- },
202
- "plugins": [
203
- "@semantic-release/commit-analyzer",
204
- "@semantic-release/release-notes-generator",
205
- [
206
- "@semantic-release/changelog",
207
- {
208
- "changelogFile": "CHANGELOG.md"
209
- }
210
- ],
211
- "@semantic-release/npm",
212
- [
213
- "@semantic-release/git",
214
- {
215
- "assets": [
216
- "CHANGELOG.md"
217
- ]
218
- }
219
- ],
220
- "@semantic-release/github"
221
- ]
87
+ }
222
88
  }
@@ -0,0 +1,12 @@
1
+ #!/usr/bin/env node
2
+ import { debuglog } from 'node:util'
3
+ import { add } from '../main.ts'
4
+
5
+ const debug = debuglog('<%= projectName %>')
6
+
7
+ async function init () {
8
+ const sum = await add(1,2)
9
+ debug(sum.toString())
10
+ }
11
+
12
+ init()
@@ -0,0 +1,3 @@
1
+ export async function add(arg1: number, arg2: number): Promise<number> {
2
+ return Promise.resolve(arg1 + arg2)
3
+ }
@@ -0,0 +1,37 @@
1
+ {
2
+ "compilerOptions": {
3
+ "lib": [
4
+ "ES2022"
5
+ ],
6
+ "strict": true,
7
+ "allowJs": true,
8
+ "esModuleInterop": true,
9
+ "skipLibCheck": true,
10
+ "moduleResolution": "NodeNext",
11
+ "module": "NodeNext",
12
+ "target": "ES2022",
13
+ "baseUrl": ".",
14
+ "noEmit": true,
15
+ "rootDir": "./src",
16
+ "declaration": true,
17
+ "declarationMap": true,
18
+ "sourceMap": true,
19
+ "allowImportingTsExtensions": true,
20
+ "allowSyntheticDefaultImports": true,
21
+ "forceConsistentCasingInFileNames": true,
22
+ "resolveJsonModule": true,
23
+ "isolatedModules": true,
24
+ "removeComments": true,
25
+ },
26
+ "include": [
27
+ "src/**/*",
28
+ "src/bin/**/*"
29
+ ],
30
+ "exclude": [
31
+ "dist",
32
+ "node_modules"
33
+ ],
34
+ "ts-node": {
35
+ "transpileOnly": true,
36
+ }
37
+ }
@@ -0,0 +1,29 @@
1
+ import { defineConfig } from 'tsup'
2
+
3
+ export default defineConfig([
4
+ {
5
+ entryPoints: ['src/main.ts', 'src/bin/cli.ts'],
6
+ format: ['cjs', 'esm'],
7
+ dts: true,
8
+ minify: false,
9
+ outDir: 'dist/',
10
+ clean: true,
11
+ sourcemap: false,
12
+ bundle: true,
13
+ splitting: false,
14
+ outExtension (ctx) {
15
+ return {
16
+ dts: '.d.ts',
17
+ js: ctx.format === 'cjs' ? '.cjs' : '.mjs',
18
+ }
19
+ },
20
+ treeshake: false,
21
+ target: 'es2022',
22
+ platform: 'node',
23
+ tsconfig: './tsconfig.json',
24
+ cjsInterop: true,
25
+ keepNames: true,
26
+ skipNodeModulesBundle: false,
27
+ },
28
+
29
+ ])
@@ -1,44 +0,0 @@
1
- ---
2
- name: "\U0001F41B Bug report"
3
- about: Create a bug report
4
- ---
5
-
6
- <!--- Provide a general summary of the issue in the Title above -->
7
-
8
- ## Expected Behavior
9
-
10
- <!--- If you're describing a bug, tell us what should happen -->
11
- <!--- If you're suggesting a change/improvement, tell us how it should work -->
12
-
13
- ## Current Behavior
14
-
15
- <!--- If describing a bug, tell us what happens instead of the expected behavior -->
16
- <!--- If suggesting a change/improvement, explain the difference from current behavior -->
17
-
18
- ## Possible Solution
19
-
20
- <!--- Not obligatory, but suggest a fix/reason for the bug, -->
21
- <!--- or ideas how to implement the addition or change -->
22
-
23
- ## Steps to Reproduce (for bugs)
24
-
25
- <!--- Provide a link to a live example, or an unambiguous set of steps to -->
26
- <!--- reproduce this bug. Include code to reproduce, if relevant -->
27
-
28
- 1.
29
- 2.
30
- 3.
31
- 4.
32
-
33
- ## Context
34
-
35
- <!--- How has this issue affected you? What are you trying to accomplish? -->
36
- <!--- Providing context helps us come up with a solution that is most useful in the real world -->
37
-
38
- ## Your Environment
39
-
40
- <!--- Include as many relevant details about the environment you experienced the bug in -->
41
-
42
- - Library Version used:
43
- - Node.js version (e.g. Node.js 5.4):
44
- - Operating System and version (desktop or mobile):
@@ -1,19 +0,0 @@
1
- ---
2
- name: "\U0001F680 Feature request"
3
- about: Suggest an idea for this project
4
- ---
5
-
6
- <!--
7
- Thank you for suggesting an idea to make this project better!
8
-
9
- Please fill in as much of the template below as you're able.
10
- -->
11
-
12
- **Is your feature request related to a problem? Please describe.**
13
- Please describe the problem you are trying to solve.
14
-
15
- **Describe the solution you'd like**
16
- Please describe the desired behavior.
17
-
18
- **Describe alternatives you've considered**
19
- Please describe alternative solutions or features you have considered.
@@ -1,53 +0,0 @@
1
- <% const npmClientInstall = context.npmClient === 'yarn' ? 'yarn install --frozen-lockfile' : 'npm ci' -%>
2
- name: CI
3
-
4
- on: [push, pull_request]
5
-
6
- jobs:
7
- lint:
8
- name: Lint
9
- runs-on: 'ubuntu-latest'
10
- steps:
11
- - uses: actions/checkout@v3
12
- - uses: actions/setup-node@v3
13
- with:
14
- node-version: '18'
15
- - name: install dependencies
16
- run: <%= npmClientInstall %>
17
- - name: lint code
18
- run: <%= npmClient %> run lint
19
-
20
- build:
21
- strategy:
22
- matrix:
23
- platform: [ubuntu-latest]
24
- node: ['14', '16', '18']
25
- name: Tests - Node ${{ matrix.node }} (${{ matrix.platform }})
26
- runs-on: ${{ matrix.platform }}
27
- steps:
28
- - uses: actions/checkout@v3
29
- - uses: actions/setup-node@v3
30
- with:
31
- node-version: ${{ matrix.node }}
32
- - name: install dependencies
33
- run: <%= npmClientInstall %> --ignore-engines
34
- - name: run tests
35
- run: npm run test
36
-
37
- release:
38
- name: do semantic release
39
- runs-on: 'ubuntu-latest'
40
- needs: build
41
- if: github.event_name == 'push' && github.ref == 'refs/heads/main'
42
- steps:
43
- - uses: actions/checkout@v3
44
- - uses: actions/setup-node@v3
45
- with:
46
- node-version: '18'
47
- - name: install dependencies
48
- run: <%= npmClientInstall %> --ignore-engines --only=production
49
- - name: release
50
- run: npx semantic-release
51
- env:
52
- GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
53
- NPM_TOKEN: ${{secrets.NPM_TOKEN}}
@@ -1,5 +0,0 @@
1
- import { add } from '../src/main.js'
2
-
3
- test('1 + 1 is 2', () => {
4
- expect(add(1, 1)).toBe(2)
5
- })
@@ -1,4 +0,0 @@
1
- #!/usr/bin/env node
2
- import { add } from '../src/main.js'
3
-
4
- console.log(add(1, 2))
@@ -1,111 +0,0 @@
1
- # Logs
2
-
3
- logs
4
- _.log
5
- npm-debug.log_
6
- yarn-debug.log*
7
- yarn-error.log*
8
-
9
- # Runtime data
10
-
11
- pids
12
- _.pid
13
- _.seed
14
- \*.pid.lock
15
-
16
- # Directory for instrumented libs generated by jscoverage/JSCover
17
-
18
- lib-cov
19
-
20
- # Coverage directory used by tools like istanbul
21
-
22
- coverage
23
-
24
- # nyc test coverage
25
-
26
- .nyc_output
27
-
28
- # Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
29
-
30
- .grunt
31
-
32
- # Bower dependency directory (https://bower.io/)
33
-
34
- bower_components
35
-
36
- # node-waf configuration
37
-
38
- .lock-wscript
39
-
40
- # Compiled binary addons (https://nodejs.org/api/addons.html)
41
-
42
- build/Release
43
-
44
- # Dependency directories
45
-
46
- node_modules/
47
- jspm_packages/
48
-
49
- # TypeScript v1 declaration files
50
-
51
- typings/
52
-
53
- # Optional npm cache directory
54
-
55
- .npm
56
-
57
- # Optional eslint cache
58
-
59
- .eslintcache
60
-
61
- # Optional REPL history
62
-
63
- .node_repl_history
64
-
65
- # Output of 'npm pack'
66
-
67
- \*.tgz
68
-
69
- # Yarn Integrity file
70
-
71
- .yarn-integrity
72
-
73
- # dotenv environment variables file
74
-
75
- .env
76
- .env.test
77
-
78
- # parcel-bundler cache (https://parceljs.org/)
79
-
80
- .cache
81
-
82
- # next.js build output
83
-
84
- .next
85
-
86
- # nuxt.js build output
87
-
88
- .nuxt
89
-
90
- # vuepress build output
91
-
92
- .vuepress/dist
93
-
94
- # Serverless directories
95
-
96
- .serverless/
97
-
98
- # FuseBox cache
99
-
100
- .fusebox/
101
-
102
- # DynamoDB Local files
103
-
104
- .dynamodb/
105
-
106
- # Snyk Code
107
-
108
- .dccache
109
-
110
- # Visual Studio Code
111
- .vscode/
@@ -1,5 +0,0 @@
1
- function add(x, y) {
2
- return x + y
3
- }
4
-
5
- export { add }