-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8fd6497
commit 6d3305e
Showing
3 changed files
with
51 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,7 @@ on: | |
- '**/*' | ||
- '!README.md' | ||
- '!CONTRIBUTE.md' | ||
- 'versionCleanup.js' | ||
workflow_dispatch: | ||
|
||
jobs: | ||
|
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,28 @@ | ||
const { execSync } = require('child_process'); | ||
|
||
// Function to execute shell commands | ||
function execute(command) { | ||
return execSync(command, { encoding: 'utf-8' }); | ||
} | ||
|
||
// Get all package versions | ||
const packageVersions = execute('npm show <your-package-name> versions'); | ||
|
||
// Get all tagged versions | ||
const taggedVersions = execute('git tag').split('\n'); | ||
|
||
// Get all referenced versions | ||
const referencedVersions = execute('npm view <your-package-name> dependencies --json'); | ||
|
||
// Logic to find untagged and unreferenced versions | ||
const untaggedAndUnreferencedVersions = packageVersions.filter(version => { | ||
// Check if version is not tagged | ||
const isUntagged = !taggedVersions.includes(version.trim()); | ||
|
||
// Check if version is not referenced by another package | ||
const isUnreferenced = !Object.values(referencedVersions).flat().includes(version.trim()); | ||
|
||
return isUntagged && isUnreferenced; | ||
}); | ||
|
||
console.log('Untagged and Unreferenced Versions:', untaggedAndUnreferencedVersions); |
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,22 @@ | ||
name: Check Untagged Versions | ||
|
||
on: | ||
workflow_dispatch: # Trigger manually | ||
|
||
jobs: | ||
check_versions: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v2 | ||
|
||
- name: Set up Node.js | ||
uses: actions/setup-node@v2 | ||
with: | ||
node-version: '14' | ||
|
||
- name: Install dependencies | ||
run: npm install | ||
|
||
- name: Run the script | ||
run: node checkVersions.js |