@tscircuit/cli 0.1.484 → 0.1.485
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 +131 -2
- package/package.json +1 -1
package/dist/main.js
CHANGED
|
@@ -70022,7 +70022,13 @@ function getPackageManager() {
|
|
|
70022
70022
|
execSync(installCommand, { stdio: "inherit", cwd });
|
|
70023
70023
|
},
|
|
70024
70024
|
getInitCommand,
|
|
70025
|
-
getInstallDepsCommand
|
|
70025
|
+
getInstallDepsCommand,
|
|
70026
|
+
installAll: ({ cwd }) => {
|
|
70027
|
+
const installCommand = getInstallAllCommand();
|
|
70028
|
+
console.log(kleur_default.gray(`> ${installCommand}`));
|
|
70029
|
+
execSync(installCommand, { stdio: "inherit", cwd });
|
|
70030
|
+
},
|
|
70031
|
+
getInstallAllCommand
|
|
70026
70032
|
};
|
|
70027
70033
|
function getInitCommand() {
|
|
70028
70034
|
if (pm === "yarn")
|
|
@@ -70033,6 +70039,15 @@ function getPackageManager() {
|
|
|
70033
70039
|
return "bun init -y";
|
|
70034
70040
|
return "npm init -y";
|
|
70035
70041
|
}
|
|
70042
|
+
function getInstallAllCommand() {
|
|
70043
|
+
if (pm === "yarn")
|
|
70044
|
+
return "yarn install";
|
|
70045
|
+
if (pm === "pnpm")
|
|
70046
|
+
return "pnpm install";
|
|
70047
|
+
if (pm === "bun")
|
|
70048
|
+
return "bun install";
|
|
70049
|
+
return "npm install";
|
|
70050
|
+
}
|
|
70036
70051
|
function getInstallDepsCommand(deps, dev) {
|
|
70037
70052
|
const depList = deps.join(" ");
|
|
70038
70053
|
if (pm === "bun")
|
|
@@ -72369,7 +72384,7 @@ var getGlobalDepsInstallCommand = (packageManager, deps) => {
|
|
|
72369
72384
|
import { execSync as execSync2 } from "node:child_process";
|
|
72370
72385
|
var import_semver2 = __toESM2(require_semver2(), 1);
|
|
72371
72386
|
// package.json
|
|
72372
|
-
var version = "0.1.
|
|
72387
|
+
var version = "0.1.484";
|
|
72373
72388
|
var package_default = {
|
|
72374
72389
|
name: "@tscircuit/cli",
|
|
72375
72390
|
version,
|
|
@@ -94121,6 +94136,8 @@ async function generateCircuitJson({
|
|
|
94121
94136
|
platformConfig
|
|
94122
94137
|
}) {
|
|
94123
94138
|
debug11(`Generating circuit JSON for ${filePath}`);
|
|
94139
|
+
const React = await importFromUserLand("react");
|
|
94140
|
+
globalThis.React = React;
|
|
94124
94141
|
const userLandTscircuit = await importFromUserLand("tscircuit");
|
|
94125
94142
|
const runner = new userLandTscircuit.RootCircuit({
|
|
94126
94143
|
platform: platformConfig
|
|
@@ -196888,6 +196905,117 @@ var registerSimulate = (program3) => {
|
|
|
196888
196905
|
});
|
|
196889
196906
|
};
|
|
196890
196907
|
|
|
196908
|
+
// lib/shared/install-project-dependencies.ts
|
|
196909
|
+
import fs40 from "node:fs";
|
|
196910
|
+
import path38 from "node:path";
|
|
196911
|
+
|
|
196912
|
+
// lib/shared/collect-tsci-dependencies.ts
|
|
196913
|
+
import fs39 from "node:fs";
|
|
196914
|
+
import path37 from "node:path";
|
|
196915
|
+
var DEFAULT_PATTERNS = ["**/*.{ts,tsx,js,jsx}"];
|
|
196916
|
+
var DEFAULT_IGNORES = [
|
|
196917
|
+
"**/node_modules/**",
|
|
196918
|
+
"**/.git/**",
|
|
196919
|
+
"**/dist/**",
|
|
196920
|
+
"**/build/**",
|
|
196921
|
+
"**/.tsci/**"
|
|
196922
|
+
];
|
|
196923
|
+
var IMPORT_PATTERN = /["'`](@tsci\/[A-Za-z0-9._/-]+)["'`]/g;
|
|
196924
|
+
function collectTsciDependencies({
|
|
196925
|
+
cwd = process.cwd(),
|
|
196926
|
+
patterns = DEFAULT_PATTERNS,
|
|
196927
|
+
ignore = DEFAULT_IGNORES
|
|
196928
|
+
} = {}) {
|
|
196929
|
+
const searchRoot = path37.resolve(cwd);
|
|
196930
|
+
const files = globbySync(patterns, {
|
|
196931
|
+
cwd: searchRoot,
|
|
196932
|
+
absolute: true,
|
|
196933
|
+
ignore,
|
|
196934
|
+
gitignore: true
|
|
196935
|
+
});
|
|
196936
|
+
const dependencies2 = new Set;
|
|
196937
|
+
for (const filePath of files) {
|
|
196938
|
+
try {
|
|
196939
|
+
const fileContents = fs39.readFileSync(filePath, "utf-8");
|
|
196940
|
+
let match;
|
|
196941
|
+
while (true) {
|
|
196942
|
+
match = IMPORT_PATTERN.exec(fileContents);
|
|
196943
|
+
if (match === null)
|
|
196944
|
+
break;
|
|
196945
|
+
dependencies2.add(match[1]);
|
|
196946
|
+
}
|
|
196947
|
+
} catch (error) {}
|
|
196948
|
+
}
|
|
196949
|
+
return Array.from(dependencies2);
|
|
196950
|
+
}
|
|
196951
|
+
|
|
196952
|
+
// lib/shared/install-project-dependencies.ts
|
|
196953
|
+
async function installProjectDependencies({
|
|
196954
|
+
cwd = process.cwd()
|
|
196955
|
+
} = {}) {
|
|
196956
|
+
const projectRoot = path38.resolve(cwd);
|
|
196957
|
+
const packageJsonPath = path38.join(projectRoot, "package.json");
|
|
196958
|
+
const npmrcPath = path38.join(projectRoot, ".npmrc");
|
|
196959
|
+
const packageManager = getPackageManager();
|
|
196960
|
+
if (!fs40.existsSync(projectRoot)) {
|
|
196961
|
+
throw new Error(`Directory not found: ${projectRoot}`);
|
|
196962
|
+
}
|
|
196963
|
+
let packageJsonCreated = false;
|
|
196964
|
+
if (!fs40.existsSync(packageJsonPath)) {
|
|
196965
|
+
console.log("No package.json found. Generating a new one.");
|
|
196966
|
+
generatePackageJson(projectRoot);
|
|
196967
|
+
packageJsonCreated = true;
|
|
196968
|
+
} else {
|
|
196969
|
+
console.log("Found existing package.json.");
|
|
196970
|
+
}
|
|
196971
|
+
if (!fs40.existsSync(npmrcPath)) {
|
|
196972
|
+
console.log("Creating .npmrc with tscircuit registry configuration.");
|
|
196973
|
+
fs40.writeFileSync(npmrcPath, "@tsci:registry=https://npm.tscircuit.com");
|
|
196974
|
+
}
|
|
196975
|
+
const packageJson = JSON.parse(fs40.readFileSync(packageJsonPath, "utf-8"));
|
|
196976
|
+
if (packageJsonCreated) {
|
|
196977
|
+
const tsciDependencies = collectTsciDependencies({ cwd: projectRoot });
|
|
196978
|
+
if (tsciDependencies.length > 0) {
|
|
196979
|
+
packageJson.dependencies = packageJson.dependencies || {};
|
|
196980
|
+
for (const dependency of tsciDependencies) {
|
|
196981
|
+
if (!packageJson.dependencies[dependency]) {
|
|
196982
|
+
packageJson.dependencies[dependency] = "latest";
|
|
196983
|
+
}
|
|
196984
|
+
}
|
|
196985
|
+
console.log(`Added ${tsciDependencies.length} @tsci dependencies to package.json.`);
|
|
196986
|
+
} else {
|
|
196987
|
+
console.log("No @tsci dependencies detected in circuit files.");
|
|
196988
|
+
}
|
|
196989
|
+
}
|
|
196990
|
+
fs40.writeFileSync(packageJsonPath, `${JSON.stringify(packageJson, null, 2)}
|
|
196991
|
+
`);
|
|
196992
|
+
console.log(`Installing dependencies using ${kleur_default.bold(packageManager.name)}...`);
|
|
196993
|
+
try {
|
|
196994
|
+
packageManager.installAll({ cwd: projectRoot });
|
|
196995
|
+
console.log("Dependencies installed successfully.");
|
|
196996
|
+
} catch (error) {
|
|
196997
|
+
console.warn("Failed to automatically install dependencies.");
|
|
196998
|
+
console.warn(`Please run \`${packageManager.getInstallAllCommand()}\` manually.`);
|
|
196999
|
+
throw error;
|
|
197000
|
+
}
|
|
197001
|
+
}
|
|
197002
|
+
|
|
197003
|
+
// cli/install/register.ts
|
|
197004
|
+
var registerInstall = (program3) => {
|
|
197005
|
+
program3.command("install").description("Install project dependencies and generate package.json if needed").action(async () => {
|
|
197006
|
+
try {
|
|
197007
|
+
await installProjectDependencies();
|
|
197008
|
+
} catch (error) {
|
|
197009
|
+
if (error instanceof Error) {
|
|
197010
|
+
console.error(error.message);
|
|
197011
|
+
} else {
|
|
197012
|
+
console.error(error);
|
|
197013
|
+
}
|
|
197014
|
+
process.exit(1);
|
|
197015
|
+
}
|
|
197016
|
+
});
|
|
197017
|
+
};
|
|
197018
|
+
|
|
196891
197019
|
// cli/main.ts
|
|
196892
197020
|
var program2 = new Command;
|
|
196893
197021
|
program2.name("tsci").description("CLI for developing tscircuit packages");
|
|
@@ -196910,6 +197038,7 @@ registerAdd(program2);
|
|
|
196910
197038
|
registerRemove(program2);
|
|
196911
197039
|
registerSnapshot(program2);
|
|
196912
197040
|
registerSetup(program2);
|
|
197041
|
+
registerInstall(program2);
|
|
196913
197042
|
registerUpgradeCommand(program2);
|
|
196914
197043
|
registerSearch(program2);
|
|
196915
197044
|
registerImport(program2);
|