Skip to content

Commit

Permalink
purge keeps binary
Browse files Browse the repository at this point in the history
  • Loading branch information
eagleoflqj committed Aug 28, 2023
1 parent 5b81f8b commit 5e40d91
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 16 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ jobs:
pip install ninja
echo "$env:ProgramFiles\LLVM\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
- name: Use Node.js latest
uses: actions/setup-node@v2
uses: actions/setup-node@v3
with:
node-version: 20.x
- name: Install node dependencies
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:
steps:
- uses: actions/checkout@v3
- name: Use Node.js latest
uses: actions/setup-node@v2
uses: actions/setup-node@v3
with:
node-version: 20.x
- name: Install node dependencies
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
"devDependencies": {
"@codemirror/legacy-modes": "^6.3.3",
"@libreservice/lazy-cache": "^0.1.1",
"@libreservice/micro-plum": "^0.2.0",
"@libreservice/micro-plum": "^0.2.1",
"@libreservice/my-widget": "^0.1.4",
"@libreservice/my-worker": "^0.4.2",
"@libreservice/wasm-code": "^0.1.3",
Expand Down
21 changes: 9 additions & 12 deletions scripts/install_schemas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { cwd, chdir, exit } from 'process'
import yaml from 'js-yaml'
import {
Recipe,
getBinaryNames,
GitHubDownloader
} from '@libreservice/micro-plum'
import { rf, utf8, ensure, md5sum } from './util.js'
Expand Down Expand Up @@ -47,18 +48,14 @@ async function install (recipe: Recipe, target?: string) {

function parseYaml (schemaId: string) {
const content = yaml.load(readFileSync(`${RIME_DIR}/build/${schemaId}.schema.yaml`, utf8)) as { [key: string]: any }
for (const [key, value] of Object.entries(content)) {
if (key === 'translator') {
const { dictionary, prism } = value as { dictionary: string, prism?: string }
schemaFiles[schemaId] = {}
// By default, dictionary equals to schemaId, and prism equals to dictionary (not schemaId, see luna_pinyin_fluency)
if (dictionary !== schemaId) {
schemaFiles[schemaId].dict = dictionary
}
if (prism && prism !== dictionary) {
schemaFiles[schemaId].prism = prism
}
}
schemaFiles[schemaId] = {}
const { dict, prism } = getBinaryNames(content)
// By default, dictionary equals to schemaId, and prism equals to dictionary (not schemaId, see luna_pinyin_fluency)
if (dict !== schemaId) {
schemaFiles[schemaId].dict = dict
}
if (prism !== dict) {
schemaFiles[schemaId].prism = prism
}
}

Expand Down
19 changes: 18 additions & 1 deletion src/components/micro-plum/DeployPane.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
import yaml from 'js-yaml'
import {
u2s,
getBinaryNames,
Recipe,
FileLoader
} from '@libreservice/micro-plum'
Expand Down Expand Up @@ -98,12 +99,28 @@ async function onTrash () {
if (content && !keptFiles.includes(file)) {
keptFiles.push(file)
}
if (file.endsWith('.schema.yaml')) {
const schemaYaml = `build/${file}`
try {
const obj = yaml.load(u2s(await FS.readFile(`${RIME_PATH}/${schemaYaml}`))) as object
const { dict, prism } = getBinaryNames(obj)
if (dict) {
const defaultYaml = 'build/default.yaml'
const tableBin = `build/${dict}.table.bin`
const reverseBin = `build/${dict}.reverse.bin`
const prismBin = `build/${prism}.prism.bin`
for (const bin of [defaultYaml, schemaYaml, tableBin, reverseBin, prismBin]) {
keptFiles.includes(bin) || keptFiles.push(bin)
}
}
} catch {}
}
}
}
await Promise.all(prerequisites.map(prerequisite => add(new LocalLoader(prerequisite, []))))
await add(new LocalLoader('', selected.value))
await traverseFS(FS, undefined, async (path: string) => {
const file = path.slice(6)
const file = path.slice(6) // Trim /rime/ prefix
const match = file.match(/^(\S+)\.userdb\/\S+$/)
if (!keptFiles.includes(file) && (!match || !keptFiles.includes(`${match[1]}.dict.yaml`))) {
await FS.unlink(path)
Expand Down

0 comments on commit 5e40d91

Please sign in to comment.