@tscircuit/cli 0.1.109 → 0.1.111
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 +43 -24
- package/package.json +1 -1
package/dist/main.js
CHANGED
|
@@ -433495,7 +433495,7 @@ var getGlobalDepsInstallCommand = (packageManager, deps) => {
|
|
|
433495
433495
|
import { execSync as execSync2 } from "node:child_process";
|
|
433496
433496
|
var import_semver = __toESM2(require_semver2(), 1);
|
|
433497
433497
|
// package.json
|
|
433498
|
-
var version = "0.1.
|
|
433498
|
+
var version = "0.1.110";
|
|
433499
433499
|
var package_default = {
|
|
433500
433500
|
name: "@tscircuit/cli",
|
|
433501
433501
|
version,
|
|
@@ -433707,11 +433707,17 @@ var prompts_default = prompts;
|
|
|
433707
433707
|
|
|
433708
433708
|
// lib/shared/check-for-cli-update.ts
|
|
433709
433709
|
var currentCliVersion = () => program2?.version() ?? import_semver.default.inc(version, "patch") ?? version;
|
|
433710
|
+
var getLatestVersion = async () => {
|
|
433711
|
+
const { version: latestCliVersion } = await distribution_default.get("https://registry.npmjs.org/@tscircuit/cli/latest", { throwHttpErrors: false }).json();
|
|
433712
|
+
return latestCliVersion;
|
|
433713
|
+
};
|
|
433710
433714
|
var checkForTsciUpdates = async () => {
|
|
433711
433715
|
if (process.env.TSCI_SKIP_CLI_UPDATE === "true")
|
|
433712
|
-
return;
|
|
433713
|
-
const
|
|
433714
|
-
if (latestCliVersion
|
|
433716
|
+
return false;
|
|
433717
|
+
const latestCliVersion = await getLatestVersion();
|
|
433718
|
+
if (!latestCliVersion)
|
|
433719
|
+
return false;
|
|
433720
|
+
if (import_semver.default.gt(latestCliVersion, currentCliVersion())) {
|
|
433715
433721
|
const { userWantsToUpdate } = await prompts({
|
|
433716
433722
|
type: "confirm",
|
|
433717
433723
|
name: "userWantsToUpdate",
|
|
@@ -433719,19 +433725,30 @@ var checkForTsciUpdates = async () => {
|
|
|
433719
433725
|
Would you like to update now?`
|
|
433720
433726
|
});
|
|
433721
433727
|
if (userWantsToUpdate) {
|
|
433722
|
-
|
|
433723
|
-
const installCommand = getGlobalDepsInstallCommand(packageManager.name, "@tscircuit/cli@latest");
|
|
433724
|
-
try {
|
|
433725
|
-
console.log(`Updating tsci using: ${installCommand}`);
|
|
433726
|
-
execSync2(installCommand, { stdio: "inherit" });
|
|
433727
|
-
console.log(kleur_default.green("tsci has been updated successfully!"));
|
|
433728
|
-
} catch {
|
|
433729
|
-
console.warn("Update failed. You can try updating manually by running:");
|
|
433730
|
-
console.warn(` ${installCommand}`);
|
|
433731
|
-
}
|
|
433728
|
+
return await updateTsci();
|
|
433732
433729
|
}
|
|
433733
|
-
}
|
|
433730
|
+
}
|
|
433731
|
+
return false;
|
|
433732
|
+
};
|
|
433733
|
+
var updateTsciIfNewVersionIsAvailable = async () => {
|
|
433734
|
+
const latestCliVersion = await getLatestVersion();
|
|
433735
|
+
if (!latestCliVersion)
|
|
433734
433736
|
return false;
|
|
433737
|
+
if (import_semver.default.gt(latestCliVersion, currentCliVersion())) {
|
|
433738
|
+
return await updateTsci();
|
|
433739
|
+
}
|
|
433740
|
+
return false;
|
|
433741
|
+
};
|
|
433742
|
+
var updateTsci = async () => {
|
|
433743
|
+
const packageManager = getPackageManager();
|
|
433744
|
+
const installCommand = getGlobalDepsInstallCommand(packageManager.name, "@tscircuit/cli@latest");
|
|
433745
|
+
try {
|
|
433746
|
+
console.log(`Updating tsci using: ${installCommand}`);
|
|
433747
|
+
execSync2(installCommand, { stdio: "inherit" });
|
|
433748
|
+
console.log(kleur_default.green("tsci has been updated successfully!"));
|
|
433749
|
+
} catch {
|
|
433750
|
+
console.warn("Update failed. You can try updating manually by running:");
|
|
433751
|
+
console.warn(` ${installCommand}`);
|
|
433735
433752
|
}
|
|
433736
433753
|
return true;
|
|
433737
433754
|
};
|
|
@@ -439291,20 +439308,22 @@ class DevServer {
|
|
|
439291
439308
|
async handleFileUpdatedEventFromServer(ev) {
|
|
439292
439309
|
if (ev.initiator === "filesystem_change")
|
|
439293
439310
|
return;
|
|
439294
|
-
|
|
439295
|
-
|
|
439296
|
-
|
|
439297
|
-
|
|
439298
|
-
|
|
439299
|
-
|
|
439311
|
+
const { file } = await this.fsKy.get("api/files/get", {
|
|
439312
|
+
searchParams: { file_path: ev.file_path }
|
|
439313
|
+
}).json();
|
|
439314
|
+
const fullPath = path18.join(this.projectDir, ev.file_path);
|
|
439315
|
+
const dirPath = path18.dirname(fullPath);
|
|
439316
|
+
if (!fs18.existsSync(dirPath)) {
|
|
439317
|
+
fs18.mkdirSync(dirPath, { recursive: true });
|
|
439300
439318
|
}
|
|
439319
|
+
fs18.writeFileSync(fullPath, file.text_content);
|
|
439301
439320
|
}
|
|
439302
439321
|
async handleFileChangedOnFilesystem(absoluteFilePath) {
|
|
439303
439322
|
const relativeFilePath = path18.relative(this.projectDir, absoluteFilePath);
|
|
439304
439323
|
if (relativeFilePath.includes("manual-edits.json"))
|
|
439305
439324
|
return;
|
|
439306
439325
|
await this.typesHandler?.handleFileTypeDependencies(absoluteFilePath);
|
|
439307
|
-
console.log(
|
|
439326
|
+
console.log(kleur_default.green(`Saving: ${relativeFilePath}`));
|
|
439308
439327
|
await this.fsKy.post("api/files/upsert", {
|
|
439309
439328
|
json: {
|
|
439310
439329
|
file_path: relativeFilePath,
|
|
@@ -439339,7 +439358,7 @@ class DevServer {
|
|
|
439339
439358
|
console.error(`Network error deleting ${relativeFilePath}: ${error instanceof Error ? error.message : String(error)}`);
|
|
439340
439359
|
return { error: "Connection error" };
|
|
439341
439360
|
});
|
|
439342
|
-
if (response
|
|
439361
|
+
if (response?.error) {
|
|
439343
439362
|
if (response.error.includes("File not found")) {
|
|
439344
439363
|
debug2(`File not found: ${relativeFilePath}`);
|
|
439345
439364
|
} else {
|
|
@@ -464677,7 +464696,7 @@ var registerAdd = (program3) => {
|
|
|
464677
464696
|
// cli/upgrade/register.ts
|
|
464678
464697
|
function registerUpgradeCommand(program3) {
|
|
464679
464698
|
program3.command("upgrade").description("Upgrade CLI to the latest version").action(async () => {
|
|
464680
|
-
const isUpdated = await
|
|
464699
|
+
const isUpdated = await updateTsciIfNewVersionIsAvailable();
|
|
464681
464700
|
if (!isUpdated) {
|
|
464682
464701
|
console.log(kleur_default.green(`You are already using the latest version of tsci (v${currentCliVersion()})`));
|
|
464683
464702
|
}
|