Skip to content

Commit

Permalink
ci: setup ci
Browse files Browse the repository at this point in the history
  • Loading branch information
ssssota committed Dec 5, 2024
1 parent be0091d commit 489f05c
Show file tree
Hide file tree
Showing 8 changed files with 79 additions and 38 deletions.
14 changes: 14 additions & 0 deletions .github/actions/setup/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: Setup Node.js and Install deps
description: Setup Node.js/pnpm. Install dependencies.
runs:
using: 'composite'
steps:
- run: corepack enable
shell: bash
- uses: actions/setup-node@v4
with:
node-version: 22
cache: pnpm
- name: Install deps
run: pnpm install
shell: bash
15 changes: 15 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: CI
on:
push:
branches:
- main
pull_request:
jobs:
check:
runs-on: macos-latest
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/setup
- run: pnpm check
- run: sudo pnpm test
working-directory: tests
31 changes: 14 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,33 +1,30 @@
# apple-app-site-association

Check apple-app-site-association file.
It works with `swcutil` command that is preinstalled in macOS.

## Usage

Reference types:
Test universal links:

```typescript
import type { AppleAppSiteAssociation } from 'apple-app-site-association';
const aasa = {
applinks: {
// ...
}
} as const satisfies AppleAppSiteAssociation;
```sh
# swcutil command requires root permission
sudo node --test --experimental-strip-types # `--experimental-strip-types` is required node@22
```

Test universal links:

```typescript
import { test } from 'node:test';
import { createAssert } from 'apple-app-site-association';
const assert = createAssert(YOUR_DOMAIN, AASA_JSON);
test("universal link works", async () => {
await assert.universalLink("/path/to/your/app", "match");
await assert.universalLink("/#donot_deeplinking", "block");
// test-universallinks.test.ts
import * as assert from "node:assert";
import { test } from "node:test";
import { verify, type AppleAppSiteAssociation } from "apple-app-site-association";
const json = { applinks: { /* ... */ } } satisfies AppleAppSiteAssociation;
test("/search/ should match", async () => {
const actual: 'match' | 'block' | 'unset' = await verify("example.com", "/search/", json);
assert.strictEqual(actual, "match");
});
```

Use `swcutil` command directly:
Use `swcutil` command programmatically:

```typescript
import { swcutil } from 'apple-app-site-association/swcutil';
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@
"build": "tsc",
"clean": "node -e \"fs.rmSync('dist',{recursive:true,force:true})\"",
"prepare": "npm run clean && npm run build",
"fmt": "biome check --write ."
"fmt": "biome check --write .",
"check": "biome check ."
},
"keywords": [
"aasa",
Expand Down
18 changes: 0 additions & 18 deletions tests/node.test.mjs

This file was deleted.

30 changes: 30 additions & 0 deletions tests/node.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import * as assert from "node:assert";
import { test } from "node:test";
import {
verify,
type AppleAppSiteAssociation,
} from "apple-app-site-association";

const json = {
applinks: {
details: [
{
appIDs: ["HOGE.com.example.app"],
components: [
{ "#": "nondeeplinking", exclude: true },
{ "/": "/search/" },
],
},
],
},
} as const satisfies AppleAppSiteAssociation;

test("/search/ should match", async () => {
const actual = await verify("example.com", "/search/", json);
assert.strictEqual(actual, "match");
});

test("#nondeeplinking should block", async () => {
const actual = await verify("example.com", "/search/#nondeeplinking", json);
assert.strictEqual(actual, "block");
});
3 changes: 2 additions & 1 deletion tests/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
"type": "module",
"scripts": {
"test": "npm run test:node",
"test:node": "node --test node.test.mjs"
"test:node": "node --test --experimental-strip-types node.test.ts"
},
"devDependencies": {
"apple-app-site-association": "workspace:*"
Expand Down
3 changes: 2 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@
"declaration": true,
"verbatimModuleSyntax": true,
"isolatedDeclarations": true
}
},
"exclude": ["dist"]
}

0 comments on commit 489f05c

Please sign in to comment.