@actions-kit/dev
v0.2.0
Published
Development tool library of Actions Kit
Downloads
8
Maintainers
Readme
Actions Kit - Dev
A development tool library for Actions Kit, an additional toolkit for developing GitHub Actions.
This package simplifies the development configuration of other packages in the Actions Kit and can also be used in other projects. It uses the following stacks for project development:
- TypeScript: The primary language for project development.
- Prettier: A code formatter for TypeScript, JavaScript, and JSON source files.
- ESLint: A linter for TypeScript and JavaScript code.
- Jest: A testing framework for TypeScript and JavaScript code.
This package offers two main features:
- A dev tool that serves as the primary entry point for executing various commands.
- A default configuration along with the flexibility to modify it according to the specific requirements of a project.
Installation
Run the following commmand to install the @actions-kit/dev
package as a dev dependency:
npm install @actions-kit/dev --save-dev
Usage
Using the Dev Tool
Use the dev tool by running the following commands:
dev build
: Compiles source files from TypeScript to JavaScript.dev clean
: Cleans the build output directory.dev format
: Formats the source files using Prettier.dev lint
: Lints the source files using ESLint.dev test
: Runs tests using Jest.
The dev tool can also be invoked as a script in the package.json
file to simplify build commands during project development:
{
...
"scripts": {
"build": "dev build",
"clean": "dev clean",
"format": "dev format",
"lint": "dev lint",
"test": "dev test"
},
...
}
Configuring TypeScript
Configure TypeScript by extending the tsconfig.json
from @actions-kit/dev/tsconfig.json
:
{
"extends": "@actions-kit/dev/tsconfig.json",
"compilerOptions": {
"outDir": "lib"
},
"include": ["src"],
...
}
Make sure to set the compilerOptions.outDir
and include
properties correctly according to the project's requirements.
For more information on further modifications to the tsconfig.json
file, refer to the TSConfig reference.
Configuring ESLint
Set up a default ESLint configuration by importing createEslintConfig
from @actions-kit/dev
in the .eslintrc.js
file:
const dev = require("@actions-kit/dev");
module.exports = dev.createEslintConfig();
To modify the default configuration, pass an object to the createEslintConfig
function:
module.exports = dev.createEslintConfig({ env: { browser: true } });
Alternatively, pass a function to the createEslintConfig
to further modify the default configuration:
module.exports = dev.createEslintConfig((config) => {
config.rules["no-shadow"] = 2;
return config;
});
For more information on configuring ESLint, refer to the ESLint configuration documentation.
Configuring Jest
Set up a default Jest configuration by importing createJestConfig
from @actions-kit/dev
in the jest.config.ts
file:
import { createJestConfig } from "@actions-kit/dev";
export default createJestConfig();
To modify the default configuration, pass an object to the createJestConfig
function:
export default createJestConfig({ verbose: false });
Alternatively, pass a function to the createJestConfig
to further modify the default configuration:
export default createJestConfig((config) => {
config.testMatch?.push("**/*.test.js");
return config;
});
For more information on configuring Jest, refer to the Jest configuration documentation.
License
This project is licensed under the terms of the MIT License.
Copyright © 2023 Alfi Maulana