lucy-cli 0.7.14 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -3,130 +3,97 @@ import { createGulpEsbuild } from 'gulp-esbuild';
3
3
  import rename from 'gulp-rename';
4
4
  import * as path from 'path';
5
5
  import { TaskOptions } from '../Gulpfile';
6
- import { blue, red } from '../index.js';
7
- import ts from 'gulp-typescript';
8
- import merge from 'merge2';
9
- import esbuild from 'gulp-esbuild';
10
- import concat from 'gulp-concat';
11
- import tsConf from '../../files/typescript/tsconfig.json' assert { type: 'json' };
12
-
13
-
14
- type TsSettings = ts.Settings;
15
- const tsOptions:TsSettings = tsConf.compilerOptions;
6
+ import { blue, orange, red } from '../index.js';
16
7
 
17
8
  export function buildBackend(options: TaskOptions) {
18
- const { outputDir, enableIncrementalBuild } = options;
19
- const gulpEsbuild = createGulpEsbuild({
20
- incremental: enableIncrementalBuild,
21
- });
22
-
23
- return () => {
24
- return gulp.src([
25
- 'typescript/backend/**/*.ts',
26
- 'typescript/backend/**/*.tsx',
27
- '!typescript/backend/**/*.jsw.ts',
28
- '!typescript/backend/**/*.spec.ts',
29
- '!typescript/backend/http-functions.ts',
30
- ])
31
- .pipe(gulpEsbuild({
32
- bundle: false,
33
- }))
34
- .pipe(gulp.dest(path.join(outputDir, 'backend')))
35
- .on('error', function () {
36
- console.log("💩" + red.underline.bold(' => Build of Backend TS files failed!'));
37
- this.emit('end');
38
- })
39
- .on('end', function() { console.log("🐶" + blue.underline(' => Build of Backend TS files succeeded!'));
9
+ const folders = ['typescript'];
10
+ if (options.modulesSync){
11
+ for (const module of Object.keys(options.modulesSync)) {
12
+ folders.push(module);
40
13
  }
41
- )}
42
- }
14
+ }
43
15
 
44
- export function buildBackendLib(options: TaskOptions) {
45
16
  const { outputDir, enableIncrementalBuild } = options;
46
17
  const gulpEsbuild = createGulpEsbuild({
47
18
  incremental: enableIncrementalBuild,
48
19
  });
49
-
50
- return () => {
51
- return gulp.src([
52
- 'lib/backend/**/*.ts',
53
- 'lib/backend/**/*.tsx',
54
- '!lib/backend/**/*.jsw.ts',
55
- '!lib/backend/**/*.spec.ts',
56
- '!lib/backend/http-functions.ts',
57
- ])
58
- .pipe(gulpEsbuild({
59
- bundle: false,
60
- }))
61
- .pipe(gulp.dest(path.join(outputDir, 'backend')))
62
- .on('error', function () {
63
- console.log("💩" + red.underline.bold(' => Build of Backend TS (LIB) files failed!'));
64
- this.emit('end');
65
- })
66
- .on('end', function() { console.log("🐶" + blue.underline(' => Build of Backend TS (LIB) files succeeded!'));
67
- }
68
- )}
69
- }
70
20
 
71
- export function buildBackendJSW(options: TaskOptions) {
72
- const { outputDir, enableIncrementalBuild } = options;
73
- const gulpEsbuild = createGulpEsbuild({
74
- incremental: enableIncrementalBuild,
21
+ // Create tasks for each folder
22
+ const tasks = folders.map((folder) => {
23
+ const taskName = `build_Backend-${folder}`; // Create a unique name for each task
24
+
25
+ const task = () =>
26
+ gulp.src([
27
+ `${folder}/backend/**/*.ts`,
28
+ `${folder}/backend/**/*.tsx`,
29
+ `!${folder}/backend/**/*.jsw.ts`,
30
+ `!${folder}/backend/**/*.spec.ts`,
31
+ ])
32
+ .pipe(
33
+ gulpEsbuild({
34
+ bundle: false,
35
+ })
36
+ )
37
+ .pipe(gulp.dest(path.join(outputDir, 'backend')))
38
+ .on('error', function () {
39
+ console.log("💩" + red.underline.bold(` => Build of Backend files for ${orange(folder)} failed!`));
40
+ this.emit('end');
41
+ })
42
+ .on('end', function () {
43
+ console.log("🐶" + blue.underline(` => Build of Backend files for ${orange(folder)} succeeded!`));
44
+ });
45
+
46
+ // Register the task with Gulp
47
+ Object.defineProperty(task, 'name', { value: taskName }); // Set a unique name for debugging
48
+ return task;
75
49
  });
76
50
 
77
- return () => {
78
- return gulp.src(['typescript/backend/**/*.jsw.ts'])
79
- .pipe(gulpEsbuild({
80
- bundle: false,
81
- }))
82
- .pipe(rename({ extname: '' }))
83
- .pipe(gulp.dest(path.join(outputDir, 'backend')))
84
- .on('error', function () {
85
- console.log("💩" + red.underline.bold(' => Build of JSW files failed!'));
86
- this.emit('end');
87
- })
88
- .on('end', function() { console.log("🐶" + blue.underline(' => Build of (JSW) files succeeded!'))})
89
- }
51
+ // Run all tasks in parallel
52
+ return gulp.parallel(...tasks);
90
53
  }
91
54
 
92
- export function buildBackendJSWLib(options: TaskOptions) {
55
+
56
+ export function buildBackendJSW(options: TaskOptions) {
57
+ const folders = ['typescript'];
58
+ if (options.modulesSync){
59
+ for (const module of Object.keys(options.modulesSync)) {
60
+ folders.push(module);
61
+ }
62
+ }
63
+
93
64
  const { outputDir, enableIncrementalBuild } = options;
94
65
  const gulpEsbuild = createGulpEsbuild({
95
66
  incremental: enableIncrementalBuild,
96
67
  });
97
68
 
98
- return () => {
99
- return gulp.src(['lib/backend/**/*.jsw.ts'])
100
- .pipe(gulpEsbuild({
101
- bundle: false,
102
- }))
103
- .pipe(rename({ extname: '' }))
104
- .pipe(gulp.dest(path.join(outputDir, 'backend')))
105
- .on('error', function () {
106
- console.log("💩" + red.underline.bold(' => Build of JSW (LIB) files failed!'));
107
- this.emit('end');
108
- })
109
- .on('end', function() { console.log("🐶" + blue.underline(' => Build of JSW (LIB) files succeeded!'))})
110
- }
111
- }
69
+ // Create tasks for each folder
70
+ const tasks = folders.map((folder) => {
71
+ const taskName = `build-${folder}`; // Create a unique name for each task
112
72
 
113
- export function buildBackendHTTP(options: TaskOptions) {
114
- const { outputDir, enableIncrementalBuild } = options;
115
- delete tsOptions.outFile;
116
- delete tsOptions.outDir;
117
- delete tsOptions.rootDir;
118
- // tsOptions.resolveJsonModule = false;
119
- tsOptions.module = 'amd';
120
- tsOptions.outFile = 'http-functions.js';
121
- console.log({tsOptions})
122
- return () => {
123
- return gulp.src(['lib/backend/http-functions.ts', 'typescript/backend/http-functions.ts'])
124
- .pipe(ts(tsOptions))
125
- .pipe(gulp.dest(path.join(outputDir, 'backend')))
126
- .on('error', function () {
127
- console.log("💩" + red.underline.bold(' => Build of HTTP (LIB) files failed!'));
128
- this.emit('end');
129
- })
130
- .on('end', function() { console.log("🐶" + blue.underline(' => Build of HTTP (LIB) files succeeded!'))})
131
- };
73
+ const task = () =>
74
+ gulp.src([
75
+ `${folder}/backend/**/*.jsw.ts`,
76
+ ])
77
+ .pipe(
78
+ gulpEsbuild({
79
+ bundle: false,
80
+ })
81
+ )
82
+ .pipe(rename({ extname: '' }))
83
+ .pipe(gulp.dest(path.join(outputDir, 'backend')))
84
+ .on('error', function () {
85
+ console.log("💩" + red.underline.bold(` => Build of JSW files for ${orange(folder)} failed!`));
86
+ this.emit('end');
87
+ })
88
+ .on('end', function () {
89
+ console.log("🐶" + blue.underline(` => Build of JSW files for ${orange(folder)} succeeded!`));
90
+ });
91
+
92
+ // Register the task with Gulp
93
+ Object.defineProperty(task, 'name', { value: taskName }); // Set a unique name for debugging
94
+ return task;
95
+ });
96
+
97
+ // Run all tasks in parallel
98
+ return gulp.parallel(...tasks);
132
99
  }
@@ -3,7 +3,8 @@ import glob from 'glob';
3
3
  import * as path from 'path';
4
4
  import gulp from 'gulp';
5
5
  import ts from 'gulp-typescript';
6
- import { blue, green, magenta, red, yellow } from '../index.js';
6
+ import { blue, green, magenta, orange, red, yellow } from '../index.js';
7
+ import { TaskOptions } from '../Gulpfile.js';
7
8
 
8
9
  /**
9
10
  * Extracts a match from a file
@@ -118,33 +119,36 @@ export async function checkPages(fail: boolean, force: boolean) {
118
119
  });
119
120
  }
120
121
 
121
- export function checkTs() {
122
- const tsProject = ts.createProject('./lib/tsconfig.json', { noEmit: true });
123
- return () => {
124
- return gulp.src(['lib/typescript/**/*.ts', '!lib/typescript/types/**/*.ts'], { cwd: 'typescript' })
125
- .pipe(tsProject(ts.reporter.fullReporter()))
126
- .on('error', function () {
127
- console.log("💩" + red.underline.bold(' => Typescript error!'));
128
- this.emit('end');
129
- })
130
- .on('end', function () {
131
- console.log("🐶" + blue.underline(' => Typescriptcheck succeeded!'));
132
- });
133
- };
134
- }
122
+ export function checkTs(options: TaskOptions) {
123
+ const folders = ['typescript'];
124
+ if (options.modulesSync){
125
+ for (const module of Object.keys(options.modulesSync)) {
126
+ folders.push(module);
127
+ }
128
+ }
129
+
130
+ // Create tasks for each folder
131
+ const tasks = folders.map((folder) => {
132
+ const tsProject = ts.createProject(`./${folder}/tsconfig.json`, { noEmit: true });
133
+
134
+ const taskName = `test-${folder}`; // Create a unique name for each task
135
+
136
+ const task = () =>
137
+ gulp.src([`${folder}/**/*.ts`, `!${folder}/types/**/*.ts`], { cwd: folder })
138
+ .pipe(tsProject(ts.reporter.fullReporter()))
139
+ .on('error', function () {
140
+ console.log("💩" + red.underline.bold(` => Typescriptcheck for ${orange(folder)} failed!`));
141
+ this.emit('end');
142
+ })
143
+ .on('end', function () {
144
+ console.log("🐶" + blue.underline(` => Typescriptcheck for ${orange(folder)} succeeded!`));
145
+ });
135
146
 
136
- export function checkTsLib() {
137
- const tsProject = ts.createProject('./lib/tsconfig.json', { noEmit: true });
147
+ // Register the task with Gulp
148
+ Object.defineProperty(task, 'name', { value: taskName }); // Set a unique name for debugging
149
+ return task;
150
+ });
138
151
 
139
- return () => {
140
- return gulp.src(['lib/typescript/**/*.ts', '!lib/typescript/types/**/*.ts'], { cwd: 'typescript' })
141
- .pipe(tsProject(ts.reporter.fullReporter()))
142
- .on('error', function () {
143
- console.log("💩" + red.underline.bold(' => Typescript (LIB) error!'));
144
- this.emit('end');
145
- })
146
- .on('end', function () {
147
- console.log("🐶" + blue.underline(' => Typescript check (LIB) succeeded!'));
148
- });
149
- };
152
+ // Run all tasks in parallel
153
+ return gulp.parallel(...tasks);
150
154
  }
package/src/gulp/copy.ts CHANGED
@@ -1,48 +1,47 @@
1
1
  import gulp from 'gulp';
2
2
  import chalk from 'chalk';
3
3
  import { TaskOptions } from '../Gulpfile';
4
- import { blue, red } from '../index.js';
4
+ import { blue, orange, red } from '../index.js';
5
5
 
6
6
  export function copyFiles(options: TaskOptions) {
7
- const { outputDir} = options;
8
-
9
- return () => {
10
- return gulp.src([
11
- 'typescript/**/*',
12
- '!typescript/*tsconfig.json',
13
- '!typescript/**/*.ts',
14
- '!typescript/**/*.tsx',
15
- '!typescript/types/**/**',
16
- '!typescript/__mocks__/**/**',
17
- '!typescript/styles/**',
18
- ])
19
- .pipe(gulp.dest(outputDir))
20
- .on('error', function () {
21
- console.log("💩" + red.underline.bold(' => Copy of files failed!'));
22
- this.emit('end');
23
- })
24
- .on('end', function() { console.log("🐶" + blue.underline(' => Copy of files succeeded!')); });
7
+ const folders = ['typescript'];
8
+ if (options.modulesSync){
9
+ for (const module of Object.keys(options.modulesSync)) {
10
+ folders.push(module);
11
+ }
25
12
  }
26
- }
27
13
 
28
- export function copyFilesLib(options: TaskOptions) {
29
- const { outputDir} = options;
14
+ // Create tasks for each folder
15
+ const tasks = folders.map((folder) => {
16
+ const { outputDir} = options;
30
17
 
31
- return () => {
32
- return gulp.src([
33
- 'typescript/**/*',
34
- '!typescript/*tsconfig.json',
35
- '!typescript/**/*.ts',
36
- '!typescript/**/*.tsx',
37
- '!typescript/types/**/**',
38
- '!typescript/__mocks__/**/**',
39
- '!typescript/styles/**',
40
- ])
41
- .pipe(gulp.dest(outputDir))
42
- .on('error', function () {
43
- console.log("💩" + red.underline.bold(' => Copy of files (LIB) failed!'));
44
- this.emit('end');
45
- })
46
- .on('end', function() { console.log("🐶" + blue.underline(' => Copy of files (LIB) succeeded!')); });
47
- }
48
- }
18
+
19
+ const taskName = `copy-${folder}`; // Create a unique name for each task
20
+
21
+ const task = () =>
22
+ gulp.src([
23
+ `${folder}/**/*`,
24
+ `!${folder}/*tsconfig.json`,
25
+ `!${folder}/**/*.ts`,
26
+ `!${folder}/**/*.tsx`,
27
+ `!${folder}/types/**/**`,
28
+ `!${folder}/__mocks__/**/**`,
29
+ `!${folder}/styles/**`,
30
+ ])
31
+ .pipe(gulp.dest(outputDir))
32
+ .on('error', function () {
33
+ console.log("💩" + red.underline.bold(` => Copy of files for ${orange(folder)} failed!`));
34
+ this.emit('end');
35
+ })
36
+ .on('end', function () {
37
+ console.log("🐶" + blue.underline(` => Copy of files for ${orange(folder)} succeeded!`));
38
+ });
39
+
40
+ // Register the task with Gulp
41
+ Object.defineProperty(task, 'name', { value: taskName }); // Set a unique name for debugging
42
+ return task;
43
+ });
44
+
45
+ // Run all tasks in parallel
46
+ return gulp.parallel(...tasks);
47
+ }
@@ -0,0 +1,9 @@
1
+
2
+ import * as path from 'path';
3
+ import * as fs from 'fs';
4
+
5
+ export function getModulesSync(): Record<string, string> | undefined {
6
+ const absolutePath = path.resolve('./lucy.json');
7
+ const fileContent = fs.readFileSync(absolutePath, 'utf8') as any;
8
+ return JSON.parse(fileContent).modules;
9
+ }
@@ -3,62 +3,51 @@ import { createGulpEsbuild } from 'gulp-esbuild';
3
3
 
4
4
  import * as path from 'path';
5
5
  import { TaskOptions } from '../Gulpfile';
6
- import { blue, red } from '../index.js';
6
+ import { blue, orange, red } from '../index.js';
7
7
 
8
8
  export function buildPublic(options: TaskOptions) {
9
+ const folders = ['typescript'];
10
+ if (options.modulesSync){
11
+ for (const module of Object.keys(options.modulesSync)) {
12
+ folders.push(module);
13
+ }
14
+ }
15
+
9
16
  const { outputDir, enableIncrementalBuild } = options;
10
17
  const gulpEsbuild = createGulpEsbuild({
11
18
  incremental: enableIncrementalBuild,
12
19
  });
13
20
 
14
- return () => {
15
- return gulp.src([
16
- 'typescript/public/**/*.ts',
17
- 'typescript/public/**/*.tsx',
18
- ])
19
- .pipe(gulpEsbuild({
20
- bundle: false,
21
- loader: {
22
- '.tsx': 'tsx',
23
- },
24
- }))
25
- .pipe(gulp.dest(path.join(outputDir, 'public')))
26
- .on('error', function () {
27
- console.log("💩" + red.underline.bold(' => Build of Public TS files failed!'));
28
- this.emit('end');
29
- })
30
- .on('end', function () {
31
- console.log("🐶" + blue.underline(' => Build of Public TS files succeeded!'));
32
- });
33
- };
34
- }
21
+ // Create tasks for each folder
22
+ const tasks = folders.map((folder) => {
23
+ const taskName = `build_Public-${folder}`; // Create a unique name for each task
35
24
 
36
- export function buildPublicLib(options: TaskOptions) {
37
- const { outputDir, enableIncrementalBuild } = options;
38
- const gulpEsbuild = createGulpEsbuild({
39
- incremental: enableIncrementalBuild,
25
+ const task = () =>
26
+ gulp.src([
27
+ `${folder}/public/**/*.ts`,
28
+ `${folder}/public/**/*.tsx`,
29
+ ])
30
+ .pipe(gulpEsbuild({
31
+ bundle: false,
32
+ loader: {
33
+ '.tsx': 'tsx',
34
+ },
35
+ }))
36
+ .pipe(gulp.dest(path.join(outputDir, 'public')))
37
+ .on('error', function () {
38
+ console.log("💩" + red.underline.bold(` => Build of Public files for ${orange(folder)} failed!`));
39
+ this.emit('end');
40
+ })
41
+ .on('end', function () {
42
+ console.log("🐶" + blue.underline(` => Build of Public files for ${orange(folder)} succeeded!`));
43
+ });
44
+
45
+ // Register the task with Gulp
46
+ Object.defineProperty(task, 'name', { value: taskName }); // Set a unique name for debugging
47
+ return task;
40
48
  });
41
49
 
42
- return () => {
43
- return gulp.src([
44
- 'lib/public/**/*.ts',
45
- 'lib/public/**/*.tsx'
46
- ])
47
- .pipe(gulpEsbuild({
48
- bundle: false,
49
- loader: {
50
- '.tsx': 'tsx',
51
- },
52
- }))
53
- .pipe(gulp.dest(path.join(outputDir, 'public')))
54
- .on('error', function () {
55
- console.log("💩" + red.underline.bold(' => Build of Public (LIB) TS files failed!'));
56
- this.emit('end');
57
- })
58
- .on('end', function () {
59
- console.log("🐶" + blue.underline(' => Build of Public (LIB) TS files succeeded!'));
60
- });
61
- };
50
+ // Run all tasks in parallel
51
+ return gulp.parallel(...tasks);
62
52
  }
63
53
 
64
-
@@ -1,21 +1,40 @@
1
1
  import gulp from 'gulp';
2
2
  import chalk from 'chalk';
3
3
  import { TaskOptions } from '../Gulpfile';
4
- import { blue, red } from '../index.js';
4
+ import { blue, orange, red } from '../index.js';
5
5
 
6
6
  export function compileScss(options: TaskOptions) {
7
+ const folders = ['typescript'];
8
+ // if (options.modulesSync){
9
+ // for (const module of Object.keys(options.modulesSync)) {
10
+ // folders.push(module);
11
+ // }
12
+ // }
13
+
7
14
  const { sass, outputDir} = options;
8
15
 
9
- return () => {
10
- return gulp.src(['typescript/styles/global.scss'])
11
- .pipe(sass().on('error', sass.logError))
12
- .pipe(gulp.dest(`${outputDir}/styles`))
13
- .on('error', function () {
14
- console.log("💩" + red.underline.bold(' => Compiling of scss files failed!'));
15
- this.emit('end');
16
- })
17
- .on('end', function () {
18
- console.log("🐶" + blue.underline(' => Compiling of scss files succeeded!'));
19
- });
20
- };
16
+
17
+ // Create tasks for each folder
18
+ const tasks = folders.map((folder) => {
19
+ const taskName = `compile_sass-${folder}`; // Create a unique name for each task
20
+
21
+ const task = () =>
22
+ gulp.src(['typescript/styles/global.scss'])
23
+ .pipe(sass().on('error', sass.logError))
24
+ .pipe(gulp.dest(`${outputDir}/styles`))
25
+ .on('error', function () {
26
+ console.log("💩" + red.underline.bold(` => Compiling of scss files for ${orange(folder)} failed!`));
27
+ this.emit('end');
28
+ })
29
+ .on('end', function () {
30
+ console.log("🐶" + blue.underline(` => Compiling of scss files for ${orange(folder)} succeeded!`));
31
+ });
32
+
33
+ // Register the task with Gulp
34
+ Object.defineProperty(task, 'name', { value: taskName }); // Set a unique name for debugging
35
+ return task;
36
+ });
37
+
38
+ // Run all tasks in parallel
39
+ return gulp.parallel(...tasks);
21
40
  }
@@ -1,44 +1,43 @@
1
1
  import gulp from 'gulp';
2
- import { File } from '../Gulpfile';
2
+ import { File, TaskOptions } from '../Gulpfile';
3
3
  import exec from 'gulp-exec';
4
- import { blue, red } from '../index.js';
4
+ import { blue, orange, red } from '../index.js';
5
5
 
6
- export function previewTemplates() {
7
- const options = {
8
- continueOnError: true,
9
- };
10
-
11
- return () => {
12
- return gulp.src([
13
- 'typescript/backend/templates/**/*.tsx',
14
- 'typescript/backend/templates/data/*.json',
15
- '!typescript/backend/templates/render.ts',
16
- ])
17
- .pipe(exec((file: File) => `npx ts-node-esm -T ${file.path}`, options))
18
- .on('error', function () {
19
- console.log("💩" + red.underline.bold(' => Render of Template failed!'));
20
- this.emit('end');
21
- })
22
- .on('end', function() { console.log("🐶" + blue.underline(' => Render of Template succeeded!')); });
23
- };
24
- }
25
-
26
- export function previewTemplatesLib() {
27
- const options = {
28
- continueOnError: true,
29
- };
30
-
31
- return () => {
32
- return gulp.src([
33
- 'lib/backend/templates/**/*.tsx',
34
- 'lib/backend/templates/data/*.json',
35
- '!lib/backend/templates/render.ts',
36
- ])
37
- .pipe(exec((file: File) => `npx ts-node-esm -T ${file.path}`, options))
38
- .on('error', function () {
39
- console.log("💩" + red.underline.bold(' => Render of Template (LIB) failed!'));
40
- this.emit('end');
41
- })
42
- .on('end', function() { console.log("🐶" + blue.underline(' => Render of Template (LIB) succeeded!')); });
6
+ export function previewTemplates(options: TaskOptions) {
7
+ const folders = ['typescript'];
8
+ if (options.modulesSync){
9
+ for (const module of Object.keys(options.modulesSync)) {
10
+ folders.push(module);
11
+ }
12
+ }
13
+
14
+ const taskOpt = {
15
+ continueOnError: true,
43
16
  };
17
+
18
+ // Create tasks for each folder
19
+ const tasks = folders.map((folder) => {
20
+ const taskName = `render_templates-${folder}`; // Create a unique name for each task
21
+ const task = () =>
22
+ gulp.src([
23
+ `${folder}/backend/templates/**/*.tsx`,
24
+ `${folder}/backend/templates/data/*.json`,
25
+ `!${folder}/backend/templates/render.ts`,
26
+ ])
27
+ .pipe(exec((file: File) => `npx ts-node-esm -T ${file.path}`, taskOpt))
28
+ .on('error', function () {
29
+ console.log("💩" + red.underline.bold(` => Render of Template for ${orange(folder)} failed!`));
30
+ this.emit('end');
31
+ })
32
+ .on('end', function () {
33
+ console.log("🐶" + blue.underline(` => Render of Template for ${orange(folder)} succeeded!`));
34
+ });
35
+
36
+ // Register the task with Gulp
37
+ Object.defineProperty(task, 'name', { value: taskName }); // Set a unique name for debugging
38
+ return task;
39
+ });
40
+
41
+ // Run all tasks in parallel
42
+ return gulp.parallel(...tasks);
44
43
  }