lucy-cli 0.6.0 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.cjs +1 -1
- package/LICENSE.md +22 -0
- package/README.md +103 -1
- package/dist/helpers.d.ts +4 -0
- package/dist/helpers.js +69 -0
- package/dist/index.d.ts +26 -1
- package/dist/index.js +49 -32
- package/dist/init copy.d.ts +8 -0
- package/dist/init copy.js +167 -0
- package/dist/init.js +4 -53
- package/dist/install.d.ts +2 -0
- package/dist/install.js +53 -0
- package/dist/prepare.d.ts +8 -0
- package/dist/prepare.js +18 -0
- package/dist/settings.json +10 -78
- package/dist/start_gulp.d.ts +2 -0
- package/{src/dev.ts → dist/start_gulp.js} +3 -9
- package/files/.eslintrc.cjs +3 -0
- package/files/.yarnrc.yml +0 -2
- package/files/currents.config.js +1 -1
- package/files/docs.tsconfig.json +6 -5
- package/files/lucy.json +26 -2
- package/lucy.jpg +0 -0
- package/package.json +1 -1
- package/src/helpers.ts +79 -0
- package/src/index.ts +88 -34
- package/src/init.ts +3 -53
- package/src/prepare.ts +23 -0
- package/src/settings.json +10 -78
- package/.drone/.drone.yml +0 -156
- package/.drone/mail_prod_build.hbs +0 -319
- package/.drone/mail_prod_deploy.hbs +0 -309
- package/.drone/mail_satges.hbs +0 -309
- package/.drone/telegram_prod_build.tpl +0 -23
- package/.drone/telegram_prod_deploy.tpl +0 -20
- package/.drone/telegram_stages.tpl +0 -20
- package/files/.eslintrc.json +0 -3
- package/files/typescript/.eslintrc.json +0 -35
package/dist/install.js
ADDED
@@ -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>;
|
package/dist/prepare.js
ADDED
@@ -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
|
+
}
|
package/dist/settings.json
CHANGED
@@ -1,97 +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
|
-
|
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
|
-
"@
|
23
|
-
"@js-joda/locale": "4.8.10",
|
24
|
-
"@js-joda/locale_de": "4.8.10",
|
25
|
-
"@js-joda/locale_en": "4.8.10",
|
26
|
-
"@js-joda/locale_fr": "4.8.10",
|
27
|
-
"@js-joda/locale_it": "4.8.10",
|
28
|
-
"@js-joda/timezone": "2.18.0",
|
29
|
-
"@react-pdf/renderer": "4.0.0",
|
30
|
-
"@wix/image": "1.96.0",
|
31
|
-
"@wix/velo-bind": "1.0.8",
|
32
|
-
"add": "^2.0.6",
|
33
|
-
"await-semaphore": "0.1.3",
|
34
|
-
"axios": "1.4.0",
|
35
|
-
"crypto-js": "4.1.1",
|
36
|
-
"uuid": "11.0.3",
|
37
|
-
"velo-sync": "^0.0.9",
|
38
|
-
"@legendapp/state": "beta",
|
39
|
-
"zod": "3.22.2",
|
40
|
-
"react": "18.2.0",
|
41
|
-
"react-dom": "18.1.0",
|
42
|
-
"react-transition-group": "4.4.5",
|
43
|
-
"mobx": "6.8.0",
|
44
|
-
"mobx-utils": "6.0.3",
|
45
|
-
"node-cache": "5.1.2",
|
46
|
-
"nodemailer": "6.9.3",
|
47
|
-
"payment": "2.3.0",
|
48
|
-
"merge-stream": "^2.0.0",
|
49
|
-
"i18next": "23.16.5",
|
50
|
-
"eventemitter3": "5.0.1",
|
51
|
-
"gsap": "3.11.4"
|
14
|
+
"@hey-api/openapi-ts": "0.55.1"
|
52
15
|
},
|
53
16
|
"devPackages": {
|
54
|
-
"@
|
55
|
-
"@styled/typescript-styled-plugin": "^1.0.1",
|
56
|
-
"@total-typescript/ts-reset": "0.6.1",
|
57
|
-
"@types/i18n": "^0.13.6",
|
58
|
-
"@types/jest": "^29.5.3",
|
59
|
-
"@types/node": "22.9.0",
|
60
|
-
"@types/nodemailer": "^6.4.10",
|
61
|
-
"@types/react": "^18.2.21",
|
62
|
-
"@typescript-eslint/eslint-plugin": "8.14.0",
|
63
|
-
"@typescript-eslint/parser": "8.14.0",
|
64
|
-
"@typescript-eslint/utils": "8.14.0",
|
65
|
-
"@wix/cli": "latest",
|
66
|
-
"@wix/eslint-plugin-cli": "latest",
|
67
|
-
"cypress": "13.15.2",
|
68
|
-
"cypress-cloud": "^1.9.3",
|
69
|
-
"esbuild": "0.24.0",
|
70
|
-
"eslint": "9.14.0",
|
71
|
-
"eslint-plugin-import": "^2.27.5",
|
72
|
-
"eslint-plugin-jsdoc": "50.5.0",
|
73
|
-
"eslint-plugin-named-import-spacing": "^1.0.3",
|
74
|
-
"eslint-plugin-simple-import-sort": "12.1.1",
|
75
|
-
"helpful-decorators": "^2.1.0",
|
76
|
-
"jest": "^29.6.1",
|
77
|
-
"prettier": "^3.0.3",
|
78
|
-
"sass": "^1.65.1",
|
79
|
-
"ts-jest": "^29.1.1",
|
80
|
-
"ts-node": "^10.9.1",
|
81
|
-
"tsx": "4.19.2",
|
82
|
-
"typedoc": "0.26.11",
|
83
|
-
"typedoc-theme-hierarchy": "5.0.3",
|
84
|
-
"typescript": "^5.1.6",
|
85
|
-
"typescript-eslint-language-service": "^5.0.5"
|
17
|
+
"@wix/cli": "1.1.50"
|
86
18
|
},
|
87
19
|
"scripts": {
|
88
20
|
"postinstall": "wix sync-types",
|
89
21
|
"wix:dev": "wix dev",
|
90
|
-
"dev": "
|
22
|
+
"dev": "lucy-cli dev",
|
91
23
|
"lint": "eslint .",
|
92
24
|
"docs": "typedoc --tsconfig typescript/tsconfig.json --skipErrorChecking",
|
93
|
-
"build": "
|
94
|
-
"fix-wix": "
|
25
|
+
"build": "lucy-cli build-prod",
|
26
|
+
"fix-wix": "lucy-cli fix",
|
95
27
|
"tsc": "tsc -p ./typescript/tsconfig.json --noEmit",
|
96
28
|
"test": "jest --config jest.config.ts --passWithNoTests",
|
97
29
|
"test:watch": "jest --config jest.config.ts --watch"
|
@@ -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
|
-
|
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
|
+
}
|
package/files/.eslintrc.cjs
CHANGED
@@ -2,6 +2,9 @@ module.exports = {
|
|
2
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
|
+
parserOptions: {
|
6
|
+
ecmaVersion: 2021,
|
7
|
+
},
|
5
8
|
ignorePatterns: ['src/**/*', 'typescript/types/backend/**/*', 'typescript/types/pages/**/*', 'typescript/types/public/**/*', 'typescript/types/node/**/*', '.wix/**/*', 'coverage/**/*', 'docs/**/*'],
|
6
9
|
rules: {
|
7
10
|
quotes: [2, 'single', { 'avoidEscape': true, 'allowTemplateLiterals': true }],
|
package/files/.yarnrc.yml
CHANGED
package/files/currents.config.js
CHANGED
@@ -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.
|
4
|
+
cloudServiceUrl: 'http://some-e2e.ch:1234', // Sorry Cypress users - set the director service URL
|
5
5
|
};
|
package/files/docs.tsconfig.json
CHANGED
@@ -20,16 +20,17 @@
|
|
20
20
|
"strictPropertyInitialization": true,
|
21
21
|
"experimentalDecorators": true,
|
22
22
|
"paths": {
|
23
|
-
"public/*": ["
|
24
|
-
"backend/*": ["
|
25
|
-
"pages/*": ["
|
26
|
-
"types/*": ["
|
23
|
+
"public/*": ["./**/public/*"],
|
24
|
+
"backend/*": ["./**/backend/*"],
|
25
|
+
"pages/*": ["./**/pages/*"],
|
26
|
+
"types/*": ["./**/types/*"]
|
27
27
|
},
|
28
|
-
"typeRoots": ["
|
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
|
-
|
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
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?:
|
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("
|
79
|
-
console.log("
|
80
|
-
console.log("🦮" + magenta.
|
81
|
-
console.log("🦮" + magenta.
|
82
|
-
console.log("🦮" + magenta.
|
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
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
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('
|
151
|
-
|
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();
|