airyhooks 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Leif Arriens
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,21 +1,15 @@
1
1
  # airyhooks
2
2
 
3
- Add production-ready React hooks directly to your project—no package installation required.
3
+ ![airyhooks logo](https://raw.githubusercontent.com/leifarriens/airyhooks/HEAD/media/logo_embed.png)
4
4
 
5
- airyhooks is a CLI tool that lets you add battle-tested, TypeScript-first React hooks directly to your codebase. Instead of installing a package, you copy exactly what you need. This gives you complete control: modify hooks for your use case, avoid dependency bloat, and eliminate version conflicts.
5
+ Add production-ready zero-dependency React hooks without package installation directly to your project.
6
+
7
+ `airyhooks` is a CLI tool that lets you add tested, TypeScript-first React hooks directly to your codebase. Instead of installing a package, you copy exactly what you need. This gives you complete control: modify hooks for your use case, avoid dependency bloat, and eliminate version conflicts.
6
8
 
7
9
  ```bash
8
- pnpm dlx airyhooks@latest add useDebounce
10
+ pnpm dlx airyhooks
9
11
  ```
10
12
 
11
- ## Why airyhooks?
12
-
13
- - **Zero Dependencies**: Hooks only depend on React—nothing else
14
- - **Full Ownership**: Code lives in your repo; customize freely
15
- - **TypeScript Native**: Complete type safety with generics
16
- - **Battle-Tested**: 50+ tests, 94%+ coverage
17
- - **One Command**: Add hooks instantly with the CLI
18
-
19
13
  ## 🚀 Quick Start
20
14
 
21
15
  ### 1. Initialize
@@ -23,17 +17,26 @@ pnpm dlx airyhooks@latest add useDebounce
23
17
  Create the configuration file and set your hooks directory:
24
18
 
25
19
  ```bash
26
- pnpm dlx airyhooks@latest init
20
+ pnpm dlx airyhooks init
27
21
  ```
28
22
 
29
23
  This creates `airyhooks.json` in your project root and prompts you for the hooks directory path (default: `./hooks`).
30
24
 
31
- ### 2. Add a Hook
25
+ > [!NOTE]
26
+ > You can use `airyhooks` without initialization. It will use the [default configuration](/#configuration).
32
27
 
33
- Add any hook to your project:
28
+ ### 2. Start Adding Hooks
29
+
30
+ Pick from all available hooks and add them to your project:
34
31
 
35
32
  ```bash
36
- pnpm dlx airyhooks@latest add useDebounce
33
+ pnpm dlx airyhooks
34
+ ```
35
+
36
+ Or add a specific hook directly:
37
+
38
+ ```bash
39
+ pnpm dlx airyhooks add useDebounce
37
40
  ```
38
41
 
39
42
  This creates the following structure:
@@ -65,6 +68,36 @@ export function SearchComponent() {
65
68
  }
66
69
  ```
67
70
 
71
+ ## 📚 Available Hooks
72
+
73
+ | Hook | Description |
74
+ | ------------------------- | ------------------------------------------------------- |
75
+ | `useClickAway` | Detect clicks outside of an element |
76
+ | `useCopyToClipboard` | Copy text to clipboard with status feedback |
77
+ | `useCounter` | Manage numeric state with increment/decrement/reset/set |
78
+ | `useDebounce` | Debounce a value with a specified delay |
79
+ | `useDocumentTitle` | Dynamically update the document title |
80
+ | `useEventListener` | Attach event listeners with automatic cleanup |
81
+ | `useFetch` | Fetch data with loading, error, and refetch support |
82
+ | `useHover` | Track mouse hover state on elements |
83
+ | `useIntersectionObserver` | Track element visibility in viewport |
84
+ | `useInterval` | Call a callback at specified intervals |
85
+ | `useIsClient` | Check if code is running on client (SSR-safe) |
86
+ | `useKeyPress` | Detect specific keyboard key presses |
87
+ | `useLocalStorage` | Sync state with localStorage |
88
+ | `useLockBodyScroll` | Prevent body scrolling (useful for modals) |
89
+ | `useMeasure` | Measure element dimensions with ResizeObserver |
90
+ | `useMedia` | React to CSS media query changes |
91
+ | `useMount` | Call a callback on component mount |
92
+ | `usePrevious` | Track previous state or props value |
93
+ | `useScroll` | Track scroll position of element or window |
94
+ | `useSessionStorage` | Sync state with sessionStorage |
95
+ | `useThrottle` | Throttle a value to update at most once per interval |
96
+ | `useTimeout` | Call a callback after a timeout |
97
+ | `useToggle` | Toggle a boolean value with convenient handlers |
98
+ | `useUnmount` | Call a callback on component unmount |
99
+ | `useWindowSize` | Track window dimensions |
100
+
68
101
  ## 📖 Commands
69
102
 
70
103
  ### `airyhooks init`
@@ -72,9 +105,19 @@ export function SearchComponent() {
72
105
  Initialize airyhooks in your project. Creates `airyhooks.json` configuration file and prompts for your hooks directory path.
73
106
 
74
107
  ```bash
75
- pnpm dlx airyhooks@latest init
108
+ pnpm dlx airyhooks init
76
109
  # or
77
- npx airyhooks@latest init
110
+ npx airyhooks init
111
+ ```
112
+
113
+ ### `airyhooks`
114
+
115
+ Run the interactive hook picker to browse and add hooks to your project.
116
+
117
+ ```bash
118
+ pnpm dlx airyhooks
119
+ # or
120
+ npx airyhooks
78
121
  ```
79
122
 
80
123
  ### `airyhooks add <hook-name>`
@@ -82,39 +125,27 @@ npx airyhooks@latest init
82
125
  Add a specific hook to your project. Creates the hook directory with TypeScript files.
83
126
 
84
127
  ```bash
85
- pnpm dlx airyhooks@latest add useDebounce
128
+ pnpm dlx airyhooks add useDebounce
86
129
  ```
87
130
 
88
- ### `airyhooks list`
131
+ #### Options
89
132
 
90
- List all available hooks with descriptions.
133
+ - `--raw` - Output only the raw hook template to console (no files created)
134
+
135
+ > [!TIP]
136
+ > Use `--raw` to pipe the hook directly to a file or integrate with other tools:
91
137
 
92
138
  ```bash
93
- pnpm dlx airyhooks@latest list
139
+ pnpm dlx airyhooks add useDebounce --raw > useDebounce.ts
94
140
  ```
95
141
 
96
- ## 📚 Available Hooks
142
+ ### `airyhooks list`
97
143
 
98
- | Hook | Description |
99
- | ------------------- | ------------------------------------------------------- |
100
- | `useDebounce` | Debounce a value with a specified delay |
101
- | `useThrottle` | Throttle a value to update at most once per interval |
102
- | `useLocalStorage` | Sync state with localStorage |
103
- | `useSessionStorage` | Sync state with sessionStorage |
104
- | `usePrevious` | Track previous state or props value |
105
- | `useToggle` | Toggle a boolean value with convenient handlers |
106
- | `useBoolean` | Boolean state with setTrue, setFalse, and toggle |
107
- | `useMount` | Call a callback on component mount |
108
- | `useUnmount` | Call a callback on component unmount |
109
- | `useInterval` | Call a callback at specified intervals |
110
- | `useTimeout` | Call a callback after a timeout |
111
- | `useClickAway` | Detect clicks outside of an element |
112
- | `useWindowSize` | Track window dimensions |
113
- | `useCounter` | Manage numeric state with increment/decrement/reset/set |
114
- | `useHover` | Track mouse hover state on elements |
115
- | `useKeyPress` | Detect specific keyboard key presses |
116
- | `useMedia` | React to CSS media query changes |
117
- | `useScroll` | Track scroll position of element or window |
144
+ List all available hooks with descriptions.
145
+
146
+ ```bash
147
+ pnpm dlx airyhooks list
148
+ ```
118
149
 
119
150
  ## 💡 Usage Example
120
151
 
@@ -147,11 +178,59 @@ The `airyhooks.json` file stores your configuration:
147
178
 
148
179
  ```json
149
180
  {
150
- "hooksPath": "./hooks"
181
+ "casing": "camelCase",
182
+ "hooksPath": "src/hooks",
183
+ "importExtension": "none"
151
184
  }
152
185
  ```
153
186
 
154
- You can manually edit this file to change the hooks directory path.
187
+ ### Options
188
+
189
+ | Option | Type | Default | Description |
190
+ | ----------------- | ------------------------------- | ------------- | ------------------------------------------------ |
191
+ | `hooksPath` | `string` | `"src/hooks"` | Directory path where hooks are added |
192
+ | `casing` | `"camelCase"` \| `"kebab-case"` | `"camelCase"` | Naming convention for hook directories and files |
193
+ | `importExtension` | `"none"` \| `"js"` \| `"ts"` | `"none"` | File extension used in barrel export imports |
194
+
195
+ #### `hooksPath`
196
+
197
+ The directory where hooks will be created. Can be any valid path relative to your project root.
198
+
199
+ ```json
200
+ { "hooksPath": "src/lib/hooks" }
201
+ ```
202
+
203
+ #### `casing`
204
+
205
+ Controls the naming convention for hook directories and files:
206
+
207
+ - `"camelCase"` — Keeps the original hook name (e.g., `useDebounce/useDebounce.ts`)
208
+ - `"kebab-case"` — Converts to kebab-case (e.g., `use-debounce/use-debounce.ts`)
209
+
210
+ ```
211
+ # camelCase (default)
212
+ hooks/useDebounce/
213
+ ├── useDebounce.ts
214
+ └── index.ts
215
+
216
+ # kebab-case
217
+ hooks/use-debounce/
218
+ ├── use-debounce.ts
219
+ └── index.ts
220
+ ```
221
+
222
+ > [!TIP]
223
+ > You can override casing per-command with the `--kebab` flag: `airyhooks add useDebounce --kebab`
224
+
225
+ #### `importExtension`
226
+
227
+ Controls the file extension in the generated `index.ts` barrel export. Choose based on your TypeScript configuration:
228
+
229
+ | Value | Output | When to use |
230
+ | -------- | ------------------------------------------------ | --------------------------------------------------- |
231
+ | `"none"` | `export { useDebounce } from "./useDebounce"` | `moduleResolution: "bundler"` (Vite, webpack, etc.) |
232
+ | `"js"` | `export { useDebounce } from "./useDebounce.js"` | `moduleResolution: "nodenext"` or `"node16"` |
233
+ | `"ts"` | `export { useDebounce } from "./useDebounce.ts"` | `allowImportingTsExtensions: true` in tsconfig |
155
234
 
156
235
  ## 📦 Package Managers
157
236
 
@@ -159,22 +238,18 @@ airyhooks works with all major package managers:
159
238
 
160
239
  ```bash
161
240
  # pnpm
162
- pnpm dlx airyhooks@latest add useDebounce
241
+ pnpm dlx airyhooks add useDebounce
163
242
 
164
243
  # npm
165
- npx airyhooks@latest add useDebounce
244
+ npx airyhooks add useDebounce
166
245
 
167
246
  # yarn
168
- yarn dlx airyhooks@latest add useDebounce
247
+ yarn dlx airyhooks add useDebounce
169
248
 
170
249
  # bun
171
- bunx airyhooks@latest add useDebounce
250
+ bunx airyhooks add useDebounce
172
251
  ```
173
252
 
174
- ## 📄 License
175
-
176
- MIT
177
-
178
253
  ---
179
254
 
180
- **Ready to use?** Run `pnpm dlx airyhooks@latest init` to get started!
255
+ **Ready to use?** Run `pnpm dlx airyhooks init` to get started!
@@ -2,37 +2,48 @@ import fs from "fs-extra";
2
2
  import path from "node:path";
3
3
  import pc from "picocolors";
4
4
  import { getConfig } from "../utils/config.js";
5
+ import { getFileExtension } from "../utils/get-file-extension.js";
6
+ import { getHookFileBaseName } from "../utils/get-hook-filename.js";
5
7
  import { getHookTemplate } from "../utils/get-hook-template.js";
6
8
  import { registry } from "../utils/registry.js";
7
- export async function add(hookName) {
9
+ export async function add(hookName, options = {}) {
10
+ const { force, kebab, raw } = options;
8
11
  const hook = registry.find((h) => h.name.toLowerCase() === hookName.toLowerCase());
9
12
  if (!hook) {
10
13
  console.log(pc.red(`✗ Hook "${hookName}" not found.`));
11
14
  console.log(pc.dim("Run `airyhooks list` to see available hooks."));
12
15
  process.exit(1);
13
16
  }
14
- const config = await getConfig();
17
+ const config = await getConfig({
18
+ ...(kebab ? { casing: "kebab-case" } : {}),
19
+ });
15
20
  const hooksDir = path.join(process.cwd(), config.hooksPath);
16
- const hookDir = path.join(hooksDir, hook.name);
17
- // Ensure hook subdirectory exists
18
- await fs.ensureDir(hookDir);
19
- // Check if hook already exists
20
- const hookFilePath = path.join(hookDir, `${hook.name}.ts`);
21
- if (await fs.pathExists(hookFilePath)) {
22
- console.log(pc.yellow(`⚠ ${hook.name} already exists. Skipping.`));
23
- return;
24
- }
25
- // Write hook implementation
21
+ const casedHookName = getHookFileBaseName(hook.name, config.casing);
22
+ const hookTargetDir = path.join(hooksDir, casedHookName);
26
23
  const template = getHookTemplate(hook.name);
27
- await fs.writeFile(hookFilePath, template);
28
- // Write barrel export
29
- const barrelFilePath = path.join(hookDir, "index.ts");
30
- const barrelContent = `export { ${hook.name} } from "./${hook.name}.js";\n`;
31
- await fs.writeFile(barrelFilePath, barrelContent);
32
- console.log(pc.green(`✓ Added ${hook.name}`));
33
- console.log(pc.dim(` → ${path.relative(process.cwd(), hookDir)}/`));
34
- console.log(pc.dim(` ├── ${hook.name}.ts`));
35
- console.log(pc.dim(` └── index.ts`));
24
+ const barrelContent = `export { ${hook.name} } from "./${casedHookName}${getFileExtension(config.importExtension)}";\n`;
25
+ if (!raw) {
26
+ // Ensure hook subdirectory exists
27
+ await fs.ensureDir(hookTargetDir);
28
+ const hookFilePath = path.join(hookTargetDir, `${casedHookName}.ts`);
29
+ // Check if hook already exists
30
+ if (!force && (await fs.pathExists(hookFilePath))) {
31
+ console.log(pc.yellow(`⚠ ${casedHookName} already exists. Skipping.`));
32
+ return;
33
+ }
34
+ const barrelFilePath = path.join(hookTargetDir, "index.ts");
35
+ // Write hook implementation
36
+ await fs.writeFile(hookFilePath, template);
37
+ // Write barrel export
38
+ await fs.writeFile(barrelFilePath, barrelContent);
39
+ console.log(pc.green(`✓ Added ${hook.name}`));
40
+ console.log(pc.dim(` → ${path.relative(process.cwd(), hookTargetDir)}/`));
41
+ console.log(pc.dim(` ├── ${casedHookName}.ts`));
42
+ console.log(pc.dim(` └── index.ts`));
43
+ }
44
+ else {
45
+ console.log(pc.cyan(template));
46
+ }
36
47
  if (hook.dependencies && hook.dependencies.length > 0) {
37
48
  console.log(pc.dim(`\n Required dependencies:`));
38
49
  hook.dependencies.forEach((dep) => {
@@ -1 +1 @@
1
- {"version":3,"file":"add.js","sourceRoot":"","sources":["../../src/commands/add.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,UAAU,CAAC;AAC1B,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,E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AG,CAAC,EAAE,CAAC,GAAG,CAAC,OAAO,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,aAAa,CAAC,GAAG,CAAC,CAAC,CAAC;QAC3E,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,WAAW,aAAa,KAAK,CAAC,CAAC,CAAC;QACnD,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,kBAAkB,CAAC,CAAC,CAAC;IAC1C,CAAC;SAAM,CAAC;QACN,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC;IACjC,CAAC;IAED,IAAI,IAAI,CAAC,YAAY,IAAI,IAAI,CAAC,YAAY,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACtD,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,4BAA4B,CAAC,CAAC,CAAC;QAClD,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,EAAE;YAChC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,mBAAmB,GAAG,EAAE,CAAC,CAAC,CAAC;QAChD,CAAC,CAAC,CAAC;IACL,CAAC;AACH,CAAC"}
@@ -0,0 +1,27 @@
1
+ import prompts from "prompts";
2
+ import { registry } from "../utils/registry.js";
3
+ import { add } from "./add.js";
4
+ export async function entry() {
5
+ const response = await prompts({
6
+ choices: registry.map((hook) => ({
7
+ description: hook.description,
8
+ title: hook.name,
9
+ value: hook.name,
10
+ })),
11
+ limit: 10,
12
+ message: "Select a hook to add:",
13
+ name: "hookName",
14
+ async suggest(input, choices) {
15
+ return Promise.resolve(choices
16
+ .filter((choice) => choice.title.toLowerCase().includes(input.toLowerCase()))
17
+ .sort((a, b) => a.title.localeCompare(b.title)));
18
+ },
19
+ type: "autocomplete",
20
+ });
21
+ const hookName = response.hookName;
22
+ if (!hookName) {
23
+ return;
24
+ }
25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+2,7 @@ import fs from "fs-extra";
2
2
  import path from "node:path";
3
3
  import pc from "picocolors";
4
4
  import prompts from "prompts";
5
- import { DEFAULT_CONFIG } from "../utils/config.js";
5
+ import { DEFAULT_CONFIG, } from "../utils/config.js";
6
6
  export async function init() {
7
7
  const configPath = path.join(process.cwd(), "airyhooks.json");
8
8
  if (await fs.pathExists(configPath)) {
@@ -17,18 +17,41 @@ export async function init() {
17
17
  return;
18
18
  }
19
19
  }
20
- const response = await prompts({
21
- initial: DEFAULT_CONFIG.hooksPath,
22
- message: "Where would you like to store your hooks?",
23
- name: "hooksPath",
24
- type: "text",
25
- });
20
+ const response = await prompts([
21
+ {
22
+ initial: DEFAULT_CONFIG.hooksPath,
23
+ message: "Where would you like to store your hooks?",
24
+ name: "hooksPath",
25
+ type: "text",
26
+ },
27
+ {
28
+ choices: [
29
+ {
30
+ description: "Use camelCase for hook file and directory names",
31
+ title: "useDebounce",
32
+ value: "camelCase",
33
+ },
34
+ {
35
+ description: "Use kebab-case for hook file and directory names",
36
+ title: "use-debounce",
37
+ value: "kebab-case",
38
+ },
39
+ ],
40
+ initial: 0,
41
+ message: "What naming convention would you like to use for your hook files and directories?",
42
+ name: "casing",
43
+ type: "select",
44
+ },
45
+ ]);
26
46
  const hooksPath = response.hooksPath;
27
- if (!hooksPath) {
47
+ const casing = response.casing;
48
+ if (!hooksPath || !casing) {
28
49
  console.log(pc.yellow("Initialization cancelled."));
29
50
  return;
30
51
  }
31
52
  const config = {
53
+ ...DEFAULT_CONFIG,
54
+ casing,
32
55
  hooksPath,
33
56
  };
34
57
  await fs.writeJson(configPath, config, { spaces: 2 });
@@ -1 +1 @@
1
- {"version":3,"file":"init.js","sourceRoot":"","sources":["../../src/commands/init.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,UAAU,CAAC;AAC1B,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,MAAM,YAAY,CAAC;AAC5B,OAAO,OAAO,MAAM,SAAS,CA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E,CAAC;YACV,OAAO,EACL,mFAAmF;YACrF,IAAI,EAAE,QAAQ;YACd,IAAI,EAAE,QAAQ;SACf;KACF,CAAC,CAAC;IAEH,MAAM,SAAS,GAAG,QAAQ,CAAC,SAA+B,CAAC;IAC3D,MAAM,MAAM,GAAG,QAAQ,CAAC,MAA4B,CAAC;IAErD,IAAI,CAAC,SAAS,IAAI,CAAC,MAAM,EAAE,CAAC;QAC1B,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,MAAM,CAAC,2BAA2B,CAAC,CAAC,CAAC;QACpD,OAAO;IACT,CAAC;IAED,MAAM,MAAM,GAAoB;QAC9B,GAAG,cAAc;QACjB,MAAM;QACN,SAAS;KACV,CAAC;IAEF,MAAM,EAAE,CAAC,SAAS,CAAC,UAAU,EAAE,MAAM,EAAE,EAAE,MAAM,EAAE,CAAC,EAAE,CAAC,CAAC;IAEtD,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,KAAK,CAAC,0BAA0B,CAAC,CAAC,CAAC;IAClD,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,4BAA4B,SAAS,EAAE,CAAC,CAAC,CAAC;AAC/D,CAAC"}
@@ -2,7 +2,7 @@ import pc from "picocolors";
2
2
  import { registry } from "../utils/registry.js";
3
3
  export function list() {
4
4
  console.log(pc.bold("\nAvailable hooks:\n"));
5
- for (const hook of registry) {
5
+ for (const hook of registry.sort((a, b) => a.name.localeCompare(b.name))) {
6
6
  console.log(` ${pc.cyan(hook.name)}`);
7
7
  console.log(pc.dim(` ${hook.description}\n`));
8
8
  }
@@ -1 +1 @@
1
- {"version":3,"file":"list.js","sourceRoot":"","sources":["../../src/commands/list.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,YAAY,CAAC;AAE5B,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAEhD,MAAM,UAAU,IAAI;IAClB,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,sBAAsB,CAAC,CAAC,CAAC;IAE7C,KAAK,MAAM,IAAI,IAAI,QAAQ,EAAE,CAAC;QAC5B,OAAO,CAAC,GAAG,CAAC,KAAK,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QACvC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,OAAO,IAAI,CAAC,WAAW,IAAI,CAAC,CAAC,CAAC;IACnD,CAAC;IAED,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,oCAAoC,CAAC,CAAC,CAAC;AAC5D,CAAC"}
1
+ {"version":3,"file":"list.js","sourceRoot":"","sources":["../../src/commands/list.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,YAAY,CAAC;AAE5B,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAEhD,MAAM,UAAU,IAAI;IAClB,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,sBAAsB,CAAC,CAAC,CAAC;IAE7C,KAAK,MAAM,IAAI,IAAI,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC;QACzE,OAAO,CAAC,GAAG,CAAC,KAAK,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QACvC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,OAAO,IAAI,CAAC,WAAW,IAAI,CAAC,CAAC,CAAC;IACnD,CAAC;IAED,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,oCAAoC,CAAC,CAAC,CAAC;AAC5D,CAAC"}
package/dist/index.js CHANGED
@@ -1,13 +1,17 @@
1
1
  #!/usr/bin/env node
2
2
  import { Command } from "commander";
3
+ import packageJson from "../package.json" with { type: "json" };
3
4
  import { add } from "./commands/add.js";
5
+ import { entry } from "./commands/entry.js";
4
6
  import { init } from "./commands/init.js";
5
7
  import { list } from "./commands/list.js";
6
8
  const program = new Command();
7
9
  program
8
10
  .name("airyhooks")
9
11
  .description("Add React hooks to your project")
10
- .version("0.1.0");
12
+ .action(entry)
13
+ .alias("search")
14
+ .version(packageJson.version, "-v, --version");
11
15
  program
12
16
  .command("init")
13
17
  .description("Initialize airyhooks configuration")
@@ -16,6 +20,9 @@ program
16
20
  .command("add")
17
21
  .description("Add a hook to your project")
18
22
  .argument("<hook>", "Name of the hook to add (e.g., useDebounce)")
23
+ .option("-r --raw", "Output only the raw hook template to console", false)
24
+ .option("-f --force", "Force overwrite if the hook file already exists", false)
25
+ .option("-k --kebab", "Use kebab-case for the hook file and directory names. Overrides the default casing in config.", false)
19
26
  .action(add);
20
27
  program.command("list").description("List all available hooks").action(list);
21
28
  program.parse();
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,OAAO,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AACxC,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAC1C,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAE1C,MAAM,OAAO,GAAG,IAAI,OAAO,EAAE,CAAC;AAE9B,OAAO;KACJ,IAAI,CAAC,WAAW,CAAC;KACjB,WAAW,CAAC,iCAAiC,CAAC;KAC9C,OAAO,CAAC,OAAO,CAAC,CAAC;AAEpB,OAAO;KACJ,OAAO,CAAC,MAAM,CAAC;KACf,WAAW,CAAC,oCAAoC,CAAC;KACjD,MAAM,CAAC,IAAI,CAAC,CAAC;AAEhB,OAAO;KACJ,OAAO,CAAC,KAAK,CAAC;KACd,WAAW,CAAC,4BAA4B,CAAC;KACzC,QAAQ,CA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AC/F,KAAK,CACN;KACA,MAAM,CAAC,GAAG,CAAC,CAAC;AAEf,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,WAAW,CAAC,0BAA0B,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;AAE7E,OAAO,CAAC,KAAK,EAAE,CAAC"}
@@ -1,14 +1,16 @@
1
1
  import fs from "fs-extra";
2
2
  import path from "node:path";
3
3
  export const DEFAULT_CONFIG = {
4
+ casing: "camelCase",
4
5
  hooksPath: "src/hooks",
6
+ importExtension: "none",
5
7
  };
6
- export async function getConfig() {
8
+ export async function getConfig(overrides) {
7
9
  const configPath = path.join(process.cwd(), "airyhooks.json");
8
10
  if (await fs.pathExists(configPath)) {
9
11
  const userConfig = (await fs.readJson(configPath));
10
- return { ...DEFAULT_CONFIG, ...userConfig };
12
+ return { ...DEFAULT_CONFIG, ...userConfig, ...overrides };
11
13
  }
12
- return DEFAULT_CONFIG;
14
+ return { ...DEFAULT_CONFIG, ...overrides };
13
15
  }
14
16
  //# sourceMappingURL=config.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/utils/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,UAAU,CAAC;AAC1B,OAAO,IAAI,MAAM,WAAW,CAAC;AAM7B,MAAM,CAAC,MAAM,cAAc,GAAoB;IAC7C,SAAS,EAAE,WAAW;CACvB,CAAC;AAEF,MAAM,CAAC,KAAK,UAAU,SAAS;IAC7B,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,gBAAgB,CAAC,CAAC;IAE9D,IAAI,MAAM,EAAE,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,CAAC;QACpC,MAAM,UAAU,GAAG,CAAC,MAAM,EAAE,CAAC,QAAQ,CACnC,UAAU,CACX,CAA6B,CAAC;QAC/B,OAAO,EAAE,GAAG,cAAc,EAAE,GAAG,UAAU,EAAE,CAAC;IAC9C,CAAC;IAED,OAAO,cAAc,CAAC;AACxB,CAAC"}
1
+ {"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/utils/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,UAAU,CAAC;AAC1B,OAAO,IAAI,MAAM,WAAW,CAAC;AAkB7B,MAAM,CAAC,MAAM,cAAc,GAA8B;IACvD,MAAM,EAAE,WAAW;IACnB,SAAS,EAAE,WAAW;IACtB,eAAe,EAAE,MAAM;CACxB,CAAC;AAEF,MAAM,CAAC,KAAK,UAAU,SAAS,CAC7B,SAAoC;IAEpC,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,gBAAgB,CAAC,CAAC;IAE9D,IAAI,MAAM,EAAE,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,CAAC;QACpC,MAAM,UAAU,GAAG,CAAC,MAAM,EAAE,CAAC,QAAQ,CACnC,UAAU,CACX,CAA6B,CAAC;QAE/B,OAAO,EAAE,GAAG,cAAc,EAAE,GAAG,UAAU,EAAE,GAAG,SAAS,EAAE,CAAC;IAC5D,CAAC;IAED,OAAO,EAAE,GAAG,cAAc,EAAE,GAAG,SAAS,EAAE,CAAC;AAC7C,CAAC"}
@@ -0,0 +1,9 @@
1
+ export function getFileExtension(ext) {
2
+ if (ext === "none") {
3
+ return "";
4
+ }
5
+ else {
6
+ return `.${ext}`;
7
+ }
8
+ }
9
+ //# sourceMappingURL=get-file-extension.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-file-extension.js","sourceRoot":"","sources":["../../src/utils/get-file-extension.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,gBAAgB,CAC9B,GAAyC;IAEzC,IAAI,GAAG,KAAK,MAAM,EAAE,CAAC;QACnB,OAAO,EAAE,CAAC;IACZ,CAAC;SAAM,CAAC;QACN,OAAO,IAAI,GAAG,EAAE,CAAC;IACnB,CAAC;AACH,CAAC"}
@@ -0,0 +1,12 @@
1
+ export function getHookFileBaseName(hookName, casing) {
2
+ if (casing === "camelCase") {
3
+ return hookName;
4
+ }
5
+ else {
6
+ return hookName
7
+ .replace(/([a-z0-9])([A-Z])/g, "$1-$2")
8
+ .replace(/([A-Z])([A-Z][a-z])/g, "$1-$2")
9
+ .toLowerCase();
10
+ }
11
+ }
12
+ //# sourceMappingURL=get-hook-filename.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-hook-filename.js","sourceRoot":"","sources":["../../src/utils/get-hook-filename.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,mBAAmB,CACjC,QAAgB,EAChB,MAAkC;IAElC,IAAI,MAAM,KAAK,WAAW,EAAE,CAAC;QAC3B,OAAO,QAAQ,CAAC;IAClB,CAAC;SAAM,CAAC;QACN,OAAO,QAAQ;aACZ,OAAO,CAAC,oBAAoB,EAAE,OAAO,CAAC;aACtC,OAAO,CAAC,sBAAsB,EAAE,OAAO,CAAC;aACxC,WAAW,EAAE,CAAC;IACnB,CAAC;AACH,CAAC"}