@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.
- package/README.md +7 -220
- package/bin/serve_spa.js +0 -1
- package/lib/bin/serve_spa.js +67 -39
- package/lib/express/middlewares/singlepageapp.d.ts +2 -2
- package/lib/express/middlewares/singlepageapp.js +20 -13
- package/lib/grunt/args.d.ts +14 -42
- package/lib/grunt/args.js +27 -41
- package/lib/grunt/reactapp/copy.d.ts +8 -34
- package/lib/grunt/reactapp/copy.js +47 -49
- package/lib/grunt/reactapp/image.d.ts +8 -23
- package/lib/grunt/reactapp/image.js +45 -42
- package/lib/grunt/reactapp/pug.d.ts +8 -30
- package/lib/grunt/reactapp/pug.js +49 -50
- package/lib/grunt/reactapp/sass.d.ts +8 -29
- package/lib/grunt/reactapp/sass.js +48 -43
- package/lib/grunt/reactapp/util.d.ts +5 -9
- package/lib/grunt/reactapp/util.js +12 -15
- package/lib/grunt/reactapp/webpack.d.ts +10 -81
- package/lib/grunt/reactapp/webpack.js +72 -132
- package/lib/grunt/reactapp.d.ts +22 -65
- package/lib/grunt/reactapp.js +70 -93
- package/lib/grunt/util.d.ts +4 -7
- package/lib/grunt/util.js +5 -8
- package/lib/grunt.d.ts +2 -3
- package/lib/grunt.js +5 -5
- package/lib/util.js +5 -4
- package/package.json +24 -36
- package/grunt.js +0 -3
- package/lib/express/autoclose.d.ts +0 -17
- package/lib/express/autoclose.js +0 -76
- package/lib/express/logger.d.ts +0 -25
- package/lib/express/logger.js +0 -132
- package/lib/express/middlewares/bodylogger.d.ts +0 -9
- package/lib/express/middlewares/bodylogger.js +0 -90
- package/lib/express/pipelinebuilder.d.ts +0 -115
- package/lib/express/pipelinebuilder.js +0 -288
- package/lib/express/unprocessableentityerror.d.ts +0 -8
- package/lib/express/unprocessableentityerror.js +0 -57
- package/lib/express.d.ts +0 -158
- package/lib/express.js +0 -218
- package/lib/repl.d.ts +0 -27
- package/lib/repl.js +0 -68
- package/lib/winston.d.ts +0 -38
- package/lib/winston.js +0 -224
package/lib/grunt/args.js
CHANGED
|
@@ -28,7 +28,6 @@
|
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
29
|
exports.getOptionsFromGruntCLI = exports.displayHelp = exports.OptType = void 0;
|
|
30
30
|
const util_js_1 = require("../util.js");
|
|
31
|
-
// eslint-disable-next-line no-shadow
|
|
32
31
|
var OptType;
|
|
33
32
|
(function (OptType) {
|
|
34
33
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
@@ -38,56 +37,44 @@ var OptType;
|
|
|
38
37
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
39
38
|
OptType["BOOLEAN"] = "boolean";
|
|
40
39
|
})(OptType || (exports.OptType = OptType = {}));
|
|
41
|
-
/**
|
|
42
|
-
* Process a string-type argument
|
|
43
|
-
*/
|
|
40
|
+
/** Process a string-type argument */
|
|
44
41
|
const handleOptionString = (rawValue) => {
|
|
45
|
-
if (typeof rawValue !== "string")
|
|
42
|
+
if (typeof rawValue !== "string")
|
|
46
43
|
throw new Error("Missing string argument");
|
|
47
|
-
}
|
|
48
44
|
return rawValue;
|
|
49
45
|
};
|
|
50
|
-
/**
|
|
51
|
-
* Process a number-type argument
|
|
52
|
-
*/
|
|
46
|
+
/** Process a number-type argument */
|
|
53
47
|
const handleOptionNumber = (rawValue) => {
|
|
54
|
-
if (typeof rawValue !== "string")
|
|
48
|
+
if (typeof rawValue !== "string")
|
|
55
49
|
throw new Error("Missing number argument");
|
|
56
|
-
}
|
|
57
50
|
const asNumber = Number.parseFloat(rawValue);
|
|
58
|
-
if (Number.isNaN(asNumber))
|
|
51
|
+
if (Number.isNaN(asNumber))
|
|
59
52
|
throw new Error("Not a number");
|
|
60
|
-
}
|
|
61
53
|
return asNumber;
|
|
62
54
|
};
|
|
63
|
-
/**
|
|
64
|
-
* Process a boolean-type argument
|
|
65
|
-
*/
|
|
55
|
+
/** Process a boolean-type argument */
|
|
66
56
|
const handleOptionBoolean = (rawValue) => {
|
|
67
|
-
if (typeof rawValue !== "boolean")
|
|
57
|
+
if (typeof rawValue !== "boolean")
|
|
68
58
|
throw new Error("Missing boolean argument");
|
|
69
|
-
}
|
|
70
59
|
return rawValue;
|
|
71
60
|
};
|
|
72
|
-
/**
|
|
73
|
-
* Process one option from the list of expected arguments
|
|
74
|
-
*/
|
|
61
|
+
/** Process one option from the list of expected arguments */
|
|
75
62
|
const handleOptionDef = (optionDef, rawValue) => {
|
|
76
63
|
if (rawValue === undefined) {
|
|
77
|
-
if (optionDef.defaultValue === undefined)
|
|
64
|
+
if (optionDef.defaultValue === undefined)
|
|
78
65
|
throw new Error("Missing option");
|
|
79
|
-
}
|
|
80
66
|
return optionDef.defaultValue;
|
|
81
67
|
}
|
|
82
68
|
switch (optionDef.type) {
|
|
83
|
-
case OptType.STRING:
|
|
84
|
-
|
|
85
|
-
case OptType.
|
|
69
|
+
case OptType.STRING:
|
|
70
|
+
return handleOptionString(rawValue);
|
|
71
|
+
case OptType.NUMBER:
|
|
72
|
+
return handleOptionNumber(rawValue);
|
|
73
|
+
case OptType.BOOLEAN:
|
|
74
|
+
return handleOptionBoolean(rawValue);
|
|
86
75
|
}
|
|
87
76
|
};
|
|
88
|
-
/**
|
|
89
|
-
* Get a value from the command line
|
|
90
|
-
*/
|
|
77
|
+
/** Get a value from the command line */
|
|
91
78
|
const getFromOptionProvider = (keyName, optionProvider) => {
|
|
92
79
|
const kebabName = (0, util_js_1.camelToKebab)(keyName);
|
|
93
80
|
return optionProvider.option(kebabName);
|
|
@@ -96,14 +83,15 @@ const getFromOptionProvider = (keyName, optionProvider) => {
|
|
|
96
83
|
const outputHelp = (msg) => console.log(msg);
|
|
97
84
|
const getTypeInfoString = (optionType, kebabName) => {
|
|
98
85
|
switch (optionType) {
|
|
99
|
-
case OptType.STRING:
|
|
100
|
-
|
|
101
|
-
case OptType.
|
|
86
|
+
case OptType.STRING:
|
|
87
|
+
return "=<string value>";
|
|
88
|
+
case OptType.NUMBER:
|
|
89
|
+
return "=<numeric value>";
|
|
90
|
+
case OptType.BOOLEAN:
|
|
91
|
+
return ` (use --no-${kebabName} to disable)`;
|
|
102
92
|
}
|
|
103
93
|
};
|
|
104
|
-
/**
|
|
105
|
-
* Display help for a single parameter
|
|
106
|
-
*/
|
|
94
|
+
/** Display help for a single parameter */
|
|
107
95
|
const displayHelpForConfigKey = (keyName, optionDef) => {
|
|
108
96
|
const isMandatory = optionDef.defaultValue === undefined;
|
|
109
97
|
const kebabName = (0, util_js_1.camelToKebab)(keyName);
|
|
@@ -113,17 +101,15 @@ const displayHelpForConfigKey = (keyName, optionDef) => {
|
|
|
113
101
|
const typeInfo = getTypeInfoString(optionDef.type, kebabName);
|
|
114
102
|
outputHelp(` --${kebabName}${typeInfo}${mandatoryString}`);
|
|
115
103
|
if (optionDef.description) {
|
|
116
|
-
optionDef.description.split("\n").forEach(line => {
|
|
104
|
+
optionDef.description.split("\n").forEach((line) => {
|
|
117
105
|
outputHelp(` ${line}`);
|
|
118
106
|
});
|
|
119
107
|
}
|
|
120
108
|
};
|
|
121
|
-
/**
|
|
122
|
-
* Display help to the user
|
|
123
|
-
*/
|
|
109
|
+
/** Display help to the user */
|
|
124
110
|
const displayHelp = (configDef) => {
|
|
125
111
|
outputHelp("Accepted command line arguments:");
|
|
126
|
-
Object.keys(configDef).forEach(configKey => displayHelpForConfigKey(configKey, configDef[configKey]));
|
|
112
|
+
Object.keys(configDef).forEach((configKey) => displayHelpForConfigKey(configKey, configDef[configKey]));
|
|
127
113
|
};
|
|
128
114
|
exports.displayHelp = displayHelp;
|
|
129
115
|
/**
|
|
@@ -137,7 +123,7 @@ const getOptionsFromGruntCLI = (optionProvider, configDef) => {
|
|
|
137
123
|
return null;
|
|
138
124
|
}
|
|
139
125
|
const result = {};
|
|
140
|
-
Object.keys(configDef).forEach(keyName => {
|
|
126
|
+
Object.keys(configDef).forEach((keyName) => {
|
|
141
127
|
try {
|
|
142
128
|
result[keyName] = handleOptionDef(configDef[keyName], getFromOptionProvider(keyName, optionProvider));
|
|
143
129
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
1
|
+
import { type HandlerFunctionResult } from "../reactapp.js";
|
|
2
|
+
import { type BaseOptions } from "../util.js";
|
|
3
|
+
import * as util from "./util.js";
|
|
4
4
|
export interface CopyOptions extends BaseOptions {
|
|
5
5
|
options?: Record<string, unknown>;
|
|
6
6
|
excludedExtensions?: Array<string>;
|
|
@@ -12,39 +12,13 @@ export interface CopyOptions extends BaseOptions {
|
|
|
12
12
|
}
|
|
13
13
|
/** Add the copy task for a reactApp recipe.
|
|
14
14
|
*
|
|
15
|
-
* @param gruntConfig
|
|
16
|
-
* The Grunt configuration to add tasks to.
|
|
15
|
+
* @param gruntConfig - The Grunt configuration to add tasks to.
|
|
17
16
|
*
|
|
18
|
-
* @param targetName
|
|
19
|
-
* Name of the target for the pug task.
|
|
17
|
+
* @param targetName - Name of the target for the pug task.
|
|
20
18
|
*
|
|
21
|
-
* @param copyOptions
|
|
22
|
-
* Configuration for the pug task.
|
|
19
|
+
* @param copyOptions - Configuration for the pug task.
|
|
23
20
|
*
|
|
24
|
-
* @
|
|
25
|
-
* Valid options to pass directly to grunt-contrib-copy.
|
|
26
|
-
*
|
|
27
|
-
* @param [copyOptions.excludedExtensions]
|
|
28
|
-
* File extensions to not copy.
|
|
29
|
-
*
|
|
30
|
-
* @param [copyOptions.extraFiles]
|
|
31
|
-
* Add extra files to copy (to bypass excluded extensions)
|
|
32
|
-
*
|
|
33
|
-
* @param [copyOptions.sourcePath]
|
|
34
|
-
* Path to take source files from.
|
|
35
|
-
* Defaults to "webres/<targetName>"
|
|
36
|
-
*
|
|
37
|
-
* @param [copyOptions.outputPath]
|
|
38
|
-
* Path to put the output files into. The source directory tree will be
|
|
39
|
-
* preserved.
|
|
40
|
-
* Defaults to "dist/<targetName>"
|
|
41
|
-
*
|
|
42
|
-
* @param [copyOptions.dot]
|
|
43
|
-
* When expanding the globing pattern, includes files / directory starting with
|
|
44
|
-
* a dot.
|
|
45
|
-
* Defaults to false
|
|
46
|
-
*
|
|
47
|
-
* @return
|
|
21
|
+
* @returns
|
|
48
22
|
* The name of the tasks added to the gruntConfig object.
|
|
49
23
|
*/
|
|
50
|
-
export declare const handle: (gruntConfig: GruntConfig, targetName: string, copyOptions: CopyOptions) => HandlerFunctionResult;
|
|
24
|
+
export declare const handle: (gruntConfig: util.GruntConfig, targetName: string, copyOptions: CopyOptions) => HandlerFunctionResult;
|
|
@@ -25,75 +25,73 @@
|
|
|
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
|
|
64
|
+
const util = __importStar(require("./util.js"));
|
|
32
65
|
/** Add the copy task for a reactApp recipe.
|
|
33
66
|
*
|
|
34
|
-
* @param gruntConfig
|
|
35
|
-
* The Grunt configuration to add tasks to.
|
|
36
|
-
*
|
|
37
|
-
* @param targetName
|
|
38
|
-
* Name of the target for the pug task.
|
|
39
|
-
*
|
|
40
|
-
* @param copyOptions
|
|
41
|
-
* Configuration for the pug task.
|
|
42
|
-
*
|
|
43
|
-
* @param [copyOptions.options]
|
|
44
|
-
* Valid options to pass directly to grunt-contrib-copy.
|
|
45
|
-
*
|
|
46
|
-
* @param [copyOptions.excludedExtensions]
|
|
47
|
-
* File extensions to not copy.
|
|
48
|
-
*
|
|
49
|
-
* @param [copyOptions.extraFiles]
|
|
50
|
-
* Add extra files to copy (to bypass excluded extensions)
|
|
67
|
+
* @param gruntConfig - The Grunt configuration to add tasks to.
|
|
51
68
|
*
|
|
52
|
-
* @param
|
|
53
|
-
* Path to take source files from.
|
|
54
|
-
* Defaults to "webres/<targetName>"
|
|
69
|
+
* @param targetName - Name of the target for the pug task.
|
|
55
70
|
*
|
|
56
|
-
* @param
|
|
57
|
-
* Path to put the output files into. The source directory tree will be
|
|
58
|
-
* preserved.
|
|
59
|
-
* Defaults to "dist/<targetName>"
|
|
71
|
+
* @param copyOptions - Configuration for the pug task.
|
|
60
72
|
*
|
|
61
|
-
* @
|
|
62
|
-
* When expanding the globing pattern, includes files / directory starting with
|
|
63
|
-
* a dot.
|
|
64
|
-
* Defaults to false
|
|
65
|
-
*
|
|
66
|
-
* @return
|
|
73
|
+
* @returns
|
|
67
74
|
* The name of the tasks added to the gruntConfig object.
|
|
68
75
|
*/
|
|
69
76
|
const handle = (gruntConfig, targetName, copyOptions) => {
|
|
70
|
-
const srcList = ["**/*"]
|
|
71
|
-
.concat((copyOptions.
|
|
72
|
-
|
|
73
|
-
: `!${fileDef}`));
|
|
77
|
+
const srcList = ["**/*"]
|
|
78
|
+
.concat((copyOptions.excludedExtensions ?? []).map((ext) => `!**/*${ext}`))
|
|
79
|
+
.concat(copyOptions.extraFiles ?? [])
|
|
80
|
+
.concat((copyOptions.skipFiles ?? []).map((fileDef) => fileDef.startsWith("!") ? fileDef : `!${fileDef}`));
|
|
74
81
|
const copyTask = {
|
|
75
82
|
options: copyOptions.options,
|
|
76
83
|
files: [
|
|
77
84
|
{
|
|
85
|
+
cwd: copyOptions.sourcePath ?? (0, path_1.join)("webres", targetName),
|
|
86
|
+
dest: copyOptions.outputPath ?? (0, path_1.join)("dist", targetName),
|
|
78
87
|
dot: copyOptions.dot,
|
|
79
88
|
expand: true,
|
|
80
|
-
cwd: copyOptions.sourcePath ?? (0, path_1.join)("webres", targetName),
|
|
81
89
|
src: srcList,
|
|
82
|
-
dest: copyOptions.outputPath ?? (0, path_1.join)("dist", targetName),
|
|
83
90
|
},
|
|
84
91
|
],
|
|
85
92
|
};
|
|
86
|
-
const requiredTasks = [
|
|
87
|
-
const watchTasks = [
|
|
88
|
-
|
|
89
|
-
filesToWatch: srcList,
|
|
90
|
-
taskToRun: requiredTasks[0],
|
|
91
|
-
},
|
|
92
|
-
];
|
|
93
|
-
return {
|
|
94
|
-
requiredTasks,
|
|
95
|
-
handledFiles: srcList,
|
|
96
|
-
watchTasks,
|
|
97
|
-
};
|
|
93
|
+
const requiredTasks = [util.insertTask(gruntConfig, "copy", targetName, copyTask)];
|
|
94
|
+
const watchTasks = [{ filesToWatch: srcList, taskToRun: requiredTasks[0] }];
|
|
95
|
+
return { handledFiles: srcList, requiredTasks, watchTasks };
|
|
98
96
|
};
|
|
99
97
|
exports.handle = handle;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
1
|
+
import { type HandlerFunctionResult } from "../reactapp.js";
|
|
2
|
+
import { type BaseOptions } from "../util.js";
|
|
3
|
+
import * as util from "./util.js";
|
|
4
4
|
export interface ImageOptions extends BaseOptions {
|
|
5
5
|
options?: Record<string, unknown>;
|
|
6
6
|
sourcePath?: string;
|
|
@@ -8,28 +8,13 @@ export interface ImageOptions extends BaseOptions {
|
|
|
8
8
|
}
|
|
9
9
|
/** Add an image minification task to the Grunt configuration
|
|
10
10
|
*
|
|
11
|
-
* @param gruntConfig
|
|
12
|
-
* Grunt configuration to add the task to
|
|
11
|
+
* @param gruntConfig - Grunt configuration to add the task to
|
|
13
12
|
*
|
|
14
|
-
* @param targetName
|
|
15
|
-
* Name of the target for the image minification task.
|
|
13
|
+
* @param targetName - Name of the target for the image minification task.
|
|
16
14
|
*
|
|
17
|
-
* @param imageOptions
|
|
18
|
-
* Options for the image task configuration.
|
|
15
|
+
* @param imageOptions - Options for the image task configuration.
|
|
19
16
|
*
|
|
20
|
-
* @
|
|
21
|
-
* Options to pass to @cley_faye/imagemin-lite.
|
|
22
|
-
*
|
|
23
|
-
* @param [imageOptions.sourcePath]
|
|
24
|
-
* Path where the source images can be found. Subdirectories will be searched.
|
|
25
|
-
* Default to "webres/<targetName>"
|
|
26
|
-
*
|
|
27
|
-
* @param [imageOptions.outputPath]
|
|
28
|
-
* Path to put the output files into. The source directory tree will be
|
|
29
|
-
* preserved.
|
|
30
|
-
* Defaults to "dist/<targetName>"
|
|
31
|
-
*
|
|
32
|
-
* @return
|
|
17
|
+
* @returns
|
|
33
18
|
* List of tasks added to the grunt configuration
|
|
34
19
|
*/
|
|
35
|
-
export declare const handle: (gruntConfig: GruntConfig, targetName: string, imageOptions: ImageOptions) => HandlerFunctionResult;
|
|
20
|
+
export declare const handle: (gruntConfig: util.GruntConfig, targetName: string, imageOptions: ImageOptions) => HandlerFunctionResult;
|
|
@@ -25,69 +25,72 @@
|
|
|
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
|
|
64
|
+
const util = __importStar(require("./util.js"));
|
|
32
65
|
/** File extensions handled by this task */
|
|
33
|
-
const handledExtensions = [
|
|
34
|
-
".jpg",
|
|
35
|
-
".png",
|
|
36
|
-
".svg",
|
|
37
|
-
];
|
|
66
|
+
const handledExtensions = [".jpg", ".png", ".svg"];
|
|
38
67
|
/** Add an image minification task to the Grunt configuration
|
|
39
68
|
*
|
|
40
|
-
* @param gruntConfig
|
|
41
|
-
* Grunt configuration to add the task to
|
|
42
|
-
*
|
|
43
|
-
* @param targetName
|
|
44
|
-
* Name of the target for the image minification task.
|
|
45
|
-
*
|
|
46
|
-
* @param imageOptions
|
|
47
|
-
* Options for the image task configuration.
|
|
48
|
-
*
|
|
49
|
-
* @param [imageOptions.options]
|
|
50
|
-
* Options to pass to @cley_faye/imagemin-lite.
|
|
69
|
+
* @param gruntConfig - Grunt configuration to add the task to
|
|
51
70
|
*
|
|
52
|
-
* @param
|
|
53
|
-
* Path where the source images can be found. Subdirectories will be searched.
|
|
54
|
-
* Default to "webres/<targetName>"
|
|
71
|
+
* @param targetName - Name of the target for the image minification task.
|
|
55
72
|
*
|
|
56
|
-
* @param
|
|
57
|
-
* Path to put the output files into. The source directory tree will be
|
|
58
|
-
* preserved.
|
|
59
|
-
* Defaults to "dist/<targetName>"
|
|
73
|
+
* @param imageOptions - Options for the image task configuration.
|
|
60
74
|
*
|
|
61
|
-
* @
|
|
75
|
+
* @returns
|
|
62
76
|
* List of tasks added to the grunt configuration
|
|
63
77
|
*/
|
|
64
78
|
const handle = (gruntConfig, targetName, imageOptions) => {
|
|
65
|
-
const handledFiles = handledExtensions.map(ext => `**/*${ext}`);
|
|
79
|
+
const handledFiles = handledExtensions.map((ext) => `**/*${ext}`);
|
|
66
80
|
// TODO use @cley_faye/imagemin-lite once it exists
|
|
67
81
|
const newImageTask = {
|
|
68
82
|
options: imageOptions.options,
|
|
69
83
|
files: [
|
|
70
84
|
{
|
|
71
|
-
expand: true,
|
|
72
85
|
cwd: imageOptions.sourcePath ?? (0, path_1.join)("webres", targetName),
|
|
73
|
-
src: handledFiles,
|
|
74
86
|
dest: imageOptions.outputPath ?? (0, path_1.join)("dist", targetName),
|
|
87
|
+
expand: true,
|
|
88
|
+
src: handledFiles,
|
|
75
89
|
},
|
|
76
90
|
],
|
|
77
91
|
};
|
|
78
|
-
const requiredTasks = [
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
const watchTasks = [
|
|
82
|
-
{
|
|
83
|
-
filesToWatch: handledFiles,
|
|
84
|
-
taskToRun: requiredTasks[0],
|
|
85
|
-
},
|
|
86
|
-
];
|
|
87
|
-
return {
|
|
88
|
-
requiredTasks,
|
|
89
|
-
handledFiles,
|
|
90
|
-
watchTasks,
|
|
91
|
-
};
|
|
92
|
+
const requiredTasks = [util.insertTask(gruntConfig, "copy", `${targetName}_image`, newImageTask)];
|
|
93
|
+
const watchTasks = [{ filesToWatch: handledFiles, taskToRun: requiredTasks[0] }];
|
|
94
|
+
return { handledFiles, requiredTasks, watchTasks };
|
|
92
95
|
};
|
|
93
96
|
exports.handle = handle;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
1
|
+
import { type HandlerFunctionResult } from "../reactapp.js";
|
|
2
|
+
import { type BaseOptions } from "../util.js";
|
|
3
|
+
import * as util from "./util.js";
|
|
4
4
|
export type DynamicDataFunc = () => Promise<Record<string, unknown>>;
|
|
5
5
|
export interface PugOptions extends BaseOptions {
|
|
6
6
|
options?: Record<string, unknown>;
|
|
@@ -11,35 +11,13 @@ export interface PugOptions extends BaseOptions {
|
|
|
11
11
|
}
|
|
12
12
|
/** Add the pug task for a reactApp recipe.
|
|
13
13
|
*
|
|
14
|
-
* @param gruntConfig
|
|
15
|
-
* The Grunt configuration to add tasks to.
|
|
14
|
+
* @param gruntConfig - The Grunt configuration to add tasks to.
|
|
16
15
|
*
|
|
17
|
-
* @param targetName
|
|
18
|
-
* Name of the target for the pug task.
|
|
16
|
+
* @param targetName - Name of the target for the pug task.
|
|
19
17
|
*
|
|
20
|
-
* @param pugOptions
|
|
21
|
-
* Configuration for the pug task.
|
|
18
|
+
* @param pugOptions - Configuration for the pug task.
|
|
22
19
|
*
|
|
23
|
-
* @
|
|
24
|
-
* Valid options to pass directly to grunt-contrib-pug.
|
|
25
|
-
* Most notably, pugOptions.options.data can be set here.
|
|
26
|
-
*
|
|
27
|
-
* @param [pugOptions.sourcePath]
|
|
28
|
-
* Path where the pug templates can be found. Subdirectories will be searched.
|
|
29
|
-
* Default to "webres/<targetName>"
|
|
30
|
-
*
|
|
31
|
-
* @param [pugOptions.outputPath]
|
|
32
|
-
* Path to put the output files into. The source directory tree will be
|
|
33
|
-
* preserved.
|
|
34
|
-
* Defaults to "dist/<targetName>"
|
|
35
|
-
*
|
|
36
|
-
* @param [pugOptions.fileSuffix]
|
|
37
|
-
* Suffix for output files. Defaults to ".html"
|
|
38
|
-
*
|
|
39
|
-
* @param [pugOptions.dynamicData]
|
|
40
|
-
* A function that returns a promise with data to add to `options.data`
|
|
41
|
-
*
|
|
42
|
-
* @return
|
|
20
|
+
* @returns
|
|
43
21
|
* The name of the tasks added to the gruntConfig object.
|
|
44
22
|
*/
|
|
45
|
-
export declare const handle: (gruntConfig: GruntConfig, targetName: string, pugOptions: PugOptions) => HandlerFunctionResult;
|
|
23
|
+
export declare const handle: (gruntConfig: util.GruntConfig, targetName: string, pugOptions: PugOptions) => HandlerFunctionResult;
|
|
@@ -25,25 +25,57 @@
|
|
|
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
|
|
64
|
+
const util = __importStar(require("./util.js"));
|
|
32
65
|
/** File extensions handled by this task */
|
|
33
66
|
const handledExtensions = [".pug"];
|
|
34
67
|
const createDynamicTask = (gruntConfig, targetName, pugOptions, pugTask, requiredTasks) => {
|
|
35
68
|
if (!pugOptions.dynamicData) {
|
|
36
69
|
return;
|
|
37
70
|
}
|
|
38
|
-
requiredTasks.splice(0, 0,
|
|
71
|
+
requiredTasks.splice(0, 0, util.insertDynamicTask(gruntConfig, "pugDynamicData", targetName, () => {
|
|
39
72
|
if (!pugOptions.dynamicData) {
|
|
40
73
|
return Promise.reject(new Error("Missing expected function"));
|
|
41
74
|
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
}
|
|
75
|
+
// eslint-disable-next-line promise/prefer-await-to-then
|
|
76
|
+
return pugOptions.dynamicData().then((extraData) => {
|
|
77
|
+
// eslint-disable-next-line promise/always-return
|
|
78
|
+
pugTask.options ?? (pugTask.options = {});
|
|
47
79
|
pugTask.options.data = {
|
|
48
80
|
...pugTask.options.data,
|
|
49
81
|
...extraData,
|
|
@@ -53,65 +85,32 @@ const createDynamicTask = (gruntConfig, targetName, pugOptions, pugTask, require
|
|
|
53
85
|
};
|
|
54
86
|
/** Add the pug task for a reactApp recipe.
|
|
55
87
|
*
|
|
56
|
-
* @param gruntConfig
|
|
57
|
-
* The Grunt configuration to add tasks to.
|
|
58
|
-
*
|
|
59
|
-
* @param targetName
|
|
60
|
-
* Name of the target for the pug task.
|
|
61
|
-
*
|
|
62
|
-
* @param pugOptions
|
|
63
|
-
* Configuration for the pug task.
|
|
64
|
-
*
|
|
65
|
-
* @param [pugOptions.options]
|
|
66
|
-
* Valid options to pass directly to grunt-contrib-pug.
|
|
67
|
-
* Most notably, pugOptions.options.data can be set here.
|
|
68
|
-
*
|
|
69
|
-
* @param [pugOptions.sourcePath]
|
|
70
|
-
* Path where the pug templates can be found. Subdirectories will be searched.
|
|
71
|
-
* Default to "webres/<targetName>"
|
|
88
|
+
* @param gruntConfig - The Grunt configuration to add tasks to.
|
|
72
89
|
*
|
|
73
|
-
* @param
|
|
74
|
-
* Path to put the output files into. The source directory tree will be
|
|
75
|
-
* preserved.
|
|
76
|
-
* Defaults to "dist/<targetName>"
|
|
90
|
+
* @param targetName - Name of the target for the pug task.
|
|
77
91
|
*
|
|
78
|
-
* @param
|
|
79
|
-
* Suffix for output files. Defaults to ".html"
|
|
92
|
+
* @param pugOptions - Configuration for the pug task.
|
|
80
93
|
*
|
|
81
|
-
* @
|
|
82
|
-
* A function that returns a promise with data to add to `options.data`
|
|
83
|
-
*
|
|
84
|
-
* @return
|
|
94
|
+
* @returns
|
|
85
95
|
* The name of the tasks added to the gruntConfig object.
|
|
86
96
|
*/
|
|
87
97
|
const handle = (gruntConfig, targetName, pugOptions) => {
|
|
88
|
-
const handledFiles = handledExtensions.map(ext => `**/*${ext}`);
|
|
98
|
+
const handledFiles = handledExtensions.map((ext) => `**/*${ext}`);
|
|
89
99
|
const newPugTask = {
|
|
90
100
|
options: pugOptions.options,
|
|
91
101
|
files: [
|
|
92
102
|
{
|
|
93
|
-
expand: true,
|
|
94
103
|
cwd: pugOptions.sourcePath ?? (0, path_1.join)("webres", targetName),
|
|
95
|
-
src: handledFiles,
|
|
96
104
|
dest: pugOptions.outputPath ?? (0, path_1.join)("dist", targetName),
|
|
105
|
+
expand: true,
|
|
97
106
|
ext: pugOptions.fileSuffix ?? ".html",
|
|
107
|
+
src: handledFiles,
|
|
98
108
|
},
|
|
99
109
|
],
|
|
100
110
|
};
|
|
101
|
-
const requiredTasks = [
|
|
102
|
-
(0, util_js_1.insertTask)(gruntConfig, "pug", targetName, newPugTask),
|
|
103
|
-
];
|
|
111
|
+
const requiredTasks = [util.insertTask(gruntConfig, "pug", targetName, newPugTask)];
|
|
104
112
|
createDynamicTask(gruntConfig, targetName, pugOptions, newPugTask, requiredTasks);
|
|
105
|
-
const watchTasks = [
|
|
106
|
-
|
|
107
|
-
filesToWatch: handledFiles,
|
|
108
|
-
taskToRun: requiredTasks,
|
|
109
|
-
},
|
|
110
|
-
];
|
|
111
|
-
return {
|
|
112
|
-
requiredTasks,
|
|
113
|
-
handledFiles,
|
|
114
|
-
watchTasks,
|
|
115
|
-
};
|
|
113
|
+
const watchTasks = [{ filesToWatch: handledFiles, taskToRun: requiredTasks }];
|
|
114
|
+
return { handledFiles, requiredTasks, watchTasks };
|
|
116
115
|
};
|
|
117
116
|
exports.handle = handle;
|