@tscircuit/cli 0.1.1201 → 0.1.1202
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/cli/build/build.worker.js +9 -8
- package/dist/cli/main.js +82 -13
- package/dist/lib/index.js +1 -1
- package/package.json +1 -1
|
@@ -11514,16 +11514,17 @@ function analyzeCircuitJson(circuitJson) {
|
|
|
11514
11514
|
if (!item || typeof item !== "object")
|
|
11515
11515
|
continue;
|
|
11516
11516
|
const t = item.type;
|
|
11517
|
-
|
|
11518
|
-
|
|
11519
|
-
|
|
11520
|
-
|
|
11521
|
-
|
|
11522
|
-
}
|
|
11523
|
-
if ("error_type" in item)
|
|
11517
|
+
const hasErrorType = typeof item.error_type === "string";
|
|
11518
|
+
const hasWarningType = typeof item.warning_type === "string";
|
|
11519
|
+
const isTypedError = typeof t === "string" && t.endsWith("_error");
|
|
11520
|
+
const isTypedWarning = typeof t === "string" && t.endsWith("_warning");
|
|
11521
|
+
if (hasErrorType || isTypedError) {
|
|
11524
11522
|
errors.push(item);
|
|
11525
|
-
|
|
11523
|
+
continue;
|
|
11524
|
+
}
|
|
11525
|
+
if (hasWarningType || isTypedWarning) {
|
|
11526
11526
|
warnings.push(item);
|
|
11527
|
+
}
|
|
11527
11528
|
}
|
|
11528
11529
|
return { errors, warnings };
|
|
11529
11530
|
}
|
package/dist/cli/main.js
CHANGED
|
@@ -99964,7 +99964,7 @@ var import_perfect_cli = __toESM2(require_dist2(), 1);
|
|
|
99964
99964
|
// lib/getVersion.ts
|
|
99965
99965
|
import { createRequire as createRequire2 } from "node:module";
|
|
99966
99966
|
// package.json
|
|
99967
|
-
var version = "0.1.
|
|
99967
|
+
var version = "0.1.1201";
|
|
99968
99968
|
var package_default = {
|
|
99969
99969
|
name: "@tscircuit/cli",
|
|
99970
99970
|
version,
|
|
@@ -109035,16 +109035,17 @@ function analyzeCircuitJson(circuitJson) {
|
|
|
109035
109035
|
if (!item || typeof item !== "object")
|
|
109036
109036
|
continue;
|
|
109037
109037
|
const t = item.type;
|
|
109038
|
-
|
|
109039
|
-
|
|
109040
|
-
|
|
109041
|
-
|
|
109042
|
-
|
|
109043
|
-
}
|
|
109044
|
-
if ("error_type" in item)
|
|
109038
|
+
const hasErrorType = typeof item.error_type === "string";
|
|
109039
|
+
const hasWarningType = typeof item.warning_type === "string";
|
|
109040
|
+
const isTypedError = typeof t === "string" && t.endsWith("_error");
|
|
109041
|
+
const isTypedWarning = typeof t === "string" && t.endsWith("_warning");
|
|
109042
|
+
if (hasErrorType || isTypedError) {
|
|
109045
109043
|
errors.push(item);
|
|
109046
|
-
|
|
109044
|
+
continue;
|
|
109045
|
+
}
|
|
109046
|
+
if (hasWarningType || isTypedWarning) {
|
|
109047
109047
|
warnings.push(item);
|
|
109048
|
+
}
|
|
109048
109049
|
}
|
|
109049
109050
|
return { errors, warnings };
|
|
109050
109051
|
}
|
|
@@ -113107,6 +113108,73 @@ var analyzeAllPlacements = (circuitJson) => {
|
|
|
113107
113108
|
};
|
|
113108
113109
|
|
|
113109
113110
|
// cli/check/placement/register.ts
|
|
113111
|
+
import {
|
|
113112
|
+
categorizeErrorOrWarning as categorizeErrorOrWarning2
|
|
113113
|
+
} from "@tscircuit/circuit-json-util";
|
|
113114
|
+
var normalizeCategory2 = (category) => category === "netlist" || category === "pin_specification" || category === "placement" || category === "routing" ? category : "unknown";
|
|
113115
|
+
var isPlacementDiagnostic = (issue) => normalizeCategory2(categorizeErrorOrWarning2(issue)) === "placement";
|
|
113116
|
+
var getIssueType = (issue) => issue.error_type ?? issue.warning_type ?? issue.type ?? "unknown_issue";
|
|
113117
|
+
var getScopedComponentIds = (circuitJson, refdes) => {
|
|
113118
|
+
const sourceComponentIds = new Set;
|
|
113119
|
+
const pcbComponentIds = new Set;
|
|
113120
|
+
for (const item of circuitJson) {
|
|
113121
|
+
const record = item;
|
|
113122
|
+
if (record.type === "source_component" && record.name === refdes && typeof record.source_component_id === "string") {
|
|
113123
|
+
sourceComponentIds.add(record.source_component_id);
|
|
113124
|
+
}
|
|
113125
|
+
}
|
|
113126
|
+
for (const item of circuitJson) {
|
|
113127
|
+
const record = item;
|
|
113128
|
+
if (record.type === "pcb_component" && typeof record.source_component_id === "string" && sourceComponentIds.has(record.source_component_id) && typeof record.pcb_component_id === "string") {
|
|
113129
|
+
pcbComponentIds.add(record.pcb_component_id);
|
|
113130
|
+
}
|
|
113131
|
+
}
|
|
113132
|
+
return { sourceComponentIds, pcbComponentIds };
|
|
113133
|
+
};
|
|
113134
|
+
var isIssueRelatedToRefdes = (issue, refdes, scopedIds) => {
|
|
113135
|
+
if (typeof issue.source_component_id === "string" && scopedIds.sourceComponentIds.has(issue.source_component_id)) {
|
|
113136
|
+
return true;
|
|
113137
|
+
}
|
|
113138
|
+
if (typeof issue.pcb_component_id === "string" && scopedIds.pcbComponentIds.has(issue.pcb_component_id)) {
|
|
113139
|
+
return true;
|
|
113140
|
+
}
|
|
113141
|
+
if (typeof issue.component_name === "string" && issue.component_name === refdes) {
|
|
113142
|
+
return true;
|
|
113143
|
+
}
|
|
113144
|
+
if (typeof issue.name === "string" && issue.name === refdes) {
|
|
113145
|
+
return true;
|
|
113146
|
+
}
|
|
113147
|
+
return typeof issue.message === "string" && issue.message.includes(refdes);
|
|
113148
|
+
};
|
|
113149
|
+
var getPlacementDiagnostics = (circuitJson, refdes) => {
|
|
113150
|
+
const diagnostics = analyzeCircuitJson(circuitJson);
|
|
113151
|
+
let errors = diagnostics.errors.filter(isPlacementDiagnostic);
|
|
113152
|
+
let warnings = diagnostics.warnings.filter(isPlacementDiagnostic);
|
|
113153
|
+
if (refdes) {
|
|
113154
|
+
const scopedIds = getScopedComponentIds(circuitJson, refdes);
|
|
113155
|
+
errors = errors.filter((issue) => isIssueRelatedToRefdes(issue, refdes, scopedIds));
|
|
113156
|
+
warnings = warnings.filter((issue) => isIssueRelatedToRefdes(issue, refdes, scopedIds));
|
|
113157
|
+
}
|
|
113158
|
+
return { errors, warnings };
|
|
113159
|
+
};
|
|
113160
|
+
var formatPlacementDiagnostics = ({
|
|
113161
|
+
errors,
|
|
113162
|
+
warnings
|
|
113163
|
+
}) => {
|
|
113164
|
+
const lines = [
|
|
113165
|
+
"placement drc:",
|
|
113166
|
+
`Errors: ${errors.length}`,
|
|
113167
|
+
`Warnings: ${warnings.length}`
|
|
113168
|
+
];
|
|
113169
|
+
if (errors.length > 0) {
|
|
113170
|
+
lines.push(...errors.map((issue) => `- ${getIssueType(issue)}: ${issue.message ?? ""}`));
|
|
113171
|
+
}
|
|
113172
|
+
if (warnings.length > 0) {
|
|
113173
|
+
lines.push(...warnings.map((issue) => `- ${getIssueType(issue)}: ${issue.message ?? ""}`));
|
|
113174
|
+
}
|
|
113175
|
+
return lines.join(`
|
|
113176
|
+
`);
|
|
113177
|
+
};
|
|
113110
113178
|
var checkPlacement = async (file, refdes) => {
|
|
113111
113179
|
const resolvedInputFilePath = await resolveCheckInputFilePath(file);
|
|
113112
113180
|
const circuitJson = await getCircuitJsonForCheck({
|
|
@@ -113117,10 +113185,11 @@ var checkPlacement = async (file, refdes) => {
|
|
|
113117
113185
|
},
|
|
113118
113186
|
allowPrebuiltCircuitJson: true
|
|
113119
113187
|
});
|
|
113120
|
-
|
|
113121
|
-
|
|
113122
|
-
}
|
|
113123
|
-
|
|
113188
|
+
const analysisReport = refdes ? analyzeComponentPlacement(circuitJson, refdes).getString() : analyzeAllPlacements(circuitJson).getString();
|
|
113189
|
+
const placementDiagnostics = getPlacementDiagnostics(circuitJson, refdes);
|
|
113190
|
+
return `${analysisReport.trimEnd()}
|
|
113191
|
+
|
|
113192
|
+
${formatPlacementDiagnostics(placementDiagnostics)}`;
|
|
113124
113193
|
};
|
|
113125
113194
|
var registerCheckPlacement = (program2) => {
|
|
113126
113195
|
program2.commands.find((c) => c.name() === "check").command("placement").description("Partially build and validate the placement").argument("[file]", "Path to the entry file").argument("[refdes]", "Optional refdes to scope the check").action(async (file, refdes) => {
|
package/dist/lib/index.js
CHANGED
|
@@ -60678,7 +60678,7 @@ var getNodeHandler = (winterSpec, { port, middleware = [] }) => {
|
|
|
60678
60678
|
}));
|
|
60679
60679
|
};
|
|
60680
60680
|
// package.json
|
|
60681
|
-
var version = "0.1.
|
|
60681
|
+
var version = "0.1.1201";
|
|
60682
60682
|
var package_default = {
|
|
60683
60683
|
name: "@tscircuit/cli",
|
|
60684
60684
|
version,
|