@ankhorage/doctor 0.14.12 → 0.14.13
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/CHANGELOG.md
CHANGED
package/README.md
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
# @ankhorage/doctor
|
|
5
5
|
|
|
6
|
-
         
|
|
7
7
|
|
|
8
8
|
Executable Ankh provider and standalone CLI for lightweight repo and package compliance diagnostics.
|
|
9
9
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"capabilityCatalogImport.d.ts","sourceRoot":"","sources":["../src/capabilityCatalogImport.ts"],"names":[],"mappings":"AAKA,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB;AAED,8EAA8E;AAC9E,wBAAsB,sBAAsB,CAC1C,WAAW,EAAE,MAAM,EACnB,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC,oBAAoB,CAAC,CAI/B;AAED,gFAAgF;AAChF,wBAAsB,2BAA2B,CAC/C,WAAW,EAAE,MAAM,EACnB,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC,oBAAoB,CAAC,
|
|
1
|
+
{"version":3,"file":"capabilityCatalogImport.d.ts","sourceRoot":"","sources":["../src/capabilityCatalogImport.ts"],"names":[],"mappings":"AAKA,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB;AAED,8EAA8E;AAC9E,wBAAsB,sBAAsB,CAC1C,WAAW,EAAE,MAAM,EACnB,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC,oBAAoB,CAAC,CAI/B;AAED,gFAAgF;AAChF,wBAAsB,2BAA2B,CAC/C,WAAW,EAAE,MAAM,EACnB,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC,oBAAoB,CAAC,CAO/B"}
|
|
@@ -12,11 +12,32 @@ export async function resolveLocalImportPathAsync(packageRoot, fromPath, specifi
|
|
|
12
12
|
const candidate = path.resolve(path.dirname(fromPath), specifier);
|
|
13
13
|
if (!isInsidePackage(packageRoot, candidate) && candidate !== packageRoot)
|
|
14
14
|
throw new Error('Capability catalogs may not import outside their package.');
|
|
15
|
-
for (const
|
|
16
|
-
if (await isFileAsync(
|
|
17
|
-
return { packageRoot, path:
|
|
15
|
+
for (const sourcePath of localSourceCandidates(candidate))
|
|
16
|
+
if (await isFileAsync(sourcePath))
|
|
17
|
+
return { packageRoot, path: sourcePath };
|
|
18
18
|
throw new Error(`Unable to resolve static capability import ${specifier}.`);
|
|
19
19
|
}
|
|
20
|
+
/*** Enumerate source files represented by one package-local ESM import specifier. */
|
|
21
|
+
function localSourceCandidates(candidate) {
|
|
22
|
+
const extension = path.extname(candidate);
|
|
23
|
+
if (extension === '.js')
|
|
24
|
+
return [candidate.replace(/\.js$/u, '.ts'), candidate.replace(/\.js$/u, '.tsx'), candidate];
|
|
25
|
+
if (extension === '.mjs')
|
|
26
|
+
return [candidate.replace(/\.mjs$/u, '.mts'), candidate];
|
|
27
|
+
if (extension === '.cjs')
|
|
28
|
+
return [candidate.replace(/\.cjs$/u, '.cts'), candidate];
|
|
29
|
+
return [
|
|
30
|
+
candidate,
|
|
31
|
+
`${candidate}.ts`,
|
|
32
|
+
`${candidate}.tsx`,
|
|
33
|
+
`${candidate}.js`,
|
|
34
|
+
`${candidate}.mjs`,
|
|
35
|
+
`${candidate}.cjs`,
|
|
36
|
+
`${candidate}/index.ts`,
|
|
37
|
+
`${candidate}/index.tsx`,
|
|
38
|
+
`${candidate}/index.js`,
|
|
39
|
+
];
|
|
40
|
+
}
|
|
20
41
|
/*** Check whether a resolved path remains within the inspected package root. */
|
|
21
42
|
function isInsidePackage(packageRoot, candidate) {
|
|
22
43
|
const relativePath = path.relative(packageRoot, candidate);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"capabilityCatalogImport.js","sourceRoot":"","sources":["../src/capabilityCatalogImport.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,IAAI,EAAE,EAAE,MAAM,SAAS,CAAC;AACzC,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,EAAE,kCAAkC,EAAE,MAAM,uCAAuC,CAAC;AAO3F,8EAA8E;AAC9E,MAAM,CAAC,KAAK,UAAU,sBAAsB,CAC1C,WAAmB,EACnB,QAAgB,EAChB,SAAiB;IAEjB,IAAI,SAAS,CAAC,UAAU,CAAC,GAAG,CAAC;QAC3B,OAAO,2BAA2B,CAAC,WAAW,EAAE,QAAQ,EAAE,SAAS,CAAC,CAAC;IACvE,OAAO,kCAAkC,CAAC,WAAW,EAAE,QAAQ,EAAE,SAAS,CAAC,CAAC;AAC9E,CAAC;AAED,gFAAgF;AAChF,MAAM,CAAC,KAAK,UAAU,2BAA2B,CAC/C,WAAmB,EACnB,QAAgB,EAChB,SAAiB;IAEjB,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,SAAS,CAAC,CAAC;IAClE,IAAI,CAAC,eAAe,CAAC,WAAW,EAAE,SAAS,CAAC,IAAI,SAAS,KAAK,WAAW;QACvE,MAAM,IAAI,KAAK,CAAC,2DAA2D,CAAC,CAAC;IAC/E,KAAK,MAAM,SAAS,IAAI,CAAC,EAAE,EAAE,
|
|
1
|
+
{"version":3,"file":"capabilityCatalogImport.js","sourceRoot":"","sources":["../src/capabilityCatalogImport.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,IAAI,EAAE,EAAE,MAAM,SAAS,CAAC;AACzC,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAA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AM;QAAE,OAAO,CAAC,SAAS,CAAC,OAAO,CAAC,SAAS,EAAE,MAAM,CAAC,EAAE,SAAS,CAAC,CAAC;IACnF,IAAI,SAAS,KAAK,MAAM;QAAE,OAAO,CAAC,SAAS,CAAC,OAAO,CAAC,SAAS,EAAE,MAAM,CAAC,EAAE,SAAS,CAAC,CAAC;IACnF,OAAO;QACL,SAAS;QACT,GAAG,SAAS,KAAK;QACjB,GAAG,SAAS,MAAM;QAClB,GAAG,SAAS,KAAK;QACjB,GAAG,SAAS,MAAM;QAClB,GAAG,SAAS,MAAM;QAClB,GAAG,SAAS,WAAW;QACvB,GAAG,SAAS,YAAY;QACxB,GAAG,SAAS,WAAW;KACxB,CAAC;AACJ,CAAC;AAED,gFAAgF;AAChF,SAAS,eAAe,CAAC,WAAmB,EAAE,SAAiB;IAC7D,MAAM,YAAY,GAAG,IAAI,CAAC,QAAQ,CAAC,WAAW,EAAE,SAAS,CAAC,CAAC;IAC3D,OAAO,YAAY,KAAK,EAAE,IAAI,CAAC,YAAY,CAAC,UAAU,CAAC,KAAK,IAAI,CAAC,GAAG,EAAE,CAAC,IAAI,YAAY,KAAK,IAAI,CAAC;AACnG,CAAC;AAED,sDAAsD;AACtD,KAAK,UAAU,WAAW,CAAC,SAAiB;IAC1C,IAAI,CAAC;QACH,OAAO,CAAC,MAAM,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;IAC7C,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC","sourcesContent":["import { promises as fs } from 'node:fs';\nimport path from 'node:path';\n\nimport { resolveContractsCatalogImportAsync } from './capabilityCatalogContractsImport.js';\n\nexport interface ResolvedStaticImport {\n readonly packageRoot: string;\n readonly path: string;\n}\n\n/*** Resolve an allowed static import without executing its target package. */\nexport async function resolveImportPathAsync(\n packageRoot: string,\n fromPath: string,\n specifier: string,\n): Promise<ResolvedStaticImport> {\n if (specifier.startsWith('.'))\n return resolveLocalImportPathAsync(packageRoot, fromPath, specifier);\n return resolveContractsCatalogImportAsync(packageRoot, fromPath, specifier);\n}\n\n/*** Resolve a relative static import that remains within its owning package. */\nexport async function resolveLocalImportPathAsync(\n packageRoot: string,\n fromPath: string,\n specifier: string,\n): Promise<ResolvedStaticImport> {\n const candidate = path.resolve(path.dirname(fromPath), specifier);\n if (!isInsidePackage(packageRoot, candidate) && candidate !== packageRoot)\n throw new Error('Capability catalogs may not import outside their package.');\n for (const sourcePath of localSourceCandidates(candidate))\n if (await isFileAsync(sourcePath)) return { packageRoot, path: sourcePath };\n throw new Error(`Unable to resolve static capability import ${specifier}.`);\n}\n\n/*** Enumerate source files represented by one package-local ESM import specifier. */\nfunction localSourceCandidates(candidate: string): readonly string[] {\n const extension = path.extname(candidate);\n if (extension === '.js')\n return [candidate.replace(/\\.js$/u, '.ts'), candidate.replace(/\\.js$/u, '.tsx'), candidate];\n if (extension === '.mjs') return [candidate.replace(/\\.mjs$/u, '.mts'), candidate];\n if (extension === '.cjs') return [candidate.replace(/\\.cjs$/u, '.cts'), candidate];\n return [\n candidate,\n `${candidate}.ts`,\n `${candidate}.tsx`,\n `${candidate}.js`,\n `${candidate}.mjs`,\n `${candidate}.cjs`,\n `${candidate}/index.ts`,\n `${candidate}/index.tsx`,\n `${candidate}/index.js`,\n ];\n}\n\n/*** Check whether a resolved path remains within the inspected package root. */\nfunction isInsidePackage(packageRoot: string, candidate: string): boolean {\n const relativePath = path.relative(packageRoot, candidate);\n return relativePath !== '' && !relativePath.startsWith(`..${path.sep}`) && relativePath !== '..';\n}\n\n/*** Check whether one candidate is a regular file. */\nasync function isFileAsync(candidate: string): Promise<boolean> {\n try {\n return (await fs.stat(candidate)).isFile();\n } catch {\n return false;\n }\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ankhorage/doctor",
|
|
3
|
-
"version": "0.14.
|
|
3
|
+
"version": "0.14.13",
|
|
4
4
|
"description": "Executable Ankh provider and standalone CLI for lightweight repo and package compliance diagnostics.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"publishConfig": {
|
|
@@ -141,7 +141,7 @@
|
|
|
141
141
|
},
|
|
142
142
|
"devDependencies": {
|
|
143
143
|
"@ankhorage/ankh": "^0.13.0",
|
|
144
|
-
"@ankhorage/devtools": "^2.3.
|
|
144
|
+
"@ankhorage/devtools": "^2.3.12",
|
|
145
145
|
"@ankhorage/paradox": "^0.3.3",
|
|
146
146
|
"@types/bun": "^1.4.2",
|
|
147
147
|
"@types/node": "^26.6.5",
|
|
@@ -28,12 +28,31 @@ export async function resolveLocalImportPathAsync(
|
|
|
28
28
|
const candidate = path.resolve(path.dirname(fromPath), specifier);
|
|
29
29
|
if (!isInsidePackage(packageRoot, candidate) && candidate !== packageRoot)
|
|
30
30
|
throw new Error('Capability catalogs may not import outside their package.');
|
|
31
|
-
for (const
|
|
32
|
-
if (await isFileAsync(
|
|
33
|
-
return { packageRoot, path: `${candidate}${extension}` };
|
|
31
|
+
for (const sourcePath of localSourceCandidates(candidate))
|
|
32
|
+
if (await isFileAsync(sourcePath)) return { packageRoot, path: sourcePath };
|
|
34
33
|
throw new Error(`Unable to resolve static capability import ${specifier}.`);
|
|
35
34
|
}
|
|
36
35
|
|
|
36
|
+
/*** Enumerate source files represented by one package-local ESM import specifier. */
|
|
37
|
+
function localSourceCandidates(candidate: string): readonly string[] {
|
|
38
|
+
const extension = path.extname(candidate);
|
|
39
|
+
if (extension === '.js')
|
|
40
|
+
return [candidate.replace(/\.js$/u, '.ts'), candidate.replace(/\.js$/u, '.tsx'), candidate];
|
|
41
|
+
if (extension === '.mjs') return [candidate.replace(/\.mjs$/u, '.mts'), candidate];
|
|
42
|
+
if (extension === '.cjs') return [candidate.replace(/\.cjs$/u, '.cts'), candidate];
|
|
43
|
+
return [
|
|
44
|
+
candidate,
|
|
45
|
+
`${candidate}.ts`,
|
|
46
|
+
`${candidate}.tsx`,
|
|
47
|
+
`${candidate}.js`,
|
|
48
|
+
`${candidate}.mjs`,
|
|
49
|
+
`${candidate}.cjs`,
|
|
50
|
+
`${candidate}/index.ts`,
|
|
51
|
+
`${candidate}/index.tsx`,
|
|
52
|
+
`${candidate}/index.js`,
|
|
53
|
+
];
|
|
54
|
+
}
|
|
55
|
+
|
|
37
56
|
/*** Check whether a resolved path remains within the inspected package root. */
|
|
38
57
|
function isInsidePackage(packageRoot: string, candidate: string): boolean {
|
|
39
58
|
const relativePath = path.relative(packageRoot, candidate);
|