inai-react-components 2.0.4 → 2.0.6
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"update.d.ts","sourceRoot":"","sources":["../../src/commands/update.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"update.d.ts","sourceRoot":"","sources":["../../src/commands/update.ts"],"names":[],"mappings":"AA6BA,MAAM,WAAW,YAAY;IAC3B,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,+DAA+D;IAC/D,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;IACvB,2EAA2E;IAC3E,eAAe,CAAC,EAAE,MAAM,EAAE,CAAC;CAC5B;AAED,MAAM,WAAW,YAAY;IAC3B,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,EAAE,OAAO,CAAC;IACtB,aAAa,EAAE,MAAM,CAAC;CACvB;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAC3B,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,GACb,YAAY,CA4Cd;AAED,wBAAsB,SAAS,CAC7B,aAAa,EAAE,MAAM,EACrB,OAAO,EAAE,MAAM,EACf,WAAW,UAAQ,GAClB,OAAO,CAAC,YAAY,CAAC,CAqSvB;AAED,wBAAsB,aAAa,CACjC,aAAa,CAAC,EAAE,MAAM,EACtB,OAAO,CAAC,EAAE;IAAE,GAAG,CAAC,EAAE,OAAO,CAAA;CAAE,GAC1B,OAAO,CAAC,IAAI,CAAC,CAiDf"}
|
package/dist/commands/update.js
CHANGED
|
@@ -8,7 +8,7 @@ import { readComponentsJson, readRegistryJson, } from "./status.js";
|
|
|
8
8
|
import { findComponentInRegistry, computeDiff } from "./diff.js";
|
|
9
9
|
import { getTargetDir } from "./add.js";
|
|
10
10
|
import { resolveRegistryDir } from "../utils/registry-resolver.js";
|
|
11
|
-
import { rewriteCompanyUiImports, rewriteLibImports, stripRelativeJsExtensions, } from "../utils/paths.js";
|
|
11
|
+
import { rewriteCompanyUiImports, rewriteLibImports, stripRelativeJsExtensions, resolveLocalDir, getSourceRoot, } from "../utils/paths.js";
|
|
12
12
|
import { loadSnapshot, saveSnapshot, sha256, } from "../utils/snapshot.js";
|
|
13
13
|
/**
|
|
14
14
|
* Run a 3-way line merge between base (snapshot), mine (local) and theirs
|
|
@@ -236,6 +236,50 @@ export async function runUpdate(componentName, rootDir, skipPrompts = false) {
|
|
|
236
236
|
};
|
|
237
237
|
}
|
|
238
238
|
}
|
|
239
|
+
// Sync internal deps (lib/cn, lib/animations, lib/i18n-*, …). add.ts copies
|
|
240
|
+
// these on install, but update used to skip them — which meant any change to
|
|
241
|
+
// `lib/*.ts` (e.g. new i18n keys) never propagated, even though the
|
|
242
|
+
// component itself imports from there. We mirror add.ts's lookup + rewrite
|
|
243
|
+
// logic but overwrite unconditionally: lib files are canonical library code,
|
|
244
|
+
// not user-owned (the user's own `utils.ts` lives behind `aliases.utils`).
|
|
245
|
+
const libDirRaw = componentsJson.aliases.lib;
|
|
246
|
+
const libDir = libDirRaw
|
|
247
|
+
? resolveLocalDir(libDirRaw, componentsJson)
|
|
248
|
+
: `${getSourceRoot(componentsJson)}/lib`;
|
|
249
|
+
for (const dep of registryComponent.internalDeps) {
|
|
250
|
+
const depBase = dep.split("/").pop();
|
|
251
|
+
const tsSource = path.join(registryDir, "packages", "ui", "src", dep + ".ts");
|
|
252
|
+
const tsxSource = path.join(registryDir, "packages", "ui", "src", dep + ".tsx");
|
|
253
|
+
let depSourcePath;
|
|
254
|
+
let depFileName;
|
|
255
|
+
if (fs.existsSync(tsSource)) {
|
|
256
|
+
depSourcePath = tsSource;
|
|
257
|
+
depFileName = `${depBase}.ts`;
|
|
258
|
+
}
|
|
259
|
+
else if (fs.existsSync(tsxSource)) {
|
|
260
|
+
depSourcePath = tsxSource;
|
|
261
|
+
depFileName = `${depBase}.tsx`;
|
|
262
|
+
}
|
|
263
|
+
else {
|
|
264
|
+
continue;
|
|
265
|
+
}
|
|
266
|
+
let depContent = fs.readFileSync(depSourcePath, "utf-8");
|
|
267
|
+
depContent = rewriteLibImports(depContent, componentsJson);
|
|
268
|
+
depContent = rewriteCompanyUiImports(depContent, componentsJson);
|
|
269
|
+
depContent = stripRelativeJsExtensions(depContent);
|
|
270
|
+
const depTargetPath = path.join(rootDir, libDir, depFileName);
|
|
271
|
+
if (fs.existsSync(depTargetPath)) {
|
|
272
|
+
const existing = fs.readFileSync(depTargetPath, "utf-8");
|
|
273
|
+
if (existing === depContent) {
|
|
274
|
+
continue;
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
fs.mkdirSync(path.dirname(depTargetPath), { recursive: true });
|
|
278
|
+
fs.writeFileSync(depTargetPath, depContent);
|
|
279
|
+
updatedFiles.push(path.join(libDir, depFileName));
|
|
280
|
+
cleanMerges.push(path.join(libDir, depFileName));
|
|
281
|
+
needsUpdate = true;
|
|
282
|
+
}
|
|
239
283
|
if (!needsUpdate) {
|
|
240
284
|
return {
|
|
241
285
|
updated: false,
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
import { readFileSync } from "node:fs";
|
|
3
|
+
import { dirname, join } from "node:path";
|
|
4
|
+
import { fileURLToPath } from "node:url";
|
|
2
5
|
import { Command } from "commander";
|
|
3
6
|
import { addCommand } from "./commands/add.js";
|
|
4
7
|
import { initCommand } from "./commands/init.js";
|
|
@@ -16,11 +19,25 @@ import { registriesListCommand, registriesAddCommand, registriesRemoveCommand, }
|
|
|
16
19
|
import { removeCommand } from "./commands/remove.js";
|
|
17
20
|
import { generateBlockCommand } from "./commands/generate.js";
|
|
18
21
|
import { manifestCommand } from "./commands/manifest.js";
|
|
22
|
+
// Read the CLI version dynamically from package.json so it never drifts from
|
|
23
|
+
// what npm publishes. `dist/index.js` lives at `dist/`, so package.json is one
|
|
24
|
+
// level up.
|
|
25
|
+
function readCliVersion() {
|
|
26
|
+
try {
|
|
27
|
+
const here = dirname(fileURLToPath(import.meta.url));
|
|
28
|
+
const pkgPath = join(here, "..", "package.json");
|
|
29
|
+
const pkg = JSON.parse(readFileSync(pkgPath, "utf-8"));
|
|
30
|
+
return pkg.version ?? "0.0.0";
|
|
31
|
+
}
|
|
32
|
+
catch {
|
|
33
|
+
return "0.0.0";
|
|
34
|
+
}
|
|
35
|
+
}
|
|
19
36
|
const program = new Command();
|
|
20
37
|
program
|
|
21
38
|
.name("inai-ui")
|
|
22
39
|
.description("CLI for InAI UI component library")
|
|
23
|
-
.version(
|
|
40
|
+
.version(readCliVersion());
|
|
24
41
|
program
|
|
25
42
|
.command("init [repo-url]")
|
|
26
43
|
.description("Initialize InAI UI in your project. Optionally pass a Git repo URL to fetch components remotely.")
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registry-resolver.d.ts","sourceRoot":"","sources":["../../src/utils/registry-resolver.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,QAAQ,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAC;AAS7E,wBAAgB,WAAW,IAAI,MAAM,CAEpC;AAED,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAExD;AAsED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAiBrD;AAmBD;;;;;;;;;;;;GAYG;AACH,wBAAsB,eAAe,CACnC,QAAQ,EAAE,QAAQ,EAClB,UAAU,EAAE,MAAM,EAClB,OAAO,GAAE,sBAA2B,GACnC,OAAO,CAAC,MAAM,CAAC,CA+FjB;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,
|
|
1
|
+
{"version":3,"file":"registry-resolver.d.ts","sourceRoot":"","sources":["../../src/utils/registry-resolver.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,QAAQ,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAC;AAS7E,wBAAgB,WAAW,IAAI,MAAM,CAEpC;AAED,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAExD;AAsED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAiBrD;AAmBD;;;;;;;;;;;;GAYG;AACH,wBAAsB,eAAe,CACnC,QAAQ,EAAE,QAAQ,EAClB,UAAU,EAAE,MAAM,EAClB,OAAO,GAAE,sBAA2B,GACnC,OAAO,CAAC,MAAM,CAAC,CA+FjB;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,CAoB7D"}
|
|
@@ -228,6 +228,18 @@ export function resolveRegistryDir(projectDir) {
|
|
|
228
228
|
if (!fs.existsSync(path.join(LEGACY_CACHE_DIR, ".git"))) {
|
|
229
229
|
cloneRegistry(componentsJson.registrySource);
|
|
230
230
|
}
|
|
231
|
+
else if (process.env.INAI_UI_OFFLINE !== "1") {
|
|
232
|
+
// The cache exists — refresh it against origin so callers don't see a
|
|
233
|
+
// stale snapshot. Without this, `update`/`add`/`status` could report
|
|
234
|
+
// "already up to date" against a registry HEAD that's days behind npm
|
|
235
|
+
// (the exact bug that motivated this code path in v2.0.6).
|
|
236
|
+
//
|
|
237
|
+
// `refreshGitCache` fast-forwards in the happy path and resets hard
|
|
238
|
+
// if the local cache diverged. Failures are silent on purpose: the
|
|
239
|
+
// user might be offline, and a stale cache is more useful than a
|
|
240
|
+
// hard error here.
|
|
241
|
+
refreshGitCache(LEGACY_CACHE_DIR);
|
|
242
|
+
}
|
|
231
243
|
return LEGACY_CACHE_DIR;
|
|
232
244
|
}
|
|
233
245
|
return projectDir;
|
package/package.json
CHANGED