packtory 0.0.66 → 0.0.68
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/checks/check-runner.d.ts +6 -0
- package/checks/check-runner.d.ts.map +1 -0
- package/checks/check-runner.js +7 -6
- package/checks/check-runner.js.map +1 -1
- package/checks/rule.d.ts +5 -0
- package/checks/rule.d.ts.map +1 -0
- package/checks/rules/max-bundle-size.d.ts +3 -0
- package/checks/rules/max-bundle-size.d.ts.map +1 -0
- package/checks/rules/no-dev-dependency-imports.d.ts +4 -0
- package/checks/rules/no-dev-dependency-imports.d.ts.map +1 -0
- package/checks/rules/no-duplicated-files.d.ts +4 -0
- package/checks/rules/no-duplicated-files.d.ts.map +1 -0
- package/checks/rules/no-side-effects.d.ts +4 -0
- package/checks/rules/no-side-effects.d.ts.map +1 -0
- package/checks/rules/no-unused-bundle-dependencies.d.ts +4 -0
- package/checks/rules/no-unused-bundle-dependencies.d.ts.map +1 -0
- package/checks/rules/registry.d.ts +9 -0
- package/checks/rules/registry.d.ts.map +1 -0
- package/checks/rules/registry.js +13 -11
- package/checks/rules/registry.js.map +1 -1
- package/checks/rules/required-files.d.ts +4 -0
- package/checks/rules/required-files.d.ts.map +1 -0
- package/checks/rules/type-script-declaration-integrity.d.ts +3 -0
- package/checks/rules/type-script-declaration-integrity.d.ts.map +1 -0
- package/checks/rules/type-script-declaration-integrity.js +58 -0
- package/checks/rules/type-script-declaration-integrity.js.map +1 -0
- package/checks/rules/type-script-declaration-paths.js +56 -0
- package/checks/rules/type-script-declaration-paths.js.map +1 -0
- package/checks/rules/type-script-declaration-project.d.ts +2 -0
- package/checks/rules/type-script-declaration-project.d.ts.map +1 -0
- package/checks/rules/type-script-declaration-project.js +104 -0
- package/checks/rules/type-script-declaration-project.js.map +1 -0
- package/checks/rules/type-script-declaration-reachability.js +39 -0
- package/checks/rules/type-script-declaration-reachability.js.map +1 -0
- package/checks/rules/type-script-declaration-roots.js +31 -0
- package/checks/rules/type-script-declaration-roots.js.map +1 -0
- package/checks/rules/type-script-integrity.d.ts +6 -0
- package/checks/rules/type-script-integrity.d.ts.map +1 -0
- package/checks/rules/type-script-integrity.js +54 -0
- package/checks/rules/type-script-integrity.js.map +1 -0
- package/checks/rules/type-script-package-resolution.d.ts +5 -0
- package/checks/rules/type-script-package-resolution.d.ts.map +1 -0
- package/checks/rules/type-script-package-resolution.js +43 -0
- package/checks/rules/type-script-package-resolution.js.map +1 -0
- package/checks/rules/type-script-resolution-summary.js +54 -0
- package/checks/rules/type-script-resolution-summary.js.map +1 -0
- package/checks/rules/unique-target-paths.d.ts +4 -0
- package/checks/rules/unique-target-paths.d.ts.map +1 -0
- package/common/declaration-companion-paths.js +25 -0
- package/common/declaration-companion-paths.js.map +1 -0
- package/common/package-layout.js +6 -0
- package/common/package-layout.js.map +1 -1
- package/config/checks-schema.d.ts +4 -8
- package/config/checks-schema.d.ts.map +1 -1
- package/config/checks-schema.js +3 -3
- package/config/checks-schema.js.map +1 -1
- package/dead-code-eliminator/load-bundle.js +0 -3
- package/dead-code-eliminator/load-bundle.js.map +1 -1
- package/dead-code-eliminator/reachability/local-seed-gathering.js +2 -1
- package/dead-code-eliminator/reachability/local-seed-gathering.js.map +1 -1
- package/linker/linker.d.ts.map +1 -1
- package/linker/linker.js +24 -1
- package/linker/linker.js.map +1 -1
- package/linker/replacement-lookup.js +1 -1
- package/linker/replacement-lookup.js.map +1 -1
- package/package-surface/substitution-exports.js +37 -19
- package/package-surface/substitution-exports.js.map +1 -1
- package/package.json +1 -1
- package/packages/packtory.composition.js +31 -0
- package/packages/packtory.composition.js.map +1 -1
- package/packtory/packtory-resolve.js.map +1 -1
- package/packtory/packtory.d.ts +1 -0
- package/packtory/packtory.d.ts.map +1 -1
- package/packtory/packtory.js.map +1 -1
- package/packtory/resolved-package.d.ts +1 -0
- package/packtory/resolved-package.d.ts.map +1 -1
- package/packtory/resolved-package.js +28 -11
- package/packtory/resolved-package.js.map +1 -1
- package/report/release-diff/file-set-diff.d.ts +1 -1
- package/report/release-diff/file-set-diff.d.ts.map +1 -1
- package/report/release-diff/file-set-diff.js +16 -2
- package/report/release-diff/file-set-diff.js.map +1 -1
- package/resource-resolver/dependency-resolution-walker.js +90 -18
- package/resource-resolver/dependency-resolution-walker.js.map +1 -1
- package/resource-resolver/resource-resolver.js +1 -1
- package/resource-resolver/resource-resolver.js.map +1 -1
- package/sbom.cdx.json +5 -5
- package/checks/rules/are-the-types-wrong.js +0 -154
- package/checks/rules/are-the-types-wrong.js.map +0 -1
- package/file-manager/file-description-by-path.js +0 -8
- package/file-manager/file-description-by-path.js.map +0 -1
- package/report/release-diff/file-hunks.js +0 -10
- package/report/release-diff/file-hunks.js.map +0 -1
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { ChecksSettings, PackageChecksSettings, PackageConfigsByName } from '../config/config.ts';
|
|
2
|
+
import type { AnalyzedBundle } from '../dead-code-eliminator/analyzed-bundle.ts';
|
|
3
|
+
import type { PublishedPackageWithManifest } from '../published-package/published-package.ts';
|
|
4
|
+
import type { AllCheckRules } from './rules/registry.ts';
|
|
5
|
+
export {};
|
|
6
|
+
//# sourceMappingURL=check-runner.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"check-runner.d.ts","sourceRoot":"","sources":["../../../../source/checks/check-runner.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,qBAAqB,EAAE,oBAAoB,EAAE,MAAM,qBAAqB;AACtG,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,4CAA4C;AAChF,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,2CAA2C;AAC7F,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB"}
|
package/checks/check-runner.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
export function createCheckRunner(dependencies) {
|
|
2
|
+
return async function runChecks(params) {
|
|
3
|
+
const issues = await Promise.all(dependencies.rules.map(async function (rule) {
|
|
4
|
+
return await rule.run(params);
|
|
5
|
+
}));
|
|
6
|
+
return issues.flat();
|
|
7
|
+
};
|
|
7
8
|
}
|
|
8
9
|
//# sourceMappingURL=check-runner.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"check-runner.js","sourceRoot":"","sources":["../../../../source/checks/check-runner.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"check-runner.js","sourceRoot":"","sources":["../../../../source/checks/check-runner.ts"],"names":[],"mappings":"AAmBA,MAAM,UAAU,iBAAiB,CAAC,YAAqC;IACnE,OAAO,KAAK,UAAU,SAAS,CAAC,MAAM;QAClC,MAAM,MAAM,GAAG,MAAM,OAAO,CAAC,GAAG,CAC5B,YAAY,CAAC,KAAK,CAAC,GAAG,CAAC,KAAK,WAAW,IAAI;YACvC,OAAO,MAAM,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;QAClC,CAAC,CAAC,CACL,CAAC;QACF,OAAO,MAAM,CAAC,IAAI,EAAE,CAAC;IACzB,CAAC,CAAC;AACN,CAAC"}
|
package/checks/rule.d.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { z, type ZodMiniType } from 'zod/mini';
|
|
2
|
+
import type { AnalyzedBundle } from '../dead-code-eliminator/analyzed-bundle.ts';
|
|
3
|
+
import type { PublishedPackageWithManifest } from '../published-package/published-package.ts';
|
|
4
|
+
export {};
|
|
5
|
+
//# sourceMappingURL=rule.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rule.d.ts","sourceRoot":"","sources":["../../../../source/checks/rule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,KAAK,WAAW,EAAE,MAAM,UAAU;AAE9C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,4CAA4C;AAChF,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,2CAA2C"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"max-bundle-size.d.ts","sourceRoot":"","sources":["../../../../../source/checks/rules/max-bundle-size.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,mBAAmB,EAAiB,MAAM,YAAY"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"no-dev-dependency-imports.d.ts","sourceRoot":"","sources":["../../../../../source/checks/rules/no-dev-dependency-imports.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,UAAU;AAEjC,OAAO,EACH,KAAK,mBAAmB,EACxB,qBAAqB,EACrB,uBAAuB,EAG1B,MAAM,YAAY"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"no-duplicated-files.d.ts","sourceRoot":"","sources":["../../../../../source/checks/rules/no-duplicated-files.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,UAAU;AAEjC,OAAO,EACH,KAAK,mBAAmB,EACxB,yBAAyB,EACzB,6BAA6B,EAEhC,MAAM,YAAY"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"no-side-effects.d.ts","sourceRoot":"","sources":["../../../../../source/checks/rules/no-side-effects.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,UAAU;AAEjC,OAAO,EAGH,KAAK,mBAAmB,EAE3B,MAAM,YAAY"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"no-unused-bundle-dependencies.d.ts","sourceRoot":"","sources":["../../../../../source/checks/rules/no-unused-bundle-dependencies.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,UAAU;AAGjC,OAAO,EACH,qBAAqB,EACrB,uBAAuB,EACvB,KAAK,mBAAmB,EAG3B,MAAM,YAAY"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { maxBundleSizeRule } from './max-bundle-size.ts';
|
|
2
|
+
import { noDevDependencyImportsRule } from './no-dev-dependency-imports.ts';
|
|
3
|
+
import { noDuplicatedFilesRule } from './no-duplicated-files.ts';
|
|
4
|
+
import { noSideEffectsRule } from './no-side-effects.ts';
|
|
5
|
+
import { noUnusedBundleDependenciesRule } from './no-unused-bundle-dependencies.ts';
|
|
6
|
+
import { requiredFilesRule } from './required-files.ts';
|
|
7
|
+
import { type TypeScriptIntegrityDependencies, type TypeScriptIntegrityRule } from './type-script-integrity.ts';
|
|
8
|
+
import { uniqueTargetPathsRule } from './unique-target-paths.ts';
|
|
9
|
+
//# sourceMappingURL=registry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../../../../source/checks/rules/registry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB;AACxD,OAAO,EAAE,0BAA0B,EAAE,MAAM,gCAAgC;AAC3E,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B;AAChE,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB;AACxD,OAAO,EAAE,8BAA8B,EAAE,MAAM,oCAAoC;AACnF,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB;AACvD,OAAO,EAEH,KAAK,+BAA+B,EACpC,KAAK,uBAAuB,EAC/B,MAAM,4BAA4B;AACnC,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B"}
|
package/checks/rules/registry.js
CHANGED
|
@@ -1,19 +1,21 @@
|
|
|
1
|
-
import { areTheTypesWrongRule } from "./are-the-types-wrong.js";
|
|
2
1
|
import { maxBundleSizeRule } from "./max-bundle-size.js";
|
|
3
2
|
import { noDevDependencyImportsRule } from "./no-dev-dependency-imports.js";
|
|
4
3
|
import { noDuplicatedFilesRule } from "./no-duplicated-files.js";
|
|
5
4
|
import { noSideEffectsRule } from "./no-side-effects.js";
|
|
6
5
|
import { noUnusedBundleDependenciesRule } from "./no-unused-bundle-dependencies.js";
|
|
7
6
|
import { requiredFilesRule } from "./required-files.js";
|
|
7
|
+
import { createTypeScriptIntegrityRule } from "./type-script-integrity.js";
|
|
8
8
|
import { uniqueTargetPathsRule } from "./unique-target-paths.js";
|
|
9
|
-
export
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
9
|
+
export function createAllRules(dependencies) {
|
|
10
|
+
return [
|
|
11
|
+
createTypeScriptIntegrityRule(dependencies),
|
|
12
|
+
noDuplicatedFilesRule,
|
|
13
|
+
requiredFilesRule,
|
|
14
|
+
maxBundleSizeRule,
|
|
15
|
+
noUnusedBundleDependenciesRule,
|
|
16
|
+
noDevDependencyImportsRule,
|
|
17
|
+
uniqueTargetPathsRule,
|
|
18
|
+
noSideEffectsRule
|
|
19
|
+
];
|
|
20
|
+
}
|
|
19
21
|
//# sourceMappingURL=registry.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registry.js","sourceRoot":"","sources":["../../../../../source/checks/rules/registry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"registry.js","sourceRoot":"","sources":["../../../../../source/checks/rules/registry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,EAAE,0BAA0B,EAAE,MAAM,gCAAgC,CAAC;AAC5E,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,EAAE,8BAA8B,EAAE,MAAM,oCAAoC,CAAC;AACpF,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EACH,6BAA6B,EAGhC,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AAejE,MAAM,UAAU,cAAc,CAAC,YAAmC;IAC9D,OAAO;QACH,6BAA6B,CAAC,YAAY,CAAC;QAC3C,qBAAqB;QACrB,iBAAiB;QACjB,iBAAiB;QACjB,8BAA8B;QAC9B,0BAA0B;QAC1B,qBAAqB;QACrB,iBAAiB;KACpB,CAAC;AACN,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"required-files.d.ts","sourceRoot":"","sources":["../../../../../source/checks/rules/required-files.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,UAAU;AAG5B,OAAO,KAAK,EAAE,mBAAmB,EAAiB,MAAM,YAAY"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"type-script-declaration-integrity.d.ts","sourceRoot":"","sources":["../../../../../source/checks/rules/type-script-declaration-integrity.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,8CAA8C;AAEhG,OAAO,KAAK,EAGR,0BAA0B,EAE7B,MAAM,sCAAsC"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { isDeclarationPath } from "./type-script-declaration-paths.js";
|
|
2
|
+
import { reachableDeclarationPaths } from "./type-script-declaration-reachability.js";
|
|
3
|
+
import { declarationRootsFromManifest } from "./type-script-declaration-roots.js";
|
|
4
|
+
function collectPackageFiles(publishedPackage) {
|
|
5
|
+
return [
|
|
6
|
+
{
|
|
7
|
+
filePath: publishedPackage.manifestFile.filePath,
|
|
8
|
+
content: publishedPackage.manifestFile.content
|
|
9
|
+
},
|
|
10
|
+
...publishedPackage.contents.map(function (entry) {
|
|
11
|
+
return {
|
|
12
|
+
filePath: entry.fileDescription.targetFilePath,
|
|
13
|
+
content: entry.fileDescription.content
|
|
14
|
+
};
|
|
15
|
+
})
|
|
16
|
+
];
|
|
17
|
+
}
|
|
18
|
+
function collectDeclarationPaths(packageFiles) {
|
|
19
|
+
return new Set(packageFiles
|
|
20
|
+
.map(function (packageFile) {
|
|
21
|
+
return packageFile.filePath;
|
|
22
|
+
})
|
|
23
|
+
.filter(isDeclarationPath));
|
|
24
|
+
}
|
|
25
|
+
function checkedDeclarationPaths(project, declarationPaths, rootPaths, declarationMode) {
|
|
26
|
+
if (declarationMode === 'all') {
|
|
27
|
+
return declarationPaths;
|
|
28
|
+
}
|
|
29
|
+
return reachableDeclarationPaths({
|
|
30
|
+
declarationPaths,
|
|
31
|
+
rootPaths,
|
|
32
|
+
moduleSpecifiersOf: project.moduleSpecifiersOf
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
function formatDeclarationDiagnostic(packageName, modeLabel, diagnostic) {
|
|
36
|
+
return (`Package "${packageName}" failed TypeScript integrity in ${modeLabel}: ` +
|
|
37
|
+
`${diagnostic.declarationPath}:${diagnostic.line} TS${diagnostic.code}: ${diagnostic.message}`);
|
|
38
|
+
}
|
|
39
|
+
export function createDeclarationIntegritySummarizer(dependencies) {
|
|
40
|
+
const { createDeclarationProjects } = dependencies;
|
|
41
|
+
return function summarizeDeclarationIntegrity(packageName, publishedPackage, declarationMode) {
|
|
42
|
+
const packageFiles = collectPackageFiles(publishedPackage);
|
|
43
|
+
const declarationPaths = collectDeclarationPaths(packageFiles);
|
|
44
|
+
const rootPaths = declarationRootsFromManifest(publishedPackage.manifestFile.content);
|
|
45
|
+
return createDeclarationProjects(packageName, packageFiles).flatMap(function (project) {
|
|
46
|
+
const checkedPaths = checkedDeclarationPaths(project, declarationPaths, rootPaths, declarationMode);
|
|
47
|
+
return project
|
|
48
|
+
.listDiagnostics()
|
|
49
|
+
.filter(function (diagnostic) {
|
|
50
|
+
return checkedPaths.has(diagnostic.declarationPath);
|
|
51
|
+
})
|
|
52
|
+
.map(function (diagnostic) {
|
|
53
|
+
return formatDeclarationDiagnostic(packageName, project.modeLabel, diagnostic);
|
|
54
|
+
});
|
|
55
|
+
});
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
//# sourceMappingURL=type-script-declaration-integrity.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"type-script-declaration-integrity.js","sourceRoot":"","sources":["../../../../../source/checks/rules/type-script-declaration-integrity.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,oCAAoC,CAAC;AAOvE,OAAO,EAAE,yBAAyB,EAAE,MAAM,2CAA2C,CAAC;AACtF,OAAO,EAAE,4BAA4B,EAAE,MAAM,oCAAoC,CAAC;AAclF,SAAS,mBAAmB,CAAC,gBAAwD;IACjF,OAAO;QACH;YACI,QAAQ,EAAE,gBAAgB,CAAC,YAAY,CAAC,QAAQ;YAChD,OAAO,EAAE,gBAAgB,CAAC,YAAY,CAAC,OAAO;SACjD;QACD,GAAG,gBAAgB,CAAC,QAAQ,CAAC,GAAG,CAAC,UAAU,KAAK;YAC5C,OAAO;gBACH,QAAQ,EAAE,KAAK,CAAC,eAAe,CAAC,cAAc;gBAC9C,OAAO,EAAE,KAAK,CAAC,eAAe,CAAC,OAAO;aACzC,CAAC;QACN,CAAC,CAAC;KACL,CAAC;AACN,CAAC;AAED,SAAS,uBAAuB,CAAC,YAAoC;IACjE,OAAO,IAAI,GAAG,CACV,YAAY;SACP,GAAG,CAAC,UAAU,WAAW;QACtB,OAAO,WAAW,CAAC,QAAQ,CAAC;IAChC,CAAC,CAAC;SACD,MAAM,CAAC,iBAAiB,CAAC,CACjC,CAAC;AACN,CAAC;AAED,SAAS,uBAAuB,CAC5B,OAA2B,EAC3B,gBAAqC,EACrC,SAA8B,EAC9B,eAAgC;IAEhC,IAAI,eAAe,KAAK,KAAK,EAAE,CAAC;QAC5B,OAAO,gBAAgB,CAAC;IAC5B,CAAC;IAED,OAAO,yBAAyB,CAAC;QAC7B,gBAAgB;QAChB,SAAS;QACT,kBAAkB,EAAE,OAAO,CAAC,kBA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.ts', '.d.mts', '.d.cts'];
|
|
3
|
+
const knownDeclarationExtensions = [
|
|
4
|
+
{
|
|
5
|
+
javascriptExtension: '.js',
|
|
6
|
+
declarationExtensions: ['.d.ts']
|
|
7
|
+
},
|
|
8
|
+
{
|
|
9
|
+
javascriptExtension: '.mjs',
|
|
10
|
+
declarationExtensions: ['.d.mts', '.d.ts']
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
javascriptExtension: '.cjs',
|
|
14
|
+
declarationExtensions: ['.d.cts', '.d.ts']
|
|
15
|
+
}
|
|
16
|
+
];
|
|
17
|
+
export function isDeclarationPath(filePath) {
|
|
18
|
+
return declarationExtensions.some(function (extension) {
|
|
19
|
+
return filePath.endsWith(extension);
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
export function isRelativeSpecifier(specifier) {
|
|
23
|
+
return specifier.startsWith('./') || specifier.startsWith('../');
|
|
24
|
+
}
|
|
25
|
+
function stripJavascriptExtension(resolvedPath, javascriptExtension) {
|
|
26
|
+
return resolvedPath.slice(0, -javascriptExtension.length);
|
|
27
|
+
}
|
|
28
|
+
function declarationCandidatesForKnownExtension(resolvedPath) {
|
|
29
|
+
const knownExtension = knownDeclarationExtensions.find(function (candidate) {
|
|
30
|
+
return resolvedPath.endsWith(candidate.javascriptExtension);
|
|
31
|
+
});
|
|
32
|
+
if (knownExtension === undefined) {
|
|
33
|
+
return undefined;
|
|
34
|
+
}
|
|
35
|
+
const basePath = stripJavascriptExtension(resolvedPath, knownExtension.javascriptExtension);
|
|
36
|
+
return knownExtension.declarationExtensions.map(function (declarationExtension) {
|
|
37
|
+
return `${basePath}${declarationExtension}`;
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
function declarationCandidatesForExtensionlessPath(resolvedPath) {
|
|
41
|
+
return [
|
|
42
|
+
resolvedPath,
|
|
43
|
+
...declarationExtensions.map(function (declarationExtension) {
|
|
44
|
+
return `${resolvedPath}${declarationExtension}`;
|
|
45
|
+
}),
|
|
46
|
+
...declarationExtensions.map(function (declarationExtension) {
|
|
47
|
+
return `${resolvedPath}/index${declarationExtension}`;
|
|
48
|
+
})
|
|
49
|
+
];
|
|
50
|
+
}
|
|
51
|
+
export function declarationCandidatesFor(importerPath, specifier) {
|
|
52
|
+
const resolvedPath = path.posix.normalize(path.posix.join(path.posix.dirname(importerPath), specifier));
|
|
53
|
+
return declarationCandidatesForKnownExtension(resolvedPath) ??
|
|
54
|
+
declarationCandidatesForExtensionlessPath(resolvedPath);
|
|
55
|
+
}
|
|
56
|
+
//# sourceMappingURL=type-script-declaration-paths.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"type-script-declaration-paths.js","sourceRoot":"","sources":["../../../../../source/checks/rules/type-script-declaration-paths.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAO7B,MAAM,qBAAqB,GAAG,CAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,CAAW,CAAC;AAEvE,MAAM,0BAA0B,GAAyC;IACrE;QACI,mBAAmB,EAAE,KAAK;QAC1B,qBAAqB,EAAE,CAAE,OAAO,CAAE;KACrC;IACD;QACI,mBAAmB,EAAE,MAAM;QAC3B,qBAAqB,EAAE,CAAE,QAAQ,EAAE,OAAO,CAAE;KAC/C;IACD;QACI,mBAAmB,EAAE,MAAM;QAC3B,qBAAqB,EAAE,CAAE,QAAQ,EAAE,OAAO,CAAE;KAC/C;CACJ,CAAC;AAEF,MAAM,UAAU,iBAAiB,CAAC,QAAgB;IAC9C,OAAO,qBAAqB,CAAC,IAAI,CAAC,UAAU,SAAS;QACjD,OAAO,QAAQ,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC;IACxC,CAAC,CAAC,CAAC;AACP,CAAC;AAED,MAAM,UAAU,mBAAmB,CAAC,SAAiB;IACjD,OAAO,SAAS,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,SAAS,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;AACrE,CA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AY,CAAC;QACvD,yCAAyC,CAAC,YAAY,CAAC,CAAC;AAChE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"type-script-declaration-project.d.ts","sourceRoot":"","sources":["../../../../../source/checks/rules/type-script-declaration-project.ts"],"names":[],"mappings":"AACA,OAAO,EAOH,KAAK,cAAc,EACnB,KAAK,OAAO,IAAI,cAAc,EAEjC,MAAM,UAAU"}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import path from 'node:path';
|
|
2
|
+
import { ModuleKind, ModuleResolutionKind, ScriptKind, ScriptTarget, ts as typescript } from 'ts-morph';
|
|
3
|
+
function declarationCompilerModes() {
|
|
4
|
+
return [
|
|
5
|
+
{
|
|
6
|
+
label: 'node16-esm',
|
|
7
|
+
module: ModuleKind.Node16,
|
|
8
|
+
moduleResolution: ModuleResolutionKind.Node16
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
label: 'bundler',
|
|
12
|
+
module: ModuleKind.ESNext,
|
|
13
|
+
moduleResolution: ModuleResolutionKind.Bundler
|
|
14
|
+
}
|
|
15
|
+
];
|
|
16
|
+
}
|
|
17
|
+
function moduleSpecifiersIn(sourceFile) {
|
|
18
|
+
return [
|
|
19
|
+
...sourceFile.getImportDeclarations(),
|
|
20
|
+
...sourceFile.getExportDeclarations()
|
|
21
|
+
]
|
|
22
|
+
.map(function (declaration) {
|
|
23
|
+
return declaration.getModuleSpecifierValue();
|
|
24
|
+
})
|
|
25
|
+
.filter(function (specifier) {
|
|
26
|
+
return specifier !== undefined;
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
function declarationProjectPackageFolder(baseFolder, packageName) {
|
|
30
|
+
return path.join(baseFolder, '.packtory-type-integrity', 'node_modules', packageName);
|
|
31
|
+
}
|
|
32
|
+
function declarationProjectPackageFilePath(packageFolder, relativeFilePath) {
|
|
33
|
+
return path.join(packageFolder, relativeFilePath);
|
|
34
|
+
}
|
|
35
|
+
function declarationProjectPackageRelativeFilePath(packageFolder, filePath) {
|
|
36
|
+
return path.relative(packageFolder, filePath).split(path.sep).join(path.posix.sep);
|
|
37
|
+
}
|
|
38
|
+
function toDeclarationDiagnostic(packageFolder, diagnostic) {
|
|
39
|
+
const sourceFile = diagnostic.getSourceFile();
|
|
40
|
+
const start = diagnostic.getStart();
|
|
41
|
+
if (sourceFile === undefined || start === undefined) {
|
|
42
|
+
return undefined;
|
|
43
|
+
}
|
|
44
|
+
return {
|
|
45
|
+
declarationPath: declarationProjectPackageRelativeFilePath(packageFolder, sourceFile.getFilePath()),
|
|
46
|
+
line: sourceFile.getLineAndColumnAtPos(start).line,
|
|
47
|
+
code: diagnostic.getCode(),
|
|
48
|
+
message: typescript.flattenDiagnosticMessageText(diagnostic.compilerObject.messageText, '\n')
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
function isDeclarationDiagnostic(diagnostic) {
|
|
52
|
+
return diagnostic !== undefined;
|
|
53
|
+
}
|
|
54
|
+
function createModeProject(project, packageFolder, modeLabel) {
|
|
55
|
+
return {
|
|
56
|
+
modeLabel,
|
|
57
|
+
moduleSpecifiersOf(declarationPath) {
|
|
58
|
+
return moduleSpecifiersIn(project.getSourceFileOrThrow(declarationProjectPackageFilePath(packageFolder, declarationPath)));
|
|
59
|
+
},
|
|
60
|
+
listDiagnostics() {
|
|
61
|
+
return project
|
|
62
|
+
.getPreEmitDiagnostics()
|
|
63
|
+
.map(function (diagnostic) {
|
|
64
|
+
return toDeclarationDiagnostic(packageFolder, diagnostic);
|
|
65
|
+
})
|
|
66
|
+
.filter(isDeclarationDiagnostic);
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
export function createDeclarationProjectFactory(dependencies) {
|
|
71
|
+
const { Project, fileSystemHost, packageResolutionBaseFolder } = dependencies;
|
|
72
|
+
function createProjectForMode(packageName, packageFiles, compilerMode) {
|
|
73
|
+
const packageFolder = declarationProjectPackageFolder(packageResolutionBaseFolder, packageName);
|
|
74
|
+
const project = new Project({
|
|
75
|
+
fileSystem: fileSystemHost,
|
|
76
|
+
skipAddingFilesFromTsConfig: true,
|
|
77
|
+
compilerOptions: {
|
|
78
|
+
module: compilerMode.module,
|
|
79
|
+
moduleResolution: compilerMode.moduleResolution,
|
|
80
|
+
noEmit: true,
|
|
81
|
+
resolveJsonModule: true,
|
|
82
|
+
skipLibCheck: false,
|
|
83
|
+
strict: true,
|
|
84
|
+
target: ScriptTarget.ESNext
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
for (const packageFile of packageFiles) {
|
|
88
|
+
const filePath = declarationProjectPackageFilePath(packageFolder, packageFile.filePath);
|
|
89
|
+
if (path.basename(packageFile.filePath) === 'package.json') {
|
|
90
|
+
project.createSourceFile(filePath, packageFile.content, { scriptKind: ScriptKind.JSON });
|
|
91
|
+
}
|
|
92
|
+
else {
|
|
93
|
+
project.createSourceFile(filePath, packageFile.content);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
return createModeProject(project, packageFolder, compilerMode.label);
|
|
97
|
+
}
|
|
98
|
+
return function createDeclarationProjects(packageName, packageFiles) {
|
|
99
|
+
return declarationCompilerModes().map(function (compilerMode) {
|
|
100
|
+
return createProjectForMode(packageName, packageFiles, compilerMode);
|
|
101
|
+
});
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
//# sourceMappingURL=type-script-declaration-project.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"type-script-declaration-project.js","sourceRoot":"","sources":["../../../../../source/checks/rules/type-script-declaration-project.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EACH,UAAU,EACV,oBAAoB,EACpB,UAAU,EACV,YAAY,EACZ,EAAE,IAAI,UAAU,EAKnB,MAAM,UAAU,CAAC;AAqClB,SAAS,wBAAwB;IAC7B,OAAO;QACH;YACI,KAAK,EAAE,YAAY;YACnB,MAAM,EAAE,UAAU,CAAC,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ACjC,eAAe,EAAE;gBACb,MAAM,EAAE,YAAY,CAAC,MAAM;gBAC3B,gBAAgB,EAAE,YAAY,CAAC,gBAAgB;gBAC/C,MAAM,EAAE,IAAI;gBACZ,iBAAiB,EAAE,IAAI;gBACvB,YAAY,EAAE,KAAK;gBACnB,MAAM,EAAE,IAAI;gBACZ,MAAM,EAAE,YAAY,CAAC,MAAM;aAC9B;SACJ,CAAC,CAAC;QAEH,KAAK,MAAM,WAAW,IAAI,YAAY,EAAE,CAAC;YACrC,MAAM,QAAQ,GAAG,iCAAiC,CAAC,aAAa,EAAE,WAAW,CAAC,QAAQ,CAAC,CAAC;YACxF,IAAI,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC,QAAQ,CAAC,KAAK,cAAc,EAAE,CAAC;gBACzD,OAAO,CAAC,gBAAgB,CAAC,QAAQ,EAAE,WAAW,CAAC,OAAO,EAAE,EAAE,UAAU,EAAE,UAAU,CAAC,IAAI,EAAE,CAAC,CAAC;YAC7F,CAAC;iBAAM,CAAC;gBACJ,OAAO,CAAC,gBAAgB,CAAC,QAAQ,EAAE,WAAW,CAAC,OAAO,CAAC,CAAC;YAC5D,CAAC;QACL,CAAC;QAED,OAAO,iBAAiB,CAAC,OAAO,EAAE,aAAa,EAAE,YAAY,CAAC,KAAK,CAAC,CAAC;IACzE,CAAC;IAED,OAAO,SAAS,yBAAyB,CAAC,WAAW,EAAE,YAAY;QAC/D,OAAO,wBAAwB,EAAE,CAAC,GAAG,CAAC,UAAU,YAAY;YACxD,OAAO,oBAAoB,CAAC,WAAW,EAAE,YAAY,EAAE,YAAY,CAAC,CAAC;QACzE,CAAC,CAAC,CAAC;IACP,CAAC,CAAC;AACN,CAAC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { createDirectedGraph } from "../../directed-graph/graph.js";
|
|
2
|
+
import { declarationCandidatesFor, isRelativeSpecifier } from "./type-script-declaration-paths.js";
|
|
3
|
+
function referencedDeclarationPaths(references, declarationPath) {
|
|
4
|
+
const referencedPaths = references
|
|
5
|
+
.moduleSpecifiersOf(declarationPath)
|
|
6
|
+
.filter(isRelativeSpecifier)
|
|
7
|
+
.flatMap(function (specifier) {
|
|
8
|
+
return declarationCandidatesFor(declarationPath, specifier);
|
|
9
|
+
})
|
|
10
|
+
.filter(function (candidate) {
|
|
11
|
+
return references.declarationPaths.has(candidate);
|
|
12
|
+
});
|
|
13
|
+
return new Set(referencedPaths);
|
|
14
|
+
}
|
|
15
|
+
function buildDeclarationGraph(references) {
|
|
16
|
+
const graph = createDirectedGraph();
|
|
17
|
+
for (const declarationPath of references.declarationPaths) {
|
|
18
|
+
graph.addNode(declarationPath, undefined);
|
|
19
|
+
}
|
|
20
|
+
for (const declarationPath of references.declarationPaths) {
|
|
21
|
+
for (const referencedPath of referencedDeclarationPaths(references, declarationPath)) {
|
|
22
|
+
graph.connect({ from: declarationPath, to: referencedPath });
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
return graph;
|
|
26
|
+
}
|
|
27
|
+
export function reachableDeclarationPaths(references) {
|
|
28
|
+
const graph = buildDeclarationGraph(references);
|
|
29
|
+
const reachable = new Set();
|
|
30
|
+
for (const rootPath of references.rootPaths) {
|
|
31
|
+
if (references.declarationPaths.has(rootPath)) {
|
|
32
|
+
graph.visitBreadthFirstSearch(rootPath, function (node) {
|
|
33
|
+
reachable.add(node.id);
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
return reachable;
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=type-script-declaration-reachability.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"type-script-declaration-reachability.js","sourceRoot":"","sources":["../../../../../source/checks/rules/type-script-declaration-reachability.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAsB,MAAM,+BAA+B,CAAC;AACxF,OAAO,EAAE,wBAAwB,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAC;AAQnG,SA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CAAC,uBAAuB,CAAC,QAAQ,EAAE,UAAU,IAAI;gBAClD,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;YAC3B,CAAC,CAAC,CAAC;QACP,CAAC;IACL,CAAC;IAED,OAAO,SAAS,CAAC;AACrB,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
const relativeSpecifierPrefix = './';
|
|
2
|
+
function isRecord(value) {
|
|
3
|
+
return Object.prototype.toString.call(value) === '[object Object]';
|
|
4
|
+
}
|
|
5
|
+
function packagePathsIn(value) {
|
|
6
|
+
if (typeof value === 'string') {
|
|
7
|
+
return value.startsWith(relativeSpecifierPrefix)
|
|
8
|
+
? [value.slice(relativeSpecifierPrefix.length)]
|
|
9
|
+
: [value];
|
|
10
|
+
}
|
|
11
|
+
if (typeof value === 'object' && value !== null) {
|
|
12
|
+
return Object.values(value).flatMap(packagePathsIn);
|
|
13
|
+
}
|
|
14
|
+
return [];
|
|
15
|
+
}
|
|
16
|
+
function parseManifestContent(manifestContent) {
|
|
17
|
+
const manifest = JSON.parse(manifestContent);
|
|
18
|
+
if (!isRecord(manifest)) {
|
|
19
|
+
return {};
|
|
20
|
+
}
|
|
21
|
+
return manifest;
|
|
22
|
+
}
|
|
23
|
+
export function declarationRootsFromManifest(manifestContent) {
|
|
24
|
+
const manifest = parseManifestContent(manifestContent);
|
|
25
|
+
return new Set([
|
|
26
|
+
...packagePathsIn(manifest.exports),
|
|
27
|
+
...packagePathsIn(manifest.types),
|
|
28
|
+
...packagePathsIn(manifest.typings)
|
|
29
|
+
]);
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=type-script-declaration-roots.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"type-script-declaration-roots.js","sourceRoot":"","sources":["../../../../../source/checks/rules/type-script-declaration-roots.ts"],"names":[],"mappings":"AAAA,MAAM,uBAAuB,GAAG,IAAI,CAAC;AAErC,SAAS,QAAQ,CAAC,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IntegritySummarizer } from './type-script-declaration-integrity.ts';
|
|
4
|
+
import type { PackageResolutionAnalyzer } from './type-script-package-resolution.ts';
|
|
5
|
+
export {};
|
|
6
|
+
//# sourceMappingURL=type-script-integrity.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"type-script-integrity.d.ts","sourceRoot":"","sources":["../../../../../source/checks/rules/type-script-integrity.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,UAAU;AAE5B,OAAO,KAAK,EAAE,mBAAmB,EAAiB,MAAM,YAAY;AACpE,OAAO,KAAK,EAAE,8BAA8B,EAAmB,MAAM,wCAAwC;AAC7G,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,qCAAqC"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { z } from 'zod/mini';
|
|
2
|
+
import { summarizeResolutionReport } from "./type-script-resolution-summary.js";
|
|
3
|
+
const ruleName = 'typeScriptIntegrity';
|
|
4
|
+
const checkedResolutionKinds = ['node16-esm', 'bundler'];
|
|
5
|
+
const declarationModeValues = ['all', 'exports-graph'];
|
|
6
|
+
const defaultDeclarationMode = 'all';
|
|
7
|
+
const globalSchema = z.strictObject({
|
|
8
|
+
enabled: z.boolean(),
|
|
9
|
+
declarations: z.optional(z.enum(declarationModeValues))
|
|
10
|
+
});
|
|
11
|
+
const perPackageSchema = z.strictObject({});
|
|
12
|
+
export const typeScriptIntegritySchemas = {
|
|
13
|
+
globalSchema,
|
|
14
|
+
perPackageSchema
|
|
15
|
+
};
|
|
16
|
+
export function createTypeScriptIntegrityRule(dependencies) {
|
|
17
|
+
const { analyzePackageResolution, summarizeDeclarationIntegrity } = dependencies;
|
|
18
|
+
async function summarizePackageResolution(packageName, publishedPackage) {
|
|
19
|
+
try {
|
|
20
|
+
const report = await analyzePackageResolution(publishedPackage, checkedResolutionKinds);
|
|
21
|
+
return summarizeResolutionReport(packageName, report, checkedResolutionKinds);
|
|
22
|
+
}
|
|
23
|
+
catch (error) {
|
|
24
|
+
return [`Package "${packageName}" failed TypeScript integrity: ${String(error)}`];
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
async function runForPackage(packageName, publishedPackage, declarationMode) {
|
|
28
|
+
return [
|
|
29
|
+
...await summarizePackageResolution(packageName, publishedPackage),
|
|
30
|
+
...summarizeDeclarationIntegrity(packageName, publishedPackage, declarationMode)
|
|
31
|
+
];
|
|
32
|
+
}
|
|
33
|
+
async function run(params) {
|
|
34
|
+
const globalConfig = params.settings?.typeScriptIntegrity;
|
|
35
|
+
if (globalConfig?.enabled !== true) {
|
|
36
|
+
return [];
|
|
37
|
+
}
|
|
38
|
+
const declarationMode = globalConfig.declarations ?? defaultDeclarationMode;
|
|
39
|
+
const issuesByBundle = await Promise.all(params.bundles.map(async function (bundle) {
|
|
40
|
+
const publishedPackage = params.publishedPackages?.get(bundle.name);
|
|
41
|
+
if (publishedPackage === undefined) {
|
|
42
|
+
throw new Error(`Published package missing for "${bundle.name}"`);
|
|
43
|
+
}
|
|
44
|
+
return await runForPackage(bundle.name, publishedPackage, declarationMode);
|
|
45
|
+
}));
|
|
46
|
+
return issuesByBundle.flat();
|
|
47
|
+
}
|
|
48
|
+
return {
|
|
49
|
+
name: ruleName,
|
|
50
|
+
...typeScriptIntegritySchemas,
|
|
51
|
+
run
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
//# sourceMappingURL=type-script-integrity.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"type-script-integrity.js","sourceRoot":"","sources":["../../../../../source/checks/rules/type-script-integrity.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,UAAU,CAAC;AAK7B,OAAO,EAAE,yBAAyB,EAAE,MAAM,qCAAqC,CAAC;AAEhF,MAAM,QAAQ,GAAG,qBAAqB,CAAC;AACvC,MAAM,sBAAsB,GAA8B,CAAE,YAAY,EAAE,SAAS,CAAE,CAAC;AACtF,MA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mB,CAAC;QAC1D,IAAI,YAAY,EAAE,OAAO,KAAK,IAAI,EAAE,CAAC;YACjC,OAAO,EAAE,CAAC;QACd,CAAC;QAED,MAAM,eAAe,GAAG,YAAY,CAAC,YAAY,IAAI,sBAAsB,CAAC;QAC5E,MAAM,cAAc,GAAG,MAAM,OAAO,CAAC,GAAG,CACpC,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,WAAW,MAAM;YACrC,MAAM,gBAAgB,GAAG,MAAM,CAAC,iBAAiB,EAAE,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;YACpE,IAAI,gBAAgB,KAAK,SAAS,EAAE,CAAC;gBACjC,MAAM,IAAI,KAAK,CAAC,kCAAkC,MAAM,CAAC,IAAI,GAAG,CAAC,CAAC;YACtE,CAAC;YAED,OAAO,MAAM,aAAa,CAAC,MAAM,CAAC,IAAI,EAAE,gBAAgB,EAAE,eAAe,CAAC,CAAC;QAC/E,CAAC,CAAC,CACL,CAAC;QACF,OAAO,cAAc,CAAC,IAAI,EAAE,CAAC;IACjC,CAAC;IAED,OAAO;QACH,IAAI,EAAE,QAAQ;QACd,GAAG,0BAA0B;QAC7B,GAAG;KACN,CAAC;AACN,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { Analysis, CheckResult, Package as TypesPackage, Problem, ProblemKind, ResolutionKind } from '@arethetypeswrong/core';
|
|
2
|
+
import type { problemKindInfo as ProblemKindInfo } from '@arethetypeswrong/core/problems';
|
|
3
|
+
import type { PublishedPackageWithManifest } from '../../published-package/published-package.ts';
|
|
4
|
+
export {};
|
|
5
|
+
//# sourceMappingURL=type-script-package-resolution.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"type-script-package-resolution.d.ts","sourceRoot":"","sources":["../../../../../source/checks/rules/type-script-package-resolution.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACR,QAAQ,EACR,WAAW,EACX,OAAO,IAAI,YAAY,EACvB,OAAO,EACP,WAAW,EACX,cAAc,EACjB,MAAM,wBAAwB;AAC/B,OAAO,KAAK,EAAE,eAAe,IAAI,eAAe,EAAE,MAAM,iCAAiC;AAEzF,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,8CAA8C"}
|