@ts-for-gir/cli 4.0.0-rc.13 → 4.0.0-rc.14

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/bin/ts-for-gir CHANGED
@@ -7268,7 +7268,7 @@ import { dirname, join } from "node:path";
7268
7268
  import { fileURLToPath } from "node:url";
7269
7269
  function getPackageVersion() {
7270
7270
  if (true) {
7271
- return "4.0.0-rc.13";
7271
+ return "4.0.0-rc.14";
7272
7272
  }
7273
7273
  const currentModulePath = fileURLToPath(import.meta.url);
7274
7274
  const currentDir = dirname(currentModulePath);
@@ -8165,7 +8165,7 @@ import { fileURLToPath as fileURLToPath2 } from "node:url";
8165
8165
  var NEW_LINE_REG_EXP = /[\n\r]+/g;
8166
8166
  function getPackageVersion2() {
8167
8167
  if (true) {
8168
- return "4.0.0-rc.13";
8168
+ return "4.0.0-rc.14";
8169
8169
  }
8170
8170
  try {
8171
8171
  const currentModulePath = fileURLToPath2(import.meta.url);
@@ -22492,7 +22492,7 @@ var copy = {
22492
22492
 
22493
22493
  // src/commands/create.ts
22494
22494
  import { spawnSync } from "node:child_process";
22495
- import { cpSync, existsSync as existsSync3, mkdirSync, readdirSync, readFileSync as readFileSync4, writeFileSync as writeFileSync2 } from "node:fs";
22495
+ import { cpSync, existsSync as existsSync3, mkdirSync, readdirSync, readFileSync as readFileSync4, realpathSync, writeFileSync as writeFileSync2 } from "node:fs";
22496
22496
  import { dirname as dirname6, join as join9, resolve as resolve5 } from "node:path";
22497
22497
  import { fileURLToPath as fileURLToPath4 } from "node:url";
22498
22498
  import { input, select as select2 } from "@inquirer/prompts";
@@ -22530,19 +22530,34 @@ var builder3 = createBuilder(createOptions, examples3);
22530
22530
  function findTemplatesRoot() {
22531
22531
  const __filename = fileURLToPath4(import.meta.url);
22532
22532
  const __dirname3 = dirname6(__filename);
22533
+ let realDirname = __dirname3;
22534
+ try {
22535
+ realDirname = dirname6(realpathSync(__filename));
22536
+ } catch {
22537
+ }
22533
22538
  const candidates = [
22534
- // Bundled production binary (bin/ts-for-gir): ../dist-templates
22539
+ // Symlink-resolved binary (`npm i -g` / `gjsify install -g`): the
22540
+ // realpath-aware candidate is required when the CLI is launched via a
22541
+ // `~/.local/bin/<name>` symlink that points at the real package's
22542
+ // `bin/<name>`. Try it first so the success path is symmetric across
22543
+ // install modes.
22544
+ resolve5(realDirname, "..", "dist-templates"),
22545
+ // Bundled production binary invoked at its real path (no symlink),
22546
+ // or a tarball extracted into a flat `bin/` + `dist-templates/` layout.
22535
22547
  resolve5(__dirname3, "..", "dist-templates"),
22536
22548
  // Source layout (src/commands/create.ts): ../../dist-templates then ../../templates
22537
22549
  resolve5(__dirname3, "..", "..", "dist-templates"),
22538
22550
  resolve5(__dirname3, "..", "..", "templates")
22539
22551
  ];
22552
+ const seen = /* @__PURE__ */ new Set();
22540
22553
  for (const path of candidates) {
22554
+ if (seen.has(path)) continue;
22555
+ seen.add(path);
22541
22556
  if (existsSync3(path)) return path;
22542
22557
  }
22543
22558
  throw new Error(
22544
22559
  `Could not locate templates directory. Looked in:
22545
- ${candidates.join("\n ")}
22560
+ ${[...seen].join("\n ")}
22546
22561
  If you are running from source, make sure packages/cli/templates/ exists. If you are running the published CLI, make sure dist-templates/ was packed.`
22547
22562
  );
22548
22563
  }
@@ -22581,16 +22596,21 @@ function walkAndSubstitute(rootDir, projectName) {
22581
22596
  }
22582
22597
  }
22583
22598
  var handler3 = async (args) => {
22584
- if (typeof __GJS_BUNDLE__ !== "undefined") {
22585
- process.stderr.write(
22586
- "The 'create' command is not yet supported in the GJS bundle.\nUse Node.js instead: npx @ts-for-gir/cli create ...\n"
22587
- );
22588
- process.exitCode = 1;
22589
- return;
22590
- }
22591
22599
  const opts = args;
22592
22600
  const log3 = new Logger(opts.verbose ?? false, "CreateCommand");
22593
- const templatesRoot = findTemplatesRoot();
22601
+ let templatesRoot;
22602
+ try {
22603
+ templatesRoot = findTemplatesRoot();
22604
+ } catch (err) {
22605
+ if (typeof __GJS_BUNDLE__ !== "undefined") {
22606
+ process.stderr.write(
22607
+ "The 'create' command needs templates that aren't shipped alongside this binary.\nInstall the full package instead so `dist-templates/` lives next to the bin:\n gjsify install -g @ts-for-gir/cli\n npm install -g @ts-for-gir/cli\n npx @ts-for-gir/cli create ... # one-shot, no install\n"
22608
+ );
22609
+ process.exitCode = 1;
22610
+ return;
22611
+ }
22612
+ throw err;
22613
+ }
22594
22614
  const available = listTemplates(templatesRoot);
22595
22615
  if (available.length === 0) {
22596
22616
  throw new Error(`No templates found in ${templatesRoot}`);
@@ -27775,10 +27795,14 @@ import { fileURLToPath as fileURLToPath5 } from "node:url";
27775
27795
  import { i18n, JSX as JSX8, ReflectionKind as ReflectionKind5 } from "typedoc";
27776
27796
  function getTsForGirVersion() {
27777
27797
  if (true) {
27778
- return "4.0.0-rc.13";
27798
+ return "4.0.0-rc.14";
27799
+ }
27800
+ try {
27801
+ const __dirname3 = dirname8(fileURLToPath5(import.meta.url));
27802
+ return JSON.parse(readFileSync7(join14(__dirname3, "..", "..", "package.json"), "utf8")).version;
27803
+ } catch {
27804
+ return "";
27779
27805
  }
27780
- const __dirname3 = dirname8(fileURLToPath5(import.meta.url));
27781
- return JSON.parse(readFileSync7(join14(__dirname3, "..", "..", "package.json"), "utf8")).version;
27782
27806
  }
27783
27807
  var TSFOR_GIR_VERSION = getTsForGirVersion();
27784
27808
  function giDocgenModuleInfo(context, mod, nsMeta) {