@plugjs/build 0.1.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.
- package/LICENSE.md +211 -0
- package/NOTICE.md +13 -0
- package/README.md +13 -0
- package/dist/bootstrap.d.mts +2 -0
- package/dist/bootstrap.mjs +47 -0
- package/dist/bootstrap.mjs.map +6 -0
- package/dist/build.cjs +170 -0
- package/dist/build.cjs.map +6 -0
- package/dist/build.d.ts +85 -0
- package/dist/build.mjs +154 -0
- package/dist/build.mjs.map +6 -0
- package/package.json +41 -0
- package/resources/.eslintignore +3 -0
- package/resources/.eslintrc.cjs +8 -0
- package/resources/.gitignore +6 -0
- package/resources/build.ts +3 -0
- package/resources/src/index.ts +1 -0
- package/resources/test/00-index.test.ts +7 -0
- package/resources/test/tsconfig.json +8 -0
- package/resources/tsconfig.json +21 -0
- package/src/bootstrap.mts +60 -0
- package/src/build.ts +276 -0
package/LICENSE.md
ADDED
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
# Apache License
|
|
2
|
+
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
|
|
5
|
+
[http://www.apache.org/licenses/](http://www.apache.org/licenses/)
|
|
6
|
+
|
|
7
|
+
##### TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
8
|
+
|
|
9
|
+
### 1. Definitions.
|
|
10
|
+
|
|
11
|
+
"**License**" shall mean the terms and conditions for use, reproduction,
|
|
12
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
13
|
+
|
|
14
|
+
"**Licensor**" shall mean the copyright owner or entity authorized by
|
|
15
|
+
the copyright owner that is granting the License.
|
|
16
|
+
|
|
17
|
+
"**Legal Entity**" shall mean the union of the acting entity and all
|
|
18
|
+
other entities that control, are controlled by, or are under common
|
|
19
|
+
control with that entity. For the purposes of this definition,
|
|
20
|
+
"**control**" means **(i)** the power, direct or indirect, to cause the
|
|
21
|
+
direction or management of such entity, whether by contract or
|
|
22
|
+
otherwise, _or_ **(ii)** ownership of fifty percent (50%) or more of
|
|
23
|
+
the outstanding shares, _or_ **(iii)** beneficial ownership of such
|
|
24
|
+
entity.
|
|
25
|
+
|
|
26
|
+
"**You**" (or "**Your**") shall mean an individual or Legal Entity
|
|
27
|
+
exercising permissions granted by this License.
|
|
28
|
+
|
|
29
|
+
"**Source**" form shall mean the preferred form for making
|
|
30
|
+
modifications, including but not limited to software source code,
|
|
31
|
+
documentation source, and configuration files.
|
|
32
|
+
|
|
33
|
+
"**Object**" form shall mean any form resulting from mechanical
|
|
34
|
+
transformation or translation of a Source form, including but not
|
|
35
|
+
limited to compiled object code, generated documentation, and
|
|
36
|
+
conversions to other media types.
|
|
37
|
+
|
|
38
|
+
"**Work**" shall mean the work of authorship, whether in Source or
|
|
39
|
+
Object form, made available under the License, as indicated by a
|
|
40
|
+
copyright notice that is included in or attached to the work (an example
|
|
41
|
+
is provided in the Appendix below).
|
|
42
|
+
|
|
43
|
+
"**Derivative Works**" shall mean any work, whether in Source or Object
|
|
44
|
+
form, that is based on (or derived from) the Work and for which the
|
|
45
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
46
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
47
|
+
of this License, Derivative Works shall not include works that remain
|
|
48
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
49
|
+
the Work and Derivative Works thereof.
|
|
50
|
+
|
|
51
|
+
"**Contribution**" shall mean any work of authorship, including the
|
|
52
|
+
original version of the Work and any modifications or additions to that
|
|
53
|
+
Work or Derivative Works thereof, that is intentionally submitted to
|
|
54
|
+
Licensor for inclusion in the Work by the copyright owner or by an
|
|
55
|
+
individual or Legal Entity authorized to submit on behalf of the
|
|
56
|
+
copyright owner. For the purposes of this definition, "**submitted**"
|
|
57
|
+
means any form of electronic, verbal, or written communication sent to
|
|
58
|
+
the Licensor or its representatives, including but not limited to
|
|
59
|
+
communication on electronic mailing lists, source code control systems,
|
|
60
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
61
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
62
|
+
excluding communication that is conspicuously marked or otherwise
|
|
63
|
+
designated in writing by the copyright owner as "**Not a
|
|
64
|
+
Contribution**".
|
|
65
|
+
|
|
66
|
+
"**Contributor**" shall mean Licensor and any individual or Legal Entity
|
|
67
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
68
|
+
subsequently incorporated within the Work.
|
|
69
|
+
|
|
70
|
+
### 2. Grant of Copyright License.
|
|
71
|
+
|
|
72
|
+
Subject to the terms and conditions of this License, each Contributor
|
|
73
|
+
hereby grants to You a perpetual, worldwide, non-exclusive, no-charge,
|
|
74
|
+
royalty-free, irrevocable copyright license to reproduce, prepare
|
|
75
|
+
Derivative Works of, publicly display, publicly perform, sublicense,
|
|
76
|
+
and distribute the Work and such Derivative Works in Source or Object
|
|
77
|
+
form.
|
|
78
|
+
|
|
79
|
+
### 3. Grant of Patent License.
|
|
80
|
+
|
|
81
|
+
Subject to the terms and conditions of this License, each Contributor
|
|
82
|
+
hereby grants to You a perpetual, worldwide, non-exclusive, no-charge,
|
|
83
|
+
royalty-free, irrevocable (except as stated in this section) patent
|
|
84
|
+
license to make, have made, use, offer to sell, sell, import, and
|
|
85
|
+
otherwise transfer the Work, where such license applies only to those
|
|
86
|
+
patent claims licensable by such Contributor that are necessarily
|
|
87
|
+
infringed by their Contribution(s) alone or by combination of their
|
|
88
|
+
Contribution(s) with the Work to which such Contribution(s) was
|
|
89
|
+
submitted. If You institute patent litigation against any entity
|
|
90
|
+
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
|
91
|
+
the Work or a Contribution incorporated within the Work constitutes
|
|
92
|
+
direct or contributory patent infringement, then any patent licenses
|
|
93
|
+
granted to You under this License for that Work shall terminate as of
|
|
94
|
+
the date such litigation is filed.
|
|
95
|
+
|
|
96
|
+
### 4. Redistribution.
|
|
97
|
+
|
|
98
|
+
You may reproduce and distribute copies of the Work or Derivative Works
|
|
99
|
+
thereof in any medium, with or without modifications, and in Source or
|
|
100
|
+
Object form, provided that You meet the following conditions:
|
|
101
|
+
|
|
102
|
+
<ol type="a">
|
|
103
|
+
<li>You must give any other recipients of the Work or Derivative Works
|
|
104
|
+
a copy of this License; and
|
|
105
|
+
<li>You must cause any modified files to carry prominent notices
|
|
106
|
+
stating that You changed the files; and
|
|
107
|
+
<li>You must retain, in the Source form of any Derivative Works that
|
|
108
|
+
You distribute, all copyright, patent, trademark, and attribution
|
|
109
|
+
notices from the Source form of the Work, excluding those notices
|
|
110
|
+
that do not pertain to any part of the Derivative Works; and
|
|
111
|
+
<li>If the Work includes a "NOTICE" text file as part of its
|
|
112
|
+
distribution, then any Derivative Works that You distribute must
|
|
113
|
+
include a readable copy of the attribution notices contained within
|
|
114
|
+
such NOTICE file, excluding those notices that do not pertain to any
|
|
115
|
+
part of the Derivative Works, in at least one of the following
|
|
116
|
+
places: within a NOTICE text file distributed as part of the
|
|
117
|
+
Derivative Works; within the Source form or documentation, if
|
|
118
|
+
provided along with the Derivative Works; or, within a display
|
|
119
|
+
generated by the Derivative Works, if and wherever such third-party
|
|
120
|
+
notices normally appear. The contents of the NOTICE file are for
|
|
121
|
+
informational purposes only and do not modify the License. You may
|
|
122
|
+
add Your own attribution notices within Derivative Works that You
|
|
123
|
+
distribute, alongside or as an addendum to the NOTICE text from the
|
|
124
|
+
Work, provided that such additional attribution notices cannot be
|
|
125
|
+
construed as modifying the License.
|
|
126
|
+
</ol>
|
|
127
|
+
|
|
128
|
+
You may add Your own copyright statement to Your modifications and may
|
|
129
|
+
provide additional or different license terms and conditions for use,
|
|
130
|
+
reproduction, or distribution of Your modifications, or for any such
|
|
131
|
+
Derivative Works as a whole, provided Your use, reproduction, and
|
|
132
|
+
distribution of the Work otherwise complies with the conditions stated
|
|
133
|
+
in this License.
|
|
134
|
+
|
|
135
|
+
### 5. Submission of Contributions.
|
|
136
|
+
|
|
137
|
+
Unless You explicitly state otherwise, any Contribution intentionally
|
|
138
|
+
submitted for inclusion in the Work by You to the Licensor shall be
|
|
139
|
+
under the terms and conditions of this License, without any additional
|
|
140
|
+
terms or conditions. Notwithstanding the above, nothing herein shall
|
|
141
|
+
supersede or modify the terms of any separate license agreement you may
|
|
142
|
+
have executed with Licensor regarding such Contributions.
|
|
143
|
+
|
|
144
|
+
### 6. Trademarks.
|
|
145
|
+
|
|
146
|
+
This License does not grant permission to use the trade names,
|
|
147
|
+
trademarks, service marks, or product names of the Licensor, except as
|
|
148
|
+
required for reasonable and customary use in describing the origin of
|
|
149
|
+
the Work and reproducing the content of the NOTICE file.
|
|
150
|
+
|
|
151
|
+
### 7. Disclaimer of Warranty.
|
|
152
|
+
|
|
153
|
+
Unless required by applicable law or agreed to in writing, Licensor
|
|
154
|
+
provides the Work (and each Contributor provides its Contributions) on
|
|
155
|
+
an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
|
|
156
|
+
express or implied, including, without limitation, any warranties or
|
|
157
|
+
conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR
|
|
158
|
+
A PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
159
|
+
appropriateness of using or redistributing the Work and assume any risks
|
|
160
|
+
associated with Your exercise of permissions under this License.
|
|
161
|
+
|
|
162
|
+
### 8. Limitation of Liability.
|
|
163
|
+
|
|
164
|
+
In no event and under no legal theory, whether in tort (including
|
|
165
|
+
negligence), contract, or otherwise, unless required by applicable law
|
|
166
|
+
(such as deliberate and grossly negligent acts) or agreed to in writing,
|
|
167
|
+
shall any Contributor be liable to You for damages, including any
|
|
168
|
+
direct, indirect, special, incidental, or consequential damages of any
|
|
169
|
+
character arising as a result of this License or out of the use or
|
|
170
|
+
inability to use the Work (including but not limited to damages for loss
|
|
171
|
+
of goodwill, work stoppage, computer failure or malfunction, or any and
|
|
172
|
+
all other commercial damages or losses), even if such Contributor has
|
|
173
|
+
been advised of the possibility of such damages.
|
|
174
|
+
|
|
175
|
+
### 9. Accepting Warranty or Additional Liability.
|
|
176
|
+
|
|
177
|
+
While redistributing the Work or Derivative Works thereof, You may
|
|
178
|
+
choose to offer, and charge a fee for, acceptance of support, warranty,
|
|
179
|
+
indemnity, or other liability obligations and/or rights consistent with
|
|
180
|
+
this License. However, in accepting such obligations, You may act only
|
|
181
|
+
on Your own behalf and on Your sole responsibility, not on behalf of any
|
|
182
|
+
other Contributor, and only if You agree to indemnify, defend, and hold
|
|
183
|
+
each Contributor harmless for any liability incurred by, or claims
|
|
184
|
+
asserted against, such Contributor by reason of your accepting any
|
|
185
|
+
such warranty or additional liability.
|
|
186
|
+
|
|
187
|
+
##### END OF TERMS AND CONDITIONS
|
|
188
|
+
|
|
189
|
+
## APPENDIX: How to apply the Apache License to your work.
|
|
190
|
+
|
|
191
|
+
To apply the Apache License to your work, attach the following
|
|
192
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
193
|
+
replaced with your own identifying information. (Don't include the
|
|
194
|
+
brackets!) The text should be enclosed in the appropriate comment
|
|
195
|
+
syntax for the file format. We also recommend that a file or class name
|
|
196
|
+
and description of purpose be included on the same "printed page" as the
|
|
197
|
+
copyright notice for easier identification within third-party archives.
|
|
198
|
+
|
|
199
|
+
> #### Copyright [yyyy] [name of copyright owner]
|
|
200
|
+
>
|
|
201
|
+
> Licensed under the Apache License, Version 2.0 (the "License");
|
|
202
|
+
> you may not use this file except in compliance with the License.
|
|
203
|
+
> You may obtain a copy of the License at
|
|
204
|
+
>
|
|
205
|
+
> [http://www.apache.org/licenses/](http://www.apache.org/licenses/)
|
|
206
|
+
>
|
|
207
|
+
> Unless required by applicable law or agreed to in writing, software
|
|
208
|
+
> distributed under the License is distributed on an "AS IS" BASIS,
|
|
209
|
+
> WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
210
|
+
> See the License for the specific language governing permissions and
|
|
211
|
+
> limitations under the License.
|
package/NOTICE.md
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# Copyright 2022 Juit GmbH
|
|
2
|
+
|
|
3
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
you may not use this file except in compliance with the License.
|
|
5
|
+
You may obtain a copy of the License at
|
|
6
|
+
|
|
7
|
+
[http://www.apache.org/licenses/](http://www.apache.org/licenses/)
|
|
8
|
+
|
|
9
|
+
Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
See the License for the specific language governing permissions and
|
|
13
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
// bootstrap.mts
|
|
4
|
+
import { build, find, invoke, log, resolve, fs, isFile } from "@plugjs/plug";
|
|
5
|
+
import { $p } from "@plugjs/plug/logging";
|
|
6
|
+
var tasks = build({
|
|
7
|
+
async bootstrap_resources() {
|
|
8
|
+
const pipe = find("**/*", "**/.*", { directory: "@../resources" });
|
|
9
|
+
const sources = await pipe;
|
|
10
|
+
const targets = await pipe.copy(".", { overwrite });
|
|
11
|
+
log("Bootstrapped", targets.length, "of", sources.length, "files:");
|
|
12
|
+
for (const file of targets.absolutePaths())
|
|
13
|
+
log(` ${$p(file)}`);
|
|
14
|
+
},
|
|
15
|
+
async bootstrap_package() {
|
|
16
|
+
const buildPackage = resolve("@../package.json");
|
|
17
|
+
log(`Reading ${$p(buildPackage)}`);
|
|
18
|
+
const buildData = await fs.readFile(buildPackage, "utf-8");
|
|
19
|
+
const buildJson = JSON.parse(buildData);
|
|
20
|
+
const targetJson = {};
|
|
21
|
+
const targetPackage = resolve("./package.json");
|
|
22
|
+
if (isFile(targetPackage)) {
|
|
23
|
+
log(`Reading ${$p(targetPackage)}`);
|
|
24
|
+
const targetData = await fs.readFile(targetPackage, "utf-8");
|
|
25
|
+
Object.assign(targetJson, JSON.parse(targetData));
|
|
26
|
+
}
|
|
27
|
+
log(`Updating ${$p(targetPackage)}`);
|
|
28
|
+
if (!targetJson.scripts?.build) {
|
|
29
|
+
targetJson.scripts = Object.assign({}, targetJson.scripts, {
|
|
30
|
+
build: "plug"
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
targetJson.devDependencies = Object.assign({}, targetJson.devDependencies, {
|
|
34
|
+
[buildJson.name]: `^${buildJson.version}`
|
|
35
|
+
});
|
|
36
|
+
log(`Writing ${$p(targetPackage)}`);
|
|
37
|
+
await fs.writeFile(targetPackage, JSON.stringify(targetJson, null, 2), "utf-8");
|
|
38
|
+
},
|
|
39
|
+
async bootstrap() {
|
|
40
|
+
log(`Boostrapping PlugJS Build from ${$p(resolve("@"))}`);
|
|
41
|
+
await this.bootstrap_resources();
|
|
42
|
+
await this.bootstrap_package();
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
var overwrite = process.argv[2] === "--overwrite" ? "overwrite" : "skip";
|
|
46
|
+
invoke(tasks, "bootstrap", { overwrite }).catch(log.error);
|
|
47
|
+
//# sourceMappingURL=bootstrap.mjs.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/bootstrap.mts"],
|
|
4
|
+
"mappings": ";;;AACA,SAAS,OAAO,MAAM,QAAQ,KAAK,SAAS,IAAI,cAAc;AAC9D,SAAS,UAAU;AAEnB,IAAM,QAAQ,MAAM;AAAA,EAElB,MAAM,sBAAqC;AACzC,UAAM,OAAO,KAAK,QAAQ,SAAS,EAAE,WAAW,gBAAgB,CAAC;AACjE,UAAM,UAAU,MAAM;AACtB,UAAM,UAAU,MAAM,KAAK,KAAK,KAAK,EAAE,UAAU,CAAC;AAElD,QAAI,gBAAgB,QAAQ,QAAQ,MAAM,QAAQ,QAAQ,QAAQ;AAClE,eAAW,QAAQ,QAAQ,cAAc;AAAG,UAAI,OAAO,GAAG,IAAI,GAAG;AAAA,EACnE;AAAA,EAGA,MA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3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// build.ts
|
|
21
|
+
var build_exports = {};
|
|
22
|
+
__export(build_exports, {
|
|
23
|
+
tasks: () => tasks
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(build_exports);
|
|
26
|
+
var import_cov8 = require("@plugjs/cov8");
|
|
27
|
+
var import_eslint = require("@plugjs/eslint");
|
|
28
|
+
var import_jasmine = require("@plugjs/jasmine");
|
|
29
|
+
var import_typescript = require("@plugjs/typescript");
|
|
30
|
+
var import_plug = require("@plugjs/plug");
|
|
31
|
+
var esbuildDefaults = {
|
|
32
|
+
platform: "node",
|
|
33
|
+
sourcemap: "linked",
|
|
34
|
+
sourcesContent: false,
|
|
35
|
+
plugins: [(0, import_plug.fixExtensions)()]
|
|
36
|
+
};
|
|
37
|
+
function tasks(options = {}) {
|
|
38
|
+
const {
|
|
39
|
+
sourceDir = "src",
|
|
40
|
+
destDir = "dist",
|
|
41
|
+
testDir = "test",
|
|
42
|
+
coverageDir = "coverage",
|
|
43
|
+
coverageDataDir = ".coverage-data",
|
|
44
|
+
extraTypesDir = "types",
|
|
45
|
+
testGlob = "**/*.test.ts",
|
|
46
|
+
disableTests = false,
|
|
47
|
+
disableCoverage = false,
|
|
48
|
+
disableLint = false,
|
|
49
|
+
minimumCoverage = 100,
|
|
50
|
+
minimumFileCoverage = 100,
|
|
51
|
+
optimalCoverage = void 0,
|
|
52
|
+
optimalFileCoverage = void 0,
|
|
53
|
+
esbuildOptions = {}
|
|
54
|
+
} = options;
|
|
55
|
+
const esbuildMergedOptions = Object.assign({}, esbuildDefaults, esbuildOptions);
|
|
56
|
+
return (0, import_plug.build)({
|
|
57
|
+
find_sources_cts() {
|
|
58
|
+
return (0, import_plug.find)("**/*.(c)?ts", { directory: sourceDir, ignore: "**/*.d.ts" });
|
|
59
|
+
},
|
|
60
|
+
find_sources_mts() {
|
|
61
|
+
return (0, import_plug.find)("**/*.(m)?ts", { directory: sourceDir, ignore: "**/*.d.ts" });
|
|
62
|
+
},
|
|
63
|
+
find_sources() {
|
|
64
|
+
return (0, import_plug.merge)([this.find_sources_cts(), this.find_sources_mts()]);
|
|
65
|
+
},
|
|
66
|
+
find_types() {
|
|
67
|
+
return (0, import_plug.find)("**/*.d.ts", { directory: sourceDir });
|
|
68
|
+
},
|
|
69
|
+
find_extras() {
|
|
70
|
+
if (!(0, import_plug.isDirectory)(extraTypesDir))
|
|
71
|
+
return (0, import_plug.noop)();
|
|
72
|
+
return (0, import_plug.find)("**/*.d.ts", { directory: extraTypesDir });
|
|
73
|
+
},
|
|
74
|
+
find_resources() {
|
|
75
|
+
return (0, import_plug.find)("**/*", { directory: sourceDir, ignore: "**/*.([mt])?ts" });
|
|
76
|
+
},
|
|
77
|
+
find_tests() {
|
|
78
|
+
return (0, import_plug.find)(testGlob, { directory: testDir, ignore: "**/*.d.ts" });
|
|
79
|
+
},
|
|
80
|
+
transpile_cjs() {
|
|
81
|
+
return this.find_sources_cts().esbuild({
|
|
82
|
+
...esbuildMergedOptions,
|
|
83
|
+
format: "cjs",
|
|
84
|
+
outdir: destDir,
|
|
85
|
+
outExtension: { ".js": ".cjs" }
|
|
86
|
+
});
|
|
87
|
+
},
|
|
88
|
+
transpile_esm() {
|
|
89
|
+
return this.find_sources_mts().esbuild({
|
|
90
|
+
...esbuildMergedOptions,
|
|
91
|
+
format: "esm",
|
|
92
|
+
outdir: destDir,
|
|
93
|
+
outExtension: { ".js": ".mjs" }
|
|
94
|
+
});
|
|
95
|
+
},
|
|
96
|
+
transpile_types() {
|
|
97
|
+
return (0, import_plug.merge)([
|
|
98
|
+
this.find_sources(),
|
|
99
|
+
this.find_types(),
|
|
100
|
+
this.find_extras()
|
|
101
|
+
]).tsc("tsconfig.json", {
|
|
102
|
+
noEmit: false,
|
|
103
|
+
rootDir: sourceDir,
|
|
104
|
+
declaration: true,
|
|
105
|
+
emitDeclarationOnly: true,
|
|
106
|
+
outDir: destDir
|
|
107
|
+
});
|
|
108
|
+
},
|
|
109
|
+
transpile_resources() {
|
|
110
|
+
return (0, import_plug.merge)([
|
|
111
|
+
this.find_resources(),
|
|
112
|
+
this.find_types()
|
|
113
|
+
]).copy(destDir);
|
|
114
|
+
},
|
|
115
|
+
transpile() {
|
|
116
|
+
return (0, import_plug.merge)([
|
|
117
|
+
this.transpile_cjs(),
|
|
118
|
+
this.transpile_esm(),
|
|
119
|
+
this.transpile_types(),
|
|
120
|
+
this.transpile_resources()
|
|
121
|
+
]);
|
|
122
|
+
},
|
|
123
|
+
async test() {
|
|
124
|
+
if (disableTests) {
|
|
125
|
+
return void import_plug.log.warn("Testing disabled");
|
|
126
|
+
}
|
|
127
|
+
if ((0, import_plug.isDirectory)(coverageDataDir))
|
|
128
|
+
await (0, import_plug.rmrf)(coverageDataDir);
|
|
129
|
+
await this.find_tests().jasmine({ coverageDir: coverageDataDir });
|
|
130
|
+
},
|
|
131
|
+
async coverage() {
|
|
132
|
+
if (disableTests || disableCoverage) {
|
|
133
|
+
return void import_plug.log.warn("Coverage disabled");
|
|
134
|
+
}
|
|
135
|
+
await this.test().finally(() => this.find_sources().coverage(coverageDataDir, {
|
|
136
|
+
reportDir: coverageDir,
|
|
137
|
+
minimumCoverage,
|
|
138
|
+
minimumFileCoverage,
|
|
139
|
+
optimalCoverage,
|
|
140
|
+
optimalFileCoverage
|
|
141
|
+
}));
|
|
142
|
+
},
|
|
143
|
+
async lint() {
|
|
144
|
+
if (disableLint) {
|
|
145
|
+
return void import_plug.log.warn("Linting disabled");
|
|
146
|
+
}
|
|
147
|
+
await (0, import_plug.merge)([
|
|
148
|
+
this.find_sources(),
|
|
149
|
+
this.find_tests(),
|
|
150
|
+
this.find_types(),
|
|
151
|
+
this.find_extras()
|
|
152
|
+
]).eslint();
|
|
153
|
+
},
|
|
154
|
+
async default() {
|
|
155
|
+
if ((0, import_plug.isDirectory)(destDir))
|
|
156
|
+
await (0, import_plug.rmrf)(destDir);
|
|
157
|
+
await Promise.all([
|
|
158
|
+
this.test(),
|
|
159
|
+
this.coverage(),
|
|
160
|
+
this.lint(),
|
|
161
|
+
this.transpile()
|
|
162
|
+
]);
|
|
163
|
+
}
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
167
|
+
0 && (module.exports = {
|
|
168
|
+
tasks
|
|
169
|
+
});
|
|
170
|
+
//# sourceMappingURL=build.cjs.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/build.ts"],
|
|
4
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAO;AACP,oBAAO;AACP,qBAAO;AACP,wBAAO;AACP,kBASO;AAKP,IAAM,kBAAkC;AAAA,EACtC,UAAU;AAAA,EACV,WAAW;AAAA,EACX,gBAAgB;AAAA,EAChB,SAAS,KAAE,2BAAc,CAAE;AAC7B;AA6DO,SAAS,MAAM,UAAwB,CAAC,GAAG;AAChD,QAAM;AAAA,IACJ,YAAY;AAAA,IAC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AAA,QACA;AAAA,MACF,CAAC,CAAC;AAAA,IACZ;AAAA,IAGA,MAAM,OAAsB;AAC1B,UAAI,aAAa;AACf,eAAO,KAAK,gBAAI,KAAK,kBAAkB;AAAA,MACzC;AAEA,gBAAM,mBAAM;AAAA,QACV,KAAK,aAAa;AAAA,QAClB,KAAK,WAAW;AAAA,QAChB,KAAK,WAAW;AAAA,QAChB,KAAK,YAAY;AAAA,MACnB,CAAC,EAAE,OAAO;AAAA,IACZ;AAAA,IAOA,MAAM,UAAyB;AAC7B,cAAI,yBAAY,OAAO;AAAG,kBAAM,kBAAK,OAAO;AAE5C,YAAM,QAAQ,IAAI;AAAA,QAChB,KAAK,KAAK;AAAA,QACV,KAAK,SAAS;AAAA,QACd,KAAK,KAAK;AAAA,QACV,KAAK,UAAU;AAAA,MACjB,CAAC;AAAA,IACH;AAAA,EACF,CAAC;AACH;",
|
|
5
|
+
"names": []
|
|
6
|
+
}
|
package/dist/build.d.ts
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import '@plugjs/cov8';
|
|
2
|
+
import '@plugjs/eslint';
|
|
3
|
+
import '@plugjs/jasmine';
|
|
4
|
+
import '@plugjs/typescript';
|
|
5
|
+
import type { ESBuildOptions, Pipe } from '@plugjs/plug';
|
|
6
|
+
/** Options for creating our shared build file */
|
|
7
|
+
export interface TasksOptions {
|
|
8
|
+
/** The directory for the original sources (default: `src`) */
|
|
9
|
+
sourceDir?: string;
|
|
10
|
+
/** The destination directory of the transpiled sources (default: `dist`) */
|
|
11
|
+
destDir?: string;
|
|
12
|
+
/** The directory for the test files (default: `test`) */
|
|
13
|
+
testDir?: string;
|
|
14
|
+
/** The directory for the coverage report (default: `coverage`) */
|
|
15
|
+
coverageDir?: string;
|
|
16
|
+
/** The directory for the coverage data (default: `.coverage-data`) */
|
|
17
|
+
coverageDataDir?: string;
|
|
18
|
+
/** A directory containing extra types to use while transpiling (default: `types`) */
|
|
19
|
+
extraTypesDir?: string;
|
|
20
|
+
/** A glob pattern matching all test files (default: `**∕*.test.ts`) */
|
|
21
|
+
testGlob?: string;
|
|
22
|
+
/** Whether to disable tests or not (defailt: `false`) */
|
|
23
|
+
disableTests?: boolean;
|
|
24
|
+
/** Whether to disable code coverage or not (defailt: `false`) */
|
|
25
|
+
disableCoverage?: boolean;
|
|
26
|
+
/** Whether to disable code linting or not (defailt: `false`) */
|
|
27
|
+
disableLint?: boolean;
|
|
28
|
+
/** Minimum overall coverage percentage (default: `100`) */
|
|
29
|
+
minimumCoverage?: number;
|
|
30
|
+
/** Minimum per-file coverage percentage (default: `100`) */
|
|
31
|
+
minimumFileCoverage?: number;
|
|
32
|
+
/** Optimal overall coverage percentage (default: _none_) */
|
|
33
|
+
optimalCoverage?: number;
|
|
34
|
+
/** Optimal per-file coverage percentage (default: _none_) */
|
|
35
|
+
optimalFileCoverage?: number;
|
|
36
|
+
/**
|
|
37
|
+
* ESBuild compilation options
|
|
38
|
+
*
|
|
39
|
+
* Default:
|
|
40
|
+
*
|
|
41
|
+
* ```
|
|
42
|
+
* {
|
|
43
|
+
* platform: 'node',
|
|
44
|
+
* sourcemap: 'linked',
|
|
45
|
+
* sourcesContent: false,
|
|
46
|
+
* plugins: [ fixExtensions() ],
|
|
47
|
+
* }
|
|
48
|
+
* ```
|
|
49
|
+
*/
|
|
50
|
+
esbuildOptions?: ESBuildOptions;
|
|
51
|
+
}
|
|
52
|
+
export declare function tasks(options?: TasksOptions): import("@plugjs/plug").Build<{
|
|
53
|
+
/** Find all CommonJS source files (`*.cts`) */
|
|
54
|
+
find_sources_cts(): Pipe;
|
|
55
|
+
/** Find all EcmaScript Module source files (`*.mts`) */
|
|
56
|
+
find_sources_mts(): Pipe;
|
|
57
|
+
/** Find all typescript source files (`*.ts`, `*.mts` and `*.cts`) */
|
|
58
|
+
find_sources(): Pipe;
|
|
59
|
+
/** Find all types definition files within sources */
|
|
60
|
+
find_types(): Pipe;
|
|
61
|
+
/** Find all types definition files within sources */
|
|
62
|
+
find_extras(): Pipe;
|
|
63
|
+
/** Find all resource files (non-typescript files) within sources */
|
|
64
|
+
find_resources(): Pipe;
|
|
65
|
+
/** Find all test source files */
|
|
66
|
+
find_tests(): Pipe;
|
|
67
|
+
/** Transpile to CJS */
|
|
68
|
+
transpile_cjs(): Pipe;
|
|
69
|
+
/** Transpile to ESM */
|
|
70
|
+
transpile_esm(): Pipe;
|
|
71
|
+
/** Generate all .d.ts files */
|
|
72
|
+
transpile_types(): Pipe;
|
|
73
|
+
/** Copy all resources coming alongside our sources */
|
|
74
|
+
transpile_resources(): Pipe;
|
|
75
|
+
/** Transpile all source code */
|
|
76
|
+
transpile(): Pipe;
|
|
77
|
+
/** Run test and emit coverage data */
|
|
78
|
+
test(): Promise<void>;
|
|
79
|
+
/** Run tests (always) and generate a coverage report */
|
|
80
|
+
coverage(): Promise<void>;
|
|
81
|
+
/** Run test and emit coverage data */
|
|
82
|
+
lint(): Promise<void>;
|
|
83
|
+
/** Build everything */
|
|
84
|
+
default(): Promise<void>;
|
|
85
|
+
}>;
|
package/dist/build.mjs
ADDED
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
// build.ts
|
|
2
|
+
import "@plugjs/cov8";
|
|
3
|
+
import "@plugjs/eslint";
|
|
4
|
+
import "@plugjs/jasmine";
|
|
5
|
+
import "@plugjs/typescript";
|
|
6
|
+
import {
|
|
7
|
+
build,
|
|
8
|
+
find,
|
|
9
|
+
fixExtensions,
|
|
10
|
+
isDirectory,
|
|
11
|
+
log,
|
|
12
|
+
merge,
|
|
13
|
+
noop,
|
|
14
|
+
rmrf
|
|
15
|
+
} from "@plugjs/plug";
|
|
16
|
+
var esbuildDefaults = {
|
|
17
|
+
platform: "node",
|
|
18
|
+
sourcemap: "linked",
|
|
19
|
+
sourcesContent: false,
|
|
20
|
+
plugins: [fixExtensions()]
|
|
21
|
+
};
|
|
22
|
+
function tasks(options = {}) {
|
|
23
|
+
const {
|
|
24
|
+
sourceDir = "src",
|
|
25
|
+
destDir = "dist",
|
|
26
|
+
testDir = "test",
|
|
27
|
+
coverageDir = "coverage",
|
|
28
|
+
coverageDataDir = ".coverage-data",
|
|
29
|
+
extraTypesDir = "types",
|
|
30
|
+
testGlob = "**/*.test.ts",
|
|
31
|
+
disableTests = false,
|
|
32
|
+
disableCoverage = false,
|
|
33
|
+
disableLint = false,
|
|
34
|
+
minimumCoverage = 100,
|
|
35
|
+
minimumFileCoverage = 100,
|
|
36
|
+
optimalCoverage = void 0,
|
|
37
|
+
optimalFileCoverage = void 0,
|
|
38
|
+
esbuildOptions = {}
|
|
39
|
+
} = options;
|
|
40
|
+
const esbuildMergedOptions = Object.assign({}, esbuildDefaults, esbuildOptions);
|
|
41
|
+
return build({
|
|
42
|
+
find_sources_cts() {
|
|
43
|
+
return find("**/*.(c)?ts", { directory: sourceDir, ignore: "**/*.d.ts" });
|
|
44
|
+
},
|
|
45
|
+
find_sources_mts() {
|
|
46
|
+
return find("**/*.(m)?ts", { directory: sourceDir, ignore: "**/*.d.ts" });
|
|
47
|
+
},
|
|
48
|
+
find_sources() {
|
|
49
|
+
return merge([this.find_sources_cts(), this.find_sources_mts()]);
|
|
50
|
+
},
|
|
51
|
+
find_types() {
|
|
52
|
+
return find("**/*.d.ts", { directory: sourceDir });
|
|
53
|
+
},
|
|
54
|
+
find_extras() {
|
|
55
|
+
if (!isDirectory(extraTypesDir))
|
|
56
|
+
return noop();
|
|
57
|
+
return find("**/*.d.ts", { directory: extraTypesDir });
|
|
58
|
+
},
|
|
59
|
+
find_resources() {
|
|
60
|
+
return find("**/*", { directory: sourceDir, ignore: "**/*.([mt])?ts" });
|
|
61
|
+
},
|
|
62
|
+
find_tests() {
|
|
63
|
+
return find(testGlob, { directory: testDir, ignore: "**/*.d.ts" });
|
|
64
|
+
},
|
|
65
|
+
transpile_cjs() {
|
|
66
|
+
return this.find_sources_cts().esbuild({
|
|
67
|
+
...esbuildMergedOptions,
|
|
68
|
+
format: "cjs",
|
|
69
|
+
outdir: destDir,
|
|
70
|
+
outExtension: { ".js": ".cjs" }
|
|
71
|
+
});
|
|
72
|
+
},
|
|
73
|
+
transpile_esm() {
|
|
74
|
+
return this.find_sources_mts().esbuild({
|
|
75
|
+
...esbuildMergedOptions,
|
|
76
|
+
format: "esm",
|
|
77
|
+
outdir: destDir,
|
|
78
|
+
outExtension: { ".js": ".mjs" }
|
|
79
|
+
});
|
|
80
|
+
},
|
|
81
|
+
transpile_types() {
|
|
82
|
+
return merge([
|
|
83
|
+
this.find_sources(),
|
|
84
|
+
this.find_types(),
|
|
85
|
+
this.find_extras()
|
|
86
|
+
]).tsc("tsconfig.json", {
|
|
87
|
+
noEmit: false,
|
|
88
|
+
rootDir: sourceDir,
|
|
89
|
+
declaration: true,
|
|
90
|
+
emitDeclarationOnly: true,
|
|
91
|
+
outDir: destDir
|
|
92
|
+
});
|
|
93
|
+
},
|
|
94
|
+
transpile_resources() {
|
|
95
|
+
return merge([
|
|
96
|
+
this.find_resources(),
|
|
97
|
+
this.find_types()
|
|
98
|
+
]).copy(destDir);
|
|
99
|
+
},
|
|
100
|
+
transpile() {
|
|
101
|
+
return merge([
|
|
102
|
+
this.transpile_cjs(),
|
|
103
|
+
this.transpile_esm(),
|
|
104
|
+
this.transpile_types(),
|
|
105
|
+
this.transpile_resources()
|
|
106
|
+
]);
|
|
107
|
+
},
|
|
108
|
+
async test() {
|
|
109
|
+
if (disableTests) {
|
|
110
|
+
return void log.warn("Testing disabled");
|
|
111
|
+
}
|
|
112
|
+
if (isDirectory(coverageDataDir))
|
|
113
|
+
await rmrf(coverageDataDir);
|
|
114
|
+
await this.find_tests().jasmine({ coverageDir: coverageDataDir });
|
|
115
|
+
},
|
|
116
|
+
async coverage() {
|
|
117
|
+
if (disableTests || disableCoverage) {
|
|
118
|
+
return void log.warn("Coverage disabled");
|
|
119
|
+
}
|
|
120
|
+
await this.test().finally(() => this.find_sources().coverage(coverageDataDir, {
|
|
121
|
+
reportDir: coverageDir,
|
|
122
|
+
minimumCoverage,
|
|
123
|
+
minimumFileCoverage,
|
|
124
|
+
optimalCoverage,
|
|
125
|
+
optimalFileCoverage
|
|
126
|
+
}));
|
|
127
|
+
},
|
|
128
|
+
async lint() {
|
|
129
|
+
if (disableLint) {
|
|
130
|
+
return void log.warn("Linting disabled");
|
|
131
|
+
}
|
|
132
|
+
await merge([
|
|
133
|
+
this.find_sources(),
|
|
134
|
+
this.find_tests(),
|
|
135
|
+
this.find_types(),
|
|
136
|
+
this.find_extras()
|
|
137
|
+
]).eslint();
|
|
138
|
+
},
|
|
139
|
+
async default() {
|
|
140
|
+
if (isDirectory(destDir))
|
|
141
|
+
await rmrf(destDir);
|
|
142
|
+
await Promise.all([
|
|
143
|
+
this.test(),
|
|
144
|
+
this.coverage(),
|
|
145
|
+
this.lint(),
|
|
146
|
+
this.transpile()
|
|
147
|
+
]);
|
|
148
|
+
}
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
export {
|
|
152
|
+
tasks
|
|
153
|
+
};
|
|
154
|
+
//# sourceMappingURL=build.mjs.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/build.ts"],
|
|
4
|
+
"mappings": ";AAAA,OAAO;AACP,OAAO;AACP,OAAO;AACP,OAAO;AACP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAKP,IAAM,kBAAkC;AAAA,EACtC,UAAU;AAAA,EACV,WAAW;AAAA,EACX,gBAAgB;AAAA,EAChB,SAAS,CAAE,cAAc,CAAE;AAC7B;AA6DO,SAAS,MAAM,UAAwB,CAAC,GAAG;AAChD,QAAM;AAAA,IACJ,YAAY;AAAA,IACZ,UAAU;AAAA,IACV,UAAU;AAAA,IACV,cAAc;AAAA,IACd,kBAAkB;AAAA,IAClB,gBAAgB;AAAA,IAEhB,WAAW;AAAA,IACX,eAAe;AAAA,IACf,kBAAkB;AAAA,I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AAA,QAClB,KAAK,WAAW;AAAA,QAChB,KAAK,WAAW;AAAA,QAChB,KAAK,YAAY;AAAA,MACnB,CAAC,EAAE,OAAO;AAAA,IACZ;AAAA,IAOA,MAAM,UAAyB;AAC7B,UAAI,YAAY,OAAO;AAAG,cAAM,KAAK,OAAO;AAE5C,YAAM,QAAQ,IAAI;AAAA,QAChB,KAAK,KAAK;AAAA,QACV,KAAK,SAAS;AAAA,QACd,KAAK,KAAK;AAAA,QACV,KAAK,UAAU;AAAA,MACjB,CAAC;AAAA,IACH;AAAA,EACF,CAAC;AACH;",
|
|
5
|
+
"names": []
|
|
6
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@plugjs/build",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Simple shared build using PlugJS",
|
|
5
|
+
"main": "./dist/build.cjs",
|
|
6
|
+
"module": "./dist/build.mjs",
|
|
7
|
+
"types": "./dist/build.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"import": {
|
|
11
|
+
"types": "./dist/build.d.ts",
|
|
12
|
+
"default": "./dist/build.mjs"
|
|
13
|
+
},
|
|
14
|
+
"require": {
|
|
15
|
+
"types": "./dist/build.d.ts",
|
|
16
|
+
"default": "./dist/build.cjs"
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
"bin": {
|
|
21
|
+
"bootstrap-plugjs-build": "./dist/bootstrap.mjs"
|
|
22
|
+
},
|
|
23
|
+
"scripts": {
|
|
24
|
+
"build": "plug"
|
|
25
|
+
},
|
|
26
|
+
"dependencies": {
|
|
27
|
+
"@plugjs/cov8": "^0.1.2",
|
|
28
|
+
"@plugjs/eslint": "^0.1.2",
|
|
29
|
+
"@plugjs/eslint-plugin": "^0.1.1",
|
|
30
|
+
"@plugjs/jasmine": "^0.1.2",
|
|
31
|
+
"@plugjs/plug": "^0.1.3",
|
|
32
|
+
"@plugjs/typescript": "^0.1.2"
|
|
33
|
+
},
|
|
34
|
+
"files": [
|
|
35
|
+
"*.md",
|
|
36
|
+
"dist/",
|
|
37
|
+
"resources/",
|
|
38
|
+
"resources/**/.*",
|
|
39
|
+
"src/"
|
|
40
|
+
]
|
|
41
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const theAnswer = 42
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"lib": [ "es2022" ],
|
|
4
|
+
"target": "es2022",
|
|
5
|
+
"module": "es2022",
|
|
6
|
+
"moduleResolution": "node16",
|
|
7
|
+
"types": [ "node" ],
|
|
8
|
+
"esModuleInterop": true,
|
|
9
|
+
|
|
10
|
+
"noEmit": true,
|
|
11
|
+
|
|
12
|
+
"strict": true,
|
|
13
|
+
"noImplicitReturns": true,
|
|
14
|
+
"noUnusedLocals": true,
|
|
15
|
+
"noUnusedParameters": true,
|
|
16
|
+
},
|
|
17
|
+
"include": [
|
|
18
|
+
"./src",
|
|
19
|
+
"./build.ts",
|
|
20
|
+
],
|
|
21
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { build, find, invoke, log, resolve, fs, isFile } from '@plugjs/plug'
|
|
3
|
+
import { $p } from '@plugjs/plug/logging'
|
|
4
|
+
|
|
5
|
+
const tasks = build({
|
|
6
|
+
/** Copy all resources from the `resources/` directory into the target */
|
|
7
|
+
async bootstrap_resources(): Promise<void> {
|
|
8
|
+
const pipe = find('**/*', '**/.*', { directory: '@../resources' })
|
|
9
|
+
const sources = await pipe
|
|
10
|
+
const targets = await pipe.copy('.', { overwrite })
|
|
11
|
+
|
|
12
|
+
log('Bootstrapped', targets.length, 'of', sources.length, 'files:')
|
|
13
|
+
for (const file of targets.absolutePaths()) log(` ${$p(file)}`)
|
|
14
|
+
},
|
|
15
|
+
|
|
16
|
+
/** Setup dependencies and build script into target `package.json` */
|
|
17
|
+
async bootstrap_package(): Promise<void> {
|
|
18
|
+
// Read the "package.json" of "@plugjs/build"
|
|
19
|
+
const buildPackage = resolve('@../package.json')
|
|
20
|
+
log(`Reading ${$p(buildPackage)}`)
|
|
21
|
+
const buildData = await fs.readFile(buildPackage, 'utf-8')
|
|
22
|
+
const buildJson = JSON.parse(buildData)
|
|
23
|
+
|
|
24
|
+
// Read the "package.json" in the current directory (if any)
|
|
25
|
+
const targetJson: Record<string, any> = {}
|
|
26
|
+
const targetPackage = resolve('./package.json')
|
|
27
|
+
if (isFile(targetPackage)) {
|
|
28
|
+
log(`Reading ${$p(targetPackage)}`)
|
|
29
|
+
const targetData = await fs.readFile(targetPackage, 'utf-8')
|
|
30
|
+
Object.assign(targetJson, JSON.parse(targetData))
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// Merge package contents
|
|
34
|
+
log(`Updating ${$p(targetPackage)}`)
|
|
35
|
+
|
|
36
|
+
if (! targetJson.scripts?.build) {
|
|
37
|
+
targetJson.scripts = Object.assign({}, targetJson.scripts, {
|
|
38
|
+
build: 'plug',
|
|
39
|
+
})
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
targetJson.devDependencies = Object.assign({}, targetJson.devDependencies, {
|
|
43
|
+
[buildJson.name]: `^${buildJson.version}`,
|
|
44
|
+
})
|
|
45
|
+
|
|
46
|
+
// Overwrite taget package.json file
|
|
47
|
+
log(`Writing ${$p(targetPackage)}`)
|
|
48
|
+
await fs.writeFile(targetPackage, JSON.stringify(targetJson, null, 2), 'utf-8')
|
|
49
|
+
},
|
|
50
|
+
|
|
51
|
+
/** Bootstrap the project */
|
|
52
|
+
async bootstrap(): Promise<void> {
|
|
53
|
+
log(`Boostrapping PlugJS Build from ${$p(resolve('@'))}`)
|
|
54
|
+
await this.bootstrap_resources()
|
|
55
|
+
await this.bootstrap_package()
|
|
56
|
+
},
|
|
57
|
+
})
|
|
58
|
+
|
|
59
|
+
const overwrite = process.argv[2] === '--overwrite' ? 'overwrite' : 'skip'
|
|
60
|
+
invoke(tasks, 'bootstrap', { overwrite }).catch(log.error)
|
package/src/build.ts
ADDED
|
@@ -0,0 +1,276 @@
|
|
|
1
|
+
import '@plugjs/cov8'
|
|
2
|
+
import '@plugjs/eslint'
|
|
3
|
+
import '@plugjs/jasmine'
|
|
4
|
+
import '@plugjs/typescript'
|
|
5
|
+
import {
|
|
6
|
+
build,
|
|
7
|
+
find,
|
|
8
|
+
fixExtensions,
|
|
9
|
+
isDirectory,
|
|
10
|
+
log,
|
|
11
|
+
merge,
|
|
12
|
+
noop,
|
|
13
|
+
rmrf,
|
|
14
|
+
} from '@plugjs/plug'
|
|
15
|
+
|
|
16
|
+
import type { ESBuildOptions, Pipe } from '@plugjs/plug'
|
|
17
|
+
|
|
18
|
+
/** Shared ESBuild options */
|
|
19
|
+
const esbuildDefaults: ESBuildOptions = {
|
|
20
|
+
platform: 'node',
|
|
21
|
+
sourcemap: 'linked',
|
|
22
|
+
sourcesContent: false,
|
|
23
|
+
plugins: [ fixExtensions() ],
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/** Options for creating our shared build file */
|
|
27
|
+
export interface TasksOptions {
|
|
28
|
+
/* ======================================================================== *
|
|
29
|
+
* DIRECTORIES *
|
|
30
|
+
* ======================================================================== */
|
|
31
|
+
|
|
32
|
+
/** The directory for the original sources (default: `src`) */
|
|
33
|
+
sourceDir?: string,
|
|
34
|
+
/** The destination directory of the transpiled sources (default: `dist`) */
|
|
35
|
+
destDir?: string,
|
|
36
|
+
/** The directory for the test files (default: `test`) */
|
|
37
|
+
testDir?: string,
|
|
38
|
+
/** The directory for the coverage report (default: `coverage`) */
|
|
39
|
+
coverageDir?: string,
|
|
40
|
+
/** The directory for the coverage data (default: `.coverage-data`) */
|
|
41
|
+
coverageDataDir?: string,
|
|
42
|
+
/** A directory containing extra types to use while transpiling (default: `types`) */
|
|
43
|
+
extraTypesDir?: string,
|
|
44
|
+
|
|
45
|
+
/* ======================================================================== *
|
|
46
|
+
* OTHER OPTIONS *
|
|
47
|
+
* ======================================================================== */
|
|
48
|
+
|
|
49
|
+
/** A glob pattern matching all test files (default: `**∕*.test.ts`) */
|
|
50
|
+
testGlob?: string,
|
|
51
|
+
/** Whether to disable tests or not (defailt: `false`) */
|
|
52
|
+
disableTests?: boolean,
|
|
53
|
+
/** Whether to disable code coverage or not (defailt: `false`) */
|
|
54
|
+
disableCoverage?: boolean,
|
|
55
|
+
/** Whether to disable code linting or not (defailt: `false`) */
|
|
56
|
+
disableLint?: boolean,
|
|
57
|
+
|
|
58
|
+
/** Minimum overall coverage percentage (default: `100`) */
|
|
59
|
+
minimumCoverage?: number,
|
|
60
|
+
/** Minimum per-file coverage percentage (default: `100`) */
|
|
61
|
+
minimumFileCoverage?: number,
|
|
62
|
+
/** Optimal overall coverage percentage (default: _none_) */
|
|
63
|
+
optimalCoverage?: number,
|
|
64
|
+
/** Optimal per-file coverage percentage (default: _none_) */
|
|
65
|
+
optimalFileCoverage?: number,
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* ESBuild compilation options
|
|
69
|
+
*
|
|
70
|
+
* Default:
|
|
71
|
+
*
|
|
72
|
+
* ```
|
|
73
|
+
* {
|
|
74
|
+
* platform: 'node',
|
|
75
|
+
* sourcemap: 'linked',
|
|
76
|
+
* sourcesContent: false,
|
|
77
|
+
* plugins: [ fixExtensions() ],
|
|
78
|
+
* }
|
|
79
|
+
* ```
|
|
80
|
+
*/
|
|
81
|
+
esbuildOptions?: ESBuildOptions,
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
|
|
85
|
+
export function tasks(options: TasksOptions = {}) {
|
|
86
|
+
const {
|
|
87
|
+
sourceDir = 'src',
|
|
88
|
+
destDir = 'dist',
|
|
89
|
+
testDir = 'test',
|
|
90
|
+
coverageDir = 'coverage',
|
|
91
|
+
coverageDataDir = '.coverage-data',
|
|
92
|
+
extraTypesDir = 'types',
|
|
93
|
+
|
|
94
|
+
testGlob = '**/*.test.ts',
|
|
95
|
+
disableTests = false,
|
|
96
|
+
disableCoverage = false,
|
|
97
|
+
disableLint = false,
|
|
98
|
+
|
|
99
|
+
minimumCoverage = 100,
|
|
100
|
+
minimumFileCoverage = 100,
|
|
101
|
+
optimalCoverage = undefined,
|
|
102
|
+
optimalFileCoverage = undefined,
|
|
103
|
+
|
|
104
|
+
esbuildOptions = {},
|
|
105
|
+
} = options
|
|
106
|
+
|
|
107
|
+
// Merge esbuild defaults with specified options
|
|
108
|
+
const esbuildMergedOptions = Object.assign({}, esbuildDefaults, esbuildOptions)
|
|
109
|
+
|
|
110
|
+
return build({
|
|
111
|
+
/* ====================================================================== *
|
|
112
|
+
* SOURCES STRUCTURE *
|
|
113
|
+
* ====================================================================== */
|
|
114
|
+
|
|
115
|
+
/** Find all CommonJS source files (`*.cts`) */
|
|
116
|
+
find_sources_cts(): Pipe {
|
|
117
|
+
return find('**/*.(c)?ts', { directory: sourceDir, ignore: '**/*.d.ts' })
|
|
118
|
+
},
|
|
119
|
+
|
|
120
|
+
/** Find all EcmaScript Module source files (`*.mts`) */
|
|
121
|
+
find_sources_mts(): Pipe {
|
|
122
|
+
return find('**/*.(m)?ts', { directory: sourceDir, ignore: '**/*.d.ts' })
|
|
123
|
+
},
|
|
124
|
+
|
|
125
|
+
/** Find all typescript source files (`*.ts`, `*.mts` and `*.cts`) */
|
|
126
|
+
find_sources(): Pipe {
|
|
127
|
+
return merge([ this.find_sources_cts(), this.find_sources_mts() ])
|
|
128
|
+
},
|
|
129
|
+
|
|
130
|
+
/** Find all types definition files within sources */
|
|
131
|
+
find_types(): Pipe {
|
|
132
|
+
return find('**/*.d.ts', { directory: sourceDir })
|
|
133
|
+
},
|
|
134
|
+
|
|
135
|
+
/** Find all types definition files within sources */
|
|
136
|
+
find_extras(): Pipe {
|
|
137
|
+
if (! isDirectory(extraTypesDir)) return noop()
|
|
138
|
+
return find('**/*.d.ts', { directory: extraTypesDir })
|
|
139
|
+
},
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
/** Find all resource files (non-typescript files) within sources */
|
|
143
|
+
find_resources(): Pipe {
|
|
144
|
+
return find('**/*', { directory: sourceDir, ignore: '**/*.([mt])?ts' })
|
|
145
|
+
},
|
|
146
|
+
|
|
147
|
+
/** Find all test source files */
|
|
148
|
+
find_tests(): Pipe {
|
|
149
|
+
return find(testGlob, { directory: testDir, ignore: '**/*.d.ts' })
|
|
150
|
+
},
|
|
151
|
+
|
|
152
|
+
/* ====================================================================== *
|
|
153
|
+
* TRANSPILE *
|
|
154
|
+
* ====================================================================== */
|
|
155
|
+
|
|
156
|
+
/** Transpile to CJS */
|
|
157
|
+
transpile_cjs(): Pipe {
|
|
158
|
+
return this.find_sources_cts()
|
|
159
|
+
.esbuild({
|
|
160
|
+
...esbuildMergedOptions,
|
|
161
|
+
format: 'cjs',
|
|
162
|
+
outdir: destDir,
|
|
163
|
+
outExtension: { '.js': '.cjs' },
|
|
164
|
+
})
|
|
165
|
+
},
|
|
166
|
+
|
|
167
|
+
/** Transpile to ESM */
|
|
168
|
+
transpile_esm(): Pipe {
|
|
169
|
+
return this.find_sources_mts()
|
|
170
|
+
.esbuild({
|
|
171
|
+
...esbuildMergedOptions,
|
|
172
|
+
format: 'esm',
|
|
173
|
+
outdir: destDir,
|
|
174
|
+
outExtension: { '.js': '.mjs' },
|
|
175
|
+
})
|
|
176
|
+
},
|
|
177
|
+
|
|
178
|
+
/** Generate all .d.ts files */
|
|
179
|
+
transpile_types(): Pipe {
|
|
180
|
+
return merge([
|
|
181
|
+
this.find_sources(),
|
|
182
|
+
this.find_types(),
|
|
183
|
+
this.find_extras(),
|
|
184
|
+
]).tsc('tsconfig.json', {
|
|
185
|
+
noEmit: false,
|
|
186
|
+
rootDir: sourceDir,
|
|
187
|
+
declaration: true,
|
|
188
|
+
emitDeclarationOnly: true,
|
|
189
|
+
outDir: destDir,
|
|
190
|
+
})
|
|
191
|
+
},
|
|
192
|
+
|
|
193
|
+
/** Copy all resources coming alongside our sources */
|
|
194
|
+
transpile_resources(): Pipe {
|
|
195
|
+
return merge([
|
|
196
|
+
this.find_resources(),
|
|
197
|
+
this.find_types(),
|
|
198
|
+
]).copy(destDir)
|
|
199
|
+
},
|
|
200
|
+
|
|
201
|
+
/** Transpile all source code */
|
|
202
|
+
transpile(): Pipe {
|
|
203
|
+
return merge([
|
|
204
|
+
this.transpile_cjs(),
|
|
205
|
+
this.transpile_esm(),
|
|
206
|
+
this.transpile_types(),
|
|
207
|
+
this.transpile_resources(),
|
|
208
|
+
])
|
|
209
|
+
},
|
|
210
|
+
|
|
211
|
+
/* ====================================================================== *
|
|
212
|
+
* TEST, COVERAGE & LINTING *
|
|
213
|
+
* ====================================================================== */
|
|
214
|
+
|
|
215
|
+
/** Run test and emit coverage data */
|
|
216
|
+
async test(): Promise<void> {
|
|
217
|
+
if (disableTests) {
|
|
218
|
+
return void log.warn('Testing disabled')
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
if (isDirectory(coverageDataDir)) await rmrf(coverageDataDir)
|
|
222
|
+
|
|
223
|
+
await this
|
|
224
|
+
.find_tests()
|
|
225
|
+
.jasmine({ coverageDir: coverageDataDir })
|
|
226
|
+
},
|
|
227
|
+
|
|
228
|
+
/** Run tests (always) and generate a coverage report */
|
|
229
|
+
async coverage(): Promise<void> {
|
|
230
|
+
if (disableTests || disableCoverage) {
|
|
231
|
+
return void log.warn('Coverage disabled')
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
await this
|
|
235
|
+
.test()
|
|
236
|
+
.finally(() => this.find_sources()
|
|
237
|
+
.coverage(coverageDataDir, {
|
|
238
|
+
reportDir: coverageDir,
|
|
239
|
+
minimumCoverage,
|
|
240
|
+
minimumFileCoverage,
|
|
241
|
+
optimalCoverage,
|
|
242
|
+
optimalFileCoverage,
|
|
243
|
+
}))
|
|
244
|
+
},
|
|
245
|
+
|
|
246
|
+
/** Run test and emit coverage data */
|
|
247
|
+
async lint(): Promise<void> {
|
|
248
|
+
if (disableLint) {
|
|
249
|
+
return void log.warn('Linting disabled')
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
await merge([
|
|
253
|
+
this.find_sources(),
|
|
254
|
+
this.find_tests(),
|
|
255
|
+
this.find_types(),
|
|
256
|
+
this.find_extras(),
|
|
257
|
+
]).eslint()
|
|
258
|
+
},
|
|
259
|
+
|
|
260
|
+
/* ====================================================================== *
|
|
261
|
+
* DEFAULT: DO EVERYTHING *
|
|
262
|
+
* ====================================================================== */
|
|
263
|
+
|
|
264
|
+
/** Build everything */
|
|
265
|
+
async default(): Promise<void> {
|
|
266
|
+
if (isDirectory(destDir)) await rmrf(destDir)
|
|
267
|
+
|
|
268
|
+
await Promise.all([
|
|
269
|
+
this.test(),
|
|
270
|
+
this.coverage(),
|
|
271
|
+
this.lint(),
|
|
272
|
+
this.transpile(),
|
|
273
|
+
])
|
|
274
|
+
},
|
|
275
|
+
})
|
|
276
|
+
}
|