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
package/src/config.ts CHANGED
@@ -1,12 +1,13 @@
1
- import { Context, Layer, Schema } from "effect"
1
+ import { Context, Effect, Layer, Schema } from "effect"
2
2
  import { get_args } from "./args.js";
3
3
  import { dirname, join } from "path";
4
4
  import { fileURLToPath } from "url";
5
- import { readFileSync, existsSync } from "fs";
6
5
  import { lucySettings, LucySettings } from "./schemas/lucy.js";
7
- import { logger } from "./utils/logger.js";
8
6
  import os from 'os';
9
- import { Action, Actions } from "./schemas/types.js";
7
+ import { Actions } from "./schemas/types.js";
8
+ import { JsonSchema, veloSyncSettings, VeloSyncSettings, WixSDKSettings, wixSDKSettings } from "./schemas/index.js";
9
+ import { FileSystem, Path } from "@effect/platform"
10
+ import { NodeContext } from "@effect/platform-node/index";
10
11
 
11
12
  export class Config extends Context.Tag("Config")<
12
13
  Config,
@@ -17,6 +18,12 @@ export class Config extends Context.Tag("Config")<
17
18
  readonly cwd: string;
18
19
  readonly packageRoot: string;
19
20
  readonly filesFolder: string;
21
+ readonly veloSyncArguments?:{
22
+ data?: string;
23
+ collection?: string;
24
+ schema?: string;
25
+ dry: boolean;
26
+ }
20
27
  packageJson: any;
21
28
  lucySettings: LucySettings;
22
29
  readonly lucyHome: string;
@@ -24,78 +31,112 @@ export class Config extends Context.Tag("Config")<
24
31
  templateFiles: string;
25
32
  projectName: string;
26
33
  defaultModuleBasePath: string;
34
+ veloSyncSettings?: VeloSyncSettings;
35
+ wixSDKSettings?: WixSDKSettings;
27
36
  }
28
37
  }
29
38
  >() {}
30
39
 
31
- // or, if you want just the inner config object:
32
- export type LucyConfig = typeof Config.Service["config"];
33
-
34
40
  // In an ES module, `__dirname` is not available by default.
35
41
  // We can replicate it using `import.meta.url`.
36
42
  const __filename = fileURLToPath(import.meta.url);
37
43
  const __dirname = dirname(__filename);
38
-
39
- // Assuming your compiled output is in a 'dist' folder at the project root,
40
- // and your source `config.ts` is in `src`, the running `config.js` will be
41
- // in something like `dist/src`. To get to the package root, we go up two levels.
42
44
  const packageRoot = join(__dirname, "..");
43
45
 
46
+ export const packageJsonName = "package.json";
47
+ export const lucyJsonName = "lucy.json";
48
+ export const wixSyncJsonName = "wix-sync.json";
49
+ export const wixSDKSettingsJsonName = "wix-sdk-settings.json";
50
+ export const syncDataName = 'sync-data';
51
+ export const packageJsonPath = join(process.cwd(), packageJsonName);
52
+ export const lucyJsonPath = join(process.cwd(), lucyJsonName);
53
+ export const veloSyncJsonPath = join(process.cwd(), wixSyncJsonName);
54
+ export const wixSDKSettingsJsonPath = join(process.cwd(), wixSDKSettingsJsonName);
55
+ export const syncFilesSource= join(packageRoot, 'files', syncDataName);
56
+
57
+
44
58
  export const ConfigLayer = (args: Awaited<ReturnType<typeof get_args>>) => {
45
- let packageJson = '{}';
46
- let lucyJson: LucySettings | undefined = undefined;
47
- const packageJsonPath = join(process.cwd(), 'package.json');
48
- const lucyJsonPath = join(process.cwd(), 'lucy.json');
49
- try {
50
- if (existsSync(packageJsonPath)) {
51
- const raw = readFileSync(packageJsonPath, 'utf-8');
52
- packageJson = JSON.parse(raw);
53
- }
54
- } catch (error) {
55
- logger.error("Error reading package.json:", error);
56
- }
57
- try {
58
- if (existsSync(lucyJsonPath)) {
59
- const raw = readFileSync(lucyJsonPath, 'utf-8');
60
- lucyJson = Schema.decodeUnknownSync(lucySettings)(JSON.parse(raw));
61
- }
62
- } catch (error) {
63
- logger.error("Error reading lucy.json:", error);
64
- }
65
- const defaultModulePath = () => {
66
- if (args.type === 'monorepo') {
67
- return join('packages');
68
- }
69
- return '';
70
- }
71
- return Layer.succeed(
59
+ return Layer.effect(
72
60
  Config,
73
- Config.of({
74
- config: {
75
- action: {
76
- type: args.type,
77
- action: args._[0],
78
- task: args.task,
79
- },
80
- force: args.force === true ? true : false,
81
- cwd: process.cwd(),
82
- projectName: process.cwd().split('/').pop() || 'lucy-project',
83
- packageRoot: packageRoot,
84
- filesFolder: join(packageRoot, 'files'),
85
- packageJson,
86
- lucyHome: join(os.homedir(), '.lucy-cli'),
87
- lucySettings: lucyJson || {
88
- modules: {},
89
- devDependencies: {},
90
- dependencies: {},
91
- scripts: {},
92
- initialized: false,
93
- type: args.type || 'velo',
94
- },
95
- templateFiles: '',
96
- templateDir: '',
97
- defaultModuleBasePath: defaultModulePath(),
61
+ Effect.gen(function* () {
62
+ const fs = yield* FileSystem.FileSystem;
63
+ const path = yield* Path.Path;
64
+
65
+ let packageJson: any = {};
66
+ let lucyJson: LucySettings | undefined = undefined;
67
+ let veloSyncJson: VeloSyncSettings | undefined = undefined;
68
+ let wixSDKSettingsJson: WixSDKSettings | undefined = undefined;
69
+ // Read package.json
70
+ if (yield* fs.exists(packageJsonPath)) {
71
+ const raw = yield* fs.readFileString(packageJsonPath, 'utf-8');
72
+ packageJson = yield* Schema.decodeUnknown(JsonSchema)(raw);
73
+ }
74
+
75
+ // Read lucy.json
76
+ if (yield* fs.exists(lucyJsonPath)) {
77
+ const raw = yield* fs.readFileString(lucyJsonPath, 'utf-8');
78
+ const lucyJsonRaw = yield* Schema.decodeUnknown(JsonSchema)(raw);
79
+ lucyJson = yield* Schema.decodeUnknown(lucySettings)(lucyJsonRaw);
80
+ }
81
+
82
+ // Read wix-sync.json
83
+ if (yield* fs.exists(veloSyncJsonPath)) {
84
+ const raw = yield* fs.readFileString(veloSyncJsonPath, 'utf-8');
85
+ const veloSyncSettingsRaw = yield* Schema.decodeUnknown(JsonSchema)(raw);
86
+ veloSyncJson = yield* Schema.decodeUnknown(veloSyncSettings)(veloSyncSettingsRaw);
98
87
  }
99
- })
88
+
89
+ // Read wix-sdk-settings.json
90
+ if (yield* fs.exists(wixSDKSettingsJsonPath)) {
91
+ const raw = yield* fs.readFileString(wixSDKSettingsJsonPath, 'utf-8');
92
+ const wixSDKSettingsRaw = yield* Schema.decodeUnknown(JsonSchema)(raw);
93
+ wixSDKSettingsJson = yield* Schema.decodeUnknown(wixSDKSettings)(wixSDKSettingsRaw);
94
+ }
95
+
96
+ const defaultModulePath = () => {
97
+ if (args.type === 'monorepo') {
98
+ return join('packages');
99
+ }
100
+ return '';
101
+ };
102
+
103
+ return Config.of({
104
+ config: {
105
+ action: {
106
+ initType: args.initType,
107
+ action: args._[0],
108
+ tasksName: args.tasksName,
109
+ syncAction: args.syncAction,
110
+ wixSDKAction: args.wixSDKAction,
111
+ },
112
+ force: args.force === true ? true : false,
113
+ cwd: process.cwd(),
114
+ projectName: process.cwd().split('/').pop() || 'lucy-project',
115
+ packageRoot,
116
+ filesFolder: join(packageRoot, 'files'),
117
+ packageJson,
118
+ lucyHome: join(os.homedir(), '.lucy-cli'),
119
+ veloSyncSettings: veloSyncJson,
120
+ veloSyncArguments: {
121
+ data: path.join(process.cwd(), args.input || ''),
122
+ collection: args.collection,
123
+ schema: path.join(process.cwd(), args.schema || ''),
124
+ dry: args.d || false,
125
+ },
126
+ wixSDKSettings: wixSDKSettingsJson,
127
+ lucySettings: lucyJson || {
128
+ modules: {},
129
+ devDependencies: {},
130
+ dependencies: {},
131
+ scripts: {},
132
+ initialized: false,
133
+ type: args.initType || 'velo',
134
+ },
135
+ templateFiles: '',
136
+ templateDir: '',
137
+ defaultModuleBasePath: defaultModulePath(),
138
+ }
139
+ });
140
+ }).pipe(Effect.provide(NodeContext.layer))
100
141
  );
101
- }
142
+ }
package/src/helpers.ts CHANGED
@@ -1,3 +1,7 @@
1
+ import os from 'os';
2
+ import { spawnSync, exec } from 'child_process';
3
+ import { logger } from './utils/logger.js';
4
+
1
5
  export function parse_error(error: unknown): Error {
2
6
  if (error instanceof Error) {
3
7
  return error;
@@ -6,4 +10,90 @@ export function parse_error(error: unknown): Error {
6
10
  } else {
7
11
  return new Error('Unknown error');
8
12
  }
13
+ }
14
+
15
+
16
+ /**
17
+ * Kill all processes matching a specific substring in their command, with a fallback for Windows.
18
+ * @param {string} processPattern - The substring to match (e.g., "wix:dev" or "@wix/cli/bin/wix.cjs").
19
+ */
20
+ export function killAllProcesses(processPattern: string) {
21
+ const isWindows = os.platform() === 'win32';
22
+ const command = isWindows
23
+ ? `tasklist /FI "IMAGENAME eq node.exe" /FO CSV | findstr "${processPattern}"` // Adjust for Node.js processes
24
+ : `ps -eo pid,command | grep "${processPattern}" | grep -v grep`;
25
+
26
+ exec(command, (error, stdout, stderr) => {
27
+ if (error) {
28
+ logger.error(`Failed to find processes matching pattern: ${processPattern}`);
29
+ return;
30
+ }
31
+ if (stderr) {
32
+ logger.error(`Error output:')} ${stderr}`);
33
+ }
34
+ if (!stdout.trim()) {
35
+ logger.info(`No processes found matching pattern: ${processPattern}`);
36
+ return;
37
+ }
38
+
39
+ logger.info(`Found matching processes:\n${stdout}`);
40
+ const lines = stdout.trim().split('\n');
41
+ const pids = isWindows
42
+ ? lines.map(line => line.match(/"(\d+)"/)?.[1]) // Extract PID from Windows tasklist output
43
+ : lines.map(line => line.trim().split(/\s+/)[0]).filter(pid => !isNaN(Number(pid)));
44
+
45
+ pids.forEach(pid => {
46
+ if (!pid) return;
47
+ try {
48
+ const killCommand = isWindows
49
+ ? `taskkill /PID ${pid} /T /F` // Forcefully terminate the process on Windows
50
+ : `kill -SIGTERM ${pid}`;
51
+
52
+ exec(killCommand, (killError) => {
53
+ if (killError) {
54
+ logger.error(`Failed to kill process with PID ${pid}: ${killError.message}`);
55
+ } else {
56
+ logger.success(`Killed process with PID: ${pid}`);
57
+ }
58
+ });
59
+
60
+ // Schedule SIGKILL fallback for non-Windows platforms
61
+ if (!isWindows) {
62
+ setTimeout(() => {
63
+ try {
64
+ process.kill(parseInt(pid, 10), 'SIGKILL');
65
+ logger.kill(`Sent SIGKILL to process with PID: ${pid}`);
66
+ } catch (killError: any) {
67
+ if (killError.code === 'ESRCH') {
68
+ logger.info(`Process with PID ${pid} already terminated.`);
69
+ } else {
70
+ logger.error(`Failed to send SIGKILL to process with PID ${pid}: ${killError.message}`);
71
+ }
72
+ }
73
+ }, 10000);
74
+ }
75
+ } catch (err: any) {
76
+ logger.error(`Failed to kill process with PID ${pid}: ${err.message}`);
77
+ }
78
+ });
79
+ });
80
+ }
81
+
82
+ /**
83
+ * Clean up and run a command before exiting the process.
84
+ */
85
+ export function cleanupWatchers() {
86
+ logger.info(`🧹 Cleaning up Watchman watchers...`);
87
+ const cwd = process.cwd();
88
+ const command = `watchman watch-del "${cwd}"`; // Adjust for Windows paths
89
+ exec(command, (error, stdout, stderr) => {
90
+ if (error) {
91
+ logger.error(`Failed to run cleanup command: ${error.message}`);
92
+ return;
93
+ }
94
+ if (stderr) {
95
+ logger.error(`Watchman stderr: ${stderr}`);
96
+ }
97
+ logger.info(`Watchman cleanup success: ${stdout}`);
98
+ });
9
99
  }
package/src/index.ts CHANGED
@@ -1,32 +1,73 @@
1
1
  #!/usr/bin/env node
2
- import { Chunk, Duration, Effect, pipe, Schedule, Array, Ref } from "effect";
2
+ import { Effect, pipe} from "effect";
3
3
  import { build_runtime } from "./runtime.js";
4
4
  import { get_args } from "./args.js";
5
5
  import 'dotenv/config'
6
6
  import { Config } from "./config.js";
7
- import { ServiceInspectState } from "./states.js";
8
7
  import { init } from "./init/index.js";
9
8
  import { logger } from "./utils/logger.js";
10
- import { AppError } from "./error.js";
11
9
  import { open } from "./commands/exec.js";
12
- import { runTask } from "./tasks/Gulpfile.js";
13
10
  import { tasks } from "./tasks/index.js";
11
+ import { cleanupWatchers, killAllProcesses } from "./helpers.js";
12
+ import { wix_sync } from "./wix-sync/index.js";
13
+ import { wix_sdk } from "./wix-sdk/index.js";
14
+
15
+ let exitReason: 'SIGINT' | 'SIGTERM' | 'none' = 'none'
16
+ let needsCleanup = false;
17
+
18
+ export function setNeedsCleanup(value: boolean) {
19
+ needsCleanup = value;
20
+ }
21
+ process.on('exit', (code) => {
22
+ if(!needsCleanup) return;
23
+ if(exitReason === 'none') {
24
+ killAllProcesses('@wix/cli/bin/wix.cjs'); // Matches processes running the Wix CLI
25
+ killAllProcesses('wix:dev');
26
+ cleanupWatchers();
27
+ }
28
+
29
+ logger.info(`🛑 Process exited with code: ${code}`);
30
+ });
31
+
32
+ process.on('SIGINT', () => {
33
+ exitReason = "SIGINT";
34
+
35
+ logger.info(`🐕 Received Ctrl+C (SIGINT), cleaning up...`);
36
+ killAllProcesses('@wix/cli/bin/wix.cjs'); // Matches processes running the Wix CLI
37
+ killAllProcesses('wix:dev');
38
+ cleanupWatchers();
39
+ process.exit(); // Exit explicitly after handling
40
+ });
41
+
42
+ process.on('SIGTERM', () => {
43
+ exitReason = "SIGTERM";
44
+
45
+ logger.info(`🛑 Received termination signal (SIGTERM), cleaning up...`);
46
+ killAllProcesses('@wix/cli/bin/wix.cjs'); // Matches processes running the Wix CLI
47
+ killAllProcesses('wix:dev');
48
+ cleanupWatchers();
49
+ process.exit(); // Exit explicitly after handling
50
+ });
14
51
 
15
52
  const lucyCLI = pipe(
16
53
  Effect.gen(function* (_) {
17
54
  const config = yield* Config;
18
55
  const t = Config;
19
- config.config.action.type;
20
56
  if (config.config.action.action === 'init') {
21
- return yield* init();
57
+ return yield* init;
22
58
  }
23
59
  if (config.config.action.action === 'open') {
24
60
  return yield* open;
25
61
  }
26
62
  if (config.config.action.action === 'task') {
27
- return yield* tasks();
63
+ return yield* tasks;
64
+ }
65
+ if (config.config.action.action === 'wix-sync') {
66
+ return yield* wix_sync;
67
+ }
68
+ if (config.config.action.action === 'wix-sdk') {
69
+ return yield* wix_sdk;
28
70
  }
29
-
30
71
  }),
31
72
  ).pipe(
32
73
  Effect.catchTags({
@@ -66,7 +107,6 @@ main().then(() => {
66
107
  }).catch((error) => {
67
108
  if (error instanceof Error) {
68
109
  logger.error(error.message);
69
- console.debug(JSON.stringify(error, null, 2));
70
110
  }
71
111
  process.exit(1);
72
112
  });
@@ -1,5 +1,5 @@
1
1
  import { Effect, Schema } from "effect/index"
2
- import { Config } from "../config.js";
2
+ import { Config, lucyJsonName } from "../config.js";
3
3
  import { Command, FileSystem, Path } from "@effect/platform"
4
4
  import { JsonSchema } from "../schemas/index.js";
5
5
  import { logger } from "../utils/logger.js";
@@ -41,7 +41,7 @@ export const init_blocks = () => {
41
41
  }
42
42
  const files = yield * fs.readDirectory(config.config.cwd, { recursive: false });
43
43
 
44
- const allExcludes = ['.git', 'lucy.json'];
44
+ const allExcludes = ['.git', lucyJsonName];
45
45
  const filteredFiles = files.filter(file => !allExcludes.includes(file));
46
46
 
47
47
  const t = yield* fs.stat(filteredFiles[0]);
package/src/init/index.ts CHANGED
@@ -14,56 +14,50 @@ import { init_submodules } from "./gitModules.js";
14
14
  import { init_tauri } from "./tauri.js";
15
15
 
16
16
 
17
- export const init = () => {
18
- return Effect.gen(function* (_) {
19
- const config = yield* Config;
20
- if(config.config.action.type === undefined) {
21
- return yield* Effect.fail(new AppError({ message: "No action type provided", cause: new Error("No action type provided") }));
17
+ export const init = Effect.gen(function* (_) {
18
+ const config = yield* Config;
19
+ if(config.config.action.initType === undefined) {
20
+ return yield* Effect.fail(new AppError({ message: "No init type provided", cause: new Error("No init type provided") }));
21
+ }
22
+ yield* createLucyHome();
23
+ const projectName = config.config.cwd.split('/').pop() || 'expo-project';
24
+ const templateQuestion = new Enquirer();
25
+ const choice = yield* Effect.tryPromise({
26
+ try: () => templateQuestion.prompt({
27
+ type: 'input',
28
+ name: 'projectName',
29
+ message: 'Enter a project name',
30
+ initial: projectName,
31
+ validate: (value: string) => value.trim() !== '' ? true : 'Project name cannot be empty'
32
+ }),
33
+ catch: (e) => {
34
+ return new AppError({ cause: e, message: 'Error selecting template' });
22
35
  }
23
- yield* createLucyHome();
24
- const projectName = config.config.cwd.split('/').pop() || 'expo-project';
25
-
26
- const templateQuestion = new Enquirer();
27
- const choice = yield* Effect.tryPromise({
28
- try: () => templateQuestion.prompt({
29
- type: 'input',
30
- name: 'projectName',
31
- message: 'Enter a project name',
32
- initial: projectName,
33
- validate: (value: string) => value.trim() !== '' ? true : 'Project name cannot be empty'
34
- }),
35
- catch: (e) => {
36
- return new AppError({ cause: e, message: 'Error selecting template' });
37
- }
38
- })
39
- const selectedName = yield* Schema.decodeUnknown(Schema.Struct({ projectName: Schema.String }))(choice)
40
- config.config.projectName = selectedName.projectName.trim();
41
-
42
- yield* selectTemplate();
43
- yield* readLucyJsonFromTemplate;
44
-
45
- if(config.config.action.type === 'expo') {
46
- return yield* init_expo();
47
- }
48
- if(config.config.action.type === 'monorepo') {
49
- return yield* init_monorepo();
50
- }
51
- if(config.config.action.type === 'cargo') {
52
- return yield* init_cargo();
53
- }
54
- if(config.config.action.type === 'blocks') {
55
- return yield* init_blocks();
56
- }
57
- if(config.config.action.type === 'tauri') {
58
- return yield* init_tauri();
59
- }
60
- if(config.config.action.type === 'velo') {
61
- return yield* init_velo();
62
- }
63
- if(config.config.action.type === 'submodules') {
64
- return yield* init_submodules();
65
- }
66
-
67
- yield* Effect.fail(new AppError({ message: `Unsupported action type: ${config.config.action.type}`, cause: new Error(`Unsupported action type: ${config.config.action.type}`) }));
68
36
  })
69
- }
37
+ const selectedName = yield* Schema.decodeUnknown(Schema.Struct({ projectName: Schema.String }))(choice)
38
+ config.config.projectName = selectedName.projectName.trim();
39
+ yield* selectTemplate();
40
+ yield* readLucyJsonFromTemplate;
41
+ if(config.config.action.initType === 'expo') {
42
+ return yield* init_expo();
43
+ }
44
+ if(config.config.action.initType === 'monorepo') {
45
+ return yield* init_monorepo();
46
+ }
47
+ if(config.config.action.initType === 'cargo') {
48
+ return yield* init_cargo();
49
+ }
50
+ if(config.config.action.initType === 'blocks') {
51
+ return yield* init_blocks();
52
+ }
53
+ if(config.config.action.initType === 'tauri') {
54
+ return yield* init_tauri();
55
+ }
56
+ if(config.config.action.initType === 'velo') {
57
+ return yield* init_velo();
58
+ }
59
+ if(config.config.action.initType === 'submodules') {
60
+ return yield* init_submodules();
61
+ }
62
+ yield* Effect.fail(new AppError({ message: `Unsupported init type: ${config.config.action.initType}`, cause: new Error(`Unsupported init type: ${config.config.action.initType}`) }));
63
+ })
@@ -1,5 +1,5 @@
1
1
  import { Effect, Schema } from "effect/index";
2
- import { Config } from "../config.js";
2
+ import { Config, lucyJsonName, lucyJsonPath } from "../config.js";
3
3
  import { orange, red, green, logger } from "../utils/logger.js";
4
4
  import { FileSystem } from "@effect/platform"
5
5
  import path, { join } from 'path';
@@ -25,11 +25,10 @@ export const selectTemplate = () => {
25
25
  const templateChoices: string[] = [];
26
26
  for (const dirent of files) {
27
27
  if (dirent.isDirectory()) {
28
- const lucyJsonPath = join(templatesPath, dirent.name, 'lucy.json');
29
- const lucyRaw = yield* fs.readFileString(lucyJsonPath, 'utf-8');
28
+ const lucyRaw = yield* fs.readFileString(lucyJsonPath);
30
29
  const lucySettingsJSON = yield* Schema.decodeUnknown(JsonSchema)(lucyRaw);
31
30
  const lucySetting = yield* Schema.decodeUnknown(lucySettings)(lucySettingsJSON)
32
- if (lucySetting.type === config.config.action.type) {
31
+ if (lucySetting.type === config.config.action.initType) {
33
32
  templateChoices.push(dirent.name);
34
33
  }
35
34
  }
@@ -59,16 +58,16 @@ export const selectTemplate = () => {
59
58
  config.config.templateDir = templateDir;
60
59
  config.config.templateFiles = templateFilesDir;
61
60
 
62
- const templateSettingsPath = join(templateDir, 'lucy.json');
61
+ const templateSettingsPath = join(templateDir, lucyJsonName);
63
62
 
64
63
  if (!(yield* fs.exists(templateSettingsPath))) {
65
- logger.warning((`💩 ${red.underline.bold("=> Template is missing lucy.json at =>")} ${orange(templateSettingsPath)}`));
66
- yield* Effect.fail(new AppError({ message: 'Template is missing lucy.json', cause: templateSettingsPath }));
64
+ logger.warning((`💩 ${red.underline.bold(`Template is missing ${lucyJsonName} at =>`)} ${orange(templateSettingsPath)}`));
65
+ yield* Effect.fail(new AppError({ message: `Template is missing ${lucyJsonName}`, cause: templateSettingsPath }));
67
66
  }
68
- const lucySettingsRaw = yield* fs.readFileString(templateSettingsPath, 'utf-8');
67
+ const lucySettingsRaw = yield* fs.readFileString(templateSettingsPath);
69
68
  const newLucySettings = yield* Schema.decodeUnknown(lucySettings)(JSON.parse(lucySettingsRaw));
70
- if( newLucySettings.type !== config.config.action.type) return yield* Effect.fail(new AppError({
71
- message: `Template type ${newLucySettings.type} does not match action type ${config.config.action.type}`,
69
+ if( newLucySettings.type !== config.config.action.initType) return yield* Effect.fail(new AppError({
70
+ message: `Template type ${newLucySettings.type} does not match action type ${config.config.action.initType}`,
72
71
  cause: newLucySettings.type
73
72
  }));
74
73
  if(config.config.lucySettings.initialized) {
@@ -78,7 +77,7 @@ export const selectTemplate = () => {
78
77
  try: () => overwriteQuestion.prompt({
79
78
  type: 'confirm',
80
79
  name: 'overwrite',
81
- message: 'Overwrite existing lucy.json settings?',
80
+ message: `Overwrite existing ${lucyJsonName} settings?`,
82
81
  }),
83
82
  catch: (e) => {
84
83
  return new AppError({
@@ -91,7 +90,7 @@ export const selectTemplate = () => {
91
90
  if (choice.overwrite) {
92
91
  config.config.lucySettings = newLucySettings;
93
92
  } else {
94
- logger.info(`Existing lucy.json settings will be used.`);
93
+ logger.info(`Existing ${lucyJsonName} settings will be used.`);
95
94
  }
96
95
  }
97
96
  logger.success(`Selected template: ${green(selectedTemplate.template)}`);
@@ -1,23 +1,32 @@
1
1
  import { LucySettings } from "./lucy";
2
2
  import * as dartSass from 'sass';
3
3
  import gulpSass from 'gulp-sass';
4
+ import backendSettings from '../../settings/backend-settings.json' with { type: "json" };;
5
+ import masterSettings from '../../settings/master-settings.json' with { type: "json" };;
6
+ import pageSettings from '../../settings/page-settings.json' with { type: "json" };;
7
+ import publicSettings from '../../settings/public-settings.json' with { type: "json" };;
4
8
 
5
9
  const sass = gulpSass(dartSass);
6
10
 
7
- export type ModuleSettings = {
8
- packageRoot: string;
9
- targetFolder: string;
10
- wixConfigPath: string;
11
- lucyConfigPath: string;
12
- packageJsonPath: string;
13
- settings: LucySettings;
14
- force: boolean;
15
- veloConfigName: string;
11
+ export type TaskOptions = {
12
+ enableIncrementalBuild: boolean;
13
+ outputDir: string;
14
+ sass: ReturnType<typeof gulpSass>;
15
+ replaceOptions: {
16
+ logs: {
17
+ enabled: boolean;
18
+ }
19
+ };
20
+ backendSettings: typeof backendSettings,
21
+ masterSettings: typeof masterSettings,
22
+ pageSettings: typeof pageSettings,
23
+ publicSettings: typeof publicSettings,
24
+ modulesSourcePaths: string[];
25
+ cwd: string;
26
+ isWatching?: boolean;
16
27
  }
17
28
 
18
- export type ProjectSettings = {
19
- // packages?: Record<string, string>;
20
- modules?: Record<string, any>;
21
- lucySettings?: LucySettings;
22
- packageJSON?: Record<string, any>;
23
- }
29
+ export interface File {
30
+ path: string;
31
+ dirname: string;
32
+ }
@@ -1,3 +1,14 @@
1
1
  import { Schema } from "effect/index";
2
2
 
3
- export const JsonSchema = Schema.parseJson()
3
+ export const JsonSchema = Schema.parseJson()
4
+ export const veloSyncSettings = Schema.Struct({
5
+ siteUrl: Schema.String,
6
+ secret: Schema.String,
7
+ });
8
+ export type VeloSyncSettings = typeof veloSyncSettings.Type;
9
+
10
+ export const wixSDKSettings = Schema.Struct({
11
+ apiKey: Schema.String,
12
+ siteId: Schema.String,
13
+ });
14
+ export type WixSDKSettings = typeof wixSDKSettings.Type;