lucy-cli 0.8.3 â 0.9.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/dist/Gulpfile.js +6 -1
- package/dist/gulp/backend.js +34 -19
- package/dist/gulp/checks.js +2 -1
- package/dist/gulp/clean.js +5 -3
- package/dist/gulp/copy.js +2 -1
- package/dist/gulp/pages.d.ts +1 -1
- package/dist/gulp/pages.js +20 -11
- package/dist/gulp/pipeline.js +3 -2
- package/dist/gulp/public.js +19 -13
- package/dist/gulp/styles.js +7 -1
- package/dist/gulp/templates.js +2 -1
- package/dist/gulp/test.js +2 -1
- package/dist/gulp/types.js +3 -3
- package/dist/helpers.d.ts +6 -1
- package/dist/helpers.js +73 -7
- package/dist/index.js +39 -4
- package/package.json +7 -5
- package/src/Gulpfile.ts +5 -1
- package/src/gulp/backend.ts +44 -32
- package/src/gulp/checks.ts +2 -1
- package/src/gulp/clean.ts +5 -3
- package/src/gulp/copy.ts +2 -1
- package/src/gulp/pages.ts +26 -16
- package/src/gulp/pipeline.ts +3 -2
- package/src/gulp/public.ts +21 -15
- package/src/gulp/styles.ts +7 -1
- package/src/gulp/templates.ts +2 -1
- package/src/gulp/test.ts +2 -1
- package/src/gulp/types.ts +3 -3
- package/src/helpers.ts +74 -10
- package/src/index.ts +44 -4
- package/src/types.d.ts +2 -1
package/dist/Gulpfile.js
CHANGED
@@ -87,6 +87,11 @@ export async function runTask(task, moduleSettings, projectSettings) {
|
|
87
87
|
taskOptions.moduleSettings = moduleSettings;
|
88
88
|
taskOptions.projectSettings = projectSettings;
|
89
89
|
console.log("đ" + magenta.underline(' => Starting Task => ' + orange(task)));
|
90
|
-
|
90
|
+
try {
|
91
|
+
await gulpTaskRunner(task);
|
92
|
+
}
|
93
|
+
catch (err) {
|
94
|
+
console.log((`đŠ ${red.underline.bold("=> Error starting tasks =>")} ${orange(err)}`));
|
95
|
+
}
|
91
96
|
console.log("đļ" + green.underline.bold(' => Task completed: ' + task));
|
92
97
|
}
|
package/dist/gulp/backend.js
CHANGED
@@ -1,8 +1,17 @@
|
|
1
1
|
import gulp from 'gulp';
|
2
|
-
import { createGulpEsbuild } from 'gulp-esbuild';
|
3
2
|
import rename from 'gulp-rename';
|
4
3
|
import * as path from 'path';
|
5
4
|
import { blue, orange, red } from '../index.js';
|
5
|
+
import swc from 'gulp-swc';
|
6
|
+
const swcOptions = {
|
7
|
+
jsc: {
|
8
|
+
target: 'es2020',
|
9
|
+
parser: {
|
10
|
+
syntax: "typescript",
|
11
|
+
tsx: true,
|
12
|
+
},
|
13
|
+
},
|
14
|
+
};
|
6
15
|
export function buildBackend(options) {
|
7
16
|
const folders = ['typescript'];
|
8
17
|
if (options.modulesSync) {
|
@@ -10,11 +19,7 @@ export function buildBackend(options) {
|
|
10
19
|
folders.push(module);
|
11
20
|
}
|
12
21
|
}
|
13
|
-
const { outputDir
|
14
|
-
const gulpEsbuild = createGulpEsbuild({
|
15
|
-
incremental: enableIncrementalBuild,
|
16
|
-
pipe: true,
|
17
|
-
});
|
22
|
+
const { outputDir } = options;
|
18
23
|
// Create tasks for each folder
|
19
24
|
const tasks = folders.map((folder) => {
|
20
25
|
const taskName = `build_Backend-${folder}`; // Create a unique name for each task
|
@@ -24,12 +29,17 @@ export function buildBackend(options) {
|
|
24
29
|
`!${folder}/backend/**/*.jsw.ts`,
|
25
30
|
`!${folder}/backend/**/*.spec.ts`,
|
26
31
|
])
|
27
|
-
.pipe(
|
28
|
-
|
29
|
-
|
32
|
+
.pipe(swc(swcOptions))
|
33
|
+
.pipe(swc(swcOptions))
|
34
|
+
.on('error', function (e) {
|
35
|
+
console.log("đŠ" + red.underline.bold(` => Build of Backend files for ${orange(folder)} failed!`));
|
36
|
+
console.log("đŠ" + red.underline.bold(` => Error: ${orange(e.message)}`));
|
37
|
+
this.emit('end');
|
38
|
+
})
|
30
39
|
.pipe(gulp.dest(path.join(outputDir, 'backend')))
|
31
|
-
.on('error', function () {
|
40
|
+
.on('error', function (e) {
|
32
41
|
console.log("đŠ" + red.underline.bold(` => Build of Backend files for ${orange(folder)} failed!`));
|
42
|
+
console.log("đŠ" + red.underline.bold(` => Error: ${orange(e.message)}`));
|
33
43
|
this.emit('end');
|
34
44
|
})
|
35
45
|
.on('end', function () {
|
@@ -49,24 +59,29 @@ export function buildBackendJSW(options) {
|
|
49
59
|
folders.push(module);
|
50
60
|
}
|
51
61
|
}
|
52
|
-
const
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
}
|
62
|
+
const swcOptions = {
|
63
|
+
jsc: {
|
64
|
+
target: 'es6',
|
65
|
+
},
|
66
|
+
};
|
67
|
+
const { outputDir } = options;
|
57
68
|
// Create tasks for each folder
|
58
69
|
const tasks = folders.map((folder) => {
|
59
70
|
const taskName = `build-${folder}`; // Create a unique name for each task
|
60
71
|
const task = () => gulp.src([
|
61
72
|
`${folder}/backend/**/*.jsw.ts`,
|
62
73
|
])
|
63
|
-
.pipe(
|
64
|
-
|
65
|
-
|
74
|
+
.pipe(swc(swcOptions))
|
75
|
+
.on('error', function (e) {
|
76
|
+
console.log("đŠ" + red.underline.bold(` => Build of Public files for ${orange(folder)} failed!`));
|
77
|
+
console.log("đŠ" + red.underline.bold(` => Error: ${orange(e.message)}`));
|
78
|
+
this.emit('end');
|
79
|
+
})
|
66
80
|
.pipe(rename({ extname: '' }))
|
67
81
|
.pipe(gulp.dest(path.join(outputDir, 'backend')))
|
68
|
-
.on('error', function () {
|
82
|
+
.on('error', function (e) {
|
69
83
|
console.log("đŠ" + red.underline.bold(` => Build of JSW files for ${orange(folder)} failed!`));
|
84
|
+
console.log("đŠ" + red.underline.bold(` => Error: ${orange(e.message)}`));
|
70
85
|
this.emit('end');
|
71
86
|
})
|
72
87
|
.on('end', function () {
|
package/dist/gulp/checks.js
CHANGED
@@ -128,8 +128,9 @@ export function checkTs(options) {
|
|
128
128
|
const taskName = `test-${folder}`; // Create a unique name for each task
|
129
129
|
const task = () => gulp.src([`${folder}/**/*.ts`, `!${folder}/types/**/*.ts`], { cwd: folder })
|
130
130
|
.pipe(tsProject(ts.reporter.fullReporter()))
|
131
|
-
.on('error', function () {
|
131
|
+
.on('error', function (e) {
|
132
132
|
console.log("đŠ" + red.underline.bold(` => Typescriptcheck for ${orange(folder)} failed!`));
|
133
|
+
console.log("đŠ" + red.underline.bold(` => Error: ${orange(e.message)}`));
|
133
134
|
this.emit('end');
|
134
135
|
})
|
135
136
|
.on('end', function () {
|
package/dist/gulp/clean.js
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
import gulp from 'gulp';
|
2
2
|
import clean from 'gulp-clean';
|
3
|
-
import { blue, red } from '../index.js';
|
3
|
+
import { blue, orange, red } from '../index.js';
|
4
4
|
export function cleanWix() {
|
5
5
|
return () => {
|
6
6
|
return gulp.src('./.wix', { read: false, allowEmpty: true })
|
7
7
|
.pipe(clean({ force: true }))
|
8
|
-
.on('error', function () {
|
8
|
+
.on('error', function (e) {
|
9
9
|
console.log("đŠ" + red.underline.bold(' => Cleaning of .wix failed!'));
|
10
|
+
console.log("đŠ" + red.underline.bold(` => Error: ${orange(e.message)}`));
|
10
11
|
this.emit('end');
|
11
12
|
})
|
12
13
|
.on('end', function () { console.log("đļ" + blue.underline(' => Cleaning of .wix succeeded!')); });
|
@@ -17,8 +18,9 @@ export function cleanSrc(options) {
|
|
17
18
|
return () => {
|
18
19
|
return gulp.src([`${outputDir}/pages`, `${outputDir}/public`, `${outputDir}/backend`], { read: false, allowEmpty: true })
|
19
20
|
.pipe(clean({ force: true }))
|
20
|
-
.on('error', function () {
|
21
|
+
.on('error', function (e) {
|
21
22
|
console.log("đŠ" + red.underline.bold('Cleaning of output files failed!'));
|
23
|
+
console.log("đŠ" + red.underline.bold(` => Error: ${orange(e.message)}`));
|
22
24
|
this.emit('end');
|
23
25
|
})
|
24
26
|
.on('end', function () { console.log("đļ" + blue.underline(' => Cleaning of .src succeeded!')); });
|
package/dist/gulp/copy.js
CHANGED
@@ -21,8 +21,9 @@ export function copyFiles(options) {
|
|
21
21
|
`!${folder}/styles/**`,
|
22
22
|
])
|
23
23
|
.pipe(gulp.dest(outputDir))
|
24
|
-
.on('error', function () {
|
24
|
+
.on('error', function (e) {
|
25
25
|
console.log("đŠ" + red.underline.bold(` => Copy of files for ${orange(folder)} failed!`));
|
26
|
+
console.log("đŠ" + red.underline.bold(` => Error: ${orange(e.message)}`));
|
26
27
|
this.emit('end');
|
27
28
|
})
|
28
29
|
.on('end', function () {
|
package/dist/gulp/pages.d.ts
CHANGED
@@ -1,2 +1,2 @@
|
|
1
1
|
import { TaskOptions } from '../Gulpfile';
|
2
|
-
export declare function buildPages(options: TaskOptions): () =>
|
2
|
+
export declare function buildPages(options: TaskOptions): () => any;
|
package/dist/gulp/pages.js
CHANGED
@@ -1,21 +1,30 @@
|
|
1
1
|
import gulp from 'gulp';
|
2
|
-
import { createGulpEsbuild } from 'gulp-esbuild';
|
3
2
|
import * as path from 'path';
|
4
|
-
import { blue, red } from '../index.js';
|
3
|
+
import { blue, orange, red } from '../index.js';
|
4
|
+
import swc from 'gulp-swc';
|
5
|
+
const swcOptions = {
|
6
|
+
jsc: {
|
7
|
+
target: 'es2020',
|
8
|
+
parser: {
|
9
|
+
syntax: "typescript",
|
10
|
+
tsx: true,
|
11
|
+
},
|
12
|
+
},
|
13
|
+
};
|
5
14
|
export function buildPages(options) {
|
6
|
-
const { outputDir
|
7
|
-
const gulpEsbuild = createGulpEsbuild({
|
8
|
-
incremental: enableIncrementalBuild, // enables the esbuild's incremental build
|
9
|
-
pipe: true, // enables the esbuild's pipe mode
|
10
|
-
});
|
15
|
+
const { outputDir } = options;
|
11
16
|
return () => {
|
12
17
|
return gulp.src('typescript/pages/*.ts')
|
13
|
-
.pipe(
|
14
|
-
|
15
|
-
|
18
|
+
.pipe(swc(swcOptions))
|
19
|
+
.on('error', function (e) {
|
20
|
+
console.log("đŠ" + red.underline.bold(` => Build of Pages files failed!`));
|
21
|
+
console.log("đŠ" + red.underline.bold(` => Error: ${orange(e.message)}`));
|
22
|
+
this.emit('end');
|
23
|
+
})
|
16
24
|
.pipe(gulp.dest(path.join(outputDir, 'pages')))
|
17
|
-
.on('error', function () {
|
25
|
+
.on('error', function (e) {
|
18
26
|
console.log("đŠ" + red.underline.bold(' => Build of Pages TS files failed!'));
|
27
|
+
console.log("đŠ" + red.underline.bold(` => Error: ${orange(e.message)}`));
|
19
28
|
this.emit('end');
|
20
29
|
})
|
21
30
|
.on('end', function () { console.log("đļ" + blue.underline(' => Build of Pages TS files succeeded!')); });
|
package/dist/gulp/pipeline.js
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
import gulp from 'gulp';
|
2
2
|
import * as path from 'path';
|
3
3
|
import replace from 'gulp-string-replace';
|
4
|
-
import { blue, red } from '../index.js';
|
4
|
+
import { blue, orange, red } from '../index.js';
|
5
5
|
export function setProdConfig() {
|
6
6
|
const tag = process.env.GIT_TAG || 'development';
|
7
7
|
const regexGit = /gitTag:\s*(.*),/g;
|
@@ -16,8 +16,9 @@ export function setProdConfig() {
|
|
16
16
|
const outputDir = path.dirname(filePath);
|
17
17
|
return path.join(`${outputDir}/constants`);
|
18
18
|
}))
|
19
|
-
.on('error', function () {
|
19
|
+
.on('error', function (e) {
|
20
20
|
console.log("đŠ" + red.underline.bold(' => Setting the git tag failed!'));
|
21
|
+
console.log("đŠ" + red.underline.bold(` => Error: ${orange(e.message)}`));
|
21
22
|
this.emit('end');
|
22
23
|
})
|
23
24
|
.on('end', function () {
|
package/dist/gulp/public.js
CHANGED
@@ -1,7 +1,16 @@
|
|
1
1
|
import gulp from 'gulp';
|
2
|
-
import { createGulpEsbuild } from 'gulp-esbuild';
|
3
2
|
import * as path from 'path';
|
4
3
|
import { blue, orange, red } from '../index.js';
|
4
|
+
import swc from 'gulp-swc';
|
5
|
+
const swcOptions = {
|
6
|
+
jsc: {
|
7
|
+
target: 'es2020',
|
8
|
+
parser: {
|
9
|
+
syntax: "typescript",
|
10
|
+
tsx: true,
|
11
|
+
},
|
12
|
+
},
|
13
|
+
};
|
5
14
|
export function buildPublic(options) {
|
6
15
|
const folders = ['typescript'];
|
7
16
|
if (options.modulesSync) {
|
@@ -9,11 +18,7 @@ export function buildPublic(options) {
|
|
9
18
|
folders.push(module);
|
10
19
|
}
|
11
20
|
}
|
12
|
-
const { outputDir
|
13
|
-
const gulpEsbuild = createGulpEsbuild({
|
14
|
-
incremental: enableIncrementalBuild,
|
15
|
-
pipe: true,
|
16
|
-
});
|
21
|
+
const { outputDir } = options;
|
17
22
|
// Create tasks for each folder
|
18
23
|
const tasks = folders.map((folder) => {
|
19
24
|
const taskName = `build_Public-${folder}`; // Create a unique name for each task
|
@@ -21,15 +26,16 @@ export function buildPublic(options) {
|
|
21
26
|
`${folder}/public/**/*.ts`,
|
22
27
|
`${folder}/public/**/*.tsx`,
|
23
28
|
])
|
24
|
-
.pipe(
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
})
|
29
|
+
.pipe(swc(swcOptions))
|
30
|
+
.on('error', function (e) {
|
31
|
+
console.log("đŠ" + red.underline.bold(` => Build of Public files for ${orange(folder)} failed!`));
|
32
|
+
console.log("đŠ" + red.underline.bold(` => Error: ${orange(e.message)}`));
|
33
|
+
this.emit('end');
|
34
|
+
})
|
30
35
|
.pipe(gulp.dest(path.join(outputDir, 'public')))
|
31
|
-
.on('error', function () {
|
36
|
+
.on('error', function (e) {
|
32
37
|
console.log("đŠ" + red.underline.bold(` => Build of Public files for ${orange(folder)} failed!`));
|
38
|
+
console.log("đŠ" + red.underline.bold(` => Error: ${orange(e.message)}`));
|
33
39
|
this.emit('end');
|
34
40
|
})
|
35
41
|
.on('end', function () {
|
package/dist/gulp/styles.js
CHANGED
@@ -13,9 +13,15 @@ export function compileScss(options) {
|
|
13
13
|
const taskName = `compile_sass-${folder}`; // Create a unique name for each task
|
14
14
|
const task = () => gulp.src(['typescript/styles/global.scss'])
|
15
15
|
.pipe(sass().on('error', sass.logError))
|
16
|
+
.on('error', function (e) {
|
17
|
+
console.log("đŠ" + red.underline.bold(` => Build of SCSS files for ${orange(folder)} failed!`));
|
18
|
+
console.log("đŠ" + red.underline.bold(` => Error: ${orange(e.message)}`));
|
19
|
+
this.emit('end');
|
20
|
+
})
|
16
21
|
.pipe(gulp.dest(`${outputDir}/styles`))
|
17
|
-
.on('error', function () {
|
22
|
+
.on('error', function (e) {
|
18
23
|
console.log("đŠ" + red.underline.bold(` => Compiling of scss files for ${orange(folder)} failed!`));
|
24
|
+
console.log("đŠ" + red.underline.bold(` => Error: ${orange(e.message)}`));
|
19
25
|
this.emit('end');
|
20
26
|
})
|
21
27
|
.on('end', function () {
|
package/dist/gulp/templates.js
CHANGED
@@ -20,8 +20,9 @@ export function previewTemplates(options) {
|
|
20
20
|
`!${folder}/backend/templates/render.ts`,
|
21
21
|
])
|
22
22
|
.pipe(exec((file) => `npx ts-node-esm -T ${file.path}`, taskOpt))
|
23
|
-
.on('error', function () {
|
23
|
+
.on('error', function (e) {
|
24
24
|
console.log("đŠ" + red.underline.bold(` => Render of Template for ${orange(folder)} failed!`));
|
25
|
+
console.log("đŠ" + red.underline.bold(` => Error: ${orange(e.message)}`));
|
25
26
|
this.emit('end');
|
26
27
|
})
|
27
28
|
.on('end', function () {
|
package/dist/gulp/test.js
CHANGED
@@ -40,8 +40,9 @@ export function test(options) {
|
|
40
40
|
'public/(.*)': '<rootDir>/public/$1'
|
41
41
|
}
|
42
42
|
}))
|
43
|
-
.on('error', function () {
|
43
|
+
.on('error', function (e) {
|
44
44
|
console.log("đŠ" + red.underline.bold(` => Tests for ${orange(folder)} failed!`));
|
45
|
+
console.log("đŠ" + red.underline.bold(` => Error: ${orange(e.message)}`));
|
45
46
|
this.emit('end');
|
46
47
|
})
|
47
48
|
.on('end', function () {
|
package/dist/gulp/types.js
CHANGED
@@ -5,7 +5,7 @@ import flatmap from 'gulp-flatmap';
|
|
5
5
|
import jeditor from 'gulp-json-editor';
|
6
6
|
import merge from 'merge-stream';
|
7
7
|
import * as insert from 'gulp-insert';
|
8
|
-
import { blue, red, yellow } from '../index.js';
|
8
|
+
import { blue, orange, red, yellow } from '../index.js';
|
9
9
|
import tap from 'gulp-tap';
|
10
10
|
export function updateWixTypes(options) {
|
11
11
|
return () => {
|
@@ -141,7 +141,7 @@ export function updateWixTypes(options) {
|
|
141
141
|
}))
|
142
142
|
.on('error', function (e) {
|
143
143
|
console.log("đŠ" + red.underline.bold('Modification of WIX configs failed!'));
|
144
|
-
console.
|
144
|
+
console.log("đŠ" + red.underline.bold(` => Error: ${orange(e.message)}`));
|
145
145
|
this.emit('end');
|
146
146
|
})
|
147
147
|
.on('end', function () { console.log("đļ" + blue.underline(`Modification of ${yellow(count)} WIX configs succeeded!`)); });
|
@@ -168,8 +168,8 @@ export function addTypes(options, done) {
|
|
168
168
|
.pipe(gulp.dest('./.wix/types/wix-code-types/dist/types/common/'));
|
169
169
|
return merge(processPages, processCommon, exportTypesBeta, exportTypes)
|
170
170
|
.on('error', function (e) {
|
171
|
-
console.error(e);
|
172
171
|
console.log("đŠ" + red.underline.bold(' => Updating WIX failed!'));
|
172
|
+
console.log("đŠ" + red.underline.bold(` => Error: ${orange(e.message)}`));
|
173
173
|
this.emit('end');
|
174
174
|
done();
|
175
175
|
})
|
package/dist/helpers.d.ts
CHANGED
@@ -5,4 +5,9 @@ export declare function runGulp(moduleSettings: ModuleSettings, projectSettings:
|
|
5
5
|
/**
|
6
6
|
* Clean up and run a command before exiting the process.
|
7
7
|
*/
|
8
|
-
export declare function
|
8
|
+
export declare function cleanupWatchers(): void;
|
9
|
+
/**
|
10
|
+
* Kill all processes matching a specific substring in their command, with a fallback for Windows.
|
11
|
+
* @param {string} processPattern - The substring to match (e.g., "wix:dev" or "@wix/cli/bin/wix.cjs").
|
12
|
+
*/
|
13
|
+
export declare function killAllProcesses(processPattern: string): void;
|
package/dist/helpers.js
CHANGED
@@ -5,7 +5,8 @@ import { spawnSync } from 'child_process';
|
|
5
5
|
import path from 'path';
|
6
6
|
import { fileURLToPath } from 'url';
|
7
7
|
import { exec } from 'child_process';
|
8
|
-
import
|
8
|
+
import os from 'os';
|
9
|
+
import { blue, green, orange, red, yellow, magenta } from './index.js';
|
9
10
|
export async function installPackages(wixPackages, devPackages, cwd, locked) {
|
10
11
|
if (locked)
|
11
12
|
console.log("đ" + blue.underline(` => Installing & version locked packages!`));
|
@@ -71,18 +72,83 @@ export async function runGulp(moduleSettings, projectSettings, task) {
|
|
71
72
|
/**
|
72
73
|
* Clean up and run a command before exiting the process.
|
73
74
|
*/
|
74
|
-
export function
|
75
|
+
export function cleanupWatchers() {
|
76
|
+
console.log(`đ§š ${magenta.underline('Cleaning up Watchman watchers...')}`);
|
75
77
|
const cwd = process.cwd();
|
76
|
-
const command = `watchman watch-del
|
77
|
-
console.log("đ" + blue.underline(' => Cleaning up...'));
|
78
|
+
const command = `watchman watch-del "${cwd}"`; // Adjust for Windows paths
|
78
79
|
exec(command, (error, stdout, stderr) => {
|
79
80
|
if (error) {
|
80
|
-
console.error(`đŠ Failed to run cleanup: ${error.message}`);
|
81
|
+
console.error(`đŠ ${red.underline('Failed to run cleanup:')} ${orange(error.message)}`);
|
81
82
|
return;
|
82
83
|
}
|
83
84
|
if (stderr) {
|
84
|
-
console.error(`â ī¸
|
85
|
+
console.error(`â ī¸ ${yellow.underline('Watchman stderr:')} ${stderr}`);
|
85
86
|
}
|
86
|
-
console.log(`â
Watchman cleanup success: ${stdout}`);
|
87
|
+
console.log(`â
${green.underline('Watchman cleanup success:')} ${stdout}`);
|
88
|
+
});
|
89
|
+
}
|
90
|
+
/**
|
91
|
+
* Kill all processes matching a specific substring in their command, with a fallback for Windows.
|
92
|
+
* @param {string} processPattern - The substring to match (e.g., "wix:dev" or "@wix/cli/bin/wix.cjs").
|
93
|
+
*/
|
94
|
+
export function killAllProcesses(processPattern) {
|
95
|
+
const isWindows = os.platform() === 'win32';
|
96
|
+
const command = isWindows
|
97
|
+
? `tasklist /FI "IMAGENAME eq node.exe" /FO CSV | findstr "${processPattern}"` // Adjust for Node.js processes
|
98
|
+
: `ps -eo pid,command | grep "${processPattern}" | grep -v grep`;
|
99
|
+
exec(command, (error, stdout, stderr) => {
|
100
|
+
if (error) {
|
101
|
+
console.error(`đŠ ${red.underline('Failed to find processes:')} ${orange(error.message)}`);
|
102
|
+
return;
|
103
|
+
}
|
104
|
+
if (stderr) {
|
105
|
+
console.error(`â ī¸ ${yellow.underline('Error output:')} ${stderr}`);
|
106
|
+
}
|
107
|
+
if (!stdout.trim()) {
|
108
|
+
console.log(`âšī¸ ${blue.underline(`No processes found matching pattern:`)} ${orange(processPattern)}`);
|
109
|
+
return;
|
110
|
+
}
|
111
|
+
console.log(`đ ${magenta.underline('Found matching processes:')}\n${stdout}`);
|
112
|
+
const lines = stdout.trim().split('\n');
|
113
|
+
const pids = isWindows
|
114
|
+
? lines.map(line => line.match(/"(\d+)"/)?.[1]) // Extract PID from Windows tasklist output
|
115
|
+
: lines.map(line => line.trim().split(/\s+/)[0]).filter(pid => !isNaN(Number(pid)));
|
116
|
+
pids.forEach(pid => {
|
117
|
+
if (!pid)
|
118
|
+
return;
|
119
|
+
try {
|
120
|
+
const killCommand = isWindows
|
121
|
+
? `taskkill /PID ${pid} /T /F` // Forcefully terminate the process on Windows
|
122
|
+
: `kill -SIGTERM ${pid}`;
|
123
|
+
exec(killCommand, (killError) => {
|
124
|
+
if (killError) {
|
125
|
+
console.error(`â ī¸ ${yellow.underline('Failed to kill process with PID')} ${orange(pid)}: ${red(killError.message)}`);
|
126
|
+
}
|
127
|
+
else {
|
128
|
+
console.log(`â
${green.underline('Killed process with PID:')} ${orange(pid)}`);
|
129
|
+
}
|
130
|
+
});
|
131
|
+
// Schedule SIGKILL fallback for non-Windows platforms
|
132
|
+
if (!isWindows) {
|
133
|
+
setTimeout(() => {
|
134
|
+
try {
|
135
|
+
process.kill(parseInt(pid, 10), 'SIGKILL');
|
136
|
+
console.log(`đĒ ${red.underline('Sent SIGKILL to process with PID:')} ${orange(pid)} (fallback).`);
|
137
|
+
}
|
138
|
+
catch (killError) {
|
139
|
+
if (killError.code === 'ESRCH') {
|
140
|
+
console.log(`â
${green.underline('Process with PID')} ${orange(pid)} ${green.underline('already terminated.')}`);
|
141
|
+
}
|
142
|
+
else {
|
143
|
+
console.error(`â ī¸ ${yellow.underline('Failed to send SIGKILL to process with PID')} ${orange(pid)}: ${red(killError.message)}`);
|
144
|
+
}
|
145
|
+
}
|
146
|
+
}, 10000);
|
147
|
+
}
|
148
|
+
}
|
149
|
+
catch (err) {
|
150
|
+
console.error(`â ī¸ ${yellow.underline('Failed to kill process with PID')} ${orange(pid)}: ${red(err.message)}`);
|
151
|
+
}
|
152
|
+
});
|
87
153
|
});
|
88
154
|
}
|
package/dist/index.js
CHANGED
@@ -9,7 +9,7 @@ import { join } from 'path';
|
|
9
9
|
import fs from 'fs/promises';
|
10
10
|
import { init } from './init.js';
|
11
11
|
import { sync } from './sync.js';
|
12
|
-
import { runGulp, installPackages,
|
12
|
+
import { runGulp, installPackages, killAllProcesses, cleanupWatchers } from './helpers.js';
|
13
13
|
import { prepare } from './prepare.js';
|
14
14
|
import { spawnSync } from 'child_process';
|
15
15
|
export const orange = chalk.hex('#FFA500');
|
@@ -22,10 +22,45 @@ export const magenta = chalk.magentaBright;
|
|
22
22
|
const __filename = fileURLToPath(import.meta.url);
|
23
23
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
24
24
|
const __dirname = dirname(__filename);
|
25
|
+
// const cwd = process.cwd();
|
26
|
+
// const command = `watchman watch-del '${cwd}'`;
|
27
|
+
// killAllProcesses('@wix/cli/bin/wix.cjs'); // Matches processes running the Wix CLI
|
28
|
+
// killAllProcesses('wix:dev');
|
29
|
+
process.on('exit', (code) => {
|
30
|
+
killAllProcesses('@wix/cli/bin/wix.cjs'); // Matches processes running the Wix CLI
|
31
|
+
killAllProcesses('wix:dev');
|
32
|
+
cleanupWatchers();
|
33
|
+
console.log(`đĒ ${magenta.underline('Process exiting with code:')} ${orange(code)}`);
|
34
|
+
});
|
25
35
|
process.on('SIGINT', () => {
|
26
|
-
console.log(
|
27
|
-
|
28
|
-
|
36
|
+
console.log(`đ ${green.underline('Received Ctrl+C (SIGINT), cleaning up...')}`);
|
37
|
+
killAllProcesses('@wix/cli/bin/wix.cjs'); // Matches processes running the Wix CLI
|
38
|
+
killAllProcesses('wix:dev');
|
39
|
+
cleanupWatchers();
|
40
|
+
process.exit(); // Exit explicitly after handling
|
41
|
+
});
|
42
|
+
process.on('SIGTERM', () => {
|
43
|
+
console.log(`đ ${red.underline('Received termination signal (SIGTERM), cleaning up...')}`);
|
44
|
+
killAllProcesses('@wix/cli/bin/wix.cjs'); // Matches processes running the Wix CLI
|
45
|
+
killAllProcesses('wix:dev');
|
46
|
+
cleanupWatchers();
|
47
|
+
process.exit(); // Exit explicitly after handling
|
48
|
+
});
|
49
|
+
process.on('uncaughtException', (error) => {
|
50
|
+
console.error(`đĨ ${red.underline('Uncaught Exception:')}`, error);
|
51
|
+
killAllProcesses('@wix/cli/bin/wix.cjs'); // Matches processes running the Wix CLI
|
52
|
+
killAllProcesses('wix:dev');
|
53
|
+
cleanupWatchers();
|
54
|
+
process.exit(1); // Exit with an error code
|
55
|
+
});
|
56
|
+
process.on('unhandledRejection', (reason, promise) => {
|
57
|
+
console.error(`đ¨ ${yellow.underline('Unhandled Rejection at:')} ${orange(promise)}`);
|
58
|
+
console.error(`đ¨ ${red.underline('Reason:')} ${reason}`);
|
59
|
+
cleanupWatchers();
|
60
|
+
killAllProcesses('@wix/cli/bin/wix.cjs'); // Matches processes running the Wix CLI
|
61
|
+
killAllProcesses('wix:dev');
|
62
|
+
cleanupWatchers();
|
63
|
+
process.exit(1); // Exit with an error code
|
29
64
|
});
|
30
65
|
/**
|
31
66
|
* Main function
|
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"type": "module",
|
3
3
|
"name": "lucy-cli",
|
4
|
-
"version": "0.
|
4
|
+
"version": "0.9.0",
|
5
5
|
"description": "Lucy Framework for WIX Studio Editor",
|
6
6
|
"main": ".dist/index.js",
|
7
7
|
"scripts": {
|
@@ -32,6 +32,7 @@
|
|
32
32
|
"registry": "https://registry.npmjs.org"
|
33
33
|
},
|
34
34
|
"dependencies": {
|
35
|
+
"@swc/core": "^1.9.3",
|
35
36
|
"@wix/cli": "^1.0.83",
|
36
37
|
"@wix/eslint-plugin-cli": "^1.0.1",
|
37
38
|
"chalk": "^5.3.0",
|
@@ -41,20 +42,21 @@
|
|
41
42
|
"gulp-clean": "^0.4.0",
|
42
43
|
"gulp-cli": "3.0.0",
|
43
44
|
"gulp-concat": "^2.6.1",
|
44
|
-
"gulp-esbuild": "0.12.1",
|
45
45
|
"gulp-exec": "^5.0.0",
|
46
46
|
"gulp-flatmap": "^1.0.2",
|
47
47
|
"gulp-if": "^3.0.0",
|
48
48
|
"gulp-insert": "^0.5.0",
|
49
49
|
"gulp-jest": "^4.0.4",
|
50
50
|
"gulp-json-editor": "2.6.0",
|
51
|
+
"gulp-plumber": "^1.2.1",
|
51
52
|
"gulp-rename": "^2.0.0",
|
52
53
|
"gulp-sass": "^5.1.0",
|
53
54
|
"gulp-shell": "^0.8.0",
|
54
55
|
"gulp-string-replace": "^1.1.2",
|
56
|
+
"gulp-swc": "^2.2.0",
|
55
57
|
"gulp-tap": "^2.0.0",
|
56
58
|
"gulp-typedoc": "^3.0.2",
|
57
|
-
"gulp-typescript": "
|
59
|
+
"gulp-typescript": "5.0.1",
|
58
60
|
"gulp-wait": "^0.0.2",
|
59
61
|
"jest": "^29.7.0",
|
60
62
|
"merge-stream": "^2.0.0",
|
@@ -75,6 +77,7 @@
|
|
75
77
|
"@types/gulp-concat": "^0.0.37",
|
76
78
|
"@types/gulp-insert": "^0.5.13",
|
77
79
|
"@types/gulp-json-editor": "^2.2.36",
|
80
|
+
"@types/gulp-plumber": "^0.0.37",
|
78
81
|
"@types/gulp-rename": "^2.0.6",
|
79
82
|
"@types/gulp-sass": "^5.0.4",
|
80
83
|
"@types/gulp-tap": "^1.0.5",
|
@@ -84,13 +87,12 @@
|
|
84
87
|
"@typescript-eslint/eslint-plugin": "8.14.0",
|
85
88
|
"@typescript-eslint/parser": "8.14.0",
|
86
89
|
"@typescript-eslint/utils": "8.14.0",
|
87
|
-
"esbuild": "0.24.0",
|
88
90
|
"eslint": "9.14.0",
|
89
91
|
"eslint-plugin-import": "^2.27.5",
|
90
92
|
"eslint-plugin-jsdoc": "50.5.0",
|
91
93
|
"eslint-plugin-named-import-spacing": "^1.0.3",
|
92
94
|
"eslint-plugin-simple-import-sort": "12.1.1",
|
93
95
|
"ts-node": "^10.9.1",
|
94
|
-
"typescript": "^5.
|
96
|
+
"typescript": "^5.6.3"
|
95
97
|
}
|
96
98
|
}
|
package/src/Gulpfile.ts
CHANGED
@@ -133,7 +133,7 @@ gulp.task('fix-wix', gulp.series(
|
|
133
133
|
gulp.task('build', gulp.parallel(
|
134
134
|
'build-backend',
|
135
135
|
'build-public',
|
136
|
-
buildPages(taskOptions),
|
136
|
+
buildPages(taskOptions),
|
137
137
|
compileScss(taskOptions),
|
138
138
|
'copy-files'
|
139
139
|
)
|
@@ -196,6 +196,10 @@ export async function runTask(task: string, moduleSettings: ModuleSettings, proj
|
|
196
196
|
taskOptions.moduleSettings = moduleSettings;
|
197
197
|
taskOptions.projectSettings = projectSettings;
|
198
198
|
console.log("đ" + magenta.underline(' => Starting Task => ' + orange(task)));
|
199
|
+
try {
|
199
200
|
await gulpTaskRunner(task);
|
201
|
+
} catch (err) {
|
202
|
+
console.log((`đŠ ${red.underline.bold("=> Error starting tasks =>")} ${orange(err)}`));
|
203
|
+
}
|
200
204
|
console.log("đļ" + green.underline.bold(' => Task completed: ' + task));
|
201
205
|
}
|
package/src/gulp/backend.ts
CHANGED
@@ -1,9 +1,20 @@
|
|
1
1
|
import gulp from 'gulp';
|
2
|
-
import { createGulpEsbuild } from 'gulp-esbuild';
|
3
2
|
import rename from 'gulp-rename';
|
4
3
|
import * as path from 'path';
|
5
4
|
import { TaskOptions } from '../Gulpfile';
|
6
5
|
import { blue, orange, red } from '../index.js';
|
6
|
+
import swc from 'gulp-swc';
|
7
|
+
import { cond } from 'cypress/types/lodash';
|
8
|
+
|
9
|
+
const swcOptions = {
|
10
|
+
jsc: {
|
11
|
+
target: 'es2020',
|
12
|
+
parser: {
|
13
|
+
syntax: "typescript",
|
14
|
+
tsx: true,
|
15
|
+
},
|
16
|
+
},
|
17
|
+
};
|
7
18
|
|
8
19
|
export function buildBackend(options: TaskOptions) {
|
9
20
|
const folders = ['typescript'];
|
@@ -13,11 +24,7 @@ export function buildBackend(options: TaskOptions) {
|
|
13
24
|
}
|
14
25
|
}
|
15
26
|
|
16
|
-
const { outputDir
|
17
|
-
const gulpEsbuild = createGulpEsbuild({
|
18
|
-
incremental: enableIncrementalBuild,
|
19
|
-
pipe: true,
|
20
|
-
});
|
27
|
+
const { outputDir } = options;
|
21
28
|
|
22
29
|
// Create tasks for each folder
|
23
30
|
const tasks = folders.map((folder) => {
|
@@ -30,14 +37,17 @@ export function buildBackend(options: TaskOptions) {
|
|
30
37
|
`!${folder}/backend/**/*.jsw.ts`,
|
31
38
|
`!${folder}/backend/**/*.spec.ts`,
|
32
39
|
])
|
33
|
-
.pipe(
|
34
|
-
|
35
|
-
|
36
|
-
})
|
37
|
-
|
40
|
+
.pipe(swc(swcOptions))
|
41
|
+
.pipe(swc(swcOptions))
|
42
|
+
.on('error', function (e: Error) {
|
43
|
+
console.log("đŠ" + red.underline.bold(` => Build of Backend files for ${orange(folder)} failed!`));
|
44
|
+
console.log("đŠ" + red.underline.bold(` => Error: ${orange(e.message)}`));
|
45
|
+
this.emit('end');
|
46
|
+
})
|
38
47
|
.pipe(gulp.dest(path.join(outputDir, 'backend')))
|
39
|
-
.on('error', function () {
|
48
|
+
.on('error', function (e: Error) {
|
40
49
|
console.log("đŠ" + red.underline.bold(` => Build of Backend files for ${orange(folder)} failed!`));
|
50
|
+
console.log("đŠ" + red.underline.bold(` => Error: ${orange(e.message)}`));
|
41
51
|
this.emit('end');
|
42
52
|
})
|
43
53
|
.on('end', function () {
|
@@ -61,12 +71,12 @@ export function buildBackendJSW(options: TaskOptions) {
|
|
61
71
|
folders.push(module);
|
62
72
|
}
|
63
73
|
}
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
}
|
74
|
+
const swcOptions = {
|
75
|
+
jsc: {
|
76
|
+
target: 'es6',
|
77
|
+
},
|
78
|
+
};
|
79
|
+
const { outputDir } = options;
|
70
80
|
|
71
81
|
// Create tasks for each folder
|
72
82
|
const tasks = folders.map((folder) => {
|
@@ -76,20 +86,22 @@ export function buildBackendJSW(options: TaskOptions) {
|
|
76
86
|
gulp.src([
|
77
87
|
`${folder}/backend/**/*.jsw.ts`,
|
78
88
|
])
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
)
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
})
|
90
|
-
.
|
91
|
-
|
92
|
-
|
89
|
+
.pipe(swc(swcOptions))
|
90
|
+
.on('error', function (e: Error) {
|
91
|
+
console.log("đŠ" + red.underline.bold(` => Build of Public files for ${orange(folder)} failed!`));
|
92
|
+
console.log("đŠ" + red.underline.bold(` => Error: ${orange(e.message)}`));
|
93
|
+
this.emit('end');
|
94
|
+
})
|
95
|
+
.pipe(rename({ extname: '' }))
|
96
|
+
.pipe(gulp.dest(path.join(outputDir, 'backend')))
|
97
|
+
.on('error', function (e: Error) {
|
98
|
+
console.log("đŠ" + red.underline.bold(` => Build of JSW files for ${orange(folder)} failed!`));
|
99
|
+
console.log("đŠ" + red.underline.bold(` => Error: ${orange(e.message)}`));
|
100
|
+
this.emit('end');
|
101
|
+
})
|
102
|
+
.on('end', function () {
|
103
|
+
console.log("đļ" + blue.underline(` => Build of JSW files for ${orange(folder)} succeeded!`));
|
104
|
+
});
|
93
105
|
|
94
106
|
// Register the task with Gulp
|
95
107
|
Object.defineProperty(task, 'name', { value: taskName }); // Set a unique name for debugging
|
package/src/gulp/checks.ts
CHANGED
@@ -136,8 +136,9 @@ export function checkTs(options: TaskOptions) {
|
|
136
136
|
const task = () =>
|
137
137
|
gulp.src([`${folder}/**/*.ts`, `!${folder}/types/**/*.ts`], { cwd: folder })
|
138
138
|
.pipe(tsProject(ts.reporter.fullReporter()))
|
139
|
-
.on('error', function () {
|
139
|
+
.on('error', function (e: Error) {
|
140
140
|
console.log("đŠ" + red.underline.bold(` => Typescriptcheck for ${orange(folder)} failed!`));
|
141
|
+
console.log("đŠ" + red.underline.bold(` => Error: ${orange(e.message)}`));
|
141
142
|
this.emit('end');
|
142
143
|
})
|
143
144
|
.on('end', function () {
|
package/src/gulp/clean.ts
CHANGED
@@ -2,14 +2,15 @@ import chalk from 'chalk';
|
|
2
2
|
import gulp from 'gulp';
|
3
3
|
import { TaskOptions } from '../Gulpfile';
|
4
4
|
import clean from 'gulp-clean';
|
5
|
-
import { blue, red } from '../index.js';
|
5
|
+
import { blue, orange, red } from '../index.js';
|
6
6
|
|
7
7
|
export function cleanWix() {
|
8
8
|
return () => {
|
9
9
|
return gulp.src('./.wix', { read: false, allowEmpty: true })
|
10
10
|
.pipe(clean({ force: true }))
|
11
|
-
.on('error', function () {
|
11
|
+
.on('error', function (e: Error) {
|
12
12
|
console.log("đŠ" + red.underline.bold(' => Cleaning of .wix failed!'));
|
13
|
+
console.log("đŠ" + red.underline.bold(` => Error: ${orange(e.message)}`));
|
13
14
|
this.emit('end');
|
14
15
|
})
|
15
16
|
.on('end', function() { console.log("đļ" + blue.underline(' => Cleaning of .wix succeeded!')); });
|
@@ -22,8 +23,9 @@ export function cleanSrc(options: TaskOptions) {
|
|
22
23
|
return () => {
|
23
24
|
return gulp.src([`${outputDir}/pages`, `${outputDir}/public`, `${outputDir}/backend`], { read: false, allowEmpty: true })
|
24
25
|
.pipe(clean({ force: true }))
|
25
|
-
.on('error', function () {
|
26
|
+
.on('error', function (e: Error) {
|
26
27
|
console.log("đŠ" + red.underline.bold('Cleaning of output files failed!'));
|
28
|
+
console.log("đŠ" + red.underline.bold(` => Error: ${orange(e.message)}`));
|
27
29
|
this.emit('end');
|
28
30
|
})
|
29
31
|
.on('end', function() { console.log("đļ" + blue.underline(' => Cleaning of .src succeeded!')); });
|
package/src/gulp/copy.ts
CHANGED
@@ -28,8 +28,9 @@ export function copyFiles(options: TaskOptions) {
|
|
28
28
|
`!${folder}/styles/**`,
|
29
29
|
])
|
30
30
|
.pipe(gulp.dest(outputDir))
|
31
|
-
.on('error', function () {
|
31
|
+
.on('error', function (e: Error) {
|
32
32
|
console.log("đŠ" + red.underline.bold(` => Copy of files for ${orange(folder)} failed!`));
|
33
|
+
console.log("đŠ" + red.underline.bold(` => Error: ${orange(e.message)}`));
|
33
34
|
this.emit('end');
|
34
35
|
})
|
35
36
|
.on('end', function () {
|
package/src/gulp/pages.ts
CHANGED
@@ -1,26 +1,36 @@
|
|
1
1
|
import gulp from 'gulp';
|
2
2
|
import { TaskOptions } from '../Gulpfile';
|
3
|
-
import { createGulpEsbuild } from 'gulp-esbuild';
|
4
3
|
import * as path from 'path';
|
5
|
-
import { blue, red } from '../index.js';
|
4
|
+
import { blue, orange, red } from '../index.js';
|
5
|
+
import swc from 'gulp-swc';
|
6
|
+
|
7
|
+
const swcOptions = {
|
8
|
+
jsc: {
|
9
|
+
target: 'es2020',
|
10
|
+
parser: {
|
11
|
+
syntax: "typescript",
|
12
|
+
tsx: true,
|
13
|
+
},
|
14
|
+
},
|
15
|
+
};
|
6
16
|
|
7
17
|
export function buildPages(options: TaskOptions) {
|
8
|
-
const { outputDir
|
9
|
-
const gulpEsbuild = createGulpEsbuild({
|
10
|
-
incremental: enableIncrementalBuild, // enables the esbuild's incremental build
|
11
|
-
pipe: true, // enables the esbuild's pipe mode
|
12
|
-
});
|
18
|
+
const { outputDir} = options;
|
13
19
|
|
14
20
|
return () => {
|
15
21
|
return gulp.src('typescript/pages/*.ts')
|
16
|
-
.pipe(
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
22
|
+
.pipe(swc(swcOptions))
|
23
|
+
.on('error', function (e: Error) {
|
24
|
+
console.log("đŠ" + red.underline.bold(` => Build of Pages files failed!`));
|
25
|
+
console.log("đŠ" + red.underline.bold(` => Error: ${orange(e.message)}`));
|
26
|
+
this.emit('end');
|
27
|
+
})
|
28
|
+
.pipe(gulp.dest(path.join(outputDir, 'pages')))
|
29
|
+
.on('error', function (e: Error) {
|
30
|
+
console.log("đŠ" + red.underline.bold(' => Build of Pages TS files failed!'));
|
31
|
+
console.log("đŠ" + red.underline.bold(` => Error: ${orange(e.message)}`));
|
32
|
+
this.emit('end');
|
33
|
+
})
|
34
|
+
.on('end', function() { console.log("đļ" + blue.underline(' => Build of Pages TS files succeeded!')); });
|
25
35
|
};
|
26
36
|
}
|
package/src/gulp/pipeline.ts
CHANGED
@@ -2,7 +2,7 @@ import gulp from 'gulp';
|
|
2
2
|
import * as path from 'path';
|
3
3
|
import { File } from '../Gulpfile';
|
4
4
|
import replace from 'gulp-string-replace';
|
5
|
-
import { blue, red } from '../index.js';
|
5
|
+
import { blue, orange, red } from '../index.js';
|
6
6
|
|
7
7
|
export function setProdConfig() {
|
8
8
|
const tag = process.env.GIT_TAG || 'development';
|
@@ -20,8 +20,9 @@ export function setProdConfig() {
|
|
20
20
|
|
21
21
|
return path.join(`${outputDir}/constants`);
|
22
22
|
}))
|
23
|
-
.on('error', function () {
|
23
|
+
.on('error', function (e: Error) {
|
24
24
|
console.log("đŠ" + red.underline.bold(' => Setting the git tag failed!'));
|
25
|
+
console.log("đŠ" + red.underline.bold(` => Error: ${orange(e.message)}`));
|
25
26
|
this.emit('end');
|
26
27
|
})
|
27
28
|
.on('end', function() { console.log("đļ" + blue.underline(' => Setting the git tag succeeded!'));
|
package/src/gulp/public.ts
CHANGED
@@ -1,9 +1,18 @@
|
|
1
1
|
import gulp from 'gulp';
|
2
|
-
import { createGulpEsbuild } from 'gulp-esbuild';
|
3
|
-
|
4
2
|
import * as path from 'path';
|
5
3
|
import { TaskOptions } from '../Gulpfile';
|
6
4
|
import { blue, orange, red } from '../index.js';
|
5
|
+
import swc from 'gulp-swc';
|
6
|
+
|
7
|
+
const swcOptions = {
|
8
|
+
jsc: {
|
9
|
+
target: 'es2020',
|
10
|
+
parser: {
|
11
|
+
syntax: "typescript",
|
12
|
+
tsx: true,
|
13
|
+
},
|
14
|
+
},
|
15
|
+
};
|
7
16
|
|
8
17
|
export function buildPublic(options: TaskOptions) {
|
9
18
|
const folders = ['typescript'];
|
@@ -13,11 +22,7 @@ export function buildPublic(options: TaskOptions) {
|
|
13
22
|
}
|
14
23
|
}
|
15
24
|
|
16
|
-
const { outputDir
|
17
|
-
const gulpEsbuild = createGulpEsbuild({
|
18
|
-
incremental: enableIncrementalBuild,
|
19
|
-
pipe: true,
|
20
|
-
});
|
25
|
+
const { outputDir } = options;
|
21
26
|
|
22
27
|
// Create tasks for each folder
|
23
28
|
const tasks = folders.map((folder) => {
|
@@ -28,15 +33,16 @@ export function buildPublic(options: TaskOptions) {
|
|
28
33
|
`${folder}/public/**/*.ts`,
|
29
34
|
`${folder}/public/**/*.tsx`,
|
30
35
|
])
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
.on('error', function () {
|
36
|
+
.pipe(swc(swcOptions))
|
37
|
+
.on('error', function (e: Error) {
|
38
|
+
console.log("đŠ" + red.underline.bold(` => Build of Public files for ${orange(folder)} failed!`));
|
39
|
+
console.log("đŠ" + red.underline.bold(` => Error: ${orange(e.message)}`));
|
40
|
+
this.emit('end');
|
41
|
+
})
|
42
|
+
.pipe(gulp.dest(path.join(outputDir, 'public')))
|
43
|
+
.on('error', function (e: Error) {
|
39
44
|
console.log("đŠ" + red.underline.bold(` => Build of Public files for ${orange(folder)} failed!`));
|
45
|
+
console.log("đŠ" + red.underline.bold(` => Error: ${orange(e.message)}`));
|
40
46
|
this.emit('end');
|
41
47
|
})
|
42
48
|
.on('end', function () {
|
package/src/gulp/styles.ts
CHANGED
@@ -21,9 +21,15 @@ export function compileScss(options: TaskOptions) {
|
|
21
21
|
const task = () =>
|
22
22
|
gulp.src(['typescript/styles/global.scss'])
|
23
23
|
.pipe(sass().on('error', sass.logError))
|
24
|
+
.on('error', function (e: Error) {
|
25
|
+
console.log("đŠ" + red.underline.bold(` => Build of SCSS files for ${orange(folder)} failed!`));
|
26
|
+
console.log("đŠ" + red.underline.bold(` => Error: ${orange(e.message)}`));
|
27
|
+
this.emit('end');
|
28
|
+
})
|
24
29
|
.pipe(gulp.dest(`${outputDir}/styles`))
|
25
|
-
.on('error', function () {
|
30
|
+
.on('error', function (e: Error) {
|
26
31
|
console.log("đŠ" + red.underline.bold(` => Compiling of scss files for ${orange(folder)} failed!`));
|
32
|
+
console.log("đŠ" + red.underline.bold(` => Error: ${orange(e.message)}`));
|
27
33
|
this.emit('end');
|
28
34
|
})
|
29
35
|
.on('end', function () {
|
package/src/gulp/templates.ts
CHANGED
@@ -25,8 +25,9 @@ export function previewTemplates(options: TaskOptions) {
|
|
25
25
|
`!${folder}/backend/templates/render.ts`,
|
26
26
|
])
|
27
27
|
.pipe(exec((file: File) => `npx ts-node-esm -T ${file.path}`, taskOpt))
|
28
|
-
.on('error', function () {
|
28
|
+
.on('error', function (e: Error) {
|
29
29
|
console.log("đŠ" + red.underline.bold(` => Render of Template for ${orange(folder)} failed!`));
|
30
|
+
console.log("đŠ" + red.underline.bold(` => Error: ${orange(e.message)}`));
|
30
31
|
this.emit('end');
|
31
32
|
})
|
32
33
|
.on('end', function () {
|
package/src/gulp/test.ts
CHANGED
@@ -44,8 +44,9 @@ export function test(options: TaskOptions) {
|
|
44
44
|
'public/(.*)': '<rootDir>/public/$1'
|
45
45
|
}
|
46
46
|
}))
|
47
|
-
.on('error', function () {
|
47
|
+
.on('error', function (e: Error) {
|
48
48
|
console.log("đŠ" + red.underline.bold(` => Tests for ${orange(folder)} failed!`));
|
49
|
+
console.log("đŠ" + red.underline.bold(` => Error: ${orange(e.message)}`));
|
49
50
|
this.emit('end');
|
50
51
|
})
|
51
52
|
.on('end', function () {
|
package/src/gulp/types.ts
CHANGED
@@ -7,7 +7,7 @@ import flatmap from 'gulp-flatmap';
|
|
7
7
|
import jeditor from 'gulp-json-editor';
|
8
8
|
import merge from 'merge-stream';
|
9
9
|
import * as insert from 'gulp-insert';
|
10
|
-
import { blue, red, yellow } from '../index.js';
|
10
|
+
import { blue, orange, red, yellow } from '../index.js';
|
11
11
|
import tap from 'gulp-tap';
|
12
12
|
import { TSConfig } from '../models';
|
13
13
|
|
@@ -150,7 +150,7 @@ export function updateWixTypes(options: TaskOptions) {
|
|
150
150
|
}))
|
151
151
|
.on('error', function (e: Error) {
|
152
152
|
console.log("đŠ" + red.underline.bold('Modification of WIX configs failed!'));
|
153
|
-
console.
|
153
|
+
console.log("đŠ" + red.underline.bold(` => Error: ${orange(e.message)}`));
|
154
154
|
this.emit('end');
|
155
155
|
})
|
156
156
|
.on('end', function() { console.log("đļ" + blue.underline(`Modification of ${yellow(count)} WIX configs succeeded!`)); });
|
@@ -187,8 +187,8 @@ export function addTypes(options: TaskOptions, done: gulp.TaskFunctionCallback):
|
|
187
187
|
exportTypes,
|
188
188
|
)
|
189
189
|
.on('error', function(e: Error) {
|
190
|
-
console.error(e);
|
191
190
|
console.log("đŠ" + red.underline.bold(' => Updating WIX failed!'));
|
191
|
+
console.log("đŠ" + red.underline.bold(` => Error: ${orange(e.message)}`));
|
192
192
|
this.emit('end');
|
193
193
|
done();
|
194
194
|
})
|
package/src/helpers.ts
CHANGED
@@ -1,15 +1,14 @@
|
|
1
1
|
import chalk from 'chalk';
|
2
|
-
import { join } from 'path';
|
3
2
|
import { simpleGit } from 'simple-git';
|
4
|
-
import fs from 'fs/promises';
|
5
3
|
import { spawnSync } from 'child_process';
|
6
4
|
// https://www.sergevandenoever.nl/run-gulp4-tasks-programatically-from-node/
|
7
5
|
import path from 'path';
|
8
6
|
import { fileURLToPath } from 'url';
|
9
7
|
import { ModuleSettings, ProjectSettings } from '.';
|
10
8
|
import { exec } from 'child_process';
|
9
|
+
import os from 'os';
|
11
10
|
|
12
|
-
import { blue, green, orange, red } from './index.js';
|
11
|
+
import { blue, green, orange, red, yellow, magenta } from './index.js';
|
13
12
|
|
14
13
|
export async function installPackages(wixPackages: Record<string, string>, devPackages: Record<string, string>, cwd: string, locked: boolean ) {
|
15
14
|
if (locked) console.log("đ" + blue.underline(` => Installing & version locked packages!`));
|
@@ -83,19 +82,84 @@ export async function runGulp(moduleSettings: ModuleSettings, projectSettings: P
|
|
83
82
|
/**
|
84
83
|
* Clean up and run a command before exiting the process.
|
85
84
|
*/
|
86
|
-
export function
|
85
|
+
export function cleanupWatchers() {
|
86
|
+
console.log(`đ§š ${magenta.underline('Cleaning up Watchman watchers...')}`);
|
87
87
|
const cwd = process.cwd();
|
88
|
-
const command = `watchman watch-del
|
89
|
-
|
90
|
-
console.log("đ" + blue.underline(' => Cleaning up...'));
|
88
|
+
const command = `watchman watch-del "${cwd}"`; // Adjust for Windows paths
|
91
89
|
exec(command, (error, stdout, stderr) => {
|
92
90
|
if (error) {
|
93
|
-
console.error(`đŠ Failed to run cleanup: ${error.message}`);
|
91
|
+
console.error(`đŠ ${red.underline('Failed to run cleanup:')} ${orange(error.message)}`);
|
94
92
|
return;
|
95
93
|
}
|
96
94
|
if (stderr) {
|
97
|
-
console.error(`â ī¸
|
95
|
+
console.error(`â ī¸ ${yellow.underline('Watchman stderr:')} ${stderr}`);
|
98
96
|
}
|
99
|
-
console.log(`â
Watchman cleanup success: ${stdout}`);
|
97
|
+
console.log(`â
${green.underline('Watchman cleanup success:')} ${stdout}`);
|
100
98
|
});
|
101
99
|
}
|
100
|
+
|
101
|
+
/**
|
102
|
+
* Kill all processes matching a specific substring in their command, with a fallback for Windows.
|
103
|
+
* @param {string} processPattern - The substring to match (e.g., "wix:dev" or "@wix/cli/bin/wix.cjs").
|
104
|
+
*/
|
105
|
+
export function killAllProcesses(processPattern: string) {
|
106
|
+
const isWindows = os.platform() === 'win32';
|
107
|
+
const command = isWindows
|
108
|
+
? `tasklist /FI "IMAGENAME eq node.exe" /FO CSV | findstr "${processPattern}"` // Adjust for Node.js processes
|
109
|
+
: `ps -eo pid,command | grep "${processPattern}" | grep -v grep`;
|
110
|
+
|
111
|
+
exec(command, (error, stdout, stderr) => {
|
112
|
+
if (error) {
|
113
|
+
console.error(`đŠ ${red.underline('Failed to find processes:')} ${orange(error.message)}`);
|
114
|
+
return;
|
115
|
+
}
|
116
|
+
if (stderr) {
|
117
|
+
console.error(`â ī¸ ${yellow.underline('Error output:')} ${stderr}`);
|
118
|
+
}
|
119
|
+
if (!stdout.trim()) {
|
120
|
+
console.log(`âšī¸ ${blue.underline(`No processes found matching pattern:`)} ${orange(processPattern)}`);
|
121
|
+
return;
|
122
|
+
}
|
123
|
+
|
124
|
+
console.log(`đ ${magenta.underline('Found matching processes:')}\n${stdout}`);
|
125
|
+
const lines = stdout.trim().split('\n');
|
126
|
+
const pids = isWindows
|
127
|
+
? lines.map(line => line.match(/"(\d+)"/)?.[1]) // Extract PID from Windows tasklist output
|
128
|
+
: lines.map(line => line.trim().split(/\s+/)[0]).filter(pid => !isNaN(Number(pid)));
|
129
|
+
|
130
|
+
pids.forEach(pid => {
|
131
|
+
if (!pid) return;
|
132
|
+
try {
|
133
|
+
const killCommand = isWindows
|
134
|
+
? `taskkill /PID ${pid} /T /F` // Forcefully terminate the process on Windows
|
135
|
+
: `kill -SIGTERM ${pid}`;
|
136
|
+
|
137
|
+
exec(killCommand, (killError) => {
|
138
|
+
if (killError) {
|
139
|
+
console.error(`â ī¸ ${yellow.underline('Failed to kill process with PID')} ${orange(pid)}: ${red(killError.message)}`);
|
140
|
+
} else {
|
141
|
+
console.log(`â
${green.underline('Killed process with PID:')} ${orange(pid)}`);
|
142
|
+
}
|
143
|
+
});
|
144
|
+
|
145
|
+
// Schedule SIGKILL fallback for non-Windows platforms
|
146
|
+
if (!isWindows) {
|
147
|
+
setTimeout(() => {
|
148
|
+
try {
|
149
|
+
process.kill(parseInt(pid, 10), 'SIGKILL');
|
150
|
+
console.log(`đĒ ${red.underline('Sent SIGKILL to process with PID:')} ${orange(pid)} (fallback).`);
|
151
|
+
} catch (killError: any) {
|
152
|
+
if (killError.code === 'ESRCH') {
|
153
|
+
console.log(`â
${green.underline('Process with PID')} ${orange(pid)} ${green.underline('already terminated.')}`);
|
154
|
+
} else {
|
155
|
+
console.error(`â ī¸ ${yellow.underline('Failed to send SIGKILL to process with PID')} ${orange(pid)}: ${red(killError.message)}`);
|
156
|
+
}
|
157
|
+
}
|
158
|
+
}, 10000);
|
159
|
+
}
|
160
|
+
} catch (err: any) {
|
161
|
+
console.error(`â ī¸ ${yellow.underline('Failed to kill process with PID')} ${orange(pid)}: ${red(err.message)}`);
|
162
|
+
}
|
163
|
+
});
|
164
|
+
});
|
165
|
+
}
|
package/src/index.ts
CHANGED
@@ -11,7 +11,7 @@ import fs from 'fs/promises';
|
|
11
11
|
|
12
12
|
import { init } from './init.js';
|
13
13
|
import { sync } from './sync.js';
|
14
|
-
import { runGulp, installPackages,
|
14
|
+
import { runGulp, installPackages, killAllProcesses, cleanupWatchers } from './helpers.js';
|
15
15
|
import { prepare } from './prepare.js';
|
16
16
|
import { spawnSync } from 'child_process';
|
17
17
|
|
@@ -71,10 +71,50 @@ const __filename = fileURLToPath(import.meta.url);
|
|
71
71
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
72
72
|
const __dirname = dirname(__filename);
|
73
73
|
|
74
|
+
// const cwd = process.cwd();
|
75
|
+
// const command = `watchman watch-del '${cwd}'`;
|
76
|
+
// killAllProcesses('@wix/cli/bin/wix.cjs'); // Matches processes running the Wix CLI
|
77
|
+
// killAllProcesses('wix:dev');
|
78
|
+
|
79
|
+
|
80
|
+
process.on('exit', (code) => {
|
81
|
+
killAllProcesses('@wix/cli/bin/wix.cjs'); // Matches processes running the Wix CLI
|
82
|
+
killAllProcesses('wix:dev');
|
83
|
+
cleanupWatchers();
|
84
|
+
console.log(`đĒ ${magenta.underline('Process exiting with code:')} ${orange(code)}`);
|
85
|
+
});
|
86
|
+
|
74
87
|
process.on('SIGINT', () => {
|
75
|
-
|
76
|
-
|
77
|
-
|
88
|
+
console.log(`đ ${green.underline('Received Ctrl+C (SIGINT), cleaning up...')}`);
|
89
|
+
killAllProcesses('@wix/cli/bin/wix.cjs'); // Matches processes running the Wix CLI
|
90
|
+
killAllProcesses('wix:dev');
|
91
|
+
cleanupWatchers();
|
92
|
+
process.exit(); // Exit explicitly after handling
|
93
|
+
});
|
94
|
+
|
95
|
+
process.on('SIGTERM', () => {
|
96
|
+
console.log(`đ ${red.underline('Received termination signal (SIGTERM), cleaning up...')}`);
|
97
|
+
killAllProcesses('@wix/cli/bin/wix.cjs'); // Matches processes running the Wix CLI
|
98
|
+
killAllProcesses('wix:dev');
|
99
|
+
cleanupWatchers();
|
100
|
+
process.exit(); // Exit explicitly after handling
|
101
|
+
});
|
102
|
+
|
103
|
+
process.on('uncaughtException', (error) => {
|
104
|
+
console.error(`đĨ ${red.underline('Uncaught Exception:')}`, error);
|
105
|
+
killAllProcesses('@wix/cli/bin/wix.cjs'); // Matches processes running the Wix CLI
|
106
|
+
killAllProcesses('wix:dev');
|
107
|
+
cleanupWatchers();
|
108
|
+
process.exit(1); // Exit with an error code
|
109
|
+
});
|
110
|
+
|
111
|
+
process.on('unhandledRejection', (reason, promise) => {
|
112
|
+
console.error(`đ¨ ${yellow.underline('Unhandled Rejection at:')} ${orange(promise)}`);
|
113
|
+
console.error(`đ¨ ${red.underline('Reason:')} ${reason}`); cleanupWatchers();
|
114
|
+
killAllProcesses('@wix/cli/bin/wix.cjs'); // Matches processes running the Wix CLI
|
115
|
+
killAllProcesses('wix:dev');
|
116
|
+
cleanupWatchers();
|
117
|
+
process.exit(1); // Exit with an error code
|
78
118
|
});
|
79
119
|
|
80
120
|
/**
|
package/src/types.d.ts
CHANGED