@tamer4lynx/cli 0.0.11 → 0.0.13

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/index.js +68 -18
  2. package/package.json +5 -3
package/dist/index.js CHANGED
@@ -9,11 +9,9 @@ process.on("warning", (w) => {
9
9
  // index.ts
10
10
  import fs24 from "fs";
11
11
  import path25 from "path";
12
+ import { fileURLToPath } from "url";
12
13
  import { program } from "commander";
13
14
 
14
- // package.json
15
- var version = "0.0.11";
16
-
17
15
  // src/android/create.ts
18
16
  import fs4 from "fs";
19
17
  import path4 from "path";
@@ -3522,7 +3520,6 @@ function getDevViewControllerSwift() {
3522
3520
  import Lynx
3523
3521
  import tamerdevclient
3524
3522
  import tamerinsets
3525
- import tamersystemui
3526
3523
 
3527
3524
  class ViewController: UIViewController {
3528
3525
  private var lynxView: LynxView?
@@ -3552,7 +3549,7 @@ class ViewController: UIViewController {
3552
3549
  TamerInsetsModule.reRequestInsets()
3553
3550
  }
3554
3551
 
3555
- override var preferredStatusBarStyle: UIStatusBarStyle { SystemUIModule.statusBarStyleForHost }
3552
+ override var preferredStatusBarStyle: UIStatusBarStyle { TamerPreferredStatusBar.style }
3556
3553
 
3557
3554
  private func setupLynxView() {
3558
3555
  let size = fullscreenBounds().size
@@ -4198,6 +4195,7 @@ $1`
4198
4195
  } else {
4199
4196
  console.log("\u2139\uFE0F No Tamer4Lynx native packages found.");
4200
4197
  }
4198
+ syncHost_default();
4201
4199
  updatePodfile(packages);
4202
4200
  ensureXElementPod();
4203
4201
  ensureLynxPatchInPodfile();
@@ -4464,11 +4462,19 @@ async function init() {
4464
4462
  \u2705 Generated tamer.config.json at ${configPath}`);
4465
4463
  const tamerTypesInclude = "node_modules/@tamer4lynx/tamer-*/src/**/*.d.ts";
4466
4464
  const tsconfigCandidates = lynxProject ? [path18.join(process.cwd(), lynxProject, "tsconfig.json"), path18.join(process.cwd(), "tsconfig.json")] : [path18.join(process.cwd(), "tsconfig.json")];
4465
+ function parseTsconfigJson(raw) {
4466
+ try {
4467
+ return JSON.parse(raw);
4468
+ } catch {
4469
+ const noTrailingCommas = raw.replace(/,\s*([\]}])/g, "$1");
4470
+ return JSON.parse(noTrailingCommas);
4471
+ }
4472
+ }
4467
4473
  for (const tsconfigPath of tsconfigCandidates) {
4468
4474
  if (!fs17.existsSync(tsconfigPath)) continue;
4469
4475
  try {
4470
4476
  const raw = fs17.readFileSync(tsconfigPath, "utf-8");
4471
- const tsconfig = JSON.parse(raw);
4477
+ const tsconfig = parseTsconfigJson(raw);
4472
4478
  const include = tsconfig.include ?? [];
4473
4479
  const arr = Array.isArray(include) ? include : [include];
4474
4480
  if (arr.some((p) => (typeof p === "string" ? p : "").includes("tamer-"))) continue;
@@ -5661,7 +5667,10 @@ ${podDeps.map((d) => `pod '${d.podName}', :path => '${d.absPath}'`).join("\n")}
5661
5667
  // src/common/add.ts
5662
5668
  import fs23 from "fs";
5663
5669
  import path24 from "path";
5664
- import { execSync as execSync10 } from "child_process";
5670
+ import { execFile, execSync as execSync10 } from "child_process";
5671
+ import { promisify } from "util";
5672
+ import semver from "semver";
5673
+ var execFileAsync = promisify(execFile);
5665
5674
  var CORE_PACKAGES = [
5666
5675
  "@tamer4lynx/tamer-app-shell",
5667
5676
  "@tamer4lynx/tamer-screen",
@@ -5672,6 +5681,30 @@ var CORE_PACKAGES = [
5672
5681
  "@tamer4lynx/tamer-icons"
5673
5682
  ];
5674
5683
  var PACKAGE_ALIASES = {};
5684
+ async function getHighestPublishedVersion(fullName) {
5685
+ try {
5686
+ const { stdout } = await execFileAsync("npm", ["view", fullName, "versions", "--json"], {
5687
+ maxBuffer: 10 * 1024 * 1024
5688
+ });
5689
+ const parsed = JSON.parse(stdout.trim());
5690
+ const list = Array.isArray(parsed) ? parsed : [parsed];
5691
+ const valid = list.filter((v) => typeof v === "string" && !!semver.valid(v));
5692
+ if (valid.length === 0) return null;
5693
+ return semver.rsort(valid)[0] ?? null;
5694
+ } catch {
5695
+ return null;
5696
+ }
5697
+ }
5698
+ async function normalizeTamerInstallSpec(pkg) {
5699
+ if (!pkg.startsWith("@tamer4lynx/")) return pkg;
5700
+ if (/^@[^/]+\/[^@]+@/.test(pkg)) return pkg;
5701
+ const highest = await getHighestPublishedVersion(pkg);
5702
+ if (highest) {
5703
+ return `${pkg}@${highest}`;
5704
+ }
5705
+ console.warn(`\u26A0\uFE0F Could not resolve published versions for ${pkg}; using @prerelease`);
5706
+ return `${pkg}@prerelease`;
5707
+ }
5675
5708
  function detectPackageManager(cwd) {
5676
5709
  const dir = path24.resolve(cwd);
5677
5710
  if (fs23.existsSync(path24.join(dir, "pnpm-lock.yaml"))) return "pnpm";
@@ -5683,14 +5716,16 @@ function runInstall(cwd, packages, pm) {
5683
5716
  const cmd = pm === "npm" ? "npm" : pm === "pnpm" ? "pnpm" : "bun";
5684
5717
  execSync10(`${cmd} ${args.join(" ")}`, { stdio: "inherit", cwd });
5685
5718
  }
5686
- function addCore() {
5719
+ async function addCore() {
5687
5720
  const { lynxProjectDir } = resolveHostPaths();
5688
5721
  const pm = detectPackageManager(lynxProjectDir);
5689
- console.log(`Adding core packages to ${lynxProjectDir} (using ${pm})...`);
5690
- runInstall(lynxProjectDir, CORE_PACKAGES, pm);
5722
+ console.log(`Resolving latest published versions (npm)\u2026`);
5723
+ const resolved = await Promise.all(CORE_PACKAGES.map(normalizeTamerInstallSpec));
5724
+ console.log(`Adding core packages to ${lynxProjectDir} (using ${pm})\u2026`);
5725
+ runInstall(lynxProjectDir, resolved, pm);
5691
5726
  console.log("\u2705 Core packages installed. Run `t4l link` to link native modules.");
5692
5727
  }
5693
- function add(packages = []) {
5728
+ async function add(packages = []) {
5694
5729
  const list = Array.isArray(packages) ? packages : [];
5695
5730
  if (list.length === 0) {
5696
5731
  console.log("Usage: t4l add <package> [package...]");
@@ -5701,16 +5736,27 @@ function add(packages = []) {
5701
5736
  }
5702
5737
  const { lynxProjectDir } = resolveHostPaths();
5703
5738
  const pm = detectPackageManager(lynxProjectDir);
5704
- const normalized = list.map((p) => {
5705
- if (p.startsWith("@")) return p;
5706
- return PACKAGE_ALIASES[p] ?? `@tamer4lynx/${p}`;
5707
- });
5708
- console.log(`Adding ${normalized.join(", ")} to ${lynxProjectDir} (using ${pm})...`);
5739
+ console.log(`Resolving latest published versions (npm)\u2026`);
5740
+ const normalized = await Promise.all(
5741
+ list.map(async (p) => {
5742
+ const spec = p.startsWith("@") ? p : PACKAGE_ALIASES[p] ?? `@tamer4lynx/${p}`;
5743
+ return normalizeTamerInstallSpec(spec);
5744
+ })
5745
+ );
5746
+ console.log(`Adding ${normalized.join(", ")} to ${lynxProjectDir} (using ${pm})\u2026`);
5709
5747
  runInstall(lynxProjectDir, normalized, pm);
5710
5748
  console.log("\u2705 Packages installed. Run `t4l link` to link native modules.");
5711
5749
  }
5712
5750
 
5713
5751
  // index.ts
5752
+ function readCliVersion() {
5753
+ const root = path25.dirname(fileURLToPath(import.meta.url));
5754
+ const here = path25.join(root, "package.json");
5755
+ const parent = path25.join(root, "..", "package.json");
5756
+ const pkgPath = fs24.existsSync(here) ? here : parent;
5757
+ return JSON.parse(fs24.readFileSync(pkgPath, "utf8")).version;
5758
+ }
5759
+ var version = readCliVersion();
5714
5760
  function validateDebugRelease(debug, release) {
5715
5761
  if (debug && release) {
5716
5762
  console.error("Cannot use --debug and --release together.");
@@ -5825,8 +5871,12 @@ program.command("build-dev-app").option("-p, --platform <platform>", "Platform:
5825
5871
  await build_default2({ install: opts.install, release: false });
5826
5872
  }
5827
5873
  });
5828
- program.command("add [packages...]").description("Add @tamer4lynx packages to the Lynx project. Future: will track versions for compatibility (Expo-style).").action((packages) => add(packages));
5829
- program.command("add-core").description("Add core packages (app-shell, screen, router, insets, transports, system-ui, icons)").action(() => addCore());
5874
+ program.command("add [packages...]").description("Add @tamer4lynx packages to the Lynx project. Future: will track versions for compatibility (Expo-style).").action(async (packages) => {
5875
+ await add(packages);
5876
+ });
5877
+ program.command("add-core").description("Add core packages (app-shell, screen, router, insets, transports, system-ui, icons)").action(async () => {
5878
+ await addCore();
5879
+ });
5830
5880
  program.command("codegen").description("Generate code from @lynxmodule declarations").action(() => {
5831
5881
  codegen_default();
5832
5882
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tamer4lynx/cli",
3
- "version": "0.0.11",
3
+ "version": "0.0.13",
4
4
  "module": "index.ts",
5
5
  "type": "module",
6
6
  "description": "A CLI tool for managing LynxJS native modules.",
@@ -66,6 +66,7 @@
66
66
  "@types/bun": "latest",
67
67
  "@types/node": "^24.1.0",
68
68
  "@types/node-fetch": "^2.6.13",
69
+ "@types/semver": "^7.7.1",
69
70
  "typescript": "^5.9.2"
70
71
  },
71
72
  "peerDependencies": {
@@ -83,9 +84,10 @@
83
84
  "chokidar": "^4.0.3",
84
85
  "commander": "^14.0.0",
85
86
  "dnssd-advertise": "^1.1.3",
87
+ "esbuild": "^0.24.2",
86
88
  "node-fetch": "^2.7.0",
87
89
  "qrcode-terminal": "^0.12.0",
88
- "ws": "^8.19.0",
89
- "esbuild": "^0.24.2"
90
+ "semver": "^7.7.4",
91
+ "ws": "^8.19.0"
90
92
  }
91
93
  }