@florianpat/lando-core 3.23.7-compose → 3.23.22-test2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +101 -1
- package/bin/lando +2 -0
- package/bin/lando.cmd +3 -0
- package/builders/_lando.js +2 -1
- package/components/l337-v4.js +2 -2
- package/config.yml +3 -2
- package/hooks/lando-autostart-engine.js +4 -25
- package/hooks/lando-run-setup.js +58 -0
- package/hooks/lando-setup-build-engine-darwin.js +13 -12
- package/hooks/lando-setup-build-engine-linux.js +14 -4
- package/hooks/lando-setup-build-engine-win32.js +27 -20
- package/hooks/lando-setup-build-engine-wsl.js +210 -0
- package/hooks/lando-setup-check.js +19 -0
- package/hooks/lando-setup-create-ca-wsl.js +34 -0
- package/hooks/lando-setup-create-ca.js +22 -23
- package/hooks/lando-setup-install-ca-darwin.js +5 -1
- package/hooks/lando-setup-install-ca-linux.js +4 -1
- package/hooks/lando-setup-install-ca-win32.js +5 -1
- package/hooks/lando-setup-install-ca-wsl.js +145 -0
- package/hooks/lando-setup-orchestrator.js +4 -4
- package/index.js +18 -12
- package/lib/app.js +2 -2
- package/lib/art.js +20 -8
- package/lib/compose.js +0 -3
- package/lib/daemon.js +79 -76
- package/lib/docker.js +2 -2
- package/lib/engine.js +10 -3
- package/lib/lando.js +2 -2
- package/lib/metrics.js +5 -3
- package/lib/updates.js +12 -2
- package/node_modules/nanoid/.devcontainer.json +23 -0
- package/node_modules/nanoid/README.md +517 -2
- package/node_modules/nanoid/async/index.browser.cjs +37 -2
- package/node_modules/nanoid/async/index.browser.js +37 -2
- package/node_modules/nanoid/async/index.cjs +38 -2
- package/node_modules/nanoid/async/index.js +38 -2
- package/node_modules/nanoid/async/index.native.js +33 -2
- package/node_modules/nanoid/index.browser.cjs +39 -1
- package/node_modules/nanoid/index.browser.js +39 -1
- package/node_modules/nanoid/index.cjs +42 -2
- package/node_modules/nanoid/index.js +42 -2
- package/node_modules/nanoid/non-secure/index.cjs +15 -2
- package/node_modules/nanoid/non-secure/index.js +15 -2
- package/node_modules/nanoid/package.json +1 -1
- package/node_modules/nanoid/url-alphabet/index.cjs +4 -0
- package/node_modules/nanoid/url-alphabet/index.js +4 -0
- package/package.json +7 -7
- package/plugins/networking/app.js +4 -2
- package/plugins/networking/index.js +19 -6
- package/plugins/proxy/builders/_proxy.js +1 -2
- package/release-aliases/3-EDGE +1 -1
- package/release-aliases/3-STABLE +1 -1
- package/renderers/dc2.js +2 -1
- package/scripts/add-to-group.sh +72 -0
- package/scripts/docker-engine-start.sh +15 -1
- package/scripts/install-docker-desktop.ps1 +11 -12
- package/scripts/install-system-ca-win32.ps1 +14 -14
- package/scripts/run-elevated.ps1 +2 -2
- package/scripts/semcompare.sh +142 -0
- package/scripts/wait-for-user.sh +1 -2
- package/tasks/destroy.js +3 -0
- package/tasks/info.js +2 -1
- package/tasks/init.js +35 -30
- package/tasks/rebuild.js +2 -8
- package/tasks/restart.js +2 -8
- package/tasks/setup.js +2 -2
- package/tasks/shellenv.js +2 -2
- package/tasks/start.js +2 -8
- package/tasks/stop.js +3 -0
- package/utils/build-config.js +2 -0
- package/utils/build-tooling-runner.js +2 -1
- package/utils/get-app.js +1 -1
- package/utils/get-bin-paths.js +2 -2
- package/utils/get-compose-x.js +1 -1
- package/utils/get-config-defaults.js +12 -7
- package/utils/get-docker-bin-path.js +6 -2
- package/utils/get-docker-desktop-x.js +21 -0
- package/utils/get-docker-x.js +3 -2
- package/utils/get-shellenv.js +1 -2
- package/utils/get-system-cas.js +25 -6
- package/utils/get-win32-envvar-from-wsl.js +7 -0
- package/utils/is-admin-user.js +9 -8
- package/utils/is-group-member.js +14 -7
- package/utils/is-wsl-interop.js +17 -4
- package/utils/run-elevated.js +9 -0
- package/utils/run-powershell-script.js +31 -5
- package/utils/run-tasks.js +3 -2
- package/utils/setup-metrics.js +10 -1
- package/utils/shutdown-os.js +8 -3
- package/utils/spawn-sync-stringer.js +1 -0
- package/utils/update-shell-profile.js +8 -7
- package/utils/validate-ca.js +31 -0
- package/utils/winpath-2-wslpath.js +6 -0
- package/utils/wslpath-2-winpath.js +6 -0
- package/hooks/lando-dep-check.js +0 -26
- package/lib/checksums.txt +0 -0
|
@@ -22,7 +22,8 @@ module.exports = (app, lando) => {
|
|
|
22
22
|
return landonet.disconnect({Container: container.id, Force: true})
|
|
23
23
|
// Only throw non not connected errors
|
|
24
24
|
.catch(error => {
|
|
25
|
-
if (!_.includes(error.message, 'is not connected to network')
|
|
25
|
+
if (!_.includes(error.message, 'is not connected to network') &&
|
|
26
|
+
!_.includes(error.message, 'is not connected to the network')) throw error;
|
|
26
27
|
})
|
|
27
28
|
// Connect
|
|
28
29
|
.then(() => {
|
|
@@ -67,7 +68,8 @@ module.exports = (app, lando) => {
|
|
|
67
68
|
return bridgeNet.disconnect({Container: proxyContainer, Force: true})
|
|
68
69
|
// Only throw non not connected errors
|
|
69
70
|
.catch(error => {
|
|
70
|
-
if (!_.includes(error.message, 'is not connected to network')
|
|
71
|
+
if (!_.includes(error.message, 'is not connected to network') &&
|
|
72
|
+
!_.includes(error.message, 'is not connected to the network')) throw error;
|
|
71
73
|
})
|
|
72
74
|
// Connect
|
|
73
75
|
.then(() => {
|
|
@@ -2,13 +2,15 @@
|
|
|
2
2
|
|
|
3
3
|
// Modules
|
|
4
4
|
const _ = require('lodash');
|
|
5
|
+
const fs = require('fs');
|
|
6
|
+
const getDockerDesktopBin = require('../../utils/get-docker-desktop-x');
|
|
5
7
|
|
|
6
8
|
/*
|
|
7
9
|
* Helper to clean out any old networks when we hit the limit
|
|
8
10
|
*/
|
|
9
11
|
const cleanNetworks = lando => lando.engine.getNetworks()
|
|
10
12
|
.then(networks => {
|
|
11
|
-
if (_.size(networks) >=
|
|
13
|
+
if (_.size(networks) >= lando.config.networkLimit) {
|
|
12
14
|
// Warn user about this action
|
|
13
15
|
lando.log.warn('Lando has detected you are at Docker\'s network limit!');
|
|
14
16
|
lando.log.warn('Give us a moment as we try to make space by cleaning up old networks...');
|
|
@@ -53,26 +55,37 @@ module.exports = lando => {
|
|
|
53
55
|
// skip the installation of the network if set
|
|
54
56
|
if (options.skipNetworking) return;
|
|
55
57
|
|
|
58
|
+
// we need access to dat socket for this to work
|
|
59
|
+
const dependsOn = ['linux', 'wsl']
|
|
60
|
+
.includes(lando.config.os.landoPlatform) ? ['setup-build-engine-group', 'setup-build-engine'] : ['setup-build-engine'];
|
|
61
|
+
|
|
56
62
|
options.tasks.push({
|
|
57
63
|
title: `Creating Landonet`,
|
|
58
64
|
id: 'create-landonet',
|
|
59
|
-
dependsOn
|
|
65
|
+
dependsOn,
|
|
60
66
|
description: '@lando/landonet',
|
|
61
67
|
comments: {
|
|
62
|
-
'NOT INSTALLED': 'Will create
|
|
68
|
+
'NOT INSTALLED': 'Will create LandoNet',
|
|
69
|
+
},
|
|
70
|
+
skip: () => {
|
|
71
|
+
if (!['linux', 'wsl'].includes(lando.config.os.landoPlatform)) return false;
|
|
72
|
+
return !require('../../utils/is-group-member')('docker');
|
|
63
73
|
},
|
|
64
74
|
hasRun: async () => {
|
|
65
75
|
// if docker isnt even installed then this is easy
|
|
66
76
|
if (lando.engine.dockerInstalled === false) return false;
|
|
67
77
|
|
|
78
|
+
// we also want to do an additional check on docker-destkop
|
|
79
|
+
if (lando.config.os.landoPlatform !== 'linux' && !fs.existsSync(getDockerDesktopBin())) return false;
|
|
80
|
+
|
|
68
81
|
// otherwise attempt to sus things out
|
|
69
82
|
try {
|
|
83
|
+
await lando.engine.daemon.up({max: 10, backoff: 1000});
|
|
70
84
|
const landonet = lando.engine.getNetwork(lando.config.networkBridge);
|
|
71
|
-
await lando.engine.daemon.up();
|
|
72
85
|
await landonet.inspect();
|
|
73
86
|
return lando.versions.networking > 1;
|
|
74
87
|
} catch (error) {
|
|
75
|
-
debug('looks like there isnt a landonet yet %o %o', error
|
|
88
|
+
debug('looks like there isnt a landonet yet %o %o', error?.message, error?.stack);
|
|
76
89
|
return false;
|
|
77
90
|
}
|
|
78
91
|
},
|
|
@@ -82,7 +95,7 @@ module.exports = lando => {
|
|
|
82
95
|
const daemon = new LandoDaemon(lando.cache, lando.events, undefined, lando.log);
|
|
83
96
|
|
|
84
97
|
// we need docker up for this
|
|
85
|
-
await daemon.up();
|
|
98
|
+
await daemon.up({max: 5, backoff: 1000});
|
|
86
99
|
|
|
87
100
|
// if we are v1 then disconnect and remove for upgrade
|
|
88
101
|
if (lando.versions.networking === 1) {
|
|
@@ -17,7 +17,7 @@ const getProxy = ({
|
|
|
17
17
|
return {
|
|
18
18
|
services: {
|
|
19
19
|
proxy: {
|
|
20
|
-
image: 'traefik:2.
|
|
20
|
+
image: 'traefik:2.11.16',
|
|
21
21
|
command: proxyCommand.join(' '),
|
|
22
22
|
environment: {
|
|
23
23
|
LANDO_APP_PROJECT: '_lando_',
|
|
@@ -25,7 +25,6 @@ const getProxy = ({
|
|
|
25
25
|
LANDO_PROXY_CONFIG_FILE: '/proxy_config/proxy.yaml',
|
|
26
26
|
LANDO_PROXY_PASSTHRU: _.toString(proxyPassThru),
|
|
27
27
|
LANDO_VERSION: version,
|
|
28
|
-
LANDO_DOMAIN: proxyDomain,
|
|
29
28
|
},
|
|
30
29
|
networks: ['edge'],
|
|
31
30
|
volumes: [
|
package/release-aliases/3-EDGE
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
v3.
|
|
1
|
+
v3.24.0-beta.8
|
package/release-aliases/3-STABLE
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
v3.23.
|
|
1
|
+
v3.23.22
|
package/renderers/dc2.js
CHANGED
|
@@ -36,8 +36,9 @@ class DC2Renderer extends LandoRenderer {
|
|
|
36
36
|
options.states = {
|
|
37
37
|
COMPLETED: {message: 'Done', color: 'green'},
|
|
38
38
|
FAILED: {message: 'ERROR', color: 'red'},
|
|
39
|
+
SKIPPED: {message: 'Deferred', color: 'gray'},
|
|
39
40
|
STARTED: {message: 'Waiting', color: 'green'},
|
|
40
|
-
WAITING: {message: 'Waiting', color: '
|
|
41
|
+
WAITING: {message: 'Waiting', color: 'gray'},
|
|
41
42
|
...options.states,
|
|
42
43
|
};
|
|
43
44
|
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
set -eo pipefail
|
|
3
|
+
|
|
4
|
+
DEBUG=0
|
|
5
|
+
GROUP=""
|
|
6
|
+
USER=""
|
|
7
|
+
|
|
8
|
+
chomp() {
|
|
9
|
+
printf "%s" "${1%$'\n'}"
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
abort() {
|
|
13
|
+
printf "ERROR: %s\n" "$(chomp "$1")" >&2
|
|
14
|
+
exit 1
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
debug() {
|
|
18
|
+
if [ "${DEBUG}" == 1 ]; then printf '%s\n' "$1" >&2; fi
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
# PARSE THE ARGZZ
|
|
22
|
+
while (( "$#" )); do
|
|
23
|
+
case "$1" in
|
|
24
|
+
--debug)
|
|
25
|
+
DEBUG=1
|
|
26
|
+
shift
|
|
27
|
+
;;
|
|
28
|
+
--group)
|
|
29
|
+
GROUP="$2"
|
|
30
|
+
shift 2
|
|
31
|
+
;;
|
|
32
|
+
--group=*)
|
|
33
|
+
GROUP="${1#*=}"
|
|
34
|
+
shift
|
|
35
|
+
;;
|
|
36
|
+
--user)
|
|
37
|
+
USER="$2"
|
|
38
|
+
shift 2
|
|
39
|
+
;;
|
|
40
|
+
--user=*)
|
|
41
|
+
USER="${1#*=}"
|
|
42
|
+
shift
|
|
43
|
+
;;
|
|
44
|
+
--)
|
|
45
|
+
shift
|
|
46
|
+
break
|
|
47
|
+
;;
|
|
48
|
+
-*|--*=)
|
|
49
|
+
shift
|
|
50
|
+
;;
|
|
51
|
+
*)
|
|
52
|
+
shift
|
|
53
|
+
;;
|
|
54
|
+
esac
|
|
55
|
+
done
|
|
56
|
+
|
|
57
|
+
# Check that both --group and --user were provided
|
|
58
|
+
if [ -z "$GROUP" ] || [ -z "$USER" ]; then
|
|
59
|
+
abort "Usage: $0 --group GROUPNAME --user USERNAME"
|
|
60
|
+
fi
|
|
61
|
+
|
|
62
|
+
# Check if the group exists, create if not
|
|
63
|
+
if ! getent group "$GROUP" > /dev/null 2>&1; then
|
|
64
|
+
debug "Group '$GROUP' does not exist. Creating..."
|
|
65
|
+
groupadd "$GROUP" || { abort "Failed to create group."; }
|
|
66
|
+
fi
|
|
67
|
+
|
|
68
|
+
# Add the user to the group
|
|
69
|
+
debug "Adding user '$USER' to group '$GROUP'..."
|
|
70
|
+
usermod -aG "$GROUP" "$USER" || { abort "Failed to add user to group."; }
|
|
71
|
+
|
|
72
|
+
echo "User '$USER' successfully added to group '$GROUP'."
|
|
@@ -1,4 +1,18 @@
|
|
|
1
1
|
#!/bin/sh
|
|
2
2
|
set -e
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
# Function to check if a Polkit agent is running
|
|
5
|
+
is_polkit_agent_running() {
|
|
6
|
+
ps aux | grep -q "[p]olkit" && return 0 || return 1
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
# Check if the DISPLAY or XDG_SESSION_TYPE indicates a desktop environment
|
|
10
|
+
if [ -n "$DISPLAY" ] || [ "$XDG_SESSION_TYPE" = "x11" ] || [ "$XDG_SESSION_TYPE" = "wayland" ]; then
|
|
11
|
+
if is_polkit_agent_running; then
|
|
12
|
+
systemctl start docker.service || service docker start
|
|
13
|
+
else
|
|
14
|
+
sudo systemctl start docker.service || sudo service docker start
|
|
15
|
+
fi
|
|
16
|
+
else
|
|
17
|
+
sudo systemctl start docker.service || sudo service docker start
|
|
18
|
+
fi
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
#!/
|
|
2
2
|
|
|
3
3
|
# handle params
|
|
4
|
-
# @NOTE: we omit DEBUG as a param because its "built in"
|
|
5
4
|
[CmdletBinding(PositionalBinding=$false)]
|
|
6
5
|
Param(
|
|
7
|
-
[string]$
|
|
8
|
-
[switch]$
|
|
6
|
+
[string]$Installer,
|
|
7
|
+
[switch]$AcceptLicense = $false
|
|
9
8
|
)
|
|
10
9
|
|
|
11
10
|
# error handling
|
|
@@ -19,28 +18,28 @@ trap {
|
|
|
19
18
|
|
|
20
19
|
# enable debugging if debug is true
|
|
21
20
|
$DebugPreference = If ($DebugPreference -eq "Inquire") {"Continue"} Else {"SilentlyContinue"}
|
|
22
|
-
$
|
|
21
|
+
$Debug = If ($DebugPreference -eq "Continue") {$true} Else {$false}
|
|
23
22
|
Write-Debug "running script with:"
|
|
24
|
-
Write-Debug "INSTALLER: $
|
|
25
|
-
Write-Debug "ACCEPT LICENSE: $
|
|
26
|
-
Write-Debug "DEBUG: $
|
|
23
|
+
Write-Debug "INSTALLER: $Installer"
|
|
24
|
+
Write-Debug "ACCEPT LICENSE: $AcceptLicense"
|
|
25
|
+
Write-Debug "DEBUG: $Debug"
|
|
27
26
|
|
|
28
27
|
# validation
|
|
29
28
|
# @TODO: check if installer exists on fs?
|
|
30
|
-
if ([string]::IsNullOrEmpty($
|
|
29
|
+
if ([string]::IsNullOrEmpty($Installer)) {
|
|
31
30
|
throw "You must pass in an -Installer!"
|
|
32
31
|
}
|
|
33
32
|
|
|
34
33
|
# Start arg stuff
|
|
35
34
|
$options = "--backend=wsl-2"
|
|
36
35
|
# if debug mode is off then make the installer quiet
|
|
37
|
-
if ($
|
|
36
|
+
if ($Debug -eq $false) {$options = "$options --quiet"}
|
|
38
37
|
# if accept license is true then add that as well
|
|
39
|
-
if ($
|
|
38
|
+
if ($AcceptLicense -eq $true) {$options = "$options --accept-license"}
|
|
40
39
|
|
|
41
40
|
# Install
|
|
42
|
-
Write-Debug "Running $
|
|
43
|
-
$p = Start-Process -FilePath "$
|
|
41
|
+
Write-Debug "Running $Installer with 'install $options'"
|
|
42
|
+
$p = Start-Process -FilePath "$Installer" -ArgumentList "install $options" -Wait -PassThru
|
|
44
43
|
Write-Debug "Process finished with return code: $($p.ExitCode)"
|
|
45
44
|
|
|
46
45
|
# If there is an error then throw here
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
#!/
|
|
2
2
|
|
|
3
3
|
# handle params
|
|
4
|
-
# @NOTE: we omit DEBUG as a param because its "built in"
|
|
5
4
|
[CmdletBinding(PositionalBinding=$false)]
|
|
6
5
|
Param(
|
|
7
|
-
[string]$
|
|
8
|
-
[switch]$
|
|
6
|
+
[string]$Ca,
|
|
7
|
+
[switch]$NonInteractive = $env:LANDO_NONINTERACTIVE -or $env:NONINTERACTIVE -or $false
|
|
9
8
|
)
|
|
10
9
|
|
|
11
|
-
#
|
|
10
|
+
# Stop execution of this script if any cmdlet fails.
|
|
11
|
+
# We'll still need to check exit codes on any exe we run.
|
|
12
12
|
$ErrorActionPreference = "Stop"
|
|
13
13
|
|
|
14
14
|
# handle uncaught errorz
|
|
@@ -18,30 +18,30 @@ trap {
|
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
# validation
|
|
21
|
-
|
|
22
|
-
if ([string]::IsNullOrEmpty($ca)) {
|
|
21
|
+
if ([string]::IsNullOrEmpty($Ca)) {
|
|
23
22
|
throw "You must pass in a -CA!"
|
|
24
23
|
}
|
|
25
24
|
|
|
25
|
+
# enable debugging if debug is true
|
|
26
26
|
# enable debugging if debug is true
|
|
27
27
|
$DebugPreference = If ($DebugPreference -eq "Inquire") {"Continue"} Else {"SilentlyContinue"}
|
|
28
|
-
$
|
|
28
|
+
$Debug = If ($DebugPreference -eq "Continue") {$true} Else {$false}
|
|
29
29
|
Write-Debug "running script with:"
|
|
30
|
-
Write-Debug "CA: $
|
|
30
|
+
Write-Debug "CA: $Ca"
|
|
31
31
|
Write-Debug "CI: $env:CI"
|
|
32
|
-
Write-Debug "DEBUG: $
|
|
33
|
-
Write-Debug "NONINTERACTIVE: $
|
|
32
|
+
Write-Debug "DEBUG: $Debug"
|
|
33
|
+
Write-Debug "NONINTERACTIVE: $NonInteractive"
|
|
34
34
|
|
|
35
35
|
# if we are in CI then reset non-interactive to true
|
|
36
36
|
if ($env:CI) {
|
|
37
|
-
$
|
|
37
|
+
$NonInteractive = $true
|
|
38
38
|
Write-Debug "Running in non-interactive mode because CI=$env:CI is set."
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
# if non-interactive eg we are probably on CI lets just powershell it out as admin
|
|
42
|
-
if ($
|
|
42
|
+
if ($NonInteractive -eq $true) {
|
|
43
43
|
# start the process with elevated permissions
|
|
44
|
-
$p = Start-Process -FilePath certutil.exe -ArgumentList "-addstore Root `"$
|
|
44
|
+
$p = Start-Process -FilePath certutil.exe -ArgumentList "-addstore Root `"$Ca`"" -Verb RunAs -Wait -PassThru
|
|
45
45
|
Write-Debug "Process finished with return code: $($p.ExitCode)"
|
|
46
46
|
|
|
47
47
|
# if there is an error then throw here
|
|
@@ -51,7 +51,7 @@ if ($noninteractive -eq $true) {
|
|
|
51
51
|
} else {
|
|
52
52
|
# read the certificate
|
|
53
53
|
$cert = New-Object System.Security.Cryptography.X509Certificates.X509Certificate2
|
|
54
|
-
$cert.Import($
|
|
54
|
+
$cert.Import($Ca)
|
|
55
55
|
# add it to the store
|
|
56
56
|
$store = New-Object System.Security.Cryptography.X509Certificates.X509Store "Root", "CurrentUser"
|
|
57
57
|
$store.Open("ReadWrite")
|
package/scripts/run-elevated.ps1
CHANGED
|
@@ -16,8 +16,8 @@ $debug = If ($DebugPreference -eq "Continue") {$true} Else {$false}
|
|
|
16
16
|
|
|
17
17
|
# figure out the command and setup fake fds
|
|
18
18
|
$command = $cmd.split(',')
|
|
19
|
-
$stdoutfile = Join-Path $Env:Temp $(
|
|
20
|
-
$stderrfile = Join-Path $Env:Temp $(
|
|
19
|
+
$stdoutfile = Join-Path $Env:Temp $([guid]::NewGuid().ToString())
|
|
20
|
+
$stderrfile = Join-Path $Env:Temp $([guid]::NewGuid().ToString())
|
|
21
21
|
|
|
22
22
|
# DEBUG
|
|
23
23
|
Write-Debug "running elevated command:"
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
|
|
3
|
+
# semcompare.sh
|
|
4
|
+
# Usage: ./semcompare.sh version1 version2
|
|
5
|
+
|
|
6
|
+
version1="$1"
|
|
7
|
+
version2="$2"
|
|
8
|
+
|
|
9
|
+
parse_version() {
|
|
10
|
+
local version="$1"
|
|
11
|
+
local major minor patch pre_release
|
|
12
|
+
|
|
13
|
+
# Updated regex to allow optional leading 'v'
|
|
14
|
+
if [[ "$version" =~ ^v?([0-9]+)\.([0-9]+)\.([0-9]+)(-([0-9A-Za-z.-]+))?$ ]]; then
|
|
15
|
+
major="${BASH_REMATCH[1]}"
|
|
16
|
+
minor="${BASH_REMATCH[2]}"
|
|
17
|
+
patch="${BASH_REMATCH[3]}"
|
|
18
|
+
pre_release="${BASH_REMATCH[5]}"
|
|
19
|
+
else
|
|
20
|
+
echo "Invalid version: $version" >&2
|
|
21
|
+
exit 1
|
|
22
|
+
fi
|
|
23
|
+
|
|
24
|
+
echo "$major" "$minor" "$patch" "$pre_release"
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
compare_pre_release() {
|
|
28
|
+
local pre1="$1"
|
|
29
|
+
local pre2="$2"
|
|
30
|
+
|
|
31
|
+
# If both are empty, they're equal
|
|
32
|
+
if [[ -z "$pre1" && -z "$pre2" ]]; then
|
|
33
|
+
echo 0
|
|
34
|
+
return
|
|
35
|
+
fi
|
|
36
|
+
|
|
37
|
+
# A version without pre-release is higher
|
|
38
|
+
if [[ -z "$pre1" ]]; then
|
|
39
|
+
echo 1
|
|
40
|
+
return
|
|
41
|
+
fi
|
|
42
|
+
if [[ -z "$pre2" ]]; then
|
|
43
|
+
echo -1
|
|
44
|
+
return
|
|
45
|
+
fi
|
|
46
|
+
|
|
47
|
+
IFS='.' read -ra arr1 <<< "$pre1"
|
|
48
|
+
IFS='.' read -ra arr2 <<< "$pre2"
|
|
49
|
+
|
|
50
|
+
local len1="${#arr1[@]}"
|
|
51
|
+
local len2="${#arr2[@]}"
|
|
52
|
+
local len=$(( len1 > len2 ? len1 : len2 ))
|
|
53
|
+
|
|
54
|
+
for ((i=0; i<len; i++)); do
|
|
55
|
+
id1="${arr1[i]}"
|
|
56
|
+
id2="${arr2[i]}"
|
|
57
|
+
|
|
58
|
+
# Treat missing identifiers as empty strings
|
|
59
|
+
[[ -z "$id1" ]] && id1=""
|
|
60
|
+
[[ -z "$id2" ]] && id2=""
|
|
61
|
+
|
|
62
|
+
# Numeric identifiers compare numerically
|
|
63
|
+
if [[ "$id1" =~ ^[0-9]+$ ]] && [[ "$id2" =~ ^[0-9]+$ ]]; then
|
|
64
|
+
if ((10#$id1 > 10#$id2)); then
|
|
65
|
+
echo 1
|
|
66
|
+
return
|
|
67
|
+
elif ((10#$id1 < 10#$id2)); then
|
|
68
|
+
echo -1
|
|
69
|
+
return
|
|
70
|
+
fi
|
|
71
|
+
else
|
|
72
|
+
# Alphanumeric identifiers compare lexically
|
|
73
|
+
if [[ "$id1" > "$id2" ]]; then
|
|
74
|
+
echo 1
|
|
75
|
+
return
|
|
76
|
+
elif [[ "$id1" < "$id2" ]]; then
|
|
77
|
+
echo -1
|
|
78
|
+
return
|
|
79
|
+
fi
|
|
80
|
+
fi
|
|
81
|
+
done
|
|
82
|
+
|
|
83
|
+
echo 0
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
compare_versions() {
|
|
87
|
+
local v1=($1)
|
|
88
|
+
local v2=($2)
|
|
89
|
+
|
|
90
|
+
local major1="${v1[0]}"
|
|
91
|
+
local minor1="${v1[1]}"
|
|
92
|
+
local patch1="${v1[2]}"
|
|
93
|
+
local pre1="${v1[3]}"
|
|
94
|
+
|
|
95
|
+
local major2="${v2[0]}"
|
|
96
|
+
local minor2="${v2[1]}"
|
|
97
|
+
local patch2="${v2[2]}"
|
|
98
|
+
local pre2="${v2[3]}"
|
|
99
|
+
|
|
100
|
+
# Compare major
|
|
101
|
+
if ((major1 > major2)); then
|
|
102
|
+
echo 1
|
|
103
|
+
return
|
|
104
|
+
elif ((major1 < major2)); then
|
|
105
|
+
echo -1
|
|
106
|
+
return
|
|
107
|
+
fi
|
|
108
|
+
|
|
109
|
+
# Compare minor
|
|
110
|
+
if ((minor1 > minor2)); then
|
|
111
|
+
echo 1
|
|
112
|
+
return
|
|
113
|
+
elif ((minor1 < minor2)); then
|
|
114
|
+
echo -1
|
|
115
|
+
return
|
|
116
|
+
fi
|
|
117
|
+
|
|
118
|
+
# Compare patch
|
|
119
|
+
if ((patch1 > patch2)); then
|
|
120
|
+
echo 1
|
|
121
|
+
return
|
|
122
|
+
elif ((patch1 < patch2)); then
|
|
123
|
+
echo -1
|
|
124
|
+
return
|
|
125
|
+
fi
|
|
126
|
+
|
|
127
|
+
# Compare pre-release
|
|
128
|
+
pre_release_cmp=$(compare_pre_release "$pre1" "$pre2")
|
|
129
|
+
echo "$pre_release_cmp"
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
v1_components=$(parse_version "$version1")
|
|
133
|
+
v2_components=$(parse_version "$version2")
|
|
134
|
+
|
|
135
|
+
result=$(compare_versions "$v1_components" "$v2_components")
|
|
136
|
+
|
|
137
|
+
# Return 1 if the first version is higher, else 0
|
|
138
|
+
if [[ "$result" -gt 0 ]]; then
|
|
139
|
+
exit 0
|
|
140
|
+
else
|
|
141
|
+
exit 1
|
|
142
|
+
fi
|
package/scripts/wait-for-user.sh
CHANGED
|
@@ -5,7 +5,6 @@ set -e
|
|
|
5
5
|
# user info
|
|
6
6
|
user="${1:-$LANDO_WEBROOT_USER}"
|
|
7
7
|
id="${2:-$LANDO_HOST_UID}"
|
|
8
|
-
gid="${3:-$LANDO_HOST_GID}"
|
|
9
8
|
|
|
10
9
|
# retry settings
|
|
11
10
|
attempt=0
|
|
@@ -14,7 +13,7 @@ retry=25
|
|
|
14
13
|
|
|
15
14
|
until [ "$attempt" -ge "$retry" ]
|
|
16
15
|
do
|
|
17
|
-
id
|
|
16
|
+
id "$user"| grep uid | grep "$id" &>/dev/null && break
|
|
18
17
|
attempt=$((attempt+1))
|
|
19
18
|
sleep "$delay"
|
|
20
19
|
done
|
package/tasks/destroy.js
CHANGED
|
@@ -22,6 +22,9 @@ module.exports = lando => {
|
|
|
22
22
|
// Destroy the app
|
|
23
23
|
if (app) {
|
|
24
24
|
console.log(lando.cli.makeArt('appDestroy', {name: app.name, phase: 'pre'}));
|
|
25
|
+
// run setup if we need to
|
|
26
|
+
await require('../hooks/lando-run-setup')(lando);
|
|
27
|
+
// destroy
|
|
25
28
|
await app.destroy();
|
|
26
29
|
console.log(lando.cli.makeArt('appDestroy', {name: app.name, phase: 'post'}));
|
|
27
30
|
}
|
package/tasks/info.js
CHANGED
|
@@ -34,11 +34,12 @@ module.exports = lando => ({
|
|
|
34
34
|
const getData = async () => {
|
|
35
35
|
// go deep
|
|
36
36
|
if (options.deep) {
|
|
37
|
+
const separator = _.get(app, '_config.orchestratorSeparator', '_');
|
|
37
38
|
return await lando.engine.list({project: app.project})
|
|
38
39
|
.map(async container => await lando.engine.scan(container))
|
|
39
40
|
.filter(container => {
|
|
40
41
|
if (!options.service) return true;
|
|
41
|
-
return options.service.map(service => `/${app.project}
|
|
42
|
+
return options.service.map(service => `/${app.project}${separator}${service}${separator}1`).includes(container.Name);
|
|
42
43
|
});
|
|
43
44
|
|
|
44
45
|
// normal info
|
package/tasks/init.js
CHANGED
|
@@ -44,7 +44,7 @@ const runBuild = (lando, options = {}, steps = []) => lando.Promise.each(steps,
|
|
|
44
44
|
step,
|
|
45
45
|
)),
|
|
46
46
|
);
|
|
47
|
-
}
|
|
47
|
+
}
|
|
48
48
|
});
|
|
49
49
|
|
|
50
50
|
module.exports = lando => {
|
|
@@ -80,7 +80,7 @@ module.exports = lando => {
|
|
|
80
80
|
[--yes]
|
|
81
81
|
[--other-plugin-provided-options...]`,
|
|
82
82
|
options: _.merge(getInitBaseOpts(recipes, sources), configOpts, getInitOveridesOpts(inits, recipes, sources)),
|
|
83
|
-
run: options => {
|
|
83
|
+
run: async options => {
|
|
84
84
|
// Parse options abd and configs
|
|
85
85
|
options = parseInitOptions(options);
|
|
86
86
|
// Get our recipe and source configs
|
|
@@ -90,44 +90,49 @@ module.exports = lando => {
|
|
|
90
90
|
const buildSteps = (_.has(sourceConfig, 'build')) ? sourceConfig.build(options, lando) : [];
|
|
91
91
|
const configStep = (_.has(recipeConfig, 'build')) ? recipeConfig.build : () => {};
|
|
92
92
|
|
|
93
|
+
// run setup if we need to
|
|
94
|
+
await require('../hooks/lando-run-setup')(lando);
|
|
95
|
+
|
|
93
96
|
// Pre init event and run build steps
|
|
94
97
|
// @NOTE: source build steps are designed to grab code from somewhere
|
|
95
|
-
|
|
98
|
+
await lando.events.emit('pre-init', options, buildSteps);
|
|
99
|
+
|
|
100
|
+
// run build
|
|
101
|
+
await runBuild(lando, options, buildSteps);
|
|
102
|
+
|
|
96
103
|
// Run any config steps
|
|
97
104
|
// @NOTE: config steps are designed to augmnet the landofile with additional metadata
|
|
98
|
-
|
|
105
|
+
const config = await configStep(options, lando);
|
|
99
106
|
|
|
100
107
|
// Compile and dump the yaml
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
_.merge(landoFile, new Recipe(landoFile.name, recipeConfig).config);
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
// Merge in any additional configuration options specified
|
|
116
|
-
_.forEach(options.option, option => {
|
|
117
|
-
const key = _.first(option.split('='));
|
|
118
|
-
_.set(landoFile, `config.${key}`, _.last(option.split('=')));
|
|
119
|
-
});
|
|
120
|
-
|
|
121
|
-
// Merge and dump the config file
|
|
122
|
-
lando.yaml.dump(dest, _.merge(landoFile, config));
|
|
108
|
+
// if config is false then it means we want to skip landofile mutation
|
|
109
|
+
if (config !== false) {
|
|
110
|
+
// Where are we going?
|
|
111
|
+
const dest = path.join(options.destination, '.lando.yml');
|
|
112
|
+
const landoFile = getYaml(dest, options, lando);
|
|
113
|
+
|
|
114
|
+
// Get a lower level config if needed, merge in current recipe config
|
|
115
|
+
if (options.full) {
|
|
116
|
+
const Recipe = lando.factory.get(options.recipe);
|
|
117
|
+
const recipeConfig = _.merge({}, landoFile, {app: landoFile.name, _app: {_config: lando.config}});
|
|
118
|
+
_.merge(landoFile, new Recipe(landoFile.name, recipeConfig).config);
|
|
123
119
|
}
|
|
124
120
|
|
|
125
|
-
//
|
|
126
|
-
|
|
127
|
-
|
|
121
|
+
// Merge in any additional configuration options specified
|
|
122
|
+
_.forEach(options.option, option => {
|
|
123
|
+
const key = _.first(option.split('='));
|
|
124
|
+
_.set(landoFile, `config.${key}`, _.last(option.split('=')));
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
// Merge and dump the config file
|
|
128
|
+
lando.yaml.dump(dest, _.merge(landoFile, config));
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
// Show it
|
|
132
|
+
showInit(lando, options);
|
|
128
133
|
|
|
129
134
|
// Post init event
|
|
130
|
-
|
|
135
|
+
await lando.events.emit('post-init', options);
|
|
131
136
|
},
|
|
132
137
|
};
|
|
133
138
|
};
|
package/tasks/rebuild.js
CHANGED
|
@@ -33,16 +33,10 @@ module.exports = lando => {
|
|
|
33
33
|
if (app) {
|
|
34
34
|
console.log(lando.cli.makeArt('appRebuild', {name: app.name, phase: 'pre'}));
|
|
35
35
|
|
|
36
|
-
// run
|
|
37
|
-
|
|
38
|
-
sopts.buildEngine = false;
|
|
39
|
-
sopts.skipCommonPlugins = true;
|
|
40
|
-
sopts.yes = true;
|
|
41
|
-
const setupTasks = await lando.getSetupStatus(sopts);
|
|
36
|
+
// run setup if we need to
|
|
37
|
+
await require('../hooks/lando-run-setup')(lando);
|
|
42
38
|
|
|
43
39
|
try {
|
|
44
|
-
// run a limited setup if needed
|
|
45
|
-
if (setupTasks.length > 0) await lando.setup(sopts);
|
|
46
40
|
// If user has given us options then set those
|
|
47
41
|
if (!_.isEmpty(options.service)) app.opts = _.merge({}, app.opts, {services: options.service});
|
|
48
42
|
// rebuild hero
|
package/tasks/restart.js
CHANGED
|
@@ -16,17 +16,11 @@ module.exports = lando => {
|
|
|
16
16
|
if (app) {
|
|
17
17
|
console.log(lando.cli.makeArt('appRestart', {name: app.name, phase: 'pre'}));
|
|
18
18
|
|
|
19
|
-
// run
|
|
20
|
-
|
|
21
|
-
sopts.buildEngine = false;
|
|
22
|
-
sopts.skipCommonPlugins = true;
|
|
23
|
-
sopts.yes = true;
|
|
24
|
-
const setupTasks = await lando.getSetupStatus(sopts);
|
|
19
|
+
// run setup if we need to
|
|
20
|
+
await require('../hooks/lando-run-setup')(lando);
|
|
25
21
|
|
|
26
22
|
// Normal bootup
|
|
27
23
|
try {
|
|
28
|
-
// run a limited setup if needed
|
|
29
|
-
if (setupTasks.length > 0) await lando.setup(sopts);
|
|
30
24
|
// then restart
|
|
31
25
|
await app.restart();
|
|
32
26
|
// determine legacy settings
|