create-baresync 0.2.0 → 0.2.2

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.
package/dist/cli.js CHANGED
@@ -2278,11 +2278,10 @@ function buildRootScaffoldFiles(options) {
2278
2278
  function buildUserFacingNextSteps(options) {
2279
2279
  return [
2280
2280
  `1. cd ${options.projectName}`,
2281
- `2. ${options.packageManager} install`,
2282
- `3. ${options.packageManager} run generate:sync`,
2283
- `4. ${options.packageManager} run migrate:local`,
2284
- `5. ${options.packageManager} run migrate:server`,
2285
- `6. ${options.packageManager} run dev`
2281
+ `2. ${options.packageManager} run generate:sync`,
2282
+ `3. ${options.packageManager} run migrate:local`,
2283
+ `4. ${options.packageManager} run migrate:server`,
2284
+ `5. ${options.packageManager} run dev`
2286
2285
  ].join(`
2287
2286
  `);
2288
2287
  }
@@ -2481,7 +2480,9 @@ async function scaffoldProject() {
2481
2480
  await fs3.mkdir(path3.join(projectDir, "packages"), { recursive: true });
2482
2481
  R2.info(`Detected package manager: ${packageManager}`);
2483
2482
  const appTargetDir = path3.join(projectDir, "apps");
2484
- await runInteractive(packageManager, createCommandArgs(packageManager, "tauri-app", "app"), appTargetDir);
2483
+ try {
2484
+ await runInteractive(packageManager, createCommandArgs(packageManager, "tauri-app", "app"), appTargetDir);
2485
+ } catch {}
2485
2486
  const serverFramework = await promptServerFramework();
2486
2487
  const options = {
2487
2488
  packageManager,
@@ -2494,10 +2495,7 @@ async function scaffoldProject() {
2494
2495
  const serverInitializer = serverFramework === "hono" ? "hono" : "elysia";
2495
2496
  try {
2496
2497
  await runInteractive(packageManager, createCommandArgs(packageManager, serverInitializer, "server"), serverTargetDir);
2497
- } catch {
2498
- R2.warn("\u26A0\uFE0F\u2003Note: create-hono exited with an error (likely an install failure).");
2499
- R2.warn("This is safe to ignore \u2014 you can just run install at the workspace root later.");
2500
- }
2498
+ } catch {}
2501
2499
  await patchAppFiles(projectDir, options, allFiles);
2502
2500
  await patchServerFiles(projectDir, options, allFiles);
2503
2501
  await fs3.writeFile(path3.join(projectDir, "package.json"), JSON.stringify({
@@ -2519,6 +2517,8 @@ Generated with create-baresync.
2519
2517
 
2520
2518
  ${buildUserFacingNextSteps(options)}
2521
2519
  `, "utf8");
2520
+ R2.info("Installing dependencies...");
2521
+ await runInteractive(packageManager, ["install"], projectDir);
2522
2522
  ye(`${import_picocolors.default.green("Success!")} Baresync monorepo starter is ready!
2523
2523
 
2524
2524
  ${buildUserFacingNextSteps(options)}`);
package/dist/index.js CHANGED
@@ -2276,11 +2276,10 @@ function buildRootScaffoldFiles(options) {
2276
2276
  function buildUserFacingNextSteps(options) {
2277
2277
  return [
2278
2278
  `1. cd ${options.projectName}`,
2279
- `2. ${options.packageManager} install`,
2280
- `3. ${options.packageManager} run generate:sync`,
2281
- `4. ${options.packageManager} run migrate:local`,
2282
- `5. ${options.packageManager} run migrate:server`,
2283
- `6. ${options.packageManager} run dev`
2279
+ `2. ${options.packageManager} run generate:sync`,
2280
+ `3. ${options.packageManager} run migrate:local`,
2281
+ `4. ${options.packageManager} run migrate:server`,
2282
+ `5. ${options.packageManager} run dev`
2284
2283
  ].join(`
2285
2284
  `);
2286
2285
  }
@@ -2479,7 +2478,9 @@ async function scaffoldProject() {
2479
2478
  await fs3.mkdir(path3.join(projectDir, "packages"), { recursive: true });
2480
2479
  R2.info(`Detected package manager: ${packageManager}`);
2481
2480
  const appTargetDir = path3.join(projectDir, "apps");
2482
- await runInteractive(packageManager, createCommandArgs(packageManager, "tauri-app", "app"), appTargetDir);
2481
+ try {
2482
+ await runInteractive(packageManager, createCommandArgs(packageManager, "tauri-app", "app"), appTargetDir);
2483
+ } catch {}
2483
2484
  const serverFramework = await promptServerFramework();
2484
2485
  const options = {
2485
2486
  packageManager,
@@ -2492,10 +2493,7 @@ async function scaffoldProject() {
2492
2493
  const serverInitializer = serverFramework === "hono" ? "hono" : "elysia";
2493
2494
  try {
2494
2495
  await runInteractive(packageManager, createCommandArgs(packageManager, serverInitializer, "server"), serverTargetDir);
2495
- } catch {
2496
- R2.warn("\u26A0\uFE0F\u2003Note: create-hono exited with an error (likely an install failure).");
2497
- R2.warn("This is safe to ignore \u2014 you can just run install at the workspace root later.");
2498
- }
2496
+ } catch {}
2499
2497
  await patchAppFiles(projectDir, options, allFiles);
2500
2498
  await patchServerFiles(projectDir, options, allFiles);
2501
2499
  await fs3.writeFile(path3.join(projectDir, "package.json"), JSON.stringify({
@@ -2517,6 +2515,8 @@ Generated with create-baresync.
2517
2515
 
2518
2516
  ${buildUserFacingNextSteps(options)}
2519
2517
  `, "utf8");
2518
+ R2.info("Installing dependencies...");
2519
+ await runInteractive(packageManager, ["install"], projectDir);
2520
2520
  ye(`${import_picocolors.default.green("Success!")} Baresync monorepo starter is ready!
2521
2521
 
2522
2522
  ${buildUserFacingNextSteps(options)}`);
@@ -8,7 +8,7 @@
8
8
  "tauri:dev": "tauri dev"
9
9
  },
10
10
  "dependencies": {
11
- "baresync": "^0.2.0",
11
+ "baresync": "^0.2.1",
12
12
  "drizzle-orm": "^0.45.2"
13
13
  },
14
14
  "devDependencies": {
@@ -4,7 +4,6 @@ Generated with `create-baresync`.
4
4
 
5
5
  ## Commands
6
6
 
7
- - `__PACKAGE_MANAGER__ run install`
8
7
  - `__PACKAGE_MANAGER__ run generate:sync`
9
8
  - `__PACKAGE_MANAGER__ run migrate:local`
10
9
  - `__PACKAGE_MANAGER__ run migrate:server`
@@ -9,7 +9,7 @@
9
9
  "typecheck": "bun x tsc -p tsconfig.json --noEmit"
10
10
  },
11
11
  "dependencies": {
12
- "baresync": "^0.2.0"
12
+ "baresync": "^0.2.1"
13
13
  },
14
14
  "devDependencies": {
15
15
  "drizzle-kit": "0.31.4"
@@ -5,8 +5,7 @@ import {
5
5
  } from "baresync/server";
6
6
  import { Elysia } from "elysia";
7
7
  import { SYNC_SCOPE } from "@sync-contract/constants";
8
- import { db } from "../db/client";
9
- import { createAppSyncRepository } from "../db/v1/sync-repository";
8
+ import { repository } from "../db/v1/sync-repository";
10
9
 
11
10
  const resolveScope = ({ scopeId }: { scopeId: string }) => {
12
11
  if (scopeId !== SYNC_SCOPE) {
@@ -23,8 +22,6 @@ const resolveScope = ({ scopeId }: { scopeId: string }) => {
23
22
  };
24
23
  };
25
24
 
26
- const repository = createAppSyncRepository(db);
27
-
28
25
  const push = createSyncPushHandler({
29
26
  resolveScope,
30
27
  upsertOrder: repository.tableNames,
@@ -5,8 +5,7 @@ import {
5
5
  createSyncPushHandler,
6
6
  createSyncStatusHandler,
7
7
  } from "baresync/server";
8
- import { db } from "../db/client";
9
- import { createAppSyncRepository } from "../db/v1/sync-repository";
8
+ import { repository } from "../db/v1/sync-repository";
10
9
 
11
10
  const resolveScope = ({ scopeId }: { scopeId: string }) => {
12
11
  if (scopeId !== SYNC_SCOPE) {
@@ -23,8 +22,6 @@ const resolveScope = ({ scopeId }: { scopeId: string }) => {
23
22
  };
24
23
  };
25
24
 
26
- const repository = createAppSyncRepository(db);
27
-
28
25
  const push = createSyncPushHandler({
29
26
  resolveScope,
30
27
  upsertOrder: repository.tableNames,
@@ -6,135 +6,120 @@ import {
6
6
  requiredString,
7
7
  } from "baresync/server/drizzle";
8
8
  import { and, desc, eq, gt, type InferInsertModel } from "drizzle-orm";
9
- import type { BetterSQLite3Database } from "drizzle-orm/better-sqlite3";
9
+ import { db } from "../client";
10
10
 
11
- type AppDb = BetterSQLite3Database<Record<string, never>>;
12
-
13
- export interface AppScope {
14
- scopeId: string;
15
- }
16
-
17
- export function createAppSyncRepository(db: AppDb) {
18
- const repository = createDrizzleSyncRepository({
19
- tables: {
20
- lists: {
21
- buildRow: ({ row, scopeId, syncUpdatedAt, updatedAt }) => ({
22
- createdAt: optionalString(row.createdAt) ?? updatedAt,
23
- deletedAt: optionalString(row.deletedAt),
24
- id: requiredString(row.id, "lists.id"),
25
- name: requiredString(row.name, "lists.name"),
26
- description: optionalString(row.description),
27
- scopeId,
28
- syncUpdatedAt,
29
- updatedAt,
30
- }),
31
- readLatestRow: async ({ scopeId }) => {
32
- const rows = await db
33
- .select()
34
- .from(lists)
35
- .where(eq(lists.scopeId, scopeId))
36
- .orderBy(
37
- desc(lists.syncUpdatedAt),
38
- desc(lists.updatedAt),
39
- desc(lists.id)
40
- )
41
- .limit(1);
42
- return rows[0] ?? null;
43
- },
44
- readRows: ({ cursorTimestamp, scopeId }) =>
45
- db
46
- .select()
47
- .from(lists)
48
- .where(
49
- cursorTimestamp > 0
50
- ? and(
51
- eq(lists.scopeId, scopeId),
52
- gt(lists.syncUpdatedAt, cursorTimestamp)
53
- )
54
- : eq(lists.scopeId, scopeId)
55
- )
56
- .orderBy(
57
- desc(lists.syncUpdatedAt),
58
- desc(lists.updatedAt),
59
- desc(lists.id)
60
- ) as Promise<readonly DrizzleSyncReadRow[]>,
61
- softDeleteRow: async ({ id, syncUpdatedAt, updatedAt }) => {
62
- await db
63
- .update(lists)
64
- .set({ deletedAt: updatedAt, syncUpdatedAt, updatedAt })
65
- .where(eq(lists.id, id));
66
- },
67
- upsertRow: async (row: InferInsertModel<typeof lists>) => {
68
- const { id: _id, ...setValues } = row;
69
- await db.insert(lists).values(row).onConflictDoUpdate({
70
- target: lists.id,
71
- set: setValues,
72
- });
73
- },
11
+ export const repository = createDrizzleSyncRepository({
12
+ tables: {
13
+ lists: {
14
+ buildRow: ({ row, scopeId, syncUpdatedAt, updatedAt }) => ({
15
+ createdAt: optionalString(row.createdAt) ?? updatedAt,
16
+ deletedAt: optionalString(row.deletedAt),
17
+ id: requiredString(row.id, "lists.id"),
18
+ name: requiredString(row.name, "lists.name"),
19
+ description: optionalString(row.description),
20
+ scopeId,
21
+ syncUpdatedAt,
22
+ updatedAt,
23
+ }),
24
+ readLatestRow: async ({ scopeId }) => {
25
+ const rows = await db
26
+ .select()
27
+ .from(lists)
28
+ .where(eq(lists.scopeId, scopeId))
29
+ .orderBy(
30
+ desc(lists.syncUpdatedAt),
31
+ desc(lists.updatedAt),
32
+ desc(lists.id)
33
+ )
34
+ .limit(1);
35
+ return rows[0] ?? null;
74
36
  },
75
- todos: {
76
- buildRow: ({ row, scopeId, syncUpdatedAt, updatedAt }) => ({
77
- createdAt: optionalString(row.createdAt) ?? updatedAt,
78
- deletedAt: optionalString(row.deletedAt),
79
- id: requiredString(row.id, "todos.id"),
80
- listId: requiredString(row.listId, "todos.listId"),
81
- title: requiredString(row.title, "todos.title"),
82
- notes: optionalString(row.notes),
83
- scopeId,
84
- syncUpdatedAt,
85
- updatedAt,
86
- }),
87
- readLatestRow: async ({ scopeId }) => {
88
- const rows = await db
89
- .select()
90
- .from(todos)
91
- .where(eq(todos.scopeId, scopeId))
92
- .orderBy(
93
- desc(todos.syncUpdatedAt),
94
- desc(todos.updatedAt),
95
- desc(todos.id)
96
- )
97
- .limit(1);
98
- return rows[0] ?? null;
99
- },
100
- readRows: ({ cursorTimestamp, scopeId }) =>
101
- db
102
- .select()
103
- .from(todos)
104
- .where(
105
- cursorTimestamp > 0
106
- ? and(
107
- eq(todos.scopeId, scopeId),
108
- gt(todos.syncUpdatedAt, cursorTimestamp)
109
- )
110
- : eq(todos.scopeId, scopeId)
111
- )
112
- .orderBy(
113
- desc(todos.syncUpdatedAt),
114
- desc(todos.updatedAt),
115
- desc(todos.id)
116
- ) as Promise<readonly DrizzleSyncReadRow[]>,
117
- softDeleteRow: async ({ id, syncUpdatedAt, updatedAt }) => {
118
- await db
119
- .update(todos)
120
- .set({ deletedAt: updatedAt, syncUpdatedAt, updatedAt })
121
- .where(eq(todos.id, id));
122
- },
123
- upsertRow: async (row: InferInsertModel<typeof todos>) => {
124
- const { id: _id, ...setValues } = row;
125
- await db.insert(todos).values(row).onConflictDoUpdate({
126
- target: todos.id,
127
- set: setValues,
128
- });
129
- },
37
+ readRows: ({ cursorTimestamp, scopeId }) =>
38
+ db
39
+ .select()
40
+ .from(lists)
41
+ .where(
42
+ cursorTimestamp > 0
43
+ ? and(
44
+ eq(lists.scopeId, scopeId),
45
+ gt(lists.syncUpdatedAt, cursorTimestamp)
46
+ )
47
+ : eq(lists.scopeId, scopeId)
48
+ )
49
+ .orderBy(
50
+ desc(lists.syncUpdatedAt),
51
+ desc(lists.updatedAt),
52
+ desc(lists.id)
53
+ ) as Promise<readonly DrizzleSyncReadRow[]>,
54
+ softDeleteRow: async ({ id, syncUpdatedAt, updatedAt }) => {
55
+ await db
56
+ .update(lists)
57
+ .set({ deletedAt: updatedAt, syncUpdatedAt, updatedAt })
58
+ .where(eq(lists.id, id));
59
+ },
60
+ upsertRow: async (row: InferInsertModel<typeof lists>) => {
61
+ const { id: _id, ...setValues } = row;
62
+ await db.insert(lists).values(row).onConflictDoUpdate({
63
+ target: lists.id,
64
+ set: setValues,
65
+ });
130
66
  },
131
67
  },
132
- });
133
-
134
- return {
135
- tableNames: repository.tableNames,
136
- applyPushChanges: repository.applyPushChanges,
137
- loadPullChanges: repository.loadPullChanges,
138
- loadSyncStatus: repository.loadSyncStatus,
139
- };
140
- }
68
+ todos: {
69
+ buildRow: ({ row, scopeId, syncUpdatedAt, updatedAt }) => ({
70
+ createdAt: optionalString(row.createdAt) ?? updatedAt,
71
+ deletedAt: optionalString(row.deletedAt),
72
+ id: requiredString(row.id, "todos.id"),
73
+ listId: requiredString(row.listId, "todos.listId"),
74
+ title: requiredString(row.title, "todos.title"),
75
+ notes: optionalString(row.notes),
76
+ scopeId,
77
+ syncUpdatedAt,
78
+ updatedAt,
79
+ }),
80
+ readLatestRow: async ({ scopeId }) => {
81
+ const rows = await db
82
+ .select()
83
+ .from(todos)
84
+ .where(eq(todos.scopeId, scopeId))
85
+ .orderBy(
86
+ desc(todos.syncUpdatedAt),
87
+ desc(todos.updatedAt),
88
+ desc(todos.id)
89
+ )
90
+ .limit(1);
91
+ return rows[0] ?? null;
92
+ },
93
+ readRows: ({ cursorTimestamp, scopeId }) =>
94
+ db
95
+ .select()
96
+ .from(todos)
97
+ .where(
98
+ cursorTimestamp > 0
99
+ ? and(
100
+ eq(todos.scopeId, scopeId),
101
+ gt(todos.syncUpdatedAt, cursorTimestamp)
102
+ )
103
+ : eq(todos.scopeId, scopeId)
104
+ )
105
+ .orderBy(
106
+ desc(todos.syncUpdatedAt),
107
+ desc(todos.updatedAt),
108
+ desc(todos.id)
109
+ ) as Promise<readonly DrizzleSyncReadRow[]>,
110
+ softDeleteRow: async ({ id, syncUpdatedAt, updatedAt }) => {
111
+ await db
112
+ .update(todos)
113
+ .set({ deletedAt: updatedAt, syncUpdatedAt, updatedAt })
114
+ .where(eq(todos.id, id));
115
+ },
116
+ upsertRow: async (row: InferInsertModel<typeof todos>) => {
117
+ const { id: _id, ...setValues } = row;
118
+ await db.insert(todos).values(row).onConflictDoUpdate({
119
+ target: todos.id,
120
+ set: setValues,
121
+ });
122
+ },
123
+ },
124
+ },
125
+ });
@@ -16,7 +16,7 @@
16
16
  "typecheck": "bun x tsc -p tsconfig.json --noEmit"
17
17
  },
18
18
  "dependencies": {
19
- "baresync": "^0.2.0",
19
+ "baresync": "^0.2.1",
20
20
  "drizzle-orm": "^0.45.2"
21
21
  },
22
22
  "devDependencies": {
@@ -1,4 +1 @@
1
- export const PROJECT_NAME = "__PROJECT_NAME__";
2
1
  export const SYNC_SCOPE = "default";
3
- export const LISTS_TABLE_NAME = "lists";
4
- export const TODOS_TABLE_NAME = "todos";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-baresync",
3
- "version": "0.2.0",
3
+ "version": "0.2.2",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "description": "Scaffold Baresync starter workspaces",