@intempt-technologies/cli 0.2.0 → 0.4.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@intempt-technologies/cli",
3
- "version": "0.2.0",
3
+ "version": "0.4.0",
4
4
  "description": "Schema-driven typed SDK wrapper generator for Intempt",
5
5
  "type": "module",
6
6
  "bin": {
@@ -8,7 +8,9 @@
8
8
  },
9
9
  "files": [
10
10
  "dist",
11
- "AGENTS.md"
11
+ "AGENTS.md",
12
+ "scripts/install.sh",
13
+ "scripts/install.ps1"
12
14
  ],
13
15
  "scripts": {
14
16
  "build": "bun build ./src/index.tsx --outdir ./dist --target node --format esm --minify",
@@ -0,0 +1,80 @@
1
+ # Installs the Intempt CLI on Windows. Served so that this works:
2
+ #
3
+ # irm https://intempt.com/api/cli/ps1 | iex
4
+ #
5
+ # Reads INTEMPT_VERSION to pin a version, INTEMPT_HOME for the install root
6
+ # (default ~\.intempt) and INTEMPT_BIN_DIR for the shim (default ~\.local\bin).
7
+ $ErrorActionPreference = 'Stop'
8
+
9
+ $Package = '@intempt-technologies/cli'
10
+ $Version = if ($env:INTEMPT_VERSION) { $env:INTEMPT_VERSION } else { 'latest' }
11
+ $HomeDir = if ($env:INTEMPT_HOME) { $env:INTEMPT_HOME } else { Join-Path $HOME '.intempt' }
12
+ $BinDir = if ($env:INTEMPT_BIN_DIR) { $env:INTEMPT_BIN_DIR } else { Join-Path $HOME '.local\bin' }
13
+
14
+ function Say([string]$Message) { Write-Host " $Message" }
15
+ function Die([string]$Message) { Write-Host " error: $Message" -ForegroundColor Red; exit 1 }
16
+
17
+ function Get-Platform {
18
+ # Cosmetic, exactly as in install.sh: this string is only ever printed. npm
19
+ # installs the same pure-JavaScript package whatever the architecture, so an
20
+ # unfamiliar PROCESSOR_ARCHITECTURE is reported rather than refused.
21
+ $arch = switch ($env:PROCESSOR_ARCHITECTURE) {
22
+ 'AMD64' { 'x64' }
23
+ 'ARM64' { 'arm64' }
24
+ default { if ($env:PROCESSOR_ARCHITECTURE) { $env:PROCESSOR_ARCHITECTURE.ToLower() } else { 'unknown' } }
25
+ }
26
+ return "windows-$arch"
27
+ }
28
+
29
+ $node = Get-Command node -ErrorAction SilentlyContinue
30
+ if (-not $node) { Die 'Node.js 18+ is required and was not found on PATH. See https://nodejs.org' }
31
+ # PowerShell strips the inner double quotes from a `node -p` expression before
32
+ # node sees it, so the version string is split here.
33
+ $nodeVersion = (& node -p 'process.versions.node').Trim()
34
+ $major = [int](($nodeVersion -split '\.')[0])
35
+ if ($major -lt 18) { Die "Node.js 18+ is required; found v$nodeVersion" }
36
+
37
+ $npm = Get-Command npm -ErrorAction SilentlyContinue
38
+ if (-not $npm) { Die 'npm is required and was not found on PATH.' }
39
+
40
+ # An existing copy stays where it is. Which one runs is PATH order, so say so
41
+ # rather than leaving two `intempt`s to be discovered later.
42
+ $existing = Get-Command intempt -ErrorAction SilentlyContinue
43
+ if ($existing -and $existing.Source -ne (Join-Path $BinDir 'intempt.cmd')) {
44
+ Say "note: another intempt is already on your PATH at $($existing.Source)"
45
+ }
46
+
47
+ Say "downloading intempt ($(Get-Platform))..."
48
+ New-Item -ItemType Directory -Force -Path $HomeDir, $BinDir | Out-Null
49
+
50
+ # --prefix keeps the install inside INTEMPT_HOME rather than the machine-wide
51
+ # npm root, so uninstalling is `Remove-Item -Recurse ~\.intempt`.
52
+ & npm install --silent --no-fund --no-audit --prefix $HomeDir "$Package@$Version" 2>$null | Out-Null
53
+ if ($LASTEXITCODE -ne 0) { Die "download failed. Retry, or install with: npm i -g $Package" }
54
+
55
+ $installed = Join-Path $HomeDir 'node_modules\.bin\intempt.cmd'
56
+ if (-not (Test-Path $installed)) { Die "install completed but $installed is missing" }
57
+ Say "installed -> $installed"
58
+
59
+ # Creating a symlink on Windows needs Developer Mode or an elevated shell; a
60
+ # .cmd shim needs neither. cmd.exe reads a .cmd in the console's OEM codepage,
61
+ # which is the only encoding a non-ASCII path survives here.
62
+ $shim = Join-Path $BinDir 'intempt.cmd'
63
+ Set-Content -Path $shim -Encoding oem -Value "@echo off`r`n`"$installed`" %*"
64
+
65
+ # The shim carries an absolute path through a codepage, so it is executed once
66
+ # before success is reported.
67
+ & $shim --version > $null 2>&1
68
+ if ($LASTEXITCODE -ne 0) {
69
+ Die "the installed shim did not run. Use the npm install instead: npm i -g $Package"
70
+ }
71
+
72
+ $onPath = ($env:PATH -split ';') -contains $BinDir
73
+ if ($onPath) {
74
+ Say "linked $shim (already on your PATH)"
75
+ } else {
76
+ Say "linked $shim"
77
+ Say "add it to your PATH: setx PATH `"$BinDir;%PATH%`""
78
+ }
79
+
80
+ Say 'run: intempt'
@@ -0,0 +1,89 @@
1
+ #!/usr/bin/env bash
2
+ # Installs the Intempt CLI. Served so that this works:
3
+ #
4
+ # curl -fsSL https://intempt.com/api/cli | bash
5
+ #
6
+ # Reads INTEMPT_VERSION to pin a version, INTEMPT_HOME for the install root
7
+ # (default ~/.intempt) and INTEMPT_BIN_DIR for the link (default ~/.local/bin).
8
+ set -euo pipefail
9
+
10
+ PACKAGE="@intempt-technologies/cli"
11
+ VERSION="${INTEMPT_VERSION:-latest}"
12
+ HOME_DIR="${INTEMPT_HOME:-$HOME/.intempt}"
13
+ BIN_DIR="${INTEMPT_BIN_DIR:-$HOME/.local/bin}"
14
+
15
+ say() { printf ' %s\n' "$*"; }
16
+ die() { printf ' error: %s\n' "$*" >&2; exit 1; }
17
+
18
+ platform() {
19
+ local os arch
20
+ case "$(uname -s)" in
21
+ Darwin) os=macos ;;
22
+ Linux) os=linux ;;
23
+ *) die "unsupported OS: $(uname -s). Install with: npm i -g $PACKAGE" ;;
24
+ esac
25
+ # The label this builds is COSMETIC -- it appears in "downloading intempt (...)"
26
+ # and nowhere else. What actually installs is `npm install <package>`, and the
27
+ # package is pure JavaScript, so it resolves the same on every architecture.
28
+ # Refusing an unfamiliar one therefore blocked an install that would have
29
+ # succeeded, on armv7l, i686 and riscv64 among others, and -- unlike the OS
30
+ # branch above -- without naming any way forward. An architecture we do not
31
+ # have a name for is reported as the kernel spells it, and the install runs.
32
+ case "$(uname -m)" in
33
+ arm64|aarch64) arch=arm64 ;;
34
+ x86_64|amd64) arch=x64 ;;
35
+ *) arch="$(uname -m)" ;;
36
+ esac
37
+ printf '%s-%s' "$os" "$arch"
38
+ }
39
+
40
+ node_major() {
41
+ command -v node >/dev/null 2>&1 || return 1
42
+ node -p 'process.versions.node.split(".")[0]' 2>/dev/null || return 1
43
+ }
44
+
45
+ on_path() {
46
+ case ":${PATH}:" in *":$1:"*) return 0 ;; *) return 1 ;; esac
47
+ }
48
+
49
+ main() {
50
+ local target major
51
+ target="$(platform)"
52
+
53
+ major="$(node_major || true)"
54
+ [ -n "$major" ] || die "Node.js 18+ is required and was not found on PATH. See https://nodejs.org"
55
+ [ "$major" -ge 18 ] || die "Node.js 18+ is required; found $(node -v)"
56
+ command -v npm >/dev/null 2>&1 || die "npm is required and was not found on PATH."
57
+
58
+ # An existing copy stays where it is. Which one runs is PATH order, so say so
59
+ # rather than leaving two `intempt`s to be discovered later.
60
+ local existing
61
+ existing="$(command -v intempt 2>/dev/null || true)"
62
+ if [ -n "$existing" ] && [ "$existing" != "$BIN_DIR/intempt" ]; then
63
+ say "note: another intempt is already on your PATH at $existing"
64
+ fi
65
+
66
+ say "downloading intempt ($target)..."
67
+ mkdir -p "$HOME_DIR" "$BIN_DIR"
68
+
69
+ # --prefix keeps the install inside INTEMPT_HOME rather than the user's
70
+ # global npm root, so uninstalling is `rm -rf ~/.intempt`.
71
+ npm install --silent --no-fund --no-audit --prefix "$HOME_DIR" "${PACKAGE}@${VERSION}" \
72
+ >/dev/null 2>&1 || die "download failed. Retry, or install with: npm i -g $PACKAGE"
73
+
74
+ local installed="$HOME_DIR/node_modules/.bin/intempt"
75
+ [ -x "$installed" ] || die "install completed but $installed is missing"
76
+ say "installed -> $installed"
77
+
78
+ ln -sf "$installed" "$BIN_DIR/intempt"
79
+ if on_path "$BIN_DIR"; then
80
+ say "linked $BIN_DIR/intempt (already on your PATH)"
81
+ else
82
+ say "linked $BIN_DIR/intempt"
83
+ say "add it to your PATH: export PATH=\"$BIN_DIR:\$PATH\""
84
+ fi
85
+
86
+ say "run: intempt"
87
+ }
88
+
89
+ main "$@"