Skip to content

Commit 678eae3

Browse files
authored
Merge pull request #23 from dev-phantom/cicd
fix(publish): replace file: dependencies with version numbers
2 parents a2e94d0 + 56b8991 commit 678eae3

1 file changed

Lines changed: 27 additions & 0 deletions

File tree

scripts/publish-packages.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#!/usr/bin/env node
22

33
const { execSync } = require('child_process');
4+
const fs = require('fs');
45
const path = require('path');
56

67
console.log('📦 Publishing JetStart packages to npm...\n');
@@ -11,12 +12,35 @@ const packages = [
1112
{ name: '@jetstart/cli', dir: 'packages/cli' }
1213
];
1314

15+
// Get the current version from root package.json
16+
const rootPkg = JSON.parse(fs.readFileSync(path.join(__dirname, '../package.json'), 'utf8'));
17+
const version = rootPkg.version;
18+
1419
for (const pkg of packages) {
1520
console.log(`\n🚀 Publishing ${pkg.name}...`);
1621

1722
try {
1823
const pkgPath = path.join(__dirname, '..', pkg.dir);
24+
const pkgJsonPath = path.join(pkgPath, 'package.json');
25+
26+
// Read package.json
27+
const pkgJson = JSON.parse(fs.readFileSync(pkgJsonPath, 'utf8'));
28+
const originalPkgJson = JSON.stringify(pkgJson, null, 2);
29+
30+
// Replace file: dependencies with version numbers
31+
if (pkgJson.dependencies) {
32+
for (const [depName, depVersion] of Object.entries(pkgJson.dependencies)) {
33+
if (depVersion.startsWith('file:')) {
34+
pkgJson.dependencies[depName] = `^${version}`;
35+
console.log(` → Updated ${depName}: ${depVersion} → ^${version}`);
36+
}
37+
}
38+
}
1939

40+
// Write updated package.json
41+
fs.writeFileSync(pkgJsonPath, JSON.stringify(pkgJson, null, 2) + '\n');
42+
43+
// Publish
2044
execSync('npm publish --access public', {
2145
cwd: pkgPath,
2246
stdio: 'inherit',
@@ -26,6 +50,9 @@ for (const pkg of packages) {
2650
}
2751
});
2852

53+
// Restore original package.json
54+
fs.writeFileSync(pkgJsonPath, originalPkgJson + '\n');
55+
2956
console.log(`✅ Successfully published ${pkg.name}`);
3057
} catch (error) {
3158
console.error(`❌ Failed to publish ${pkg.name}`);

0 commit comments

Comments
 (0)