awn-cli
v0.0.1
Published
عون (Awn) - A shadcn-style utility library for TypeScript. Copy utilities into your project.
Maintainers
Readme
عون (Awn)
A shadcn-style utility library for TypeScript - copy utilities into your project
عون (Awn, meaning "help" in Arabic) is a collection of TypeScript utility functions that you can copy directly into your project, inspired by the shadcn/ui approach. Instead of installing a heavy dependency, you get clean, typed utility functions that live in your codebase.
Installation
npm install -g awnUsage
Initialize configuration (recommended):
# Create utils.json configuration file
npx awn initThis creates a utils.json file similar to shadcn's components.json:
{
"$schema": "https://awn.dev/schema.json",
"utils": {
"path": "./src/utils"
},
"aliases": {
"utils": "~/utils"
}
}Add utilities to your project:
# Add a utility function (uses config path)
npx awn add debounce
# Override with custom path
npx awn add chunk --path ./src/lib/utilsSearch for utilities:
# List all available utilities
npx awn search
# Search with fuzzy matching
npx awn search array
npx awn search case
npx awn search randomAvailable Utilities
Array Utilities (7 utilities)
chunk- Split array into chunks of specified sizeuniq- Remove duplicates from arrayuniqBy- Remove duplicates using iteratee functionflatten- Flatten array one level deepflattenDeep- Recursively flatten arraysample- Get random element from arraysampleSize- Get n random elements from array
String Utilities (9 utilities)
camelCase- Convert to camelCase formatpascalCase- Convert to PascalCase formatkebabCase- Convert to kebab-case formatsnakeCase- Convert to snake_case formatdebounce- Create debounced functionthrottle- Create throttled functiontruncate- Truncate string with optionscapitalize- Capitalize first characterstartCase- Convert to Start Case (Title Case)
Number Utilities (8 utilities)
clamp- Clamp number within boundsinRange- Check if number is in rangerandom- Generate random numbers with optionsrandomInt- Generate random integersround- Round number to precisionceil- Ceil number to precisionfloor- Floor number to precisionpercentage- Calculate percentage with precision
Development
# Install dependencies
npm install
# Run tests
npm test
# Build
npm run build
# Format code
npm run format
# Lint
npm run lint
# Type check
npm run typecheckRelease Process
This project uses Changesets for version management:
# Add a changeset (describes your changes)
npm run changeset
# Version packages (consumes changesets and updates versions)
npm run version
# Publish to NPM (builds and publishes)
npm run releaseThe GitHub Actions workflow will automatically:
- Create release PRs when changesets are added
- Publish to NPM when release PRs are merged
How it works
Awn maintains a registry of utility functions with embedded manifests. When you run npx awn add <utility>, it copies only the function code (without metadata) directly into your project. This means:
- ✅ No runtime dependencies
- ✅ Full TypeScript support with strict typing
- ✅ You own the code
- ✅ Easy to customize
- ✅ Tree-shakeable by default
- ✅ Fuzzy search to discover utilities
- ✅ Each utility in its own file
Features
- 24 utilities across 3 categories (Array, String, Number)
- Individual test files for each utility (95 tests total)
- Fuzzy search with
npx awn search - Embedded manifests with examples and tags
- Prettier formatting and ESLint rules
- GitHub Actions CI/CD pipeline
- TypeScript strict mode with comprehensive types
Examples
// After running: npx awn add chunk
import { chunk } from './utils/chunk';
chunk([1, 2, 3, 4, 5], 2); // [[1, 2], [3, 4], [5]]// After running: npx awn add debounce
import { debounce } from './utils/debounce';
const debouncedFn = debounce(fn, 300);// After running: npx awn add clamp
import { clamp } from './utils/clamp';
clamp(5, 1, 10); // 5
clamp(-5, 1, 10); // 1Configuration
utils.json
The utils.json file allows you to customize how Awn works in your project:
{
"$schema": "https://awn.dev/schema.json",
"utils": {
"path": "./src/utils"
},
"aliases": {
"utils": "~/utils",
"~": "./src",
"@": "./src"
}
}Configuration Options:
utils.path- Where utilities will be stored (default:./src/utils)aliases- Path aliases for import statementsaliases.utils- Alias shown in import suggestions (default:~/utils)
Creating Configuration:
npx awn init # Creates utils.json with defaultsThe configuration is optional. Without it, Awn will use ./src/utils as the default path.
License
MIT
