Skip to content

Commit 513e31f

Browse files
authored
[angular] Use published version of dependency (#314)
1 parent 78e8bf8 commit 513e31f

File tree

2 files changed

+47
-1
lines changed

2 files changed

+47
-1
lines changed

renderers/angular/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "@a2ui/angular",
33
"version": "0.8.1",
44
"scripts": {
5-
"build": "ng build"
5+
"build": "ng build && node postprocess-build.mjs"
66
},
77
"dependencies": {
88
"@a2ui/lit": "file:../lit",
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
/*
2+
Copyright 2025 Google LLC
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
https://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
import { readFileSync, writeFileSync } from 'fs';
18+
import { join } from 'path';
19+
20+
// Locally we depend on the Lit package via a relative path so we can test it from source.
21+
// This breaks when published to npm so the following script updates the version to the npm one.
22+
23+
const dirname = import.meta.dirname;
24+
const litVersion = parsePackageJson(join(dirname, '../lit/package.json')).version;
25+
26+
if (!litVersion) {
27+
throw new Error('Cannot determine version of Lit package');
28+
}
29+
30+
const packageJsonPath = join(dirname, './dist/package.json');
31+
const packageJson = parsePackageJson(packageJsonPath);
32+
33+
if (!packageJson.dependencies['@a2ui/lit']) {
34+
throw new Error(
35+
'Angular package does not depend on the Lit library. ' +
36+
'Either update the package.json or remove this script.',
37+
);
38+
}
39+
40+
packageJson.dependencies['@a2ui/lit'] = '^' + litVersion;
41+
writeFileSync(packageJsonPath, JSON.stringify(packageJson, undefined, 2));
42+
43+
function parsePackageJson(path) {
44+
const content = readFileSync(path, 'utf8');
45+
return JSON.parse(content);
46+
}

0 commit comments

Comments
 (0)