lucy-cli 1.2.2 → 1.2.4
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/README.md +2 -1
- package/dist/gulp/styles.js +32 -24
- package/dist/helpers.d.ts +1 -1
- package/dist/helpers.js +39 -15
- package/dist/index.d.ts +2 -1
- package/dist/init.js +1 -1
- package/dist/prepare.js +1 -1
- package/files/.gitmodules +0 -0
- package/files/typescript/public/scss/app.scss +0 -0
- package/package.json +1 -1
- package/src/gulp/styles.ts +34 -29
- package/src/helpers.ts +45 -17
- package/src/index.ts +2 -1
- package/src/init.ts +1 -1
- package/src/prepare.ts +1 -1
package/README.md
CHANGED
@@ -59,7 +59,8 @@ Lucy-CLI is designed to streamline the setup and management of TypeScript within
|
|
59
59
|
"modules": {
|
60
60
|
"<repoName>": {
|
61
61
|
"url": "String",
|
62
|
-
"branch": "String"
|
62
|
+
"branch": "String",
|
63
|
+
"path": "String" // Optional, specifies the path where the submodule should be cloned
|
63
64
|
}
|
64
65
|
}
|
65
66
|
```
|
package/dist/gulp/styles.js
CHANGED
@@ -8,29 +8,37 @@ export function compileScss(options) {
|
|
8
8
|
// }
|
9
9
|
// }
|
10
10
|
const { sass, outputDir } = options;
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
})
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
})
|
27
|
-
.on('end', function () {
|
28
|
-
console.log("🐶" + blue.underline(` => Compiling of scss files for ${orange(folder)} succeeded!`));
|
29
|
-
});
|
30
|
-
// Register the task with Gulp
|
31
|
-
Object.defineProperty(task, 'name', { value: taskName }); // Set a unique name for debugging
|
32
|
-
return task;
|
11
|
+
const buildWixScss = () => gulp.src(['typescript/styles/global.scss'])
|
12
|
+
.pipe(sass().on('error', sass.logError))
|
13
|
+
.on('error', function (e) {
|
14
|
+
console.log("💩" + red.underline.bold(` => Build of SCSS files for ${orange('global.scs')} failed!`));
|
15
|
+
console.log("💩" + red.underline.bold(` => Error: ${orange(e.message)}`));
|
16
|
+
this.emit('end');
|
17
|
+
})
|
18
|
+
.pipe(gulp.dest(`${outputDir}/styles`))
|
19
|
+
.on('error', function (e) {
|
20
|
+
console.log("💩" + red.underline.bold(` => Compiling of scss files for ${orange('global.scs')} failed!`));
|
21
|
+
console.log("💩" + red.underline.bold(` => Error: ${orange(e.message)}`));
|
22
|
+
this.emit('end');
|
23
|
+
})
|
24
|
+
.on('end', function () {
|
25
|
+
console.log("🐶" + blue.underline(` => Compiling of scss files for ${orange('global.scs')} succeeded!`));
|
33
26
|
});
|
34
|
-
|
35
|
-
|
27
|
+
const buildScss = () => gulp.src(['typescript/public/scss/app.scss'])
|
28
|
+
.pipe(sass().on('error', sass.logError))
|
29
|
+
.on('error', function (e) {
|
30
|
+
console.log("💩" + red.underline.bold(` => Build of SCSS files for ${orange('app.scss')} failed!`));
|
31
|
+
console.log("💩" + red.underline.bold(` => Error: ${orange(e.message)}`));
|
32
|
+
this.emit('end');
|
33
|
+
})
|
34
|
+
.pipe(gulp.dest(`${outputDir}/public/css`))
|
35
|
+
.on('error', function (e) {
|
36
|
+
console.log("💩" + red.underline.bold(` => Compiling of scss files for ${orange('app.scss')} failed!`));
|
37
|
+
console.log("💩" + red.underline.bold(` => Error: ${orange(e.message)}`));
|
38
|
+
this.emit('end');
|
39
|
+
})
|
40
|
+
.on('end', function () {
|
41
|
+
console.log("🐶" + blue.underline(` => Compiling of scss files for ${orange('app.scss')} succeeded!`));
|
42
|
+
});
|
43
|
+
return gulp.parallel(buildWixScss, buildScss);
|
36
44
|
}
|
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,53 @@ export async function installPackages(wixPackages, devPackages, cwd, locked) {
|
|
69
69
|
console.log("🐕" + red.underline(` => Some packages failed to install!`));
|
70
70
|
}
|
71
71
|
}
|
72
|
-
|
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(`
|
75
|
-
const
|
94
|
+
console.log(chalk.green.underline.bold(`Processing submodule ${name}`));
|
95
|
+
const clonePath = repo.path || name;
|
76
96
|
try {
|
77
|
-
const
|
78
|
-
|
79
|
-
|
97
|
+
const isRegistered = await isSubmoduleRegistered(git, clonePath);
|
98
|
+
// Check that .gitmodules exists AND contains the entry for this specific submodule.
|
99
|
+
const isConfiguredInFile = fs.existsSync(dotGitmodulesPath) &&
|
100
|
+
fs.readFileSync(dotGitmodulesPath, 'utf-8').includes(`[submodule "${clonePath}"]`);
|
101
|
+
// Add/repair if not configured in .gitmodules, or if forced by the user.
|
102
|
+
if (!isConfiguredInFile || force) {
|
103
|
+
console.log(`🐕 ${blue.underline(`Adding/updating submodule ${name} at ${clonePath}...`)}`);
|
104
|
+
// If git already has a config entry, we must use --force to repair it.
|
105
|
+
const submoduleArgs = ['add', ...(force || isRegistered ? ['--force'] : []), repo.url, clonePath];
|
106
|
+
await git.subModule(submoduleArgs);
|
80
107
|
}
|
81
|
-
|
82
|
-
console.log(`🐕 ${blue.underline(
|
108
|
+
else {
|
109
|
+
console.log(`🐕 ${blue.underline(`Submodule ${name} at ${clonePath} already registered. Skipping add.`)}`);
|
83
110
|
}
|
84
|
-
|
85
|
-
await
|
111
|
+
await git.submoduleUpdate(['--init', '--recursive', clonePath]);
|
112
|
+
await simpleGit({ baseDir: path.join(cwd, clonePath) }).checkout(repo.branch);
|
86
113
|
}
|
87
114
|
catch (err) {
|
88
|
-
console.log((`💩 ${red.underline.bold(
|
89
|
-
}
|
90
|
-
finally {
|
91
|
-
console.log("🐕" + blue.underline(` => Cloned ${orange(name)}`));
|
115
|
+
console.log((`💩 ${red.underline.bold(`=> Command failed for submodule ${name} =>`)} ${orange(err)}`));
|
92
116
|
}
|
93
117
|
}
|
94
|
-
console.log("🐶" + green.underline(' => All
|
118
|
+
console.log("🐶" + green.underline(' => All modules processed!'));
|
95
119
|
}
|
96
120
|
export async function runGulp(moduleSettings, projectSettings, task) {
|
97
121
|
// Get the directory name of the current module
|
package/dist/index.d.ts
CHANGED
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
|
}
|
File without changes
|
File without changes
|
package/package.json
CHANGED
package/src/gulp/styles.ts
CHANGED
@@ -13,34 +13,39 @@ export function compileScss(options: TaskOptions) {
|
|
13
13
|
|
14
14
|
const { sass, outputDir} = options;
|
15
15
|
|
16
|
+
const buildWixScss = () => gulp.src(['typescript/styles/global.scss'])
|
17
|
+
.pipe(sass().on('error', sass.logError))
|
18
|
+
.on('error', function (e: Error) {
|
19
|
+
console.log("💩" + red.underline.bold(` => Build of SCSS files for ${orange('global.scs')} failed!`));
|
20
|
+
console.log("💩" + red.underline.bold(` => Error: ${orange(e.message)}`));
|
21
|
+
this.emit('end');
|
22
|
+
})
|
23
|
+
.pipe(gulp.dest(`${outputDir}/styles`))
|
24
|
+
.on('error', function (e: Error) {
|
25
|
+
console.log("💩" + red.underline.bold(` => Compiling of scss files for ${orange('global.scs')} failed!`));
|
26
|
+
console.log("💩" + red.underline.bold(` => Error: ${orange(e.message)}`));
|
27
|
+
this.emit('end');
|
28
|
+
})
|
29
|
+
.on('end', function () {
|
30
|
+
console.log("🐶" + blue.underline(` => Compiling of scss files for ${orange('global.scs')} succeeded!`));
|
31
|
+
});
|
16
32
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
.on('end', function () {
|
36
|
-
console.log("🐶" + blue.underline(` => Compiling of scss files for ${orange(folder)} succeeded!`));
|
37
|
-
});
|
38
|
-
|
39
|
-
// Register the task with Gulp
|
40
|
-
Object.defineProperty(task, 'name', { value: taskName }); // Set a unique name for debugging
|
41
|
-
return task;
|
42
|
-
});
|
43
|
-
|
44
|
-
// Run all tasks in parallel
|
45
|
-
return gulp.parallel(...tasks);
|
33
|
+
const buildScss = () => gulp.src(['typescript/public/scss/app.scss'])
|
34
|
+
.pipe(sass().on('error', sass.logError))
|
35
|
+
.on('error', function (e: Error) {
|
36
|
+
console.log("💩" + red.underline.bold(` => Build of SCSS files for ${orange('app.scss')} failed!`));
|
37
|
+
console.log("💩" + red.underline.bold(` => Error: ${orange(e.message)}`));
|
38
|
+
this.emit('end');
|
39
|
+
})
|
40
|
+
.pipe(gulp.dest(`${outputDir}/public/css`))
|
41
|
+
.on('error', function (e: Error) {
|
42
|
+
console.log("💩" + red.underline.bold(` => Compiling of scss files for ${orange('app.scss')} failed!`));
|
43
|
+
console.log("💩" + red.underline.bold(` => Error: ${orange(e.message)}`));
|
44
|
+
this.emit('end');
|
45
|
+
})
|
46
|
+
.on('end', function () {
|
47
|
+
console.log("🐶" + blue.underline(` => Compiling of scss files for ${orange('app.scss')} succeeded!`));
|
48
|
+
});
|
49
|
+
|
50
|
+
return gulp.parallel(buildWixScss, buildScss);
|
46
51
|
}
|
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,58 @@ export async function installPackages(wixPackages: Record<string, string>, devPa
|
|
75
75
|
}
|
76
76
|
}
|
77
77
|
|
78
|
-
|
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(`
|
81
|
-
|
104
|
+
console.log(chalk.green.underline.bold(`Processing submodule ${name}`));
|
105
|
+
const clonePath = repo.path || name;
|
82
106
|
|
83
107
|
try {
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
if
|
90
|
-
|
108
|
+
const isRegistered = await isSubmoduleRegistered(git, clonePath);
|
109
|
+
// Check that .gitmodules exists AND contains the entry for this specific submodule.
|
110
|
+
const isConfiguredInFile = fs.existsSync(dotGitmodulesPath) &&
|
111
|
+
fs.readFileSync(dotGitmodulesPath, 'utf-8').includes(`[submodule "${clonePath}"]`);
|
112
|
+
|
113
|
+
// Add/repair if not configured in .gitmodules, or if forced by the user.
|
114
|
+
if (!isConfiguredInFile || force) {
|
115
|
+
console.log(`🐕 ${blue.underline(`Adding/updating submodule ${name} at ${clonePath}...`)}`);
|
116
|
+
// If git already has a config entry, we must use --force to repair it.
|
117
|
+
const submoduleArgs = ['add', ...(force || isRegistered ? ['--force'] : []), repo.url, clonePath];
|
118
|
+
await git.subModule(submoduleArgs);
|
119
|
+
} else {
|
120
|
+
console.log(`🐕 ${blue.underline(`Submodule ${name} at ${clonePath} already registered. Skipping add.`)}`);
|
91
121
|
}
|
92
122
|
|
93
|
-
|
94
|
-
await
|
123
|
+
await git.submoduleUpdate(['--init', '--recursive', clonePath]);
|
124
|
+
await simpleGit({ baseDir: path.join(cwd, clonePath) }).checkout(repo.branch);
|
95
125
|
} catch (err) {
|
96
|
-
console.log((`💩 ${red.underline.bold(
|
97
|
-
} finally {
|
98
|
-
console.log("🐕" + blue.underline(` => Cloned ${orange(name)}`));
|
126
|
+
console.log((`💩 ${red.underline.bold(`=> Command failed for submodule ${name} =>`)} ${orange(err)}`));
|
99
127
|
}
|
100
128
|
}
|
101
|
-
console.log("🐶" + green.underline(' => All
|
129
|
+
console.log("🐶" + green.underline(' => All modules processed!'));
|
102
130
|
}
|
103
131
|
|
104
132
|
|
package/src/index.ts
CHANGED
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
|
}
|