@opensip-cli/lang-typescript 0.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/LICENSE +202 -0
- package/NOTICE +8 -0
- package/README.md +31 -0
- package/dist/__tests__/adapter.test.d.ts +2 -0
- package/dist/__tests__/adapter.test.d.ts.map +1 -0
- package/dist/__tests__/adapter.test.js +56 -0
- package/dist/__tests__/adapter.test.js.map +1 -0
- package/dist/__tests__/ast-utilities.test.d.ts +2 -0
- package/dist/__tests__/ast-utilities.test.d.ts.map +1 -0
- package/dist/__tests__/ast-utilities.test.js +442 -0
- package/dist/__tests__/ast-utilities.test.js.map +1 -0
- package/dist/__tests__/filter.test.d.ts +2 -0
- package/dist/__tests__/filter.test.d.ts.map +1 -0
- package/dist/__tests__/filter.test.js +183 -0
- package/dist/__tests__/filter.test.js.map +1 -0
- package/dist/__tests__/query.test.d.ts +2 -0
- package/dist/__tests__/query.test.d.ts.map +1 -0
- package/dist/__tests__/query.test.js +76 -0
- package/dist/__tests__/query.test.js.map +1 -0
- package/dist/__tests__/workspace-units.test.d.ts +2 -0
- package/dist/__tests__/workspace-units.test.d.ts.map +1 -0
- package/dist/__tests__/workspace-units.test.js +94 -0
- package/dist/__tests__/workspace-units.test.js.map +1 -0
- package/dist/adapter.d.ts +6 -0
- package/dist/adapter.d.ts.map +1 -0
- package/dist/adapter.js +17 -0
- package/dist/adapter.js.map +1 -0
- package/dist/ast-utilities.d.ts +76 -0
- package/dist/ast-utilities.d.ts.map +1 -0
- package/dist/ast-utilities.js +212 -0
- package/dist/ast-utilities.js.map +1 -0
- package/dist/filter.d.ts +39 -0
- package/dist/filter.d.ts.map +1 -0
- package/dist/filter.js +263 -0
- package/dist/filter.js.map +1 -0
- package/dist/function-scope.d.ts +70 -0
- package/dist/function-scope.d.ts.map +1 -0
- package/dist/function-scope.js +142 -0
- package/dist/function-scope.js.map +1 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +24 -0
- package/dist/index.js.map +1 -0
- package/dist/parse.d.ts +10 -0
- package/dist/parse.d.ts.map +1 -0
- package/dist/parse.js +19 -0
- package/dist/parse.js.map +1 -0
- package/dist/query.d.ts +4 -0
- package/dist/query.d.ts.map +1 -0
- package/dist/query.js +74 -0
- package/dist/query.js.map +1 -0
- package/dist/strip.d.ts +25 -0
- package/dist/strip.d.ts.map +1 -0
- package/dist/strip.js +30 -0
- package/dist/strip.js.map +1 -0
- package/dist/workspace-units.d.ts +19 -0
- package/dist/workspace-units.d.ts.map +1 -0
- package/dist/workspace-units.js +78 -0
- package/dist/workspace-units.js.map +1 -0
- package/package.json +50 -0
package/dist/query.js
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import ts from 'typescript';
|
|
2
|
+
function locationOf(sourceFile, node) {
|
|
3
|
+
const { line, character } = sourceFile.getLineAndCharacterOfPosition(node.getStart(sourceFile));
|
|
4
|
+
return { file: sourceFile.fileName, line: line + 1, column: character };
|
|
5
|
+
}
|
|
6
|
+
function walk(node, visit) {
|
|
7
|
+
visit(node);
|
|
8
|
+
ts.forEachChild(node, (child) => walk(child, visit));
|
|
9
|
+
}
|
|
10
|
+
export const typescriptQuery = {
|
|
11
|
+
findFunctions(tree) {
|
|
12
|
+
const out = [];
|
|
13
|
+
walk(tree, (n) => {
|
|
14
|
+
if (ts.isFunctionDeclaration(n) ||
|
|
15
|
+
ts.isFunctionExpression(n) ||
|
|
16
|
+
ts.isArrowFunction(n) ||
|
|
17
|
+
ts.isMethodDeclaration(n)) {
|
|
18
|
+
const name = n.name?.text ?? null;
|
|
19
|
+
out.push({ name, location: locationOf(tree, n), node: n });
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
return out;
|
|
23
|
+
},
|
|
24
|
+
findImports(tree) {
|
|
25
|
+
const out = [];
|
|
26
|
+
walk(tree, (n) => {
|
|
27
|
+
if (ts.isImportDeclaration(n) && ts.isStringLiteral(n.moduleSpecifier)) {
|
|
28
|
+
const specifier = n.moduleSpecifier.text;
|
|
29
|
+
const names = [];
|
|
30
|
+
const clause = n.importClause;
|
|
31
|
+
if (clause?.name)
|
|
32
|
+
names.push(clause.name.text);
|
|
33
|
+
if (clause?.namedBindings && ts.isNamedImports(clause.namedBindings)) {
|
|
34
|
+
for (const elem of clause.namedBindings.elements)
|
|
35
|
+
names.push(elem.name.text);
|
|
36
|
+
}
|
|
37
|
+
out.push({ specifier, names, location: locationOf(tree, n) });
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
return out;
|
|
41
|
+
},
|
|
42
|
+
findCallsTo(tree, name) {
|
|
43
|
+
const out = [];
|
|
44
|
+
walk(tree, (n) => {
|
|
45
|
+
if (ts.isCallExpression(n)) {
|
|
46
|
+
const expr = n.expression;
|
|
47
|
+
let target = '';
|
|
48
|
+
if (ts.isIdentifier(expr))
|
|
49
|
+
target = expr.text;
|
|
50
|
+
else if (ts.isPropertyAccessExpression(expr))
|
|
51
|
+
target = expr.name.text;
|
|
52
|
+
if (target === name)
|
|
53
|
+
out.push(n);
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
return out;
|
|
57
|
+
},
|
|
58
|
+
findStringLiterals(tree) {
|
|
59
|
+
const out = [];
|
|
60
|
+
walk(tree, (n) => {
|
|
61
|
+
if (ts.isStringLiteralLike(n)) {
|
|
62
|
+
out.push({ value: n.text, location: locationOf(tree, n) });
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
return out;
|
|
66
|
+
},
|
|
67
|
+
getLocation(tree, node) {
|
|
68
|
+
return locationOf(tree, node);
|
|
69
|
+
},
|
|
70
|
+
getText(tree, node) {
|
|
71
|
+
return node.getText(tree);
|
|
72
|
+
},
|
|
73
|
+
};
|
|
74
|
+
//# sourceMappingURL=query.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"query.js","sourceRoot":"","sources":["../src/query.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,M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qBACzC,IAAI,EAAE,CAAC,0BAA0B,CAAC,IAAI,CAAC;oBAAE,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC;gBACtE,IAAI,MAAM,KAAK,IAAI;oBAAE,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;YACnC,CAAC;QACH,CAAC,CAAC,CAAC;QACH,OAAO,GAAG,CAAC;IACb,CAAC;IACD,kBAAkB,CAAC,IAAI;QACrB,MAAM,GAAG,GAA4C,EAAE,CAAC;QACxD,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,EAAE,EAAE;YACf,IAAI,EAAE,CAAC,mBAAmB,CAAC,CAAC,CAAC,EAAE,CAAC;gBAC9B,GAAG,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,IAAI,EAAE,QAAQ,EAAE,UAAU,CAAC,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC;YAC7D,CAAC;QACH,CAAC,CAAC,CAAC;QACH,OAAO,GAAG,CAAC;IACb,CAAC;IACD,WAAW,CAAC,IAAI,EAAE,IAAI;QACpB,OAAO,UAAU,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IAChC,CAAC;IACD,OAAO,CAAC,IAAI,EAAE,IAAI;QAChB,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IAC5B,CAAC;CACF,CAAC"}
|
package/dist/strip.d.ts
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview TypeScript string and comment stripping.
|
|
3
|
+
*
|
|
4
|
+
* Implements the LanguageAdapter contract methods stripStrings/stripComments
|
|
5
|
+
* by re-using the rich filterContent implementation in this package. Both
|
|
6
|
+
* functions preserve byte length so line/column positions remain stable.
|
|
7
|
+
*
|
|
8
|
+
* For the canonical rationale on why a TS-AST-aware stripper coexists
|
|
9
|
+
* with the regex-based language-agnostic strippers in
|
|
10
|
+
* `@opensip-cli/fitness/framework/strip-literals.ts`, see that file's
|
|
11
|
+
* header. The dispatch boundary that selects between the two families
|
|
12
|
+
* is `applyContentFilter` in
|
|
13
|
+
* `@opensip-cli/core/languages/content-filter-dispatch.ts`
|
|
14
|
+
* (audit 2026-05-23 F9).
|
|
15
|
+
*/
|
|
16
|
+
/**
|
|
17
|
+
* Replace string literal content with whitespace of equal length.
|
|
18
|
+
* Quote/backtick delimiters are preserved; only the inside is blanked.
|
|
19
|
+
*/
|
|
20
|
+
export declare function stripStrings(content: string): string;
|
|
21
|
+
/**
|
|
22
|
+
* Replace string literals AND comments with whitespace of equal length.
|
|
23
|
+
*/
|
|
24
|
+
export declare function stripComments(content: string): string;
|
|
25
|
+
//# sourceMappingURL=strip.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"strip.d.ts","sourceRoot":"","sources":["../src/strip.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAIH;;;GAGG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAEpD;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAErD"}
|
package/dist/strip.js
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview TypeScript string and comment stripping.
|
|
3
|
+
*
|
|
4
|
+
* Implements the LanguageAdapter contract methods stripStrings/stripComments
|
|
5
|
+
* by re-using the rich filterContent implementation in this package. Both
|
|
6
|
+
* functions preserve byte length so line/column positions remain stable.
|
|
7
|
+
*
|
|
8
|
+
* For the canonical rationale on why a TS-AST-aware stripper coexists
|
|
9
|
+
* with the regex-based language-agnostic strippers in
|
|
10
|
+
* `@opensip-cli/fitness/framework/strip-literals.ts`, see that file's
|
|
11
|
+
* header. The dispatch boundary that selects between the two families
|
|
12
|
+
* is `applyContentFilter` in
|
|
13
|
+
* `@opensip-cli/core/languages/content-filter-dispatch.ts`
|
|
14
|
+
* (audit 2026-05-23 F9).
|
|
15
|
+
*/
|
|
16
|
+
import { filterContent } from './filter.js';
|
|
17
|
+
/**
|
|
18
|
+
* Replace string literal content with whitespace of equal length.
|
|
19
|
+
* Quote/backtick delimiters are preserved; only the inside is blanked.
|
|
20
|
+
*/
|
|
21
|
+
export function stripStrings(content) {
|
|
22
|
+
return filterContent(content).code;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Replace string literals AND comments with whitespace of equal length.
|
|
26
|
+
*/
|
|
27
|
+
export function stripComments(content) {
|
|
28
|
+
return filterContent(content).codeNoComments;
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=strip.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"strip.js","sourceRoot":"","sources":["../src/strip.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAE5C;;;GAGG;AACH,MAAM,UAAU,YAAY,CAAC,OAAe;IAC1C,OAAO,aAAa,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC;AACrC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,aAAa,CAAC,OAAe;IAC3C,OAAO,aAAa,CAAC,OAAO,CAAC,CAAC,cAAc,CAAC;AAC/C,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { WorkspaceUnit } from '@opensip-cli/core';
|
|
2
|
+
/**
|
|
3
|
+
* Walk <rootDir>/packages/** for directories containing tsconfig.json.
|
|
4
|
+
* Each match becomes a WorkspaceUnit. Behavior matches the legacy
|
|
5
|
+
* `discoverWorkspacePackages` in graph's scope.ts which this replaces.
|
|
6
|
+
*
|
|
7
|
+
* Returns absolute paths, sorted lexicographically.
|
|
8
|
+
*
|
|
9
|
+
* The unit `id` is the unit's path RELATIVE to <rootDir>/packages, in POSIX
|
|
10
|
+
* form (e.g. `fitness/engine`, `graph/engine`, `core`). It must be unique and
|
|
11
|
+
* stable: a bare `basename(dir)` collapses nested packages that share a leaf
|
|
12
|
+
* name (this monorepo has `fitness/engine`, `graph/engine`, and
|
|
13
|
+
* `simulation/engine` — three distinct packages all named `engine`). The id is
|
|
14
|
+
* the shard id (graph's per-shard fragment-cache PRIMARY KEY), so a collision
|
|
15
|
+
* silently overwrites cache rows and breaks build determinism. The
|
|
16
|
+
* root-relative path restores a 1:1 id↔unit mapping.
|
|
17
|
+
*/
|
|
18
|
+
export declare function discoverTypescriptWorkspaceUnits(rootDir: string): Promise<readonly WorkspaceUnit[]>;
|
|
19
|
+
//# sourceMappingURL=workspace-units.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workspace-units.d.ts","sourceRoot":"","sources":["../src/workspace-units.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAKvD;;;;;;;;;;;;;;;GAeG;AAEH,wBAAsB,gCAAgC,CACpD,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,SAAS,aAAa,EAAE,CAAC,CAiCnC"}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
// @fitness-ignore-file error-handling-quality -- safeIsDir/walk helpers for the workspace-units scan: statSync exception → "not a directory", readdirSync exception → "unreadable subdir, skip"; failure IS the function contract in each catch (already marked v8-ignore at each site as defensive/unreachable on real input).
|
|
2
|
+
// @fitness-ignore-file detached-promises -- `walk` is a synchronous filesystem walk function (declared with `function`, returns void); heuristic flags it because it's invoked inside an async-returning enclosing function.
|
|
3
|
+
import { existsSync, readdirSync, statSync } from 'node:fs';
|
|
4
|
+
import { join, relative, resolve, sep } from 'node:path';
|
|
5
|
+
const PACKAGES_SEARCH_ROOT = 'packages';
|
|
6
|
+
const SEARCH_MAX_DEPTH = 3;
|
|
7
|
+
/**
|
|
8
|
+
* Walk <rootDir>/packages/** for directories containing tsconfig.json.
|
|
9
|
+
* Each match becomes a WorkspaceUnit. Behavior matches the legacy
|
|
10
|
+
* `discoverWorkspacePackages` in graph's scope.ts which this replaces.
|
|
11
|
+
*
|
|
12
|
+
* Returns absolute paths, sorted lexicographically.
|
|
13
|
+
*
|
|
14
|
+
* The unit `id` is the unit's path RELATIVE to <rootDir>/packages, in POSIX
|
|
15
|
+
* form (e.g. `fitness/engine`, `graph/engine`, `core`). It must be unique and
|
|
16
|
+
* stable: a bare `basename(dir)` collapses nested packages that share a leaf
|
|
17
|
+
* name (this monorepo has `fitness/engine`, `graph/engine`, and
|
|
18
|
+
* `simulation/engine` — three distinct packages all named `engine`). The id is
|
|
19
|
+
* the shard id (graph's per-shard fragment-cache PRIMARY KEY), so a collision
|
|
20
|
+
* silently overwrites cache rows and breaks build determinism. The
|
|
21
|
+
* root-relative path restores a 1:1 id↔unit mapping.
|
|
22
|
+
*/
|
|
23
|
+
// eslint-disable-next-line @typescript-eslint/require-await
|
|
24
|
+
export async function discoverTypescriptWorkspaceUnits(rootDir) {
|
|
25
|
+
const root = resolve(rootDir, PACKAGES_SEARCH_ROOT);
|
|
26
|
+
if (!existsSync(root) || !safeIsDir(root))
|
|
27
|
+
return [];
|
|
28
|
+
const out = [];
|
|
29
|
+
walk(root, 0);
|
|
30
|
+
out.sort((a, b) => a.rootDir.localeCompare(b.rootDir));
|
|
31
|
+
return out;
|
|
32
|
+
function walk(dir, depth) {
|
|
33
|
+
if (depth > SEARCH_MAX_DEPTH)
|
|
34
|
+
return;
|
|
35
|
+
const tsconfigPath = join(dir, 'tsconfig.json');
|
|
36
|
+
if (existsSync(tsconfigPath)) {
|
|
37
|
+
out.push({
|
|
38
|
+
id: unitId(root, dir),
|
|
39
|
+
rootDir: dir,
|
|
40
|
+
configPath: tsconfigPath,
|
|
41
|
+
});
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
let entries;
|
|
45
|
+
try {
|
|
46
|
+
entries = readdirSync(dir);
|
|
47
|
+
}
|
|
48
|
+
catch {
|
|
49
|
+
/* v8 ignore next */
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
for (const entry of entries) {
|
|
53
|
+
if (entry === 'node_modules' || entry === 'dist' || entry === 'build')
|
|
54
|
+
continue;
|
|
55
|
+
const sub = join(dir, entry);
|
|
56
|
+
if (!safeIsDir(sub))
|
|
57
|
+
continue;
|
|
58
|
+
walk(sub, depth + 1);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Derive a unique, stable unit id: the directory's path relative to the
|
|
64
|
+
* packages root, normalized to POSIX separators (so ids are identical on
|
|
65
|
+
* Windows and POSIX). E.g. `<root>/packages/fitness/engine` → `fitness/engine`.
|
|
66
|
+
*/
|
|
67
|
+
function unitId(packagesRoot, dir) {
|
|
68
|
+
return relative(packagesRoot, dir).split(sep).join('/');
|
|
69
|
+
}
|
|
70
|
+
function safeIsDir(p) {
|
|
71
|
+
try {
|
|
72
|
+
return statSync(p).isDirectory();
|
|
73
|
+
}
|
|
74
|
+
catch {
|
|
75
|
+
return false;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
//# sourceMappingURL=workspace-units.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workspace-units.js","sourceRoot":"","sources":["../src/workspace-units.ts"],"names":[],"mappings":"AAAA,gUAAgU;AAChU,6NAA6N;AAC7N,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAC5D,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAIzD,MAAM,oBAAoB,GAAG,UAAU,CAAC;AACxC,MAAM,gBAAgB,GAAG,CAAC,CAAC;AAE3B;;;;;;;;;;;;;;;GAeG;AACH,4DAA4D;AAC5D,MAAM,CAAC,KAAK,UAAU,gCAAgC,CACpD,OAAe;IAEf,MAAM,IAAI,GAAG,OAAO,CAAC,OAAO,EAAE,oBAAoB,CAAC,CAAC;IACpD,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H,CAAC;AAED;;;;GAIG;AACH,SAAS,MAAM,CAAC,YAAoB,EAAE,GAAW;IAC/C,OAAO,QAAQ,CAAC,YAAY,EAAE,GAAG,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC1D,CAAC;AAED,SAAS,SAAS,CAAC,CAAS;IAC1B,IAAI,CAAC;QACH,OAAO,QAAQ,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC;IACnC,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@opensip-cli/lang-typescript",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"license": "Apache-2.0",
|
|
5
|
+
"description": "TypeScript/JavaScript language adapter for opensip-cli",
|
|
6
|
+
"keywords": [
|
|
7
|
+
"opensip-cli",
|
|
8
|
+
"static-analysis",
|
|
9
|
+
"code-quality",
|
|
10
|
+
"parser",
|
|
11
|
+
"ast",
|
|
12
|
+
"tree-sitter",
|
|
13
|
+
"typescript",
|
|
14
|
+
"javascript"
|
|
15
|
+
],
|
|
16
|
+
"repository": {
|
|
17
|
+
"type": "git",
|
|
18
|
+
"url": "https://github.com/opensip-ai/opensip-cli.git",
|
|
19
|
+
"directory": "packages/languages/lang-typescript"
|
|
20
|
+
},
|
|
21
|
+
"homepage": "https://github.com/opensip-ai/opensip-cli",
|
|
22
|
+
"bugs": {
|
|
23
|
+
"url": "https://github.com/opensip-ai/opensip-cli/issues"
|
|
24
|
+
},
|
|
25
|
+
"type": "module",
|
|
26
|
+
"main": "./dist/index.js",
|
|
27
|
+
"types": "./dist/index.d.ts",
|
|
28
|
+
"exports": {
|
|
29
|
+
".": "./dist/index.js"
|
|
30
|
+
},
|
|
31
|
+
"files": [
|
|
32
|
+
"dist",
|
|
33
|
+
"LICENSE",
|
|
34
|
+
"NOTICE"
|
|
35
|
+
],
|
|
36
|
+
"dependencies": {
|
|
37
|
+
"typescript": "~6.0.3",
|
|
38
|
+
"@opensip-cli/core": "0.1.0"
|
|
39
|
+
},
|
|
40
|
+
"devDependencies": {
|
|
41
|
+
"@types/node": "^24.13.2",
|
|
42
|
+
"vitest": "^4.1.8"
|
|
43
|
+
},
|
|
44
|
+
"scripts": {
|
|
45
|
+
"build": "tsc",
|
|
46
|
+
"test": "vitest run --passWithNoTests",
|
|
47
|
+
"typecheck": "tsc --noEmit",
|
|
48
|
+
"clean": "rm -rf dist"
|
|
49
|
+
}
|
|
50
|
+
}
|