@tscircuit/cli 0.1.547 → 0.1.549
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/main.js +78 -25
- package/package.json +1 -1
package/dist/main.js
CHANGED
|
@@ -67115,7 +67115,7 @@ var require_dist7 = __commonJS((exports2, module2) => {
|
|
|
67115
67115
|
});
|
|
67116
67116
|
module2.exports = __toCommonJS2(src_exports);
|
|
67117
67117
|
var import_minimist = __toESM3(require_minimist());
|
|
67118
|
-
var
|
|
67118
|
+
var import_prompts8 = __toESM3(require_prompts3());
|
|
67119
67119
|
var getAllLeafCommandPaths = (program3) => {
|
|
67120
67120
|
const allCommandPaths = [];
|
|
67121
67121
|
const traverse = (command, currentPath) => {
|
|
@@ -67175,7 +67175,7 @@ var require_dist7 = __commonJS((exports2, module2) => {
|
|
|
67175
67175
|
return commandPath;
|
|
67176
67176
|
}
|
|
67177
67177
|
const normalizeText = (text) => text.replace(/[-_ ]/g, "_").toLowerCase();
|
|
67178
|
-
const { nextCommandName } = yield (0,
|
|
67178
|
+
const { nextCommandName } = yield (0, import_prompts8.default)({
|
|
67179
67179
|
type: "autocomplete",
|
|
67180
67180
|
name: "nextCommandName",
|
|
67181
67181
|
message: "Choose command",
|
|
@@ -72387,7 +72387,7 @@ var getGlobalDepsInstallCommand = (packageManager, deps) => {
|
|
|
72387
72387
|
import { execSync as execSync2 } from "node:child_process";
|
|
72388
72388
|
var import_semver2 = __toESM2(require_semver2(), 1);
|
|
72389
72389
|
// package.json
|
|
72390
|
-
var version = "0.1.
|
|
72390
|
+
var version = "0.1.548";
|
|
72391
72391
|
var package_default = {
|
|
72392
72392
|
name: "@tscircuit/cli",
|
|
72393
72393
|
version,
|
|
@@ -77970,6 +77970,7 @@ import * as path24 from "node:path";
|
|
|
77970
77970
|
|
|
77971
77971
|
// cli/clone/clone-bug-report.ts
|
|
77972
77972
|
var import_jszip = __toESM2(require_lib4(), 1);
|
|
77973
|
+
var import_prompts7 = __toESM2(require_prompts3(), 1);
|
|
77973
77974
|
import * as fs23 from "node:fs";
|
|
77974
77975
|
import * as path23 from "node:path";
|
|
77975
77976
|
|
|
@@ -78044,7 +78045,7 @@ var cloneBugReport = async ({
|
|
|
78044
78045
|
console.error("Bug report ID must not be empty.");
|
|
78045
78046
|
process.exit(1);
|
|
78046
78047
|
}
|
|
78047
|
-
|
|
78048
|
+
let dirPath = path23.resolve(`bug-report-${trimmedBugReportId}`);
|
|
78048
78049
|
await handleExistingDirectory(dirPath);
|
|
78049
78050
|
const ky2 = getRegistryApiKy();
|
|
78050
78051
|
let zipBuffer;
|
|
@@ -78079,6 +78080,32 @@ var cloneBugReport = async ({
|
|
|
78079
78080
|
const fileContent = await entry.async("nodebuffer");
|
|
78080
78081
|
fs23.writeFileSync(fullPath, fileContent);
|
|
78081
78082
|
}
|
|
78083
|
+
const packageJsonPath = path23.join(dirPath, "package.json");
|
|
78084
|
+
if (fs23.existsSync(packageJsonPath)) {
|
|
78085
|
+
try {
|
|
78086
|
+
const packageJson = JSON.parse(fs23.readFileSync(packageJsonPath, "utf-8"));
|
|
78087
|
+
const packageName = packageJson?.name;
|
|
78088
|
+
if (typeof packageName === "string" && packageName.trim()) {
|
|
78089
|
+
const sanitizedName = packageName.replace(/[^a-zA-Z0-9]/g, "_");
|
|
78090
|
+
const suggestedDirPath = path23.resolve(`${sanitizedName}_${trimmedBugReportId.slice(7)}`);
|
|
78091
|
+
if (suggestedDirPath !== dirPath) {
|
|
78092
|
+
const response = await import_prompts7.default({
|
|
78093
|
+
type: "confirm",
|
|
78094
|
+
name: "rename",
|
|
78095
|
+
initial: true,
|
|
78096
|
+
message: `Rename the directory to "${path23.basename(suggestedDirPath)}"?`
|
|
78097
|
+
});
|
|
78098
|
+
if (response.rename) {
|
|
78099
|
+
await handleExistingDirectory(suggestedDirPath);
|
|
78100
|
+
fs23.renameSync(dirPath, suggestedDirPath);
|
|
78101
|
+
dirPath = suggestedDirPath;
|
|
78102
|
+
}
|
|
78103
|
+
}
|
|
78104
|
+
}
|
|
78105
|
+
} catch (error) {
|
|
78106
|
+
console.warn("Unable to read package name for renaming:", error);
|
|
78107
|
+
}
|
|
78108
|
+
}
|
|
78082
78109
|
fs23.writeFileSync(path23.join(dirPath, ".npmrc"), "@tsci:registry=https://npm.tscircuit.com");
|
|
78083
78110
|
generateTsConfig(dirPath);
|
|
78084
78111
|
await setupTsciProject(dirPath);
|
|
@@ -94793,13 +94820,13 @@ var getSpiceWithPaddedSim = (circuitJson, options) => {
|
|
|
94793
94820
|
};
|
|
94794
94821
|
|
|
94795
94822
|
// lib/eecircuit-engine/run-simulation.ts
|
|
94796
|
-
import { promises as fs27, existsSync as
|
|
94823
|
+
import { promises as fs27, existsSync as existsSync11 } from "node:fs";
|
|
94797
94824
|
import path27 from "node:path";
|
|
94798
94825
|
import os2 from "node:os";
|
|
94799
94826
|
var sim = null;
|
|
94800
94827
|
var fetchSimulation = async () => {
|
|
94801
94828
|
const tempFilePath = path27.join(os2.tmpdir(), "eecircuit-engine-1.5.2.mjs");
|
|
94802
|
-
if (!
|
|
94829
|
+
if (!existsSync11(tempFilePath)) {
|
|
94803
94830
|
const url = "https://cdn.jsdelivr.net/npm/eecircuit-engine@1.5.2/+esm";
|
|
94804
94831
|
const response = await fetch(url);
|
|
94805
94832
|
if (!response.ok) {
|
|
@@ -196759,6 +196786,7 @@ var createStaticAssetPlugin = ({
|
|
|
196759
196786
|
const copiedAssets = new Map;
|
|
196760
196787
|
const resolvedBaseUrl = baseUrl ?? projectDir;
|
|
196761
196788
|
const resolvedPathMappings = pathMappings ?? {};
|
|
196789
|
+
const assetIdToOutputPath = new Map;
|
|
196762
196790
|
return {
|
|
196763
196791
|
name: "tsci-static-assets",
|
|
196764
196792
|
resolveId(source, importer) {
|
|
@@ -196766,17 +196794,17 @@ var createStaticAssetPlugin = ({
|
|
|
196766
196794
|
if (!STATIC_ASSET_EXTENSIONS.has(ext))
|
|
196767
196795
|
return null;
|
|
196768
196796
|
if (path35.isAbsolute(source)) {
|
|
196769
|
-
return fs36.existsSync(source) ? source : null;
|
|
196797
|
+
return fs36.existsSync(source) ? { id: source, external: true } : null;
|
|
196770
196798
|
}
|
|
196771
196799
|
if (importer) {
|
|
196772
196800
|
const resolvedFromImporter = path35.resolve(path35.dirname(importer), source);
|
|
196773
196801
|
if (fs36.existsSync(resolvedFromImporter)) {
|
|
196774
|
-
return resolvedFromImporter;
|
|
196802
|
+
return { id: resolvedFromImporter, external: true };
|
|
196775
196803
|
}
|
|
196776
196804
|
}
|
|
196777
196805
|
const resolvedFromProject = path35.resolve(resolvedBaseUrl, source);
|
|
196778
196806
|
if (fs36.existsSync(resolvedFromProject)) {
|
|
196779
|
-
return resolvedFromProject;
|
|
196807
|
+
return { id: resolvedFromProject, external: true };
|
|
196780
196808
|
}
|
|
196781
196809
|
for (const [pattern, targets] of Object.entries(resolvedPathMappings)) {
|
|
196782
196810
|
const isWildcard = pattern.endsWith("/*");
|
|
@@ -196787,32 +196815,57 @@ var createStaticAssetPlugin = ({
|
|
|
196787
196815
|
const targetPath = isWildcard ? target.replace("*", wildcard) : target;
|
|
196788
196816
|
const resolvedTarget = path35.resolve(resolvedBaseUrl, targetPath);
|
|
196789
196817
|
if (fs36.existsSync(resolvedTarget)) {
|
|
196790
|
-
return resolvedTarget;
|
|
196818
|
+
return { id: resolvedTarget, external: true };
|
|
196791
196819
|
}
|
|
196792
196820
|
}
|
|
196793
196821
|
}
|
|
196794
196822
|
}
|
|
196795
196823
|
return null;
|
|
196796
196824
|
},
|
|
196797
|
-
|
|
196798
|
-
|
|
196799
|
-
|
|
196800
|
-
|
|
196801
|
-
|
|
196802
|
-
|
|
196803
|
-
|
|
196804
|
-
|
|
196805
|
-
|
|
196806
|
-
|
|
196807
|
-
|
|
196808
|
-
|
|
196809
|
-
|
|
196825
|
+
buildStart() {
|
|
196826
|
+
assetIdToOutputPath.clear();
|
|
196827
|
+
},
|
|
196828
|
+
renderChunk(code) {
|
|
196829
|
+
let modifiedCode = code;
|
|
196830
|
+
for (const [assetId, outputPath] of assetIdToOutputPath) {
|
|
196831
|
+
modifiedCode = modifiedCode.replace(new RegExp(escapeRegExp(assetId), "g"), outputPath);
|
|
196832
|
+
}
|
|
196833
|
+
return { code: modifiedCode, map: null };
|
|
196834
|
+
},
|
|
196835
|
+
generateBundle(_options, bundle) {
|
|
196836
|
+
for (const chunk of Object.values(bundle)) {
|
|
196837
|
+
if (chunk.type !== "chunk")
|
|
196838
|
+
continue;
|
|
196839
|
+
for (const importedId of chunk.imports) {
|
|
196840
|
+
const ext = path35.extname(importedId).toLowerCase();
|
|
196841
|
+
if (!STATIC_ASSET_EXTENSIONS.has(ext))
|
|
196842
|
+
continue;
|
|
196843
|
+
if (!copiedAssets.has(importedId)) {
|
|
196844
|
+
const assetDir = path35.join(outputDir, "assets");
|
|
196845
|
+
fs36.mkdirSync(assetDir, { recursive: true });
|
|
196846
|
+
const fileBuffer = fs36.readFileSync(importedId);
|
|
196847
|
+
const hash = createHash("sha1").update(fileBuffer).digest("hex").slice(0, 8);
|
|
196848
|
+
const fileName = `${path35.basename(importedId, ext)}-${hash}${ext}`;
|
|
196849
|
+
const outputFilePath = path35.join(assetDir, fileName);
|
|
196850
|
+
fs36.writeFileSync(outputFilePath, fileBuffer);
|
|
196851
|
+
copiedAssets.set(importedId, `./assets/${fileName}`);
|
|
196852
|
+
assetIdToOutputPath.set(importedId, `./assets/${fileName}`);
|
|
196853
|
+
}
|
|
196854
|
+
}
|
|
196855
|
+
if (chunk.code) {
|
|
196856
|
+
let modifiedCode = chunk.code;
|
|
196857
|
+
for (const [assetId, relativePath] of copiedAssets) {
|
|
196858
|
+
modifiedCode = modifiedCode.replace(new RegExp(escapeRegExp(assetId), "g"), relativePath);
|
|
196859
|
+
}
|
|
196860
|
+
chunk.code = modifiedCode;
|
|
196861
|
+
}
|
|
196810
196862
|
}
|
|
196811
|
-
const relativePath = `./assets/${fileName}`;
|
|
196812
|
-
return `export default ${JSON.stringify(relativePath)};`;
|
|
196813
196863
|
}
|
|
196814
196864
|
};
|
|
196815
196865
|
};
|
|
196866
|
+
function escapeRegExp(string) {
|
|
196867
|
+
return string.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
196868
|
+
}
|
|
196816
196869
|
|
|
196817
196870
|
// cli/build/transpile/index.ts
|
|
196818
196871
|
var createExternalFunction = (projectDir, tsconfigPath) => (id2) => {
|