hokit 1.1.0 → 1.2.1-beta.1
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.d.ts +1 -0
- package/dist/cli/index.js +9 -0
- package/dist/index.d.ts +13 -2
- package/dist/index.js +1 -1
- package/dist/lint-B7CfdNnF.js +1 -0
- package/package.json +4 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import{n as e,t}from"../lint-B7CfdNnF.js";import n from"node:path";const r=process.argv[2],i=await import(n.join(process.cwd(),`hokit.config.ts`));switch(r){case`build`:await e(...i.default.snippets);break;case`lint`:await t(...i.default.snippets);break;default:console.log(`
|
|
3
|
+
Hokit
|
|
4
|
+
|
|
5
|
+
Usage:
|
|
6
|
+
|
|
7
|
+
hokit build
|
|
8
|
+
hokit lint
|
|
9
|
+
`)}export{};
|
package/dist/index.d.ts
CHANGED
|
@@ -14,7 +14,7 @@ interface Snippet {
|
|
|
14
14
|
declare class SnippetBuilder {
|
|
15
15
|
private snippet;
|
|
16
16
|
name(name: string): this;
|
|
17
|
-
scope(
|
|
17
|
+
scope(scopes: Scope[]): this;
|
|
18
18
|
prefix(prefix: string): this;
|
|
19
19
|
body(snippet: string[]): this;
|
|
20
20
|
describe(description: string): this;
|
|
@@ -36,9 +36,20 @@ declare function defineCofig(config: Config): Config;
|
|
|
36
36
|
//#region src/build.d.ts
|
|
37
37
|
declare function build(...config: Config[]): Promise<void>;
|
|
38
38
|
//#endregion
|
|
39
|
+
//#region src/types/hokit-config.d.ts
|
|
40
|
+
interface HokitConfig {
|
|
41
|
+
snippets: Config[];
|
|
42
|
+
}
|
|
43
|
+
//#endregion
|
|
44
|
+
//#region src/define-hokit-config.d.ts
|
|
45
|
+
declare function defineConfig(config: HokitConfig): HokitConfig;
|
|
46
|
+
//#endregion
|
|
47
|
+
//#region src/lint.d.ts
|
|
48
|
+
declare function lint(...configs: Config[]): Promise<void>;
|
|
49
|
+
//#endregion
|
|
39
50
|
//#region src/registry.d.ts
|
|
40
51
|
declare abstract class Registry {
|
|
41
52
|
static name(name: string): SnippetBuilder;
|
|
42
53
|
}
|
|
43
54
|
//#endregion
|
|
44
|
-
export { Registry, type Snippet, build, defineCofig };
|
|
55
|
+
export { HokitConfig, Registry, type Snippet, build, defineCofig, defineConfig, lint };
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import
|
|
1
|
+
import{n as e,t}from"./lint-B7CfdNnF.js";function n(e){return e}function r(e){return e}var i=class{snippet={};name(e){return this.snippet.name=e,this}scope(e){return this.snippet.scope=[...e].sort(),this}prefix(e){return this.snippet.prefix=e,this}body(e){return this.snippet.body=e,this}describe(e){return this.snippet.description=e,this}template(e=!0){return this.snippet.isFileTemplate=e,this}tag(e){return this.snippet.tags=e,this}build(){return this.snippet}},a=class{static name(e){return new i().name(e)}};export{a as Registry,e as build,n as defineCofig,r as defineConfig,t as lint};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import e from"node:fs/promises";import t from"node:path";const n={info(e){console.log(e)},success(e){console.log(e)},error(e){console.error(e)}},r={lang:void 0,message:void 0,abortEarly:void 0,abortPipeEarly:void 0};function i(e){return e?{lang:e?.lang??void 0,message:e?.message,abortEarly:e?.abortEarly??void 0,abortPipeEarly:e?.abortPipeEarly??void 0}:r}function a(e){let t=typeof e;return t===`string`?`"${e}"`:t===`number`||t===`bigint`||t===`boolean`?`${e}`:t===`object`||t===`function`?(e&&Object.getPrototypeOf(e)?.constructor?.name)??`null`:t}function o(e,t,n,r,i){let o=i&&`input`in i?i.input:n.value,s=i?.expected??e.expects??null,c=i?.received??a(o),l={kind:e.kind,type:e.type,input:o,expected:s,received:c,message:`Invalid ${t}: ${s?`Expected ${s} but r`:`R`}eceived ${c}`,requirement:e.requirement,path:i?.path,issues:i?.issues,lang:r.lang,abortEarly:r.abortEarly,abortPipeEarly:r.abortPipeEarly},u=e.kind===`schema`,d=i?.message??e.message??(e.reference,l.lang,void 0)??(u?(l.lang,void 0):null)??r.message??(l.lang,void 0);d!==void 0&&(l.message=typeof d==`function`?d(l):d),u&&(n.typed=!1),n.issues?n.issues.push(l):n.issues=[l]}const s=new WeakMap;function c(e){let t=s.get(e);return t||(t={version:1,vendor:`valibot`,validate(t){return e[`~run`]({value:t},i())}},s.set(e,t)),t}var l=class extends Error{constructor(e){super(e[0].message),this.name=`ValiError`,this.issues=e}};function u(e,t){return{kind:`validation`,type:`min_length`,reference:u,async:!1,expects:`>=${e}`,requirement:e,message:t,"~run"(e,t){return e.typed&&e.value.length<this.requirement&&o(this,`length`,e,t,{received:`${e.value.length}`}),e}}}function d(e,t,n){return typeof e.fallback==`function`?e.fallback(t,n):e.fallback}function f(e,t,n){return typeof e.default==`function`?e.default(t,n):e.default}function p(e,t){return{kind:`schema`,type:`array`,reference:p,expects:`Array`,async:!1,item:e,message:t,get"~standard"(){return c(this)},"~run"(e,t){let n=e.value;if(Array.isArray(n)){e.typed=!0,e.value=[];for(let r=0;r<n.length;r++){let i=n[r],a=this.item[`~run`]({value:i},t);if(a.issues){let o={type:`array`,origin:`value`,input:n,key:r,value:i};for(let t of a.issues)t.path?t.path.unshift(o):t.path=[o],e.issues?.push(t);if(e.issues||=a.issues,t.abortEarly){e.typed=!1;break}}a.typed||(e.typed=!1),e.value.push(a.value)}}else o(this,`type`,e,t);return e}}}function m(e){return{kind:`schema`,type:`boolean`,reference:m,expects:`boolean`,async:!1,message:e,get"~standard"(){return c(this)},"~run"(e,t){return typeof e.value==`boolean`?e.typed=!0:o(this,`type`,e,t),e}}}function h(e,t){return{kind:`schema`,type:`object`,reference:h,expects:`Object`,async:!1,entries:e,message:t,get"~standard"(){return c(this)},"~run"(e,t){let n=e.value;if(n&&typeof n==`object`){e.typed=!0,e.value={};for(let r in this.entries){let i=this.entries[r];if(r in n||(i.type===`exact_optional`||i.type===`optional`||i.type===`nullish`)&&i.default!==void 0){let a=r in n?n[r]:f(i),o=i[`~run`]({value:a},t);if(o.issues){let i={type:`object`,origin:`value`,input:n,key:r,value:a};for(let t of o.issues)t.path?t.path.unshift(i):t.path=[i],e.issues?.push(t);if(e.issues||=o.issues,t.abortEarly){e.typed=!1;break}}o.typed||(e.typed=!1),e.value[r]=o.value}else if(i.fallback!==void 0)e.value[r]=d(i);else if(i.type!==`exact_optional`&&i.type!==`optional`&&i.type!==`nullish`&&(o(this,`key`,e,t,{input:void 0,expected:`"${r}"`,path:[{type:`object`,origin:`key`,input:n,key:r,value:n[r]}]}),t.abortEarly))break}}else o(this,`type`,e,t);return e}}}function g(e){return{kind:`schema`,type:`string`,reference:g,expects:`string`,async:!1,message:e,get"~standard"(){return c(this)},"~run"(e,t){return typeof e.value==`string`?e.typed=!0:o(this,`type`,e,t),e}}}function _(e,t,n){let r=e[`~run`]({value:t},i(n));if(r.issues)throw new l(r.issues);return r.value}function v(...e){return{...e[0],pipe:e,get"~standard"(){return c(this)},"~run"(t,n){for(let r of e)if(r.kind!==`metadata`){if(t.issues&&(r.kind===`schema`||r.kind===`transformation`)){t.typed=!1;break}(!t.issues||!n.abortEarly&&!n.abortPipeEarly)&&(t=r[`~run`](t,n))}return t}}}function y(e){let t=new Set;for(let n of e){if(t.has(n.name))throw Error(`Duplicate snippet name: "${n.name}"`);t.add(n.name)}}function b(e){let t=new Set;for(let n of e)for(let e of n.scope){let r=`${e}: ${n.prefix}`;if(t.has(r))throw Error(`Duplicate prefix "${n.prefix}" in scope "${e}"`);t.add(r)}}const x=h({name:v(g(),u(1)),scope:v(p(g()),u(1)),prefix:v(g(),u(1)),body:v(p(g()),u(1)),tags:p(g()),isFileTemplate:m()});function S(e){for(let t of e)_(x,t);y(e),b(e)}function C(e){return{[e.name]:{scope:e.scope.join(`,`),prefix:e.prefix,body:e.body,description:e.description,isFileTemplate:e.isFileTemplate}}}function w(e){let t={};for(let n of e)Object.assign(t,C(n));return t}async function T(n){let r=n.snippets.map(e=>e.build());r.sort((e,t)=>e.name.localeCompare(t.name)),S(r);let i=w(r);return await e.mkdir(t.dirname(n.output),{recursive:!0}),await e.writeFile(n.output,JSON.stringify(i,null,4),`utf-8`),{output:n.output,snippets:n.snippets.length}}async function E(...e){let t=await Promise.all(e.map(T)),r=t.reduce((e,t)=>e+t.snippets,0);n.success(`Generated ${t.length} file(s) from ${r} snippet(s).`);for(let e of t)n.info(e.output)}async function D(...e){n.info(`Linting ${e.length} file(s)...`);let t=0;for(let r of e){let e=r.snippets.map(e=>e.build());S(e),t+=e.length,n.success(r.output)}n.success(`No issues found in ${t} snippet(s).`)}export{E as n,D as t};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "hokit",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.2.1-beta.1",
|
|
4
4
|
"description": "A type-safe snippet registry and compiler for VSCode and Cursor.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cursor",
|
|
@@ -17,6 +17,9 @@
|
|
|
17
17
|
"type": "git",
|
|
18
18
|
"url": "https://github.com/uaibritto/hokit.git"
|
|
19
19
|
},
|
|
20
|
+
"bin": {
|
|
21
|
+
"hokit": "./dist/cli/index.js"
|
|
22
|
+
},
|
|
20
23
|
"files": [
|
|
21
24
|
"dist"
|
|
22
25
|
],
|