devzone 4.2.0 → 4.3.0
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/README.md +2 -0
- package/bin/SHA256SUMS +6 -0
- package/bin/devzone-darwin-amd64 +0 -0
- package/bin/devzone-darwin-arm64 +0 -0
- package/bin/devzone-linux-amd64 +0 -0
- package/bin/devzone-linux-arm64 +0 -0
- package/bin/devzone-windows-amd64.exe +0 -0
- package/bin/devzone-windows-arm64.exe +0 -0
- package/manage/devzone +104 -0
- package/manage/scripts/ci/build-binaries.sh +116 -0
- package/package.json +5 -1
package/README.md
CHANGED
|
@@ -43,6 +43,8 @@ Nothing is hosted: everything runs on your machine. `workspace/` is kept across
|
|
|
43
43
|
|
|
44
44
|
On Windows: it is recommended to clone with Git for Windows (the scripts keep LF line endings thanks to `.gitattributes`, and the npm command finds the `bash` it requires).
|
|
45
45
|
|
|
46
|
+
The npm package ships a compiled `devzone` binary for Linux, macOS and Windows (amd64 and arm64): the command runs in Go when a binary exists for your platform, and in bash otherwise.
|
|
47
|
+
|
|
46
48
|
#### Minimum memory per module
|
|
47
49
|
|
|
48
50
|
Measurements from 16/11/2026.
|
package/bin/SHA256SUMS
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
7355d857795451062f960158c2619eebc3fb3176fbc7f2162553aee1a1e6246b devzone-linux-amd64
|
|
2
|
+
6435128c4613c6a1836e4277d793d48eade13248be9ed84fca45c76fd59d4ee2 devzone-linux-arm64
|
|
3
|
+
4b4656b638a3dbd4479cfece3bea5538f93abee6481233fbff432456c0f1b66b devzone-darwin-amd64
|
|
4
|
+
03f4840c9d03b2cc86369ef951929d54a77e63865ff51c15156032c68be2f56a devzone-darwin-arm64
|
|
5
|
+
c60e9cd45629c4c5f72696960c064073f98551b5e73d5952e19a8cdcabdb1dbd devzone-windows-amd64.exe
|
|
6
|
+
aa41603aa549bbb5947971b50a679516b18fc50a5ae0db8aa876add9270e7e50 devzone-windows-arm64.exe
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/manage/devzone
CHANGED
|
@@ -44,6 +44,108 @@ version() {
|
|
|
44
44
|
node -p 'require(process.argv[1]).version' "$PAQUET/package.json" 2>/dev/null || echo inconnue
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
+
# Go binary of the package (#773). bin/devzone-<os>-<arch>[.exe] is built by
|
|
48
|
+
# prepack (manage/scripts/ci/build-binaries.sh) and listed with its SHA-256 in
|
|
49
|
+
# bin/SHA256SUMS. When one exists for this machine, it is checked, copied once
|
|
50
|
+
# into ${XDG_CACHE_HOME:-~/.cache}/devzone/bin/<version>/ (npm drops the
|
|
51
|
+
# executable bit of the files outside "bin"; the copy is atomic) and run in
|
|
52
|
+
# place of this script. Any problem, DEVZONE_NO_GO or DEVZONE_FROM_GO (set by the
|
|
53
|
+
# Go binary when it delegates to this script: no loop) keeps the bash command.
|
|
54
|
+
go_platform() {
|
|
55
|
+
local os arch
|
|
56
|
+
case "$(uname -s 2>/dev/null)" in
|
|
57
|
+
Linux) os=linux ;;
|
|
58
|
+
Darwin) os=darwin ;;
|
|
59
|
+
MINGW* | MSYS* | CYGWIN*) os=windows ;;
|
|
60
|
+
*) return 1 ;;
|
|
61
|
+
esac
|
|
62
|
+
case "$(uname -m 2>/dev/null)" in
|
|
63
|
+
x86_64 | amd64) arch=amd64 ;;
|
|
64
|
+
arm64 | aarch64) arch=arm64 ;;
|
|
65
|
+
*) return 1 ;;
|
|
66
|
+
esac
|
|
67
|
+
echo "$os-$arch"
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
# SHA-256 of file $1; node when neither sha256sum nor shasum exists
|
|
71
|
+
go_sha256() {
|
|
72
|
+
if command -v sha256sum >/dev/null 2>&1; then
|
|
73
|
+
sha256sum "$1" | cut -d' ' -f1
|
|
74
|
+
elif command -v shasum >/dev/null 2>&1; then
|
|
75
|
+
shasum -a 256 "$1" | cut -d' ' -f1
|
|
76
|
+
else
|
|
77
|
+
node -e 'const h = require("crypto").createHash("sha256"); h.update(require("fs").readFileSync(process.argv[1])); console.log(h.digest("hex"))' "$1"
|
|
78
|
+
fi
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
# Sum of file $2 in the SHA256SUMS file $1 (lines: "<sum> <name>")
|
|
82
|
+
go_listed_sum() {
|
|
83
|
+
local sum name
|
|
84
|
+
[ -f "$1" ] || return 1
|
|
85
|
+
while read -r sum name; do
|
|
86
|
+
if [ "${name#\*}" = "$2" ]; then
|
|
87
|
+
echo "$sum"
|
|
88
|
+
return 0
|
|
89
|
+
fi
|
|
90
|
+
done <"$1"
|
|
91
|
+
return 1
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
# Copies binary $1 to $2 (mode 755), then writes its sum $3 in $2.sha256: each
|
|
95
|
+
# step goes through a temporary file and mv, so a launch in parallel or a
|
|
96
|
+
# crash never leaves a half-written binary
|
|
97
|
+
go_install() {
|
|
98
|
+
local tmp
|
|
99
|
+
mkdir -p "$(dirname "$2")" || return 1
|
|
100
|
+
tmp="$(mktemp "$2.XXXXXX")" || return 1
|
|
101
|
+
if cp "$1" "$tmp" && chmod 755 "$tmp" && mv -f "$tmp" "$2" \
|
|
102
|
+
&& printf '%s\n' "$3" >"$tmp" && mv -f "$tmp" "$2.sha256"; then
|
|
103
|
+
return 0
|
|
104
|
+
fi
|
|
105
|
+
rm -f "$tmp"
|
|
106
|
+
return 1
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
# Runs the Go binary when it applies (never returns then); otherwise returns
|
|
110
|
+
go_launch() {
|
|
111
|
+
local platform ext="" name bin want have ver base target
|
|
112
|
+
if [ -n "${DEVZONE_NO_GO:-}" ] || [ -n "${DEVZONE_FROM_GO:-}" ]; then return 0; fi
|
|
113
|
+
platform="$(go_platform)" || return 0
|
|
114
|
+
case "$platform" in windows-*) ext=.exe ;; esac
|
|
115
|
+
name="devzone-$platform$ext"
|
|
116
|
+
bin="$PAQUET/bin/$name"
|
|
117
|
+
[ -f "$bin" ] || return 0
|
|
118
|
+
ver="$(version)"
|
|
119
|
+
[ "$ver" != inconnue ] || return 0
|
|
120
|
+
base="${XDG_CACHE_HOME:-}"
|
|
121
|
+
if [ -z "$base" ] && [ -n "${HOME:-}" ]; then base="$HOME/.cache"; fi
|
|
122
|
+
[ -n "$base" ] || return 0
|
|
123
|
+
target="$base/devzone/bin/$ver/devzone$ext"
|
|
124
|
+
want="$(go_listed_sum "$PAQUET/bin/SHA256SUMS" "$name")" || {
|
|
125
|
+
echo "devzone: no checksum for $name in bin/SHA256SUMS, using the bash command" >&2
|
|
126
|
+
return 0
|
|
127
|
+
}
|
|
128
|
+
if ! { [ -x "$target" ] && [ "$(cat "$target.sha256" 2>/dev/null)" = "$want" ]; }; then
|
|
129
|
+
have="$(go_sha256 "$bin")" || have=""
|
|
130
|
+
if [ "$have" != "$want" ]; then
|
|
131
|
+
echo "devzone: checksum of $name does not match bin/SHA256SUMS, using the bash command" >&2
|
|
132
|
+
return 0
|
|
133
|
+
fi
|
|
134
|
+
go_install "$bin" "$target" "$want" || {
|
|
135
|
+
echo "devzone: cannot copy $name to $target, using the bash command" >&2
|
|
136
|
+
return 0
|
|
137
|
+
}
|
|
138
|
+
fi
|
|
139
|
+
# The Go binary finds the bash command (and the package.json) from here, even
|
|
140
|
+
# copied into the cache; Git Bash gives it a Windows path
|
|
141
|
+
DEVZONE_BASH_ENTRY="$PAQUET/manage/devzone"
|
|
142
|
+
case "$platform" in
|
|
143
|
+
windows-*) DEVZONE_BASH_ENTRY="$(cygpath -m "$DEVZONE_BASH_ENTRY" 2>/dev/null || echo "$DEVZONE_BASH_ENTRY")" ;;
|
|
144
|
+
esac
|
|
145
|
+
export DEVZONE_BASH_ENTRY
|
|
146
|
+
exec "$target" "$@"
|
|
147
|
+
}
|
|
148
|
+
|
|
47
149
|
show_help() {
|
|
48
150
|
cat <<EOT
|
|
49
151
|
devzone $(version) : environnement de développement conteneurisé
|
|
@@ -82,6 +184,8 @@ container_command() {
|
|
|
82
184
|
esac
|
|
83
185
|
}
|
|
84
186
|
|
|
187
|
+
go_launch "$@"
|
|
188
|
+
|
|
85
189
|
# Renamed names (#695): the French names of the host and container commands are
|
|
86
190
|
# refused before anything is created (« devzone mettre-a-jour » must not create a
|
|
87
191
|
# folder; « devzone stop » still creates ./stop). A copied devzone may miss the
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# Builds the Go binary of devzone for the six platforms of the npm package
|
|
3
|
+
# (linux, darwin, windows; amd64, arm64) into bin/ at the root of the package
|
|
4
|
+
# (#773):
|
|
5
|
+
# bin/devzone-<os>-<arch> (.exe for windows)
|
|
6
|
+
# bin/SHA256SUMS one "<sum> <name>" line per binary
|
|
7
|
+
# It is the "prepack" script of package.json: it runs on "npm publish" and
|
|
8
|
+
# "npm pack", never with --ignore-scripts. manage/devzone checks the sums, then
|
|
9
|
+
# runs the binary of the machine.
|
|
10
|
+
#
|
|
11
|
+
# The runner of the publication has Go, but not necessarily the version of
|
|
12
|
+
# go.mod. The script reads the version the image uses (ARG GO_VERSION of
|
|
13
|
+
# .devcontainer/Dockerfile) and sets GOTOOLCHAIN to it: a Go 1.21 or newer
|
|
14
|
+
# downloads that exact toolchain by itself (3 attempts, 5 s apart). Without Go,
|
|
15
|
+
# or with a Go older than 1.21, it fails with the reason. A package with a
|
|
16
|
+
# missing binary is never produced: any failure exits 1.
|
|
17
|
+
#
|
|
18
|
+
# The version printed by "devzone --version" is not injected: the Go binary
|
|
19
|
+
# reads the package.json of the package, as the bash command does.
|
|
20
|
+
# Progress goes to the standard error: npm pack --json keeps its report clean.
|
|
21
|
+
# bash 3.2 (macOS).
|
|
22
|
+
|
|
23
|
+
set -euo pipefail
|
|
24
|
+
|
|
25
|
+
ICI="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
26
|
+
ROOT="$(cd "$ICI/../../.." && pwd)"
|
|
27
|
+
OUT="$ROOT/bin"
|
|
28
|
+
IMAGE_FILE="$ROOT/.devcontainer/Dockerfile"
|
|
29
|
+
TARGETS="linux-amd64 linux-arm64 darwin-amd64 darwin-arm64 windows-amd64 windows-arm64"
|
|
30
|
+
|
|
31
|
+
die() {
|
|
32
|
+
echo "build-binaries: $*" >&2
|
|
33
|
+
exit 1
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
# retry <attempts> <pause in seconds> <command...>: the command succeeds at the
|
|
37
|
+
# first attempt that works; the last failure is the result
|
|
38
|
+
retry() {
|
|
39
|
+
local attempts="$1" pause="$2" n=1
|
|
40
|
+
shift 2
|
|
41
|
+
until "$@"; do
|
|
42
|
+
[ "$n" -lt "$attempts" ] || return 1
|
|
43
|
+
echo "build-binaries: attempt $n of $attempts failed, new attempt in ${pause}s" >&2
|
|
44
|
+
n=$((n + 1))
|
|
45
|
+
sleep "$pause"
|
|
46
|
+
done
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
# SHA-256 of file $1
|
|
50
|
+
sha256_of() {
|
|
51
|
+
if command -v sha256sum >/dev/null 2>&1; then
|
|
52
|
+
sha256sum "$1" | cut -d' ' -f1
|
|
53
|
+
elif command -v shasum >/dev/null 2>&1; then
|
|
54
|
+
shasum -a 256 "$1" | cut -d' ' -f1
|
|
55
|
+
else
|
|
56
|
+
node -e 'const h = require("crypto").createHash("sha256"); h.update(require("fs").readFileSync(process.argv[1])); console.log(h.digest("hex"))' "$1"
|
|
57
|
+
fi
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
# Selects the Go toolchain of the image through GOTOOLCHAIN
|
|
61
|
+
select_toolchain() {
|
|
62
|
+
local want local_version major minor
|
|
63
|
+
[ -f "$IMAGE_FILE" ] || die "$IMAGE_FILE not found (the Go version is read there)"
|
|
64
|
+
want="$(sed -n 's/^ARG GO_VERSION=//p' "$IMAGE_FILE" | head -n 1)"
|
|
65
|
+
[ -n "$want" ] || die "no ARG GO_VERSION in $IMAGE_FILE"
|
|
66
|
+
command -v go >/dev/null 2>&1 || die "go not found: install Go 1.21 or newer (the build then downloads Go $want by itself)"
|
|
67
|
+
local_version="$(go version | sed -n 's/^go version go\([0-9][0-9.]*\).*/\1/p')"
|
|
68
|
+
[ -n "$local_version" ] || die "cannot read the version of go (go version: $(go version))"
|
|
69
|
+
major="${local_version%%.*}"
|
|
70
|
+
minor="${local_version#*.}"
|
|
71
|
+
minor="${minor%%.*}"
|
|
72
|
+
if [ "$major" -lt 1 ] || { [ "$major" -eq 1 ] && [ "$minor" -lt 21 ]; }; then
|
|
73
|
+
die "go $local_version is too old: Go 1.21 or newer is needed to select Go $want (GOTOOLCHAIN)"
|
|
74
|
+
fi
|
|
75
|
+
export GOTOOLCHAIN="go$want"
|
|
76
|
+
# Downloads the toolchain now, with retries: a network failure stops here
|
|
77
|
+
retry 3 5 go version >/dev/null || die "cannot obtain the Go $want toolchain (network?)"
|
|
78
|
+
[ "$(go version | sed -n 's/^go version go\([0-9][0-9.]*\).*/\1/p')" = "$want" ] \
|
|
79
|
+
|| die "go $want expected, got: $(go version)"
|
|
80
|
+
echo "build-binaries: $(go version)" >&2
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
build_all() {
|
|
84
|
+
local target goos goarch name
|
|
85
|
+
rm -rf "$OUT"
|
|
86
|
+
mkdir -p "$OUT"
|
|
87
|
+
for target in $TARGETS; do
|
|
88
|
+
goos="${target%-*}"
|
|
89
|
+
goarch="${target#*-}"
|
|
90
|
+
name="devzone-$target"
|
|
91
|
+
[ "$goos" != windows ] || name="$name.exe"
|
|
92
|
+
echo "build-binaries: $name" >&2
|
|
93
|
+
(cd "$ROOT" && CGO_ENABLED=0 GOOS="$goos" GOARCH="$goarch" \
|
|
94
|
+
go build -trimpath -ldflags "-s -w" -o "$OUT/$name" ./cmd/devzone) \
|
|
95
|
+
|| die "build of $name failed"
|
|
96
|
+
done
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
# Writes bin/SHA256SUMS and refuses a package with a missing or empty binary
|
|
100
|
+
write_sums() {
|
|
101
|
+
local target name count=0
|
|
102
|
+
: >"$OUT/SHA256SUMS"
|
|
103
|
+
for target in $TARGETS; do
|
|
104
|
+
name="devzone-$target"
|
|
105
|
+
case "$target" in windows-*) name="$name.exe" ;; esac
|
|
106
|
+
[ -s "$OUT/$name" ] || die "binary missing or empty: bin/$name"
|
|
107
|
+
printf '%s %s\n' "$(sha256_of "$OUT/$name")" "$name" >>"$OUT/SHA256SUMS"
|
|
108
|
+
count=$((count + 1))
|
|
109
|
+
done
|
|
110
|
+
[ "$count" -eq 6 ] || die "$count binaries instead of 6"
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
select_toolchain
|
|
114
|
+
build_all
|
|
115
|
+
write_sums
|
|
116
|
+
echo "build-binaries: 6 binaries and SHA256SUMS in $OUT" >&2
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "devzone",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.3.0",
|
|
4
4
|
"description": "Ton poste de développement Linux, prêt en une commande, identique sur Mac, Windows et Linux.",
|
|
5
5
|
"license": "GPL-3.0-only",
|
|
6
6
|
"repository": {
|
|
@@ -19,7 +19,11 @@
|
|
|
19
19
|
"bin": {
|
|
20
20
|
"devzone": "manage/devzone"
|
|
21
21
|
},
|
|
22
|
+
"scripts": {
|
|
23
|
+
"prepack": "bash manage/scripts/ci/build-binaries.sh"
|
|
24
|
+
},
|
|
22
25
|
"files": [
|
|
26
|
+
"bin/",
|
|
23
27
|
"manage/devzone",
|
|
24
28
|
".devcontainer/",
|
|
25
29
|
"Makefile",
|