@lintai/sdk 0.1.2 → 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/dist/index.d.ts +47 -112
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +114 -61
- package/dist/index.js.map +1 -1
- package/package.json +5 -3
package/dist/index.d.ts
CHANGED
|
@@ -1,128 +1,63 @@
|
|
|
1
|
-
export type
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
} | {
|
|
16
|
-
type: "calling";
|
|
17
|
-
query: QueryValue;
|
|
18
|
-
} | {
|
|
19
|
-
type: "transitivelyCalling";
|
|
20
|
-
query: QueryValue;
|
|
21
|
-
};
|
|
22
|
-
export type FunctionView = {
|
|
23
|
-
name: string;
|
|
24
|
-
kind: string;
|
|
25
|
-
filePath: string;
|
|
26
|
-
containerName: string;
|
|
27
|
-
semanticKey: string;
|
|
28
|
-
containsAwait: boolean;
|
|
29
|
-
isExported: boolean;
|
|
30
|
-
isAsync: boolean;
|
|
31
|
-
parameterCount: number;
|
|
32
|
-
returnTypeText: string;
|
|
33
|
-
parameterTypeTexts: string[];
|
|
34
|
-
sourceLocation: SourceLocation;
|
|
35
|
-
};
|
|
36
|
-
export type ImportedSymbolView = {
|
|
37
|
-
name: string;
|
|
38
|
-
kind: "default" | "namespace" | "named";
|
|
39
|
-
isTypeOnly: boolean;
|
|
40
|
-
};
|
|
41
|
-
export type ImportEdgeView = {
|
|
42
|
-
specifier: string;
|
|
43
|
-
fromPath: string;
|
|
44
|
-
toPath: string;
|
|
45
|
-
semanticKey: string;
|
|
46
|
-
importedSymbols: ImportedSymbolView[];
|
|
47
|
-
hasDefaultImport: boolean;
|
|
48
|
-
hasNamespaceImport: boolean;
|
|
49
|
-
hasNamedImports: boolean;
|
|
50
|
-
isTypeOnly: boolean;
|
|
51
|
-
sourceLocation: SourceLocation;
|
|
52
|
-
};
|
|
53
|
-
export type CallEdgeView = {
|
|
54
|
-
fromName: string;
|
|
55
|
-
toName: string;
|
|
56
|
-
fromPath: string;
|
|
57
|
-
toPath: string;
|
|
58
|
-
semanticKey: string;
|
|
59
|
-
sourceLocation: SourceLocation;
|
|
60
|
-
};
|
|
61
|
-
export type TypeRefView = {
|
|
62
|
-
name: string;
|
|
63
|
-
filePath: string;
|
|
64
|
-
targetPath: string;
|
|
65
|
-
semanticKey: string;
|
|
66
|
-
sourceLocation: SourceLocation;
|
|
67
|
-
};
|
|
68
|
-
export type SourceLocation = {
|
|
69
|
-
file: string;
|
|
70
|
-
startLine: number;
|
|
71
|
-
startColumn: number;
|
|
72
|
-
endLine: number;
|
|
73
|
-
endColumn: number;
|
|
74
|
-
};
|
|
75
|
-
export type AssertionContext = {
|
|
1
|
+
export type Fragment = {
|
|
2
|
+
readonly __lintaiKind: "fragment";
|
|
3
|
+
readonly text: string;
|
|
4
|
+
};
|
|
5
|
+
export type Name = {
|
|
6
|
+
readonly __lintaiKind: "name";
|
|
7
|
+
readonly value: string;
|
|
8
|
+
};
|
|
9
|
+
export type DlValue = string | number | Name | Fragment;
|
|
10
|
+
export type FactValue = string | number | Name;
|
|
11
|
+
export type Facts = Record<string, FactValue[][]>;
|
|
12
|
+
export type RowValue = string | number;
|
|
13
|
+
export type Row = Record<string, RowValue>;
|
|
14
|
+
export type MessageContext = {
|
|
76
15
|
assertion_id: string;
|
|
77
16
|
};
|
|
78
17
|
export type RuleContext<Env, Setup> = {
|
|
79
18
|
env: Env;
|
|
80
19
|
setup: Setup;
|
|
81
20
|
};
|
|
82
|
-
export type
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
query: QueryValue;
|
|
21
|
+
export type SetupContext<Env> = {
|
|
22
|
+
env: Env;
|
|
23
|
+
workspaceRoot: string;
|
|
86
24
|
};
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
in(pattern: string): QueryValue;
|
|
92
|
-
from(pattern: string): QueryValue;
|
|
93
|
-
to(pattern: string): QueryValue;
|
|
94
|
-
where(predicate: Predicate<any>): QueryValue;
|
|
95
|
-
calling(other: QueryValue): QueryValue;
|
|
96
|
-
transitivelyCalling(other: QueryValue): QueryValue;
|
|
97
|
-
isEmpty(): AssertionValue;
|
|
25
|
+
declare function name(value: string): Name;
|
|
26
|
+
declare function dlTag(strings: TemplateStringsArray, ...values: DlValue[]): Fragment;
|
|
27
|
+
export type Dl = typeof dlTag & {
|
|
28
|
+
readonly name: typeof name;
|
|
98
29
|
};
|
|
99
|
-
|
|
30
|
+
export declare const dl: Dl;
|
|
31
|
+
export type ProgramInput<Env, Setup> = Fragment | ((ctx: RuleContext<Env, Setup>) => Fragment);
|
|
32
|
+
type RuleSpec<Env, Setup> = {
|
|
100
33
|
id: string;
|
|
101
34
|
versionValue?: number;
|
|
102
|
-
setupFn?: (
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
messageFn?: (
|
|
108
|
-
};
|
|
109
|
-
declare class RuleDefinition<Env, Setup
|
|
35
|
+
setupFn?: (ctx: SetupContext<Env>) => Setup | Promise<Setup>;
|
|
36
|
+
factsFn?: (ctx: RuleContext<Env, Setup>) => Facts;
|
|
37
|
+
programValue?: ProgramInput<Env, Setup>;
|
|
38
|
+
reportPredicates?: readonly string[];
|
|
39
|
+
expectNonEmptyPredicates?: readonly string[];
|
|
40
|
+
messageFn?: (row: Row, ctx: MessageContext) => string;
|
|
41
|
+
};
|
|
42
|
+
export declare class RuleDefinition<Env, Setup> {
|
|
110
43
|
private readonly spec;
|
|
111
44
|
readonly id: string;
|
|
112
45
|
readonly versionValue?: number;
|
|
113
|
-
readonly setupFn?:
|
|
114
|
-
readonly
|
|
115
|
-
readonly
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
46
|
+
readonly setupFn?: RuleSpec<Env, Setup>["setupFn"];
|
|
47
|
+
readonly factsFn?: RuleSpec<Env, Setup>["factsFn"];
|
|
48
|
+
readonly programValue?: RuleSpec<Env, Setup>["programValue"];
|
|
49
|
+
readonly reportPredicates?: readonly string[];
|
|
50
|
+
readonly expectNonEmptyPredicates?: readonly string[];
|
|
51
|
+
readonly messageFn?: RuleSpec<Env, Setup>["messageFn"];
|
|
52
|
+
constructor(spec: RuleSpec<Env, Setup>);
|
|
53
|
+
version(versionValue: number): RuleDefinition<Env, Setup>;
|
|
54
|
+
setup<NextSetup>(setupFn: (ctx: SetupContext<Env>) => NextSetup | Promise<NextSetup>): RuleDefinition<Env, Awaited<NextSetup>>;
|
|
55
|
+
facts(factsFn: (ctx: RuleContext<Env, Setup>) => Facts): RuleDefinition<Env, Setup>;
|
|
56
|
+
program(programValue: ProgramInput<Env, Setup>): RuleDefinition<Env, Setup>;
|
|
57
|
+
report(...predicates: string[]): RuleDefinition<Env, Setup>;
|
|
58
|
+
expectNonEmpty(...predicates: string[]): RuleDefinition<Env, Setup>;
|
|
59
|
+
message(messageFn: (row: Row, ctx: MessageContext) => string): RuleDefinition<Env, Setup>;
|
|
121
60
|
}
|
|
122
|
-
export declare function rule<Env = Record<string, any>, Setup = Record<string, never
|
|
123
|
-
export declare function functions(): QueryValue;
|
|
124
|
-
export declare function imports(): QueryValue;
|
|
125
|
-
export declare function calls(): QueryValue;
|
|
126
|
-
export declare function typeRefs(): QueryValue;
|
|
61
|
+
export declare function rule<Env = Record<string, any>, Setup = Record<string, never>>(id: string): RuleDefinition<Env, Setup>;
|
|
127
62
|
export {};
|
|
128
63
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,
|
|
1
|
+
{"version":3,"file":"index.d.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AE,GAAG,CAAC,EAAE,KAAK,GAAG,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,EAC5E,EAAE,EAAE,MAAM,GACR,cAAc,CAAC,GAAG,EAAE,KAAK,CAAC,CAE5B"}
|
package/dist/index.js
CHANGED
|
@@ -1,16 +1,114 @@
|
|
|
1
|
-
|
|
1
|
+
const namePattern = /^[a-z][a-z0-9_]*(\/[a-z0-9_]+)*$/;
|
|
2
|
+
function isTagged(value, kind) {
|
|
3
|
+
return (typeof value === "object" &&
|
|
4
|
+
value !== null &&
|
|
5
|
+
value.__lintaiKind === kind);
|
|
6
|
+
}
|
|
7
|
+
function describe(value) {
|
|
8
|
+
if (value === null)
|
|
9
|
+
return "null";
|
|
10
|
+
if (Array.isArray(value))
|
|
11
|
+
return "an array";
|
|
12
|
+
return typeof value;
|
|
13
|
+
}
|
|
14
|
+
function hex(code, width) {
|
|
15
|
+
return code.toString(16).padStart(width, "0");
|
|
16
|
+
}
|
|
17
|
+
function escapeString(value) {
|
|
18
|
+
let result = '"';
|
|
19
|
+
for (const char of value) {
|
|
20
|
+
const code = char.codePointAt(0) ?? 0;
|
|
21
|
+
switch (char) {
|
|
22
|
+
case "\\":
|
|
23
|
+
result += "\\\\";
|
|
24
|
+
break;
|
|
25
|
+
case '"':
|
|
26
|
+
result += '\\"';
|
|
27
|
+
break;
|
|
28
|
+
case "'":
|
|
29
|
+
result += "\\'";
|
|
30
|
+
break;
|
|
31
|
+
case "\n":
|
|
32
|
+
result += "\\n";
|
|
33
|
+
break;
|
|
34
|
+
case "\t":
|
|
35
|
+
result += "\\t";
|
|
36
|
+
break;
|
|
37
|
+
default:
|
|
38
|
+
if (code < 0x20 || code === 0x7f) {
|
|
39
|
+
result += `\\x${hex(code, 2)}`;
|
|
40
|
+
}
|
|
41
|
+
else if (code > 0x7e) {
|
|
42
|
+
result += `\\u{${hex(code, 4)}}`;
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
result += char;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
return `${result}"`;
|
|
50
|
+
}
|
|
51
|
+
function formatNumber(value) {
|
|
52
|
+
if (!Number.isFinite(value)) {
|
|
53
|
+
throw new TypeError(`dl: cannot interpolate non-finite number ${value}`);
|
|
54
|
+
}
|
|
55
|
+
if (Number.isInteger(value)) {
|
|
56
|
+
if (!Number.isSafeInteger(value)) {
|
|
57
|
+
throw new TypeError(`dl: integer ${value} is outside the safe integer range`);
|
|
58
|
+
}
|
|
59
|
+
return String(value);
|
|
60
|
+
}
|
|
61
|
+
const text = String(value);
|
|
62
|
+
if (text.includes("e")) {
|
|
63
|
+
throw new TypeError(`dl: cannot interpolate ${value}; use a number without an exponent`);
|
|
64
|
+
}
|
|
65
|
+
return text;
|
|
66
|
+
}
|
|
67
|
+
function formatValue(value) {
|
|
68
|
+
if (typeof value === "string")
|
|
69
|
+
return escapeString(value);
|
|
70
|
+
if (typeof value === "number")
|
|
71
|
+
return formatNumber(value);
|
|
72
|
+
if (isTagged(value, "fragment"))
|
|
73
|
+
return value.text;
|
|
74
|
+
if (isTagged(value, "name"))
|
|
75
|
+
return `/${value.value}`;
|
|
76
|
+
throw new TypeError(`dl: cannot interpolate ${describe(value)}; use a string, a finite number, dl.name() or a dl fragment`);
|
|
77
|
+
}
|
|
78
|
+
function name(value) {
|
|
79
|
+
if (typeof value !== "string" || !namePattern.test(value)) {
|
|
80
|
+
throw new TypeError(`dl.name: ${JSON.stringify(value)} is not a valid name; it must match ${namePattern}`);
|
|
81
|
+
}
|
|
82
|
+
return Object.freeze({ __lintaiKind: "name", value });
|
|
83
|
+
}
|
|
84
|
+
function dlTag(strings, ...values) {
|
|
85
|
+
let text = strings[0] ?? "";
|
|
86
|
+
for (let index = 0; index < values.length; index++) {
|
|
87
|
+
text += formatValue(values[index]);
|
|
88
|
+
text += strings[index + 1] ?? "";
|
|
89
|
+
}
|
|
90
|
+
return Object.freeze({ __lintaiKind: "fragment", text });
|
|
91
|
+
}
|
|
92
|
+
export const dl = Object.defineProperty((strings, ...values) => dlTag(strings, ...values), "name", { value: name, enumerable: true });
|
|
93
|
+
export class RuleDefinition {
|
|
2
94
|
spec;
|
|
3
95
|
id;
|
|
4
96
|
versionValue;
|
|
5
97
|
setupFn;
|
|
6
|
-
|
|
98
|
+
factsFn;
|
|
99
|
+
programValue;
|
|
100
|
+
reportPredicates;
|
|
101
|
+
expectNonEmptyPredicates;
|
|
7
102
|
messageFn;
|
|
8
103
|
constructor(spec) {
|
|
9
104
|
this.spec = spec;
|
|
10
105
|
this.id = spec.id;
|
|
11
106
|
this.versionValue = spec.versionValue;
|
|
12
107
|
this.setupFn = spec.setupFn;
|
|
13
|
-
this.
|
|
108
|
+
this.factsFn = spec.factsFn;
|
|
109
|
+
this.programValue = spec.programValue;
|
|
110
|
+
this.reportPredicates = spec.reportPredicates;
|
|
111
|
+
this.expectNonEmptyPredicates = spec.expectNonEmptyPredicates;
|
|
14
112
|
this.messageFn = spec.messageFn;
|
|
15
113
|
}
|
|
16
114
|
version(versionValue) {
|
|
@@ -19,71 +117,26 @@ class RuleDefinition {
|
|
|
19
117
|
setup(setupFn) {
|
|
20
118
|
return new RuleDefinition({
|
|
21
119
|
...this.spec,
|
|
22
|
-
setupFn,
|
|
120
|
+
setupFn: setupFn,
|
|
23
121
|
});
|
|
24
122
|
}
|
|
25
|
-
|
|
26
|
-
return new RuleDefinition({
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
});
|
|
123
|
+
facts(factsFn) {
|
|
124
|
+
return new RuleDefinition({ ...this.spec, factsFn });
|
|
125
|
+
}
|
|
126
|
+
program(programValue) {
|
|
127
|
+
return new RuleDefinition({ ...this.spec, programValue });
|
|
128
|
+
}
|
|
129
|
+
report(...predicates) {
|
|
130
|
+
return new RuleDefinition({ ...this.spec, reportPredicates: predicates });
|
|
131
|
+
}
|
|
132
|
+
expectNonEmpty(...predicates) {
|
|
133
|
+
return new RuleDefinition({ ...this.spec, expectNonEmptyPredicates: predicates });
|
|
30
134
|
}
|
|
31
135
|
message(messageFn) {
|
|
32
|
-
return new RuleDefinition({
|
|
33
|
-
...this.spec,
|
|
34
|
-
messageFn,
|
|
35
|
-
});
|
|
136
|
+
return new RuleDefinition({ ...this.spec, messageFn });
|
|
36
137
|
}
|
|
37
138
|
}
|
|
38
|
-
function createQuery(entity, ops = []) {
|
|
39
|
-
const query = {
|
|
40
|
-
__lintaiKind: "query",
|
|
41
|
-
entity,
|
|
42
|
-
ops,
|
|
43
|
-
in(pattern) {
|
|
44
|
-
return createQuery(entity, [...ops, { type: "in", value: pattern }]);
|
|
45
|
-
},
|
|
46
|
-
from(pattern) {
|
|
47
|
-
return createQuery(entity, [...ops, { type: "from", value: pattern }]);
|
|
48
|
-
},
|
|
49
|
-
to(pattern) {
|
|
50
|
-
return createQuery(entity, [...ops, { type: "to", value: pattern }]);
|
|
51
|
-
},
|
|
52
|
-
where(predicate) {
|
|
53
|
-
return createQuery(entity, [...ops, { type: "where", handler: predicate }]);
|
|
54
|
-
},
|
|
55
|
-
calling(other) {
|
|
56
|
-
return createQuery(entity, [...ops, { type: "calling", query: other }]);
|
|
57
|
-
},
|
|
58
|
-
transitivelyCalling(other) {
|
|
59
|
-
return createQuery(entity, [
|
|
60
|
-
...ops,
|
|
61
|
-
{ type: "transitivelyCalling", query: other },
|
|
62
|
-
]);
|
|
63
|
-
},
|
|
64
|
-
isEmpty() {
|
|
65
|
-
return {
|
|
66
|
-
__lintaiKind: "assertion",
|
|
67
|
-
terminal: "isEmpty",
|
|
68
|
-
query,
|
|
69
|
-
};
|
|
70
|
-
},
|
|
71
|
-
};
|
|
72
|
-
return query;
|
|
73
|
-
}
|
|
74
139
|
export function rule(id) {
|
|
75
140
|
return new RuleDefinition({ id });
|
|
76
141
|
}
|
|
77
|
-
export function functions() {
|
|
78
|
-
return createQuery("functions");
|
|
79
|
-
}
|
|
80
|
-
export function imports() {
|
|
81
|
-
return createQuery("imports");
|
|
82
|
-
}
|
|
83
|
-
export function calls() {
|
|
84
|
-
return createQuery("calls");
|
|
85
|
-
}
|
|
86
|
-
export function typeRefs() {
|
|
87
|
-
return createQuery("typeRefs");
|
|
88
|
-
}
|
|
89
142
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAkCA,MAAM,WAAW,GAAG,kCAAkC,CAAC;AAEvD,SAAS,QAAQ,CAAC,KAAc,EAAE,IAAyB;IAC1D,OAAO,CACN,OAAO,KAAK,KAAK,QAAQ;QACzB,KAAK,KAAK,IAAI;QACb,KAAoC,CAAC,YAAY,KAAK,IAAI,CAC3D,CAAC;AACH,CAAC;AAED,SAAS,QAAQ,CAAC,KAAc;IAC/B,IAAI,KAAK,KAAK,IAAI;QAAE,OAAO,MAAM,CAAC;IAClC,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;QAAE,OAAO,UAAU,CAAC;IAC5C,OAAO,OAAO,KAAK,CAAC;AACrB,CAAC;AAED,SAAS,GAAG,CAAC,IAAY,EAAE,KAAa;IACvC,OAAO,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;AAC/C,CAAC;AAED,SAAS,YAAY,CAAC,KAAa;IAClC,IAAI,MAAM,GAAG,GAAG,CAAC;IACjB,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QAC1B,MAAM,IAAI,GAAG,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;QACtC,QAAQ,IAAI,EAAE,CAAC;YACd,KAAK,IAAI;gBACR,MAAM,IAAI,MAAM,CAAC;gBACjB,MAAM;YACP,KAAK,GAAG;gBACP,MAAM,IAAI,KAAK,CAAC;gBAChB,MAAM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AC9D,OAAO,EAAE,OAAuD;SAChE,CAAC,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,OAAgD;QACrD,OAAO,IAAI,cAAc,CAAC,EAAE,GAAG,IAAI,CAAC,IAAI,EAAE,OAAO,EAAE,CAAC,CAAC;IACtD,CAAC;IAED,OAAO,CAAC,YAAsC;QAC7C,OAAO,IAAI,cAAc,CAAC,EAAE,GAAG,IAAI,CAAC,IAAI,EAAE,YAAY,EAAE,CAAC,CAAC;IAC3D,CAAC;IAED,MAAM,CAAC,GAAG,UAAoB;QAC7B,OAAO,IAAI,cAAc,CAAC,EAAE,GAAG,IAAI,CAAC,IAAI,EAAE,gBAAgB,EAAE,UAAU,EAAE,CAAC,CAAC;IAC3E,CAAC;IAED,cAAc,CAAC,GAAG,UAAoB;QACrC,OAAO,IAAI,cAAc,CAAC,EAAE,GAAG,IAAI,CAAC,IAAI,EAAE,wBAAwB,EAAE,UAAU,EAAE,CAAC,CAAC;IACnF,CAAC;IAED,OAAO,CAAC,SAAoD;QAC3D,OAAO,IAAI,cAAc,CAAC,EAAE,GAAG,IAAI,CAAC,IAAI,EAAE,SAAS,EAAE,CAAC,CAAC;IACxD,CAAC;CACD;AAED,MAAM,UAAU,IAAI,CACnB,EAAU;IAEV,OAAO,IAAI,cAAc,CAAa,EAAE,EAAE,EAAE,CAAC,CAAC;AAC/C,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lintai/sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -13,7 +13,8 @@
|
|
|
13
13
|
"url": "https://github.com/bigbizze/lintai/issues"
|
|
14
14
|
},
|
|
15
15
|
"files": [
|
|
16
|
-
"dist"
|
|
16
|
+
"dist",
|
|
17
|
+
"!dist/**/*.test.*"
|
|
17
18
|
],
|
|
18
19
|
"exports": {
|
|
19
20
|
".": {
|
|
@@ -35,6 +36,7 @@
|
|
|
35
36
|
},
|
|
36
37
|
"scripts": {
|
|
37
38
|
"build": "tsc",
|
|
38
|
-
"dev": "tsc --watch"
|
|
39
|
+
"dev": "tsc --watch",
|
|
40
|
+
"test": "node --test 'dist/**/*.test.js'"
|
|
39
41
|
}
|
|
40
42
|
}
|