Add an Install > China Apps menu shown only in China
This commit is contained in:
1 parent
151a530d15
commit
465d4da567
4 files changed
+64
-2
No files matched your search
Executable
+51
@@ -0,0 +1,51 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
source "$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)/base-test.sh"
|
||||
|
||||
require_command node
|
||||
|
||||
node - "$ROOT" <<'JS'
|
||||
const fs = require('fs')
|
||||
const root = process.argv[2]
|
||||
const model = require(`${root}/shell/plugins/menu/MenuModel.js`)
|
||||
const items = model.parseMenuJsonc(fs.readFileSync(`${root}/default/omarchy/omarchy-menu.jsonc`, 'utf8'))
|
||||
const china = items.filter(item => item.id === 'install.china' || item.id.startsWith('install.china.'))
|
||||
const guard = '[[ "$(omarchy-region)" == "China" ]]'
|
||||
const fail = message => { console.error(`not ok - ${message}`); process.exit(1) }
|
||||
|
||||
const aur = {
|
||||
wechat: 'wechat-universal-bwrap', qq: 'linuxqq', feishu: 'feishu-bin',
|
||||
dingtalk: 'dingtalk-bin', wemeet: 'wemeet-bin', wps: 'wps-office-cn',
|
||||
}
|
||||
const web = {
|
||||
'tencent-docs': ['腾讯文档', 'https://docs.qq.com'],
|
||||
yuque: ['语雀', 'https://www.yuque.com/dashboard'],
|
||||
shimo: ['石墨文档', 'https://shimo.im/desktop'],
|
||||
}
|
||||
|
||||
if (china.length !== 1 + Object.keys(aur).length + Object.keys(web).length) fail(`China Apps has exactly the expected entries: ${china.map(i => i.id)}`)
|
||||
if (!china.every(item => item.when === guard)) fail('every China Apps entry, including search hits, shows only in China')
|
||||
for (const [id, pkg] of Object.entries(aur)) {
|
||||
const item = china.find(i => i.id === `install.china.${id}`)
|
||||
if (!item || item.action !== `omarchy-launch-floating-terminal-with-presentation 'omarchy-pkg-aur-add ${pkg}'` || item.disabled !== `omarchy-pkg-present ${pkg}`)
|
||||
fail(`${id} installs and checks the AUR package ${pkg}`)
|
||||
}
|
||||
for (const [id, [name, url]] of Object.entries(web)) {
|
||||
const item = china.find(i => i.id === `install.china.${id}`)
|
||||
if (!item || item.action !== `omarchy-launch-floating-terminal-with-presentation 'omarchy-webapp-install ${name} ${url}'` || item.disabled !== `[[ -f "$HOME/.local/share/applications/${name}.desktop" ]]`)
|
||||
fail(`${id} installs and checks the ${name} web app`)
|
||||
}
|
||||
console.log('ok - China Apps lists the AUR packages and web apps, shown only in China')
|
||||
JS
|
||||
|
||||
aur_names="wechat-universal-bwrap linuxqq feishu-bin dingtalk-bin wemeet-bin wps-office-cn"
|
||||
if [[ ${OMARCHY_TEST_NETWORK:-} == "1" ]]; then
|
||||
query=$(printf '&arg[]=%s' $aur_names)
|
||||
found=$(curl -fsSL "https://aur.archlinux.org/rpc/v5/info?${query#&}" | jq -r '.results[].Name' | sort | tr '\n' ' ')
|
||||
[[ $found == "$(printf '%s\n' $aur_names | sort | tr '\n' ' ')" ]] || fail "every China Apps package exists in the AUR" "$found"
|
||||
pass "every China Apps package exists in the AUR"
|
||||
else
|
||||
skip "AUR existence check needs OMARCHY_TEST_NETWORK=1"
|
||||
fi
|
||||
@@ -292,7 +292,8 @@ assert(!defaultById['install.ai.crush'], 'menu removes Crush from Install > AI')
|
||||
// any other `when:` here is a row that went back to vanishing once installed.
|
||||
assertDeepEqual(
|
||||
defaultItems
|
||||
.filter(item => item.id.startsWith('install.') && item.action && item.when)
|
||||
// China Apps rows hide by region, not because the software is there.
|
||||
.filter(item => item.id.startsWith('install.') && item.action && item.when && item.when !== '[[ "$(omarchy-region)" == "China" ]]')
|
||||
.map(item => item.id),
|
||||
['install.service.chromium-account'],
|
||||
'menu never hides an Install row because the software is already there'
|
||||
|
||||
Reference in new issue
Block a user