Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,4 @@ report.[0-9]_.[0-9]_.[0-9]_.[0-9]_.json
.DS_Store
cafe_cursor.csv
credits.csv
convex/_generated
# convex/_generated is now committed with stubs for CI
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
╚═════╝╚═╝ ╚═╝╚═╝ ╚══════╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═╝╚══════╝ ╚═════╝ ╚═╝ ╚═╝
```

# Cafe Cursor CLI
# 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)

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

Expand Down
47 changes: 19 additions & 28 deletions build.ts
Original file line number Diff line number Diff line change
@@ -1,39 +1,28 @@
#!/usr/bin/env bun
import plugin from "bun-plugin-tailwind";
import { existsSync } from "fs";
import { rm } from "fs/promises";
import path from "path";

if (process.argv.includes("--help") || process.argv.includes("-h")) {
console.log(`
🏗️ Bun Build Script
🏗️ Cafe CLI Build Script

Usage: bun run build.ts [options]

Common Options:
--outdir <path> Output directory (default: "dist")
--minify Enable minification (or --minify.grayspace, --minify.syntax, etc)
--sourcemap <type> Sourcemap type: none|linked|inline|external
--target <target> Build target: browser|bun|node
--format <format> Output format: esm|cjs|iife
--splitting Enable code splitting
--packages <type> Package handling: bundle|external
--public-path <path> Public path for assets
--env <mode> Environment handling: inline|disable|prefix*
--conditions <list> Package.json export conditions (comma separated)
--external <list> External packages (comma separated)
--banner <text> Add banner text to output
--footer <text> Add footer text to output
--define <obj> Define global constants (e.g. --define.VERSION=1.0.0)
--minify Enable minification
--sourcemap <type> Sourcemap type: none|linked|inline|external
--target <target> Build target: bun|node
--help, -h Show this help message

Example:
bun run build.ts --outdir=dist --minify --sourcemap=linked --external=react,react-dom
bun run build.ts --outdir=dist --minify --sourcemap=linked
`);
process.exit(0);
}

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

const parseValue = (value: string): any => {
if (value === "true") return true;
Expand All @@ -47,8 +36,8 @@ const parseValue = (value: string): any => {
return value;
};

function parseArgs(): Partial<Bun.BuildConfig> {
const config: Partial<Bun.BuildConfig> = {};
function parseArgs(): Record<string, unknown> {
const config: Record<string, unknown> = {};
const args = process.argv.slice(2);

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

if (key.includes(".")) {
const [parentKey, childKey] = key.split(".");
const [parentKey, childKey] = key.split(".", 2) as [string, string];
config[parentKey] = config[parentKey] || {};
config[parentKey][childKey] = parseValue(value);
(config[parentKey] as Record<string, unknown>)[childKey] = parseValue(value);
} else {
config[key] = parseValue(value);
}
Expand All @@ -108,7 +97,7 @@ const formatFileSize = (bytes: number): string => {
console.log("\n🚀 Starting build process...\n");

const cliConfig = parseArgs();
const outdir = cliConfig.outdir || path.join(process.cwd(), "dist");
const outdir = (typeof cliConfig.outdir === "string" ? cliConfig.outdir : null) || path.join(process.cwd(), "dist");

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

const start = performance.now();

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

const result = await Bun.build({
entrypoints,
outdir,
plugins: [plugin],
minify: true,
target: "browser",
target: "bun",
sourcemap: "linked",
external: [
"react-devtools-core",
"electron",
"chromium-bidi",
],
define: {
"process.env.NODE_ENV": JSON.stringify("production"),
},
Expand Down
3 changes: 3 additions & 0 deletions bun.lock

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

55 changes: 55 additions & 0 deletions convex/_generated/api.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/* eslint-disable */
/**
* Generated `api` utility.
*
* THIS CODE IS AUTOMATICALLY GENERATED.
*
* To regenerate, run `npx convex dev`.
* @module
*/

import type * as credits from "../credits.js";
import type * as email from "../email.js";
import type * as emailHelpers from "../emailHelpers.js";
import type * as people from "../people.js";

import type {
ApiFromModules,
FilterApi,
FunctionReference,
} from "convex/server";

declare const fullApi: ApiFromModules<{
credits: typeof credits;
email: typeof email;
emailHelpers: typeof emailHelpers;
people: typeof people;
}>;

/**
* A utility for referencing Convex functions in your app's public API.
*
* Usage:
* ```js
* const myFunctionReference = api.myModule.myFunction;
* ```
*/
export declare const api: FilterApi<
typeof fullApi,
FunctionReference<any, "public">
>;

/**
* A utility for referencing Convex functions in your app's internal API.
*
* Usage:
* ```js
* const myFunctionReference = internal.myModule.myFunction;
* ```
*/
export declare const internal: FilterApi<
typeof fullApi,
FunctionReference<any, "internal">
>;

export declare const components: {};
23 changes: 23 additions & 0 deletions convex/_generated/api.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/* eslint-disable */
/**
* Generated `api` utility.
*
* THIS CODE IS AUTOMATICALLY GENERATED.
*
* To regenerate, run `npx convex dev`.
* @module
*/

import { anyApi, componentsGeneric } from "convex/server";

/**
* A utility for referencing Convex functions in your app's API.
*
* Usage:
* ```js
* const myFunctionReference = api.myModule.myFunction;
* ```
*/
export const api = anyApi;
export const internal = anyApi;
export const components = componentsGeneric();
60 changes: 60 additions & 0 deletions convex/_generated/dataModel.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/* eslint-disable */
/**
* Generated data model types.
*
* THIS CODE IS AUTOMATICALLY GENERATED.
*
* To regenerate, run `npx convex dev`.
* @module
*/

import type {
DataModelFromSchemaDefinition,
DocumentByName,
TableNamesInDataModel,
SystemTableNames,
} from "convex/server";
import type { GenericId } from "convex/values";
import schema from "../schema.js";

/**
* The names of all of your Convex tables.
*/
export type TableNames = TableNamesInDataModel<DataModel>;

/**
* The type of a document stored in Convex.
*
* @typeParam TableName - A string literal type of the table name (like "users").
*/
export type Doc<TableName extends TableNames> = DocumentByName<
DataModel,
TableName
>;

/**
* An identifier for a document in Convex.
*
* Convex documents are uniquely identified by their `Id`, which is accessible
* on the `_id` field. To learn more, see [Document IDs](https://docs.convex.dev/using/document-ids).
*
* Documents can be loaded using `db.get(tableName, id)` in query and mutation functions.
*
* IDs are just strings at runtime, but this type can be used to distinguish them from other
* strings when type checking.
*
* @typeParam TableName - A string literal type of the table name (like "users").
*/
export type Id<TableName extends TableNames | SystemTableNames> =
GenericId<TableName>;

/**
* A type describing your Convex data model.
*
* This type includes information about what tables you have, the type of
* documents stored in those tables, and the indexes defined on them.
*
* This type is used to parameterize methods like `queryGeneric` and
* `mutationGeneric` to make them type-safe.
*/
export type DataModel = DataModelFromSchemaDefinition<typeof schema>;
Loading