@suss/contract-wrangler 0.34.1 → 0.35.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.cjs +9 -10
- package/dist/index.d.cts +3 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.js +14 -10
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -41,6 +41,8 @@ __export(index_exports, {
|
|
|
41
41
|
});
|
|
42
42
|
module.exports = __toCommonJS(index_exports);
|
|
43
43
|
var import_node_path2 = __toESM(require("path"), 1);
|
|
44
|
+
var import_behavioral_ir3 = require("@suss/behavioral-ir");
|
|
45
|
+
var import_files = require("@suss/behavioral-ir/files");
|
|
44
46
|
var import_ir_core2 = require("@suss/ir-core");
|
|
45
47
|
|
|
46
48
|
// src/bindings.ts
|
|
@@ -388,17 +390,14 @@ function wranglerFileToSummaries(target, options = {}) {
|
|
|
388
390
|
throw new Error(`Wrangler configuration not found: ${target}`);
|
|
389
391
|
}
|
|
390
392
|
const document = loadConfigurationDocument(located.file);
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
393
|
+
const root = options.projectRoot ?? (0, import_files.defaultProjectRoot)(located.file);
|
|
394
|
+
const summaries = wranglerToSummaries(document, {
|
|
395
|
+
source: options.source ?? (0, import_files.documentSourceLabel)(RECOGNITION, located.file, root),
|
|
396
|
+
codeScope: options.codeScope ?? (0, import_ir_core2.codeScopePath)(import_node_path2.default.posix.dirname((0, import_files.pathInProject)(located.file, root)))
|
|
394
397
|
});
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
if (relative === "" || relative.startsWith("..")) {
|
|
399
|
-
return import_node_path2.default.resolve(file).split(import_node_path2.default.sep).join("/");
|
|
400
|
-
}
|
|
401
|
-
return relative.split(import_node_path2.default.sep).join("/");
|
|
398
|
+
return options.codeScope === void 0 ? summaries.map(
|
|
399
|
+
(summary) => (0, import_behavioral_ir3.withCodeScopeWorkspace)(summary, (0, import_files.projectNameOf)(root))
|
|
400
|
+
) : summaries;
|
|
402
401
|
}
|
|
403
402
|
function codeScopeFor(document, scope) {
|
|
404
403
|
const main = typeof document.main === "string" ? document.main : null;
|
package/dist/index.d.cts
CHANGED
|
@@ -116,9 +116,11 @@ interface WranglerToSummariesOptions {
|
|
|
116
116
|
/**
|
|
117
117
|
* The directory the Worker's code is in, relative to wherever the
|
|
118
118
|
* extraction run was pointed. Defaults to where the document is,
|
|
119
|
-
* relative to the
|
|
119
|
+
* relative to the project root.
|
|
120
120
|
*/
|
|
121
121
|
codeScope?: string;
|
|
122
|
+
/** Absolute. The directory the document's paths are measured from. */
|
|
123
|
+
projectRoot?: string;
|
|
122
124
|
}
|
|
123
125
|
declare function wranglerToSummaries(document: WranglerDocument, options: {
|
|
124
126
|
source: string;
|
package/dist/index.d.ts
CHANGED
|
@@ -116,9 +116,11 @@ interface WranglerToSummariesOptions {
|
|
|
116
116
|
/**
|
|
117
117
|
* The directory the Worker's code is in, relative to wherever the
|
|
118
118
|
* extraction run was pointed. Defaults to where the document is,
|
|
119
|
-
* relative to the
|
|
119
|
+
* relative to the project root.
|
|
120
120
|
*/
|
|
121
121
|
codeScope?: string;
|
|
122
|
+
/** Absolute. The directory the document's paths are measured from. */
|
|
123
|
+
projectRoot?: string;
|
|
122
124
|
}
|
|
123
125
|
declare function wranglerToSummaries(document: WranglerDocument, options: {
|
|
124
126
|
source: string;
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
// src/index.ts
|
|
2
2
|
import path2 from "path";
|
|
3
|
+
import { withCodeScopeWorkspace } from "@suss/behavioral-ir";
|
|
4
|
+
import {
|
|
5
|
+
defaultProjectRoot,
|
|
6
|
+
documentSourceLabel,
|
|
7
|
+
pathInProject,
|
|
8
|
+
projectNameOf
|
|
9
|
+
} from "@suss/behavioral-ir/files";
|
|
3
10
|
import { codeScopePath } from "@suss/ir-core";
|
|
4
11
|
|
|
5
12
|
// src/bindings.ts
|
|
@@ -347,17 +354,14 @@ function wranglerFileToSummaries(target, options = {}) {
|
|
|
347
354
|
throw new Error(`Wrangler configuration not found: ${target}`);
|
|
348
355
|
}
|
|
349
356
|
const document = loadConfigurationDocument(located.file);
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
357
|
+
const root = options.projectRoot ?? defaultProjectRoot(located.file);
|
|
358
|
+
const summaries = wranglerToSummaries(document, {
|
|
359
|
+
source: options.source ?? documentSourceLabel(RECOGNITION, located.file, root),
|
|
360
|
+
codeScope: options.codeScope ?? codeScopePath(path2.posix.dirname(pathInProject(located.file, root)))
|
|
353
361
|
});
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
if (relative === "" || relative.startsWith("..")) {
|
|
358
|
-
return path2.resolve(file).split(path2.sep).join("/");
|
|
359
|
-
}
|
|
360
|
-
return relative.split(path2.sep).join("/");
|
|
362
|
+
return options.codeScope === void 0 ? summaries.map(
|
|
363
|
+
(summary) => withCodeScopeWorkspace(summary, projectNameOf(root))
|
|
364
|
+
) : summaries;
|
|
361
365
|
}
|
|
362
366
|
function codeScopeFor(document, scope) {
|
|
363
367
|
const main = typeof document.main === "string" ? document.main : null;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@suss/contract-wrangler",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.35.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Read a Cloudflare wrangler.toml or wrangler.jsonc and check the bindings it declares against the Worker code that uses them.",
|
|
6
6
|
"keywords": [
|
|
@@ -47,8 +47,8 @@
|
|
|
47
47
|
"typecheck": "tsc --noEmit"
|
|
48
48
|
},
|
|
49
49
|
"dependencies": {
|
|
50
|
-
"@suss/behavioral-ir": "0.
|
|
51
|
-
"@suss/ir-core": "0.
|
|
50
|
+
"@suss/behavioral-ir": "0.35.0",
|
|
51
|
+
"@suss/ir-core": "0.35.0",
|
|
52
52
|
"jsonc-parser": "^3.3.1",
|
|
53
53
|
"smol-toml": "^1.4.2"
|
|
54
54
|
},
|