-
-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a script to check/update the latest and next tags. (#4899)
This just prints out the commands that should be run right now, so they can be verified by hand.
- Loading branch information
1 parent
56de6c0
commit 485ad61
Showing
2 changed files
with
83 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 |
---|---|---|
@@ -0,0 +1,82 @@ | ||
/*----------------------------------------------------------------------------- | ||
| Copyright (c) Jupyter Development Team. | ||
| Distributed under the terms of the Modified BSD License. | ||
|----------------------------------------------------------------------------*/ | ||
|
||
import * as path from 'path'; | ||
import * as childProcess from 'child_process'; | ||
import * as utils from './utils'; | ||
|
||
// Handle the packages | ||
utils.getLernaPaths().forEach(pkgPath => { | ||
handlePackage(pkgPath); | ||
}); | ||
handlePackage(path.resolve('.')); | ||
|
||
/** | ||
* Handle an individual package on the path - update the dependency. | ||
*/ | ||
function handlePackage(packagePath: string): void { | ||
let cmd: string; | ||
|
||
// Read in the package.json. | ||
packagePath = path.join(packagePath, 'package.json'); | ||
let data: any; | ||
try { | ||
data = utils.readJSONFile(packagePath); | ||
} catch (e) { | ||
console.log('Skipping package ' + packagePath); | ||
return; | ||
} | ||
|
||
if (data.private) { | ||
return; | ||
} | ||
|
||
const pkg = data.name; | ||
|
||
cmd = `npm view ${pkg} versions --json`; | ||
const versions: string[] = JSON.parse( | ||
String(childProcess.execSync(cmd)).trim() | ||
); | ||
|
||
// Find latest stable | ||
versions.reverse(); | ||
let prerelease = versions.find(v => !!v.match(/-\d$/)); | ||
let stable = versions.find(v => !v.match(/-\d$/)); | ||
|
||
// Make sure the prerelease we found is *after* the stable release | ||
if ( | ||
prerelease && | ||
stable && | ||
versions.indexOf(prerelease) > versions.indexOf(stable) | ||
) { | ||
prerelease = undefined; | ||
} | ||
|
||
cmd = `npm dist-tag list ${pkg}`; | ||
let tags = String(childProcess.execSync(cmd)) | ||
.trim() | ||
.split('\n'); | ||
|
||
console.log(); | ||
console.log(pkg, stable, prerelease, tags); | ||
|
||
let stableCmd: string; | ||
let prereleaseCmd: string; | ||
|
||
if (stable) { | ||
stableCmd = `npm dist-tag add ${pkg}@${stable} latest`; | ||
} else { | ||
stableCmd = `npm dist-tag rm ${pkg} latest`; | ||
} | ||
|
||
if (prerelease) { | ||
prereleaseCmd = `npm dist-tag add ${pkg}@${prerelease} next`; | ||
} else { | ||
prereleaseCmd = `npm dist-tag rm ${pkg} next`; | ||
} | ||
|
||
console.log(stableCmd); | ||
console.log(prereleaseCmd); | ||
} |
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