@tscircuit/cli 0.1.588 → 0.1.590

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.
Files changed (2) hide show
  1. package/dist/main.js +87 -18
  2. package/package.json +1 -1
package/dist/main.js CHANGED
@@ -57683,6 +57683,72 @@ var require_ignore = __commonJS((exports2, module2) => {
57683
57683
  define2(module2.exports, Symbol.for("setupWindows"), setupWindows);
57684
57684
  });
57685
57685
 
57686
+ // node_modules/strip-json-comments/index.js
57687
+ var require_strip_json_comments = __commonJS((exports2, module2) => {
57688
+ var singleComment = 1;
57689
+ var multiComment = 2;
57690
+ function stripWithoutWhitespace() {
57691
+ return "";
57692
+ }
57693
+ function stripWithWhitespace(str, start, end) {
57694
+ return str.slice(start, end).replace(/\S/g, " ");
57695
+ }
57696
+ module2.exports = function(str, opts) {
57697
+ opts = opts || {};
57698
+ var currentChar;
57699
+ var nextChar;
57700
+ var insideString = false;
57701
+ var insideComment = false;
57702
+ var offset = 0;
57703
+ var ret = "";
57704
+ var strip = opts.whitespace === false ? stripWithoutWhitespace : stripWithWhitespace;
57705
+ for (var i = 0;i < str.length; i++) {
57706
+ currentChar = str[i];
57707
+ nextChar = str[i + 1];
57708
+ if (!insideComment && currentChar === '"') {
57709
+ var escaped = str[i - 1] === "\\" && str[i - 2] !== "\\";
57710
+ if (!escaped) {
57711
+ insideString = !insideString;
57712
+ }
57713
+ }
57714
+ if (insideString) {
57715
+ continue;
57716
+ }
57717
+ if (!insideComment && currentChar + nextChar === "//") {
57718
+ ret += str.slice(offset, i);
57719
+ offset = i;
57720
+ insideComment = singleComment;
57721
+ i++;
57722
+ } else if (insideComment === singleComment && currentChar + nextChar === `\r
57723
+ `) {
57724
+ i++;
57725
+ insideComment = false;
57726
+ ret += strip(str, offset, i);
57727
+ offset = i;
57728
+ continue;
57729
+ } else if (insideComment === singleComment && currentChar === `
57730
+ `) {
57731
+ insideComment = false;
57732
+ ret += strip(str, offset, i);
57733
+ offset = i;
57734
+ } else if (!insideComment && currentChar + nextChar === "/*") {
57735
+ ret += str.slice(offset, i);
57736
+ offset = i;
57737
+ insideComment = multiComment;
57738
+ i++;
57739
+ continue;
57740
+ } else if (insideComment === multiComment && currentChar + nextChar === "*/") {
57741
+ i++;
57742
+ insideComment = false;
57743
+ ret += strip(str, offset, i + 1);
57744
+ offset = i + 1;
57745
+ continue;
57746
+ }
57747
+ }
57748
+ return ret + (insideComment ? strip(str.substr(offset)) : str.substr(offset));
57749
+ };
57750
+ });
57751
+
57686
57752
  // node_modules/process-nextick-args/index.js
57687
57753
  var require_process_nextick_args = __commonJS((exports2, module2) => {
57688
57754
  if (typeof process === "undefined" || !process.version || process.version.indexOf("v0.") === 0 || process.version.indexOf("v1.") === 0 && process.version.indexOf("v1.8.") !== 0) {
@@ -72387,7 +72453,7 @@ var getGlobalDepsInstallCommand = (packageManager, deps) => {
72387
72453
  import { execSync as execSync2 } from "node:child_process";
72388
72454
  var import_semver2 = __toESM2(require_semver2(), 1);
72389
72455
  // package.json
72390
- var version = "0.1.587";
72456
+ var version = "0.1.589";
72391
72457
  var package_default = {
72392
72458
  name: "@tscircuit/cli",
72393
72459
  version,
@@ -77038,6 +77104,7 @@ async function resolveTarballUrlFromRegistry(packageName) {
77038
77104
  // lib/shared/detect-and-setup-kicad-library.ts
77039
77105
  import * as fs17 from "node:fs";
77040
77106
  import * as path17 from "node:path";
77107
+ var import_strip_json_comments = __toESM2(require_strip_json_comments(), 1);
77041
77108
  function extractPackageName(packageSpec) {
77042
77109
  if (packageSpec.startsWith("http")) {
77043
77110
  const match = packageSpec.match(/github\.com\/([^/]+)\/([^/]+?)(?:\.git)?(?:[/#]|$)/);
@@ -77076,14 +77143,14 @@ async function detectAndSetupKicadLibrary(packageSpec, projectDir = process.cwd(
77076
77143
  if (kicadModFiles.length === 0) {
77077
77144
  return false;
77078
77145
  }
77079
- console.log(`Detected ${kicadModFiles.length} KiCad footprint file(s), generating types...`);
77146
+ console.log(kleur_default.cyan(`Detected ${kleur_default.bold(kicadModFiles.length.toString())} KiCad footprint file(s)`), kleur_default.dim("generating types..."));
77080
77147
  await generateKicadTypes(projectDir, packageName, kicadModFiles);
77081
77148
  await setupTsConfig(projectDir);
77082
77149
  await setupTsciProject(projectDir);
77083
- console.log(`✓ Generated types for KiCad library: ${packageName}`);
77150
+ console.log(kleur_default.green(`✓ Generated types for KiCad library: ${kleur_default.bold(packageName)}`));
77084
77151
  return true;
77085
77152
  } catch (error) {
77086
- console.warn(`Warning: Failed to detect/setup KiCad library: ${error instanceof Error ? error.message : String(error)}`);
77153
+ console.warn(kleur_default.yellow(`Warning: Failed to detect/setup KiCad library: ${error instanceof Error ? error.message : String(error)}`));
77087
77154
  return false;
77088
77155
  }
77089
77156
  }
@@ -77102,27 +77169,27 @@ async function generateKicadTypes(projectDir, packageName, kicadModFiles) {
77102
77169
 
77103
77170
  `);
77104
77171
  fs17.writeFileSync(typesFilePath, declarations);
77105
- console.log(`✓ Generated types at types/${typeFileName}`);
77172
+ console.log(kleur_default.green(`✓ Generated types at ${kleur_default.cyan(`types/${typeFileName}`)}`));
77106
77173
  }
77107
77174
  async function setupTsConfig(projectDir) {
77108
77175
  const tsconfigPath = path17.join(projectDir, "tsconfig.json");
77109
77176
  if (!fs17.existsSync(tsconfigPath)) {
77110
- console.log("Creating tsconfig.json...");
77177
+ console.log(kleur_default.dim("Creating tsconfig.json..."));
77111
77178
  generateTsConfig(projectDir);
77112
77179
  }
77113
77180
  const content = fs17.readFileSync(tsconfigPath, "utf-8");
77114
- const tsconfig = JSON.parse(content);
77181
+ const tsconfig = JSON.parse(import_strip_json_comments.default(content));
77115
77182
  if (!tsconfig.compilerOptions) {
77116
77183
  tsconfig.compilerOptions = {};
77117
77184
  }
77118
77185
  if (!tsconfig.compilerOptions.typeRoots) {
77119
77186
  tsconfig.compilerOptions.typeRoots = ["./types", "./node_modules/@types"];
77120
77187
  fs17.writeFileSync(tsconfigPath, JSON.stringify(tsconfig, null, 2));
77121
- console.log("✓ Updated tsconfig.json with types directory");
77188
+ console.log(kleur_default.green("✓ Updated tsconfig.json with types directory"));
77122
77189
  } else if (!tsconfig.compilerOptions.typeRoots.includes("./types")) {
77123
77190
  tsconfig.compilerOptions.typeRoots.unshift("./types");
77124
77191
  fs17.writeFileSync(tsconfigPath, JSON.stringify(tsconfig, null, 2));
77125
- console.log("✓ Updated tsconfig.json with types directory");
77192
+ console.log(kleur_default.green("✓ Updated tsconfig.json with types directory"));
77126
77193
  }
77127
77194
  }
77128
77195
 
@@ -77151,7 +77218,7 @@ async function addPackage(packageSpec, projectDir = process.cwd()) {
77151
77218
  const normalizedName = normalizeTscircuitPackageName(packageSpec);
77152
77219
  const displayName = normalizedName || packageSpec;
77153
77220
  let installTarget = normalizedName || packageSpec;
77154
- console.log(`Adding ${displayName}...`);
77221
+ console.log(kleur_default.cyan(`Adding ${kleur_default.bold(displayName)}...`));
77155
77222
  if (normalizedName && normalizedName.startsWith("@tsci/")) {
77156
77223
  const npmrcPath = path18.join(projectDir, ".npmrc");
77157
77224
  const npmrcContent = fs18.existsSync(npmrcPath) ? fs18.readFileSync(npmrcPath, "utf-8") : "";
@@ -77169,7 +77236,7 @@ async function addPackage(packageSpec, projectDir = process.cwd()) {
77169
77236
  ` : "") + `@tsci:registry=https://npm.tscircuit.com
77170
77237
  `;
77171
77238
  fs18.writeFileSync(npmrcPath, newContent);
77172
- console.log("Updated .npmrc with tscircuit registry");
77239
+ console.log(kleur_default.green("Updated .npmrc with tscircuit registry"));
77173
77240
  hasTsciRegistry = true;
77174
77241
  } else {
77175
77242
  console.log("Continuing without updating .npmrc; will fetch package directly from registry tarball.");
@@ -77182,11 +77249,11 @@ async function addPackage(packageSpec, projectDir = process.cwd()) {
77182
77249
  const packageManager = getPackageManager();
77183
77250
  try {
77184
77251
  packageManager.install({ name: installTarget, cwd: projectDir });
77185
- console.log(`Added ${displayName} successfully.`);
77252
+ console.log(kleur_default.green(`✓ Added ${kleur_default.bold(displayName)} successfully`));
77186
77253
  await detectAndSetupKicadLibrary(packageSpec, projectDir);
77187
77254
  } catch (error) {
77188
77255
  const errorMessage = error instanceof Error ? error.message : String(error);
77189
- console.error(`Failed to add ${displayName}:`, errorMessage);
77256
+ console.error(kleur_default.red(`✗ Failed to add ${displayName}:`), errorMessage);
77190
77257
  throw new Error(`Failed to add ${displayName}: ${errorMessage}`);
77191
77258
  }
77192
77259
  }
@@ -77207,9 +77274,7 @@ function getLocalPackages(projectDir) {
77207
77274
  try {
77208
77275
  const packageJson = JSON.parse(fs19.readFileSync(packageJsonPath, "utf-8"));
77209
77276
  const allDeps = {
77210
- ...packageJson.dependencies,
77211
- ...packageJson.devDependencies,
77212
- ...packageJson.peerDependencies
77277
+ ...packageJson.dependencies
77213
77278
  };
77214
77279
  for (const [packageName, version2] of Object.entries(allDeps)) {
77215
77280
  if (typeof version2 !== "string")
@@ -184385,9 +184450,13 @@ async function installProjectDependencies({
184385
184450
 
184386
184451
  // cli/install/register.ts
184387
184452
  var registerInstall = (program3) => {
184388
- program3.command("install").description("Install project dependencies and generate package.json if needed").action(async () => {
184453
+ program3.command("install [packageSpec]").description("Install project dependencies, or install a specific package (e.g., tsci install https://github.com/espressif/kicad-libraries)").action(async (packageSpec) => {
184389
184454
  try {
184390
- await installProjectDependencies();
184455
+ if (packageSpec) {
184456
+ await addPackage(packageSpec);
184457
+ } else {
184458
+ await installProjectDependencies();
184459
+ }
184391
184460
  } catch (error) {
184392
184461
  if (error instanceof Error) {
184393
184462
  console.error(error.message);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tscircuit/cli",
3
- "version": "0.1.588",
3
+ "version": "0.1.590",
4
4
  "main": "dist/main.js",
5
5
  "devDependencies": {
6
6
  "@babel/standalone": "^7.26.9",