lucy-cli 2.0.0-alpha.12 → 2.0.0-alpha.14

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 (253) hide show
  1. package/.turbo/cookies/7.cookie +0 -0
  2. package/.turbo/cookies/8.cookie +0 -0
  3. package/.turbo/daemon/ee24a4f4ab6aa3c0-turbo.log.2025-08-01 +0 -0
  4. package/.turbo/daemon/ee24a4f4ab6aa3c0-turbo.log.2025-08-02 +0 -0
  5. package/dist/args.js +47 -7
  6. package/dist/args.js.map +1 -1
  7. package/dist/commands/checks.d.ts +1 -1
  8. package/dist/commands/checks.js +2 -2
  9. package/dist/commands/checks.js.map +1 -1
  10. package/dist/commands/copy.d.ts +1 -0
  11. package/dist/commands/copy.js +9 -1
  12. package/dist/commands/copy.js.map +1 -1
  13. package/dist/commands/edit.d.ts +1 -1
  14. package/dist/commands/edit.js +3 -3
  15. package/dist/commands/edit.js.map +1 -1
  16. package/dist/commands/exec.d.ts +1 -1
  17. package/dist/commands/files.d.ts +7 -0
  18. package/dist/commands/files.js +28 -0
  19. package/dist/commands/files.js.map +1 -0
  20. package/dist/commands/read.d.ts +3 -2
  21. package/dist/commands/read.js +14 -7
  22. package/dist/commands/read.js.map +1 -1
  23. package/dist/commands/write.d.ts +2 -0
  24. package/dist/commands/write.js +15 -3
  25. package/dist/commands/write.js.map +1 -1
  26. package/dist/config.d.ts +20 -2
  27. package/dist/config.js +84 -57
  28. package/dist/config.js.map +1 -1
  29. package/dist/helpers.d.ts +9 -0
  30. package/dist/helpers.js +86 -0
  31. package/dist/helpers.js.map +1 -1
  32. package/dist/index.d.ts +1 -0
  33. package/dist/index.js +42 -4
  34. package/dist/index.js.map +1 -1
  35. package/dist/init/blocks.d.ts +1 -1
  36. package/dist/init/blocks.js +2 -2
  37. package/dist/init/blocks.js.map +1 -1
  38. package/dist/init/cargo.d.ts +1 -1
  39. package/dist/init/expo.d.ts +1 -1
  40. package/dist/init/gitModules.d.ts +1 -1
  41. package/dist/init/index.d.ts +1 -1
  42. package/dist/init/index.js +45 -47
  43. package/dist/init/index.js.map +1 -1
  44. package/dist/init/monorepo.d.ts +1 -1
  45. package/dist/init/prepareVelo.d.ts +1 -1
  46. package/dist/init/tauri.d.ts +1 -1
  47. package/dist/init/templates.d.ts +1 -1
  48. package/dist/init/templates.js +11 -12
  49. package/dist/init/templates.js.map +1 -1
  50. package/dist/init/velo.d.ts +1 -1
  51. package/dist/runtime.d.ts +1 -1
  52. package/dist/schemas/gulp.d.ts +25 -15
  53. package/dist/schemas/gulp.js +4 -0
  54. package/dist/schemas/gulp.js.map +1 -1
  55. package/dist/schemas/index.d.ts +10 -0
  56. package/dist/schemas/index.js +8 -0
  57. package/dist/schemas/index.js.map +1 -1
  58. package/dist/schemas/lucy.d.ts +5 -5
  59. package/dist/schemas/lucy.js +8 -8
  60. package/dist/schemas/lucy.js.map +1 -1
  61. package/dist/schemas/types.d.ts +23 -7
  62. package/dist/schemas/types.js +4 -2
  63. package/dist/schemas/types.js.map +1 -1
  64. package/dist/sync/sync.d.ts +3 -0
  65. package/dist/sync/sync.js +91 -87
  66. package/dist/sync/sync.js.map +1 -1
  67. package/dist/tasks/Gulpfile.d.ts +4 -35
  68. package/dist/tasks/Gulpfile.js +81 -104
  69. package/dist/tasks/Gulpfile.js.map +1 -1
  70. package/dist/tasks/gitModules.d.ts +2 -0
  71. package/dist/tasks/gitModules.js +13 -0
  72. package/dist/tasks/gitModules.js.map +1 -0
  73. package/dist/tasks/gulp/backend.d.ts +1 -1
  74. package/dist/tasks/gulp/backend.js +10 -10
  75. package/dist/tasks/gulp/backend.js.map +1 -1
  76. package/dist/tasks/gulp/checks.d.ts +1 -1
  77. package/dist/tasks/gulp/checks.js +3 -2
  78. package/dist/tasks/gulp/checks.js.map +1 -1
  79. package/dist/tasks/gulp/clean.d.ts +1 -1
  80. package/dist/tasks/gulp/clean.js +1 -1
  81. package/dist/tasks/gulp/clean.js.map +1 -1
  82. package/dist/tasks/gulp/copy.d.ts +1 -1
  83. package/dist/tasks/gulp/copy.js +3 -4
  84. package/dist/tasks/gulp/copy.js.map +1 -1
  85. package/dist/tasks/gulp/helpers.d.ts +3 -2
  86. package/dist/tasks/gulp/helpers.js +6 -8
  87. package/dist/tasks/gulp/helpers.js.map +1 -1
  88. package/dist/tasks/gulp/pages.d.ts +1 -1
  89. package/dist/tasks/gulp/pages.js.map +1 -1
  90. package/dist/tasks/gulp/pipeline.js +3 -3
  91. package/dist/tasks/gulp/pipeline.js.map +1 -1
  92. package/dist/tasks/gulp/public.d.ts +1 -1
  93. package/dist/tasks/gulp/public.js +5 -5
  94. package/dist/tasks/gulp/public.js.map +1 -1
  95. package/dist/tasks/gulp/styles.d.ts +1 -1
  96. package/dist/tasks/gulp/styles.js +10 -10
  97. package/dist/tasks/gulp/styles.js.map +1 -1
  98. package/dist/tasks/gulp/templates.d.ts +1 -1
  99. package/dist/tasks/gulp/templates.js +3 -3
  100. package/dist/tasks/gulp/templates.js.map +1 -1
  101. package/dist/tasks/gulp/types.d.ts +1 -1
  102. package/dist/tasks/gulp/types.js +61 -68
  103. package/dist/tasks/gulp/types.js.map +1 -1
  104. package/dist/tasks/gulp/watchers.d.ts +1 -8
  105. package/dist/tasks/gulp/watchers.js +48 -46
  106. package/dist/tasks/gulp/watchers.js.map +1 -1
  107. package/dist/tasks/index.d.ts +1 -1
  108. package/dist/tasks/index.js +19 -21
  109. package/dist/tasks/index.js.map +1 -1
  110. package/dist/tasks/syncPkg.d.ts +3 -0
  111. package/dist/tasks/syncPkg.js +13 -0
  112. package/dist/tasks/syncPkg.js.map +1 -0
  113. package/dist/tasks/syncSettings.d.ts +3 -0
  114. package/dist/tasks/syncSettings.js +18 -0
  115. package/dist/tasks/syncSettings.js.map +1 -0
  116. package/dist/wix-sdk/check.d.ts +4 -0
  117. package/dist/wix-sdk/check.js +23 -0
  118. package/dist/wix-sdk/check.js.map +1 -0
  119. package/dist/wix-sdk/client.d.ts +10 -0
  120. package/dist/wix-sdk/client.js +18 -0
  121. package/dist/wix-sdk/client.js.map +1 -0
  122. package/dist/wix-sdk/import.d.ts +1 -0
  123. package/{src/sync/sync.ts → dist/wix-sdk/import.js} +12 -20
  124. package/dist/wix-sdk/import.js.map +1 -0
  125. package/dist/wix-sdk/index.d.ts +4 -0
  126. package/dist/wix-sdk/index.js +15 -0
  127. package/dist/wix-sdk/index.js.map +1 -0
  128. package/dist/wix-sdk/init copy.d.ts +4 -0
  129. package/dist/wix-sdk/init copy.js +51 -0
  130. package/dist/wix-sdk/init copy.js.map +1 -0
  131. package/dist/wix-sdk/init.d.ts +4 -0
  132. package/dist/wix-sdk/init.js +51 -0
  133. package/dist/wix-sdk/init.js.map +1 -0
  134. package/dist/wix-sdk/is-allive.d.ts +4 -0
  135. package/dist/wix-sdk/is-allive.js +37 -0
  136. package/dist/wix-sdk/is-allive.js.map +1 -0
  137. package/dist/wix-sdk/run.d.ts +4 -0
  138. package/dist/wix-sdk/run.js +53 -0
  139. package/dist/wix-sdk/run.js.map +1 -0
  140. package/dist/wix-sdk/sync copy.d.ts +1 -0
  141. package/dist/wix-sdk/sync copy.js +88 -0
  142. package/dist/wix-sdk/sync copy.js.map +1 -0
  143. package/dist/wix-sdk/sync.d.ts +1 -0
  144. package/dist/wix-sdk/sync.js +88 -0
  145. package/dist/wix-sdk/sync.js.map +1 -0
  146. package/dist/wix-sdk/wix_sdk_check.d.ts +4 -0
  147. package/dist/wix-sdk/wix_sdk_check.js +37 -0
  148. package/dist/wix-sdk/wix_sdk_check.js.map +1 -0
  149. package/dist/wix-sync/client.d.ts +3 -0
  150. package/dist/wix-sync/client.js +5 -0
  151. package/dist/wix-sync/client.js.map +1 -0
  152. package/dist/wix-sync/export copy.d.ts +4 -0
  153. package/dist/wix-sync/export copy.js +21 -0
  154. package/dist/wix-sync/export copy.js.map +1 -0
  155. package/dist/wix-sync/export.d.ts +4 -0
  156. package/dist/wix-sync/export.js +15 -0
  157. package/dist/wix-sync/export.js.map +1 -0
  158. package/dist/wix-sync/import copy.d.ts +4 -0
  159. package/dist/wix-sync/import copy.js +21 -0
  160. package/dist/wix-sync/import copy.js.map +1 -0
  161. package/dist/wix-sync/import.d.ts +4 -0
  162. package/dist/wix-sync/import.js +26 -0
  163. package/dist/wix-sync/import.js.map +1 -0
  164. package/dist/wix-sync/index.d.ts +4 -0
  165. package/dist/wix-sync/index.js +35 -0
  166. package/dist/wix-sync/index.js.map +1 -0
  167. package/dist/wix-sync/init copy.d.ts +4 -0
  168. package/dist/wix-sync/init copy.js +54 -0
  169. package/dist/wix-sync/init copy.js.map +1 -0
  170. package/dist/wix-sync/init.d.ts +4 -0
  171. package/dist/wix-sync/init.js +74 -0
  172. package/dist/wix-sync/init.js.map +1 -0
  173. package/dist/wix-sync/is-alive.d.ts +4 -0
  174. package/dist/wix-sync/is-alive.js +23 -0
  175. package/dist/wix-sync/is-alive.js.map +1 -0
  176. package/dist/wix-sync/is-allive copy.d.ts +4 -0
  177. package/dist/wix-sync/is-allive copy.js +23 -0
  178. package/dist/wix-sync/is-allive copy.js.map +1 -0
  179. package/dist/wix-sync/is-allive.d.ts +4 -0
  180. package/dist/wix-sync/is-allive.js +23 -0
  181. package/dist/wix-sync/is-allive.js.map +1 -0
  182. package/dist/wix-sync/migrate.d.ts +4 -0
  183. package/dist/wix-sync/migrate.js +21 -0
  184. package/dist/wix-sync/migrate.js.map +1 -0
  185. package/dist/wix-sync/sync-od.d.ts +0 -0
  186. package/dist/wix-sync/sync-od.js +100 -0
  187. package/dist/wix-sync/sync-od.js.map +1 -0
  188. package/dist/wix-sync/sync.d.ts +4 -0
  189. package/dist/wix-sync/sync.js +26 -0
  190. package/dist/wix-sync/sync.js.map +1 -0
  191. package/dist/wix-sync/sync2.d.ts +4 -0
  192. package/dist/wix-sync/sync2.js +25 -0
  193. package/dist/wix-sync/sync2.js.map +1 -0
  194. package/dist/wix-sync copy/index.d.ts +4 -0
  195. package/dist/wix-sync copy/index.js +17 -0
  196. package/dist/wix-sync copy/index.js.map +1 -0
  197. package/dist/wix-sync copy/init.d.ts +4 -0
  198. package/dist/wix-sync copy/init.js +58 -0
  199. package/dist/wix-sync copy/init.js.map +1 -0
  200. package/dist/wix-sync copy/is-allive.d.ts +4 -0
  201. package/dist/wix-sync copy/is-allive.js +36 -0
  202. package/dist/wix-sync copy/is-allive.js.map +1 -0
  203. package/dist/wix-sync copy/sync.d.ts +1 -0
  204. package/dist/wix-sync copy/sync.js +88 -0
  205. package/dist/wix-sync copy/sync.js.map +1 -0
  206. package/files/sync-data/data/test.csv +17 -0
  207. package/files/sync-data/schema/test.json +11 -0
  208. package/package.json +5 -2
  209. package/src/args.ts +47 -7
  210. package/src/commands/checks.ts +2 -2
  211. package/src/commands/copy.ts +13 -1
  212. package/src/commands/edit.ts +3 -3
  213. package/src/commands/read.ts +17 -8
  214. package/src/commands/write.ts +25 -4
  215. package/src/config.ts +106 -65
  216. package/src/helpers.ts +90 -0
  217. package/src/index.ts +49 -9
  218. package/src/init/blocks.ts +2 -2
  219. package/src/init/index.ts +45 -51
  220. package/src/init/templates.ts +11 -12
  221. package/src/schemas/gulp.ts +24 -15
  222. package/src/schemas/index.ts +12 -1
  223. package/src/schemas/lucy.ts +9 -8
  224. package/src/schemas/types.ts +25 -7
  225. package/src/tasks/Gulpfile.ts +175 -219
  226. package/src/tasks/gulp/backend.ts +11 -11
  227. package/src/tasks/gulp/checks.ts +4 -3
  228. package/src/tasks/gulp/clean.ts +2 -2
  229. package/src/tasks/gulp/copy.ts +4 -10
  230. package/src/tasks/gulp/helpers.ts +6 -13
  231. package/src/tasks/gulp/pages.ts +1 -1
  232. package/src/tasks/gulp/pipeline.ts +4 -5
  233. package/src/tasks/gulp/public.ts +6 -6
  234. package/src/tasks/gulp/styles.ts +11 -11
  235. package/src/tasks/gulp/templates.ts +4 -4
  236. package/src/tasks/gulp/types.ts +62 -69
  237. package/src/tasks/gulp/watchers.ts +77 -81
  238. package/src/tasks/index.ts +21 -27
  239. package/src/tasks/syncSettings.ts +21 -0
  240. package/src/wix-sdk/check.ts +24 -0
  241. package/src/wix-sdk/client.ts +18 -0
  242. package/src/wix-sdk/index.ts +17 -0
  243. package/src/wix-sdk/init.ts +54 -0
  244. package/src/wix-sdk/run.ts +56 -0
  245. package/src/wix-sync/client.ts +6 -0
  246. package/src/wix-sync/export.ts +19 -0
  247. package/src/wix-sync/import.ts +27 -0
  248. package/src/wix-sync/index.ts +36 -0
  249. package/src/wix-sync/init.ts +77 -0
  250. package/src/wix-sync/is-alive.ts +25 -0
  251. package/src/wix-sync/migrate.ts +23 -0
  252. package/src/wix-sync/sync.ts +27 -0
  253. /package/{src/sync/index.ts → .turbo/cookies/6.cookie} +0 -0
@@ -0,0 +1,54 @@
1
+ import { Effect, Schema } from "effect/index";
2
+ import { Config } from "../config.js";
3
+ import Enquirer from "enquirer";
4
+ import { AppError } from "../error.js";
5
+ import { writeWixSDKSettings } from "../commands/write.js";
6
+ import { wixSDKSettings } from "../schemas/index.js";
7
+ import { logger } from "../utils/logger.js";
8
+ import { wix_sdk_check } from "./check.js";
9
+
10
+ export const wix_sdk_init = Effect.gen(function* (_) {
11
+ const config = yield* Config;
12
+ const prompter = new Enquirer();
13
+
14
+ const choice = yield* Effect.tryPromise({
15
+ try: () => prompter.prompt([
16
+ {
17
+ type: 'input',
18
+ name: 'siteId',
19
+ message: 'Enter the Wix SDK site ID',
20
+ initial: config.config.wixSDKSettings?.siteId || 'siteId',
21
+ validate: (value: string) => value.trim() !== '' ? true : 'Site ID cannot be empty'
22
+ },
23
+ {
24
+ type: 'input',
25
+ name: 'apiKey',
26
+ message: 'Enter the Wix SDK API key',
27
+ initial: config.config.wixSDKSettings?.apiKey || 'apiKey',
28
+ validate: (value: string) => value.trim() !== '' ? true : 'API key cannot be empty'
29
+ }
30
+ ]),
31
+ catch: (e) => {
32
+ return new AppError({ cause: e, message: 'Error initializing wix-sdk settings' });
33
+ }
34
+ });
35
+
36
+ config.config.wixSDKSettings = yield* Schema.decodeUnknown(wixSDKSettings)(choice)
37
+ yield* writeWixSDKSettings
38
+
39
+ const question = new Enquirer();
40
+ const verify = yield* Effect.tryPromise({
41
+ try: () => question.prompt({
42
+ type: 'confirm',
43
+ name: 'verify',
44
+ message: 'Do you want to verify the wix-sdk settings?',
45
+ }),
46
+ catch: (e) => {
47
+ return new AppError({ cause: e, message: 'Error setting up wix-sdk settings' });
48
+ }
49
+ })
50
+ const verifySDK = yield* Schema.decodeUnknown(Schema.Struct({ verify: Schema.Boolean }))(verify)
51
+ if (verifySDK.verify) yield* wix_sdk_check
52
+
53
+ logger.success(`Velo-sync settings initialized successfully!`);
54
+ })
@@ -0,0 +1,56 @@
1
+ import { Effect, Schema } from "effect/index";
2
+ import { Config } from "../config.js";
3
+ import Enquirer from "enquirer";
4
+ import { AppError } from "../error.js";
5
+ import { writeWixSDKSettings } from "../commands/write.js";
6
+ import { wixSDKSettings } from "../schemas/index.js";
7
+ import { logger } from "../utils/logger.js";
8
+ import { wix_sdk_check } from "./check.js";
9
+
10
+ export const wix_sdk_run = (program: Effect.Effect<never, AppError, never>) => {
11
+ return Effect.gen(function* (_) {
12
+ const config = yield* Config;
13
+ const prompter = new Enquirer();
14
+
15
+ const choice = yield* Effect.tryPromise({
16
+ try: () => prompter.prompt([
17
+ {
18
+ type: 'input',
19
+ name: 'siteId',
20
+ message: 'Enter the Wix SDK site ID',
21
+ initial: config.config.wixSDKSettings?.siteId || 'siteId',
22
+ validate: (value: string) => value.trim() !== '' ? true : 'Site ID cannot be empty'
23
+ },
24
+ {
25
+ type: 'input',
26
+ name: 'apiKey',
27
+ message: 'Enter the Wix SDK API key',
28
+ initial: config.config.wixSDKSettings?.apiKey || 'apiKey',
29
+ validate: (value: string) => value.trim() !== '' ? true : 'API key cannot be empty'
30
+ }
31
+ ]),
32
+ catch: (e) => {
33
+ return new AppError({ cause: e, message: 'Error initializing wix-sdk settings' });
34
+ }
35
+ });
36
+
37
+ config.config.wixSDKSettings = yield* Schema.decodeUnknown(wixSDKSettings)(choice)
38
+ yield* writeWixSDKSettings
39
+
40
+ const question = new Enquirer();
41
+ const verify = yield* Effect.tryPromise({
42
+ try: () => question.prompt({
43
+ type: 'confirm',
44
+ name: 'verify',
45
+ message: 'Do you want to verify the wix-sdk settings?',
46
+ }),
47
+ catch: (e) => {
48
+ return new AppError({ cause: e, message: 'Error setting up wix-sdk settings' });
49
+ }
50
+ })
51
+ const verifySDK = yield* Schema.decodeUnknown(Schema.Struct({ verify: Schema.Boolean }))(verify)
52
+ if (verifySDK.verify) yield* wix_sdk_check
53
+
54
+ logger.success(`Velo-sync settings initialized successfully!`);
55
+ })
56
+ }
@@ -0,0 +1,6 @@
1
+ import syncTask from 'velo-sync/dist/tasks/sync-task.js';
2
+ import { MigrateFileCache, SyncTaskType } from "../schemas/types";
3
+ import migrateFileCache from 'velo-sync/dist/tasks/migrate-files-cache-task.js';
4
+
5
+ export const runSyncTask = (syncTask as unknown as { default: SyncTaskType }).default;
6
+ export const migrateFileCacheTask = (migrateFileCache as unknown as { default: MigrateFileCache }).default;
@@ -0,0 +1,19 @@
1
+ import { Effect, Schema } from "effect/index";
2
+ import { Config } from "../config.js";
3
+ import Enquirer from "enquirer";
4
+ import { AppError } from "../error.js";
5
+ import { logger } from "../utils/logger.js";
6
+ import veloAPI from 'velo-sync/dist/velo/velo-api.js';
7
+
8
+ export const exportData = Effect.gen(function* (_) {
9
+ const config = yield* Config;
10
+ const veloSyncSettings = config.config.veloSyncSettings;
11
+ if (!veloSyncSettings) return yield* Effect.fail(new AppError({ message: 'Velo-sync settings not found', cause: new Error('Velo-sync settings not found') }));
12
+
13
+ logger.action(`Exporting data for site ${veloSyncSettings.siteUrl}...`);
14
+
15
+ logger.warning('Not implemented yet, please use the Velo Sync CLI for now.');
16
+
17
+ // logger.success(`Data for site ${veloSyncSettings.siteUrl} exported successfully!`);
18
+ return
19
+ })
@@ -0,0 +1,27 @@
1
+ import { Effect, Schema } from "effect/index";
2
+ import { Config } from "../config.js";
3
+ import { AppError } from "../error.js";
4
+ import { logger } from "../utils/logger.js";
5
+ import { runSyncTask } from "./client.js";
6
+
7
+ export const importData = Effect.gen(function* (_) {
8
+ const config = yield* Config;
9
+ const veloSyncSettings = config.config.veloSyncSettings;
10
+ if (!veloSyncSettings) return yield* Effect.fail(new AppError({ message: 'Velo-sync settings not found', cause: new Error('Velo-sync settings not found') }));
11
+
12
+ logger.action(`Importing data for site ${veloSyncSettings.siteUrl}...`);
13
+ let filename = config.config.veloSyncArguments?.data || '';
14
+ let collection = config.config.veloSyncArguments?.collection || '';
15
+ let schema = config.config.veloSyncArguments?.schema || '';
16
+ let dryrun = config.config.veloSyncArguments?.dry || false;
17
+ let importOnly = true
18
+ const res = yield* Effect.tryPromise({
19
+ try: () => runSyncTask(filename, collection, schema, importOnly, dryrun),
20
+ catch: (e) => {
21
+ return new AppError({ cause: e, message: 'Error syncing data' });
22
+ }
23
+ })
24
+
25
+ logger.success(`Data for site ${veloSyncSettings.siteUrl} imported successfully!`);
26
+ return
27
+ })
@@ -0,0 +1,36 @@
1
+ import { Effect, Schema } from "effect/index"
2
+ import { Config } from "../config.js";
3
+ import { AppError } from "../error.js";
4
+ import { init } from "./init.js";
5
+ import { sync } from "./sync.js";
6
+ import { migrate } from "./migrate.js";
7
+ import { importData } from "./import.js";
8
+ import { exportData } from "./export.js";
9
+ import { is_alive } from "./is-alive.js";
10
+
11
+
12
+ export const wix_sync = Effect.gen(function* (_) {
13
+ const config = yield* Config;
14
+ if(config.config.action.syncAction === undefined) {
15
+ return yield* Effect.fail(new AppError({ message: "No sync action provided", cause: new Error("No sync action provided") }));
16
+ }
17
+ if(config.config.action.syncAction === 'init') {
18
+ return yield* init;
19
+ }
20
+ if(config.config.action.syncAction === 'sync') {
21
+ return yield* sync;
22
+ }
23
+ if(config.config.action.syncAction === 'migrate') {
24
+ return yield* migrate;
25
+ }
26
+ if(config.config.action.syncAction === 'import') {
27
+ return yield* importData;
28
+ }
29
+ if(config.config.action.syncAction === 'export') {
30
+ return yield* exportData;
31
+ }
32
+ if(config.config.action.syncAction === 'is-alive') {
33
+ return yield* is_alive;
34
+ }
35
+ yield* Effect.fail(new AppError({ message: `Unsupported sync action type: ${config.config.action.syncAction}`, cause: new Error(`Unsupported sync action type: ${config.config.action.syncAction}`) }));
36
+ })
@@ -0,0 +1,77 @@
1
+ import { Effect, Schema } from "effect/index";
2
+ import { Config } from "../config.js";
3
+ import Enquirer from "enquirer";
4
+ import { AppError } from "../error.js";
5
+ import { writeVeloSyncSettings } from "../commands/write.js";
6
+ import { veloSyncSettings } from "../schemas/index.js";
7
+ import { logger } from "../utils/logger.js";
8
+ import { is_alive } from "./is-alive.js";
9
+ import { copySyncFiles } from "../commands/copy.js";
10
+
11
+ export const init = Effect.gen(function* (_) {
12
+ const config = yield* Config;
13
+ const prompter = new Enquirer();
14
+
15
+ const choice = yield* Effect.tryPromise({
16
+ try: () => prompter.prompt([
17
+ {
18
+ type: 'input',
19
+ name: 'siteUrl',
20
+ message: 'Enter a project URL',
21
+ initial: config.config.veloSyncSettings?.siteUrl || 'https://example.com',
22
+ validate: (value: string) => {
23
+ const urlPattern = /^https:\/\/[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/;
24
+ if (!value.trim()) return 'Project URL cannot be empty';
25
+ if (!urlPattern.test(value.trim())) return 'URL must be in the format https://domain.com';
26
+ return true;
27
+ }
28
+ },
29
+ {
30
+ type: 'input',
31
+ name: 'secret',
32
+ message: 'Enter the velo-sync secret',
33
+ initial: config.config.veloSyncSettings?.secret || 'secret',
34
+ validate: (value: string) => value.trim() !== '' ? true : 'Secret cannot be empty'
35
+ }
36
+ ]),
37
+ catch: (e) => {
38
+ return new AppError({ cause: e, message: 'Error initializing velo-sync settings' });
39
+ }
40
+ });
41
+
42
+ config.config.veloSyncSettings = yield* Schema.decodeUnknown(veloSyncSettings)(choice)
43
+ yield* writeVeloSyncSettings
44
+
45
+ const copyFilesQuestion = new Enquirer();
46
+ const copyFiles = yield* Effect.tryPromise({
47
+ try: () => copyFilesQuestion.prompt({
48
+ type: 'confirm',
49
+ name: 'copyFiles',
50
+ message: 'Do you want to copy the velo-sync files to your project?',
51
+ }),
52
+ catch: (e) => {
53
+ return new AppError({ cause: e, message: 'Error copying velo-sync files' });
54
+ }
55
+ })
56
+ const copy = yield* Schema.decodeUnknown(Schema.Struct({ copyFiles: Schema.Boolean }))(copyFiles)
57
+ if (copy.copyFiles) {
58
+ yield* copySyncFiles
59
+ }
60
+
61
+
62
+ const question = new Enquirer();
63
+ const verify = yield* Effect.tryPromise({
64
+ try: () => question.prompt({
65
+ type: 'confirm',
66
+ name: 'verify',
67
+ message: 'Do you want to verify the velo-sync settings?',
68
+ }),
69
+ catch: (e) => {
70
+ return new AppError({ cause: e, message: 'Error setting up velo-sync settings' });
71
+ }
72
+ })
73
+ const verifySync = yield* Schema.decodeUnknown(Schema.Struct({ verify: Schema.Boolean }))(verify)
74
+ if (verifySync.verify) yield* is_alive
75
+
76
+ logger.success(`Velo-sync settings initialized successfully!`);
77
+ })
@@ -0,0 +1,25 @@
1
+ import { Effect, Schema } from "effect/index";
2
+ import { Config } from "../config.js";
3
+ import Enquirer from "enquirer";
4
+ import { AppError } from "../error.js";
5
+ import { logger } from "../utils/logger.js";
6
+ import veloAPI from 'velo-sync/dist/velo/velo-api.js';
7
+
8
+ export const is_alive = Effect.gen(function* (_) {
9
+ const config = yield* Config;
10
+ const prompter = new Enquirer();
11
+ const veloSyncSettings = config.config.veloSyncSettings;
12
+ if (!veloSyncSettings) return yield* Effect.fail(new AppError({ message: 'Velo-sync settings not found', cause: new Error('Velo-sync settings not found') }));
13
+
14
+ logger.action(`Checking if the API for site ${veloSyncSettings.siteUrl} is alive...`);
15
+
16
+ const res = yield* Effect.tryPromise({
17
+ try: () => veloAPI.isAlive(veloSyncSettings),
18
+ catch: (e) => {
19
+ return new AppError({ cause: e, message: 'Error checking if the API is alive' });
20
+ }
21
+ })
22
+
23
+ logger.success(`API for site ${veloSyncSettings.siteUrl} is alive and working!`);
24
+ return
25
+ })
@@ -0,0 +1,23 @@
1
+ import { Effect, Schema } from "effect/index";
2
+ import { Config } from "../config.js";
3
+ import { AppError } from "../error.js";
4
+ import { logger } from "../utils/logger.js";
5
+ import { migrateFileCacheTask } from "./client.js";
6
+
7
+ export const migrate = Effect.gen(function* (_) {
8
+ const config = yield* Config;
9
+ const veloSyncSettings = config.config.veloSyncSettings;
10
+ if (!veloSyncSettings) return yield* Effect.fail(new AppError({ message: 'Velo-sync settings not found', cause: new Error('Velo-sync settings not found') }));
11
+
12
+ logger.action(`Migrating file cache for site ${veloSyncSettings.siteUrl}...`);
13
+
14
+ const res = yield* Effect.tryPromise({
15
+ try: () => migrateFileCacheTask(),
16
+ catch: (e) => {
17
+ return new AppError({ cause: e, message: 'Error migrating file cache' });
18
+ }
19
+ })
20
+
21
+ logger.success(`File cache for site ${veloSyncSettings.siteUrl} migrated successfully!`);
22
+ return
23
+ })
@@ -0,0 +1,27 @@
1
+ import { Effect, Schema } from "effect/index";
2
+ import { Config } from "../config.js";
3
+ import { AppError } from "../error.js";
4
+ import { logger } from "../utils/logger.js";
5
+ import { runSyncTask } from "./client.js";
6
+
7
+ export const sync = Effect.gen(function* (_) {
8
+ const config = yield* Config;
9
+ const veloSyncSettings = config.config.veloSyncSettings;
10
+ if (!veloSyncSettings) return yield* Effect.fail(new AppError({ message: 'Velo-sync settings not found', cause: new Error('Velo-sync settings not found') }));
11
+
12
+ logger.action(`Syncing data for site ${veloSyncSettings.siteUrl}...`);
13
+ let filename = config.config.veloSyncArguments?.data || '';
14
+ let collection = config.config.veloSyncArguments?.collection || '';
15
+ let schema = config.config.veloSyncArguments?.schema || '';
16
+ let dryrun = config.config.veloSyncArguments?.dry || false;
17
+ let importOnly = false
18
+ const res = yield* Effect.tryPromise({
19
+ try: () => runSyncTask(filename, collection, schema, importOnly, dryrun),
20
+ catch: (e) => {
21
+ return new AppError({ cause: e, message: 'Error syncing data' });
22
+ }
23
+ })
24
+
25
+ logger.success(`Data for site ${veloSyncSettings.siteUrl} synced successfully!`);
26
+ return
27
+ })
File without changes