Skip to content

Commit

Permalink
Merge branch 'main' of github.com:lando/core into main
Browse files Browse the repository at this point in the history
  • Loading branch information
pirog committed Nov 21, 2024
2 parents 627c9f8 + 04cb8ed commit 16a14a4
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 9 deletions.
1 change: 0 additions & 1 deletion .github/workflows/dev-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,6 @@ jobs:
alias:
- dev
- ${{ github.sha }}

needs:
- build-release-binary-alias
- build-release-binary-branch
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,6 @@ jobs:
- edge
- ${{ github.event.release.prerelease == false && 'stable' || 'prerelease' }}
- ${{ github.ref_name }}

needs:
- build-release-binary-alias
- build-release-binary-tag
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
## {{ UNRELEASED_VERSION }} - [{{ UNRELEASED_DATE }}]({{ UNRELEASED_LINK }})

* Fixed `lando shellenv` so it doesn't fail when `shell` profile is empty
* Fixed `lando update` so it removes lingering `lando.exe`s in the update bin directory
* Improved `lando shellenv` so that it always includes `~/.lando/bin` and includes it first
* Improved messaging on `lando shellenv --add`
* Improved messaging on `lando update` for `@lando/cli`

## v3.23.11 - [November 20, 2024](https://github.com/lando/core/releases/tag/v3.23.11)

* This release has no new content and is just to test the new modular release flow
Expand Down
Empty file removed lib/checksums.txt
Empty file.
14 changes: 12 additions & 2 deletions lib/updates.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const get = require('lodash/get');
const getOctokit = require('../utils/get-octokit');
const os = require('os');
const path = require('path');
const remove = require('../utils/remove');
const semver = require('semver');
const uniqBy = require('lodash/uniqBy');

Expand Down Expand Up @@ -249,7 +250,16 @@ module.exports = class UpdateManager {
// refresh the "symlink"
require('../utils/link-bin')(this._cli.installPath, dest, {debug: this.debug});

// is link is not in PATH then attempt to add it
// set a good default update messag
task.title = `Updated @lando/cli to ${version}`;

// if lando.exe exists on windows in the install path then remove it so the link has primacy
// in PATHEXT hierarchy
if (process.platform === 'win32' && fs.existsSync(path.join(this._cli.installPath, filename))) {
remove(path.join(this._cli.installPath, filename));
}

// if link is not in PATH then attempt to add it
// @NOTE: feels sufficient to just check for `lando` since it _should_ exist in win and posix
if (!require('../utils/is-in-path')(path.join(this._cli.installPath, 'lando'))) {
const binPaths = require('../utils/get-bin-paths')(this._cli);
Expand All @@ -269,14 +279,14 @@ module.exports = class UpdateManager {
const rcFile = require('../utils/get-shell-profile')();
require('../utils/update-shell-profile')(rcFile, shellEnv);
this.debug('added %o to %o', shellEnv, rcFile);
task.title `${task.title}. Start a new terminal session to use the updated ${color.bold(`lando`)}`;

// otherwis i guess do something else?
// @TODO: throw a warning?
} else this.debug('could not add %o to PATH!', binPaths);
}

// finish
task.title = `Updated @lando/cli to ${version}`;
resolve(data);
});
// handle errors
Expand Down
4 changes: 2 additions & 2 deletions tasks/shellenv.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ module.exports = lando => {
console.log();
console.log(color.bold(binPaths.join(os.EOL)));
console.log();
console.log(`Open a new shell to load the changes!`);
console.log(`Start a new terminal session to use ${color.bold(`lando`)}`);
return;

// otherwise update the shell profile
Expand All @@ -72,7 +72,7 @@ module.exports = lando => {
console.log();
console.log(color.bold(shellEnv.map(line => line[0]).join(os.EOL)));
console.log();
console.log(`Open a new shell or run ${color.bold(`source ${options.add}`)} to load the changes`);
console.log(`Start a new terminal session or run ${color.bold(`eval "$(lando shellenv)"`)} to use ${color.bold(`lando`)}`);
} else {
console.log(`Looks like ${color.green(options.add)} is already ready to go!`);
}
Expand Down
4 changes: 2 additions & 2 deletions utils/get-bin-paths.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
const fs = require('fs');
const path = require('path');

module.exports = ({entrypoint, file, installPath}) => {
return [entrypoint, file, installPath]
module.exports = ({installPath}) => {
return [installPath]
.filter(p => typeof p === 'string' && p !== '' && fs.existsSync(p))
.map(p => !fs.lstatSync(p).isDirectory() ? path.dirname(p) : p)
.filter(p => !process.env.PATH.split(path.delimiter).includes(p))
Expand Down
5 changes: 4 additions & 1 deletion utils/update-shell-profile.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,11 @@ module.exports = (file, updates = []) => {
const content = read(file);
// split into lines
const lines = content.split('\n');
// get penulimatimate
const penny = Math.max(lines.length - 2, 0);

// if we end up with second to last line that is empty then pop
if (lines[lines.length - 2].trim() === '') lines.pop();
if (penny > 0 && lines[lines.length - 2].trim() === '') lines.pop();

// loops through the updates and add/update as needed
for (const [update, search] of updates) {
Expand Down

0 comments on commit 16a14a4

Please sign in to comment.