forked from blocknative/web3-onboard
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Issue-16] Update automation scripts
- Loading branch information
Showing
4 changed files
with
79 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
const glob = require('glob'); | ||
const execa = require('execa'); | ||
const path = require('path'); | ||
|
||
const prefix = '@subwallet-connect'; | ||
|
||
// Function to publish a package | ||
async function publishPackage(packagePath) { | ||
try { | ||
const { stdout } = await execa('npm', ['publish', '--access', 'public'], { cwd: packagePath }); | ||
console.log(stdout); | ||
} catch (error) { | ||
console.error(`Failed to publish package at ${packagePath}:`, error.stderr); | ||
} | ||
} | ||
|
||
// Find and publish all packages with the specified prefix | ||
glob('packages/*/package.json', async (err, files) => { | ||
if (err) { | ||
return console.error('Error finding package.json files:', err); | ||
} | ||
|
||
for (const file of files) { | ||
const packageJsonPath = path.resolve(file); | ||
const packageJson = require(packageJsonPath); | ||
|
||
if (packageJson.name && packageJson.name.startsWith(prefix)) { | ||
console.log(`Publishing ${packageJson.name}...`); | ||
await publishPackage(path.dirname(packageJsonPath)); | ||
} | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
const jsonfile = require('jsonfile'); | ||
const glob = require('glob'); | ||
const path = require('path'); | ||
|
||
// This function reads all package.json files to collect package names | ||
async function getAllPackageNames() { | ||
return new Promise((resolve, reject) => { | ||
glob('packages/*/package.json', async (err, files) => { | ||
if (err) { | ||
reject('Error finding package.json files:', err); | ||
return; | ||
} | ||
|
||
const packageNames = []; | ||
for (const file of files) { | ||
try { | ||
const packageJson = await jsonfile.readFile(path.resolve(file)); | ||
packageNames.push(packageJson.name); | ||
} catch (error) { | ||
console.error(`Error reading ${file}:`, error); | ||
} | ||
} | ||
resolve(packageNames); | ||
}); | ||
}); | ||
} | ||
|
||
module.exports = { | ||
getAllPackageNames | ||
} |