@tamer4lynx/cli 0.0.12 → 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.
- package/dist/index.js +57 -13
- package/package.json +5 -3
package/dist/index.js
CHANGED
|
@@ -4462,11 +4462,19 @@ async function init() {
|
|
|
4462
4462
|
\u2705 Generated tamer.config.json at ${configPath}`);
|
|
4463
4463
|
const tamerTypesInclude = "node_modules/@tamer4lynx/tamer-*/src/**/*.d.ts";
|
|
4464
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
|
+
}
|
|
4465
4473
|
for (const tsconfigPath of tsconfigCandidates) {
|
|
4466
4474
|
if (!fs17.existsSync(tsconfigPath)) continue;
|
|
4467
4475
|
try {
|
|
4468
4476
|
const raw = fs17.readFileSync(tsconfigPath, "utf-8");
|
|
4469
|
-
const tsconfig =
|
|
4477
|
+
const tsconfig = parseTsconfigJson(raw);
|
|
4470
4478
|
const include = tsconfig.include ?? [];
|
|
4471
4479
|
const arr = Array.isArray(include) ? include : [include];
|
|
4472
4480
|
if (arr.some((p) => (typeof p === "string" ? p : "").includes("tamer-"))) continue;
|
|
@@ -5659,7 +5667,10 @@ ${podDeps.map((d) => `pod '${d.podName}', :path => '${d.absPath}'`).join("\n")}
|
|
|
5659
5667
|
// src/common/add.ts
|
|
5660
5668
|
import fs23 from "fs";
|
|
5661
5669
|
import path24 from "path";
|
|
5662
|
-
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);
|
|
5663
5674
|
var CORE_PACKAGES = [
|
|
5664
5675
|
"@tamer4lynx/tamer-app-shell",
|
|
5665
5676
|
"@tamer4lynx/tamer-screen",
|
|
@@ -5670,6 +5681,30 @@ var CORE_PACKAGES = [
|
|
|
5670
5681
|
"@tamer4lynx/tamer-icons"
|
|
5671
5682
|
];
|
|
5672
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
|
+
}
|
|
5673
5708
|
function detectPackageManager(cwd) {
|
|
5674
5709
|
const dir = path24.resolve(cwd);
|
|
5675
5710
|
if (fs23.existsSync(path24.join(dir, "pnpm-lock.yaml"))) return "pnpm";
|
|
@@ -5681,14 +5716,16 @@ function runInstall(cwd, packages, pm) {
|
|
|
5681
5716
|
const cmd = pm === "npm" ? "npm" : pm === "pnpm" ? "pnpm" : "bun";
|
|
5682
5717
|
execSync10(`${cmd} ${args.join(" ")}`, { stdio: "inherit", cwd });
|
|
5683
5718
|
}
|
|
5684
|
-
function addCore() {
|
|
5719
|
+
async function addCore() {
|
|
5685
5720
|
const { lynxProjectDir } = resolveHostPaths();
|
|
5686
5721
|
const pm = detectPackageManager(lynxProjectDir);
|
|
5687
|
-
console.log(`
|
|
5688
|
-
|
|
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);
|
|
5689
5726
|
console.log("\u2705 Core packages installed. Run `t4l link` to link native modules.");
|
|
5690
5727
|
}
|
|
5691
|
-
function add(packages = []) {
|
|
5728
|
+
async function add(packages = []) {
|
|
5692
5729
|
const list = Array.isArray(packages) ? packages : [];
|
|
5693
5730
|
if (list.length === 0) {
|
|
5694
5731
|
console.log("Usage: t4l add <package> [package...]");
|
|
@@ -5699,11 +5736,14 @@ function add(packages = []) {
|
|
|
5699
5736
|
}
|
|
5700
5737
|
const { lynxProjectDir } = resolveHostPaths();
|
|
5701
5738
|
const pm = detectPackageManager(lynxProjectDir);
|
|
5702
|
-
|
|
5703
|
-
|
|
5704
|
-
|
|
5705
|
-
|
|
5706
|
-
|
|
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`);
|
|
5707
5747
|
runInstall(lynxProjectDir, normalized, pm);
|
|
5708
5748
|
console.log("\u2705 Packages installed. Run `t4l link` to link native modules.");
|
|
5709
5749
|
}
|
|
@@ -5831,8 +5871,12 @@ program.command("build-dev-app").option("-p, --platform <platform>", "Platform:
|
|
|
5831
5871
|
await build_default2({ install: opts.install, release: false });
|
|
5832
5872
|
}
|
|
5833
5873
|
});
|
|
5834
|
-
program.command("add [packages...]").description("Add @tamer4lynx packages to the Lynx project. Future: will track versions for compatibility (Expo-style).").action((packages) =>
|
|
5835
|
-
|
|
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
|
+
});
|
|
5836
5880
|
program.command("codegen").description("Generate code from @lynxmodule declarations").action(() => {
|
|
5837
5881
|
codegen_default();
|
|
5838
5882
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tamer4lynx/cli",
|
|
3
|
-
"version": "0.0.
|
|
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
|
-
"
|
|
89
|
-
"
|
|
90
|
+
"semver": "^7.7.4",
|
|
91
|
+
"ws": "^8.19.0"
|
|
90
92
|
}
|
|
91
93
|
}
|