Browse Source

Update scripts for release

remotes/origin/add-with-shims v1.22.0-beta-1
Gal Schlezinger 4 years ago
parent
commit
8e5738dfb4
  1. 4
      .ci/generate-changelog.sh
  2. 85
      .ci/prepare-version.js
  3. 1
      .node-version
  4. 2
      CHANGELOG.md
  5. 8
      README.md
  6. 2
      docs/fnm.svg
  7. 12
      docs/record_screen.sh
  8. 8
      docs/recorded_screen_script.sh
  9. 7
      package.json
  10. 16
      yarn.lock

4
.ci/generate-changelog.sh

@ -1,8 +1,8 @@ @@ -1,8 +1,8 @@
#!/bin/bash
if [ "$1" = "" ]; then
echo "Taking version from binary" >&2
NEXT_VERSION="$(cargo run --quiet -- --version)"
echo "No version provided, using 'Unreleased'" >&2
NEXT_VERSION="Unreleased"
else
NEXT_VERSION="$1"
fi

85
.ci/prepare-version.js

@ -0,0 +1,85 @@ @@ -0,0 +1,85 @@
#!/usr/bin/env node
/// @ts-check
const fs = require("fs");
const cp = require("child_process");
const path = require("path");
const cmd = require("cmd-ts");
const toml = require("toml");
const CARGO_TOML_PATH = path.join(__dirname, "../Cargo.toml");
const command = cmd.command({
name: "prepare-version",
description: "Prepare a new fnm version",
args: {
versionType: cmd.positional({
displayName: "version type",
type: cmd.oneOf(["patch", "minor", "major"]),
}),
},
async handler({ versionType }) {
exec("git pull --ff-only");
const nextVersion = updateCargoToml(versionType);
exec("cargo build --release");
exec("./docs/record_screen.sh");
exec(`yarn changelog ${nextVersion}`);
},
});
cmd.run(cmd.binary(command), process.argv);
//////////////////////
// Helper functions //
//////////////////////
function updateCargoToml(versionType) {
const cargoToml = fs.readFileSync(CARGO_TOML_PATH, "utf8");
const cargoTomlContents = toml.parse(cargoToml);
const currentVersion = cargoTomlContents.package.version;
const nextVersion = changeVersion(
versionType,
cargoTomlContents.package.version
);
const newToml = cargoToml.replace(
`version = "${currentVersion}"`,
`version = "${nextVersion}"`
);
if (newToml === cargoToml) {
console.error("Cargo.toml didn't change, error!");
process.exitCode = 1;
return;
}
fs.writeFileSync(CARGO_TOML_PATH, newToml, "utf8");
return nextVersion;
}
function exec(command, env) {
console.log(`$ ${command}`);
return cp.execSync(command, {
cwd: path.join(__dirname, '..'), // root of repo
stdio: "inherit",
env: { ...process.env, ...env },
});
}
/**
* @param {"patch" | "minor" | "major"} type
* @param {string} version
*/
function changeVersion(type, version) {
const [major, minor, patch] = version.split(".").map((x) => parseInt(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(".");
}
}

1
.node-version

@ -0,0 +1 @@ @@ -0,0 +1 @@
v12.6.0

2
CHANGELOG.md

@ -1,4 +1,4 @@ @@ -1,4 +1,4 @@
## fnm 1.22.0 (2020-10-07)
## 1.22.0 (2020-10-07)
#### New Feature 🎉

8
README.md

@ -16,7 +16,7 @@ @@ -16,7 +16,7 @@
:rocket: Built with speed in mind
:thinking: Works with `.nvmrc` and `.node-version` files
:thinking: Works with `.node-version` and `.nvmrc` files
## Installation
@ -92,11 +92,11 @@ You can always use `fnm --help` to read the docs: @@ -92,11 +92,11 @@ You can always use `fnm --help` to read the docs:
### `fnm install [VERSION]`
Installs `[VERSION]`. If no version provided, it will install the version specified in the `.nvmrc` file located in the current working directory.
Installs `[VERSION]`. If no version provided, it will install the version specified in the `.node-version` or `.nvmrc` files located in the current working directory.
### `fnm use [VERSION]`
Activates `[VERSION]` as the current Node version. If no version provided, it will activate the version specified in the `.nvmrc` or `.node-version` file located in the current working directory.
Activates `[VERSION]` as the current Node version. If no version provided, it will activate the version specified in the `.node-version` or `.nvmrc` file located in the current working directory.
### `fnm current`
@ -129,7 +129,7 @@ Prints the required shell commands in order to configure your shell, Bash compli @@ -129,7 +129,7 @@ Prints the required shell commands in order to configure your shell, Bash compli
- Providing `--multi` will output the multishell support, allowing a different current Node version per shell
- Providing `--shell=fish` will output the Fish-compliant version. Omitting it and `fnm` will try to infer the current shell based on the process tree
- Providing `--node-dist-mirror="https://npm.taobao.org/dist"` will use the Chinese mirror of Node.js
- Providing `--use-on-cd` will also output a script that will automatically change the node version if a `.nvmrc`/`.node-version` file is found
- Providing `--use-on-cd` will also output a script that will automatically change the node version if a `.node-version`/`.nvmrc` file is found
- Providing `--fnm-dir="/tmp/fnm"` will install and use versions in `/tmp/fnm` directory
## Future Plans

2
docs/fnm.svg

File diff suppressed because one or more lines are too long

Before

Width:  |  Height:  |  Size: 26 KiB

After

Width:  |  Height:  |  Size: 29 KiB

12
docs/record_screen.sh

@ -1,10 +1,10 @@ @@ -1,10 +1,10 @@
#!/bin/bash
DIRECTORY=`dirname $0`
DIRECTORY="$(dirname "$0")"
function setup_binary() {
export TEMP_DIR=$(mktemp -d -t fnm)
cp _esy/default/build/default/executable/FnmApp.exe $TEMP_DIR/fnm
TEMP_DIR="$(mktemp -d -t fnm)"
cp ./target/release/fnm "$TEMP_DIR/fnm"
export PATH=$TEMP_DIR:$PATH
export FNM_DIR=$TEMP_DIR/.fnm
}
@ -13,7 +13,7 @@ setup_binary @@ -13,7 +13,7 @@ setup_binary
RECORDING_PATH=$DIRECTORY/screen_recording
(rm -rf $RECORDING_PATH &> /dev/null || true)
(rm -rf "$RECORDING_PATH" &> /dev/null || true)
asciinema rec -c $DIRECTORY/recorded_screen_script.sh $RECORDING_PATH
cat $RECORDING_PATH | sed "s@$TEMP_DIR@~@g" | svg-term --window --out $DIRECTORY/fnm.svg --height=17 --width=70
asciinema rec -c "$DIRECTORY/recorded_screen_script.sh" "$RECORDING_PATH"
sed "s@$TEMP_DIR@~@g" "$RECORDING_PATH" | svg-term --window --out "$DIRECTORY/fnm.svg" --height=17 --width=70

8
docs/recorded_screen_script.sh

@ -9,16 +9,14 @@ function type() { @@ -9,16 +9,14 @@ function type() {
echo $* | pv -qL $[10+(-2 + RANDOM%5)]
}
cd ./feature_tests/nvmrc
type 'eval `fnm env`'
eval `fnm env`
type 'fnm --version'
fnm --version
type 'cat .nvmrc'
cat .nvmrc
type 'cat .node-version'
cat .node-version
type 'fnm install'
fnm install
@ -30,4 +28,4 @@ type 'node -v' @@ -30,4 +28,4 @@ type 'node -v'
node -v
sleep 2
echo ""
echo ""

7
package.json

@ -6,7 +6,8 @@ @@ -6,7 +6,8 @@
"author": "Gal Schlezinger <gal@spitfire.co.il>",
"license": "GPLv3",
"scripts": {
"changelog": "./.ci/generate-changelog.sh"
"changelog": "./.ci/generate-changelog.sh",
"version:prepare": "./.ci/prepare-version.js"
},
"changelog": {
"repo": "Schniz/fnm",
@ -18,7 +19,9 @@ @@ -18,7 +19,9 @@
}
},
"devDependencies": {
"cmd-ts": "^0.6.4",
"lerna-changelog": "^1.0.1",
"prettier": "^2.1.2"
"prettier": "^2.1.2",
"toml": "^3.0.0"
}
}

16
yarn.lock

@ -170,6 +170,15 @@ cliui@^6.0.0: @@ -170,6 +170,15 @@ cliui@^6.0.0:
strip-ansi "^6.0.0"
wrap-ansi "^6.2.0"
cmd-ts@^0.6.4:
version "0.6.4"
resolved "https://registry.npmjs.org/cmd-ts/-/cmd-ts-0.6.4.tgz#3390ec94d5f9f25fe5745b7dffb34842701b96ae"
integrity sha512-z1xFprGcUjFK8qCITdvHymVZtYyuirezqVRO8K+JGv24Lr+hyQrToPTmGlvWtvEZsHPYfyqNt5+Es9FLthCgsQ==
dependencies:
chalk "^3.0.0"
debug "^4.1.1"
strip-ansi "^6.0.0"
color-convert@^1.9.0:
version "1.9.3"
resolved "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz#bb71850690e1f136567de629d2d5471deda4c1e8"
@ -227,7 +236,7 @@ cross-spawn@^6.0.0: @@ -227,7 +236,7 @@ cross-spawn@^6.0.0:
shebang-command "^1.2.0"
which "^1.2.9"
debug@4, debug@^4.1.0:
debug@4, debug@^4.1.0, debug@^4.1.1:
version "4.2.0"
resolved "https://registry.npmjs.org/debug/-/debug-4.2.0.tgz#7f150f93920e94c58f5574c2fd01a3110effe7f1"
integrity sha512-IX2ncY78vDTjZMFUdmsvIRFY2Cf4FnD0wRs+nQwJU8Lu99/tPFdb0VybiiMTPe3I6rQmwsqQqRBvxU+bZ/I8sg==
@ -980,6 +989,11 @@ thenify-all@^1.0.0: @@ -980,6 +989,11 @@ thenify-all@^1.0.0:
dependencies:
any-promise "^1.0.0"
toml@^3.0.0:
version "3.0.0"
resolved "https://registry.npmjs.org/toml/-/toml-3.0.0.tgz#342160f1af1904ec9d204d03a5d61222d762c5ee"
integrity sha512-y/mWCZinnvxjTKYhJ+pYxwD0mRLVvOtdS2Awbgxln6iEnt4rk0yBxeSBHkGJcPucRiG0e55mwWp+g/05rsrd6w==
unique-filename@^1.1.1:
version "1.1.1"
resolved "https://registry.npmjs.org/unique-filename/-/unique-filename-1.1.1.tgz#1d69769369ada0583103a1e6ae87681b56573230"

Loading…
Cancel
Save