lucy-cli 0.7.15 → 0.8.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.
@@ -1,100 +1,55 @@
1
1
  import gulp from 'gulp';
2
2
  import { TaskOptions } from '../Gulpfile.js';
3
3
  import { green } from '../index.js';
4
- import { buildBackend, buildBackendJSW, buildBackendJSWLib, buildBackendLib } from './backend.js';
5
- import { buildPublic, buildPublicLib } from './public.js';
4
+ import { buildBackend, buildBackendJSW } from './backend.js';
5
+ import { buildPublic } from './public.js';
6
6
  import { buildPages } from './pages.js';
7
- import { copyFiles, copyFilesLib } from './copy.js';
8
- import { previewTemplates, previewTemplatesLib } from './templates.js';
9
- import { checkPages, checkTs, checkTsLib } from './checks.js';
10
- import { testLib, test } from './test.js';
7
+ import { copyFiles } from './copy.js';
8
+ import { previewTemplates } from './templates.js';
9
+ import { checkPages, checkTs } from './checks.js';
10
+ import { test } from './test.js';
11
11
 
12
12
  let taskOptions: TaskOptions;
13
13
 
14
14
  export function watchSCSS() {
15
15
  return gulp.watch([
16
- 'typescript/styles/**/*.scss',
17
- 'lib/styles/**/*.scss'],
16
+ '*/styles/**/*.scss'
17
+ ],
18
18
  gulp.parallel('scss')
19
19
  );
20
20
  }
21
21
 
22
22
  export function watchBackend() {
23
23
  return gulp.watch([
24
- 'typescript/backend/**/*.ts',
25
- 'typescript/backend/**/*.tsx',
26
- '!typescript/backend/**/*.spec.ts',
27
- '!typescript/backend/**/*.jsw.ts',
24
+ '*/backend/**/*.ts',
25
+ '*/backend/**/*.tsx',
26
+ '!*/backend/**/*.spec.ts',
27
+ '!*/backend/**/*.jsw.ts',
28
+ '!src/**/**',
28
29
  ], gulp.parallel(
29
- test(),
30
- checkTs(),
30
+ test(taskOptions),
31
+ checkTs(taskOptions),
31
32
  buildBackend(taskOptions),
32
33
  )
33
34
  );
34
35
  }
35
36
 
36
- export function watchBackendLib() {
37
- return gulp.watch([
38
- 'lib/backend/**/*.ts',
39
- 'lib/backend/**/*.tsx',
40
- '!lib/backend/**/*.spec.ts',
41
- '!lib/backend/**/*.jsw.ts',
42
- ], gulp.parallel(
43
- testLib(),
44
- checkTsLib(),
45
- buildBackendLib(taskOptions)
46
- )
47
- );
48
- }
49
-
50
- export function watchJSW() {
51
- return gulp.watch(['typescript/backend/**/*.jsw.ts'],
52
- gulp.parallel(
53
- test(),
54
- checkTs(),
55
- buildBackendJSW(taskOptions)
56
- )
57
- );
58
- }
59
-
60
- export function watchJSWLib() {
61
- return gulp.watch(['lib/backend/**/*.jsw.ts'],
62
- gulp.parallel(
63
- testLib(),
64
- checkTsLib(),
65
- buildBackendJSWLib(taskOptions)
66
- )
67
- );
68
- }
69
-
70
37
  export function watchPublic() {
71
38
  return gulp.watch([
72
- 'typescript/public/**/*.ts',
73
- 'typescript/public/**/*.tsx',
39
+ '*/public/**/*.ts',
40
+ '*/public/**/*.tsx',
74
41
  ], gulp.parallel(
75
- test(),
76
- checkTs(),
42
+ test(taskOptions),
43
+ checkTs(taskOptions),
77
44
  buildPublic(taskOptions),
78
45
  )
79
46
  );
80
47
  }
81
48
 
82
- export function watchPublicLib() {
83
- return gulp.watch([
84
- 'lib/public/**/*.ts',
85
- 'lib/public/**/*.tsx',
86
- ], gulp.parallel(
87
- testLib(),
88
- checkTsLib(),
89
- buildPublicLib(taskOptions),
90
- )
91
- );
92
- }
93
-
94
49
  export function watchPages() {
95
50
  return gulp.watch('typescript/pages/**/*.ts',
96
51
  gulp.parallel(
97
- checkTs(),
52
+ checkTs(taskOptions),
98
53
  buildPages(taskOptions),
99
54
  )
100
55
  );
@@ -102,42 +57,23 @@ export function watchPages() {
102
57
 
103
58
  export function watchFiles() {
104
59
  return gulp.watch([
105
- 'typescript/backend/**/*',
106
- 'typescript/public/**/*',
107
- 'typescript/pages/**/*',
108
- '!typescript/**/*.ts',
60
+ '*/backend/**/*',
61
+ '*/public/**/*',
62
+ '*/pages/**/*',
63
+ '!*/**/*.ts',
64
+ '!*/**/*.tsx',
109
65
  ], gulp.parallel(copyFiles(taskOptions)));
110
66
  }
111
67
 
112
- export function watchFilesLib() {
113
- return gulp.watch([
114
- 'lib/backend/**/*',
115
- 'lib/public/**/*',
116
- 'lib/pages/**/*',
117
- '!lib/**/*.ts',
118
- ], gulp.parallel(copyFilesLib(taskOptions)));
119
- }
120
-
121
68
  export function watchTemplates() {
122
69
  return gulp.watch([
123
- 'typescript/backend/templates/**/*.tsx',
124
- 'typescript/backend/templates/data/*.json',
125
- '!typescript/backend/templates/render.ts',
126
- ], gulp.parallel(
127
- previewTemplates(),
128
- test()
129
- )
130
- );
131
- }
132
-
133
- export function watchTemplatesLib() {
134
- return gulp.watch([
135
- 'lib/backend/templates/**/*.tsx',
136
- 'lib/backend/templates/data/*.json',
137
- '!lib/backend/templates/render.ts',
70
+ '*/backend/templates/**/*.tsx',
71
+ '*/backend/templates/data/*.json',
72
+ '!*/backend/templates/render.ts',
138
73
  ], gulp.parallel(
139
- previewTemplatesLib(),
140
- testLib(),
74
+ previewTemplates(taskOptions),
75
+ test(taskOptions),
76
+ checkTs(taskOptions),
141
77
  )
142
78
  );
143
79
  }
@@ -160,16 +96,10 @@ export function watchAll(options: TaskOptions) {
160
96
  return gulp.parallel(
161
97
  watchSCSS,
162
98
  watchBackend,
163
- watchBackendLib,
164
- watchJSW,
165
- watchJSWLib,
166
99
  watchPublic,
167
- watchPublicLib,
168
100
  watchPages,
169
- watchFilesLib,
170
101
  watchFiles,
171
102
  watchTemplates,
172
- watchTemplatesLib,
173
103
  watchTypes,
174
104
  );
175
105
  }
package/src/helpers.ts CHANGED
@@ -7,6 +7,7 @@ import { spawnSync } from 'child_process';
7
7
  import path from 'path';
8
8
  import { fileURLToPath } from 'url';
9
9
  import { ModuleSettings, ProjectSettings } from '.';
10
+ import { exec } from 'child_process';
10
11
 
11
12
  import { blue, green, orange, red } from './index.js';
12
13
 
@@ -76,4 +77,25 @@ export async function runGulp(moduleSettings: ModuleSettings, projectSettings: P
76
77
 
77
78
  // Check if 'dev' task exists
78
79
  gulpfile.runTask(task, moduleSettings, projectSettings)
79
- }
80
+ }
81
+
82
+
83
+ /**
84
+ * Clean up and run a command before exiting the process.
85
+ */
86
+ export function handleExit() {
87
+ const cwd = process.cwd();
88
+ const command = `watchman watch-del '${cwd}'`;
89
+
90
+ console.log("🐕" + blue.underline(' => Cleaning up...'));
91
+ exec(command, (error, stdout, stderr) => {
92
+ if (error) {
93
+ console.error(`💩 Failed to run cleanup: ${error.message}`);
94
+ return;
95
+ }
96
+ if (stderr) {
97
+ console.error(`⚠️ Watchman stderr: ${stderr}`);
98
+ }
99
+ console.log(`✅ Watchman cleanup success: ${stdout}`);
100
+ });
101
+ }
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 } from './helpers.js';
14
+ import { runGulp, installPackages, handleExit } from './helpers.js';
15
15
  import { prepare } from './prepare.js';
16
16
 
17
17
  export type LucySettings = {
@@ -70,6 +70,11 @@ const __filename = fileURLToPath(import.meta.url);
70
70
  // eslint-disable-next-line @typescript-eslint/naming-convention
71
71
  const __dirname = dirname(__filename);
72
72
 
73
+ process.on('SIGINT', () => {
74
+ console.log("🐕 Received Ctrl+C, cleaning up...");
75
+ handleExit();
76
+ process.exit(); // Exit the process explicitly
77
+ });
73
78
 
74
79
  /**
75
80
  * Main function
@@ -169,6 +174,7 @@ async function main(): Promise<void> {
169
174
 
170
175
  if(moduleSettings.args.includes('-l')) moduleSettings.lockVersion = true;
171
176
 
177
+ console.log("🐕" + magenta.underline(' => Lucy CLI => RUNNING: ' + orange('Press Ctrl+C to stop.')));
172
178
  // INFO: Run commands
173
179
  if(moduleSettings.args.includes('init')){
174
180
  if(projectSettings.lucySettings?.initialized && !moduleSettings.force) {