@ncukondo/gcal-cli 0.1.3 → 0.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.js +102 -7
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -587715,6 +587715,60 @@ var ERROR_CODE_EXIT_MAP = {
587715
587715
  function errorCodeToExitCode(code) {
587716
587716
  return ERROR_CODE_EXIT_MAP[code];
587717
587717
  }
587718
+ // package.json
587719
+ var package_default = {
587720
+ name: "@ncukondo/gcal-cli",
587721
+ version: "0.1.5",
587722
+ type: "module",
587723
+ exports: {
587724
+ ".": "./dist/index.js"
587725
+ },
587726
+ bin: {
587727
+ gcal: "./dist/index.js"
587728
+ },
587729
+ files: [
587730
+ "dist"
587731
+ ],
587732
+ repository: {
587733
+ type: "git",
587734
+ url: "https://github.com/ncukondo/gcal-cli"
587735
+ },
587736
+ publishConfig: {
587737
+ access: "public"
587738
+ },
587739
+ scripts: {
587740
+ dev: "bun run src/index.ts",
587741
+ build: "bun build src/index.ts --outdir dist --target node",
587742
+ "build:bin": "bun build src/index.ts --compile --outfile gcal",
587743
+ test: "vitest",
587744
+ "test:unit": "vitest run src",
587745
+ "test:integration": "vitest run tests/integration",
587746
+ "test:e2e": "vitest run tests/e2e",
587747
+ "test:all": "vitest run",
587748
+ lint: "oxlint src tests",
587749
+ format: "oxfmt src tests",
587750
+ "format:check": "oxfmt --check src tests",
587751
+ typecheck: "tsc --noEmit",
587752
+ prepare: "husky || true",
587753
+ prepublishOnly: "bun run build"
587754
+ },
587755
+ dependencies: {
587756
+ commander: "^12.0.0",
587757
+ "date-fns": "^3.0.0",
587758
+ "date-fns-tz": "^3.0.0",
587759
+ googleapis: "^130.0.0",
587760
+ "smol-toml": "^1.0.0",
587761
+ zod: "^4.0.0-beta"
587762
+ },
587763
+ devDependencies: {
587764
+ "@types/bun": "latest",
587765
+ typescript: "^5.0.0",
587766
+ vitest: "^2.0.0",
587767
+ oxlint: "latest",
587768
+ oxfmt: "latest",
587769
+ husky: "^9.1.7"
587770
+ }
587771
+ };
587718
587772
 
587719
587773
  // src/cli.ts
587720
587774
  var FormatSchema = _enum(["text", "json"]);
@@ -587723,7 +587777,7 @@ function collect(value, previous) {
587723
587777
  }
587724
587778
  function createProgram() {
587725
587779
  const program2 = new Command;
587726
- program2.name("gcal").description("CLI tool for managing Google Calendar events").version("0.1.0").option("-f, --format <format>", "Output format: text | json", "text").option("-c, --calendar <id>", "Target calendar ID (repeatable)", collect, []).option("-q, --quiet", "Minimal output", false).option("--tz, --timezone <zone>", "Timezone (e.g., Asia/Tokyo)");
587780
+ program2.name("gcal").description("CLI tool for managing Google Calendar events").version(package_default.version).option("-f, --format <format>", "Output format: text | json", "text").option("-c, --calendar <id>", "Target calendar ID (repeatable)", collect, []).option("-q, --quiet", "Minimal output", false).option("--tz, --timezone <zone>", "Timezone (e.g., Asia/Tokyo)");
587727
587781
  program2.on("command:*", (operands) => {
587728
587782
  process.stderr.write(`error: unknown command '${operands[0]}'
587729
587783
 
@@ -591778,6 +591832,7 @@ async function handleUpdate(opts) {
591778
591832
  }
591779
591833
  function createUpdateCommand() {
591780
591834
  const cmd = new Command("update").description("Update an existing event").argument("<event-id>", "Event ID to update");
591835
+ cmd.option("-c, --calendar <id>", "Calendar ID");
591781
591836
  cmd.option("-t, --title <title>", "New title");
591782
591837
  cmd.option("-s, --start <datetime>", "New start datetime");
591783
591838
  cmd.option("-e, --end <datetime>", "New end datetime");
@@ -592132,6 +592187,30 @@ function handleError2(error, format3) {
592132
592187
  process.exit(errorCodeToExitCode(errorCode));
592133
592188
  }
592134
592189
 
592190
+ // src/lib/resolve-calendar.ts
592191
+ async function resolveEventCalendar(api2, eventId, calendars) {
592192
+ const results = await Promise.all(calendars.map(async (cal) => {
592193
+ try {
592194
+ await getEvent(api2, cal.id, cal.name, eventId);
592195
+ return { id: cal.id, name: cal.name };
592196
+ } catch (error) {
592197
+ if (error instanceof ApiError && error.code === "NOT_FOUND") {
592198
+ return null;
592199
+ }
592200
+ throw error;
592201
+ }
592202
+ }));
592203
+ const found = results.filter((r) => r !== null);
592204
+ if (found.length === 0) {
592205
+ throw new ApiError("NOT_FOUND", `Event "${eventId}" not found in any enabled calendar`);
592206
+ }
592207
+ if (found.length > 1) {
592208
+ const calList = found.map((c) => `${c.name} (${c.id})`).join(", ");
592209
+ throw new ApiError("INVALID_ARGS", `Event "${eventId}" found in multiple calendars: ${calList}. Specify -c <calendar-id>.`);
592210
+ }
592211
+ return found[0];
592212
+ }
592213
+
592135
592214
  // src/commands/index.ts
592136
592215
  function registerCommands(program2) {
592137
592216
  const authCmd = createAuthCommand();
@@ -592265,8 +592344,9 @@ ${url}`);
592265
592344
  const found = config2.calendars.find((c) => c.id === calendarId);
592266
592345
  cal = found ? { id: found.id, name: found.name } : { id: calendarId, name: calendarId };
592267
592346
  } else {
592268
- const enabled = config2.calendars.filter((c) => c.enabled);
592269
- cal = enabled[0] ?? { id: "primary", name: "Primary" };
592347
+ const calendars = selectCalendars(undefined, config2);
592348
+ const resolved = await resolveEventCalendar(api2, showCmd.args[0], calendars);
592349
+ cal = resolved;
592270
592350
  }
592271
592351
  const timezone = resolveTimezone(globalOpts.timezone, config2.timezone);
592272
592352
  const result = await handleShow({
@@ -592294,8 +592374,15 @@ ${url}`);
592294
592374
  const auth = await getAuthenticatedClient(fsAdapter);
592295
592375
  const calendarApi = import_googleapis2.google.calendar({ version: "v3", auth });
592296
592376
  const api2 = createGoogleCalendarApi(calendarApi);
592297
- const calendars = selectCalendars(deleteOpts.calendar ? [deleteOpts.calendar] : globalOpts.calendar, config2);
592298
- const resolvedCalendarId = calendars[0]?.id ?? "primary";
592377
+ let resolvedCalendarId;
592378
+ if (deleteOpts.calendar || globalOpts.calendar.length > 0) {
592379
+ const calendars = selectCalendars(deleteOpts.calendar ? [deleteOpts.calendar] : globalOpts.calendar, config2);
592380
+ resolvedCalendarId = calendars[0]?.id ?? "primary";
592381
+ } else {
592382
+ const calendars = selectCalendars(undefined, config2);
592383
+ const resolved = await resolveEventCalendar(api2, eventId, calendars);
592384
+ resolvedCalendarId = resolved.id;
592385
+ }
592299
592386
  const result = await handleDelete({
592300
592387
  api: api2,
592301
592388
  eventId,
@@ -592405,8 +592492,16 @@ ${authUrl}`);
592405
592492
  const calendar = import_googleapis2.google.calendar({ version: "v3", auth: oauth2Client });
592406
592493
  const api2 = createGoogleCalendarApi(calendar);
592407
592494
  const timezone = resolveTimezone(globalOpts.timezone, config2.timezone);
592408
- const calendars = selectCalendars(globalOpts.calendar, config2);
592409
- const cal = calendars[0];
592495
+ const updateOpsCalendar = updateOpts.calendar;
592496
+ let cal;
592497
+ if (updateOpsCalendar || globalOpts.calendar.length > 0) {
592498
+ const calendars = selectCalendars(updateOpsCalendar ? [updateOpsCalendar] : globalOpts.calendar, config2);
592499
+ cal = calendars[0];
592500
+ } else {
592501
+ const calendars = selectCalendars(undefined, config2);
592502
+ const resolved = await resolveEventCalendar(api2, eventId, calendars);
592503
+ cal = resolved;
592504
+ }
592410
592505
  const result = await handleUpdate({
592411
592506
  api: api2,
592412
592507
  eventId,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ncukondo/gcal-cli",
3
- "version": "0.1.3",
3
+ "version": "0.1.5",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": "./dist/index.js"