hokit 2.0.0 → 2.1.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/dist/cli/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env bun
2
- import{a as e,i as t,n,r,t as i}from"../watch-BO-aYzLX.js";switch(process.argv[2]){case`build`:await e();break;case`doctor`:await r();break;case`lint`:await n();break;case`watch`:await i();break;case`docs`:await t();break;default:console.log(`
2
+ import{a as e,i as t,n,o as r,r as i,t as a}from"../init-DyPLSOkt.js";switch(process.argv[2]){case`init`:await a(process.argv.find(e=>e.startsWith(`--`))?.replace(`--`,``)??`empty`);break;case`build`:await r();break;case`doctor`:await t();break;case`lint`:await i();break;case`watch`:await n();break;case`docs`:await e();break;default:console.log(`
3
3
  Hokit
4
4
 
5
5
  Usage:
package/dist/index.d.ts CHANGED
@@ -61,4 +61,7 @@ declare class HokitError extends Error {
61
61
  constructor(title: string, sections?: Record<string, string | string[]>);
62
62
  }
63
63
  //#endregion
64
- export { Build, BuildConfig, BuildOptions, HokitError, KnownScope, Module, ModuleOptions, Scope, Snippet, SnippetOptions, build, compile, defineConfig, discover, docs, doctor, lint, scopes, watchMode };
64
+ //#region src/init/init.d.ts
65
+ declare function init(template?: "empty" | "react"): Promise<void>;
66
+ //#endregion
67
+ export { Build, BuildConfig, BuildOptions, HokitError, KnownScope, Module, ModuleOptions, Scope, Snippet, SnippetOptions, build, compile, defineConfig, discover, docs, doctor, init, lint, scopes, watchMode };
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- import{_ as e,a as t,c as n,d as r,f as i,g as a,h as o,i as s,l as c,m as l,n as u,o as d,p as f,r as p,s as m,t as h,u as g}from"./watch-BO-aYzLX.js";function _(e){return e}const v=c({output:i()});function y(e){return r(v,e),t=>{o.set(t,e)}}const b=c({scopes:g(m(i())),tags:g(m(i()))});function x(e){return r(b,e),t=>{a.set(t,e)}}const S=c({name:i(),prefix:i(),body:m(i()),description:g(i()),template:g(n())});function C(t){return r(S,t),(n,r)=>{let i=n.constructor,a=e.get(i)??[];a.push({propertyKey:r,options:t}),e.set(i,a)}}const w=[`typescript`,`typescriptreact`,`javascript`,`javascriptreact`,`html`,`json`,`swift`,`kotlin`,`rust`,`go`,`python`,`java`,`c`,`cpp`,`dart`,`ruby`,`php`,`lua`,`elixir`,`zig`,`toml`,`yaml`,`markdown`];export{y as Build,d as HokitError,x as Module,C as Snippet,t as build,l as compile,_ as defineConfig,f as discover,s as docs,p as doctor,u as lint,w as scopes,h as watchMode};
1
+ import{_ as e,a as t,c as n,d as r,f as i,g as a,h as o,i as s,l as c,m as l,n as u,o as d,p as f,r as p,s as m,t as h,u as g,v as _}from"./init-DyPLSOkt.js";function v(e){return e}const y=g({output:f()});function b(e){return i(y,e),t=>{a.set(t,e)}}const x=g({scopes:r(n(f())),tags:r(n(f()))});function S(t){return i(x,t),n=>{e.set(n,t)}}const C=g({name:f(),prefix:f(),body:n(f()),description:r(f()),template:r(c())});function w(e){return i(C,e),(t,n)=>{let r=t.constructor,i=_.get(r)??[];i.push({propertyKey:n,options:e}),_.set(r,i)}}const T=[`typescript`,`typescriptreact`,`javascript`,`javascriptreact`,`html`,`json`,`swift`,`kotlin`,`rust`,`go`,`python`,`java`,`c`,`cpp`,`dart`,`ruby`,`php`,`lua`,`elixir`,`zig`,`toml`,`yaml`,`markdown`];export{b as Build,m as HokitError,S as Module,w as Snippet,d as build,o as compile,v as defineConfig,l as discover,t as docs,s as doctor,h as init,p as lint,T as scopes,u as watchMode};
@@ -4,4 +4,75 @@ import e from"node:fs/promises";import t from"node:path";import{pathToFileURL as
4
4
  `;for(let[e]of M){let n=N(e);t+=`# ${e.name}\n\n`,t+="```json\n",t+=JSON.stringify(n,null,2),t+=`
5
5
  \`\`\`
6
6
 
7
- `}await e.writeFile(`SNIPPETS.md`,t),$.success(`Generated SNIPPETS.md`)}async function Kt(){if(await xt(await Rt()),M.size===0){$.info(`No modules found.`);return}$.success(`Discovered ${M.size} module(s).`);let e=[...j.values()].reduce((e,t)=>e+t.length,0);$.success(`Loaded ${e} snippet(s).`),Vt(),$.success(`No duplicate names.`),Ut(),$.success(`No duplicate prefixes.`),Ht(),$.success(`No duplicate outputs.`)}async function qt(){await Kt()}async function Jt(){await Wt(),b(process.cwd(),{recursive:!0},async(e,t)=>{$.info(`Change detected: ${t}`);try{await Wt()}catch(e){console.error(e)}})}export{j as _,Wt as a,Mt as c,It as d,Ft as f,A as g,M as h,Gt as i,Nt as l,N as m,qt as n,Bt as o,xt as p,Kt as r,jt as s,Jt as t,Pt as u};
7
+ `}await e.writeFile(`SNIPPETS.md`,t),$.success(`Generated SNIPPETS.md`)}async function Kt(){if(await xt(await Rt()),M.size===0){$.info(`No modules found.`);return}$.success(`Discovered ${M.size} module(s).`);let e=[...j.values()].reduce((e,t)=>e+t.length,0);$.success(`Loaded ${e} snippet(s).`),Vt(),$.success(`No duplicate names.`),Ut(),$.success(`No duplicate prefixes.`),Ht(),$.success(`No duplicate outputs.`)}async function qt(){await Kt()}async function Jt(){await Wt(),b(process.cwd(),{recursive:!0},async(e,t)=>{$.info(`Change detected: ${t}`);try{await Wt()}catch(e){console.error(e)}})}async function Yt(){let t=`hokit.config.ts`;try{await e.access(t),$.info(`Skipped hokit.config.ts`);return}catch{}await e.writeFile(t,`import { defineConfig } from "hokit"
8
+
9
+ export default defineConfig({
10
+ cwd: "src/modules",
11
+ pattern:
12
+ "**/*.module.ts"
13
+
14
+ })`),$.success(`Created hokit.config.ts`)}const Xt={empty:{name:`empty`,filename:`example.module.ts`,content:`import {
15
+ Build,
16
+ Module,
17
+ Snippet
18
+ } from "hokit"
19
+
20
+ @Build({
21
+ output:
22
+ "dist/snippets/example.json"
23
+ })
24
+ @Module({
25
+ scopes: [
26
+ "typescript"
27
+ ]
28
+ })
29
+ export class ExampleModule {
30
+ @Snippet({
31
+ name:
32
+ "Example snippet",
33
+ prefix:
34
+ "example",
35
+ body: [
36
+ "$0"
37
+ ]
38
+ })
39
+ public example!: void
40
+ }`},react:{name:`react`,filename:`react.module.ts`,content:`import {
41
+ Build,
42
+ Module,
43
+ Snippet
44
+ } from "hokit"
45
+
46
+
47
+ @Build({
48
+ output:
49
+ "dist/snippets/react.json"
50
+ })
51
+
52
+
53
+ @Module({
54
+ scopes: [
55
+ "typescriptreact"
56
+ ],
57
+ tags: [
58
+ "react",
59
+ "web"
60
+ ]
61
+ })
62
+
63
+
64
+ export class ReactModule {
65
+ @Snippet({
66
+ name:
67
+ "React Functional Component",
68
+ prefix:
69
+ "rfc",
70
+ description:
71
+ "Creates a React component.",
72
+ body: [
73
+ "$0"
74
+ ]
75
+
76
+ })
77
+ public rfc!: void
78
+ }`}};async function Zt(n){let r=Xt[n],i=t.join(`src/modules`,r.filename);try{await e.access(i),$.info(`Skipped ${i}`);return}catch{}await e.mkdir(`src/modules`,{recursive:!0}),await e.writeFile(i,r.content),$.success(`Created ${i}`)}async function Qt(){let t=`tsconfig.json`;try{await e.access(t),$.info(`Skipped tsconfig.json`);return}catch{}await e.writeFile(t,JSON.stringify({compilerOptions:{target:`ES2022`,module:`ESNext`,moduleResolution:`Bundler`,strict:!0,experimentalDecorators:!0,skipLibCheck:!0}},null,4)),$.success(`Created tsconfig.json`)}async function $t(){try{let t=await e.readFile(`package.json`,`utf8`),n=JSON.parse(t);n.scripts??={},Object.assign(n.scripts,{build:`hokit build`,lint:`hokit lint`,doctor:`hokit doctor`,watch:`hokit watch`,docs:`hokit docs`}),await e.writeFile(`package.json`,JSON.stringify(n,null,4)),$.success(`Updated package.json`)}catch{$.info(`Skipped package.json`)}}async function en(e=`empty`){await Yt(),await Qt(),await Zt(e),await $t(),$.success(`Hokit initialized.`)}export{A as _,Gt as a,jt as c,Pt as d,It as f,M as g,N as h,Kt as i,Mt as l,xt as m,Jt as n,Wt as o,Ft as p,qt as r,Bt as s,en as t,Nt as u,j as v};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hokit",
3
- "version": "2.0.0",
3
+ "version": "2.1.0",
4
4
  "description": "A type-safe snippet registry and compiler for VSCode and Cursor.",
5
5
  "keywords": [
6
6
  "cursor",
package/readme.md CHANGED
@@ -18,29 +18,53 @@
18
18
  - 🎨 Colorful diagnostics
19
19
  - ⚡ Built for Bun and modern TypeScript
20
20
 
21
- ---
21
+ ## Project Initialization
22
22
 
23
- ## Installation
23
+ Hokit provides a CLI initializer to quickly create a ready-to-use project structure.
24
24
 
25
- Using Bun:
25
+ After installing Hokit:
26
26
 
27
27
  ```bash
28
28
  bun add -D hokit
29
29
  ```
30
30
 
31
- Using npm:
31
+ initialize your project:
32
32
 
33
33
  ```bash
34
- npm install -D hokit
34
+ bunx hokit init
35
35
  ```
36
36
 
37
- Using pnpm:
37
+ ## Templates
38
+
39
+ Hokit supports project templates to bootstrap different snippet collections.
40
+
41
+ ### Empty Template
42
+
43
+ Create a minimal snippet module:
38
44
 
39
45
  ```bash
40
- pnpm add -D hokit
46
+ bunx hokit init --empty
41
47
  ```
42
48
 
43
- ---
49
+ Generated file:
50
+
51
+ ```txt
52
+ src/modules/example.module.ts
53
+ ```
54
+
55
+ ### React Template
56
+
57
+ Create a React snippet module:
58
+
59
+ ```bash
60
+ hokit init --react
61
+ ```
62
+
63
+ Generated file:
64
+
65
+ ```txt
66
+ src/modules/react.module.ts
67
+ ```
44
68
 
45
69
  ## Project structure
46
70
 
@@ -59,8 +83,6 @@ dist/
59
83
  hokit.config.ts
60
84
  ```
61
85
 
62
- ---
63
-
64
86
  ## Configuration
65
87
 
66
88
  Create a `hokit.config.ts` file:
@@ -86,8 +108,6 @@ export default defineConfig({
86
108
  | `include` | Explicit include patterns | `undefined` |
87
109
  | `exclude` | Ignore patterns | `undefined` |
88
110
 
89
- ---
90
-
91
111
  ## Creating modules
92
112
 
93
113
  A module groups snippets that share metadata.
@@ -132,8 +152,6 @@ export class ReactModule {
132
152
  }
133
153
  ```
134
154
 
135
- ---
136
-
137
155
  ## Decorators
138
156
 
139
157
  ### `@Build`
@@ -181,8 +199,6 @@ Defines an individual snippet.
181
199
  })
182
200
  ```
183
201
 
184
- ---
185
-
186
202
  ## Available scopes
187
203
 
188
204
  ```ts
@@ -212,8 +228,6 @@ type Scope =
212
228
  | "markdown"
213
229
  ```
214
230
 
215
- ---
216
-
217
231
  ## CLI
218
232
 
219
233
  ### Build
@@ -230,8 +244,6 @@ Output:
230
244
  ✔ Generated dist/snippets/react.json
231
245
  ```
232
246
 
233
- ---
234
-
235
247
  ### Doctor
236
248
 
237
249
  Runs diagnostics.
@@ -250,8 +262,6 @@ Example output:
250
262
  ✔ No duplicate outputs.
251
263
  ```
252
264
 
253
- ---
254
-
255
265
  ### Lint
256
266
 
257
267
  Runs validations.
@@ -260,8 +270,6 @@ Runs validations.
260
270
  hokit lint
261
271
  ```
262
272
 
263
- ---
264
-
265
273
  ### Watch
266
274
 
267
275
  Rebuilds automatically on file changes.
@@ -277,8 +285,6 @@ Output:
277
285
  ✔ Generated dist/snippets/react.json
278
286
  ```
279
287
 
280
- ---
281
-
282
288
  ### Docs
283
289
 
284
290
  Generates documentation.
@@ -293,8 +299,6 @@ Generates:
293
299
  SNIPPETS.md
294
300
  ```
295
301
 
296
- ---
297
-
298
302
  ## Validation
299
303
 
300
304
  Hokit validates your project in two ways:
@@ -333,8 +337,6 @@ Found in:
333
337
  • AnotherModule.rfc
334
338
  ```
335
339
 
336
- ---
337
-
338
340
  #### Duplicate prefixes
339
341
 
340
342
  ```txt
@@ -348,8 +350,6 @@ Found in:
348
350
  • AnotherModule.rfc
349
351
  ```
350
352
 
351
- ---
352
-
353
353
  #### Duplicate outputs
354
354
 
355
355
  ```txt
@@ -360,8 +360,6 @@ Found in:
360
360
  • AnotherModule
361
361
  ```
362
362
 
363
- ---
364
-
365
363
  ## Generated output
366
364
 
367
365
  The following snippet:
@@ -392,8 +390,6 @@ Generates:
392
390
  }
393
391
  ```
394
392
 
395
- ---
396
-
397
393
  ## Why Hokit?
398
394
 
399
395
  Traditional snippet JSON quickly becomes difficult to maintain.
@@ -414,8 +410,6 @@ Inspired by:
414
410
  - Drizzle
415
411
  - Vite
416
412
 
417
- ---
418
-
419
413
  ## License
420
414
 
421
415
  MIT