lucy-cli 0.6.1 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,53 @@
1
+ import chalk from 'chalk';
2
+ import { join } from 'path';
3
+ import { simpleGit } from 'simple-git';
4
+ import fs from 'fs/promises';
5
+ import { spawnSync } from 'child_process';
6
+ export async function installPackages(wixPackages, devPackages, cwd) {
7
+ const wixPackageNames = Object.keys(wixPackages);
8
+ const devPackageNames = Object.keys(devPackages);
9
+ const devPackageVersions = Object.values(devPackages);
10
+ const devPackageNamesAndVersions = devPackageNames.map((name, index) => `${name}@${devPackageVersions[index]}`);
11
+ let success = true;
12
+ wixPackageNames.forEach((name, index) => {
13
+ console.log(`🐕 => Installing ${orange(name)}`);
14
+ const wixInstall = `wix install ${name}`;
15
+ const wixres = spawnSync(wixInstall, { shell: true, stdio: 'inherit' });
16
+ if (wixres.error) {
17
+ console.log((`💩 ${red.underline.bold("=> Failed to install package =>")} ${orange(wixres.error.message)}`));
18
+ success = false;
19
+ }
20
+ else {
21
+ console.log("🐕" + blue.underline(` => Package installed!`));
22
+ }
23
+ });
24
+ const yarnAdd = `yarn add -D ${devPackageNamesAndVersions.join(' ')}`;
25
+ const yarnRes = spawnSync(yarnAdd, { shell: true, stdio: 'inherit' });
26
+ if (yarnRes.error) {
27
+ success = false;
28
+ console.log((`💩 ${red.underline.bold("=> Failed to install dev packages =>")} ${orange(yarnRes.error.message)}`));
29
+ }
30
+ if (success) {
31
+ await fs.writeFile(join(cwd, 'wixpkgs.json'), JSON.stringify(wixPackages, null, 2), 'utf8');
32
+ console.log("🐕" + blue.underline(` => All Packages installed!`));
33
+ }
34
+ else {
35
+ console.log("🐕" + red.underline(` => Some packages failed to install!`));
36
+ }
37
+ }
38
+ export async function gitInit(cwd, modules) {
39
+ const git = simpleGit({ baseDir: cwd });
40
+ for (const [name, url] of Object.entries(modules)) {
41
+ console.log(chalk.green.underline.bold(`Cloning ${name}`));
42
+ try {
43
+ await git.submoduleAdd(url, name);
44
+ }
45
+ catch (err) {
46
+ console.log((`💩 ${red.underline.bold("=> Command failed =>")} ${orange(err)}`));
47
+ }
48
+ finally {
49
+ console.log("🐕" + blue.underline(` => Cloned ${orange(name)}`));
50
+ }
51
+ }
52
+ console.log("🐶" + green.underline(' => All Modules cloned!'));
53
+ }
@@ -0,0 +1,8 @@
1
+ import { ModuleSettings, ProjectSettings } from './index.js';
2
+ /**
3
+ * Init Lucy project
4
+ * @param {string} cwd Current working directory
5
+ * @param {string} packageRoot Package root directory
6
+ * @returns {void}
7
+ */
8
+ export declare function prepare(moduleSettings: ModuleSettings, projectSettings: ProjectSettings): Promise<void>;
@@ -0,0 +1,18 @@
1
+ import chalk from 'chalk';
2
+ import { orange, red } from './index.js';
3
+ import { gitInit, installPackages } from './helpers.js';
4
+ /**
5
+ * Init Lucy project
6
+ * @param {string} cwd Current working directory
7
+ * @param {string} packageRoot Package root directory
8
+ * @returns {void}
9
+ */
10
+ export async function prepare(moduleSettings, projectSettings) {
11
+ if (projectSettings.lucySettings?.initialized) {
12
+ console.log((`💩 ${red.underline.bold("=> This project is already initialized =>")} ${orange(moduleSettings.targetFolder)}`));
13
+ return;
14
+ }
15
+ await installPackages(moduleSettings.settings.wixPackages, moduleSettings.settings.devPackages, moduleSettings.targetFolder, moduleSettings.lockVersion);
16
+ await gitInit(moduleSettings.targetFolder, projectSettings?.lucySettings?.modules ? projectSettings?.lucySettings?.modules : moduleSettings.settings.modules);
17
+ console.log(chalk.greenBright.underline('🐶 => Initialization done!'));
18
+ }
@@ -1,100 +1,29 @@
1
1
  {
2
- "modules": {
3
- "lib": "git@github.com:Integral-Systems/lucy-lib.git"
4
- },
2
+ "modules": {},
5
3
  "wixSettings": {
6
4
  "compilerOptions": {
7
5
  "composite": true,
8
6
  "noEmit": false,
9
- "lib": [
10
- "DOM"
11
- ],
12
- "jsx": "react"
7
+ "lib": [],
8
+ "jsx": "react-jsx"
13
9
  },
14
- "exclude": [
15
- "**/*.js"
16
- ]
17
- },
18
- "lucySettings": {
19
- "initialized": true
10
+ "exclude": ["**/*.js"]
20
11
  },
12
+ "initialized": false,
21
13
  "wixPackages": {
22
- "@hey-api/openapi-ts": "^0.55.3",
23
- "@hey-api/client-axios": "^0.2.10",
24
- "@js-joda/core": "5.5.3",
25
- "@js-joda/locale": "4.8.10",
26
- "@js-joda/locale_de": "4.8.10",
27
- "@js-joda/locale_en": "4.8.10",
28
- "@js-joda/locale_fr": "4.8.10",
29
- "@js-joda/locale_it": "4.8.10",
30
- "@js-joda/timezone": "2.18.0",
31
- "@react-pdf/renderer": "4.0.0",
32
- "@wix/image": "1.96.0",
33
- "@wix/velo-bind": "1.0.8",
34
- "add": "^2.0.6",
35
- "await-semaphore": "0.1.3",
36
- "axios": "1.4.0",
37
- "crypto-js": "4.1.1",
38
- "uuid": "11.0.3",
39
- "velo-sync": "^0.0.9",
40
- "@legendapp/state": "beta",
41
- "zod": "3.22.2",
42
- "react": "18.2.0",
43
- "react-dom": "18.1.0",
44
- "react-transition-group": "4.4.5",
45
- "nats": "^2.28.2",
46
- "neverthrow": "^8.1.1",
47
- "node-cache": "5.1.2",
48
- "nodemailer": "6.9.3",
49
- "i18next": "23.16.5",
50
- "eventemitter3": "5.0.1",
51
- "ffi-rs": "^1.0.98",
52
- "gsap": "3.11.4",
53
- "undici": "^6.21.0"
14
+ "@hey-api/openapi-ts": "0.55.1"
54
15
  },
55
16
  "devPackages": {
56
- "@danpercic86/helpful-decorators": "^2.4.0",
57
- "@styled/typescript-styled-plugin": "^1.0.1",
58
- "@total-typescript/ts-reset": "0.6.1",
59
- "@types/i18n": "^0.13.6",
60
- "@types/jest": "^29.5.3",
61
- "@types/node": "22.9.0",
62
- "@types/nodemailer": "^6.4.10",
63
- "@types/react": "^18.2.21",
64
- "@typescript-eslint/eslint-plugin": "8.14.0",
65
- "@typescript-eslint/parser": "8.14.0",
66
- "@typescript-eslint/utils": "8.14.0",
67
- "@wix/cli": "latest",
68
- "@wix/eslint-plugin-cli": "latest",
69
- "eslint-plugin-neverthrow": "^1.1.4",
70
- "cypress": "13.15.2",
71
- "cypress-cloud": "^1.9.3",
72
- "esbuild": "0.24.0",
73
- "eslint": "9.14.0",
74
- "eslint-plugin-import": "^2.27.5",
75
- "eslint-plugin-jsdoc": "50.5.0",
76
- "eslint-plugin-named-import-spacing": "^1.0.3",
77
- "eslint-plugin-simple-import-sort": "12.1.1",
78
- "helpful-decorators": "^2.1.0",
79
- "jest": "^29.6.1",
80
- "prettier": "^3.0.3",
81
- "sass": "^1.65.1",
82
- "ts-jest": "^29.1.1",
83
- "ts-node": "^10.9.1",
84
- "tsx": "4.19.2",
85
- "typedoc": "0.26.11",
86
- "typedoc-theme-hierarchy": "5.0.3",
87
- "typescript": "^5.1.6",
88
- "typescript-eslint-language-service": "^5.0.5"
17
+ "@wix/cli": "1.1.50"
89
18
  },
90
19
  "scripts": {
91
20
  "postinstall": "wix sync-types",
92
21
  "wix:dev": "wix dev",
93
- "dev": "gulp dev",
22
+ "dev": "lucy-cli dev",
94
23
  "lint": "eslint .",
95
24
  "docs": "typedoc --tsconfig typescript/tsconfig.json --skipErrorChecking",
96
- "build": "gulp build-prod",
97
- "fix-wix": "gulp fix-wix",
25
+ "build": "lucy-cli build-prod",
26
+ "fix-wix": "lucy-cli fix",
98
27
  "tsc": "tsc -p ./typescript/tsconfig.json --noEmit",
99
28
  "test": "jest --config jest.config.ts --passWithNoTests",
100
29
  "test:watch": "jest --config jest.config.ts --watch"
@@ -0,0 +1,2 @@
1
+ import { ModuleSettings, ProjectSettings } from '.';
2
+ export declare function dev(moduleSettings: ModuleSettings, projectSettings: ProjectSettings, task: string): Promise<void>;
@@ -1,20 +1,14 @@
1
1
  // https://www.sergevandenoever.nl/run-gulp4-tasks-programatically-from-node/
2
2
  import path from 'path';
3
3
  import { fileURLToPath } from 'url';
4
- import { ModuleSettings, ProjectSettings } from '.';
5
-
6
-
7
- export async function dev(moduleSettings: ModuleSettings, projectSettings: ProjectSettings) {
4
+ export async function dev(moduleSettings, projectSettings, task) {
8
5
  // Get the directory name of the current module
9
6
  const __filename = fileURLToPath(import.meta.url);
10
7
  const __dirname = path.dirname(__filename);
11
-
12
8
  // Resolve the path to the Gulpfile
13
9
  const gulpfilePath = path.resolve(__dirname, 'Gulpfile.js');
14
-
15
10
  // Dynamically import the Gulpfile
16
11
  const gulpfile = await import(`file://${gulpfilePath}`);
17
-
18
12
  // Check if 'dev' task exists
19
- gulpfile.runTask('dev', moduleSettings, projectSettings)
20
- }
13
+ gulpfile.runTask('dev', moduleSettings, projectSettings);
14
+ }
@@ -1,5 +1,5 @@
1
1
  module.exports = {
2
- extends: ['eslint:recommended', 'plugin:import/recommended', 'plugin:jsdoc/recommended', 'plugin:@typescript-eslint/recommended', 'plugin:@wix/cli/recommended', 'neverthrow'],
2
+ extends: ['eslint:recommended', 'plugin:import/recommended', 'plugin:jsdoc/recommended', 'plugin:@typescript-eslint/recommended', 'plugin:@wix/cli/recommended'],
3
3
  plugins: ['simple-import-sort', 'eslint-plugin-named-import-spacing', '@typescript-eslint'],
4
4
  parser: '@typescript-eslint/parser',
5
5
  parserOptions: {
@@ -7,7 +7,6 @@ module.exports = {
7
7
  },
8
8
  ignorePatterns: ['src/**/*', 'typescript/types/backend/**/*', 'typescript/types/pages/**/*', 'typescript/types/public/**/*', 'typescript/types/node/**/*', '.wix/**/*', 'coverage/**/*', 'docs/**/*'],
9
9
  rules: {
10
- 'neverthrow/must-use-result': 'error',
11
10
  quotes: [2, 'single', { 'avoidEscape': true, 'allowTemplateLiterals': true }],
12
11
  curly: ['error', 'multi-line'],
13
12
  'simple-import-sort/imports': 'error',
package/files/.yarnrc.yml CHANGED
@@ -1,5 +1,3 @@
1
1
  nodeLinker: node-modules
2
-
3
2
  npmRegistryServer: "https://registry.npmjs.org/"
4
-
5
3
  yarnPath: .yarn/releases/yarn-3.7.0.cjs
@@ -1,5 +1,5 @@
1
1
  module.exports = {
2
2
  projectId: '__ProjectName__', // the projectId, can be any values for sorry-cypress users
3
3
  recordKey: '__ProjectName__', // the record key, can be any value for sorry-cypress users
4
- cloudServiceUrl: 'http://e2e.integral-systems.ch:1234', // Sorry Cypress users - set the director service URL
4
+ cloudServiceUrl: 'http://some-e2e.ch:1234', // Sorry Cypress users - set the director service URL
5
5
  };
@@ -20,16 +20,17 @@
20
20
  "strictPropertyInitialization": true,
21
21
  "experimentalDecorators": true,
22
22
  "paths": {
23
- "public/*": ["./public/*"],
24
- "backend/*": ["./backend/*"],
25
- "pages/*": ["./pages/*"],
26
- "types/*": ["./types/*"]
23
+ "public/*": ["./**/public/*"],
24
+ "backend/*": ["./**/backend/*"],
25
+ "pages/*": ["./**/pages/*"],
26
+ "types/*": ["./**/types/*"]
27
27
  },
28
- "typeRoots": ["./types", "../node_modules/@types"]
28
+ "typeRoots": ["./**/types", "../node_modules/@types"]
29
29
  },
30
30
  "exclude": [
31
31
  "../node_modules",
32
32
  "../.wix",
33
+ "**/*.js",
33
34
  "node_modules",
34
35
  "./wix",
35
36
  "./**/*.test.ts"
package/files/lucy.json CHANGED
@@ -1,5 +1,29 @@
1
1
  {
2
- "modules": {
3
- "lib": "git@github.com:Integral-Systems/lucy-lib.git"
2
+ "modules": {},
3
+ "wixSettings": {
4
+ "compilerOptions": {
5
+ "composite": true,
6
+ "noEmit": false,
7
+ "lib": [],
8
+ "jsx": "react-jsx"
9
+ },
10
+ "exclude": ["**/*.js"]
11
+ },
12
+ "initialized": false,
13
+ "wixPackages": {},
14
+ "devPackages": {
15
+ "wix-cli": "latest"
16
+ },
17
+ "scripts": {
18
+ "postinstall": "wix sync-types",
19
+ "wix:dev": "wix dev",
20
+ "dev": "lucy-cli dev",
21
+ "lint": "eslint .",
22
+ "docs": "typedoc --tsconfig typescript/tsconfig.json --skipErrorChecking",
23
+ "build": "lucy-cli build-prod",
24
+ "fix-wix": "lucy-cli fix",
25
+ "tsc": "tsc -p ./typescript/tsconfig.json --noEmit",
26
+ "test": "jest --config jest.config.ts --passWithNoTests",
27
+ "test:watch": "jest --config jest.config.ts --watch"
4
28
  }
5
29
  }
package/lucy.jpg ADDED
Binary file
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "type": "module",
3
3
  "name": "lucy-cli",
4
- "version": "0.6.1",
4
+ "version": "0.7.0",
5
5
  "description": "Lucy Framework for WIX Studio Editor",
6
6
  "main": ".dist/index.js",
7
7
  "scripts": {
package/src/helpers.ts ADDED
@@ -0,0 +1,79 @@
1
+ import chalk from 'chalk';
2
+ import { join } from 'path';
3
+ import { simpleGit } from 'simple-git';
4
+ import fs from 'fs/promises';
5
+ import { spawnSync } from 'child_process';
6
+ // https://www.sergevandenoever.nl/run-gulp4-tasks-programatically-from-node/
7
+ import path from 'path';
8
+ import { fileURLToPath } from 'url';
9
+ import { ModuleSettings, ProjectSettings } from '.';
10
+
11
+ import { blue, green, orange, red } from './index.js';
12
+
13
+ export async function installPackages(wixPackages: Record<string, string>, devPackages: Record<string, string>, cwd: string, locked: boolean ) {
14
+ if (locked) console.log("🐕" + blue.underline(` => Installing & version locked packages!`));
15
+
16
+ const wixPackageNames = Object.keys(wixPackages);
17
+ const wixPackageVersions = Object.values(wixPackages);
18
+ const wixPackageNamesAndVersions = wixPackageNames.map((name, index) => `${name}@${wixPackageVersions[index]}`);
19
+
20
+ const devPackageNames = Object.keys(devPackages);
21
+ const devPackageVersions = Object.values(devPackages);
22
+ const devPackageNamesAndVersions = devPackageNames.map((name, index) => `${name}@${devPackageVersions[index]}`);
23
+
24
+ let success = true;
25
+ wixPackageNames.forEach((name, index) => {
26
+ console.log(`🐕 => Installing ${orange(name)}`);
27
+ const wixInstall = locked ? `wix install ${wixPackageNamesAndVersions}`: `wix install ${name}`;
28
+ const wixres = spawnSync(wixInstall, { shell: true, stdio: 'inherit' });
29
+ if (wixres.error) {
30
+ console.log((`💩 ${red.underline.bold("=> Failed to install package =>")} ${orange(wixres.error.message)}`));
31
+ success = false;
32
+ } else {
33
+ console.log("🐕" + blue.underline(` => Package installed!`));
34
+ }
35
+ });
36
+ const yarnAdd = locked ? `yarn add -D ${devPackageNamesAndVersions.join(' ')}` : `yarn add -D ${devPackageNames.join(' ')}`;
37
+ const yarnRes = spawnSync(yarnAdd, { shell: true, stdio: 'inherit' });
38
+ if (yarnRes.error) {
39
+ success = false;
40
+ console.log((`💩 ${red.underline.bold("=> Failed to install dev packages =>")} ${orange(yarnRes.error.message)}`));
41
+ }
42
+
43
+ if(success) {
44
+ console.log("🐕" + blue.underline(` => All Packages installed!`));
45
+ } else {
46
+ console.log("🐕" + red.underline(` => Some packages failed to install!`));
47
+ }
48
+ }
49
+
50
+ export async function gitInit(cwd: string, modules: Record<string, string>) {
51
+ const git = simpleGit({ baseDir: cwd });
52
+ for (const [name, url] of Object.entries(modules)) {
53
+ console.log(chalk.green.underline.bold(`Cloning ${name}`));
54
+ try {
55
+ await git.submoduleAdd(url, name)
56
+ } catch (err) {
57
+ console.log((`💩 ${red.underline.bold("=> Command failed =>")} ${orange(err)}`));
58
+ } finally {
59
+ console.log("🐕" + blue.underline(` => Cloned ${orange(name)}`));
60
+ }
61
+ }
62
+ console.log("🐶" + green.underline(' => All Modules cloned!'));
63
+ }
64
+
65
+
66
+ export async function dev(moduleSettings: ModuleSettings, projectSettings: ProjectSettings, task: string) {
67
+ // Get the directory name of the current module
68
+ const __filename = fileURLToPath(import.meta.url);
69
+ const __dirname = path.dirname(__filename);
70
+
71
+ // Resolve the path to the Gulpfile
72
+ const gulpfilePath = path.resolve(__dirname, 'Gulpfile.js');
73
+
74
+ // Dynamically import the Gulpfile
75
+ const gulpfile = await import(`file://${gulpfilePath}`);
76
+
77
+ // Check if 'dev' task exists
78
+ gulpfile.runTask(task, moduleSettings, projectSettings)
79
+ }
package/src/index.ts CHANGED
@@ -2,7 +2,6 @@
2
2
  import { dirname } from 'path';
3
3
  import { fileURLToPath } from 'url';
4
4
  import { existsSync } from 'fs';
5
- import { spawnSync } from 'child_process';
6
5
  import chalk from 'chalk';
7
6
  import settings from './settings.json' assert { type: 'json' };
8
7
  import projectPackageJSON from '../package.json' assert { type: 'json' };
@@ -12,8 +11,34 @@ import { join } from 'path';
12
11
  import fs from 'fs/promises';
13
12
 
14
13
  import { init } from './init.js';
15
- import { dev } from './dev.js';
16
14
  import { sync } from './sync.js';
15
+ import { dev, installPackages } from './helpers.js';
16
+ import { prepare } from './prepare.js';
17
+
18
+ export type LucySettings = {
19
+ modules: {
20
+ [llibName: string]: string;
21
+ };
22
+ wixSettings: {
23
+ compilerOptions: {
24
+ composite: boolean;
25
+ noEmit: boolean;
26
+ lib: string[];
27
+ jsx: string;
28
+ };
29
+ exclude: string[];
30
+ };
31
+ initialized: boolean;
32
+ wixPackages: {
33
+ [packageName: string]: string;
34
+ };
35
+ devPackages: {
36
+ [packageName: string]: string;
37
+ };
38
+ scripts: {
39
+ [commandName: string]: string;
40
+ };
41
+ };
17
42
 
18
43
  export type ModuleSettings = {
19
44
  packageRoot: string;
@@ -24,22 +49,25 @@ export type ModuleSettings = {
24
49
  packageJsonPath: string;
25
50
  settings: typeof settings;
26
51
  lucyJSON: typeof lucyJSON;
52
+ lockVersion: boolean;
27
53
  }
28
54
 
29
55
  export type ProjectSettings = {
30
56
  // packages?: Record<string, string>;
31
57
  modules?: Record<string, string>;
32
- lucySettings?: Record<string, any>;
58
+ lucySettings?: LucySettings;
33
59
  packageJSON?: Record<string, any>;
34
60
  lucyJSON?: Record<string, any>;
35
61
  force: boolean;
36
62
  }
63
+
37
64
  export const orange = chalk.hex('#FFA500');
38
65
  export const blue = chalk.blueBright;
39
66
  export const green = chalk.greenBright;
40
67
  export const red = chalk.redBright;
41
68
  export const yellow = chalk.yellow;
42
69
  export const magenta = chalk.magentaBright;
70
+
43
71
  // eslint-disable-next-line @typescript-eslint/naming-convention
44
72
  const __filename = fileURLToPath(import.meta.url);
45
73
  // eslint-disable-next-line @typescript-eslint/naming-convention
@@ -61,6 +89,7 @@ async function main(): Promise<void> {
61
89
  lucyConfigPath: join(process.cwd(), 'lucy.json'),
62
90
  packageJsonPath: join(process.cwd(), 'package.json'),
63
91
  lucyJSON,
92
+ lockVersion: false
64
93
  }
65
94
 
66
95
  let projectSettings: ProjectSettings = {
@@ -74,12 +103,29 @@ async function main(): Promise<void> {
74
103
  }
75
104
 
76
105
  if(moduleSettings.args.includes('help') || moduleSettings.args.includes('-h')){
77
- console.log("🦮" + green.underline.bold(' => Lucy CLI Help'));
78
- console.log("🦮" + magenta.underline.bold(' => Run init in wix project root folder'));
79
- console.log("🦮" + magenta.underline.bold(' => Run dev to start dev Environment'));
80
- console.log("🦮" + magenta.underline.bold(' => Use -f to force dangerous function(obsoletepage deletion and missing page creation, or forced reinitialization'));
81
- console.log("🦮" + magenta.underline.bold(' => Run sync to sync DB'));
82
- console.log("🦮" + magenta.underline.bold(' => Run install to install list of npm(wix) packages'));
106
+ console.log("🦮 " + green.underline.bold(' => Lucy CLI Help'));
107
+ console.log("Usage: lucy-cli <command> [options]");
108
+ console.log("\nCommands:");
109
+ console.log("🦮 " + magenta.bold('init') + " : Initializes caontaining a WIX project to enable full TS support");
110
+ console.log("🦮 " + magenta.bold('dev') + " : Starts the development environment. This includes setting up any required services for local development.");
111
+ console.log("🦮 " + magenta.bold('build-prod') + " : Builds the project in production mode, optimizing files for deployment.");
112
+ console.log("🦮 " + magenta.bold('prepare') + " : Prepares the project by installing packages & initializing git modules, configured in lucy.json");
113
+ console.log("🦮 " + magenta.bold('sync') + " : Synchronizes the database (not Implemented)");
114
+ console.log("🦮 " + magenta.bold('install') + " : Installs all Wix npm packages listed in the 'lucy.json' file in the project directory.");
115
+ console.log("🦮 " + magenta.bold('fix') + " : Runs a fix command to resolve common issues in development or production settings.");
116
+ console.log("\nOptions:");
117
+ console.log("🦮 " + magenta.bold('-h, help') + " : Displays this help message.");
118
+ console.log("🦮 " + magenta.bold('-v, version') + " : Displays the current version of Lucy CLI as defined in the project’s package.json.");
119
+ console.log("🦮 " + magenta.bold('-f, force') + " : Forces specific commands to execute even if they may lead to potential issues.");
120
+ console.log(" Used for functions like deleting obsolete pages or initializing missing components.");
121
+ console.log("🦮 " + magenta.bold('-l') + " : Locks package versions to those specified in the configuration file lucy.json");
122
+ console.log("\nExamples:");
123
+ console.log("🦮 " + magenta.bold('lucy-cli init') + " : Initializes a new Wix project.");
124
+ console.log("🦮 " + magenta.bold('lucy-cli dev') + " : Starts the development environment.");
125
+ console.log("🦮 " + magenta.bold('lucy-cli sync') + " : Synchronizes database and settings.");
126
+ console.log("🦮 " + magenta.bold('lucy-cli install') + " : Installs all Wix npm packages from 'lucy.json'.");
127
+ console.log("🦮 " + magenta.bold('lucy-cli dev -f') + " : Starts the dev environment with forced settings.");
128
+ console.log("🦮 " + magenta.bold('lucy-cli install -l') + " : Installs Wix npm packages, respecting locked versions specified in the configuration.");
83
129
 
84
130
  return;
85
131
  }
@@ -116,51 +162,59 @@ async function main(): Promise<void> {
116
162
  };
117
163
  }
118
164
 
165
+ if(moduleSettings.args.includes('-l')) moduleSettings.lockVersion = true;
166
+
119
167
  if(moduleSettings.args.includes('init')){
120
168
  console.log("🐕" + magenta.underline(' => Initializing project'));
121
169
  init(moduleSettings, projectSettings);
122
170
 
123
171
  return;
124
172
  }
125
- if(moduleSettings.args.includes('install')){
126
- try {
127
- const data = await fs.readFile(join(process.cwd(), 'wixpkgs.json'), 'utf8');
128
- const jsonData = JSON.parse(data);
129
- console.log("🐕" + magenta.underline(' => Installing wix npm packages'));
130
- const wixPackageVersions = Object.values(jsonData);
131
-
132
- const wixPackageNamesAndVersions = wixPackageVersions.map((name, index) => `${name}@${wixPackageVersions[index]}`);
133
- wixPackageNamesAndVersions.forEach((name, index) => {
134
- console.log(`🐕 => Installing ${orange(name)}`);
135
- const wixInstall = `wix install ${name}`;
136
- const wixres = spawnSync(wixInstall, { shell: true, stdio: 'inherit' });
137
- if (wixres.error) {
138
- console.log((`💩 ${red.underline.bold("=> Failed to install package =>")} ${orange(wixres.error.message)}`));
139
- } else {
140
- console.log("🐕" + blue.underline(` => Package installed!`));
141
- }
142
- });
143
- } catch (e) {
144
- console.log((`💩 ${red.underline.bold("=> Error parsing installing wix npm packages =>")} ${orange(e)}`));
145
- }
173
+
174
+ if(moduleSettings.args.includes('prepare')){
175
+ console.log("🐕" + magenta.underline(' => Preparing project'));
176
+ init(moduleSettings, projectSettings);
146
177
 
147
178
  return;
148
179
  }
149
180
 
150
- if(moduleSettings.args.includes('dev')){
151
- dev(moduleSettings, projectSettings);
181
+ if(moduleSettings.args.includes('install')){
182
+ await installPackages( moduleSettings.settings.wixPackages, moduleSettings.settings.devPackages, moduleSettings.targetFolder, moduleSettings.lockVersion);
152
183
 
153
- return;
184
+ return;
154
185
  }
155
186
 
187
+ if(moduleSettings.args.includes('prepare')){
188
+ await prepare( moduleSettings, projectSettings);
189
+
190
+ return;
191
+ }
192
+
193
+
156
194
  if(moduleSettings.args.includes('sync')){
157
195
  sync(moduleSettings, projectSettings);
158
196
 
159
197
  return;
160
198
  }
161
199
 
200
+ if(moduleSettings.args.includes('dev')){
201
+ dev(moduleSettings, projectSettings, 'dev');
202
+
203
+ return;
204
+ }
205
+ if(moduleSettings.args.includes('build-prod')){
206
+ dev(moduleSettings, projectSettings, 'build-prod');
207
+
208
+ return;
209
+ }
210
+ if(moduleSettings.args.includes('fix')){
211
+ dev(moduleSettings, projectSettings, 'fix');
212
+
213
+ return;
214
+ }
215
+
162
216
  console.log("🐕" + blue.underline.bold(' => Running dev'));
163
- dev(moduleSettings, projectSettings);
217
+ dev(moduleSettings, projectSettings, 'dev');
164
218
  }
165
219
 
166
220
  main();