Skip to content

Commit

Permalink
Merge branch 'v2' into nickersoft/lazy
Browse files Browse the repository at this point in the history
  • Loading branch information
Nickersoft committed Nov 24, 2024
2 parents 5ca49bb + c688d43 commit ad388eb
Show file tree
Hide file tree
Showing 26 changed files with 621 additions and 584 deletions.
8 changes: 5 additions & 3 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
[target.aarch64-unknown-linux-musl]
linker = "aarch64-linux-musl-gcc"
rustflags = ["-C", "target-feature=-crt-static"]
[target.x86_64-pc-windows-msvc]
rustflags = ["-C", "target-feature=+crt-static"]

[target.i686-pc-windows-msvc]
rustflags = ["-C", "target-feature=+crt-static"]
75 changes: 21 additions & 54 deletions .github/workflows/node.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,7 @@ jobs:
build: pnpm --filter "@odict/node" build --target aarch64-unknown-linux-musl -x
- host: windows-latest
target: aarch64-pc-windows-msvc
build: pnpm --filter "@odict/node" build --target aarch64-pc-windows-msvc
- host: ubuntu-latest
target: wasm32-wasip1-threads
build: pnpm --filter "@odict/node" build --target wasm32-wasip1-threads
build: pnpm --filter "@odict/node" build --target aarch64-pc-windows-msvc
name: stable - ${{ matrix.settings.target }} - node@20
runs-on: ${{ matrix.settings.host }}
steps:
Expand Down Expand Up @@ -116,19 +113,11 @@ jobs:
shell: bash
- name: Upload artifact
uses: actions/upload-artifact@v4
if: matrix.settings.target != 'wasm32-wasip1-threads'
with:
name: bindings-${{ matrix.settings.target }}
path: 'bindings/node/*.node'
path: bindings/node/*.node
if-no-files-found: error

- name: Upload artifact
uses: actions/upload-artifact@v4
if: matrix.settings.target == 'wasm32-wasip1-threads'
with:
name: bindings-${{ matrix.settings.target }}
path: '*.wasm'
if-no-files-found: error
build-freebsd:
runs-on: ubuntu-latest
name: Build FreeBSD
Expand Down Expand Up @@ -174,7 +163,7 @@ jobs:
uses: actions/upload-artifact@v4
with:
name: bindings-freebsd
path: bindings/node/${{ env.APP_NAME }}.*.node
path: bindings/node/*.node
if-no-files-found: error
test-macOS-windows-binding:
name: Test bindings on ${{ matrix.settings.target }} - node@${{ matrix.node }}
Expand Down Expand Up @@ -213,7 +202,7 @@ jobs:
uses: actions/download-artifact@v4
with:
name: bindings-${{ matrix.settings.target }}
path: .
path: bindings/node
- name: List packages
run: ls -R .
shell: bash
Expand Down Expand Up @@ -272,7 +261,7 @@ jobs:
uses: actions/download-artifact@v4
with:
name: bindings-${{ matrix.target }}
path: .
path: bindings/node
- name: List packages
run: ls -R .
shell: bash
Expand All @@ -286,43 +275,14 @@ jobs:
with:
image: ${{ steps.docker.outputs.IMAGE }}
options: -v ${{ steps.docker.outputs.PNPM_STORE_PATH }}:${{ steps.docker.outputs.PNPM_STORE_PATH }} -v ${{ github.workspace }}:${{ github.workspace }} -w ${{ github.workspace }} --platform ${{ steps.docker.outputs.PLATFORM }}
run: npm run test
test-wasi:
name: Test WASI target
needs:
- build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: setup pnpm
uses: pnpm/action-setup@v4
- name: Setup node
uses: actions/setup-node@v4
with:
node-version: 20
cache: pnpm
- name: Install dependencies
run: pnpm install
- name: Download artifacts
uses: actions/download-artifact@v4
with:
name: bindings-wasm32-wasip1-threads
path: .
- name: List packages
run: ls -R .
shell: bash
- name: Test bindings
run: pnpm --filter "@odict/node" test
env:
NAPI_RS_FORCE_WASI: 1
run: cd bindings/node && npm run test
publish:
name: Publish
runs-on: ubuntu-latest
needs:
- build-freebsd
- test-macOS-windows-binding
- test-linux-binding
- test-wasi
steps:
- uses: actions/checkout@v4
- name: setup pnpm
Expand All @@ -337,25 +297,32 @@ jobs:
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
path: bindings/node/artifacts
- name: create npm dirs
run: pnpm napi create-npm-dirs
run: pnpm --filter="@odict/node" create-dirs
- name: Move artifacts
run: pnpm artifacts
run: pnpm --filter="@odict/node" artifacts
- name: List packages
run: ls -R ./npm
run: ls -R ./bindings/node/npm
shell: bash
- uses: olegtarasov/[email protected]
id: tagName
with:
tagRegex: "node-(.*)"
- name: Print tag name
run: echo $GIT_TAG_NAME
- name: Publish
shell: bash
run: |
npm config set provenance true
if git log -1 --pretty=%B | grep "^v\?[0-9]\+\.[0-9]\+\.[0-9]\+$";
if [[ $GIT_TAG_NAME =~ "^v?[0-9]+.[0-9]+.[0-9]+$" ]];
then
echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> ~/.npmrc
npm publish --access public
elif git log -1 --pretty=%B | grep "^v\?[0-9]\+\.[0-9]\+\.[0-9]\+";
pnpm --filter="@odict/node" publish --no-git-checks --access public
elif [[ $GIT_TAG_NAME =~ "^v?[0-9]+.[0-9]+.[0-9]+" ]];
then
echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> ~/.npmrc
npm publish --tag next --access public
pnpm --filter="@odict/node" publish --tag next --no-git-checks --access public
else
echo "Not a release, skipping publish"
fi
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
- name: Setup dependencies
run: mise run setup
- name: Run tests
run: mise run test
run: RUST_BACKTRACE=1 mise run test-all --interleave
- uses: actions/upload-artifact@v4
if: ${{ failure() }}
with:
Expand Down
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion bindings/java/lib/src/main/kotlin/org/odict/Dictionary.kt
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ class Dictionary constructor(private val path: String) {

private fun execute(vararg args: String): String? {
return try {
val baseArgs = arrayOf(if (System.getenv("RUNTIME_ENV") == "test") "../../../target/debug/cli" else "odict", "--quiet")
val baseArgs = arrayOf(if (System.getenv("RUNTIME_ENV") == "test") "../../../target/debug/odict" else "odict", "--quiet")
val proc = ProcessBuilder(*(baseArgs + args))
.redirectOutput(ProcessBuilder.Redirect.PIPE)
.start()
Expand Down
5 changes: 3 additions & 2 deletions bindings/node/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ dist
.AppleDouble
.LSOverride

# Icon must end with two
# Icon must end with two
Icon


Expand Down Expand Up @@ -194,4 +194,5 @@ Cargo.lock
!.yarn/sdks
!.yarn/versions

*.node
artifacts
*.node
117 changes: 117 additions & 0 deletions bindings/node/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
/* auto-generated by NAPI-RS */
/* eslint-disable */
export declare class Dictionary {
constructor(
pathOrAlias: string,
options?: DictionaryOptions | undefined | null,
);
static write(
xmlStr: string,
outPath: string,
options?: DictionaryOptions | undefined | null,
): Dictionary;
static compile(
xmlPath: string,
outPath?: string | undefined | null,
options?: DictionaryOptions | undefined | null,
): Dictionary;
get path(): string;
lookup(
query: LookupQuery | string | Array<LookupQuery | string>,
options?: LookupOptions | undefined | null,
): Array<Array<Entry>>;
lexicon(): Array<string>;
split(query: string, options?: SplitOptions | undefined | null): Array<Entry>;
index(options?: IndexOptions | undefined | null): void;
search(
query: string,
options?: SearchOptions | undefined | null,
): Array<Entry>;
}

export declare class MdString {
constructor(value: string);
get value(): string;
parse(strategy: MarkdownStrategy): string;
}
export type MDString = MdString;

export interface Definition {
id?: string;
value: MDString;
examples: Array<Example>;
notes: Array<Note>;
}

export interface DictionaryOptions {
split?: SplitOptions;
index?: IndexOptions;
search?: SearchOptions;
}

export interface Entry {
term: string;
seeAlso?: string;
etymologies: Array<Etymology>;
}

export interface Etymology {
id?: string;
pronunciation?: string;
description?: MDString;
senses: Record<string, Sense>;
}

export interface Example {
value: MDString;
}

export interface Group {
id?: string;
description: MDString;
definitions: Array<Definition>;
}

export interface IndexOptions {
directory?: string;
memory?: number;
overwrite?: boolean;
}

export interface LookupOptions {
split?: number;
follow?: boolean;
}

export interface LookupQuery {
term: string;
fallback: string;
}

export declare const enum MarkdownStrategy {
Disabled = 0,
HTML = 1,
Text = 2,
}

export interface Note {
id?: string;
value: MdString;
examples: Array<Example>;
}

export interface SearchOptions {
directory?: string;
threshold?: number;
autoindex?: boolean;
limit?: number;
}

export interface Sense {
pos: string;
definitions: Array<Definition | Group>;
}

export interface SplitOptions {
threshold?: number;
}
Loading

0 comments on commit ad388eb

Please sign in to comment.