freecode-sh 0.1.0-alpha.18 → 0.1.0-alpha.20
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/freecode.mjs +8 -2
- package/install.sh +55 -15
- package/npm-bootstrap-environment.mjs +7 -0
- package/package.json +2 -1
package/freecode.mjs
CHANGED
|
@@ -6,6 +6,7 @@ import { access, readFile, realpath } from 'node:fs/promises'
|
|
|
6
6
|
import { homedir } from 'node:os'
|
|
7
7
|
import { dirname, isAbsolute, join, relative, resolve, sep } from 'node:path'
|
|
8
8
|
import { fileURLToPath } from 'node:url'
|
|
9
|
+
import { withoutPowerShellModulePath } from './npm-bootstrap-environment.mjs'
|
|
9
10
|
|
|
10
11
|
const packageDirectory = dirname(fileURLToPath(import.meta.url))
|
|
11
12
|
const bootstrapPath = fileURLToPath(import.meta.url)
|
|
@@ -61,12 +62,17 @@ if (nativeVersion && compareAlphaVersions(nativeVersion, packageMetadata.version
|
|
|
61
62
|
args: ['-NoLogo', '-NoProfile', '-ExecutionPolicy', 'Bypass', '-File', join(packageDirectory, 'install.ps1'), '-Version', packageMetadata.version],
|
|
62
63
|
}
|
|
63
64
|
: { command: '/bin/sh', args: [join(packageDirectory, 'install.sh'), '--version', packageMetadata.version] }
|
|
64
|
-
const
|
|
65
|
+
const installerEnvironment = {
|
|
65
66
|
...process.env,
|
|
66
67
|
FREECODE_INSTALL_ROOT: installRoot,
|
|
67
68
|
FREECODE_BIN_DIR: binDirectory,
|
|
68
69
|
FREECODE_INSTALL_EMBEDDED: 'true',
|
|
69
|
-
}
|
|
70
|
+
}
|
|
71
|
+
const installStatus = await run(
|
|
72
|
+
installer.command,
|
|
73
|
+
installer.args,
|
|
74
|
+
windows ? withoutPowerShellModulePath(installerEnvironment) : installerEnvironment,
|
|
75
|
+
)
|
|
70
76
|
if (installStatus !== 0) process.exit(installStatus)
|
|
71
77
|
nativeVersion = await managedNativeVersion(nativeExecutable, installRoot, platform)
|
|
72
78
|
if (!nativeVersion || compareAlphaVersions(nativeVersion, packageMetadata.version) < 0) {
|
package/install.sh
CHANGED
|
@@ -9,6 +9,14 @@ DEFAULT_CHANNEL="alpha"
|
|
|
9
9
|
DEFAULT_DOWNLOAD_BASE_URL="https://releases.freecode.sh/releases"
|
|
10
10
|
DEFAULT_CHANNEL_BASE_URL="https://releases.freecode.sh/channels"
|
|
11
11
|
EXPECTED_TEAM_IDENTIFIER="GD597P8KJ2"
|
|
12
|
+
# Apple code requirement language. "anchor apple generic" forces the signing
|
|
13
|
+
# chain to terminate at Apple's root certificate, so only a real Developer ID
|
|
14
|
+
# certificate issued to this team can satisfy it. Text printed by
|
|
15
|
+
# `codesign --display` cannot be trusted for this: Authority and TeamIdentifier
|
|
16
|
+
# lines are read straight out of the certificate, so a self-signed certificate
|
|
17
|
+
# can present any subject and OU it likes.
|
|
18
|
+
RELEASE_CODE_REQUIREMENT="=anchor apple generic and certificate leaf[subject.OU] = \"$EXPECTED_TEAM_IDENTIFIER\""
|
|
19
|
+
CODESIGN_BIN="/usr/bin/codesign"
|
|
12
20
|
LEGACY_ALPHA6_MANIFEST_SHA256="1bf63e0d6114b12d61c07094936bd2606ae82ce87d5b054fbfb01c5f3d3646d8"
|
|
13
21
|
LAUNCHER_RELATIVE_PATH="bin/freecode"
|
|
14
22
|
INTERFACE_RELATIVE_PATH="libexec/freecode/freecode-tui"
|
|
@@ -374,6 +382,18 @@ validate_release_security() {
|
|
|
374
382
|
esac
|
|
375
383
|
}
|
|
376
384
|
|
|
385
|
+
# Test-only seam. Signature verification runs /usr/bin/codesign by absolute path
|
|
386
|
+
# so nothing on PATH can impersonate it; the installer test suite substitutes a
|
|
387
|
+
# stub, and like every other FREECODE_TEST_* override it is refused unless the
|
|
388
|
+
# release is being read from a local file:// URL.
|
|
389
|
+
resolve_codesign_bin() {
|
|
390
|
+
[ -n "${FREECODE_TEST_CODESIGN_BIN:-}" ] || return 0
|
|
391
|
+
case "$DOWNLOAD_BASE_URL" in
|
|
392
|
+
file://*) CODESIGN_BIN="$FREECODE_TEST_CODESIGN_BIN" ;;
|
|
393
|
+
*) fail "the test codesign override is permitted only with local file URLs" ;;
|
|
394
|
+
esac
|
|
395
|
+
}
|
|
396
|
+
|
|
377
397
|
verify_release_signatures() {
|
|
378
398
|
root=$1
|
|
379
399
|
if [ "$RELEASE_MODE" = "unsigned-override" ]; then
|
|
@@ -381,19 +401,15 @@ verify_release_signatures() {
|
|
|
381
401
|
return
|
|
382
402
|
fi
|
|
383
403
|
|
|
384
|
-
[ -x
|
|
404
|
+
[ -x "$CODESIGN_BIN" ] || fail "$CODESIGN_BIN is required to verify this release"
|
|
385
405
|
for executable in \
|
|
386
406
|
"$root/$LAUNCHER_RELATIVE_PATH" \
|
|
387
407
|
"$root/$INTERFACE_RELATIVE_PATH" \
|
|
388
408
|
"$root/$ENGINE_RELATIVE_PATH"
|
|
389
409
|
do
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|| fail "could not inspect Apple signature for $executable"
|
|
394
|
-
TEAM_IDENTIFIER=$(printf '%s\n' "$SIGNATURE_DETAILS" | sed -n 's/^TeamIdentifier=//p' | head -n 1)
|
|
395
|
-
[ "$TEAM_IDENTIFIER" = "$EXPECTED_TEAM_IDENTIFIER" ] \
|
|
396
|
-
|| fail "unexpected Apple TeamIdentifier for $executable (expected $EXPECTED_TEAM_IDENTIFIER, received ${TEAM_IDENTIFIER:-missing})"
|
|
410
|
+
# Without -R this only proves the seal is intact, not who signed it.
|
|
411
|
+
"$CODESIGN_BIN" --verify --strict --verbose=2 -R "$RELEASE_CODE_REQUIREMENT" "$executable" \
|
|
412
|
+
|| fail "Apple signature verification failed for $executable; it must be Developer ID signed by Apple team $EXPECTED_TEAM_IDENTIFIER"
|
|
397
413
|
done
|
|
398
414
|
}
|
|
399
415
|
|
|
@@ -466,6 +482,8 @@ DOWNLOAD_BASE_URL=${DOWNLOAD_BASE_URL%/}
|
|
|
466
482
|
CHANNEL_BASE_URL=${CHANNEL_BASE_URL%/}
|
|
467
483
|
validate_channel "$CHANNEL"
|
|
468
484
|
|
|
485
|
+
resolve_codesign_bin
|
|
486
|
+
|
|
469
487
|
TEMP_DIR=$(mktemp -d "${TMPDIR:-/tmp}/freecode-install.XXXXXX")
|
|
470
488
|
RELEASE_PUBLIC_KEY="$TEMP_DIR/release-signing-public.pem"
|
|
471
489
|
write_release_public_key "$RELEASE_PUBLIC_KEY"
|
|
@@ -627,16 +645,38 @@ printf '\nUninstall:\n'
|
|
|
627
645
|
printf ' rm -f "%s/freecode" && rm -rf "%s"\n' "$BIN_DIR" "$INSTALL_ROOT"
|
|
628
646
|
|
|
629
647
|
if [ "$LAUNCH_AFTER_INSTALL" = "true" ]; then
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
648
|
+
if [ -n "${FREECODE_TEST_TTY_FILE:-}" ]; then
|
|
649
|
+
if [ -r "$FREECODE_TEST_TTY_FILE" ]; then
|
|
650
|
+
CAN_LAUNCH="true"
|
|
651
|
+
else
|
|
652
|
+
CAN_LAUNCH="false"
|
|
653
|
+
fi
|
|
654
|
+
elif [ -t 1 ]; then
|
|
655
|
+
CAN_LAUNCH="true"
|
|
656
|
+
else
|
|
657
|
+
CAN_LAUNCH="false"
|
|
633
658
|
fi
|
|
634
|
-
|
|
659
|
+
|
|
660
|
+
if [ "$CAN_LAUNCH" = "true" ]; then
|
|
635
661
|
printf '\nStarting Free Code...\n'
|
|
636
|
-
if
|
|
637
|
-
|
|
662
|
+
if [ -n "${FREECODE_TEST_TTY_FILE:-}" ]; then
|
|
663
|
+
if "$BIN_DIR/freecode" < "$FREECODE_TEST_TTY_FILE"; then
|
|
664
|
+
LAUNCH_SUCCEEDED="true"
|
|
665
|
+
else
|
|
666
|
+
LAUNCH_SUCCEEDED="false"
|
|
667
|
+
fi
|
|
668
|
+
elif "$BIN_DIR/freecode" 0<&1; then
|
|
669
|
+
LAUNCH_SUCCEEDED="true"
|
|
670
|
+
else
|
|
671
|
+
LAUNCH_SUCCEEDED="false"
|
|
672
|
+
fi
|
|
673
|
+
|
|
674
|
+
if [ "$LAUNCH_SUCCEEDED" != "true" ]; then
|
|
675
|
+
printf '\nFree Code could not start automatically, but the installation succeeded.\n' >&2
|
|
676
|
+
printf 'Open a Terminal and run:\n "%s/freecode"\n' "$BIN_DIR" >&2
|
|
638
677
|
fi
|
|
639
678
|
else
|
|
640
|
-
printf '\nFree Code is installed. Open a Terminal and run
|
|
679
|
+
printf '\nFree Code is installed. Open a Terminal and run:\n'
|
|
680
|
+
printf ' "%s/freecode"\n' "$BIN_DIR"
|
|
641
681
|
fi
|
|
642
682
|
fi
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "freecode-sh",
|
|
3
|
-
"version": "0.1.0-alpha.
|
|
3
|
+
"version": "0.1.0-alpha.20",
|
|
4
4
|
"description": "A free coding agent for your terminal.",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"author": "Free Code",
|
|
@@ -27,6 +27,7 @@
|
|
|
27
27
|
"files": [
|
|
28
28
|
"check-platform.mjs",
|
|
29
29
|
"freecode.mjs",
|
|
30
|
+
"npm-bootstrap-environment.mjs",
|
|
30
31
|
"install.sh",
|
|
31
32
|
"install.ps1"
|
|
32
33
|
],
|