Skip to content

Commit d1a749c

Browse files
authored
Merge pull request #1 from Alhwyn/cli-1
Fix TypeScript errors
2 parents 8f182e7 + cb138e0 commit d1a749c

16 files changed

Lines changed: 447 additions & 54 deletions

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,4 @@ report.[0-9]_.[0-9]_.[0-9]_.[0-9]_.json
3434
.DS_Store
3535
cafe_cursor.csv
3636
credits.csv
37-
convex/_generated
37+
# convex/_generated is now committed with stubs for CI

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
╚═════╝╚═╝ ╚═╝╚═╝ ╚══════╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═╝╚══════╝ ╚═════╝ ╚═╝ ╚═╝
88
```
99

10-
# Cafe Cursor CLI
10+
# Cafe Cursor CLI [![CI](https://github.com/Alhwyn/cafe-cursor-cli/actions/workflows/ci.yml/badge.svg)](https://github.com/Alhwyn/cafe-cursor-cli/actions/workflows/ci.yml)
1111

1212
A CLI tool for managing and sending Cursor credits to event attendees via email.
1313

build.ts

Lines changed: 19 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,28 @@
11
#!/usr/bin/env bun
2-
import plugin from "bun-plugin-tailwind";
32
import { existsSync } from "fs";
43
import { rm } from "fs/promises";
54
import path from "path";
65

76
if (process.argv.includes("--help") || process.argv.includes("-h")) {
87
console.log(`
9-
🏗️ Bun Build Script
8+
🏗️ Cafe CLI Build Script
109
1110
Usage: bun run build.ts [options]
1211
1312
Common Options:
1413
--outdir <path> Output directory (default: "dist")
15-
--minify Enable minification (or --minify.grayspace, --minify.syntax, etc)
16-
--sourcemap <type> Sourcemap type: none|linked|inline|external
17-
--target <target> Build target: browser|bun|node
18-
--format <format> Output format: esm|cjs|iife
19-
--splitting Enable code splitting
20-
--packages <type> Package handling: bundle|external
21-
--public-path <path> Public path for assets
22-
--env <mode> Environment handling: inline|disable|prefix*
23-
--conditions <list> Package.json export conditions (comma separated)
24-
--external <list> External packages (comma separated)
25-
--banner <text> Add banner text to output
26-
--footer <text> Add footer text to output
27-
--define <obj> Define global constants (e.g. --define.VERSION=1.0.0)
14+
--minify Enable minification
15+
--sourcemap <type> Sourcemap type: none|linked|inline|external
16+
--target <target> Build target: bun|node
2817
--help, -h Show this help message
2918
3019
Example:
31-
bun run build.ts --outdir=dist --minify --sourcemap=linked --external=react,react-dom
20+
bun run build.ts --outdir=dist --minify --sourcemap=linked
3221
`);
3322
process.exit(0);
3423
}
3524

36-
const toCamelCase = (str: string): string => str.replace(/-([a-z])/g, g => g[1].toUpperCase());
25+
const toCamelCase = (str: string): string => str.replace(/-([a-z])/g, (_, c: string) => c.toUpperCase());
3726

3827
const parseValue = (value: string): any => {
3928
if (value === "true") return true;
@@ -47,8 +36,8 @@ const parseValue = (value: string): any => {
4736
return value;
4837
};
4938

50-
function parseArgs(): Partial<Bun.BuildConfig> {
51-
const config: Partial<Bun.BuildConfig> = {};
39+
function parseArgs(): Record<string, unknown> {
40+
const config: Record<string, unknown> = {};
5241
const args = process.argv.slice(2);
5342

5443
for (let i = 0; i < args.length; i++) {
@@ -81,9 +70,9 @@ function parseArgs(): Partial<Bun.BuildConfig> {
8170
key = toCamelCase(key);
8271

8372
if (key.includes(".")) {
84-
const [parentKey, childKey] = key.split(".");
73+
const [parentKey, childKey] = key.split(".", 2) as [string, string];
8574
config[parentKey] = config[parentKey] || {};
86-
config[parentKey][childKey] = parseValue(value);
75+
(config[parentKey] as Record<string, unknown>)[childKey] = parseValue(value);
8776
} else {
8877
config[key] = parseValue(value);
8978
}
@@ -108,7 +97,7 @@ const formatFileSize = (bytes: number): string => {
10897
console.log("\n🚀 Starting build process...\n");
10998

11099
const cliConfig = parseArgs();
111-
const outdir = cliConfig.outdir || path.join(process.cwd(), "dist");
100+
const outdir = (typeof cliConfig.outdir === "string" ? cliConfig.outdir : null) || path.join(process.cwd(), "dist");
112101

113102
if (existsSync(outdir)) {
114103
console.log(`🗑️ Cleaning previous build at ${outdir}`);
@@ -117,18 +106,20 @@ if (existsSync(outdir)) {
117106

118107
const start = performance.now();
119108

120-
const entrypoints = [...new Bun.Glob("**.html").scanSync("src")]
121-
.map(a => path.resolve("src", a))
122-
.filter(dir => !dir.includes("node_modules"));
123-
console.log(`📄 Found ${entrypoints.length} HTML ${entrypoints.length === 1 ? "file" : "files"} to process\n`);
109+
const entrypoints = [path.resolve("src", "cli.tsx")];
110+
console.log(`📄 Building CLI from ${entrypoints[0]}\n`);
124111

125112
const result = await Bun.build({
126113
entrypoints,
127114
outdir,
128-
plugins: [plugin],
129115
minify: true,
130-
target: "browser",
116+
target: "bun",
131117
sourcemap: "linked",
118+
external: [
119+
"react-devtools-core",
120+
"electron",
121+
"chromium-bidi",
122+
],
132123
define: {
133124
"process.env.NODE_ENV": JSON.stringify("production"),
134125
},

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.

convex/_generated/api.d.ts

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
/* eslint-disable */
2+
/**
3+
* Generated `api` utility.
4+
*
5+
* THIS CODE IS AUTOMATICALLY GENERATED.
6+
*
7+
* To regenerate, run `npx convex dev`.
8+
* @module
9+
*/
10+
11+
import type * as credits from "../credits.js";
12+
import type * as email from "../email.js";
13+
import type * as emailHelpers from "../emailHelpers.js";
14+
import type * as people from "../people.js";
15+
16+
import type {
17+
ApiFromModules,
18+
FilterApi,
19+
FunctionReference,
20+
} from "convex/server";
21+
22+
declare const fullApi: ApiFromModules<{
23+
credits: typeof credits;
24+
email: typeof email;
25+
emailHelpers: typeof emailHelpers;
26+
people: typeof people;
27+
}>;
28+
29+
/**
30+
* A utility for referencing Convex functions in your app's public API.
31+
*
32+
* Usage:
33+
* ```js
34+
* const myFunctionReference = api.myModule.myFunction;
35+
* ```
36+
*/
37+
export declare const api: FilterApi<
38+
typeof fullApi,
39+
FunctionReference<any, "public">
40+
>;
41+
42+
/**
43+
* A utility for referencing Convex functions in your app's internal API.
44+
*
45+
* Usage:
46+
* ```js
47+
* const myFunctionReference = internal.myModule.myFunction;
48+
* ```
49+
*/
50+
export declare const internal: FilterApi<
51+
typeof fullApi,
52+
FunctionReference<any, "internal">
53+
>;
54+
55+
export declare const components: {};

convex/_generated/api.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/* eslint-disable */
2+
/**
3+
* Generated `api` utility.
4+
*
5+
* THIS CODE IS AUTOMATICALLY GENERATED.
6+
*
7+
* To regenerate, run `npx convex dev`.
8+
* @module
9+
*/
10+
11+
import { anyApi, componentsGeneric } from "convex/server";
12+
13+
/**
14+
* A utility for referencing Convex functions in your app's API.
15+
*
16+
* Usage:
17+
* ```js
18+
* const myFunctionReference = api.myModule.myFunction;
19+
* ```
20+
*/
21+
export const api = anyApi;
22+
export const internal = anyApi;
23+
export const components = componentsGeneric();

convex/_generated/dataModel.d.ts

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
/* eslint-disable */
2+
/**
3+
* Generated data model types.
4+
*
5+
* THIS CODE IS AUTOMATICALLY GENERATED.
6+
*
7+
* To regenerate, run `npx convex dev`.
8+
* @module
9+
*/
10+
11+
import type {
12+
DataModelFromSchemaDefinition,
13+
DocumentByName,
14+
TableNamesInDataModel,
15+
SystemTableNames,
16+
} from "convex/server";
17+
import type { GenericId } from "convex/values";
18+
import schema from "../schema.js";
19+
20+
/**
21+
* The names of all of your Convex tables.
22+
*/
23+
export type TableNames = TableNamesInDataModel<DataModel>;
24+
25+
/**
26+
* The type of a document stored in Convex.
27+
*
28+
* @typeParam TableName - A string literal type of the table name (like "users").
29+
*/
30+
export type Doc<TableName extends TableNames> = DocumentByName<
31+
DataModel,
32+
TableName
33+
>;
34+
35+
/**
36+
* An identifier for a document in Convex.
37+
*
38+
* Convex documents are uniquely identified by their `Id`, which is accessible
39+
* on the `_id` field. To learn more, see [Document IDs](https://docs.convex.dev/using/document-ids).
40+
*
41+
* Documents can be loaded using `db.get(tableName, id)` in query and mutation functions.
42+
*
43+
* IDs are just strings at runtime, but this type can be used to distinguish them from other
44+
* strings when type checking.
45+
*
46+
* @typeParam TableName - A string literal type of the table name (like "users").
47+
*/
48+
export type Id<TableName extends TableNames | SystemTableNames> =
49+
GenericId<TableName>;
50+
51+
/**
52+
* A type describing your Convex data model.
53+
*
54+
* This type includes information about what tables you have, the type of
55+
* documents stored in those tables, and the indexes defined on them.
56+
*
57+
* This type is used to parameterize methods like `queryGeneric` and
58+
* `mutationGeneric` to make them type-safe.
59+
*/
60+
export type DataModel = DataModelFromSchemaDefinition<typeof schema>;

0 commit comments

Comments
 (0)