pkg-typescript-plugin-scripts
v0.2.12
Published
[](https://badge.fury.io/js/pkg-typescript-plugin-scripts) [](https://opensource.org/licenses/ISC) [ for script files - Generates npm script names based on file names (converts underscores to hyphens, lowercases)
- Supports multiple file extensions through configurable runners
Configurable Runners
Map file extensions to their execution commands:
.tsfiles →tsx(TypeScript execution).pyfiles →python(Python scripts).jsfiles →node(JavaScript execution).shfiles →bash(Shell scripts)- Any custom file type with appropriate runner
Smart Naming
- Converts file names to kebab-case npm script names
- Example:
build_database.ts→build-databasescript - Example:
Deploy_App.py→deploy-appscript
Usage
Add this plugin to your pkg-typescript configuration:
export default {
plugins: ['scripts'],
config: {
pkg_ts: {
scripts: {
dir: 'scripts', // optional, defaults to 'scripts'
runners: {
ts: 'tsx',
py: 'python',
js: 'node',
sh: 'bash',
},
},
},
},
}Configuration
The plugin accepts these configuration options:
dir (optional)
- Type:
string - Default:
'scripts' - Description: Directory to scan for script files
Examples:
"./scripts""src/scripts""tools"
runners (required)
- Type:
Record<string, string> - Description: Maps file extensions to their execution commands
Example:
{
"ts": "tsx", // TypeScript files
"py": "python", // Python files
"js": "node", // JavaScript files
"sh": "bash", // Shell scripts
"rb": "ruby", // Ruby scripts
"go": "go run" // Go files
}Example
Given this directory structure:
scripts/
├── build_database.ts
├── deploy_app.py
├── cleanup.sh
└── generate_docs.jsWith this configuration:
{
dir: 'scripts',
runners: {
'ts': 'tsx',
'py': 'python',
'sh': 'bash',
'js': 'node'
}
}The plugin generates these npm scripts:
{
"build-database": "tsx scripts/build_database.ts",
"deploy-app": "python scripts/deploy_app.py",
"cleanup": "bash scripts/cleanup.sh",
"generate-docs": "node scripts/generate_docs.js"
}Run them with:
npm run build-database
npm run deploy-app
npm run cleanup
npm run generate-docsDevelopment
yarn pkg:build # Build the plugin
yarn install # Install dependenciesLicense
ISC
