Skip to content
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
4 changes: 3 additions & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,6 @@ trim_trailing_whitespace = true
insert_final_newline = false

[*.md]
trim_trailing_whitespace = false
indent_style = space
trim_trailing_whitespace = false
insert_final_newline = true
24 changes: 12 additions & 12 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
# These are supported funding model platforms

github: [alessiofrittoli]
patreon: # Replace with a single Patreon username
open_collective: # Replace with a single Open Collective username
ko_fi: # Replace with a single Ko-fi username
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
liberapay: # Replace with a single Liberapay username
issuehunt: # Replace with a single IssueHunt username
lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry
polar: # Replace with a single Polar username
buy_me_a_coffee: # Replace with a single Buy Me a Coffee username
thanks_dev: # Replace with a single thanks.dev username
custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
# patreon: # Replace with a single Patreon username
# open_collective: # Replace with a single Open Collective username
# ko_fi: # Replace with a single Ko-fi username
# tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
# community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
# liberapay: # Replace with a single Liberapay username
# issuehunt: # Replace with a single IssueHunt username
# lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry
# polar: # Replace with a single Polar username
# buy_me_a_coffee: # Replace with a single Buy Me a Coffee username
# thanks_dev: # Replace with a single thanks.dev username
# custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
12 changes: 11 additions & 1 deletion .github/workflows/tests-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ jobs:
test:
name: Run Unit Tests
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write
steps:

- uses: actions/checkout@v4
Expand All @@ -22,4 +25,11 @@ jobs:

- name: Run tests
run: |
pnpm test:ci:coverage
pnpm test:ci:coverage

- name: Report to Coveralls
uses: coverallsapp/github-action@v2
with:
github-token: ${{ secrets.COVERALLS_REPO_TOKEN }}
file: coverage/lcov.info
allow-empty: true
2 changes: 1 addition & 1 deletion CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,4 @@ This Code of Conduct is adapted from the [Contributor Covenant][homepage], versi
available at [https://www.contributor-covenant.org/version/2/1/code_of_conduct/][version]

[homepage]: http://contributor-covenant.org
[version]: https://www.contributor-covenant.org/version/2/1
[version]: https://www.contributor-covenant.org/version/2/1
6 changes: 3 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ If you find a bug, have a question, or want to suggest a new feature:

- Search Existing Issues: Check the [Issues](https://github.com/alessiofrittoli/node-scripts/issues) tab to see if your concern has already been addressed.
- Create a New Issue: If not, open a new issue. Please provide:
- A clear and descriptive title.
- Detailed steps to reproduce the issue (if applicable).
- Suggestions or ideas (if applicable).
- A clear and descriptive title.
- Detailed steps to reproduce the issue (if applicable).
- Suggestions or ideas (if applicable).

### 2. Fork the Repository

Expand Down
158 changes: 91 additions & 67 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,26 +1,45 @@
# Node.js Scripts 🫧

Version 2.2.1
[![NPM Latest Version][version-badge]][npm-url] [![Coverage Status][coverage-badge]][coverage-url] [![NPM Monthly Downloads][downloads-badge]][npm-url] [![Dependencies][deps-badge]][deps-url]

[![Sponsor on GitHub][sponsor-badge]][sponsor-url]

[version-badge]: https://img.shields.io/npm/v/%40alessiofrittoli%2Fnode-scripts
[npm-url]: https://npmjs.org/package/%40alessiofrittoli%2Fnode-scripts
[coverage-badge]: https://coveralls.io/repos/github/alessiofrittoli/node-scripts/badge.svg
[coverage-url]: https://coveralls.io/github/alessiofrittoli/node-scripts
[downloads-badge]: https://img.shields.io/npm/dm/%40alessiofrittoli%2Fnode-scripts.svg
[deps-badge]: https://img.shields.io/librariesio/release/npm/%40alessiofrittoli%2Fnode-scripts
[deps-url]: https://libraries.io/npm/%40alessiofrittoli%2Fnode-scripts

[sponsor-badge]: https://img.shields.io/static/v1?label=Sponsor%20this%20project&message=%E2%9D%A4&logo=GitHub&color=%23DB61A2
[sponsor-url]: https://github.com/sponsors/alessiofrittoli

## Utility library with common Node.js scripts

### Table of Contents

- [Getting started](#getting-started)
- [API Reference](#api-reference)
- [Post-Install scripts](#post-install-scripts)
- [TypeScript Type Reference Management](#typescript-type-reference-management)
- [Type Reference Interfaces](#type-reference-interfaces)
- [`CommonOptions`](#commonoptions)
- [`AddTypesReferenceOptions`](#addtypesreferenceoptions)
- [Type Reference Functions](#type-reference-functions)
- [`createReferenceFile`](#createreferencefile)
- [`updateTsConfig`](#updatetsconfig)
- [`addTypesReference`](#addtypesreference)
- [Add Types Reference Example usage](#add-types-reference-example-usage)
- [Publish Scripts](#publish-scripts)
- [Publish](#publish)
- [Security](#security)
- [Post-Install scripts](#post-install-scripts)
- [TypeScript Type Reference Management](#typescript-type-reference-management)
- [Type Reference Interfaces](#type-reference-interfaces)
- [`CommonOptions`](#commonoptions)
- [`AddTypesReferenceOptions`](#addtypesreferenceoptions)
- [Type Reference Functions](#type-reference-functions)
- [`createReferenceFile`](#createreferencefile)
- [`updateTsConfig`](#updatetsconfig)
- [`addTypesReference`](#addtypesreference)
- [Add Types Reference Example usage](#add-types-reference-example-usage)
- [Publish Scripts](#publish-scripts)
- [Publish](#publish)
- [Development](#development)
- [Install depenendencies](#install-depenendencies)
- [Build the source code](#build-the-source-code)
- [ESLint](#eslint)
- [Jest](#jest)
- [Contributing](#contributing)
- [Security](#security)
- [Credits](#made-with-)

---
Expand Down Expand Up @@ -170,15 +189,15 @@ Add the `postinstall` script in your `package.json` file which will execute the

```json
{
// ...
"files": [
// ...,
"path-to-my-scripts" // ensure folder is published to `npm`
],
"scripts": {
// ...
"postinstall": "node path-to-my-scripts/ts-setup.js"
}
// ...
"files": [
// ...,
"path-to-my-scripts" // ensure folder is published to `npm`
],
"scripts": {
// ...
"postinstall": "node path-to-my-scripts/ts-setup.js"
}
}
```

Expand All @@ -190,8 +209,8 @@ const { addTypesReference } = require( '@alessiofrittoli/node-scripts/postinstal
const project = require( '../../package.json' )

addTypesReference( {
name: project.name,
outputFile: `${ project.name }.d.ts`, // optional
name: project.name,
outputFile: `${ project.name }.d.ts`, // optional
} )
```

Expand All @@ -203,8 +222,8 @@ const { addTypesReference } = require( '@alessiofrittoli/node-scripts/postinstal
const project = require( '../../package.json' )

addTypesReference( {
name: project.name,
outputFile: 'my-package-scope-env.d.ts',
name: project.name,
outputFile: 'my-package-scope-env.d.ts',
} )
```

Expand Down Expand Up @@ -295,11 +314,11 @@ Add the `release` script in your `package.json` file so you can easly run from y

```json
{
// ...
"scripts": {
// ...
"release": "node path-to-my-scripts/publish.js --verbose --npm --access restricted"
}
// ...
"scripts": {
// ...
"release": "node path-to-my-scripts/publish.js --verbose --npm --access restricted"
}
}
```

Expand All @@ -310,14 +329,14 @@ Then in your `publish.js` file simply import the script and execute it.
```ts
// path-to-my-scripts/publish.js
require( '@alessiofrittoli/node-scripts/publish' )
.publish()
.publish()
```

</details>

---

<!-- ### Development
### Development

#### Install depenendencies

Expand All @@ -331,9 +350,9 @@ or using `pnpm`
pnpm i
```

#### Build your source code
#### Build the source code

Run the following command to build code for distribution.
Run the following command to test and build code for distribution.

```bash
pnpm build
Expand All @@ -353,7 +372,7 @@ Run all the defined test suites by running the following:

```bash
# Run tests and watch file changes.
pnpm test
pnpm test:watch

# Run tests and watch file changes with jest-environment-jsdom.
pnpm test:jsdom
Expand All @@ -379,17 +398,22 @@ An HTTP server is then started to serve coverage files from `./coverage` folder.
⚠️ You may see a blank page the first time you run this command. Simply refresh the browser to see the updates.

```bash
pnpm test:coverage
test:coverage:serve
```

---

### Contributing

Contributions are truly welcome!\
Contributions are truly welcome!

Please refer to the [Contributing Doc](./CONTRIBUTING.md) for more information on how to start contributing to this project.

--- -->
Help keep this project up to date with [GitHub Sponsor][sponsor-url].

[![Sponsor on GitHub][sponsor-badge]][sponsor-url]

---

### Security

Expand All @@ -398,30 +422,30 @@ If you believe you have found a security vulnerability, we encourage you to **_r
### Made with ☕

<table style='display:flex;gap:20px;'>
<tbody>
<tr>
<td>
<img src='https://avatars.githubusercontent.com/u/35973186' style='width:60px;border-radius:50%;object-fit:contain;'>
</td>
<td>
<table style='display:flex;gap:2px;flex-direction:column;'>
<tbody>
<tr>
<td>
<a href='https://github.com/alessiofrittoli' target='_blank' rel='noopener'>Alessio Frittoli</a>
</td>
</tr>
<tr>
<td>
<small>
<a href='https://alessiofrittoli.it' target='_blank' rel='noopener'>https://alessiofrittoli.it</a> |
<a href='mailto:info@alessiofrittoli.it' target='_blank' rel='noopener'>info@alessiofrittoli.it</a>
</small>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
<tbody>
<tr>
<td>
<img alt="avatar" src='https://avatars.githubusercontent.com/u/35973186' style='width:60px;border-radius:50%;object-fit:contain;'>
</td>
<td>
<table style='display:flex;gap:2px;flex-direction:column;'>
<tbody>
<tr>
<td>
<a href='https://github.com/alessiofrittoli' target='_blank' rel='noopener'>Alessio Frittoli</a>
</td>
</tr>
<tr>
<td>
<small>
<a href='https://alessiofrittoli.it' target='_blank' rel='noopener'>https://alessiofrittoli.it</a> |
<a href='mailto:info@alessiofrittoli.it' target='_blank' rel='noopener'>info@alessiofrittoli.it</a>
</small>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
32 changes: 30 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@
"url": "https://alessiofrittoli.it"
},
"license": "MIT",
"funding": [
{
"type": "github",
"url": "https://github.com/sponsors/alessiofrittoli"
}
],
"keywords": [
"nodejs",
"node-scripts"
Expand Down Expand Up @@ -49,19 +55,41 @@
},
"sideEffects": false,
"scripts": {
"//1a": "*********************************************************************",
"//1b": "*********************** BUILD - LINT - RELEASE **********************",
"//1c": "*********************************************************************",
"build": "pnpm lint && pnpm test:ci && tsup",
"build:watch": "tsup --watch",
"lint": "eslint",
"release": "node scripts/publish.js --verbose --npm",
"test": "pnpm test:watch",
"//2a": "*********************************************************************",
"//2b": "***************************** UNIT TESTS ****************************",
"//2c": "*********************************************************************",
"test": "jest --verbose",
"test:watch": "jest --watchAll --verbose",
"test:jsdom": "JSDOM=true pnpm test:watch",
"test:ci": "jest --ci --verbose",
"test:ci:jsdom": "JSDOM=true pnpm test:ci",
"//3a": "*********************************************************************",
"//3b": "************************ UNIT TESTS COVERAGE ************************",
"//3c": "*********************************************************************",
"test:coverage": "pnpm test:watch --coverage",
"test:ci:coverage": "pnpm test:ci --coverage",
"test:serve-coverage": "http-server ./coverage/lcov-report --gzip true -p 0 -o --silent",
"test:coverage:serve": "concurrently --prefix none --kill-others \"pnpm test:coverage\" \"pnpm test:serve-coverage\"",
"test:coverage:jsdom": "JSDOM=true pnpm test:coverage",
"test:coverage:jsdom:serve": "JSDOM=true pnpm test:coverage:serve",
"//4a": "*********************************************************************",
"//4b": "************************ TARGETED UNIT TESTS ************************",
"//4c": "*********************************************************************",
"test:postinstall": "pnpm test:watch postinstall/*",
"test:publish": "pnpm test:watch publish/*",
"test:git": "pnpm test:watch git.test.ts",
"test:jest": "pnpm test:watch jest.test.ts",
"test:jest:jsdom": "JSDOM=true pnpm test:jest"
"test:jest:jsdom": "JSDOM=true pnpm test:jest",
"test:npm": "pnpm test:watch npm.test.ts",
"test:package": "pnpm test:watch package.test.ts",
"test:process": "pnpm test:watch process.test.ts"
},
"devDependencies": {
"@eslint/js": "^9.17.0",
Expand Down