lucy-cli 1.2.1 → 1.2.3

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/dist/helpers.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { LucySettings, ModuleSettings, ProjectSettings } from '.';
2
2
  export declare function installPackages(wixPackages: Record<string, string>, devPackages: Record<string, string>, cwd: string, locked: boolean): Promise<void>;
3
- export declare function gitInit(cwd: string, modules: LucySettings['modules']): Promise<void>;
3
+ export declare function gitInit(cwd: string, modules: LucySettings['modules'] | undefined, force: boolean): Promise<void>;
4
4
  export declare function runGulp(moduleSettings: ModuleSettings, projectSettings: ProjectSettings, task: string): Promise<void>;
5
5
  /**
6
6
  * Clean up and run a command before exiting the process.
package/dist/helpers.js CHANGED
@@ -69,29 +69,52 @@ export async function installPackages(wixPackages, devPackages, cwd, locked) {
69
69
  console.log("🐕" + red.underline(` => Some packages failed to install!`));
70
70
  }
71
71
  }
72
- export async function gitInit(cwd, modules) {
72
+ async function isSubmoduleRegistered(git, submoduleName) {
73
+ try {
74
+ const urlConfig = await git.getConfig(`submodule.${submoduleName}.url`);
75
+ return !!urlConfig.value;
76
+ }
77
+ catch (e) {
78
+ // simple-git throws an error if the config key doesn't exist
79
+ return false;
80
+ }
81
+ }
82
+ export async function gitInit(cwd, modules, force) {
83
+ const git = simpleGit({ baseDir: cwd });
84
+ if (!(await git.checkIsRepo())) {
85
+ console.log(chalk.yellow('Project is not a git repository. Initializing...'));
86
+ await git.init();
87
+ }
88
+ if (!modules) {
89
+ console.log(chalk.yellow('No submodules defined in settings, skipping.'));
90
+ return;
91
+ }
92
+ const dotGitmodulesPath = path.join(cwd, '.gitmodules');
73
93
  for (const [name, repo] of Object.entries(modules)) {
74
- console.log(chalk.green.underline.bold(`Cloning ${name}`));
75
- const git = simpleGit({ baseDir: cwd });
94
+ console.log(chalk.green.underline.bold(`Processing submodule ${name}`));
76
95
  try {
77
- const repoPath = path.resolve(cwd, name);
78
- if (!fs.existsSync(repoPath)) {
79
- await git.submoduleAdd(repo.url, name);
96
+ const isRegistered = await isSubmoduleRegistered(git, name);
97
+ // Check that .gitmodules exists AND contains the entry for this specific submodule.
98
+ const isConfiguredInFile = fs.existsSync(dotGitmodulesPath) &&
99
+ fs.readFileSync(dotGitmodulesPath, 'utf-8').includes(`[submodule "${name}"]`);
100
+ // Add/repair if not configured in .gitmodules, or if forced by the user.
101
+ if (!isConfiguredInFile || force) {
102
+ console.log(`🐕 ${blue.underline(`Adding/updating submodule ${name}...`)}`);
103
+ // If git already has a config entry, we must use --force to repair it.
104
+ const submoduleArgs = ['add', ...(force || isRegistered ? ['--force'] : []), repo.url, name];
105
+ await git.subModule(submoduleArgs);
80
106
  }
81
- if (fs.existsSync(repoPath)) {
82
- console.log(`🐕 ${blue.underline(' => Module already cloned!')}`);
107
+ else {
108
+ console.log(`🐕 ${blue.underline(`Submodule ${name} already registered. Skipping add.`)}`);
83
109
  }
84
- const localGit = simpleGit({ baseDir: `${cwd}/${name}` });
85
- await localGit.checkout(repo.branch);
110
+ await git.submoduleUpdate(['--init', '--recursive', name]);
111
+ await simpleGit({ baseDir: path.join(cwd, name) }).checkout(repo.branch);
86
112
  }
87
113
  catch (err) {
88
- console.log((`💩 ${red.underline.bold("=> Command failed =>")} ${orange(err)}`));
89
- }
90
- finally {
91
- console.log("🐕" + blue.underline(` => Cloned ${orange(name)}`));
114
+ console.log((`💩 ${red.underline.bold(`=> Command failed for submodule ${name} =>`)} ${orange(err)}`));
92
115
  }
93
116
  }
94
- console.log("🐶" + green.underline(' => All Modules cloned!'));
117
+ console.log("🐶" + green.underline(' => All modules processed!'));
95
118
  }
96
119
  export async function runGulp(moduleSettings, projectSettings, task) {
97
120
  // Get the directory name of the current module
package/dist/init.js CHANGED
@@ -59,7 +59,7 @@ export async function init(moduleSettings, projectSettings) {
59
59
  await installPackages(moduleSettings.settings.wixPackages, moduleSettings.settings.devPackages, moduleSettings.targetFolder, moduleSettings.lockVersion);
60
60
  await editJson(join(moduleSettings.targetFolder, 'jsconfig.json'), ['compilerOptions', 'exclude'], [moduleSettings.settings.wixSettings.compilerOptions, moduleSettings.settings.wixSettings.exclude]);
61
61
  await editJson(join(moduleSettings.targetFolder, 'typedoc.json'), ['name'], [path.basename(moduleSettings.targetFolder)]);
62
- await gitInit(moduleSettings.targetFolder, moduleSettings.settings.modules);
62
+ await gitInit(moduleSettings.targetFolder, moduleSettings.settings.modules, moduleSettings.force);
63
63
  moduleSettings.settings.initialized = true;
64
64
  const eslintrcPath = join(moduleSettings.targetFolder, '.eslintrc.json');
65
65
  if (existsSync(eslintrcPath)) {
package/dist/prepare.js CHANGED
@@ -14,6 +14,6 @@ export async function prepare(moduleSettings, projectSettings) {
14
14
  return;
15
15
  }
16
16
  await installPackages(projectSettings.lucySettings.wixPackages, projectSettings.lucySettings.devPackages, moduleSettings.targetFolder, moduleSettings.lockVersion);
17
- await gitInit(moduleSettings.targetFolder, projectSettings?.lucySettings?.modules);
17
+ await gitInit(moduleSettings.targetFolder, projectSettings?.lucySettings?.modules, moduleSettings.force);
18
18
  console.log(chalk.greenBright.underline('🐶 => Prepare done!'));
19
19
  }
@@ -18,6 +18,7 @@
18
18
  "@types/node": "^24.0.10",
19
19
  "@types/nodemailer": "^6.4.17",
20
20
  "@types/react": "^19.1.8",
21
+ "madge": "^8.0.0",
21
22
  "@typescript-eslint/eslint-plugin": "^8.35.1",
22
23
  "@typescript-eslint/parser": "^8.35.1",
23
24
  "@typescript-eslint/utils": "^8.35.1",
@@ -60,6 +61,7 @@
60
61
  "test": "vitest --ui --coverage",
61
62
  "coverage": "vitest run --coverage",
62
63
  "cypress": "cypress open",
63
- "e2e": "cypress-cloud run --parallel --record"
64
+ "e2e": "cypress-cloud run --parallel --record",
65
+ "graph": "madge --image graph.svg src"
64
66
  }
65
67
  }
@@ -1,5 +1,5 @@
1
1
  /* eslint-disable @typescript-eslint/naming-convention */
2
- import { batchCheckUpdateState, clearStale, getImageUploadUrl, insertItemBatch, isAlive, saveItemBatch } from 'backend/lib/http-functions/sync2';
2
+ import { batchCheckUpdateState, clearStale, getImageUploadUrl, insertItemBatch, isAlive, saveItemBatch } from 'backend/lib/http-functions/sync';
3
3
  import { WixHttpFunctionRequest } from 'wix-http-functions';
4
4
 
5
5
  /**------------------------------------------------------------------------
File without changes
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "type": "module",
3
3
  "name": "lucy-cli",
4
- "version": "1.2.1",
4
+ "version": "1.2.3",
5
5
  "description": "Lucy Framework for WIX Studio Editor",
6
6
  "main": ".dist/index.js",
7
7
  "scripts": {
package/src/helpers.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import chalk from 'chalk';
2
- import { simpleGit } from 'simple-git';
2
+ import { simpleGit, SimpleGit } from 'simple-git';
3
3
  import { spawnSync, exec } from 'child_process';
4
4
  // https://www.sergevandenoever.nl/run-gulp4-tasks-programatically-from-node/
5
5
  import path, { join } from 'path';
@@ -75,30 +75,57 @@ export async function installPackages(wixPackages: Record<string, string>, devPa
75
75
  }
76
76
  }
77
77
 
78
- export async function gitInit(cwd: string, modules: LucySettings['modules']) {
78
+ async function isSubmoduleRegistered(git: SimpleGit, submoduleName: string): Promise<boolean> {
79
+ try {
80
+ const urlConfig = await git.getConfig(`submodule.${submoduleName}.url`);
81
+ return !!urlConfig.value;
82
+ } catch (e) {
83
+ // simple-git throws an error if the config key doesn't exist
84
+ return false;
85
+ }
86
+ }
87
+
88
+ export async function gitInit(cwd: string, modules: LucySettings['modules'] | undefined, force: boolean) {
89
+ const git = simpleGit({ baseDir: cwd });
90
+
91
+ if (!(await git.checkIsRepo())) {
92
+ console.log(chalk.yellow('Project is not a git repository. Initializing...'));
93
+ await git.init();
94
+ }
95
+
96
+ if (!modules) {
97
+ console.log(chalk.yellow('No submodules defined in settings, skipping.'));
98
+ return;
99
+ }
100
+
101
+ const dotGitmodulesPath = path.join(cwd, '.gitmodules');
102
+
79
103
  for (const [name, repo] of Object.entries(modules)) {
80
- console.log(chalk.green.underline.bold(`Cloning ${name}`));
81
- const git = simpleGit({ baseDir: cwd });
104
+ console.log(chalk.green.underline.bold(`Processing submodule ${name}`));
82
105
 
83
106
  try {
84
- const repoPath = path.resolve(cwd, name);
85
- if (!fs.existsSync(repoPath)) {
86
- await git.submoduleAdd(repo.url, name)
87
- }
88
-
89
- if (fs.existsSync(repoPath)) {
90
- console.log(`🐕 ${blue.underline(' => Module already cloned!')}`);
107
+ const isRegistered = await isSubmoduleRegistered(git, name);
108
+ // Check that .gitmodules exists AND contains the entry for this specific submodule.
109
+ const isConfiguredInFile = fs.existsSync(dotGitmodulesPath) &&
110
+ fs.readFileSync(dotGitmodulesPath, 'utf-8').includes(`[submodule "${name}"]`);
111
+
112
+ // Add/repair if not configured in .gitmodules, or if forced by the user.
113
+ if (!isConfiguredInFile || force) {
114
+ console.log(`🐕 ${blue.underline(`Adding/updating submodule ${name}...`)}`);
115
+ // If git already has a config entry, we must use --force to repair it.
116
+ const submoduleArgs = ['add', ...(force || isRegistered ? ['--force'] : []), repo.url, name];
117
+ await git.subModule(submoduleArgs);
118
+ } else {
119
+ console.log(`🐕 ${blue.underline(`Submodule ${name} already registered. Skipping add.`)}`);
91
120
  }
92
121
 
93
- const localGit = simpleGit({ baseDir: `${cwd}/${name}` });
94
- await localGit.checkout(repo.branch);
122
+ await git.submoduleUpdate(['--init', '--recursive', name]);
123
+ await simpleGit({ baseDir: path.join(cwd, name) }).checkout(repo.branch);
95
124
  } catch (err) {
96
- console.log((`💩 ${red.underline.bold("=> Command failed =>")} ${orange(err)}`));
97
- } finally {
98
- console.log("🐕" + blue.underline(` => Cloned ${orange(name)}`));
125
+ console.log((`💩 ${red.underline.bold(`=> Command failed for submodule ${name} =>`)} ${orange(err)}`));
99
126
  }
100
127
  }
101
- console.log("🐶" + green.underline(' => All Modules cloned!'));
128
+ console.log("🐶" + green.underline(' => All modules processed!'));
102
129
  }
103
130
 
104
131
 
package/src/init.ts CHANGED
@@ -72,7 +72,7 @@ export async function init(moduleSettings: ModuleSettings, projectSettings: Proj
72
72
  await editJson(join(moduleSettings.targetFolder, 'jsconfig.json'), ['compilerOptions', 'exclude'], [moduleSettings.settings.wixSettings.compilerOptions, moduleSettings.settings.wixSettings.exclude]);
73
73
  await editJson(join(moduleSettings.targetFolder, 'typedoc.json'), ['name'], [path.basename(moduleSettings.targetFolder)]);
74
74
 
75
- await gitInit(moduleSettings.targetFolder, moduleSettings.settings.modules);
75
+ await gitInit(moduleSettings.targetFolder, moduleSettings.settings.modules, moduleSettings.force);
76
76
 
77
77
  moduleSettings.settings.initialized = true;
78
78
 
package/src/prepare.ts CHANGED
@@ -18,7 +18,7 @@ export async function prepare(moduleSettings: ModuleSettings, projectSettings: P
18
18
 
19
19
  await installPackages(projectSettings.lucySettings.wixPackages, projectSettings.lucySettings.devPackages, moduleSettings.targetFolder, moduleSettings.lockVersion);
20
20
 
21
- await gitInit(moduleSettings.targetFolder, projectSettings?.lucySettings?.modules);
21
+ await gitInit(moduleSettings.targetFolder, projectSettings?.lucySettings?.modules, moduleSettings.force);
22
22
 
23
23
  console.log(chalk.greenBright.underline('🐶 => Prepare done!'));
24
24
  }
package/src/settings.json CHANGED
@@ -18,6 +18,7 @@
18
18
  "@types/node": "^24.0.10",
19
19
  "@types/nodemailer": "^6.4.17",
20
20
  "@types/react": "^19.1.8",
21
+ "madge": "^8.0.0",
21
22
  "@typescript-eslint/eslint-plugin": "^8.35.1",
22
23
  "@typescript-eslint/parser": "^8.35.1",
23
24
  "@typescript-eslint/utils": "^8.35.1",
@@ -60,6 +61,7 @@
60
61
  "test": "vitest --ui --coverage",
61
62
  "coverage": "vitest run --coverage",
62
63
  "cypress": "cypress open",
63
- "e2e": "cypress-cloud run --parallel --record"
64
+ "e2e": "cypress-cloud run --parallel --record",
65
+ "graph": "madge --image graph.svg src"
64
66
  }
65
67
  }
@@ -1,8 +0,0 @@
1
- module.exports = {
2
- overrides: [
3
- {
4
- files: ["**/*.{ts,tsx}"],
5
- customSyntax: "@stylelint/postcss-css-in-js",
6
- },
7
- ],
8
- };
@@ -1,7 +0,0 @@
1
- export const environment = {
2
- gitTag: 'development',
3
- devMode: false,
4
- development: process.env.SEGMENT === 'dev' ? true : false,
5
- } as const;
6
-
7
- export type Environment = typeof environment;
@@ -1,4 +0,0 @@
1
- import { z } from "zod";
2
-
3
- export const frontendAPISchema = z.object({});
4
- export type FrontendAPI = z.infer<typeof frontendAPISchema>;
@@ -1,32 +0,0 @@
1
- import * as fs from 'fs';
2
-
3
-
4
- export interface RenderToFsOPtions {
5
- renderer: (arg0: any, arg1: any) => Promise<string>;
6
- dataSource: string;
7
- destination: string;
8
- }
9
- /**
10
- * Render E-Mail to file system
11
- * @param {RenderToFsOPtions} options Preview Options
12
- * @returns {Promise<void>}
13
- */
14
- export async function renderToFs(options: RenderToFsOPtions): Promise<void> {
15
- if (process.env.NODE_ENV === 'production' || process.env.NODE_ENV === 'development') return;
16
- console.log('rendered', process.env.NODE_ENV, options);
17
- fs.readFile(`typescript/backend/templates/data/${options.dataSource}`, 'utf8', async (err, data) => {
18
- if (err){
19
- console.error('Template Rendere => ', err);
20
-
21
- return;
22
- }
23
- const fakeDate = JSON.parse(data) as any;
24
- console.log('fakeDate', fakeDate);
25
- const html = await options.renderer(fakeDate, 'de');
26
- fs.writeFile(`typescript/backend/templates/preview/${options.destination}.html`, html, err => {
27
- if (err){
28
- console.error(err);
29
- }
30
- });
31
- });
32
- }