inai-react-components 2.0.1 → 2.0.3

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":"AAsBA,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,CA+MvB;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"}
1
+ {"version":3,"file":"update.d.ts","sourceRoot":"","sources":["../../src/commands/update.ts"],"names":[],"mappings":"AA2BA,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,CA6NvB;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"}
@@ -7,7 +7,7 @@ import diff3Merge from "diff3";
7
7
  import { readComponentsJson, readRegistryJson, } from "./status.js";
8
8
  import { findComponentInRegistry, computeDiff } from "./diff.js";
9
9
  import { resolveRegistryDir } from "../utils/registry-resolver.js";
10
- import { resolveLocalDir } from "../utils/paths.js";
10
+ import { resolveLocalDir, rewriteCompanyUiImports, rewriteLibImports, stripRelativeJsExtensions, } from "../utils/paths.js";
11
11
  import { loadSnapshot, saveSnapshot, sha256, } from "../utils/snapshot.js";
12
12
  /**
13
13
  * Run a 3-way line merge between base (snapshot), mine (local) and theirs
@@ -88,7 +88,21 @@ export async function runUpdate(componentName, rootDir, skipPrompts = false) {
88
88
  if (!fs.existsSync(registryFilePath)) {
89
89
  continue;
90
90
  }
91
- const registryContent = fs.readFileSync(registryFilePath, "utf-8");
91
+ // Normalize imports in the registry content the same way `add.ts` does so
92
+ // that update produces the same on-disk shape as a fresh install:
93
+ // 1. rewriteLibImports — unifies `./lib/cn.js` / `../lib/cn.js` /
94
+ // `@company/ui/lib/cn` onto the consumer's `aliases.lib` alias.
95
+ // 2. rewriteCompanyUiImports — rewrites `@company/ui/<name>` references
96
+ // (used by blocks/templates) to the consumer's components alias.
97
+ // 3. stripRelativeJsExtensions — drops the `.js` suffix the source uses
98
+ // for NodeNext resolution; bundler resolution doesn't need it.
99
+ // Without this step, `update` would write the raw source layout (`./lib/cn.js`)
100
+ // into the consumer, breaking their build because `lib/` lives at a different
101
+ // path in their tree (see consumer's aliases.lib).
102
+ const rawRegistryContent = fs.readFileSync(registryFilePath, "utf-8");
103
+ let registryContent = rewriteLibImports(rawRegistryContent, componentsJson);
104
+ registryContent = rewriteCompanyUiImports(registryContent, componentsJson);
105
+ registryContent = stripRelativeJsExtensions(registryContent);
92
106
  if (!fs.existsSync(localFilePath)) {
93
107
  // File does not exist locally -- install it
94
108
  const dir = path.dirname(localFilePath);
package/dist/index.js CHANGED
File without changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "inai-react-components",
3
- "version": "2.0.1",
3
+ "version": "2.0.3",
4
4
  "description": "CLI for InAI UI component library — install components from a private registry into your React project",
5
5
  "private": false,
6
6
  "type": "module",
@@ -28,14 +28,6 @@
28
28
  "files": [
29
29
  "dist"
30
30
  ],
31
- "scripts": {
32
- "build": "tsc && pnpm run copy-schemas",
33
- "copy-schemas": "node -e \"require('fs').cpSync('src/schemas', 'dist/schemas', {recursive: true})\"",
34
- "dev": "tsc --watch",
35
- "check-types": "tsc --noEmit",
36
- "test": "vitest run",
37
- "prepublishOnly": "pnpm run build && pnpm run test"
38
- },
39
31
  "dependencies": {
40
32
  "@modelcontextprotocol/sdk": "^1.29.0",
41
33
  "chalk": "^5.6.2",
@@ -46,10 +38,17 @@
46
38
  "prompts": "^2.4.2"
47
39
  },
48
40
  "devDependencies": {
49
- "@repo/typescript-config": "workspace:*",
50
41
  "@types/diff": "^8.0.0",
51
42
  "@types/node": "^22.15.3",
52
43
  "typescript": "5.9.2",
53
- "vitest": "^4.1.0"
44
+ "vitest": "^4.1.0",
45
+ "@repo/typescript-config": "0.0.0"
46
+ },
47
+ "scripts": {
48
+ "build": "tsc && pnpm run copy-schemas",
49
+ "copy-schemas": "node -e \"require('fs').cpSync('src/schemas', 'dist/schemas', {recursive: true})\"",
50
+ "dev": "tsc --watch",
51
+ "check-types": "tsc --noEmit",
52
+ "test": "vitest run"
54
53
  }
55
- }
54
+ }