Skip to content

Commit c9d1d92

Browse files
authored
Merge pull request #2 from HerodotusDev/feat/gh-workflow-setup
chore: add prettier and CI checks
2 parents 5d47737 + ebf9fc2 commit c9d1d92

15 files changed

Lines changed: 129 additions & 47 deletions

.github/workflows/ci.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: CI
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches:
7+
- main
8+
9+
jobs:
10+
checks:
11+
name: Test, lint, and format
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- name: Checkout
16+
uses: actions/checkout@v4
17+
18+
- name: Set up Bun
19+
uses: oven-sh/setup-bun@v2
20+
21+
- name: Install dependencies
22+
run: bun install --frozen-lockfile
23+
24+
- name: Run tests
25+
run: bun run test
26+
27+
- name: Run lint
28+
run: bun run lint
29+
30+
- name: Check formatting
31+
run: bun run format:check

.prettierrc.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"printWidth": 120,
3+
"singleQuote": true,
4+
"semi": true,
5+
"trailingComma": "all",
6+
"tabWidth": 2
7+
}

README.md

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -144,11 +144,7 @@ The adapter reads the x402 requirement returned by Atlantic, verifies that `acce
144144
Use a custom adapter when signing should happen through another wallet, custody service, browser wallet, or agent wallet.
145145

146146
```ts
147-
import {
148-
AtlanticClient,
149-
type X402PaymentAdapter,
150-
type X402PaymentPayload,
151-
} from '@herodotus_dev/atlantic-sdk';
147+
import { AtlanticClient, type X402PaymentAdapter, type X402PaymentPayload } from '@herodotus_dev/atlantic-sdk';
152148

153149
const paymentAdapter: X402PaymentAdapter = {
154150
async createPayment({ requirement }): Promise<X402PaymentPayload> {

bun.lock

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/buckets.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
import { AtlanticClient, createBucketAndSubmit } from '../src';
22

3-
const client = new AtlanticClient(
4-
process.env.ATLANTIC_API_KEY ? { apiKey: process.env.ATLANTIC_API_KEY } : {},
5-
);
3+
const client = new AtlanticClient(process.env.ATLANTIC_API_KEY ? { apiKey: process.env.ATLANTIC_API_KEY } : {});
64

75
const result = await createBucketAndSubmit(client, {
86
bucket: {
@@ -20,4 +18,7 @@ const result = await createBucketAndSubmit(client, {
2018
],
2119
});
2220

23-
console.log(result.bucket.atlanticBucket.id, result.submissions.map((submission) => submission.atlanticQueryId));
21+
console.log(
22+
result.bucket.atlanticBucket.id,
23+
result.submissions.map((submission) => submission.atlanticQueryId),
24+
);

examples/submit-and-wait.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
import { AtlanticClient, submitAndWait } from '../src';
22

3-
const client = new AtlanticClient(
4-
process.env.ATLANTIC_API_KEY ? { apiKey: process.env.ATLANTIC_API_KEY } : {},
5-
);
3+
const client = new AtlanticClient(process.env.ATLANTIC_API_KEY ? { apiKey: process.env.ATLANTIC_API_KEY } : {});
64

75
const result = await submitAndWait(
86
client,

examples/submit-query.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
import { AtlanticClient } from '../src';
22

3-
const client = new AtlanticClient(
4-
process.env.ATLANTIC_API_KEY ? { apiKey: process.env.ATLANTIC_API_KEY } : {},
5-
);
3+
const client = new AtlanticClient(process.env.ATLANTIC_API_KEY ? { apiKey: process.env.ATLANTIC_API_KEY } : {});
64

75
const result = await client.submitQuery({
86
declaredJobSize: 'S',

package.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,10 @@
1818
"scripts": {
1919
"build": "tsc",
2020
"test": "bun test",
21+
"lint": "tsc -p tsconfig.check.json",
2122
"typecheck": "tsc -p tsconfig.check.json",
23+
"format": "prettier --write .",
24+
"format:check": "prettier --check .",
2225
"check": "bun test && tsc -p tsconfig.check.json",
2326
"prepublishOnly": "bun run check && bun run build"
2427
},
@@ -45,6 +48,7 @@
4548
},
4649
"devDependencies": {
4750
"@types/bun": "^1.2.14",
51+
"prettier": "^3.8.3",
4852
"typescript": "^5.7.3"
4953
}
5054
}

src/cli/commands.ts

Lines changed: 30 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,26 +14,30 @@ interface CliContext {
1414
}
1515

1616
const commandHandlers: Record<string, CommandHandler> = {
17-
'health': ({ client }) => client.healthCheck(),
17+
health: ({ client }) => client.healthCheck(),
1818
'submit-query': ({ client, flags }) => client.submitQuery(readSubmitInput(flags)),
1919
'submit-and-wait': ({ client, flags }) => submitAndWait(client, readSubmitInput(flags), readWaitOptions(flags)),
2020
'retry-query': ({ client, flags, positionals }) => client.retryQuery(requiredId(flags, positionals, 'query-id')),
21-
'retry-if-retriable': ({ client, flags, positionals }) => retryIfRetriable(client, requiredId(flags, positionals, 'query-id')),
21+
'retry-if-retriable': ({ client, flags, positionals }) =>
22+
retryIfRetriable(client, requiredId(flags, positionals, 'query-id')),
2223
'get-query-details': ({ client, flags, positionals }) => client.getQuery(requiredId(flags, positionals, 'query-id')),
2324
'get-query-by-dedup-id': ({ client, flags, positionals }) =>
2425
client.getQueryByDedupId(requiredId(flags, positionals, 'dedup-id')),
2526
'get-my-queries': ({ client, flags }) => client.listQueries(readPagination(flags)),
2627
'get-query-jobs': ({ client, flags, positionals }) => client.getQueryJobs(requiredId(flags, positionals, 'query-id')),
27-
'get-query-with-jobs': ({ client, flags, positionals }) => getQueryWithJobs(client, requiredId(flags, positionals, 'query-id')),
28+
'get-query-with-jobs': ({ client, flags, positionals }) =>
29+
getQueryWithJobs(client, requiredId(flags, positionals, 'query-id')),
2830
'get-query-stats': ({ client }) => client.getQueryStats(),
2931
'list-buckets': ({ client, flags }) => client.listBuckets(readPagination(flags)),
3032
'create-bucket': ({ client, flags }) =>
31-
client.createBucket(compact({
32-
aggregatorVersion: requiredString(flags, 'aggregator-version'),
33-
externalId: optionalString(flags, 'external-id') ?? null,
34-
nodeWidth: optionalNumber(flags, 'node-width') ?? null,
35-
mockProof: optionalBoolean(flags, 'mock-proof') ?? null,
36-
})),
33+
client.createBucket(
34+
compact({
35+
aggregatorVersion: requiredString(flags, 'aggregator-version'),
36+
externalId: optionalString(flags, 'external-id') ?? null,
37+
nodeWidth: optionalNumber(flags, 'node-width') ?? null,
38+
mockProof: optionalBoolean(flags, 'mock-proof') ?? null,
39+
}),
40+
),
3741
'get-bucket': ({ client, flags, positionals }) => client.getBucket(requiredId(flags, positionals, 'bucket-id')),
3842
'close-bucket': ({ client, flags, positionals }) => client.closeBucket(requiredId(flags, positionals, 'bucket-id')),
3943
'submit-to-bucket': ({ client, flags }) =>
@@ -44,7 +48,9 @@ const commandHandlers: Record<string, CommandHandler> = {
4448
}),
4549
'create-bucket-and-submit': ({ client, flags }) =>
4650
createBucketAndSubmit(client, {
47-
bucket: { aggregatorVersion: requiredString(flags, 'aggregator-version') },
51+
bucket: {
52+
aggregatorVersion: requiredString(flags, 'aggregator-version'),
53+
},
4854
queries: [readSubmitInput(flags)],
4955
}),
5056
};
@@ -58,7 +64,11 @@ export async function runCli(argv: string[]): Promise<number> {
5864

5965
const handler = commandHandlers[command];
6066
if (!handler) {
61-
printJson({ ok: false, error: { message: `Unknown command: ${command}` }, commands: Object.keys(commandHandlers).sort() });
67+
printJson({
68+
ok: false,
69+
error: { message: `Unknown command: ${command}` },
70+
commands: Object.keys(commandHandlers).sort(),
71+
});
6272
return 1;
6373
}
6474

@@ -76,7 +86,10 @@ export async function runCli(argv: string[]): Promise<number> {
7686
}
7787
}
7888

79-
export function parseArgs(argv: string[]): { flags: Record<string, string | boolean>; positionals: string[] } {
89+
export function parseArgs(argv: string[]): {
90+
flags: Record<string, string | boolean>;
91+
positionals: string[];
92+
} {
8093
const flags: Record<string, string | boolean> = {};
8194
const positionals: string[] = [];
8295

@@ -138,7 +151,11 @@ function readPagination(flags: Record<string, string | boolean | undefined>) {
138151
return pagination;
139152
}
140153

141-
function requiredId(flags: Record<string, string | boolean | undefined>, positionals: string[], flagName: string): string {
154+
function requiredId(
155+
flags: Record<string, string | boolean | undefined>,
156+
positionals: string[],
157+
flagName: string,
158+
): string {
142159
return optionalString(flags, flagName) ?? positionals[0] ?? fail(`Missing required ${flagName}`);
143160
}
144161

src/client/multipart.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,5 @@ async function toMultipartValue(value: AtlanticFileValue | AtlanticFileReference
4747
}
4848

4949
function isFileReference(value: unknown): value is AtlanticFileReference {
50-
return (
51-
!!value &&
52-
typeof value === 'object' &&
53-
'bucketKey' in value &&
54-
'metadataType' in value
55-
);
50+
return !!value && typeof value === 'object' && 'bucketKey' in value && 'metadataType' in value;
5651
}

0 commit comments

Comments
 (0)