Skip to content

Commit 5d94a48

Browse files
committed
feat: added script to update angular-sdk-components local dependency
1 parent cc09253 commit 5d94a48

File tree

2 files changed

+60
-0
lines changed

2 files changed

+60
-0
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
"test": "node ./scripts/playwright-message.js && playwright test --project=chromium MediaCo/portal MediaCo/embedded",
4242
"test:headed": "playwright test --headed --project=chromium MediaCo/portal MediaCo/embedded",
4343
"test-report": "playwright show-report",
44+
"update:dependencies": "node scripts/update-dependencies.js",
4445
"_comment_internal_SDK_scripts": "The following commands are for internal use and are intended to be called only from public scripts above",
4546
"_internal-compress-angularsdk": "node ./scripts/compress-with-assets.mjs",
4647
"_internal-build-dev-only": "shx rm -rf ./dist && ng build --configuration development && npm run _internal-copy-index",

scripts/update-dependencies.js

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
const { execSync } = require('child_process');
2+
const path = require('path');
3+
const fs = require('fs');
4+
const readline = require('readline');
5+
6+
try {
7+
const angularSdkPath = process.cwd();
8+
console.log(`angular-sdk path: ${angularSdkPath}`);
9+
10+
// Create readline interface to ask for angular-sdk-components path
11+
const rl = readline.createInterface({
12+
input: process.stdin,
13+
output: process.stdout
14+
});
15+
16+
rl.question('Please enter the absolute path of angular-sdk-components project: ', componentsProjectPathInput => {
17+
rl.close();
18+
const componentsProjectPath = path.resolve(componentsProjectPathInput);
19+
const distDir = path.join(componentsProjectPath, 'dist', 'angular-sdk-components');
20+
21+
// Delete existing dist folder before build
22+
if (fs.existsSync(distDir)) {
23+
console.log(`---- Removing existing dist folder: ${distDir} ----`);
24+
fs.rmSync(distDir, { recursive: true, force: true });
25+
}
26+
27+
console.log(`---- Building angular-sdk-components at: ${componentsProjectPath} ----`);
28+
execSync(`cd ${componentsProjectPath} && ng build angular-sdk-components`, { stdio: 'inherit' });
29+
30+
console.log(`---- Packing npm package in: ${distDir} ----`);
31+
execSync(`cd ${distDir} && npm pack`, { stdio: 'inherit' });
32+
33+
// Find the generated .tgz file
34+
const tgzFile = fs.readdirSync(distDir).find(file => file.endsWith('.tgz'));
35+
if (!tgzFile) {
36+
throw new Error('No .tgz file found in dist folder!');
37+
}
38+
39+
const tgzPath = path.join(distDir, tgzFile);
40+
const targetPath = path.join(angularSdkPath, tgzFile);
41+
42+
// Delete old .tgz file if exists in angular-sdk folder
43+
const existingTgz = fs.readdirSync(angularSdkPath).find(file => file.endsWith('.tgz'));
44+
if (existingTgz) {
45+
console.log(`---- Removing old package: ${existingTgz} ----`);
46+
fs.unlinkSync(path.join(angularSdkPath, existingTgz));
47+
}
48+
49+
console.log(`---- Copying ${tgzFile} to angular-sdk folder: ${angularSdkPath} ----`);
50+
fs.copyFileSync(tgzPath, targetPath);
51+
52+
console.log('---- Installing package in angular-sdk ----');
53+
execSync(`cd ${angularSdkPath} && npm install ./${tgzFile}`, { stdio: 'inherit' });
54+
console.log("Done!!! 'angular-sdk' now uses local build of angular-sdk-components.");
55+
});
56+
} catch (error) {
57+
console.error('Error:', error.message);
58+
process.exit(1);
59+
}

0 commit comments

Comments
 (0)