
Security News
Axios Supply Chain Attack Reaches OpenAI macOS Signing Pipeline, Forces Certificate Rotation
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.
toolkit-utils
Advanced tools
A set of reusable classes and utilities for creating toolkits
⚠️ This is very much work in progress. The API will be facing breaking changes until it is no longer alpha.
Inspired by "Tools without config", "The Melting Pot of JavaScript", and kcd-scripts.
This library provides utility classes and methods for creating toolkits, used to abstract much of the overhead involved in regular JS and TS tasks, such as testing, linting, formatting, building, etc.
IScriptResultThe utility class for viewing and manipulating project properties as well as executing scripts.
Prints the help message including the list of available scripts.
Returns a new array, replacing an argument name with a new name. Does not mutate the original array.
The utility class for viewing and manipulating project properties as well as executing scripts.
Kind: global class
IScriptResultThe utility class for viewing and manipulating project properties as well as executing scripts.
| Param | Description |
|---|---|
| [options] | Options |
| [options.debug] | Enables debug logs. |
| [options.silent] | Silences the logger. |
| [options.logger] | The instance of Signale to be used as a logger. |
| [options.filesDir] | The directory of the |
| [options.toolkitRoot] | The root of the toolkit using this library. |
Path of the src dir in the toolkit.
Kind: instance property of Project
Path of the scripts dir.
Kind: instance property of Project
Path of the config dir.
Kind: instance property of Project
The name of the toolkit.
Kind: instance property of Project
Path of the root of the toolkit.
Kind: instance property of Project
The name of the project
Kind: instance property of Project
The full project package.json object.
Kind: instance property of Project
Determine whether a project is compiled via Typescript or Babel.
Kind: instance property of Project
Determine whether a project is a TypeScript project.
Kind: instance property of Project
The command name of the toolkit's bin.
Kind: instance property of Project
List of scripts available in this toolkit.
Kind: instance property of Project
Returns the given path added to the path of the project root. A path may be given as a single string or in multiple parts.
Kind: instance method of Project
Returns:
Path in root directory.
| Param | Description |
|---|---|
| ...part | Path relative to the root dir. |
Returns the given path added to the path of the toolkit root. A path may be given as a single string or in multiple parts.
Kind: instance method of Project
Returns:
Path in toolkit root directory.
| Param | Description |
|---|---|
| ...part | Path relative to the root dir of the toolkit. |
Returns the given path added to path of the config directory. A path may be given as a single string or in multiple parts.
Kind: instance method of Project
Returns:
Path in config directory.
| Param | Description |
|---|---|
| ...part | Path relative to the config dir. |
Returns the given path added to path of the scripts directory. A path may be given as a single string or in multiple parts.
Kind: instance method of Project
Returns:
Path in scripts dir.
| Param | Description |
|---|---|
| ...part | Path relative to the scripts dir. |
Returns one of the given values based on whether project has any of the given dependencies in dependencies, devDependencies, peerDependencies.
Kind: instance method of Project
Returns:
Boolean value based on the existence of dependency in package.json.
| Param | Description |
|---|---|
| deps | Dependency or dependencies to check. |
Checks whether the given environment variable is set.
Kind: instance method of Project
Returns:
Whether the given environment variable is set.
| Param | Description |
|---|---|
| name | Name of the environment variable to look for. |
Returns environment variable if it is set. Returns the default value otherwise.
Kind: instance method of Project
Returns:
Environment variable or default value
| Param | Description |
|---|---|
| name | Name of the environment variable to look for. |
| defaultValue | Default value if the environment variable is not net. |
Checks if a given path is a direct property of the package.json
Kind: instance method of Project
Returns:
Whether the given path is in the package file
| Param | Description |
|---|---|
| jsonPath | The path to check |
Provides the value at the given path within package.json
Kind: instance method of Project
Returns:
The value at the given path in the package file
| Param | Description |
|---|---|
| jsonPath | The path to get a value from |
Sets the value at the given path within package.json
Kind: instance method of Project
| Param | Description |
|---|---|
| jsonPath | The path to get a value from |
| value | The value to set at the path |
Checks whether the given script exists in the scripts directory.
ts, js.Kind: instance method of Project
Returns:
Full path of the script. Null if none is found.
| Param | Description |
|---|---|
| scriptFile | Script file to check for the existance of. |
Checks for a file with a matching filename in the project root.
Kind: instance method of Project
| Param | Description |
|---|---|
| fileNames | The filename(s) including the extension to look for in the project root. |
Creates and writes the given data to a file in the project.
Kind: instance method of Project
| Param | Description |
|---|---|
| fileName | The name of the file to be written |
| data | The data to be written to the file. Objects that are provided will be serialized. |
Copies a file from the toolkit to the project. Paths should be given relative to the toolkit root and project root.
Kind: instance method of Project
| Param | Description |
|---|---|
| sourceFile | The path to the source file. |
| newFile | The path to the destination file. |
Returns the relative path to an executable located in node_modules/.bin.
Kind: instance method of Project
| Param | Description |
|---|---|
| executable | The name of the executable. |
Given an object with keys as script names and values as commands, return parameters to pass concurrently.
Kind: instance method of Project
Returns:
| Param | Description |
|---|---|
| scripts | Object with script names as keys and commands as values. |
| killOthers | Whether all scripts should be killed if one fails. |
Executes a given script file's exported script function. The given script file should be in the "scripts" directory.
Kind: instance method of Project
| Param | Description |
|---|---|
| scriptFile | The script file to execute from the "scripts" directory. |
| args | A list of arguments to be passed to the script function. |
Executes a script based on the script name that was passed in process.argv.
Kind: instance method of Project
Returns:
Result of script
| Param | Description |
|---|---|
| exit | Whether to exit from process. |
IScriptResultExecutes a binary using spawn.sync with given arguments and returns results.
For a single [Executable](Executable), it executes and returns result. For multiple [Executables](Executable), it executes them
serially. Execution stops and the function returns result, if one of the commands fails (which adds previous results to result.previousResults).
If an object is provided with names as keys and [Executables](Executable) as values, it executes them using concurrently
and returns result of concurrently.
Kind: instance method of Project
Returns: IScriptResult -
| Param | Type | Description |
|---|---|---|
| ...executables | Executable | Executable or executables. |
Example
// Execute some commands serially and concurrently. Commands in the object are executed concurrently.
// 1. `serial-command-1` is executed first.
// 2. `serial-command-2` is executed second.
// 3. Based on a condition, `serial-command-3` might be executed.
// 4. `build doc command`, `some-other-command`, and `tsc` are executed in parallel. (object keys are names used in logs)
// 5. Lastly, `other-serial-command` is executed.
const result = project.execute(
["serial-command-1", ["arg"]],
"serial-command-2",
someCondition ? "serial-command-3" : null,
{
my-parallel-job: ["build-doc-command", ["arg"],
my-parallel-task: "some-other-command"
builder: ["tsc", ["arg"]],
},
["other-serial-command", ["arg"]],
);
Prints the help message including the list of available scripts.
Kind: global function
| Param | Description |
|---|---|
| scriptNames | The list of available scripts. |
Returns a new array, replacing an argument name with a new name. Does not mutate the original array.
Kind: global function
Returns:
An array with the arguments replaced.
| Param | Description |
|---|---|
| args | Arguments array. |
| names | Parameter names to look for in arguments. |
| newName | Parameter names to look for in arguments. |
Example
const arguments = ["--a", "--b"];
replaceArgumentName(arguments, ["--a"], "--c"); // -> ["--c", "--b"]
FAQs
A set of utilities for creating toolkits
We found that toolkit-utils demonstrated a not healthy version release cadence and project activity because the last version was released 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
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.

Security News
Open source is under attack because of how much value it creates. It has been the foundation of every major software innovation for the last three decades. This is not the time to walk away from it.

Security News
Socket CEO Feross Aboukhadijeh breaks down how North Korea hijacked Axios and what it means for the future of software supply chain security.