oh-my-devpod 0.14.2 → 0.14.4

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 CHANGED
@@ -24,6 +24,16 @@ npm update -g oh-my-devpod
24
24
  ```
25
25
 
26
26
  npm updates retain the saved source choice. Set
27
- `OHMYDEVPOD_SOURCE=github|gitee` during an update only when changing it.
27
+ the source independently of npm updates with:
28
+
29
+ ```bash
30
+ omd --source gitee
31
+ omd --source github
32
+ ```
33
+
34
+ This also migrates native source configuration for already installed,
35
+ OMD-managed Linuxbrew, uv, Micromamba, and pip environments. User-owned
36
+ configuration is preserved.
37
+
28
38
  `omd --update` is reserved for bootstrap-managed installations and is rejected
29
39
  in the npm package.
package/bin/omd CHANGED
@@ -9,10 +9,14 @@ while [[ -L "${script_path}" ]]; do
9
9
  done
10
10
 
11
11
  package_root="$(cd "$(dirname "${script_path}")/.." && pwd)"
12
- source_file="${package_root}/.npm-source"
12
+ package_source_file="${package_root}/.npm-source"
13
+ config_dir="${OHMYDEVPOD_CONFIG_DIR:-${XDG_CONFIG_HOME:-${HOME}/.config}/oh-my-devpod}"
14
+ persisted_source_file="${config_dir}/npm-source"
13
15
  runtime_root="${package_root}/runtime"
14
16
  runtime_binary="${runtime_root}/bin/omd"
15
17
 
18
+ source_file="${persisted_source_file}"
19
+ [[ -f "${source_file}" ]] || source_file="${package_source_file}"
16
20
  [[ -f "${source_file}" ]] || {
17
21
  printf 'oh-my-devpod: npm source selection is missing; reinstall the package\n' >&2
18
22
  exit 1
@@ -35,6 +39,7 @@ esac
35
39
  export OHMYDEVPOD_BUNDLE_ROOT="${runtime_root}"
36
40
  export OHMYDEVPOD_INSTALL_CHANNEL="npm"
37
41
  export OHMYDEVPOD_NPM_SOURCE="${source_name}"
42
+ export OHMYDEVPOD_CONFIG_DIR="${config_dir}"
38
43
  export OHMYDEVPOD_BIN_DIR="${OHMYDEVPOD_BIN_DIR:-${HOME}/.local/bin}"
39
44
 
40
45
  exec "${runtime_binary}" "$@"
package/lib/source.js CHANGED
@@ -15,6 +15,9 @@ function selectSource(value, persistedValue) {
15
15
  }
16
16
 
17
17
  function sourceStatePath(env = process.env, homeDirectory = os.homedir()) {
18
+ if (env.OHMYDEVPOD_CONFIG_DIR) {
19
+ return path.join(env.OHMYDEVPOD_CONFIG_DIR, "npm-source");
20
+ }
18
21
  const configHome = env.XDG_CONFIG_HOME || path.join(homeDirectory, ".config");
19
22
  return path.join(configHome, "oh-my-devpod", "npm-source");
20
23
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "oh-my-devpod",
3
- "version": "0.14.2",
3
+ "version": "0.14.4",
4
4
  "description": "Ubuntu productivity tool manager with the omd terminal interface",
5
5
  "license": "MIT",
6
6
  "author": "zhangdw156",
package/runtime/VERSION CHANGED
@@ -1 +1 @@
1
- 0.14.2
1
+ 0.14.4
package/runtime/bin/omd CHANGED
Binary file
@@ -0,0 +1,141 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+
4
+ api_base="${OHMYDEVPOD_GITEE_CLI_API_BASE:-https://gitee.com/api/v5}"
5
+ release_base="${OHMYDEVPOD_GITEE_CLI_RELEASE_BASE:-https://gitee.com/oschina/gitee-cli/releases/download}"
6
+ requested_version="${OHMYDEVPOD_GITEE_CLI_VERSION:-latest}"
7
+ bin_dir="${OHMYDEVPOD_BIN_DIR:-${HOME}/.local/bin}"
8
+ target_arch="${TARGETARCH:-}"
9
+ repo="oschina/gitee-cli"
10
+ staged_path=""
11
+
12
+ fail() {
13
+ printf 'error: %s\n' "$*" >&2
14
+ exit 1
15
+ }
16
+
17
+ download() {
18
+ local url="$1" destination="$2"
19
+ curl \
20
+ -fsSL \
21
+ --retry 3 \
22
+ --retry-delay 2 \
23
+ --retry-connrefused \
24
+ --connect-timeout 15 \
25
+ --max-time 300 \
26
+ "${url}" \
27
+ -o "${destination}"
28
+ }
29
+
30
+ sha256_file() {
31
+ local path="$1"
32
+ if command -v sha256sum >/dev/null 2>&1; then
33
+ sha256sum "${path}" | awk '{print $1}'
34
+ elif command -v shasum >/dev/null 2>&1; then
35
+ shasum -a 256 "${path}" | awk '{print $1}'
36
+ else
37
+ fail "sha256sum or shasum is required"
38
+ fi
39
+ }
40
+
41
+ json_field() {
42
+ local key="$1"
43
+ grep -o "\"${key}\"[[:space:]]*:[[:space:]]*\"[^\"]*\"" |
44
+ sed 's/^[^:]*:[[:space:]]*"\([^"]*\)"$/\1/' |
45
+ head -n 1
46
+ }
47
+
48
+ if [[ -z "${target_arch}" ]]; then
49
+ target_arch="$(uname -m)"
50
+ fi
51
+
52
+ case "${target_arch}" in
53
+ amd64|x86_64)
54
+ release_arch="amd64"
55
+ ;;
56
+ arm64|aarch64)
57
+ release_arch="arm64"
58
+ ;;
59
+ *)
60
+ fail "unsupported architecture for Gitee CLI: ${target_arch}"
61
+ ;;
62
+ esac
63
+
64
+ if [[ "${requested_version}" == "latest" ]]; then
65
+ release_endpoint="${api_base}/repos/${repo}/releases/latest"
66
+ else
67
+ release_tag="${requested_version}"
68
+ [[ "${release_tag}" == v* ]] || release_tag="v${release_tag}"
69
+ release_endpoint="${api_base}/repos/${repo}/releases/tags/${release_tag}"
70
+ fi
71
+
72
+ tmp_dir="$(mktemp -d)"
73
+ cleanup() {
74
+ rm -rf "${tmp_dir}"
75
+ [[ -z "${staged_path}" ]] || rm -f "${staged_path}"
76
+ }
77
+ trap cleanup EXIT
78
+
79
+ release_json_path="${tmp_dir}/release.json"
80
+ download "${release_endpoint}" "${release_json_path}" ||
81
+ fail "failed to fetch Gitee CLI release metadata"
82
+ release_json="$(cat "${release_json_path}")"
83
+ release_tag="$(printf '%s' "${release_json}" | json_field tag_name)"
84
+ [[ "${release_tag}" =~ ^v[0-9][0-9A-Za-z.-]*$ ]] ||
85
+ fail "invalid Gitee CLI release tag: ${release_tag:-missing}"
86
+
87
+ release_version="${release_tag#v}"
88
+ archive_name="gitee_${release_version}_linux_${release_arch}.tar.gz"
89
+ archive_url="${release_base}/${release_tag}/${archive_name}"
90
+ checksums_url="${release_base}/${release_tag}/checksums.txt"
91
+
92
+ archive_path="${tmp_dir}/${archive_name}"
93
+ checksums_path="${tmp_dir}/checksums.txt"
94
+ download "${archive_url}" "${archive_path}" ||
95
+ fail "failed to download ${archive_name}"
96
+ download "${checksums_url}" "${checksums_path}" ||
97
+ fail "failed to download checksums.txt"
98
+
99
+ expected_sha="$(
100
+ awk -v name="${archive_name}" \
101
+ '$2 == name || $2 == "./" name {print $1}' \
102
+ "${checksums_path}" |
103
+ head -n 1
104
+ )"
105
+ [[ "${expected_sha}" =~ ^[[:xdigit:]]{64}$ ]] ||
106
+ fail "checksums.txt has no valid SHA-256 entry for ${archive_name}"
107
+ actual_sha="$(sha256_file "${archive_path}")"
108
+ [[ "${actual_sha}" == "${expected_sha}" ]] ||
109
+ fail "checksum mismatch for ${archive_name}"
110
+
111
+ extract_dir="${tmp_dir}/extract"
112
+ mkdir -p "${extract_dir}"
113
+ tar -xzf "${archive_path}" -C "${extract_dir}" gitee ||
114
+ fail "failed to extract Gitee CLI binary"
115
+ [[ -f "${extract_dir}/gitee" && ! -L "${extract_dir}/gitee" ]] ||
116
+ fail "release archive does not contain a regular gitee binary"
117
+ chmod 0755 "${extract_dir}/gitee"
118
+
119
+ version_output="$("${extract_dir}/gitee" --version 2>&1)" ||
120
+ fail "downloaded Gitee CLI binary failed validation"
121
+ version_matches=false
122
+ for version_token in ${version_output}; do
123
+ version_token="${version_token#v}"
124
+ if [[ "${version_token}" == "${release_version}" ]]; then
125
+ version_matches=true
126
+ break
127
+ fi
128
+ done
129
+ [[ "${version_matches}" == "true" ]] ||
130
+ fail "downloaded Gitee CLI version does not match ${release_tag}"
131
+
132
+ mkdir -p "${bin_dir}"
133
+ [[ ! -d "${bin_dir}/gitee" ]] ||
134
+ fail "refusing to replace directory: ${bin_dir}/gitee"
135
+ staged_path="${bin_dir}/.gitee.tmp.$$"
136
+ install -m 0755 "${extract_dir}/gitee" "${staged_path}"
137
+ mv -f "${staged_path}" "${bin_dir}/gitee"
138
+ staged_path=""
139
+ [[ -f "${bin_dir}/gitee" && -x "${bin_dir}/gitee" ]]
140
+
141
+ printf 'Installed Gitee CLI %s to %s\n' "${release_tag}" "${bin_dir}/gitee"
@@ -50,6 +50,26 @@ requires = []
50
50
  install_requires = ["linuxbrew"]
51
51
  uninstall = true
52
52
 
53
+ [[component]]
54
+ id = "gh"
55
+ name = "GitHub CLI"
56
+ description = "Official command-line client for GitHub"
57
+ category = "development"
58
+ module = "modules/tools/gh.sh"
59
+ requires = []
60
+ install_requires = ["linuxbrew"]
61
+ uninstall = true
62
+
63
+ [[component]]
64
+ id = "gitee"
65
+ name = "Gitee CLI"
66
+ description = "Official command-line client for Gitee"
67
+ category = "development"
68
+ module = "modules/tools/gitee.sh"
69
+ requires = []
70
+ install_requires = []
71
+ uninstall = true
72
+
53
73
  [[component]]
54
74
  id = "ripgrep"
55
75
  name = "ripgrep"
@@ -100,6 +120,16 @@ requires = []
100
120
  install_requires = ["linuxbrew"]
101
121
  uninstall = true
102
122
 
123
+ [[component]]
124
+ id = "yq"
125
+ name = "yq"
126
+ description = "YAML, JSON, XML, CSV, TOML, and properties processor"
127
+ category = "terminal"
128
+ module = "modules/tools/yq.sh"
129
+ requires = []
130
+ install_requires = ["linuxbrew"]
131
+ uninstall = true
132
+
103
133
  [[component]]
104
134
  id = "atuin"
105
135
  name = "Atuin"
@@ -7,6 +7,7 @@ ohmyzsh/ohmyzsh path:lib
7
7
  # 2. OMZ 插件
8
8
  ohmyzsh/ohmyzsh path:plugins/git
9
9
  ohmyzsh/ohmyzsh path:plugins/extract
10
+ ohmyzsh/ohmyzsh path:plugins/z
10
11
 
11
12
  # 3. Zsh 社区插件
12
13
  zsh-users/zsh-autosuggestions
@@ -9,7 +9,7 @@ export ZSH=/opt/vendor/zsh/ohmyzsh
9
9
  export ZSH_DISABLE_COMPFIX=true
10
10
  export DISABLE_AUTO_UPDATE=true
11
11
  ZSH_THEME=""
12
- plugins=(git extract)
12
+ plugins=(git extract z)
13
13
 
14
14
  source "${ZSH}/oh-my-zsh.sh"
15
15
  [[ -f /opt/vendor/zsh/zsh-autosuggestions/zsh-autosuggestions.zsh ]] && \
@@ -135,6 +135,7 @@ omd_validate_bundle() {
135
135
  for required in \
136
136
  bin/omd \
137
137
  components.toml \
138
+ install/bootstrap.sh \
138
139
  install/update.sh \
139
140
  modules \
140
141
  build \
@@ -307,16 +308,17 @@ omd_persist_source() {
307
308
  printf '%s\n' "${mirror_profile}" | omd_atomic_write "${config_dir}/mirror-profile" || return 1
308
309
  env_file="${config_dir}/env"
309
310
  {
310
- printf '# Generated by oh-my-devpod. Use omd --update --github or --gitee to change this profile.\n'
311
+ printf '# Generated by oh-my-devpod. Use omd --source github or gitee to change this profile.\n'
311
312
  printf 'export OHMYDEVPOD_CONFIG_DIR=%q\n' "${config_dir}"
312
313
  printf 'export OHMYDEVPOD_MIRROR_PROFILE=%q\n' "${mirror_profile}"
313
314
  printf '%s\n' \
314
- 'unset HOMEBREW_BREW_GIT_REMOTE HOMEBREW_BOTTLE_DOMAIN HOMEBREW_API_DOMAIN' \
315
+ 'unset HOMEBREW_BREW_GIT_REMOTE HOMEBREW_CORE_GIT_REMOTE HOMEBREW_BOTTLE_DOMAIN HOMEBREW_API_DOMAIN' \
315
316
  'unset UV_CONFIG_FILE PIP_INDEX_URL' \
316
317
  'unset CONDA_CHANNELS MAMBA_CHANNEL_ALIAS MAMBA_DEFAULT_CHANNELS'
317
318
  if [[ "${mirror_profile}" == "cn" ]]; then
318
319
  printf '%s\n' \
319
320
  'export HOMEBREW_BREW_GIT_REMOTE="https://mirrors.ustc.edu.cn/brew.git"' \
321
+ 'export HOMEBREW_CORE_GIT_REMOTE="https://mirrors.ustc.edu.cn/homebrew-core.git"' \
320
322
  'export HOMEBREW_BOTTLE_DOMAIN="https://mirrors.ustc.edu.cn/homebrew-bottles"' \
321
323
  'export HOMEBREW_API_DOMAIN="https://mirrors.ustc.edu.cn/homebrew-bottles/api"' \
322
324
  'export UV_CONFIG_FILE="${OHMYDEVPOD_CONFIG_DIR}/uv.toml"' \
@@ -329,7 +331,7 @@ omd_persist_source() {
329
331
 
330
332
  if [[ "${mirror_profile}" == "cn" ]]; then
331
333
  cat <<'EOF' | omd_atomic_write "${config_dir}/uv.toml"
332
- # Generated by oh-my-devpod. Use omd --update --github or --gitee to change this profile.
334
+ # Generated by oh-my-devpod. Use omd --source github or gitee to change this profile.
333
335
  [[index]]
334
336
  url = "https://mirrors.tuna.tsinghua.edu.cn/pypi/web/simple"
335
337
  default = true
@@ -394,6 +396,14 @@ omd_source_brew_remote() {
394
396
  esac
395
397
  }
396
398
 
399
+ omd_source_brew_core_remote() {
400
+ case "$1" in
401
+ github) printf '%s\n' "${OHMYDEVPOD_GITHUB_BREW_CORE_REMOTE:-https://github.com/Homebrew/homebrew-core.git}" ;;
402
+ gitee) printf '%s\n' "${OHMYDEVPOD_GITEE_BREW_CORE_REMOTE:-https://mirrors.ustc.edu.cn/homebrew-core.git}" ;;
403
+ *) return 1 ;;
404
+ esac
405
+ }
406
+
397
407
  omd_main() {
398
408
  local os_release target requested_version source bin_dir prefix cache_dir config_dir
399
409
  local archive checksum selected_source installed_version candidate