@tscircuit/cli 0.1.1184 → 0.1.1185
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/main.js +79 -0
- package/package.json +1 -1
package/dist/cli/main.js
CHANGED
|
@@ -98770,6 +98770,26 @@ function getPackageManager() {
|
|
|
98770
98770
|
process.stdout.write(output);
|
|
98771
98771
|
}
|
|
98772
98772
|
},
|
|
98773
|
+
update: ({ name, cwd }) => {
|
|
98774
|
+
let updateCommand;
|
|
98775
|
+
if (pm === "yarn") {
|
|
98776
|
+
updateCommand = `yarn upgrade ${name}`;
|
|
98777
|
+
} else if (pm === "pnpm") {
|
|
98778
|
+
updateCommand = `pnpm update ${name}`;
|
|
98779
|
+
} else if (pm === "bun") {
|
|
98780
|
+
updateCommand = `bun update ${name}`;
|
|
98781
|
+
} else {
|
|
98782
|
+
updateCommand = `npm update ${name}`;
|
|
98783
|
+
}
|
|
98784
|
+
console.log(kleur_default.gray(`> ${updateCommand}`));
|
|
98785
|
+
const output = execSync(updateCommand, {
|
|
98786
|
+
stdio: ["inherit", "pipe", "pipe"],
|
|
98787
|
+
cwd
|
|
98788
|
+
});
|
|
98789
|
+
if (output) {
|
|
98790
|
+
process.stdout.write(output);
|
|
98791
|
+
}
|
|
98792
|
+
},
|
|
98773
98793
|
init: ({ cwd }) => {
|
|
98774
98794
|
const initCommand = getInitCommand();
|
|
98775
98795
|
execSync(initCommand, { stdio: "inherit", cwd });
|
|
@@ -270044,6 +270064,64 @@ function registerUpgradeCommand(program3) {
|
|
|
270044
270064
|
});
|
|
270045
270065
|
}
|
|
270046
270066
|
|
|
270067
|
+
// lib/shared/update-package.ts
|
|
270068
|
+
import * as path68 from "node:path";
|
|
270069
|
+
import * as fs65 from "node:fs";
|
|
270070
|
+
async function updatePackage(packageSpec, projectDir = process.cwd()) {
|
|
270071
|
+
const packageManager = getPackageManager();
|
|
270072
|
+
if (!packageSpec) {
|
|
270073
|
+
const pkgJsonPath = path68.join(projectDir, "package.json");
|
|
270074
|
+
if (!fs65.existsSync(pkgJsonPath)) {
|
|
270075
|
+
console.log(kleur_default.yellow("No package.json found. Cannot update all packages."));
|
|
270076
|
+
return;
|
|
270077
|
+
}
|
|
270078
|
+
const pkgJson = JSON.parse(fs65.readFileSync(pkgJsonPath, "utf-8"));
|
|
270079
|
+
const allDeps = {
|
|
270080
|
+
...pkgJson.dependencies || {},
|
|
270081
|
+
...pkgJson.devDependencies || {}
|
|
270082
|
+
};
|
|
270083
|
+
const tsciPackages = Object.keys(allDeps).filter((dep) => dep.startsWith("@tsci/") || dep.startsWith("@tscircuit/"));
|
|
270084
|
+
if (tsciPackages.length === 0) {
|
|
270085
|
+
console.log(kleur_default.yellow("No tscircuit packages found in package.json to update."));
|
|
270086
|
+
return;
|
|
270087
|
+
}
|
|
270088
|
+
const targetList = tsciPackages.join(" ");
|
|
270089
|
+
console.log(kleur_default.cyan(`Updating ${tsciPackages.length} packages: ${kleur_default.bold(targetList)}...`));
|
|
270090
|
+
try {
|
|
270091
|
+
packageManager.update({ name: targetList, cwd: projectDir });
|
|
270092
|
+
console.log(kleur_default.green(`✓ Updated all tscircuit packages successfully`));
|
|
270093
|
+
} catch (error) {
|
|
270094
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
270095
|
+
console.error(kleur_default.red(`✗ Failed to update packages:`), errorMessage);
|
|
270096
|
+
throw new Error(`Failed to update packages: ${errorMessage}`);
|
|
270097
|
+
}
|
|
270098
|
+
return;
|
|
270099
|
+
}
|
|
270100
|
+
const normalizedName = normalizeTscircuitPackageName(packageSpec);
|
|
270101
|
+
const displayName = normalizedName || packageSpec;
|
|
270102
|
+
const updateTarget = normalizedName || packageSpec;
|
|
270103
|
+
console.log(kleur_default.cyan(`Updating ${kleur_default.bold(displayName)}...`));
|
|
270104
|
+
try {
|
|
270105
|
+
packageManager.update({ name: updateTarget, cwd: projectDir });
|
|
270106
|
+
console.log(kleur_default.green(`✓ Updated ${kleur_default.bold(displayName)} successfully`));
|
|
270107
|
+
} catch (error) {
|
|
270108
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
270109
|
+
console.error(kleur_default.red(`✗ Failed to update ${displayName}:`), errorMessage);
|
|
270110
|
+
throw new Error(`Failed to update ${displayName}: ${errorMessage}`);
|
|
270111
|
+
}
|
|
270112
|
+
}
|
|
270113
|
+
|
|
270114
|
+
// cli/update/register.ts
|
|
270115
|
+
var registerUpdate = (program3) => {
|
|
270116
|
+
program3.command("update").description("Update tscircuit component packages to their latest version").argument("[packageSpec]", "Package to update, leave blank to update all @tsci dependencies.").action(async (packageSpec) => {
|
|
270117
|
+
try {
|
|
270118
|
+
await updatePackage(packageSpec);
|
|
270119
|
+
} catch (error) {
|
|
270120
|
+
process.exit(1);
|
|
270121
|
+
}
|
|
270122
|
+
});
|
|
270123
|
+
};
|
|
270124
|
+
|
|
270047
270125
|
// cli/main.ts
|
|
270048
270126
|
var program2 = new Command;
|
|
270049
270127
|
program2.name("tsci").description("CLI for developing tscircuit packages");
|
|
@@ -270070,6 +270148,7 @@ registerRemove(program2);
|
|
|
270070
270148
|
registerSnapshot(program2);
|
|
270071
270149
|
registerSetup(program2);
|
|
270072
270150
|
registerInstall(program2);
|
|
270151
|
+
registerUpdate(program2);
|
|
270073
270152
|
registerUpgradeCommand(program2);
|
|
270074
270153
|
registerDoctor(program2);
|
|
270075
270154
|
registerCheck(program2);
|