@plugjs/build 0.3.3 → 0.4.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/dist/index.cjs +46 -46
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +11 -6
- package/dist/index.mjs +47 -47
- package/dist/index.mjs.map +1 -1
- package/package.json +6 -6
- package/resources/test/index.test.ts +1 -1
- package/resources/test/tsconfig.json +1 -2
- package/resources/tsconfig.json +1 -1
- package/src/index.ts +65 -50
package/dist/index.cjs
CHANGED
|
@@ -21,13 +21,12 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
21
21
|
// index.ts
|
|
22
22
|
var src_exports = {};
|
|
23
23
|
__export(src_exports, {
|
|
24
|
-
banner: () => banner,
|
|
25
24
|
tasks: () => tasks
|
|
26
25
|
});
|
|
27
26
|
module.exports = __toCommonJS(src_exports);
|
|
28
27
|
var import_cov8 = require("@plugjs/cov8");
|
|
29
28
|
var import_eslint = require("@plugjs/eslint");
|
|
30
|
-
var
|
|
29
|
+
var import_expect5 = require("@plugjs/expect5");
|
|
31
30
|
var import_plug = require("@plugjs/plug");
|
|
32
31
|
var import_typescript = require("@plugjs/typescript");
|
|
33
32
|
__reExport(src_exports, require("@plugjs/plug"), module.exports);
|
|
@@ -49,8 +48,8 @@ function tasks(options = {}) {
|
|
|
49
48
|
outputPackageJson: _outputPackageJson = _packageJson,
|
|
50
49
|
cjsExtension: _cjsExtension = ".cjs",
|
|
51
50
|
esmExtension: _esmExtension = ".mjs",
|
|
52
|
-
|
|
53
|
-
|
|
51
|
+
cjs: _cjs = true,
|
|
52
|
+
esm: _esm = true,
|
|
54
53
|
parallelize: _parallelize = false,
|
|
55
54
|
banners: _banners = !_parallelize,
|
|
56
55
|
testGlob: _testGlob = "**/*.test.([cm])?ts",
|
|
@@ -62,7 +61,7 @@ function tasks(options = {}) {
|
|
|
62
61
|
optimalFileCoverage: _optimalFileCoverage = void 0,
|
|
63
62
|
esbuildOptions: _esbuildOptions = {}
|
|
64
63
|
} = options;
|
|
65
|
-
const emitBanner = _banners ? banner : (...args) => void 0;
|
|
64
|
+
const emitBanner = _banners ? import_plug.banner : (...args) => void 0;
|
|
66
65
|
const esbuildMergedOptions = Object.assign({}, esbuildDefaults, _esbuildOptions);
|
|
67
66
|
return (0, import_plug.build)({
|
|
68
67
|
/** The directory for the original sources (default: `src`) */
|
|
@@ -85,6 +84,10 @@ function tasks(options = {}) {
|
|
|
85
84
|
cjsExtension: _cjsExtension,
|
|
86
85
|
/** The extension used for EcmaScript modules (default: `.mjs`) */
|
|
87
86
|
esmExtension: _esmExtension,
|
|
87
|
+
/** The extension used for CommonJS modules (default: `.cjs`) */
|
|
88
|
+
cjs: _cjs ? "true" : "false",
|
|
89
|
+
/** The extension used for EcmaScript modules (default: `.mjs`) */
|
|
90
|
+
esm: _esm ? "true" : "false",
|
|
88
91
|
/** A glob pattern matching all test files (default: `**∕*.test.([cm])?ts`) */
|
|
89
92
|
testGlob: _testGlob,
|
|
90
93
|
/** A glob pattern matching files to be exported (default: `index.*`) */
|
|
@@ -103,19 +106,19 @@ function tasks(options = {}) {
|
|
|
103
106
|
/** Find all typescript source files (`*.ts`, `*.mts` and `*.cts`) */
|
|
104
107
|
_find_sources() {
|
|
105
108
|
return (0, import_plug.merge)([
|
|
106
|
-
|
|
107
|
-
|
|
109
|
+
this.cjs === "true" ? this._find_sources_cts() : (0, import_plug.noop)(),
|
|
110
|
+
this.esm === "true" ? this._find_sources_mts() : (0, import_plug.noop)()
|
|
108
111
|
]);
|
|
109
112
|
},
|
|
110
113
|
/** Find all types definition files within sources */
|
|
111
114
|
_find_types() {
|
|
112
|
-
return (0, import_plug.find)("**/*.d.ts", { directory: this.sourceDir });
|
|
115
|
+
return (0, import_plug.find)("**/*.d.([cm])?ts", { directory: this.sourceDir });
|
|
113
116
|
},
|
|
114
117
|
/** Find all extra types definition files from `extraTypesDir` */
|
|
115
118
|
_find_extra_types() {
|
|
116
119
|
if (!(0, import_plug.isDirectory)(this.extraTypesDir))
|
|
117
120
|
return (0, import_plug.noop)();
|
|
118
|
-
return (0, import_plug.find)("**/*.d.ts", { directory: this.extraTypesDir });
|
|
121
|
+
return (0, import_plug.find)("**/*.d.([cm])?ts", { directory: this.extraTypesDir });
|
|
119
122
|
},
|
|
120
123
|
/** Find all resource files (non-typescript files) within sources */
|
|
121
124
|
_find_resources() {
|
|
@@ -123,7 +126,7 @@ function tasks(options = {}) {
|
|
|
123
126
|
},
|
|
124
127
|
/** Find all test source files */
|
|
125
128
|
_find_tests() {
|
|
126
|
-
return (0, import_plug.find)(this.testGlob, { directory: this.testDir, ignore: "**/*.d.ts" });
|
|
129
|
+
return (0, import_plug.find)(this.testGlob, { directory: this.testDir, ignore: "**/*.d.([cm])?ts" });
|
|
127
130
|
},
|
|
128
131
|
/** Find all source files to lint */
|
|
129
132
|
_find_lint_sources() {
|
|
@@ -157,16 +160,17 @@ function tasks(options = {}) {
|
|
|
157
160
|
},
|
|
158
161
|
/** Generate all .d.ts files */
|
|
159
162
|
transpile_types() {
|
|
163
|
+
const extraTypesDir = (0, import_plug.isDirectory)(this.extraTypesDir) ? this.extraTypesDir : void 0;
|
|
160
164
|
return (0, import_plug.merge)([
|
|
161
165
|
this._find_sources(),
|
|
162
|
-
this._find_types()
|
|
163
|
-
this._find_extra_types()
|
|
166
|
+
this._find_types()
|
|
164
167
|
]).tsc("tsconfig.json", {
|
|
165
168
|
noEmit: false,
|
|
166
169
|
rootDir: this.sourceDir,
|
|
167
170
|
declaration: true,
|
|
168
171
|
emitDeclarationOnly: true,
|
|
169
|
-
outDir: this.destDir
|
|
172
|
+
outDir: this.destDir,
|
|
173
|
+
extraTypesDir
|
|
170
174
|
});
|
|
171
175
|
},
|
|
172
176
|
/** Copy all resources coming alongside our sources */
|
|
@@ -182,8 +186,8 @@ function tasks(options = {}) {
|
|
|
182
186
|
if ((0, import_plug.isDirectory)(this.destDir))
|
|
183
187
|
await (0, import_plug.rmrf)(this.destDir);
|
|
184
188
|
const result = await (0, import_plug.merge)([
|
|
185
|
-
|
|
186
|
-
|
|
189
|
+
this.cjs === "true" ? this.transpile_cjs() : (0, import_plug.noop)(),
|
|
190
|
+
this.esm === "true" ? this.transpile_esm() : (0, import_plug.noop)(),
|
|
187
191
|
this.transpile_types(),
|
|
188
192
|
this.copy_resources()
|
|
189
193
|
]);
|
|
@@ -192,38 +196,43 @@ function tasks(options = {}) {
|
|
|
192
196
|
/* ====================================================================== *
|
|
193
197
|
* TEST & COVERAGE *
|
|
194
198
|
* ====================================================================== */
|
|
199
|
+
/** Check test types */
|
|
200
|
+
async test_types() {
|
|
201
|
+
emitBanner("Checking test types");
|
|
202
|
+
const tsconfig = (0, import_plug.resolve)(this.testDir, "tsconfig.json");
|
|
203
|
+
const extraTypesDir = (0, import_plug.isDirectory)(this.extraTypesDir) ? this.extraTypesDir : void 0;
|
|
204
|
+
await this._find_tests().tsc(tsconfig, {
|
|
205
|
+
rootDir: ".",
|
|
206
|
+
noEmit: true,
|
|
207
|
+
declaration: false,
|
|
208
|
+
emitDeclarationOnly: false,
|
|
209
|
+
extraTypesDir
|
|
210
|
+
});
|
|
211
|
+
},
|
|
195
212
|
/** Run tests */
|
|
196
213
|
async test_cjs() {
|
|
197
214
|
emitBanner("Running tests (CommonJS)");
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
} finally {
|
|
203
|
-
delete process.env.__TS_LOADER_FORCE_TYPE;
|
|
204
|
-
if (forceType)
|
|
205
|
-
process.env.__TS_LOADER_FORCE_TYPE = forceType;
|
|
206
|
-
}
|
|
215
|
+
await this._find_tests().test({
|
|
216
|
+
coverageDir: _coverage ? this.coverageDataDir : void 0,
|
|
217
|
+
forceModule: "commonjs"
|
|
218
|
+
});
|
|
207
219
|
},
|
|
208
220
|
/** Run tests */
|
|
209
221
|
async test_esm() {
|
|
210
222
|
emitBanner("Running tests (ES Modules)");
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
} finally {
|
|
216
|
-
delete process.env.__TS_LOADER_FORCE_TYPE;
|
|
217
|
-
if (forceType)
|
|
218
|
-
process.env.__TS_LOADER_FORCE_TYPE = forceType;
|
|
219
|
-
}
|
|
223
|
+
await this._find_tests().test({
|
|
224
|
+
coverageDir: _coverage ? this.coverageDataDir : void 0,
|
|
225
|
+
forceModule: "module"
|
|
226
|
+
});
|
|
220
227
|
},
|
|
221
228
|
/** Run tests */
|
|
222
229
|
async test() {
|
|
223
230
|
if (_coverage && (0, import_plug.isDirectory)(this.coverageDataDir))
|
|
224
231
|
await (0, import_plug.rmrf)(this.coverageDataDir);
|
|
225
|
-
|
|
226
|
-
|
|
232
|
+
if (this.cjs === "true")
|
|
233
|
+
await this.test_cjs();
|
|
234
|
+
if (this.esm === "true")
|
|
235
|
+
await this.test_esm();
|
|
227
236
|
},
|
|
228
237
|
/** Ensure tests have run and generate a coverage report */
|
|
229
238
|
async coverage() {
|
|
@@ -273,12 +282,13 @@ function tasks(options = {}) {
|
|
|
273
282
|
if (_parallelize) {
|
|
274
283
|
await Promise.all([
|
|
275
284
|
this.transpile(),
|
|
285
|
+
this.test_types(),
|
|
276
286
|
_coverage ? this.coverage() : this.test(),
|
|
277
287
|
this.lint()
|
|
278
288
|
]);
|
|
279
289
|
} else {
|
|
280
290
|
await this.transpile();
|
|
281
|
-
await (_coverage ? this.coverage() : this.test()), await this.lint();
|
|
291
|
+
await this.test_types(), await (_coverage ? this.coverage() : this.test()), await this.lint();
|
|
282
292
|
}
|
|
283
293
|
},
|
|
284
294
|
/* ====================================================================== *
|
|
@@ -296,18 +306,8 @@ function tasks(options = {}) {
|
|
|
296
306
|
}
|
|
297
307
|
});
|
|
298
308
|
}
|
|
299
|
-
function banner(message) {
|
|
300
|
-
import_plug.log.notice([
|
|
301
|
-
"",
|
|
302
|
-
(0, import_plug.$gry)(`\u2554${"".padStart(60, "\u2550")}\u2557`),
|
|
303
|
-
`${(0, import_plug.$gry)("\u2551")} ${(0, import_plug.$wht)(message.padEnd(58, " "))} ${(0, import_plug.$gry)("\u2551")}`,
|
|
304
|
-
(0, import_plug.$gry)(`\u255A${"".padStart(60, "\u2550")}\u255D`),
|
|
305
|
-
""
|
|
306
|
-
].join("\n"));
|
|
307
|
-
}
|
|
308
309
|
// Annotate the CommonJS export names for ESM import in node:
|
|
309
310
|
0 && (module.exports = {
|
|
310
|
-
banner,
|
|
311
311
|
tasks,
|
|
312
312
|
...require("@plugjs/plug")
|
|
313
313
|
});
|
package/dist/index.cjs.map
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/index.ts"],
|
|
4
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA
|
|
4
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAO;AACP,oBAAO;AACP,qBAAO;AACP,kBAUO;AACP,wBAAO;AAIP,wBAAc,yBAlBd;AAqBA,IAAM,kBAAkC;AAAA,EACtC,UAAU;AAAA,EACV,WAAW;AAAA,EACX,gBAAgB;AAAA,EAChB,SAAS,KAAE,2BAAc,CAAE;AAC7B;AAoFO,SAAS,MAAM,UAAwB,CAAC,GAAG;AAChD,QAAM;AAAA,IACJ,WAAW,aAAa;AAAA,IACxB,SAAS,WAAW;AAAA,IACpB,SAAS,WAAW;AAAA,IACpB,aAAa,eAAe;AAAA,IAC5B,iBAAiB,mBAAmB;AAAA,IACpC,eAAe,iBAAiB;AAAA,IAEhC,aAAa,eAAe;AAAA,IAC5B,mBAAmB,qBAAqB;AAAA,IAExC,cAAc,gBAAgB;AAAA,IAC9B,cAAc,gBAAgB;AAAA,IAC9B,KAAK,OAAO;AAAA,IACZ,KAAK,OAAO;AAAA,IAEZ,aAAa,eAAe;AAAA,IAC5B,SAAS,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AAA,UAChB,YAAY,KAAK,SAAS,IAAI,KAAK,KAAK;AAAA,UACxC,KAAK,KAAK;AAAA,QACZ,CAAC;AAAA,MACH,OAAO;AACL,cAAM,KAAK,UAAU;AACrB,cAAM,KAAK,WAAW,GACtB,OAAO,YAAY,KAAK,SAAS,IAAI,KAAK,KAAK,IAC/C,MAAM,KAAK,KAAK;AAAA,MAClB;AAAA,IACF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAaA,MAAM,UAAyB;AAC7B,YAAM,KAAK,IAAI;AAAA,IACjB;AAAA,EACF,CAAC;AACH;",
|
|
5
5
|
"names": []
|
|
6
6
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import '@plugjs/cov8';
|
|
2
2
|
import '@plugjs/eslint';
|
|
3
|
-
import '@plugjs/
|
|
3
|
+
import '@plugjs/expect5';
|
|
4
4
|
import '@plugjs/typescript';
|
|
5
5
|
import type { ESBuildOptions, Pipe } from '@plugjs/plug';
|
|
6
6
|
export * from '@plugjs/plug';
|
|
@@ -26,10 +26,10 @@ export interface TasksOptions {
|
|
|
26
26
|
cjsExtension?: string;
|
|
27
27
|
/** The extension used for EcmaScript modules (default: `.mjs`) */
|
|
28
28
|
esmExtension?: string;
|
|
29
|
-
/** Enable CommonJS Modules
|
|
30
|
-
|
|
31
|
-
/** Enable EcmaScript Modules
|
|
32
|
-
|
|
29
|
+
/** Enable CommonJS Modules or not (default: `true`) */
|
|
30
|
+
cjs?: boolean;
|
|
31
|
+
/** Enable EcmaScript Modules or not (default: `true`) */
|
|
32
|
+
esm?: boolean;
|
|
33
33
|
/** Enable or disable banners (default: `true` if `parallelize` is `false`) */
|
|
34
34
|
banners?: boolean;
|
|
35
35
|
/** Parallelize tasks (might make output confusing, default: `false`) */
|
|
@@ -85,6 +85,10 @@ export declare function tasks(options?: TasksOptions): import("@plugjs/plug").Bu
|
|
|
85
85
|
cjsExtension: string;
|
|
86
86
|
/** The extension used for EcmaScript modules (default: `.mjs`) */
|
|
87
87
|
esmExtension: string;
|
|
88
|
+
/** The extension used for CommonJS modules (default: `.cjs`) */
|
|
89
|
+
cjs: string;
|
|
90
|
+
/** The extension used for EcmaScript modules (default: `.mjs`) */
|
|
91
|
+
esm: string;
|
|
88
92
|
/** A glob pattern matching all test files (default: `**∕*.test.([cm])?ts`) */
|
|
89
93
|
testGlob: string;
|
|
90
94
|
/** A glob pattern matching files to be exported (default: `index.*`) */
|
|
@@ -115,6 +119,8 @@ export declare function tasks(options?: TasksOptions): import("@plugjs/plug").Bu
|
|
|
115
119
|
copy_resources(): Pipe;
|
|
116
120
|
/** Transpile all source code */
|
|
117
121
|
transpile(): Promise<Pipe>;
|
|
122
|
+
/** Check test types */
|
|
123
|
+
test_types(): Promise<void>;
|
|
118
124
|
/** Run tests */
|
|
119
125
|
test_cjs(): Promise<void>;
|
|
120
126
|
/** Run tests */
|
|
@@ -137,4 +143,3 @@ export declare function tasks(options?: TasksOptions): import("@plugjs/plug").Bu
|
|
|
137
143
|
*/
|
|
138
144
|
default(): Promise<void>;
|
|
139
145
|
}>;
|
|
140
|
-
export declare function banner(message: string): void;
|
package/dist/index.mjs
CHANGED
|
@@ -1,17 +1,16 @@
|
|
|
1
1
|
// index.ts
|
|
2
2
|
import "@plugjs/cov8";
|
|
3
3
|
import "@plugjs/eslint";
|
|
4
|
-
import "@plugjs/
|
|
4
|
+
import "@plugjs/expect5";
|
|
5
5
|
import {
|
|
6
|
-
|
|
7
|
-
$wht,
|
|
6
|
+
banner,
|
|
8
7
|
build,
|
|
9
8
|
find,
|
|
10
9
|
fixExtensions,
|
|
11
10
|
isDirectory,
|
|
12
|
-
log,
|
|
13
11
|
merge,
|
|
14
12
|
noop,
|
|
13
|
+
resolve,
|
|
15
14
|
rmrf
|
|
16
15
|
} from "@plugjs/plug";
|
|
17
16
|
import "@plugjs/typescript";
|
|
@@ -34,8 +33,8 @@ function tasks(options = {}) {
|
|
|
34
33
|
outputPackageJson: _outputPackageJson = _packageJson,
|
|
35
34
|
cjsExtension: _cjsExtension = ".cjs",
|
|
36
35
|
esmExtension: _esmExtension = ".mjs",
|
|
37
|
-
|
|
38
|
-
|
|
36
|
+
cjs: _cjs = true,
|
|
37
|
+
esm: _esm = true,
|
|
39
38
|
parallelize: _parallelize = false,
|
|
40
39
|
banners: _banners = !_parallelize,
|
|
41
40
|
testGlob: _testGlob = "**/*.test.([cm])?ts",
|
|
@@ -70,6 +69,10 @@ function tasks(options = {}) {
|
|
|
70
69
|
cjsExtension: _cjsExtension,
|
|
71
70
|
/** The extension used for EcmaScript modules (default: `.mjs`) */
|
|
72
71
|
esmExtension: _esmExtension,
|
|
72
|
+
/** The extension used for CommonJS modules (default: `.cjs`) */
|
|
73
|
+
cjs: _cjs ? "true" : "false",
|
|
74
|
+
/** The extension used for EcmaScript modules (default: `.mjs`) */
|
|
75
|
+
esm: _esm ? "true" : "false",
|
|
73
76
|
/** A glob pattern matching all test files (default: `**∕*.test.([cm])?ts`) */
|
|
74
77
|
testGlob: _testGlob,
|
|
75
78
|
/** A glob pattern matching files to be exported (default: `index.*`) */
|
|
@@ -88,19 +91,19 @@ function tasks(options = {}) {
|
|
|
88
91
|
/** Find all typescript source files (`*.ts`, `*.mts` and `*.cts`) */
|
|
89
92
|
_find_sources() {
|
|
90
93
|
return merge([
|
|
91
|
-
|
|
92
|
-
|
|
94
|
+
this.cjs === "true" ? this._find_sources_cts() : noop(),
|
|
95
|
+
this.esm === "true" ? this._find_sources_mts() : noop()
|
|
93
96
|
]);
|
|
94
97
|
},
|
|
95
98
|
/** Find all types definition files within sources */
|
|
96
99
|
_find_types() {
|
|
97
|
-
return find("**/*.d.ts", { directory: this.sourceDir });
|
|
100
|
+
return find("**/*.d.([cm])?ts", { directory: this.sourceDir });
|
|
98
101
|
},
|
|
99
102
|
/** Find all extra types definition files from `extraTypesDir` */
|
|
100
103
|
_find_extra_types() {
|
|
101
104
|
if (!isDirectory(this.extraTypesDir))
|
|
102
105
|
return noop();
|
|
103
|
-
return find("**/*.d.ts", { directory: this.extraTypesDir });
|
|
106
|
+
return find("**/*.d.([cm])?ts", { directory: this.extraTypesDir });
|
|
104
107
|
},
|
|
105
108
|
/** Find all resource files (non-typescript files) within sources */
|
|
106
109
|
_find_resources() {
|
|
@@ -108,7 +111,7 @@ function tasks(options = {}) {
|
|
|
108
111
|
},
|
|
109
112
|
/** Find all test source files */
|
|
110
113
|
_find_tests() {
|
|
111
|
-
return find(this.testGlob, { directory: this.testDir, ignore: "**/*.d.ts" });
|
|
114
|
+
return find(this.testGlob, { directory: this.testDir, ignore: "**/*.d.([cm])?ts" });
|
|
112
115
|
},
|
|
113
116
|
/** Find all source files to lint */
|
|
114
117
|
_find_lint_sources() {
|
|
@@ -142,16 +145,17 @@ function tasks(options = {}) {
|
|
|
142
145
|
},
|
|
143
146
|
/** Generate all .d.ts files */
|
|
144
147
|
transpile_types() {
|
|
148
|
+
const extraTypesDir = isDirectory(this.extraTypesDir) ? this.extraTypesDir : void 0;
|
|
145
149
|
return merge([
|
|
146
150
|
this._find_sources(),
|
|
147
|
-
this._find_types()
|
|
148
|
-
this._find_extra_types()
|
|
151
|
+
this._find_types()
|
|
149
152
|
]).tsc("tsconfig.json", {
|
|
150
153
|
noEmit: false,
|
|
151
154
|
rootDir: this.sourceDir,
|
|
152
155
|
declaration: true,
|
|
153
156
|
emitDeclarationOnly: true,
|
|
154
|
-
outDir: this.destDir
|
|
157
|
+
outDir: this.destDir,
|
|
158
|
+
extraTypesDir
|
|
155
159
|
});
|
|
156
160
|
},
|
|
157
161
|
/** Copy all resources coming alongside our sources */
|
|
@@ -167,8 +171,8 @@ function tasks(options = {}) {
|
|
|
167
171
|
if (isDirectory(this.destDir))
|
|
168
172
|
await rmrf(this.destDir);
|
|
169
173
|
const result = await merge([
|
|
170
|
-
|
|
171
|
-
|
|
174
|
+
this.cjs === "true" ? this.transpile_cjs() : noop(),
|
|
175
|
+
this.esm === "true" ? this.transpile_esm() : noop(),
|
|
172
176
|
this.transpile_types(),
|
|
173
177
|
this.copy_resources()
|
|
174
178
|
]);
|
|
@@ -177,38 +181,43 @@ function tasks(options = {}) {
|
|
|
177
181
|
/* ====================================================================== *
|
|
178
182
|
* TEST & COVERAGE *
|
|
179
183
|
* ====================================================================== */
|
|
184
|
+
/** Check test types */
|
|
185
|
+
async test_types() {
|
|
186
|
+
emitBanner("Checking test types");
|
|
187
|
+
const tsconfig = resolve(this.testDir, "tsconfig.json");
|
|
188
|
+
const extraTypesDir = isDirectory(this.extraTypesDir) ? this.extraTypesDir : void 0;
|
|
189
|
+
await this._find_tests().tsc(tsconfig, {
|
|
190
|
+
rootDir: ".",
|
|
191
|
+
noEmit: true,
|
|
192
|
+
declaration: false,
|
|
193
|
+
emitDeclarationOnly: false,
|
|
194
|
+
extraTypesDir
|
|
195
|
+
});
|
|
196
|
+
},
|
|
180
197
|
/** Run tests */
|
|
181
198
|
async test_cjs() {
|
|
182
199
|
emitBanner("Running tests (CommonJS)");
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
} finally {
|
|
188
|
-
delete process.env.__TS_LOADER_FORCE_TYPE;
|
|
189
|
-
if (forceType)
|
|
190
|
-
process.env.__TS_LOADER_FORCE_TYPE = forceType;
|
|
191
|
-
}
|
|
200
|
+
await this._find_tests().test({
|
|
201
|
+
coverageDir: _coverage ? this.coverageDataDir : void 0,
|
|
202
|
+
forceModule: "commonjs"
|
|
203
|
+
});
|
|
192
204
|
},
|
|
193
205
|
/** Run tests */
|
|
194
206
|
async test_esm() {
|
|
195
207
|
emitBanner("Running tests (ES Modules)");
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
} finally {
|
|
201
|
-
delete process.env.__TS_LOADER_FORCE_TYPE;
|
|
202
|
-
if (forceType)
|
|
203
|
-
process.env.__TS_LOADER_FORCE_TYPE = forceType;
|
|
204
|
-
}
|
|
208
|
+
await this._find_tests().test({
|
|
209
|
+
coverageDir: _coverage ? this.coverageDataDir : void 0,
|
|
210
|
+
forceModule: "module"
|
|
211
|
+
});
|
|
205
212
|
},
|
|
206
213
|
/** Run tests */
|
|
207
214
|
async test() {
|
|
208
215
|
if (_coverage && isDirectory(this.coverageDataDir))
|
|
209
216
|
await rmrf(this.coverageDataDir);
|
|
210
|
-
|
|
211
|
-
|
|
217
|
+
if (this.cjs === "true")
|
|
218
|
+
await this.test_cjs();
|
|
219
|
+
if (this.esm === "true")
|
|
220
|
+
await this.test_esm();
|
|
212
221
|
},
|
|
213
222
|
/** Ensure tests have run and generate a coverage report */
|
|
214
223
|
async coverage() {
|
|
@@ -258,12 +267,13 @@ function tasks(options = {}) {
|
|
|
258
267
|
if (_parallelize) {
|
|
259
268
|
await Promise.all([
|
|
260
269
|
this.transpile(),
|
|
270
|
+
this.test_types(),
|
|
261
271
|
_coverage ? this.coverage() : this.test(),
|
|
262
272
|
this.lint()
|
|
263
273
|
]);
|
|
264
274
|
} else {
|
|
265
275
|
await this.transpile();
|
|
266
|
-
await (_coverage ? this.coverage() : this.test()), await this.lint();
|
|
276
|
+
await this.test_types(), await (_coverage ? this.coverage() : this.test()), await this.lint();
|
|
267
277
|
}
|
|
268
278
|
},
|
|
269
279
|
/* ====================================================================== *
|
|
@@ -281,17 +291,7 @@ function tasks(options = {}) {
|
|
|
281
291
|
}
|
|
282
292
|
});
|
|
283
293
|
}
|
|
284
|
-
function banner(message) {
|
|
285
|
-
log.notice([
|
|
286
|
-
"",
|
|
287
|
-
$gry(`\u2554${"".padStart(60, "\u2550")}\u2557`),
|
|
288
|
-
`${$gry("\u2551")} ${$wht(message.padEnd(58, " "))} ${$gry("\u2551")}`,
|
|
289
|
-
$gry(`\u255A${"".padStart(60, "\u2550")}\u255D`),
|
|
290
|
-
""
|
|
291
|
-
].join("\n"));
|
|
292
|
-
}
|
|
293
294
|
export {
|
|
294
|
-
banner,
|
|
295
295
|
tasks
|
|
296
296
|
};
|
|
297
297
|
//# sourceMappingURL=index.mjs.map
|
package/dist/index.mjs.map
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/index.ts"],
|
|
4
|
-
"mappings": ";AAAA,OAAO;AACP,OAAO;AACP,OAAO;AACP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,
|
|
4
|
+
"mappings": ";AAAA,OAAO;AACP,OAAO;AACP,OAAO;AACP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,OAAO;AAIP,cAAc;AAGd,IAAM,kBAAkC;AAAA,EACtC,UAAU;AAAA,EACV,WAAW;AAAA,EACX,gBAAgB;AAAA,EAChB,SAAS,CAAE,cAAc,CAAE;AAC7B;AAoFO,SAAS,MAAM,UAAwB,CAAC,GAAG;AAChD,QAAM;AAAA,IACJ,WAAW,aAAa;AAAA,IACxB,SAAS,WAAW;AAAA,IACpB,SAAS,WAAW;AAAA,IACpB,aAAa,eAAe;AAAA,IAC5B,iBAAiB,mBAAmB;AAAA,IACpC,eAAe,iBAAiB;AAAA,IAEhC,aAAa,eAAe;AAAA,IAC5B,mBAAmB,qBAAqB;AAAA,IAExC,cAAc,gBAAgB;AAAA,IAC9B,cAAc,gBAAgB;AAAA,IAC9B,KAAK,OAAO;AAAA,IACZ,KAAK,OAAO;AAAA,IAEZ,aAAa,eAAe;AAAA,IAC5B,SAAS,WAAW,CAAC;AAAA,IACrB,UAAU,YAAY;AAAA,IACtB,aAAa,eAAe;AAAA,IAC5B,UAAU,YAAY;AAAA,IACtB,iBAAiB,mBAAmB;AAAA,IACpC,qBAAqB,uBAAuB;AAAA,IAC5C,iBAAiB,mBAAmB;AAAA,IACpC,qBAAqB,uBAAuB;AAAA,IAE5C,gBAAgB,kBAAkB,C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;AAAA;AAAA;AAAA;AAAA;AAAA,IAaA,MAAM,UAAyB;AAC7B,YAAM,KAAK,IAAI;AAAA,IACjB;AAAA,EACF,CAAC;AACH;",
|
|
5
5
|
"names": []
|
|
6
6
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@plugjs/build",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.1",
|
|
4
4
|
"description": "Simple shared build using PlugJS",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
@@ -30,12 +30,12 @@
|
|
|
30
30
|
"transpile": "plug transpile"
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@plugjs/cov8": "^0.3
|
|
34
|
-
"@plugjs/eslint": "^0.3
|
|
33
|
+
"@plugjs/cov8": "^0.4.3",
|
|
34
|
+
"@plugjs/eslint": "^0.4.3",
|
|
35
35
|
"@plugjs/eslint-plugin": "^0.1.5",
|
|
36
|
-
"@plugjs/
|
|
37
|
-
"@plugjs/plug": "^0.3
|
|
38
|
-
"@plugjs/typescript": "^0.3
|
|
36
|
+
"@plugjs/expect5": "^0.4.3",
|
|
37
|
+
"@plugjs/plug": "^0.4.3",
|
|
38
|
+
"@plugjs/typescript": "^0.4.3"
|
|
39
39
|
},
|
|
40
40
|
"files": [
|
|
41
41
|
"*.md",
|
package/resources/tsconfig.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import '@plugjs/cov8'
|
|
2
2
|
import '@plugjs/eslint'
|
|
3
|
-
import '@plugjs/
|
|
3
|
+
import '@plugjs/expect5'
|
|
4
4
|
import {
|
|
5
|
-
|
|
6
|
-
$wht,
|
|
5
|
+
banner,
|
|
7
6
|
build,
|
|
8
7
|
find,
|
|
9
8
|
fixExtensions,
|
|
10
|
-
isDirectory,
|
|
9
|
+
isDirectory,
|
|
10
|
+
merge,
|
|
11
11
|
noop,
|
|
12
|
+
resolve,
|
|
12
13
|
rmrf,
|
|
13
14
|
} from '@plugjs/plug'
|
|
14
15
|
import '@plugjs/typescript'
|
|
@@ -61,10 +62,10 @@ export interface TasksOptions {
|
|
|
61
62
|
cjsExtension?: string,
|
|
62
63
|
/** The extension used for EcmaScript modules (default: `.mjs`) */
|
|
63
64
|
esmExtension?: string,
|
|
64
|
-
/** Enable CommonJS Modules
|
|
65
|
-
|
|
66
|
-
/** Enable EcmaScript Modules
|
|
67
|
-
|
|
65
|
+
/** Enable CommonJS Modules or not (default: `true`) */
|
|
66
|
+
cjs?: boolean,
|
|
67
|
+
/** Enable EcmaScript Modules or not (default: `true`) */
|
|
68
|
+
esm?: boolean,
|
|
68
69
|
|
|
69
70
|
/* ======================================================================== *
|
|
70
71
|
* OTHER OPTIONS *
|
|
@@ -121,8 +122,8 @@ export function tasks(options: TasksOptions = {}) {
|
|
|
121
122
|
|
|
122
123
|
cjsExtension: _cjsExtension = '.cjs',
|
|
123
124
|
esmExtension: _esmExtension = '.mjs',
|
|
124
|
-
|
|
125
|
-
|
|
125
|
+
cjs: _cjs = true,
|
|
126
|
+
esm: _esm = true,
|
|
126
127
|
|
|
127
128
|
parallelize: _parallelize = false,
|
|
128
129
|
banners: _banners = !_parallelize,
|
|
@@ -164,6 +165,10 @@ export function tasks(options: TasksOptions = {}) {
|
|
|
164
165
|
cjsExtension: _cjsExtension,
|
|
165
166
|
/** The extension used for EcmaScript modules (default: `.mjs`) */
|
|
166
167
|
esmExtension: _esmExtension,
|
|
168
|
+
/** The extension used for CommonJS modules (default: `.cjs`) */
|
|
169
|
+
cjs: _cjs ? 'true' : 'false',
|
|
170
|
+
/** The extension used for EcmaScript modules (default: `.mjs`) */
|
|
171
|
+
esm: _esm ? 'true' : 'false',
|
|
167
172
|
/** A glob pattern matching all test files (default: `**∕*.test.([cm])?ts`) */
|
|
168
173
|
testGlob: _testGlob,
|
|
169
174
|
/** A glob pattern matching files to be exported (default: `index.*`) */
|
|
@@ -186,20 +191,20 @@ export function tasks(options: TasksOptions = {}) {
|
|
|
186
191
|
/** Find all typescript source files (`*.ts`, `*.mts` and `*.cts`) */
|
|
187
192
|
_find_sources(): Pipe {
|
|
188
193
|
return merge([
|
|
189
|
-
|
|
190
|
-
|
|
194
|
+
this.cjs === 'true' ? this._find_sources_cts() : noop(),
|
|
195
|
+
this.esm === 'true' ? this._find_sources_mts() : noop(),
|
|
191
196
|
])
|
|
192
197
|
},
|
|
193
198
|
|
|
194
199
|
/** Find all types definition files within sources */
|
|
195
200
|
_find_types(): Pipe {
|
|
196
|
-
return find('**/*.d.ts', { directory: this.sourceDir })
|
|
201
|
+
return find('**/*.d.([cm])?ts', { directory: this.sourceDir })
|
|
197
202
|
},
|
|
198
203
|
|
|
199
204
|
/** Find all extra types definition files from `extraTypesDir` */
|
|
200
205
|
_find_extra_types(): Pipe {
|
|
201
206
|
if (! isDirectory(this.extraTypesDir)) return noop()
|
|
202
|
-
return find('**/*.d.ts', { directory: this.extraTypesDir })
|
|
207
|
+
return find('**/*.d.([cm])?ts', { directory: this.extraTypesDir })
|
|
203
208
|
},
|
|
204
209
|
|
|
205
210
|
/** Find all resource files (non-typescript files) within sources */
|
|
@@ -209,7 +214,7 @@ export function tasks(options: TasksOptions = {}) {
|
|
|
209
214
|
|
|
210
215
|
/** Find all test source files */
|
|
211
216
|
_find_tests(): Pipe {
|
|
212
|
-
return find(this.testGlob, { directory: this.testDir, ignore: '**/*.d.ts' })
|
|
217
|
+
return find(this.testGlob, { directory: this.testDir, ignore: '**/*.d.([cm])?ts' })
|
|
213
218
|
},
|
|
214
219
|
|
|
215
220
|
/** Find all source files to lint */
|
|
@@ -250,16 +255,21 @@ export function tasks(options: TasksOptions = {}) {
|
|
|
250
255
|
|
|
251
256
|
/** Generate all .d.ts files */
|
|
252
257
|
transpile_types(): Pipe {
|
|
258
|
+
const extraTypesDir =
|
|
259
|
+
isDirectory(this.extraTypesDir) ?
|
|
260
|
+
this.extraTypesDir :
|
|
261
|
+
undefined
|
|
262
|
+
|
|
253
263
|
return merge([
|
|
254
264
|
this._find_sources(),
|
|
255
265
|
this._find_types(),
|
|
256
|
-
this._find_extra_types(),
|
|
257
266
|
]).tsc('tsconfig.json', {
|
|
258
267
|
noEmit: false,
|
|
259
268
|
rootDir: this.sourceDir,
|
|
260
269
|
declaration: true,
|
|
261
270
|
emitDeclarationOnly: true,
|
|
262
271
|
outDir: this.destDir,
|
|
272
|
+
extraTypesDir,
|
|
263
273
|
})
|
|
264
274
|
},
|
|
265
275
|
|
|
@@ -278,8 +288,8 @@ export function tasks(options: TasksOptions = {}) {
|
|
|
278
288
|
if (isDirectory(this.destDir)) await rmrf(this.destDir)
|
|
279
289
|
|
|
280
290
|
const result = await merge([
|
|
281
|
-
|
|
282
|
-
|
|
291
|
+
this.cjs === 'true' ? this.transpile_cjs() : noop(),
|
|
292
|
+
this.esm === 'true' ? this.transpile_esm() : noop(),
|
|
283
293
|
this.transpile_types(),
|
|
284
294
|
this.copy_resources(),
|
|
285
295
|
])
|
|
@@ -291,44 +301,57 @@ export function tasks(options: TasksOptions = {}) {
|
|
|
291
301
|
* TEST & COVERAGE *
|
|
292
302
|
* ====================================================================== */
|
|
293
303
|
|
|
304
|
+
/** Check test types */
|
|
305
|
+
async test_types(): Promise<void> {
|
|
306
|
+
emitBanner('Checking test types')
|
|
307
|
+
|
|
308
|
+
const tsconfig = resolve(this.testDir, 'tsconfig.json')
|
|
309
|
+
const extraTypesDir =
|
|
310
|
+
isDirectory(this.extraTypesDir) ?
|
|
311
|
+
this.extraTypesDir :
|
|
312
|
+
undefined
|
|
313
|
+
|
|
314
|
+
await this
|
|
315
|
+
._find_tests()
|
|
316
|
+
.tsc(tsconfig, {
|
|
317
|
+
rootDir: '.',
|
|
318
|
+
noEmit: true,
|
|
319
|
+
declaration: false,
|
|
320
|
+
emitDeclarationOnly: false,
|
|
321
|
+
extraTypesDir,
|
|
322
|
+
})
|
|
323
|
+
},
|
|
324
|
+
|
|
294
325
|
/** Run tests */
|
|
295
326
|
async test_cjs(): Promise<void> {
|
|
296
327
|
emitBanner('Running tests (CommonJS)')
|
|
297
328
|
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
} finally {
|
|
305
|
-
delete process.env.__TS_LOADER_FORCE_TYPE
|
|
306
|
-
if (forceType) process.env.__TS_LOADER_FORCE_TYPE = forceType
|
|
307
|
-
}
|
|
329
|
+
await this
|
|
330
|
+
._find_tests()
|
|
331
|
+
.test({
|
|
332
|
+
coverageDir: _coverage ? this.coverageDataDir : undefined,
|
|
333
|
+
forceModule: 'commonjs',
|
|
334
|
+
})
|
|
308
335
|
},
|
|
309
336
|
|
|
310
337
|
/** Run tests */
|
|
311
338
|
async test_esm(): Promise<void> {
|
|
312
339
|
emitBanner('Running tests (ES Modules)')
|
|
313
340
|
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
} finally {
|
|
321
|
-
delete process.env.__TS_LOADER_FORCE_TYPE
|
|
322
|
-
if (forceType) process.env.__TS_LOADER_FORCE_TYPE = forceType
|
|
323
|
-
}
|
|
341
|
+
await this
|
|
342
|
+
._find_tests()
|
|
343
|
+
.test({
|
|
344
|
+
coverageDir: _coverage ? this.coverageDataDir : undefined,
|
|
345
|
+
forceModule: 'module',
|
|
346
|
+
})
|
|
324
347
|
},
|
|
325
348
|
|
|
326
349
|
/** Run tests */
|
|
327
350
|
async test(): Promise<void> {
|
|
328
351
|
if (_coverage && isDirectory(this.coverageDataDir)) await rmrf(this.coverageDataDir)
|
|
329
352
|
|
|
330
|
-
await this.test_cjs()
|
|
331
|
-
await this.test_esm()
|
|
353
|
+
if (this.cjs === 'true') await this.test_cjs()
|
|
354
|
+
if (this.esm === 'true') await this.test_esm()
|
|
332
355
|
},
|
|
333
356
|
|
|
334
357
|
/** Ensure tests have run and generate a coverage report */
|
|
@@ -396,11 +419,13 @@ export function tasks(options: TasksOptions = {}) {
|
|
|
396
419
|
if (_parallelize) {
|
|
397
420
|
await Promise.all([
|
|
398
421
|
this.transpile(),
|
|
422
|
+
this.test_types(),
|
|
399
423
|
_coverage ? this.coverage() : this.test(),
|
|
400
424
|
this.lint(),
|
|
401
425
|
])
|
|
402
426
|
} else {
|
|
403
427
|
await this.transpile()
|
|
428
|
+
await this.test_types(),
|
|
404
429
|
await (_coverage ? this.coverage() : this.test()),
|
|
405
430
|
await this.lint()
|
|
406
431
|
}
|
|
@@ -422,13 +447,3 @@ export function tasks(options: TasksOptions = {}) {
|
|
|
422
447
|
},
|
|
423
448
|
})
|
|
424
449
|
}
|
|
425
|
-
|
|
426
|
-
/* coverage ignore next */
|
|
427
|
-
/* Leave this at the _end_ of the file, unicode messes up sitemaps... */
|
|
428
|
-
export function banner(message: string): void {
|
|
429
|
-
log.notice([
|
|
430
|
-
'', $gry(`\u2554${''.padStart(60, '\u2550')}\u2557`),
|
|
431
|
-
`${$gry('\u2551')} ${$wht(message.padEnd(58, ' '))} ${$gry('\u2551')}`,
|
|
432
|
-
$gry(`\u255A${''.padStart(60, '\u2550')}\u255D`), '',
|
|
433
|
-
].join('\n'))
|
|
434
|
-
}
|