create-node-lib 2.5.1 → 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 (37) hide show
  1. package/.github/CODEOWNERS +1 -0
  2. package/.github/workflows/main.yml +16 -16
  3. package/__tests__/generator.test.js +6 -6
  4. package/package.json +33 -30
  5. package/saofile.js +15 -19
  6. package/template/.github/.markdownlint.yml +9 -0
  7. package/template/.github/CODEOWNERS +1 -0
  8. package/template/{CONTRIBUTING.md → .github/CONTRIBUTING.md} +9 -5
  9. package/template/.github/ISSUE_TEMPLATE/1-bug-report.yml +31 -0
  10. package/template/.github/ISSUE_TEMPLATE/2-feature-request.yml +23 -0
  11. package/template/.github/dependabot.yml +38 -0
  12. package/template/.github/labeler.yml +20 -0
  13. package/template/.github/workflows/ci.yml +49 -0
  14. package/template/.github/workflows/labeler.yml +12 -0
  15. package/template/.github/workflows/links-checker-schedule.yml +28 -0
  16. package/template/.github/workflows/lock-threads.yml +34 -0
  17. package/template/.github/workflows/markdown-lint.yml +26 -0
  18. package/template/.github/workflows/release.yml +38 -0
  19. package/template/.husky/commit-msg +1 -1
  20. package/template/README.md +8 -17
  21. package/template/RELEASE.md +42 -0
  22. package/template/SECURITY.md +14 -5
  23. package/template/__tests__/app.test.ts +17 -0
  24. package/template/eslint.config.js +32 -0
  25. package/template/package.json +52 -176
  26. package/template/src/bin/cli.ts +12 -0
  27. package/template/src/main.ts +3 -0
  28. package/template/tsconfig.json +37 -0
  29. package/template/tsup.config.ts +29 -0
  30. package/template/.github/ISSUE_TEMPLATE/1-bug-report.md +0 -44
  31. package/template/.github/ISSUE_TEMPLATE/2-feature-request.md +0 -19
  32. package/template/.github/workflows/main.yml +0 -53
  33. package/template/__tests__/app.test.js +0 -5
  34. package/template/bin/cli.js +0 -4
  35. package/template/gitignore +0 -110
  36. package/template/src/main.js +0 -5
  37. /package/template/{CODE_OF_CONDUCT.md → .github/CODE_OF_CONDUCT.md} +0 -0
@@ -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,169 +64,25 @@
44
64
  "type": "git",
45
65
  "url": "<%= projectRepository %>.git"
46
66
  },
47
- "dependencies": {},
48
67
  "devDependencies": {
49
- "@babel/core": "^7.15.8",
50
- "@babel/eslint-parser": "^7.15.8",
51
- "@babel/plugin-syntax-top-level-await": "^7.14.5",
52
- "@commitlint/cli": "^13.2.1",
53
- "@commitlint/config-conventional": "^13.2.0",
54
- "@semantic-release/changelog": "^6.0.0",
55
- "@semantic-release/commit-analyzer": "^9.0.1",
56
- "@semantic-release/git": "^10.0.0",
57
- "@semantic-release/github": "^8.0.1",
58
- "@semantic-release/npm": "^8.0.2",
59
- "@semantic-release/release-notes-generator": "^10.0.2",
60
- "eslint": "^8.0.1",
61
- "eslint-plugin-jest": "^25.2.2",
62
- "eslint-plugin-node": "^11.1.0",
63
- "eslint-plugin-security": "^1.4.0",
64
- "eslint-plugin-standard": "^4.1.0",
65
- "husky": "^7.0.4",
66
- "jest": "^27.3.1",
67
- "lint-staged": "^11.2.3",
68
- "lockfile-lint": "^4.6.2",
69
- "open-cli": "^7.0.1",
70
- "prettier": "^2.4.1"
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
- "**/*.js": [
97
- "<%= npmClient %> run format"
98
- ]
99
- },
100
- "commitlint": {
101
- "extends": [
102
- "@commitlint/config-conventional"
84
+ "**/*.{js,json}": [
85
+ "npm run lint:fix"
103
86
  ]
104
- },
105
- "standard": {
106
- "env": [
107
- "jest"
108
- ],
109
- "parser": "babel-eslint",
110
- "ignore": [
111
- "**/out/"
112
- ]
113
- },
114
- "eslintIgnore": [
115
- "coverage/**"
116
- ],
117
- "babel": {
118
- "plugins": [
119
- "@babel/plugin-syntax-top-level-await"
120
- ]
121
- },
122
- "eslintConfig": {
123
- "plugins": [
124
- "node",
125
- "security",
126
- "jest"
127
- ],
128
- "extends": [
129
- "plugin:node/recommended"
130
- ],
131
- "rules": {
132
- "node/no-unsupported-features/es-syntax": [
133
- "error",
134
- {
135
- "ignores": [
136
- "dynamicImport",
137
- "modules"
138
- ]
139
- }
140
- ],
141
- "no-process-exit": "warn",
142
- "jest/no-disabled-tests": "error",
143
- "jest/no-focused-tests": "error",
144
- "jest/no-identical-title": "error",
145
- "node/no-unsupported-features": "off",
146
- "node/no-unpublished-require": "off",
147
- "security/detect-non-literal-fs-filename": "error",
148
- "security/detect-unsafe-regex": "error",
149
- "security/detect-buffer-noassert": "error",
150
- "security/detect-child-process": "error",
151
- "security/detect-disable-mustache-escape": "error",
152
- "security/detect-eval-with-expression": "error",
153
- "security/detect-no-csrf-before-method-override": "error",
154
- "security/detect-non-literal-regexp": "error",
155
- "security/detect-object-injection": "warn",
156
- "security/detect-possible-timing-attacks": "error",
157
- "security/detect-pseudoRandomBytes": "error",
158
- "space-before-function-paren": "off",
159
- "object-curly-spacing": "off"
160
- },
161
- "parser": "@babel/eslint-parser",
162
- "parserOptions": {
163
- "sourceType": "module",
164
- "ecmaFeatures": {
165
- "impliedStrict": true
166
- }
167
- }
168
- },
169
- "release": {
170
- "branches": [
171
- "main",
172
- "master"
173
- ],
174
- "analyzeCommits": {
175
- "preset": "angular",
176
- "releaseRules": [
177
- {
178
- "type": "docs",
179
- "release": "patch"
180
- },
181
- {
182
- "type": "refactor",
183
- "release": "patch"
184
- },
185
- {
186
- "type": "style",
187
- "release": "patch"
188
- }
189
- ]
190
- }
191
- },
192
- "plugins": [
193
- "@semantic-release/commit-analyzer",
194
- "@semantic-release/release-notes-generator",
195
- [
196
- "@semantic-release/changelog",
197
- {
198
- "changelogFile": "CHANGELOG.md"
199
- }
200
- ],
201
- "@semantic-release/npm",
202
- [
203
- "@semantic-release/git",
204
- {
205
- "assets": [
206
- "CHANGELOG.md"
207
- ]
208
- }
209
- ],
210
- "@semantic-release/github"
211
- ]
87
+ }
212
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@v2
12
- - uses: actions/setup-node@v2
13
- with:
14
- node-version: '16'
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']
25
- name: Tests - Node ${{ matrix.node }} (${{ matrix.platform }})
26
- runs-on: ${{ matrix.platform }}
27
- steps:
28
- - uses: actions/checkout@v2
29
- - uses: actions/setup-node@v2
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@v2
44
- - uses: actions/setup-node@v2
45
- with:
46
- node-version: '16'
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))