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
Showing
5 changed files
with
81 additions
and
4 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,62 @@ | ||
#!/usr/bin/env node | ||
|
||
const fs = require("fs"); | ||
const cp = require("child_process"); | ||
const ARGUMENTS = process.argv.slice(2); | ||
|
||
const versions = { | ||
patch: "patch", | ||
minor: "minor", | ||
major: "major" | ||
}; | ||
|
||
if (!ARGUMENTS[0]) { | ||
console.log( | ||
[ | ||
"esy version:prepare, prepare a new fnm version", | ||
"", | ||
"Usage:", | ||
"------", | ||
"", | ||
" esy version:prepare patch - to prepare a patch version (X.X.X+1)", | ||
" esy version:prepare minor - to prepare a minor version (X.X+1.0)", | ||
" esy version:prepare major - to prepare a major version (X+1.0.0)" | ||
].join("\n") | ||
); | ||
process.exit(1); | ||
} | ||
const versionType = versions[ARGUMENTS[0].toLowerCase()]; | ||
if (!versionType) { | ||
throw new Error("Version (argument 0) must be one of major/minor/patch."); | ||
} | ||
|
||
const pkgJson = JSON.parse(fs.readFileSync("./package.json", "utf8")); | ||
pkgJson.version = changeVersion(versionType, pkgJson.version); | ||
fs.writeFileSync("./package.json", JSON.stringify(pkgJson, null, 2)); | ||
|
||
exec("git fetch origin"); | ||
exec("esy update-fnm-package"); | ||
exec("esy verify-fnm-package"); | ||
exec("esy build"); | ||
exec("./docs/record_screen.sh"); | ||
exec(`esy changelog`, { NEXT_VERSION: `v${pkgJson.version}` }); | ||
|
||
function exec(command, env) { | ||
console.log(`$ ${command}`); | ||
return cp.execSync(command, { | ||
stdio: "inherit", | ||
env: { ...process.env, ...env } | ||
}); | ||
} | ||
|
||
function changeVersion(type, version) { | ||
const [major, minor, patch] = version.split(".").map(x => parseFloat(x, 10)); | ||
switch (type) { | ||
case "patch": | ||
return [major, minor, patch + 1].join("."); | ||
case "minor": | ||
return [major, minor + 1, 0].join("."); | ||
case "major": | ||
return [major + 1, 0, 0].join("."); | ||
} | ||
} |
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
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 |
---|---|---|
@@ -1 +1 @@ | ||
let version = "1.6.1"; | ||
let version = "1.6.2"; |
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