
Security News
Open Source Maintainers Feeling the Weight of the EU’s Cyber Resilience Act
The EU Cyber Resilience Act is prompting compliance requests that open source maintainers may not be obligated or equipped to handle.
@alessiofrittoli/node-scripts
Advanced tools
Run the following command to start using node-scripts
in your projects:
npm i @alessiofrittoli/node-scripts
or using pnpm
pnpm i @alessiofrittoli/node-scripts
The addTypesReference
function allows you to create and manage TypeScript reference files and update the related tsconfig.json
file for a project installing your node module.
Below are the detailed descriptions of the interfaces and functions included.
CommonOptions
Property | Type | Description |
---|---|---|
root | string | The root directory of the project which is installing your node module. |
name | string | The name of your node module. |
outputFile | string | The output file name. |
AddTypesReferenceOptions
Property | Type | Default | Description |
---|---|---|---|
name | string | - | The project name currently executing the script. |
outputFile | string | 'alessiofrittoli-env.d.ts' | The *.d.ts output file name. |
createReferenceFile
Creates or updates a reference file with type definitions for a project.
Parameters
Parameter | Type | Description |
---|---|---|
options | CommonOptions | Common options for the reference file creation. |
Returns
void
Throws
Error
- Throws an error if there is an issue creating or updating the file.
updateTsConfig
Updates the tsconfig.json file by adding the specified output file to the include
array.
Parameters
Parameter | Type | Description |
---|---|---|
options | CommonOptions | Common options for the reference file creation. |
Returns
void
Throws
Error
- Throws an error if the tsconfig.json file cannot be read or updated.
addTypesReference
Adds a TypeScript reference file and updates the tsconfig.json for the project installing your node module.
If the options.outputFile
already exists, it will be updated with the new package reference if not already in there.
Parameters
Parameter | Type | Description |
---|---|---|
options | AddTypesReferenceOptions | The options for adding the types reference. |
Returns
void
Error
Exit the process with code 1
on failure.
Add the postinstall
script in your package.json
file which will execute the script once your package get installed in an external project.
{
// ...
"files": [
// ...,
"path-to-my-scripts" // ensure folder is published to `npm`
],
"scripts": {
// ...
"postinstall": "node path-to-my-scripts/ts-setup.js"
}
}
Then in your ts-setup.js
file simply import the script and execute it with a few options.
// path-to-my-scripts/ts-setup.js
const { addTypesReference } = require( '@alessiofrittoli/node-scripts/postinstall' )
const project = require( '../../package.json' )
addTypesReference( {
name: project.name,
outputFile: `${ project.name }.d.ts`, // optional
} )
Or you can statically pass a outputFile
to add all your scoped packages in a single file.
// path-to-my-scripts/ts-setup.js
const { addTypesReference } = require( '@alessiofrittoli/node-scripts/postinstall' )
const project = require( '../../package.json' )
addTypesReference( {
name: project.name,
outputFile: 'my-package-scope-env.d.ts',
} )
publish
The publish
function automates the process of building, tagging, and optionally publishing a project to npm.
Option | Type | Default | Description |
---|---|---|---|
--version | string | Value from package.json | The version to release. Retrieved from package.json if omitted. |
--verbose | boolean | undefined | false | Enables detailed logging. |
--origin , -o | string | 'origin' | The Git origin for pushing tags. |
--npm | boolean | undefined | false | Indicates whether to publish the package to npm. |
--access | public | restricted | 'public' | Sets npm access level (public or restricted). |
package.json
file.--version
option has been provided.getProcessOptions()
.version
and access
.pre-release
).npm run build
or pnpm build
command (if pnpm
is globally installed).v{version}
origin
or to the default Git Repository Remote.npm publish
if the --npm
flag is set.--verbose
flag is set.Add the release
script in your package.json
file so you can easly run from your terminal.
{
// ...
"scripts": {
// ...
"release": "node path-to-my-scripts/publish.js --verbose --npm --access restricted"
}
}
Then in your publish.js
file simply import the script and execute it.
⚠️ Remember to add this file to .npmignore
so it won't be published within you package.
// path-to-my-scripts/publish.js
require( '@alessiofrittoli/node-scripts/publish' )
.publish()
npm install
or using pnpm
pnpm i
Run the following command to test and build code for distribution.
pnpm build
warnings / errors check.
pnpm lint
Run all the defined test suites by running the following:
# Run tests and watch file changes.
pnpm test:watch
# Run tests and watch file changes with jest-environment-jsdom.
pnpm test:jsdom
# Run tests in a CI environment.
pnpm test:ci
# Run tests in a CI environment with jest-environment-jsdom.
pnpm test:ci:jsdom
You can eventually run specific suits like so:
pnpm test:jest
pnpm test:jest:jsdom
Run tests with coverage.
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.
test:coverage:serve
Contributions are truly welcome!
Please refer to the Contributing Doc for more information on how to start contributing to this project.
Help keep this project up to date with GitHub Sponsor.
If you believe you have found a security vulnerability, we encourage you to responsibly disclose this and NOT open a public issue. We will investigate all legitimate reports. Email security@alessiofrittoli.it
to disclose any security vulnerabilities.
|
|
FAQs
Utility library with common Node.js scripts
The npm package @alessiofrittoli/node-scripts receives a total of 229 weekly downloads. As such, @alessiofrittoli/node-scripts popularity was classified as not popular.
We found that @alessiofrittoli/node-scripts demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
The EU Cyber Resilience Act is prompting compliance requests that open source maintainers may not be obligated or equipped to handle.
Security News
Crates.io adds Trusted Publishing support, enabling secure GitHub Actions-based crate releases without long-lived API tokens.
Research
/Security News
Undocumented protestware found in 28 npm packages disrupts UI for Russian-language users visiting Russian and Belarusian domains.