@tscircuit/cli 0.1.253 → 0.1.254
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 +60 -16
- package/package.json +1 -1
package/dist/main.js
CHANGED
|
@@ -57952,7 +57952,7 @@ var require_dist7 = __commonJS((exports2, module2) => {
|
|
|
57952
57952
|
});
|
|
57953
57953
|
module2.exports = __toCommonJS2(src_exports);
|
|
57954
57954
|
var import_minimist = __toESM3(require_minimist());
|
|
57955
|
-
var
|
|
57955
|
+
var import_prompts6 = __toESM3(require_prompts3());
|
|
57956
57956
|
var getAllLeafCommandPaths = (program3) => {
|
|
57957
57957
|
const allCommandPaths = [];
|
|
57958
57958
|
const traverse = (command, currentPath) => {
|
|
@@ -58012,7 +58012,7 @@ var require_dist7 = __commonJS((exports2, module2) => {
|
|
|
58012
58012
|
return commandPath;
|
|
58013
58013
|
}
|
|
58014
58014
|
const normalizeText = (text) => text.replace(/[-_ ]/g, "_").toLowerCase();
|
|
58015
|
-
const { nextCommandName } = yield (0,
|
|
58015
|
+
const { nextCommandName } = yield (0, import_prompts6.default)({
|
|
58016
58016
|
type: "autocomplete",
|
|
58017
58017
|
name: "nextCommandName",
|
|
58018
58018
|
message: "Choose command",
|
|
@@ -61091,11 +61091,7 @@ function getPackageManager() {
|
|
|
61091
61091
|
} else if (pm === "pnpm") {
|
|
61092
61092
|
installCommand = `pnpm add ${name}`;
|
|
61093
61093
|
} else if (pm === "bun") {
|
|
61094
|
-
|
|
61095
|
-
installCommand = `bun add ${name} --registry https://npm.tscircuit.com`;
|
|
61096
|
-
} else {
|
|
61097
|
-
installCommand = `bun add ${name}`;
|
|
61098
|
-
}
|
|
61094
|
+
installCommand = `bun add ${name}`;
|
|
61099
61095
|
} else {
|
|
61100
61096
|
installCommand = `npm install ${name}`;
|
|
61101
61097
|
}
|
|
@@ -63256,7 +63252,7 @@ var getGlobalDepsInstallCommand = (packageManager, deps) => {
|
|
|
63256
63252
|
import { execSync as execSync2 } from "node:child_process";
|
|
63257
63253
|
var import_semver2 = __toESM2(require_semver2(), 1);
|
|
63258
63254
|
// package.json
|
|
63259
|
-
var version = "0.1.
|
|
63255
|
+
var version = "0.1.253";
|
|
63260
63256
|
var package_default = {
|
|
63261
63257
|
name: "@tscircuit/cli",
|
|
63262
63258
|
version,
|
|
@@ -67828,6 +67824,34 @@ var pushSnippet = async ({
|
|
|
67828
67824
|
// lib/shared/add-package.ts
|
|
67829
67825
|
import * as fs17 from "node:fs";
|
|
67830
67826
|
import * as path17 from "node:path";
|
|
67827
|
+
|
|
67828
|
+
// lib/shared/resolve-tarball-url-from-registry.ts
|
|
67829
|
+
async function resolveTarballUrlFromRegistry(packageName) {
|
|
67830
|
+
const encodedName = encodeURIComponent(packageName);
|
|
67831
|
+
const response = await fetch(`https://npm.tscircuit.com/${encodedName}`);
|
|
67832
|
+
if (!response.ok) {
|
|
67833
|
+
throw new Error(`Failed to fetch package metadata for ${packageName}: HTTP ${response.status}`);
|
|
67834
|
+
}
|
|
67835
|
+
const metadata = await response.json();
|
|
67836
|
+
const latestVersion = metadata?.["dist-tags"]?.latest;
|
|
67837
|
+
let versionInfo = latestVersion ? metadata?.versions?.[latestVersion] : undefined;
|
|
67838
|
+
if (!versionInfo && metadata?.versions) {
|
|
67839
|
+
const versionEntries = Object.entries(metadata.versions);
|
|
67840
|
+
versionEntries.sort(([a], [b]) => {
|
|
67841
|
+
if (a === b)
|
|
67842
|
+
return 0;
|
|
67843
|
+
return a < b ? -1 : 1;
|
|
67844
|
+
});
|
|
67845
|
+
versionInfo = versionEntries.at(-1)?.[1];
|
|
67846
|
+
}
|
|
67847
|
+
const tarballUrl = versionInfo?.dist?.tarball;
|
|
67848
|
+
if (!tarballUrl) {
|
|
67849
|
+
throw new Error(`Unable to determine tarball URL for ${packageName} from registry metadata.`);
|
|
67850
|
+
}
|
|
67851
|
+
return tarballUrl;
|
|
67852
|
+
}
|
|
67853
|
+
|
|
67854
|
+
// lib/shared/add-package.ts
|
|
67831
67855
|
function normalizePackageNameToNpm(componentPath) {
|
|
67832
67856
|
if (componentPath.startsWith("@tscircuit/")) {
|
|
67833
67857
|
return componentPath;
|
|
@@ -67845,17 +67869,37 @@ function normalizePackageNameToNpm(componentPath) {
|
|
|
67845
67869
|
async function addPackage(componentPath, projectDir = process.cwd()) {
|
|
67846
67870
|
const packageName = normalizePackageNameToNpm(componentPath);
|
|
67847
67871
|
console.log(`Adding ${packageName}...`);
|
|
67848
|
-
|
|
67849
|
-
|
|
67850
|
-
|
|
67851
|
-
fs17.
|
|
67852
|
-
|
|
67853
|
-
|
|
67854
|
-
|
|
67872
|
+
let installTarget = packageName;
|
|
67873
|
+
if (packageName.startsWith("@tsci/")) {
|
|
67874
|
+
const npmrcPath = path17.join(projectDir, ".npmrc");
|
|
67875
|
+
const npmrcContent = fs17.existsSync(npmrcPath) ? fs17.readFileSync(npmrcPath, "utf-8") : "";
|
|
67876
|
+
let hasTsciRegistry = /@tsci[/:]/.test(npmrcContent);
|
|
67877
|
+
if (!hasTsciRegistry) {
|
|
67878
|
+
const { addRegistry } = await prompts({
|
|
67879
|
+
type: "confirm",
|
|
67880
|
+
name: "addRegistry",
|
|
67881
|
+
message: "No .npmrc entry for @tsci packages was found. Add '@tsci:registry=https://npm.tscircuit.com'?",
|
|
67882
|
+
initial: true
|
|
67883
|
+
});
|
|
67884
|
+
if (addRegistry) {
|
|
67885
|
+
const trimmedContent = npmrcContent.trimEnd();
|
|
67886
|
+
const newContent = (trimmedContent.length > 0 ? `${trimmedContent}
|
|
67887
|
+
` : "") + `@tsci:registry=https://npm.tscircuit.com
|
|
67888
|
+
`;
|
|
67889
|
+
fs17.writeFileSync(npmrcPath, newContent);
|
|
67890
|
+
console.log("Updated .npmrc with tscircuit registry");
|
|
67891
|
+
hasTsciRegistry = true;
|
|
67892
|
+
} else {
|
|
67893
|
+
console.log("Continuing without updating .npmrc; will fetch package directly from registry tarball.");
|
|
67894
|
+
}
|
|
67895
|
+
}
|
|
67896
|
+
if (!hasTsciRegistry) {
|
|
67897
|
+
installTarget = await resolveTarballUrlFromRegistry(packageName);
|
|
67898
|
+
}
|
|
67855
67899
|
}
|
|
67856
67900
|
const packageManager = getPackageManager();
|
|
67857
67901
|
try {
|
|
67858
|
-
packageManager.install({ name:
|
|
67902
|
+
packageManager.install({ name: installTarget, cwd: projectDir });
|
|
67859
67903
|
console.log(`Added ${packageName} successfully.`);
|
|
67860
67904
|
} catch (error) {
|
|
67861
67905
|
const errorMessage = error instanceof Error ? error.message : String(error);
|