@zthun/janitor-build-config 19.0.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 ADDED
@@ -0,0 +1,20 @@
1
+ # MIT License
2
+
3
+ Copyright (c) 2024 Anthony Bonta
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
6
+ this software and associated documentation files (the "Software"), to deal in
7
+ the Software without restriction, including without limitation the rights to
8
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9
+ the Software, and to permit persons to whom the Software is furnished to do so,
10
+ subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,13 @@
1
+ # Janitor Build Config
2
+
3
+ This is a set of common configurations for vite and vitest to simplify
4
+ build configuration files.
5
+
6
+ ## Getting Started
7
+
8
+ ```sh
9
+ # NPM
10
+ npm install @zthun/janitor-build-config --save-dev
11
+ # Yarn
12
+ yarn add @zthun/janitor-build-config --dev
13
+ ```
@@ -0,0 +1 @@
1
+ export * from './typedoc-config-builder.mjs';
@@ -0,0 +1,142 @@
1
+ import { EntryPointStrategy, TypeDocOptions } from 'typedoc';
2
+ /**
3
+ * A builder for TypeDoc configurations.
4
+ */
5
+ export declare class ZTypedocConfigBuilder {
6
+ static readonly OutputDist = "./dist";
7
+ static readonly EntryPointIndex = "./src/index.ts";
8
+ private typedoc;
9
+ /**
10
+ * Sets the output directory for the documentation.
11
+ *
12
+ * @param path -
13
+ * The output directory path.
14
+ * @returns
15
+ * This object.
16
+ */
17
+ out(path: string): this;
18
+ /**
19
+ * Sets the output directory to "./dist".
20
+ *
21
+ * @returns
22
+ * This object.
23
+ */
24
+ dist: () => this;
25
+ /**
26
+ * Adds a list of entry point glob to the existing entry points.
27
+ *
28
+ * @param glob -
29
+ * The entry point glob pattern.
30
+ *
31
+ * @returns
32
+ * This object.
33
+ */
34
+ entry(glob: string | string): this;
35
+ /**
36
+ * Adds an entry point for './src/index.ts'.
37
+ *
38
+ * @returns
39
+ * This object.
40
+ */
41
+ index: () => this;
42
+ /**
43
+ * Sets the entry point strategy.
44
+ *
45
+ * See {@link https://typedoc.org/api/enums/EntryPointStrategy.html | EntryPointStrategy}
46
+ * for more details.
47
+ *
48
+ * @param strategy -
49
+ * The entry point strategy to use.
50
+ *
51
+ * @returns
52
+ * This object.
53
+ */
54
+ entryPointStrategy(strategy: EntryPointStrategy): this;
55
+ /**
56
+ * Sets the entry point strategy to "resolve".
57
+ *
58
+ * @returns
59
+ * This object.
60
+ */
61
+ resolve: () => this;
62
+ /**
63
+ * Sets the entry point strategy to "packages".
64
+ *
65
+ * @returns
66
+ * This object.
67
+ */
68
+ packages: () => this;
69
+ /**
70
+ * Sets the excludeNotDocumented flag.
71
+ *
72
+ * @returns
73
+ * This object.
74
+ */
75
+ excludeNotDocumented(): this;
76
+ /**
77
+ * Sets the categorizeByGroup flag.
78
+ *
79
+ * @returns
80
+ * This object.
81
+ */
82
+ categorizeByGroup(): this;
83
+ /**
84
+ * Sets the name of the project.
85
+ *
86
+ * @param name -
87
+ * The name of the project.
88
+ *
89
+ * @returns
90
+ * This object.
91
+ */
92
+ name(name: string): this;
93
+ /**
94
+ * Sets the favicon for the project.
95
+ *
96
+ * @param path -
97
+ * The path to the favicon file.
98
+ *
99
+ * @returns
100
+ * This object.
101
+ */
102
+ favicon(path: string): this;
103
+ /**
104
+ * Adds a single exclude glob to the existing excludes.
105
+ *
106
+ * @param glob -
107
+ * The exclude glob pattern.
108
+ *
109
+ * @returns
110
+ * This object.
111
+ */
112
+ exclude(glob: string | string[]): this;
113
+ /**
114
+ * Sets the typedoc configuration to be used for an individual project.
115
+ *
116
+ * An individual project typedoc does not output any documentation by itself,
117
+ * but is part of a larger project that does.
118
+ *
119
+ * @returns
120
+ * This object.
121
+ */
122
+ project(): this;
123
+ /**
124
+ * Sets the typedoc configuration to be used a web project that outputs
125
+ * final documentation for a monorepo of packages.
126
+ *
127
+ * Normally, your monorepo will have a single web or doc project that outputs
128
+ * the typescript for every package in the monorepo. Use this configuration
129
+ * for that project.
130
+ *
131
+ * @returns
132
+ * This object.
133
+ */
134
+ web(): this;
135
+ /**
136
+ * Builds the final typedoc configuration object.
137
+ *
138
+ * @returns
139
+ * The final typedoc configuration object.
140
+ */
141
+ build(): TypeDocOptions;
142
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,181 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
+
5
+ const lodashEs = require('lodash-es');
6
+
7
+ function _define_property(obj, key, value) {
8
+ if (key in obj) {
9
+ Object.defineProperty(obj, key, {
10
+ value: value,
11
+ enumerable: true,
12
+ configurable: true,
13
+ writable: true
14
+ });
15
+ } else {
16
+ obj[key] = value;
17
+ }
18
+ return obj;
19
+ }
20
+ /**
21
+ * A builder for TypeDoc configurations.
22
+ */ class ZTypedocConfigBuilder {
23
+ /**
24
+ * Sets the output directory for the documentation.
25
+ *
26
+ * @param path -
27
+ * The output directory path.
28
+ * @returns
29
+ * This object.
30
+ */ out(path) {
31
+ this.typedoc.out = path;
32
+ return this;
33
+ }
34
+ /**
35
+ * Adds a list of entry point glob to the existing entry points.
36
+ *
37
+ * @param glob -
38
+ * The entry point glob pattern.
39
+ *
40
+ * @returns
41
+ * This object.
42
+ */ entry(glob) {
43
+ const entry = this.typedoc.entryPoints || [];
44
+ this.typedoc.entryPoints = entry.concat(glob);
45
+ return this;
46
+ }
47
+ /**
48
+ * Sets the entry point strategy.
49
+ *
50
+ * See {@link https://typedoc.org/api/enums/EntryPointStrategy.html | EntryPointStrategy}
51
+ * for more details.
52
+ *
53
+ * @param strategy -
54
+ * The entry point strategy to use.
55
+ *
56
+ * @returns
57
+ * This object.
58
+ */ entryPointStrategy(strategy) {
59
+ this.typedoc.entryPointStrategy = strategy;
60
+ return this;
61
+ }
62
+ /**
63
+ * Sets the excludeNotDocumented flag.
64
+ *
65
+ * @returns
66
+ * This object.
67
+ */ excludeNotDocumented() {
68
+ this.typedoc.excludeNotDocumented = true;
69
+ return this;
70
+ }
71
+ /**
72
+ * Sets the categorizeByGroup flag.
73
+ *
74
+ * @returns
75
+ * This object.
76
+ */ categorizeByGroup() {
77
+ this.typedoc.categorizeByGroup = true;
78
+ return this;
79
+ }
80
+ /**
81
+ * Sets the name of the project.
82
+ *
83
+ * @param name -
84
+ * The name of the project.
85
+ *
86
+ * @returns
87
+ * This object.
88
+ */ name(name) {
89
+ this.typedoc.name = name;
90
+ return this;
91
+ }
92
+ /**
93
+ * Sets the favicon for the project.
94
+ *
95
+ * @param path -
96
+ * The path to the favicon file.
97
+ *
98
+ * @returns
99
+ * This object.
100
+ */ favicon(path) {
101
+ this.typedoc.favicon = path;
102
+ return this;
103
+ }
104
+ /**
105
+ * Adds a single exclude glob to the existing excludes.
106
+ *
107
+ * @param glob -
108
+ * The exclude glob pattern.
109
+ *
110
+ * @returns
111
+ * This object.
112
+ */ exclude(glob) {
113
+ const excludes = this.typedoc.exclude || [];
114
+ this.typedoc.exclude = excludes.concat(glob);
115
+ return this;
116
+ }
117
+ /**
118
+ * Sets the typedoc configuration to be used for an individual project.
119
+ *
120
+ * An individual project typedoc does not output any documentation by itself,
121
+ * but is part of a larger project that does.
122
+ *
123
+ * @returns
124
+ * This object.
125
+ */ project() {
126
+ return this.resolve().dist();
127
+ }
128
+ /**
129
+ * Sets the typedoc configuration to be used a web project that outputs
130
+ * final documentation for a monorepo of packages.
131
+ *
132
+ * Normally, your monorepo will have a single web or doc project that outputs
133
+ * the typescript for every package in the monorepo. Use this configuration
134
+ * for that project.
135
+ *
136
+ * @returns
137
+ * This object.
138
+ */ web() {
139
+ return this.packages().excludeNotDocumented().categorizeByGroup().dist().exclude("./");
140
+ }
141
+ /**
142
+ * Builds the final typedoc configuration object.
143
+ *
144
+ * @returns
145
+ * The final typedoc configuration object.
146
+ */ build() {
147
+ return lodashEs.cloneDeep(this.typedoc);
148
+ }
149
+ constructor(){
150
+ _define_property(this, "typedoc", {});
151
+ /**
152
+ * Sets the output directory to "./dist".
153
+ *
154
+ * @returns
155
+ * This object.
156
+ */ _define_property(this, "dist", this.out.bind(this, ZTypedocConfigBuilder.OutputDist));
157
+ /**
158
+ * Adds an entry point for './src/index.ts'.
159
+ *
160
+ * @returns
161
+ * This object.
162
+ */ _define_property(this, "index", this.entry.bind(this, ZTypedocConfigBuilder.EntryPointIndex));
163
+ /**
164
+ * Sets the entry point strategy to "resolve".
165
+ *
166
+ * @returns
167
+ * This object.
168
+ */ _define_property(this, "resolve", this.entryPointStrategy.bind(this, "resolve"));
169
+ /**
170
+ * Sets the entry point strategy to "packages".
171
+ *
172
+ * @returns
173
+ * This object.
174
+ */ _define_property(this, "packages", this.entryPointStrategy.bind(this, "packages"));
175
+ }
176
+ }
177
+ _define_property(ZTypedocConfigBuilder, "OutputDist", "./dist");
178
+ _define_property(ZTypedocConfigBuilder, "EntryPointIndex", "./src/index.ts");
179
+
180
+ exports.ZTypedocConfigBuilder = ZTypedocConfigBuilder;
181
+ //# sourceMappingURL=typedoc.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"typedoc.cjs","sources":["../src/typedoc/typedoc-config-builder.mts"],"sourcesContent":["import { cloneDeep } from \"lodash-es\";\nimport { EntryPointStrategy, TypeDocOptions } from \"typedoc\";\n\n/**\n * A builder for TypeDoc configurations.\n */\nexport class ZTypedocConfigBuilder {\n public static readonly OutputDist = \"./dist\";\n public static readonly EntryPointIndex = \"./src/index.ts\";\n\n private typedoc: TypeDocOptions = {};\n\n /**\n * Sets the output directory for the documentation.\n *\n * @param path -\n * The output directory path.\n * @returns\n * This object.\n */\n public out(path: string) {\n this.typedoc.out = path;\n return this;\n }\n\n /**\n * Sets the output directory to \"./dist\".\n *\n * @returns\n * This object.\n */\n public dist = this.out.bind(this, ZTypedocConfigBuilder.OutputDist);\n\n /**\n * Adds a list of entry point glob to the existing entry points.\n *\n * @param glob -\n * The entry point glob pattern.\n *\n * @returns\n * This object.\n */\n public entry(glob: string | string) {\n const entry = this.typedoc.entryPoints || [];\n this.typedoc.entryPoints = entry.concat(glob);\n return this;\n }\n\n /**\n * Adds an entry point for './src/index.ts'.\n *\n * @returns\n * This object.\n */\n public index = this.entry.bind(this, ZTypedocConfigBuilder.EntryPointIndex);\n\n /**\n * Sets the entry point strategy.\n *\n * See {@link https://typedoc.org/api/enums/EntryPointStrategy.html | EntryPointStrategy}\n * for more details.\n *\n * @param strategy -\n * The entry point strategy to use.\n *\n * @returns\n * This object.\n */\n public entryPointStrategy(strategy: EntryPointStrategy) {\n this.typedoc.entryPointStrategy = strategy;\n return this;\n }\n\n /**\n * Sets the entry point strategy to \"resolve\".\n *\n * @returns\n * This object.\n */\n public resolve = this.entryPointStrategy.bind(this, \"resolve\");\n\n /**\n * Sets the entry point strategy to \"packages\".\n *\n * @returns\n * This object.\n */\n public packages = this.entryPointStrategy.bind(this, \"packages\");\n\n /**\n * Sets the excludeNotDocumented flag.\n *\n * @returns\n * This object.\n */\n public excludeNotDocumented() {\n this.typedoc.excludeNotDocumented = true;\n return this;\n }\n\n /**\n * Sets the categorizeByGroup flag.\n *\n * @returns\n * This object.\n */\n public categorizeByGroup() {\n this.typedoc.categorizeByGroup = true;\n return this;\n }\n\n /**\n * Sets the name of the project.\n *\n * @param name -\n * The name of the project.\n *\n * @returns\n * This object.\n */\n public name(name: string) {\n this.typedoc.name = name;\n return this;\n }\n\n /**\n * Sets the favicon for the project.\n *\n * @param path -\n * The path to the favicon file.\n *\n * @returns\n * This object.\n */\n public favicon(path: string) {\n this.typedoc.favicon = path;\n return this;\n }\n\n /**\n * Adds a single exclude glob to the existing excludes.\n *\n * @param glob -\n * The exclude glob pattern.\n *\n * @returns\n * This object.\n */\n public exclude(glob: string | string[]) {\n const excludes = this.typedoc.exclude || [];\n this.typedoc.exclude = excludes.concat(glob);\n return this;\n }\n\n /**\n * Sets the typedoc configuration to be used for an individual project.\n *\n * An individual project typedoc does not output any documentation by itself,\n * but is part of a larger project that does.\n *\n * @returns\n * This object.\n */\n public project() {\n return this.resolve().dist();\n }\n\n /**\n * Sets the typedoc configuration to be used a web project that outputs\n * final documentation for a monorepo of packages.\n *\n * Normally, your monorepo will have a single web or doc project that outputs\n * the typescript for every package in the monorepo. Use this configuration\n * for that project.\n *\n * @returns\n * This object.\n */\n public web() {\n return this.packages()\n .excludeNotDocumented()\n .categorizeByGroup()\n .dist()\n .exclude(\"./\");\n }\n\n /**\n * Builds the final typedoc configuration object.\n *\n * @returns\n * The final typedoc configuration object.\n */\n public build() {\n return cloneDeep(this.typedoc);\n }\n}\n"],"names":["ZTypedocConfigBuilder","out","path","typedoc","entry","glob","entryPoints","concat","entryPointStrategy","strategy","excludeNotDocumented","categorizeByGroup","name","favicon","exclude","excludes","resolve","dist","packages","cloneDeep","bind","OutputDist","index","EntryPointIndex"],"mappings":";;;;;;;;;;;;;;;;;;;AAGA;;AAEC,IACM,MAAMA,qBAAAA,CAAAA;AAMX;;;;;;;MAQOC,GAAIC,CAAAA,IAAY,EAAE;AACvB,QAAA,IAAI,CAACC,OAAO,CAACF,GAAG,GAAGC,IAAAA;AACnB,QAAA,OAAO,IAAI;AACb;AAUA;;;;;;;;MASOE,KAAMC,CAAAA,IAAqB,EAAE;AAClC,QAAA,MAAMD,QA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,EACjBR,CAAAA,oBAAoB,EACpBC,CAAAA,iBAAiB,EACjBM,CAAAA,IAAI,EACJH,CAAAA,OAAO,CAAC,IAAA,CAAA;AACb;AAEA;;;;;AAKC,MACD,KAAe,GAAA;QACb,OAAOK,kBAAAA,CAAU,IAAI,CAAChB,OAAO,CAAA;AAC/B;;AAxLA,QAAA,gBAAA,CAAA,IAAA,EAAQA,WAA0B,EAAC,CAAA;AAenC;;;;;MAMA,gBAAA,CAAA,IAAA,EAAOc,MAAO,EAAA,IAAI,CAAChB,GAAG,CAACmB,IAAI,CAAC,IAAI,EAAEpB,qBAAAA,CAAsBqB,UAAU,CAAA,CAAA;AAiBlE;;;;;MAMA,gBAAA,CAAA,IAAA,EAAOC,OAAQ,EAAA,IAAI,CAAClB,KAAK,CAACgB,IAAI,CAAC,IAAI,EAAEpB,qBAAAA,CAAsBuB,eAAe,CAAA,CAAA;AAmB1E;;;;;MAMA,gBAAA,CAAA,IAAA,EAAOP,WAAU,IAAI,CAACR,kBAAkB,CAACY,IAAI,CAAC,IAAI,EAAE,SAAA,CAAA,CAAA;AAEpD;;;;;MAMA,gBAAA,CAAA,IAAA,EAAOF,YAAW,IAAI,CAACV,kBAAkB,CAACY,IAAI,CAAC,IAAI,EAAE,UAAA,CAAA,CAAA;;AA4GvD;AA5LE,gBAAA,CADWpB,uBACYqB,YAAa,EAAA,QAAA,CAAA;AACpC,gBAAA,CAFWrB,uBAEYuB,iBAAkB,EAAA,gBAAA,CAAA;;;;"}
@@ -0,0 +1,177 @@
1
+ import { cloneDeep } from 'lodash-es';
2
+
3
+ function _define_property(obj, key, value) {
4
+ if (key in obj) {
5
+ Object.defineProperty(obj, key, {
6
+ value: value,
7
+ enumerable: true,
8
+ configurable: true,
9
+ writable: true
10
+ });
11
+ } else {
12
+ obj[key] = value;
13
+ }
14
+ return obj;
15
+ }
16
+ /**
17
+ * A builder for TypeDoc configurations.
18
+ */ class ZTypedocConfigBuilder {
19
+ /**
20
+ * Sets the output directory for the documentation.
21
+ *
22
+ * @param path -
23
+ * The output directory path.
24
+ * @returns
25
+ * This object.
26
+ */ out(path) {
27
+ this.typedoc.out = path;
28
+ return this;
29
+ }
30
+ /**
31
+ * Adds a list of entry point glob to the existing entry points.
32
+ *
33
+ * @param glob -
34
+ * The entry point glob pattern.
35
+ *
36
+ * @returns
37
+ * This object.
38
+ */ entry(glob) {
39
+ const entry = this.typedoc.entryPoints || [];
40
+ this.typedoc.entryPoints = entry.concat(glob);
41
+ return this;
42
+ }
43
+ /**
44
+ * Sets the entry point strategy.
45
+ *
46
+ * See {@link https://typedoc.org/api/enums/EntryPointStrategy.html | EntryPointStrategy}
47
+ * for more details.
48
+ *
49
+ * @param strategy -
50
+ * The entry point strategy to use.
51
+ *
52
+ * @returns
53
+ * This object.
54
+ */ entryPointStrategy(strategy) {
55
+ this.typedoc.entryPointStrategy = strategy;
56
+ return this;
57
+ }
58
+ /**
59
+ * Sets the excludeNotDocumented flag.
60
+ *
61
+ * @returns
62
+ * This object.
63
+ */ excludeNotDocumented() {
64
+ this.typedoc.excludeNotDocumented = true;
65
+ return this;
66
+ }
67
+ /**
68
+ * Sets the categorizeByGroup flag.
69
+ *
70
+ * @returns
71
+ * This object.
72
+ */ categorizeByGroup() {
73
+ this.typedoc.categorizeByGroup = true;
74
+ return this;
75
+ }
76
+ /**
77
+ * Sets the name of the project.
78
+ *
79
+ * @param name -
80
+ * The name of the project.
81
+ *
82
+ * @returns
83
+ * This object.
84
+ */ name(name) {
85
+ this.typedoc.name = name;
86
+ return this;
87
+ }
88
+ /**
89
+ * Sets the favicon for the project.
90
+ *
91
+ * @param path -
92
+ * The path to the favicon file.
93
+ *
94
+ * @returns
95
+ * This object.
96
+ */ favicon(path) {
97
+ this.typedoc.favicon = path;
98
+ return this;
99
+ }
100
+ /**
101
+ * Adds a single exclude glob to the existing excludes.
102
+ *
103
+ * @param glob -
104
+ * The exclude glob pattern.
105
+ *
106
+ * @returns
107
+ * This object.
108
+ */ exclude(glob) {
109
+ const excludes = this.typedoc.exclude || [];
110
+ this.typedoc.exclude = excludes.concat(glob);
111
+ return this;
112
+ }
113
+ /**
114
+ * Sets the typedoc configuration to be used for an individual project.
115
+ *
116
+ * An individual project typedoc does not output any documentation by itself,
117
+ * but is part of a larger project that does.
118
+ *
119
+ * @returns
120
+ * This object.
121
+ */ project() {
122
+ return this.resolve().dist();
123
+ }
124
+ /**
125
+ * Sets the typedoc configuration to be used a web project that outputs
126
+ * final documentation for a monorepo of packages.
127
+ *
128
+ * Normally, your monorepo will have a single web or doc project that outputs
129
+ * the typescript for every package in the monorepo. Use this configuration
130
+ * for that project.
131
+ *
132
+ * @returns
133
+ * This object.
134
+ */ web() {
135
+ return this.packages().excludeNotDocumented().categorizeByGroup().dist().exclude("./");
136
+ }
137
+ /**
138
+ * Builds the final typedoc configuration object.
139
+ *
140
+ * @returns
141
+ * The final typedoc configuration object.
142
+ */ build() {
143
+ return cloneDeep(this.typedoc);
144
+ }
145
+ constructor(){
146
+ _define_property(this, "typedoc", {});
147
+ /**
148
+ * Sets the output directory to "./dist".
149
+ *
150
+ * @returns
151
+ * This object.
152
+ */ _define_property(this, "dist", this.out.bind(this, ZTypedocConfigBuilder.OutputDist));
153
+ /**
154
+ * Adds an entry point for './src/index.ts'.
155
+ *
156
+ * @returns
157
+ * This object.
158
+ */ _define_property(this, "index", this.entry.bind(this, ZTypedocConfigBuilder.EntryPointIndex));
159
+ /**
160
+ * Sets the entry point strategy to "resolve".
161
+ *
162
+ * @returns
163
+ * This object.
164
+ */ _define_property(this, "resolve", this.entryPointStrategy.bind(this, "resolve"));
165
+ /**
166
+ * Sets the entry point strategy to "packages".
167
+ *
168
+ * @returns
169
+ * This object.
170
+ */ _define_property(this, "packages", this.entryPointStrategy.bind(this, "packages"));
171
+ }
172
+ }
173
+ _define_property(ZTypedocConfigBuilder, "OutputDist", "./dist");
174
+ _define_property(ZTypedocConfigBuilder, "EntryPointIndex", "./src/index.ts");
175
+
176
+ export { ZTypedocConfigBuilder };
177
+ //# sourceMappingURL=typedoc.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"typedoc.js","sources":["../src/typedoc/typedoc-config-builder.mts"],"sourcesContent":["import { cloneDeep } from \"lodash-es\";\nimport { EntryPointStrategy, TypeDocOptions } from \"typedoc\";\n\n/**\n * A builder for TypeDoc configurations.\n */\nexport class ZTypedocConfigBuilder {\n public static readonly OutputDist = \"./dist\";\n public static readonly EntryPointIndex = \"./src/index.ts\";\n\n private typedoc: TypeDocOptions = {};\n\n /**\n * Sets the output directory for the documentation.\n *\n * @param path -\n * The output directory path.\n * @returns\n * This object.\n */\n public out(path: string) {\n this.typedoc.out = path;\n return this;\n }\n\n /**\n * Sets the output directory to \"./dist\".\n *\n * @returns\n * This object.\n */\n public dist = this.out.bind(this, ZTypedocConfigBuilder.OutputDist);\n\n /**\n * Adds a list of entry point glob to the existing entry points.\n *\n * @param glob -\n * The entry point glob pattern.\n *\n * @returns\n * This object.\n */\n public entry(glob: string | string) {\n const entry = this.typedoc.entryPoints || [];\n this.typedoc.entryPoints = entry.concat(glob);\n return this;\n }\n\n /**\n * Adds an entry point for './src/index.ts'.\n *\n * @returns\n * This object.\n */\n public index = this.entry.bind(this, ZTypedocConfigBuilder.EntryPointIndex);\n\n /**\n * Sets the entry point strategy.\n *\n * See {@link https://typedoc.org/api/enums/EntryPointStrategy.html | EntryPointStrategy}\n * for more details.\n *\n * @param strategy -\n * The entry point strategy to use.\n *\n * @returns\n * This object.\n */\n public entryPointStrategy(strategy: EntryPointStrategy) {\n this.typedoc.entryPointStrategy = strategy;\n return this;\n }\n\n /**\n * Sets the entry point strategy to \"resolve\".\n *\n * @returns\n * This object.\n */\n public resolve = this.entryPointStrategy.bind(this, \"resolve\");\n\n /**\n * Sets the entry point strategy to \"packages\".\n *\n * @returns\n * This object.\n */\n public packages = this.entryPointStrategy.bind(this, \"packages\");\n\n /**\n * Sets the excludeNotDocumented flag.\n *\n * @returns\n * This object.\n */\n public excludeNotDocumented() {\n this.typedoc.excludeNotDocumented = true;\n return this;\n }\n\n /**\n * Sets the categorizeByGroup flag.\n *\n * @returns\n * This object.\n */\n public categorizeByGroup() {\n this.typedoc.categorizeByGroup = true;\n return this;\n }\n\n /**\n * Sets the name of the project.\n *\n * @param name -\n * The name of the project.\n *\n * @returns\n * This object.\n */\n public name(name: string) {\n this.typedoc.name = name;\n return this;\n }\n\n /**\n * Sets the favicon for the project.\n *\n * @param path -\n * The path to the favicon file.\n *\n * @returns\n * This object.\n */\n public favicon(path: string) {\n this.typedoc.favicon = path;\n return this;\n }\n\n /**\n * Adds a single exclude glob to the existing excludes.\n *\n * @param glob -\n * The exclude glob pattern.\n *\n * @returns\n * This object.\n */\n public exclude(glob: string | string[]) {\n const excludes = this.typedoc.exclude || [];\n this.typedoc.exclude = excludes.concat(glob);\n return this;\n }\n\n /**\n * Sets the typedoc configuration to be used for an individual project.\n *\n * An individual project typedoc does not output any documentation by itself,\n * but is part of a larger project that does.\n *\n * @returns\n * This object.\n */\n public project() {\n return this.resolve().dist();\n }\n\n /**\n * Sets the typedoc configuration to be used a web project that outputs\n * final documentation for a monorepo of packages.\n *\n * Normally, your monorepo will have a single web or doc project that outputs\n * the typescript for every package in the monorepo. Use this configuration\n * for that project.\n *\n * @returns\n * This object.\n */\n public web() {\n return this.packages()\n .excludeNotDocumented()\n .categorizeByGroup()\n .dist()\n .exclude(\"./\");\n }\n\n /**\n * Builds the final typedoc configuration object.\n *\n * @returns\n * The final typedoc configuration object.\n */\n public build() {\n return cloneDeep(this.typedoc);\n }\n}\n"],"names":["ZTypedocConfigBuilder","out","path","typedoc","entry","glob","entryPoints","concat","entryPointStrategy","strategy","excludeNotDocumented","categorizeByGroup","name","favicon","exclude","excludes","resolve","dist","packages","cloneDeep","bind","OutputDist","index","EntryPointIndex"],"mappings":";;;;;;;;;;;;;;;AAGA;;AAEC,IACM,MAAMA,qBAAAA,CAAAA;AAMX;;;;;;;MAQOC,GAAIC,CAAAA,IAAY,EAAE;AACvB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D,OAAiB,GAAA;AACf,QAAA,OAAO,IAAI,CAACW,OAAO,EAAA,CAAGC,IAAI,EAAA;AAC5B;AAEA;;;;;;;;;;AAUC,MACD,GAAa,GAAA;QACX,OAAO,IAAI,CAACC,QAAQ,EACjBR,CAAAA,oBAAoB,EACpBC,CAAAA,iBAAiB,EACjBM,CAAAA,IAAI,EACJH,CAAAA,OAAO,CAAC,IAAA,CAAA;AACb;AAEA;;;;;AAKC,MACD,KAAe,GAAA;QACb,OAAOK,SAAAA,CAAU,IAAI,CAAChB,OAAO,CAAA;AAC/B;;AAxLA,QAAA,gBAAA,CAAA,IAAA,EAAQA,WAA0B,EAAC,CAAA;AAenC;;;;;MAMA,gBAAA,CAAA,IAAA,EAAOc,MAAO,EAAA,IAAI,CAAChB,GAAG,CAACmB,IAAI,CAAC,IAAI,EAAEpB,qBAAAA,CAAsBqB,UAAU,CAAA,CAAA;AAiBlE;;;;;MAMA,gBAAA,CAAA,IAAA,EAAOC,OAAQ,EAAA,IAAI,CAAClB,KAAK,CAACgB,IAAI,CAAC,IAAI,EAAEpB,qBAAAA,CAAsBuB,eAAe,CAAA,CAAA;AAmB1E;;;;;MAMA,gBAAA,CAAA,IAAA,EAAOP,WAAU,IAAI,CAACR,kBAAkB,CAACY,IAAI,CAAC,IAAI,EAAE,SAAA,CAAA,CAAA;AAEpD;;;;;MAMA,gBAAA,CAAA,IAAA,EAAOF,YAAW,IAAI,CAACV,kBAAkB,CAACY,IAAI,CAAC,IAAI,EAAE,UAAA,CAAA,CAAA;;AA4GvD;AA5LE,gBAAA,CADWpB,uBACYqB,YAAa,EAAA,QAAA,CAAA;AACpC,gBAAA,CAFWrB,uBAEYuB,iBAAkB,EAAA,gBAAA,CAAA;;;;"}
@@ -0,0 +1,3 @@
1
+ export * from './vite-config-builder.mjs';
2
+ export * from './vite-library-builder.mjs';
3
+ export * from './vite-test-builder.mjs';
@@ -0,0 +1,92 @@
1
+ import { LibraryOptions, UserConfig } from 'vite';
2
+ import { InlineConfig as TestConfig } from 'vitest/node.js';
3
+ /**
4
+ * A config builder for the vite build system.
5
+ *
6
+ * This is helpful when building different types
7
+ * of projects and keeping a standard.
8
+ *
9
+ * @example vite.config.ts
10
+ *
11
+ * ```ts
12
+ * // Before Config Builder
13
+ * export default defineConfig({
14
+ * build: {
15
+ * lib: {
16
+ * entry: {
17
+ * index: "./src/index.ts",
18
+ * },
19
+ * formats: ["cjs", "es"],
20
+ * },
21
+ * },
22
+ * minify: false,
23
+ * sourceMap: true,
24
+ * plugins: [
25
+ * swc.vite(),
26
+ * tsConfigPaths(),
27
+ * externalizeDeps(),
28
+ * dtsPlugin({
29
+ * compilerOptions: {
30
+ * paths: {},
31
+ * },
32
+ * }),
33
+ * ],
34
+ * });
35
+ * ```
36
+ *
37
+ * ```ts
38
+ * // After config builder
39
+ * const config = new ZViteConfigBuilder().library().build();
40
+ * export default defineConfig(config);
41
+ * ```
42
+ */
43
+ export declare class ZViteConfigBuilder {
44
+ private _dirname;
45
+ private config;
46
+ /**
47
+ * Initializes a new instance of this object.
48
+ *
49
+ * @param _dirname -
50
+ * The directory that is housing the vite.config
51
+ * file. Pass __dirname to this.
52
+ */
53
+ constructor(_dirname: string);
54
+ /**
55
+ * Sets vite into library mode.
56
+ *
57
+ * @param options -
58
+ * The options for the library. You can set this to
59
+ * nothing to use the default library which looks for
60
+ * an entry point at the source directory called index.ts
61
+ *
62
+ * @see {@link ZViteLibraryBuilder} for more information.
63
+ *
64
+ * @returns
65
+ * This object.
66
+ */
67
+ library(options?: LibraryOptions): this;
68
+ /**
69
+ * Constructs the config to act as if it's compiling a node application.
70
+ *
71
+ * This is just an alias to {@link ZViteConfigBuilder.library} with two
72
+ * entry points.
73
+ *
74
+ * 1. The file src/cli.ts is the main entry point of the application.
75
+ * 1. The file, src/index.ts, is the api for importing
76
+ *
77
+ * @returns
78
+ * This object.
79
+ */
80
+ cli(): this;
81
+ /**
82
+ * Constructs the config to be for testing.
83
+ */
84
+ test(options?: TestConfig): this;
85
+ /**
86
+ * Returns the currently built config.
87
+ *
88
+ * @returns
89
+ * The currently built config.
90
+ */
91
+ build(): UserConfig;
92
+ }
@@ -0,0 +1 @@
1
+ export {};