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.
@@ -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
  }
package/src/gulp/test.ts CHANGED
@@ -1,82 +1,62 @@
1
1
  import gulp from 'gulp';
2
- import { blue, red } from '../index.js';
2
+ import { blue, orange, red } from '../index.js';
3
3
  import gulpJest from 'gulp-jest';
4
+ import { TaskOptions } from '../Gulpfile.js';
4
5
  const jest = gulpJest.default;
5
6
 
6
- export function test() {
7
- return () => {
8
- return gulp.src([
9
- 'typescript/backend/**/*.spec.ts',
10
- ])
11
- .pipe(jest({
12
- verbose: true,
13
- extensionsToTreatAsEsm: ['.ts'],
14
- transform: {
15
- '^.+\\.tsx?$': [
16
- 'ts-jest',
17
- {
18
- tsconfig: './typescript/tsconfig.json',
19
- usESM: true,
20
- },
21
- ],
22
- },
23
- preset: 'ts-jest',
24
- setupFilesAfterEnv: [],
25
- testEnvironment: 'node',
26
- collectCoverage: true,
27
- coverageDirectory: '../coverage',
28
- coverageReporters: ['clover', 'json', 'lcov', 'text'],
29
- rootDir: './typescript',
30
- testMatch: ['**/*.spec.ts'],
31
- passWithNoTests: true,
32
- moduleNameMapper: {
33
- 'public/(.*)': '<rootDir>/public/$1'
34
- }
35
- }))
36
- .on('error', function () {
37
- console.log("💩" + red.underline.bold(' => Tests failed!'));
38
- this.emit('end');
39
- })
40
- .on('end', function() { console.log("🐶" + blue.underline(' => Test succeeded!'));
7
+ export function test(options: TaskOptions) {
8
+ const folders = ['typescript'];
9
+ if (options.modulesSync){
10
+ for (const module of Object.keys(options.modulesSync)) {
11
+ folders.push(module);
41
12
  }
42
- )}
43
- }
13
+ }
14
+
15
+ // Create tasks for each folder
16
+ const tasks = folders.map((folder) => {
17
+ const taskName = `tests-${folder}`; // Create a unique name for each task
18
+ const task = () =>
19
+ gulp.src([
20
+ `${folder}/backend/**/*.spec.ts`,
21
+ ])
22
+ .pipe(jest({
23
+ verbose: true,
24
+ extensionsToTreatAsEsm: ['.ts'],
25
+ transform: {
26
+ '^.+\\.tsx?$': [
27
+ 'ts-jest',
28
+ {
29
+ tsconfig: `./${folder}/tsconfig.json`,
30
+ usESM: true,
31
+ },
32
+ ],
33
+ },
34
+ preset: 'ts-jest',
35
+ setupFilesAfterEnv: [],
36
+ testEnvironment: 'node',
37
+ collectCoverage: true,
38
+ coverageDirectory: './coverage',
39
+ coverageReporters: ['clover', 'json', 'lcov', 'text'],
40
+ rootDir: `./${folder}`,
41
+ testMatch: ['**/*.spec.ts'],
42
+ passWithNoTests: true,
43
+ moduleNameMapper: {
44
+ 'public/(.*)': '<rootDir>/public/$1'
45
+ }
46
+ }))
47
+ .on('error', function () {
48
+ console.log("💩" + red.underline.bold(` => Tests for ${orange(folder)} failed!`));
49
+ this.emit('end');
50
+ })
51
+ .on('end', function () {
52
+ console.log("🐶" + blue.underline(` => Tests for ${orange(folder)} succeeded!`));
53
+ });
44
54
 
45
- export function testLib() {
46
- return () => {
47
- return gulp.src([
48
- 'lib/backend/**/*.spec.ts',
49
- ])
50
- .pipe(jest({
51
- verbose: true,
52
- extensionsToTreatAsEsm: ['.ts'],
53
- transform: {
54
- '^.+\\.tsx?$': [
55
- 'ts-jest',
56
- {
57
- tsconfig: './lib/tsconfig.json',
58
- usESM: true,
59
- },
60
- ],
61
- },
62
- preset: 'ts-jest',
63
- setupFilesAfterEnv: [],
64
- testEnvironment: 'node',
65
- collectCoverage: true,
66
- passWithNoTests: true,
67
- coverageDirectory: './coverage',
68
- coverageReporters: ['clover', 'json', 'lcov', 'text'],
69
- rootDir: './lib',
70
- testMatch: ['**/*.spec.ts'],
71
- moduleNameMapper: {
72
- 'public/(.*)': '<rootDir>/public/$1'
73
- }
74
- }))
75
- .on('error', function () {
76
- console.log("💩" + red.underline.bold(' => Test (LIB) failed!'));
77
- this.emit('end');
78
- })
79
- .on('end', function() { console.log("🐶" + blue.underline(' => Test (LIB) succeeded!'));
80
- }
81
- )}
55
+ // Register the task with Gulp
56
+ Object.defineProperty(task, 'name', { value: taskName }); // Set a unique name for debugging
57
+ return task;
58
+ });
59
+
60
+ // Run all tasks in parallel
61
+ return gulp.parallel(...tasks);
82
62
  }