@cley_faye/boilerplate 3.21.2 → 4.0.1

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.
Files changed (44) hide show
  1. package/README.md +7 -220
  2. package/bin/serve_spa.js +0 -1
  3. package/lib/bin/serve_spa.js +67 -39
  4. package/lib/express/middlewares/singlepageapp.d.ts +2 -2
  5. package/lib/express/middlewares/singlepageapp.js +20 -13
  6. package/lib/grunt/args.d.ts +14 -42
  7. package/lib/grunt/args.js +27 -41
  8. package/lib/grunt/reactapp/copy.d.ts +8 -34
  9. package/lib/grunt/reactapp/copy.js +47 -49
  10. package/lib/grunt/reactapp/image.d.ts +8 -23
  11. package/lib/grunt/reactapp/image.js +45 -42
  12. package/lib/grunt/reactapp/pug.d.ts +8 -30
  13. package/lib/grunt/reactapp/pug.js +49 -50
  14. package/lib/grunt/reactapp/sass.d.ts +8 -29
  15. package/lib/grunt/reactapp/sass.js +48 -43
  16. package/lib/grunt/reactapp/util.d.ts +5 -9
  17. package/lib/grunt/reactapp/util.js +12 -15
  18. package/lib/grunt/reactapp/webpack.d.ts +10 -81
  19. package/lib/grunt/reactapp/webpack.js +72 -132
  20. package/lib/grunt/reactapp.d.ts +22 -65
  21. package/lib/grunt/reactapp.js +70 -93
  22. package/lib/grunt/util.d.ts +4 -7
  23. package/lib/grunt/util.js +5 -8
  24. package/lib/grunt.d.ts +2 -3
  25. package/lib/grunt.js +5 -5
  26. package/lib/util.js +5 -4
  27. package/package.json +24 -36
  28. package/grunt.js +0 -3
  29. package/lib/express/autoclose.d.ts +0 -17
  30. package/lib/express/autoclose.js +0 -76
  31. package/lib/express/logger.d.ts +0 -25
  32. package/lib/express/logger.js +0 -132
  33. package/lib/express/middlewares/bodylogger.d.ts +0 -9
  34. package/lib/express/middlewares/bodylogger.js +0 -90
  35. package/lib/express/pipelinebuilder.d.ts +0 -115
  36. package/lib/express/pipelinebuilder.js +0 -288
  37. package/lib/express/unprocessableentityerror.d.ts +0 -8
  38. package/lib/express/unprocessableentityerror.js +0 -57
  39. package/lib/express.d.ts +0 -158
  40. package/lib/express.js +0 -218
  41. package/lib/repl.d.ts +0 -27
  42. package/lib/repl.js +0 -68
  43. package/lib/winston.d.ts +0 -38
  44. package/lib/winston.js +0 -224
@@ -1,6 +1,6 @@
1
- import { BaseOptions } from "../util.js";
2
- import { HandlerFunctionResult } from "../reactapp.js";
3
- import { GruntConfig } from "./util.js";
1
+ import { type HandlerFunctionResult } from "../reactapp.js";
2
+ import { type BaseOptions } from "../util.js";
3
+ import * as util from "./util.js";
4
4
  interface SassOptionsOptions {
5
5
  implementation?: Record<string, unknown>;
6
6
  }
@@ -12,35 +12,14 @@ export interface SassOptions extends BaseOptions {
12
12
  }
13
13
  /** Add an sass processing task to the Grunt configuration
14
14
  *
15
- * @param gruntConfig
16
- * Grunt configuration to add the task to
15
+ * @param gruntConfig - Grunt configuration to add the task to
17
16
  *
18
- * @param targetName
19
- * Name of the target for the image minification task.
17
+ * @param targetName - Name of the target for the image minification task.
20
18
  *
21
- * @param sassOptions
22
- * Options for the sass task configuration.
19
+ * @param sassOptions - Options for the sass task configuration.
23
20
  *
24
- * @param sassOptions.options
25
- * Options to pass to grunt-sass.
26
- *
27
- * @param [sassOptions.options.implementation]
28
- * Implementation to use. Defaults to require("sass").
29
- *
30
- * @param [sassOptions.sourcePath]
31
- * Path where the pug templates can be found. Subdirectories will be searched.
32
- * Default to "webres/<targetName>"
33
- *
34
- * @param [sassOptions.outputPath]
35
- * Path to put the output files into. The source directory tree will be
36
- * preserved.
37
- * Defaults to "dist/<targetName>"
38
- *
39
- * @param [sassOptions.fileSuffix]
40
- * Output files suffix. Defaults to ".css"
41
- *
42
- * @return
21
+ * @returns
43
22
  * List of tasks added to the grunt configuration
44
23
  */
45
- export declare const handle: (gruntConfig: GruntConfig, targetName: string, sassOptions: SassOptions) => HandlerFunctionResult;
24
+ export declare const handle: (gruntConfig: util.GruntConfig, targetName: string, sassOptions: SassOptions) => HandlerFunctionResult;
46
25
  export {};
@@ -25,80 +25,85 @@
25
25
  *
26
26
  */
27
27
  "use strict";
28
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
29
+ if (k2 === undefined) k2 = k;
30
+ var desc = Object.getOwnPropertyDescriptor(m, k);
31
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
32
+ desc = { enumerable: true, get: function() { return m[k]; } };
33
+ }
34
+ Object.defineProperty(o, k2, desc);
35
+ }) : (function(o, m, k, k2) {
36
+ if (k2 === undefined) k2 = k;
37
+ o[k2] = m[k];
38
+ }));
39
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
40
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
41
+ }) : function(o, v) {
42
+ o["default"] = v;
43
+ });
44
+ var __importStar = (this && this.__importStar) || (function () {
45
+ var ownKeys = function(o) {
46
+ ownKeys = Object.getOwnPropertyNames || function (o) {
47
+ var ar = [];
48
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
49
+ return ar;
50
+ };
51
+ return ownKeys(o);
52
+ };
53
+ return function (mod) {
54
+ if (mod && mod.__esModule) return mod;
55
+ var result = {};
56
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
57
+ __setModuleDefault(result, mod);
58
+ return result;
59
+ };
60
+ })();
28
61
  Object.defineProperty(exports, "__esModule", { value: true });
29
62
  exports.handle = void 0;
30
63
  const path_1 = require("path");
31
- const util_js_1 = require("./util.js");
64
+ const util = __importStar(require("./util.js"));
32
65
  /** File extensions handled by this task */
33
- const handledExtensions = [
34
- ".scss",
35
- ".sass",
36
- ];
66
+ const handledExtensions = [".scss", ".sass"];
37
67
  /** Add an sass processing task to the Grunt configuration
38
68
  *
39
- * @param gruntConfig
40
- * Grunt configuration to add the task to
41
- *
42
- * @param targetName
43
- * Name of the target for the image minification task.
44
- *
45
- * @param sassOptions
46
- * Options for the sass task configuration.
47
- *
48
- * @param sassOptions.options
49
- * Options to pass to grunt-sass.
50
- *
51
- * @param [sassOptions.options.implementation]
52
- * Implementation to use. Defaults to require("sass").
69
+ * @param gruntConfig - Grunt configuration to add the task to
53
70
  *
54
- * @param [sassOptions.sourcePath]
55
- * Path where the pug templates can be found. Subdirectories will be searched.
56
- * Default to "webres/<targetName>"
71
+ * @param targetName - Name of the target for the image minification task.
57
72
  *
58
- * @param [sassOptions.outputPath]
59
- * Path to put the output files into. The source directory tree will be
60
- * preserved.
61
- * Defaults to "dist/<targetName>"
73
+ * @param sassOptions - Options for the sass task configuration.
62
74
  *
63
- * @param [sassOptions.fileSuffix]
64
- * Output files suffix. Defaults to ".css"
65
- *
66
- * @return
75
+ * @returns
67
76
  * List of tasks added to the grunt configuration
68
77
  */
69
78
  const handle = (gruntConfig, targetName, sassOptions) => {
70
79
  const handledFiles = [
71
- ...handledExtensions.map(ext => `**/*${ext}`),
72
- ...handledExtensions.map(ext => `!**/_*${ext}`),
73
- ...handledExtensions.map(ext => `!**/*.inc${ext}`),
80
+ ...handledExtensions.map((ext) => `**/*${ext}`),
81
+ ...handledExtensions.map((ext) => `!**/_*${ext}`),
82
+ ...handledExtensions.map((ext) => `!**/*.inc${ext}`),
74
83
  ];
75
84
  const sassTask = {
76
85
  options: { ...sassOptions.options },
77
86
  files: [
78
87
  {
79
- expand: true,
80
88
  cwd: sassOptions.sourcePath ?? (0, path_1.join)("webres", targetName),
81
- src: handledFiles,
82
89
  dest: sassOptions.outputPath ?? (0, path_1.join)("dist", targetName),
90
+ expand: true,
83
91
  ext: sassOptions.fileSuffix ?? ".css",
92
+ src: handledFiles,
84
93
  },
85
94
  ],
86
95
  };
87
96
  if (sassTask.options.implementation === undefined) {
88
- // eslint-disable-next-line @typescript-eslint/no-require-imports, global-require, @typescript-eslint/no-var-requires
97
+ // eslint-disable-next-line @typescript-eslint/no-require-imports
89
98
  sassTask.options.implementation = require("sass");
90
99
  }
91
- const requiredTasks = [(0, util_js_1.insertTask)(gruntConfig, "sass", targetName, sassTask)];
100
+ const requiredTasks = [util.insertTask(gruntConfig, "sass", targetName, sassTask)];
92
101
  const watchTasks = [
93
102
  {
94
- filesToWatch: [...handledExtensions.map(ext => `**/*${ext}`)],
103
+ filesToWatch: [...handledExtensions.map((ext) => `**/*${ext}`)],
95
104
  taskToRun: requiredTasks[0],
96
105
  },
97
106
  ];
98
- return {
99
- requiredTasks,
100
- handledFiles,
101
- watchTasks,
102
- };
107
+ return { handledFiles, requiredTasks, watchTasks };
103
108
  };
104
109
  exports.handle = handle;
@@ -2,19 +2,15 @@ export type DynamicTaskFunc = () => Promise<void>;
2
2
  export type GruntConfig = Record<string, Record<string, Record<string, unknown> | (() => void) | undefined>>;
3
3
  /** Insert a new task in a grunt config object.
4
4
  *
5
- * @param gruntConfig
6
- * The grunt configuration, before sending it to initConfig()
5
+ * @param gruntConfig - The grunt configuration, before sending it to initConfig()
7
6
  *
8
- * @param taskType
9
- * The task type name (first level of grunt config object)
7
+ * @param taskType - The task type name (first level of grunt config object)
10
8
  *
11
- * @param taskName
12
- * The task name under a givne type (second level of grunt config object)
9
+ * @param taskName - The task name under a givne type (second level of grunt config object)
13
10
  *
14
- * @param taskDef
15
- * The task definition to insert
11
+ * @param taskDef - The task definition to insert
16
12
  *
17
- * @return
13
+ * @returns
18
14
  * The task full name to reference in registerTask()
19
15
  */
20
16
  export declare const insertTask: (gruntConfig: GruntConfig, taskType: string, taskName: string, taskDef: Record<string, unknown>) => string;
@@ -29,25 +29,20 @@ Object.defineProperty(exports, "__esModule", { value: true });
29
29
  exports.insertDynamicTask = exports.dynamicKey = exports.insertTask = void 0;
30
30
  /** Insert a new task in a grunt config object.
31
31
  *
32
- * @param gruntConfig
33
- * The grunt configuration, before sending it to initConfig()
32
+ * @param gruntConfig - The grunt configuration, before sending it to initConfig()
34
33
  *
35
- * @param taskType
36
- * The task type name (first level of grunt config object)
34
+ * @param taskType - The task type name (first level of grunt config object)
37
35
  *
38
- * @param taskName
39
- * The task name under a givne type (second level of grunt config object)
36
+ * @param taskName - The task name under a givne type (second level of grunt config object)
40
37
  *
41
- * @param taskDef
42
- * The task definition to insert
38
+ * @param taskDef - The task definition to insert
43
39
  *
44
- * @return
40
+ * @returns
45
41
  * The task full name to reference in registerTask()
46
42
  */
47
43
  const insertTask = (gruntConfig, taskType, taskName, taskDef) => {
48
- if (!(taskType in gruntConfig)) {
44
+ if (!(taskType in gruntConfig))
49
45
  gruntConfig[taskType] = {};
50
- }
51
46
  const taskFullName = `${taskType}:${taskName}`;
52
47
  if (gruntConfig[taskType][taskName] !== undefined) {
53
48
  throw new Error(`Grunt task ${taskFullName} already defined`);
@@ -58,14 +53,16 @@ const insertTask = (gruntConfig, taskType, taskName, taskDef) => {
58
53
  exports.insertTask = insertTask;
59
54
  exports.dynamicKey = "_dynamic";
60
55
  const insertDynamicTask = (gruntConfig, taskType, taskName, task) => {
61
- if (!(exports.dynamicKey in gruntConfig)) {
56
+ if (!(exports.dynamicKey in gruntConfig))
62
57
  gruntConfig[exports.dynamicKey] = {};
63
- }
64
58
  const taskFullName = `${taskType}_${taskName}`;
65
59
  gruntConfig[exports.dynamicKey][taskFullName] = function dynamicTask() {
66
60
  const done = this.async();
67
- task().then(() => done())
68
- .catch(e => done(e));
61
+ task()
62
+ // eslint-disable-next-line promise/prefer-await-to-then, promise/no-callback-in-promise
63
+ .then(() => done())
64
+ // eslint-disable-next-line promise/prefer-await-to-then, promise/no-callback-in-promise
65
+ .catch((e) => done(e));
69
66
  };
70
67
  return taskFullName;
71
68
  };
@@ -1,7 +1,7 @@
1
- import { ResolveOptions } from "webpack";
2
- import { BaseOptions } from "../util.js";
3
- import { HandlerFunctionResult } from "../reactapp.js";
4
- import { GruntConfig } from "./util.js";
1
+ import { type ResolveOptions } from "webpack";
2
+ import { type BaseOptions } from "../util.js";
3
+ import * as util from "./util.js";
4
+ import type * as reactApp from "../reactapp.js";
5
5
  export interface WebpackLoadersOptions {
6
6
  development?: boolean;
7
7
  defines?: Record<string, string>;
@@ -14,28 +14,7 @@ export interface WebpackLoadersOptions {
14
14
  }
15
15
  /** Build the default webpack loaders list.
16
16
  *
17
- * Uses babel and eslint. Some options can be customized here.
18
- *
19
- * @param [options]
20
- * @param [options.development]
21
- * true for development-friendly options, false for production options
22
- *
23
- * @param [options.defines]
24
- * List of defines to set using Babel transform-define
25
- *
26
- * @param [options.babel]
27
- * @param [options.babel.corejs]
28
- * Version of core-js to use (default to 3)
29
- *
30
- * @param [options.babel.targets]
31
- * Browser targets (default to "> 2% and not dead, last 2 safari version, last 2 firefox version,
32
- * last 2 chrome version, last 2 edge version, Firefox ESR")
33
- *
34
- * @param [options.babel.plugins]
35
- * Plugins to add to babel
36
- *
37
- * @param [options.typescript]
38
- * Add support for importing .ts and .tsx files
17
+ * Uses babel. Some options can be customized here.
39
18
  */
40
19
  export declare const webpackLoadersDefault: (options: WebpackLoadersOptions) => Array<Record<string, unknown>>;
41
20
  export interface WebpackOptions extends BaseOptions {
@@ -57,64 +36,14 @@ export interface WebpackOptions extends BaseOptions {
57
36
  }
58
37
  /** Add a webpack task for the reactApp recipe
59
38
  *
60
- * @param gruntConfig
61
- * Grunt configuration to add the task to
62
- *
63
- * @param targetName
64
- * Name of the target for the image minification task.
65
- *
66
- * @param webpackOptions
67
- * Options for the webpack task configuration.
68
- *
69
- * @param [webpackOptions.options]
70
- * Options for webpack
71
- *
72
- * @param [webpackOptions.entry]
73
- * List of entrypoints.
74
- * Defaults to {targetName: "webres/<targetName>/js/loader.js"}
75
- *
76
- * @param [webpackOptions.externals]
77
- * List of external libraries.
78
- * Defaults to {}.
79
- *
80
- * @param [webpackOptions.output]
81
- * Configure webpack output location and name.
82
- * Defaults to {path: "dist/<targetName>/js", filename: "[name].js"}
83
- *
84
- * @param [webpackOptions.output.path]
85
- * Path to put the compiled files into.
86
- * It is possible to pass a completely different object as webpackOptions.output
87
- * than expected, it will be handed to webpack as-is.
88
- *
89
- * @param [webpackOptions.output.filename]
90
- * Template for output filename.
91
- * It is possible to pass a completely different object as webpackOptions.output
92
- * than expected, it will be handed to webpack as-is.
93
- *
94
- * @param [webpackOptions.loaders]
95
- * Configuration for webpack loaders. See webpack doc about module.rules.
96
- * Defaults to using babel with React configuration and eslint.
97
- * To customize the default behavior build an object with
98
- * webpackLoadersDefault().
99
- *
100
- * @param [webpackOptions.plugins]
101
- * Configuration for webpack plugins. See webpack doc about plugins.
102
- *
103
- * @param [webpackOptions.babelPlugins]
104
- * List of extra babel plugins.
105
- *
106
- * @param [webpackOptions.mode]
107
- * Build mode. "development", "production" or "none".
108
- * Defaults to "development"
39
+ * @param gruntConfig - Grunt configuration to add the task to
109
40
  *
110
- * @param [webpackOptions.generateReport]
111
- * Generate a bundle report HTML file.
41
+ * @param targetName - Name of the target for the image minification task.
112
42
  *
113
- * @param [webpackOptions.typescript]
114
- * Allow loading typescript source for webpack/babel.
43
+ * @param webpackOptions - Options for the webpack task configuration.
115
44
  *
116
- * @return
45
+ * @returns
117
46
  * List of tasks added.
118
47
  * This function add "webpack:<targetName>".
119
48
  */
120
- export declare const handle: (gruntConfig: GruntConfig, targetName: string, webpackOptions: WebpackOptions) => HandlerFunctionResult;
49
+ export declare const handle: (gruntConfig: util.GruntConfig, targetName: string, webpackOptions: WebpackOptions) => reactApp.HandlerFunctionResult;