lucy-cli 1.2.5 → 2.0.0-alpha.1

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 (171) hide show
  1. package/dist/args.d.ts +7 -0
  2. package/dist/args.js +23 -0
  3. package/dist/commands.d.ts +3 -0
  4. package/dist/commands.js +18 -0
  5. package/dist/config.d.ts +20 -0
  6. package/dist/config.js +39 -0
  7. package/dist/error.d.ts +17 -0
  8. package/dist/error.js +5 -0
  9. package/dist/helpers.d.ts +1 -32
  10. package/dist/helpers.js +6 -261
  11. package/dist/index.d.ts +2 -59
  12. package/dist/index.js +25 -282
  13. package/dist/init.d.ts +4 -8
  14. package/dist/init.js +245 -160
  15. package/dist/params.d.ts +7 -0
  16. package/dist/params.js +23 -0
  17. package/dist/policy.d.ts +3 -0
  18. package/dist/policy.js +5 -0
  19. package/dist/prepare.d.ts +0 -8
  20. package/dist/prepare.js +20 -19
  21. package/dist/runtime.d.ts +5 -0
  22. package/dist/runtime.js +11 -0
  23. package/dist/schemas/index.d.ts +2 -0
  24. package/dist/schemas/index.js +2 -0
  25. package/dist/schemas/types.js +1 -0
  26. package/dist/states.d.ts +10 -0
  27. package/dist/states.js +7 -0
  28. package/files/expo/.env +1 -0
  29. package/files/expo/.nvmrc +1 -0
  30. package/files/expo/.prettierignore +23 -0
  31. package/files/expo/.prettierrc.json +16 -0
  32. package/files/expo/.yarnrc +1 -0
  33. package/files/expo/.yarnrc.yml +3 -0
  34. package/files/expo/app/(tabs)/_layout.tsx +45 -0
  35. package/files/expo/app/_layout.tsx +45 -0
  36. package/files/expo/babel.config.js +9 -0
  37. package/files/expo/constants/Colors.ts +27 -0
  38. package/files/expo/constants/theme.ts +18 -0
  39. package/files/expo/eas.json +26 -0
  40. package/files/expo/eslint.config.js +185 -0
  41. package/files/expo/global.css +47 -0
  42. package/files/expo/hooks/useColorScheme.ts +11 -0
  43. package/files/expo/hooks/useColorScheme.web.ts +21 -0
  44. package/files/expo/hooks/useColorSchemeRN.ts +1 -0
  45. package/files/expo/hooks/useThemeColor.ts +21 -0
  46. package/files/expo/lib/data.ts +45 -0
  47. package/files/expo/lib/utils/index.ts +6 -0
  48. package/files/expo/lib/utils/polyfills.ts +29 -0
  49. package/files/expo/lib/wix/client.ts +14 -0
  50. package/files/expo/lib/wix/index.ts +1 -0
  51. package/files/expo/lucy.json +8 -0
  52. package/files/expo/readme.md +45 -0
  53. package/files/expo/tailwind.config.js +198 -0
  54. package/files/expo/tsconfig.json +40 -0
  55. package/files/expo/types/nativewind-env.d.ts +1 -0
  56. package/files/expo/types/reset.d.ts +1 -0
  57. package/files/velo/typescript/styles/global.scss +0 -0
  58. package/package.json +14 -11
  59. package/src/args.ts +36 -0
  60. package/src/commands.ts +21 -0
  61. package/src/config.ts +61 -0
  62. package/src/error.ts +4 -0
  63. package/src/helpers.ts +7 -305
  64. package/src/index.ts +29 -369
  65. package/src/init.ts +345 -177
  66. package/src/policy.ts +6 -0
  67. package/src/prepare.ts +19 -19
  68. package/src/runtime.ts +20 -0
  69. package/src/schemas/index.ts +3 -0
  70. package/src/schemas/types.ts +0 -0
  71. package/src/states.ts +15 -0
  72. package/src copy/helpers.ts +307 -0
  73. package/src copy/index.ts +379 -0
  74. package/src copy/init.ts +183 -0
  75. package/src copy/models.ts +35 -0
  76. package/src copy/prepare.ts +24 -0
  77. package/src copy/schemas/index.ts +0 -0
  78. package/src copy/schemas/types.ts +0 -0
  79. package/src copy/settings.json +67 -0
  80. package/src copy/types.d.ts +8 -0
  81. package/dist/Gulpfile.d.ts +0 -34
  82. package/dist/Gulpfile.js +0 -115
  83. package/dist/cli.d.ts +0 -2
  84. package/dist/cli.js +0 -44
  85. package/dist/dev.d.ts +0 -2
  86. package/dist/dev.js +0 -14
  87. package/dist/gulp/backend copy.d.ts +0 -4
  88. package/dist/gulp/backend copy.js +0 -50
  89. package/dist/gulp/backend.d.ts +0 -3
  90. package/dist/gulp/backend.js +0 -91
  91. package/dist/gulp/checks.d.ts +0 -3
  92. package/dist/gulp/checks.js +0 -204
  93. package/dist/gulp/clean copy.d.ts +0 -2
  94. package/dist/gulp/clean copy.js +0 -19
  95. package/dist/gulp/clean.d.ts +0 -3
  96. package/dist/gulp/clean.js +0 -28
  97. package/dist/gulp/copy.d.ts +0 -2
  98. package/dist/gulp/copy.js +0 -33
  99. package/dist/gulp/docs.d.ts +0 -2
  100. package/dist/gulp/docs.js +0 -27
  101. package/dist/gulp/helpers.d.ts +0 -2
  102. package/dist/gulp/helpers.js +0 -24
  103. package/dist/gulp/pages copy.d.ts +0 -3
  104. package/dist/gulp/pages copy.js +0 -22
  105. package/dist/gulp/pages.d.ts +0 -2
  106. package/dist/gulp/pages.js +0 -36
  107. package/dist/gulp/pipeline.d.ts +0 -1
  108. package/dist/gulp/pipeline.js +0 -28
  109. package/dist/gulp/public.d.ts +0 -2
  110. package/dist/gulp/public.js +0 -49
  111. package/dist/gulp/styles.d.ts +0 -2
  112. package/dist/gulp/styles.js +0 -39
  113. package/dist/gulp/templates.d.ts +0 -2
  114. package/dist/gulp/templates.js +0 -32
  115. package/dist/gulp/test.d.ts +0 -2
  116. package/dist/gulp/test.js +0 -26
  117. package/dist/gulp/types.d.ts +0 -4
  118. package/dist/gulp/types.js +0 -288
  119. package/dist/gulp/watchers.d.ts +0 -9
  120. package/dist/gulp/watchers.js +0 -58
  121. package/dist/init copy.d.ts +0 -8
  122. package/dist/init copy.js +0 -167
  123. package/dist/install.d.ts +0 -2
  124. package/dist/install.js +0 -53
  125. package/dist/settings.json +0 -67
  126. package/dist/start_gulp.d.ts +0 -2
  127. package/dist/start_gulp.js +0 -14
  128. package/dist/sync.d.ts +0 -2
  129. package/dist/sync.js +0 -87
  130. /package/{files/.gitmodules → dist/schemas/types.d.ts} +0 -0
  131. /package/files/{typescript/__mocks__/.gitkeep → velo/.gitmodules} +0 -0
  132. /package/files/{.madgerc → velo/.madgerc} +0 -0
  133. /package/files/{.nvmrc → velo/.nvmrc} +0 -0
  134. /package/files/{.stylelintrc.js → velo/.stylelintrc.js} +0 -0
  135. /package/files/{.yarnrc.yml → velo/.yarnrc.yml} +0 -0
  136. /package/files/{currents.config.js → velo/currents.config.js} +0 -0
  137. /package/files/{cypress → velo/cypress}/e2e/base/base.cy.ts +0 -0
  138. /package/files/{cypress → velo/cypress}/fixtures/example.json +0 -0
  139. /package/files/{cypress → velo/cypress}/support/commands.ts +0 -0
  140. /package/files/{cypress → velo/cypress}/support/e2e.ts +0 -0
  141. /package/files/{cypress → velo/cypress}/tsconfig.json +0 -0
  142. /package/files/{cypress.config.mjs → velo/cypress.config.mjs} +0 -0
  143. /package/files/{eslint.config.mjs → velo/eslint.config.mjs} +0 -0
  144. /package/files/{local.tsconfig.json → velo/local.tsconfig.json} +0 -0
  145. /package/files/{typedoc.json → velo/typedoc.json} +0 -0
  146. /package/files/{typescript/pages → velo/typescript/__mocks__}/.gitkeep +0 -0
  147. /package/files/{typescript → velo/typescript}/backend/data.ts +0 -0
  148. /package/files/{typescript → velo/typescript}/backend/events.ts +0 -0
  149. /package/files/{typescript → velo/typescript}/backend/http-functions.ts +0 -0
  150. /package/files/{typescript → velo/typescript}/backend/lib/http-functions/sync.ts +0 -0
  151. /package/files/{typescript → velo/typescript}/backend/permissions.json +0 -0
  152. /package/files/{typescript/public → velo/typescript/pages}/.gitkeep +0 -0
  153. /package/files/{typescript/styles → velo/typescript/public}/.gitkeep +0 -0
  154. /package/files/{typescript → velo/typescript}/public/scss/app.scss +0 -0
  155. /package/files/{typescript/styles/global.scss → velo/typescript/styles/.gitkeep} +0 -0
  156. /package/files/{typescript → velo/typescript}/tsconfig.json +0 -0
  157. /package/files/{vitest.config.ts → velo/vitest.config.ts} +0 -0
  158. /package/{src → src copy}/Gulpfile.ts +0 -0
  159. /package/{src → src copy}/gulp/backend.ts +0 -0
  160. /package/{src → src copy}/gulp/checks.ts +0 -0
  161. /package/{src → src copy}/gulp/clean.ts +0 -0
  162. /package/{src → src copy}/gulp/copy.ts +0 -0
  163. /package/{src → src copy}/gulp/helpers.ts +0 -0
  164. /package/{src → src copy}/gulp/pages.ts +0 -0
  165. /package/{src → src copy}/gulp/pipeline.ts +0 -0
  166. /package/{src → src copy}/gulp/public.ts +0 -0
  167. /package/{src → src copy}/gulp/styles.ts +0 -0
  168. /package/{src → src copy}/gulp/templates.ts +0 -0
  169. /package/{src → src copy}/gulp/types.ts +0 -0
  170. /package/{src → src copy}/gulp/watchers.ts +0 -0
  171. /package/{src → src copy}/sync.ts +0 -0
package/src/index.ts CHANGED
@@ -1,376 +1,36 @@
1
- #!/usr/bin/env node --no-warnings
2
- import { dirname } from 'path';
3
- import { fileURLToPath } from 'url';
4
- import { existsSync } from 'fs';
5
- import chalk from 'chalk';
6
- import settings from './settings.json' with { type: "json" };;
7
- import projectPackageJSON from '../package.json' with { type: "json" };;
8
-
9
- import { join } from 'path';
10
- import fs from 'fs/promises';
11
-
12
- import { init } from './init.js';
13
- import { sync } from './sync.js';
14
- import { runGulp, installPackages, killAllProcesses, cleanupWatchers, createTemplateFolder, updateLucyConfigFromPackageJson } from './helpers.js';
15
- import { prepare } from './prepare.js';
16
- import { spawn, spawnSync } from 'child_process';
17
- import os from 'os';
18
-
19
- export type ModulesSettings = {
20
- packageRoot: string;
21
- targetFolder: string;
22
- args: string[];
23
- settings: LucySettings;
24
- }
25
- export type LucySettings = {
26
- modules: {
27
- [libName: string]: {
28
- url: string;
29
- branch: string;
30
- path?: string;
31
- noCompile?: boolean;
32
- };
33
- };
34
- wixSettings: {
35
- compilerOptions: {
36
- composite: boolean;
37
- noEmit: boolean;
38
- lib: string[];
39
- jsx: string;
40
- };
41
- exclude: string[];
42
- };
43
- initialized: boolean;
44
- wixPackages: {
45
- [packageName: string]: string;
46
- };
47
- devPackages: {
48
- [packageName: string]: string;
49
- };
50
- scripts: {
51
- [commandName: string]: string;
52
- };
53
- };
54
-
55
- export type ModuleSettings = {
56
- packageRoot: string;
57
- targetFolder: string;
58
- args: string[];
59
- wixConfigPath: string;
60
- lucyConfigPath: string;
61
- packageJsonPath: string;
62
- settings: LucySettings;
63
- lockVersion: boolean;
64
- force: boolean;
65
- veloConfigName: string;
66
- }
67
-
68
- export type ProjectSettings = {
69
- // packages?: Record<string, string>;
70
- modules?: Record<string, string>;
71
- lucySettings?: LucySettings;
72
- packageJSON?: Record<string, any>;
73
- }
74
-
75
- export const orange = chalk.hex('#FFA500');
76
- export const blue = chalk.blueBright;
77
- export const green = chalk.greenBright;
78
- export const red = chalk.redBright;
79
- export const yellow = chalk.yellow;
80
- export const magenta = chalk.magentaBright;
81
-
82
- // eslint-disable-next-line @typescript-eslint/naming-convention
83
- const __filename = fileURLToPath(import.meta.url);
84
- // eslint-disable-next-line @typescript-eslint/naming-convention
85
- const __dirname = dirname(__filename);
86
-
87
- // const cwd = process.cwd();
88
- // const command = `watchman watch-del '${cwd}'`;
89
- // killAllProcesses('@wix/cli/bin/wix.cjs'); // Matches processes running the Wix CLI
90
- // killAllProcesses('wix:dev');
91
-
92
-
93
- process.on('exit', (code) => {
94
- killAllProcesses('@wix/cli/bin/wix.cjs'); // Matches processes running the Wix CLI
95
- killAllProcesses('wix:dev');
96
- cleanupWatchers();
97
- console.log(`🚪 ${magenta.underline('Process exiting with code:')} ${orange(code)}`);
98
- });
99
-
100
- process.on('SIGINT', () => {
101
- console.log(`🐕 ${green.underline('Received Ctrl+C (SIGINT), cleaning up...')}`);
102
- killAllProcesses('@wix/cli/bin/wix.cjs'); // Matches processes running the Wix CLI
103
- killAllProcesses('wix:dev');
104
- cleanupWatchers();
105
- process.exit(); // Exit explicitly after handling
106
- });
107
-
108
- process.on('SIGTERM', () => {
109
- console.log(`🛑 ${red.underline('Received termination signal (SIGTERM), cleaning up...')}`);
110
- killAllProcesses('@wix/cli/bin/wix.cjs'); // Matches processes running the Wix CLI
111
- killAllProcesses('wix:dev');
112
- cleanupWatchers();
113
- process.exit(); // Exit explicitly after handling
114
- });
115
-
116
- process.on('uncaughtException', (error) => {
117
- console.error(`💥 ${red.underline('Uncaught Exception:')}`, error);
118
- killAllProcesses('@wix/cli/bin/wix.cjs'); // Matches processes running the Wix CLI
119
- killAllProcesses('wix:dev');
120
- cleanupWatchers();
121
- process.exit(1); // Exit with an error code
122
- });
123
-
124
- process.on('unhandledRejection', (reason, promise) => {
125
- console.error(`🚨 ${yellow.underline('Unhandled Rejection at:')} ${orange(promise)}`);
126
- console.error(`🚨 ${red.underline('Reason:')} ${reason}`); cleanupWatchers();
127
- killAllProcesses('@wix/cli/bin/wix.cjs'); // Matches processes running the Wix CLI
128
- killAllProcesses('wix:dev');
129
- cleanupWatchers();
130
- process.exit(1); // Exit with an error code
131
- });
132
-
133
- /**
134
- * Main function
135
- * @returns {Promise<void>}
136
- */
137
- async function main(): Promise<void> {
138
- // INFO: Module settings
139
- const moduleSettings: ModuleSettings = {
140
- packageRoot: dirname(__dirname),
141
- targetFolder: process.cwd(),
142
- args: process.argv.slice(2),
143
- settings,
144
- wixConfigPath: join(process.cwd(), 'wix.config.json'),
145
- lucyConfigPath: join(process.cwd(), 'lucy.json'),
146
- packageJsonPath: join(process.cwd(), 'package.json'),
147
- force: false,
148
- lockVersion: false,
149
- veloConfigName: 'config.json'
150
- }
151
-
152
- let projectSettings: ProjectSettings = {};
153
-
154
- if(moduleSettings.args.includes('version') || moduleSettings.args.includes('-v')){
155
- console.log("🐾" + blue.bold(` => ${projectPackageJSON.version}`));
156
-
157
- return;
158
- }
159
-
160
- if (moduleSettings.args.includes('templates')) {
161
- const templatesPath = join(os.homedir(), '.lucy-cli');
162
- if (!existsSync(templatesPath)) {
163
- console.log((`💩 ${red.underline.bold("=> Lucy templates folder not found at =>")} ${orange(templatesPath)}`));
164
- console.log(chalk.yellow('🐕 Creating templates folder with default template...'));
165
- await createTemplateFolder(moduleSettings);
1
+ #!/usr/bin/env node
2
+ import { Chunk, Duration, Effect, pipe, Schedule, Array, Ref } from "effect";
3
+ import { build_runtime } from "./runtime.js";
4
+ import { get_args } from "./args.js";
5
+ import 'dotenv/config'
6
+ import { Config } from "./config.js";
7
+ import { ServiceInspectState } from "./states.js";
8
+ import { init } from "./init.js";
9
+
10
+
11
+ const lucyCLI = pipe(
12
+ Effect.gen(function* (_) {
13
+ const config = yield* Config;
14
+ config.config.action.type;
15
+ if (config.config.action.type === undefined) {
16
+ return yield* Effect.fail("No Params Provided");
166
17
  }
167
-
168
- console.log(`🐕 ${blue.underline('Opening templates folder at:')} ${orange(templatesPath)}`);
169
-
170
- let command: string;
171
- switch (process.platform) {
172
- case 'darwin': command = 'open'; break;
173
- case 'win32': command = 'start'; break;
174
- default: command = 'xdg-open'; break;
18
+ if (config.config.action.action === 'init') {
19
+ return yield* init();
175
20
  }
176
-
177
- const child = spawn(command, [templatesPath], { detached: true, stdio: 'ignore' });
178
- child.on('error', (err) => {
179
- console.error(`💩 ${red.underline.bold('Failed to open folder:')} ${orange(err.message)}`);
180
- });
181
- child.unref();
182
- return;
183
- }
184
-
185
-
186
- // Run velo sync
187
- if(moduleSettings.args.includes('velo-sync')){
188
- await sync(moduleSettings, projectSettings);
189
-
190
- return;
191
- }
192
-
193
- if(moduleSettings.args.includes('help') || moduleSettings.args.includes('-h')){
194
- console.log("🦮 " + green.underline.bold(' => Lucy CLI Help'));
195
- console.log("Usage: lucy-cli <command> [options]");
196
- console.log("\nCommands:");
197
- console.log("🦮 " + magenta.bold('init') + " : Initializes caontaining a WIX project to enable full TS support");
198
- console.log("🦮 " + magenta.bold('dev') + " : Starts the development environment. This includes setting up any required services for local development.");
199
- console.log("🦮 " + magenta.bold('build-prod') + " : Builds the project in production mode, optimizing files for deployment.");
200
- console.log("🦮 " + magenta.bold('prepare') + " : Prepares the project by installing packages & initializing git modules, configured in lucy.json");
201
- console.log("🦮 " + magenta.bold('velo-sync') + " : Synchronizes wix collections(velo-sync -h for help)");
202
- console.log("🦮 " + magenta.bold('install') + " : Installs all Wix npm packages listed in the 'lucy.json' file in the project directory.");
203
- console.log("🦮 " + magenta.bold('fix') + " : Runs a fix command to resolve common issues in development or production settings.");
204
- console.log("🦮 " + magenta.bold('docs') + " : Generates documentation for the project.");
205
- console.log("🦮 " + magenta.bold('cypress') + " : Starts the cypress test runner.");
206
- console.log("🦮 " + magenta.bold('templates') + " : Opens the Lucy CLI templates folder.");
207
- console.log("🦮 " + magenta.bold('sync-pkgs') + " : Syncs dependencies from package.json to lucy.json.");
208
- console.log("🦮 " + magenta.bold('e2e') + " : Starts the cypress test runner in CI mode. first argument is the key second is the build id <e2e <somekey <someID>");
209
- console.log("\nOptions:");
210
- console.log("🦮 " + magenta.bold('-h, help') + " : Displays this help message.");
211
- console.log("🦮 " + magenta.bold('-v, version') + " : Displays the current version of Lucy CLI as defined in the project’s package.json.");
212
- console.log("🦮 " + magenta.bold('-f, force') + " : Forces specific commands to execute even if they may lead to potential issues.");
213
- console.log(" Used for functions like deleting obsolete pages or initializing missing components.");
214
- console.log("🦮 " + magenta.bold('-l') + " : Locks package versions to those specified in the configuration file lucy.json");
215
- console.log("\nExamples:");
216
- console.log("🦮 " + magenta.bold('lucy-cli init') + " : Initializes a new Wix project.");
217
- console.log("🦮 " + magenta.bold('lucy-cli dev') + " : Starts the development environment.");
218
- console.log("🦮 " + magenta.bold('lucy-cli sync') + " : Synchronizes database and settings.");
219
- console.log("🦮 " + magenta.bold('lucy-cli install') + " : Installs all Wix npm packages from 'lucy.json'.");
220
- console.log("🦮 " + magenta.bold('lucy-cli dev -f') + " : Starts the dev environment with forced settings.");
221
- console.log("🦮 " + magenta.bold('lucy-cli install -l') + " : Installs Wix npm packages, respecting locked versions specified in the configuration.");
222
-
223
- return;
224
- }
225
-
226
- if (!existsSync(moduleSettings.wixConfigPath)) {
227
- console.log((`💩 ${red.underline.bold("=> This is not a WIX project =>")} ${orange(moduleSettings.targetFolder)}`));
228
- return;
229
- }
230
-
231
- //INFO: Collect project settings
232
- if(moduleSettings.args.includes('-f')) moduleSettings.force = true;
233
- if(moduleSettings.args.includes('-l')) moduleSettings.lockVersion = true;
234
-
235
- if(existsSync(moduleSettings.packageJsonPath)) {
236
- const packageJSONraw = await fs.readFile(join(moduleSettings.packageJsonPath), 'utf8');
237
- try {
238
- projectSettings.packageJSON = JSON.parse(packageJSONraw);
239
- if(moduleSettings.force) {
240
- console.log("❗️" + red.underline(' => Forcing'));
241
- moduleSettings.force = true;
242
- }
243
- } catch (parseError) {
244
- console.log((`💩 ${red.underline.bold("=> Error parsing package.json =>")} ${orange(parseError)}`));
245
- return;
246
- }
247
- }
248
-
249
- if(existsSync(moduleSettings.lucyConfigPath)) {
250
- try {
251
- const data = await fs.readFile(moduleSettings.lucyConfigPath, 'utf8');
252
- projectSettings.lucySettings = JSON.parse(data);
253
- } catch (parseError) {
254
- console.log((`💩 ${red.underline.bold("=> Error parsing Lucy.json =>")} ${orange(parseError)}`));
255
- }
256
- } else {
257
- if(!moduleSettings.args.includes('init')) {
258
- return console.log(yellow.underline.bold('🐶 => Project not Initialized! Please initialize using "lucy-cli init"'));
259
- };
260
- }
261
-
262
- if(!projectSettings.lucySettings?.initialized) {
263
- if(!moduleSettings.args.includes('init')) {
264
- return console.log(yellow.underline.bold('🐶 => Project not Initialized! Please initialize using "lucy-cli init"'));
265
- }
266
- }
267
-
268
- if(moduleSettings.args.includes('-l')) moduleSettings.lockVersion = true;
269
-
270
- console.log("🐕" + magenta.underline(' => Lucy CLI => RUNNING: ' + orange('Press Ctrl+C to stop.')));
271
- // INFO: Run commands
272
-
273
- if(moduleSettings.args.includes('init')){
274
- if(projectSettings.lucySettings?.initialized && !moduleSettings.force) {
275
- console.log((`💩 ${red.underline.bold("=> This project is already initialized =>")} ${orange(moduleSettings.targetFolder)}`));
276
- console.log("🐕" + magenta.underline(' => Use -f to force initialization'));
277
- return;
278
- }
279
- console.log("🐕" + magenta.underline(' => Initializing project'));
280
- init(moduleSettings, projectSettings);
281
-
282
- return;
283
- }
284
-
285
-
286
- if(moduleSettings.args.includes('docs')){
287
- const res = spawnSync('yarn docs', { shell: true, stdio: 'inherit' });
288
- if (res.error) {
289
- return console.log((`💩 ${red.underline.bold("=> Failed to Docs generated => ")} ${orange(res.error.message)}`));
290
- }
291
- return console.log("🐕" + blue.underline(` => Docs generated!`));
292
- }
293
-
294
- if(moduleSettings.args.includes('cypress')){
295
- const res = spawnSync('yarn cypress', { shell: true, stdio: 'inherit' });
296
- if (res.error) {
297
- return console.log((`💩 ${red.underline.bold("=> Failed to start cypress => ")} ${orange(res.error.message)}`));
298
- }
299
- return console.log("🐕" + blue.underline(` => Started Cypress`));
300
- }
301
-
302
- if (moduleSettings.args.includes('e2e')) {
303
- // Extract arguments
304
- const e2eIndex = moduleSettings.args.indexOf('e2e');
305
- const key = moduleSettings.args[e2eIndex + 1];
306
- const buildId = moduleSettings.args[e2eIndex + 2];
307
-
308
- // Validate that both arguments are provided
309
- if (!key && !buildId) {
310
- console.log(`💩 ${red.underline.bold("=> Missing required arguments:")} ${orange("key")} and ${orange("build ID")}`);
311
- process.exit(1);
312
- }
313
-
314
- // Run Cypress with the provided arguments
315
- const res = spawnSync(`yarn e2e --key ${key} --ci-build-id ${buildId}`, { shell: true, stdio: 'inherit' });
316
- if (res.error) {
317
- console.log(`💩 ${red.underline.bold("=> Failed to start Cypress =>")} ${orange(res.error.message)}`);
318
- process.exit(1);
319
- }
320
- return console.log("🐕 " + blue.underline(`=> Started Cypress successfully`));
321
- }
322
-
323
- if(moduleSettings.args.includes('prepare')){
324
- await prepare( moduleSettings, projectSettings);
325
-
326
- return;
327
- }
328
-
329
- if(moduleSettings.args.includes('install')){
330
- if(!projectSettings.lucySettings?.initialized) {
331
- console.log((`💩 ${red.underline.bold("=> This project is not initialized =>")} ${orange(moduleSettings.targetFolder)}`));
332
- console.log("🐕" + magenta.underline(' => Use init to initialize'));
333
- return;
334
- }
335
- await installPackages(projectSettings.lucySettings.wixPackages, projectSettings.lucySettings.devPackages, moduleSettings.targetFolder, moduleSettings.lockVersion);
336
-
337
- return;
338
- }
339
-
340
-
341
- if(moduleSettings.args.includes('dev')){
342
- runGulp(moduleSettings, projectSettings, 'dev');
343
-
344
- return;
345
- }
346
- if(moduleSettings.args.includes('build-prod')){
347
- runGulp(moduleSettings, projectSettings, 'build-prod');
348
-
349
- return;
350
- }
351
- if(moduleSettings.args.includes('fix')){
352
- runGulp(moduleSettings, projectSettings, 'fix-wix');
353
-
354
- return;
355
- }
356
21
 
357
- if(moduleSettings.args.includes('sync-pkgs')){
358
- console.log("🐕" + magenta.underline(' => Syncing package.json with lucy.json'));
359
- if (!existsSync(moduleSettings.packageJsonPath)) {
360
- console.log((`💩 ${red.underline.bold("=> package.json not found at =>")} ${orange(moduleSettings.packageJsonPath)}`));
361
- return;
362
- }
363
- if (!existsSync(moduleSettings.lucyConfigPath)) {
364
- console.log((`💩 ${red.underline.bold("=> lucy.json not found at =>")} ${orange(moduleSettings.lucyConfigPath)}`));
365
- return;
366
- }
367
- await updateLucyConfigFromPackageJson(moduleSettings.packageJsonPath, moduleSettings.lucyConfigPath);
368
- return;
369
- }
370
22
 
23
+ }),
24
+ )
371
25
 
372
- console.log("🐕" + blue.underline.bold(' => Running dev'));
373
- runGulp(moduleSettings, projectSettings, 'dev');
26
+ async function main() {
27
+ const args = await get_args();
28
+ const runtime= build_runtime(args);
29
+ // The runtime will handle logging failures. This will catch unhandled defects.
30
+ await runtime.runPromise(lucyCLI)
374
31
  }
375
32
 
376
- main();
33
+ main().catch((error) => {
34
+ console.error("An unexpected application error occurred:", error);
35
+ process.exit(1);
36
+ });