chayns-toolkit 3.0.13 → 3.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.
@@ -0,0 +1,28 @@
1
+ import type { StepParams } from "../util/runSteps";
2
+ declare type TestOptions = {
3
+ watch: boolean;
4
+ setupFile: string;
5
+ };
6
+ declare type BabelPresetOptions = {
7
+ typescriptSupport: boolean;
8
+ flowSupport: boolean;
9
+ transpileModules: string | boolean;
10
+ reactRefreshSupport: boolean;
11
+ };
12
+ declare type BabelTransformOptions = {
13
+ presets: Array<string | BabelPresetOptions>;
14
+ };
15
+ export declare type JestConfig = Partial<{
16
+ transform: {
17
+ [glob: string]: [string, BabelTransformOptions] | string;
18
+ };
19
+ moduleFileExtensions: string[];
20
+ testPathIgnorePatterns: string[];
21
+ setupFilesAfterEnv: string[];
22
+ moduleNameMapper: {
23
+ [glob: string]: string;
24
+ };
25
+ testEnvironment: "jsdom" | "node";
26
+ }>;
27
+ export declare function testCommand({ watch, setupFile, }: TestOptions): (stepParams: StepParams) => Promise<void>;
28
+ export {};
@@ -0,0 +1,65 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.testCommand = void 0;
7
+ const fs_1 = __importDefault(require("fs"));
8
+ const jest_1 = require("jest");
9
+ const path_1 = __importDefault(require("path"));
10
+ const output_1 = require("../util/output");
11
+ const project_1 = require("../util/project");
12
+ function testCommand({ watch, setupFile, }) {
13
+ return async ({ config }) => {
14
+ let jestConfig = {
15
+ transform: {
16
+ "\\.[jt]sx?$": [
17
+ "babel-jest",
18
+ {
19
+ presets: ["@babel/preset-react", "@babel/preset-env"],
20
+ },
21
+ ],
22
+ },
23
+ moduleFileExtensions: ["ts", "tsx", "js", "jsx"],
24
+ moduleNameMapper: {
25
+ "^.+\\.(css|less|scss)$": "babel-jest",
26
+ "\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$": path_1.default.resolve(__dirname, "assets", "file-mock.js"),
27
+ },
28
+ testPathIgnorePatterns: ["^.+\\.eslintrc\\.js$"],
29
+ setupFilesAfterEnv: [
30
+ path_1.default.resolve(__dirname, "assets", "react-testing-library.setup.js"),
31
+ ],
32
+ testEnvironment: "jsdom",
33
+ };
34
+ if (typeof config.jest === "function") {
35
+ const modifier = config.jest;
36
+ jestConfig = modifier(jestConfig);
37
+ }
38
+ if (setupFile) {
39
+ const setupFilePath = project_1.project.resolvePath(setupFile);
40
+ const warningText = `The specified setup file for the tests (${setupFilePath}) could not be found.`;
41
+ try {
42
+ if (fs_1.default.existsSync(setupFilePath)) {
43
+ if (jestConfig.setupFilesAfterEnv) {
44
+ jestConfig.setupFilesAfterEnv.push(setupFilePath);
45
+ }
46
+ }
47
+ else {
48
+ output_1.output.warn(warningText);
49
+ }
50
+ }
51
+ catch (ex) {
52
+ output_1.output.warn(warningText);
53
+ }
54
+ }
55
+ const args = [];
56
+ args.push("--config", JSON.stringify(jestConfig));
57
+ if (watch) {
58
+ args.push("--watch");
59
+ }
60
+ // args.push('--json'); // json output could be used for custom formatting
61
+ await (0, jest_1.run)(args);
62
+ };
63
+ }
64
+ exports.testCommand = testCommand;
65
+ //# sourceMappingURL=testCommand.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"testCommand.js","sourceRoot":"","sources":["../../src/commands/testCommand.ts"],"names":[],"mappings":";;;;;;AAAA,4CAAmB;AACnB,+BAA0B;AAC1B,gDAAuB;AACvB,2CAAuC;AACvC,6CAAyC;AAgCzC,SAAgB,WAAW,CAAC,EAC3B,KAAK,EACL,SAAS,GACI;IACb,OAAO,KAAK,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE;QAC3B,IAAI,UAAU,GAAe;YAC5B,SAAS,EAAE;gBACV,aAAa,EAAE;oBACd,YAAY;oBACZ;wBACC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;YACV,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,CAAA;SACpB;QAED,0EAA0E;QAE1E,MAAM,IAAA,UAAG,EAAC,IAAI,CAAC,CAAA;IAChB,CAAC,CAAA;AACF,CAAC;AA5DD,kCA4DC"}
@@ -0,0 +1,401 @@
1
+ import { z } from "zod";
2
+ import type { RsbuildConfig } from "@rsbuild/core/dist-types/types/config";
3
+ export declare const configSchema: z.ZodObject<{
4
+ development: z.ZodDefault<z.ZodObject<{
5
+ host: z.ZodDefault<z.ZodString>;
6
+ port: z.ZodDefault<z.ZodNumber>;
7
+ ports: z.ZodDefault<z.ZodObject<{
8
+ client: z.ZodDefault<z.ZodNumber>;
9
+ server: z.ZodDefault<z.ZodNumber>;
10
+ }, "strip", z.ZodTypeAny, {
11
+ client: number;
12
+ server: number;
13
+ }, {
14
+ client?: number | undefined;
15
+ server?: number | undefined;
16
+ }>>;
17
+ cert: z.ZodOptional<z.ZodString>;
18
+ key: z.ZodOptional<z.ZodString>;
19
+ }, "strip", z.ZodTypeAny, {
20
+ host: string;
21
+ port: number;
22
+ ports: {
23
+ client: number;
24
+ server: number;
25
+ };
26
+ cert?: string | undefined;
27
+ key?: string | undefined;
28
+ }, {
29
+ host?: string | undefined;
30
+ port?: number | undefined;
31
+ ports?: {
32
+ client?: number | undefined;
33
+ server?: number | undefined;
34
+ } | undefined;
35
+ cert?: string | undefined;
36
+ key?: string | undefined;
37
+ }>>;
38
+ output: z.ZodDefault<z.ZodEffects<z.ZodObject<{
39
+ singleBundle: z.ZodDefault<z.ZodBoolean>;
40
+ filename: z.ZodOptional<z.ZodObject<{
41
+ html: z.ZodOptional<z.ZodString>;
42
+ js: z.ZodOptional<z.ZodString>;
43
+ css: z.ZodOptional<z.ZodString>;
44
+ svg: z.ZodOptional<z.ZodString>;
45
+ font: z.ZodOptional<z.ZodString>;
46
+ image: z.ZodOptional<z.ZodString>;
47
+ media: z.ZodOptional<z.ZodString>;
48
+ }, "strip", z.ZodTypeAny, {
49
+ html?: string | undefined;
50
+ js?: string | undefined;
51
+ css?: string | undefined;
52
+ svg?: string | undefined;
53
+ font?: string | undefined;
54
+ image?: string | undefined;
55
+ media?: string | undefined;
56
+ }, {
57
+ html?: string | undefined;
58
+ js?: string | undefined;
59
+ css?: string | undefined;
60
+ svg?: string | undefined;
61
+ font?: string | undefined;
62
+ image?: string | undefined;
63
+ media?: string | undefined;
64
+ }>>;
65
+ path: z.ZodDefault<z.ZodString>;
66
+ serverSideRendering: z.ZodDefault<z.ZodUnion<[z.ZodLiteral<"all">, z.ZodLiteral<"build-only">, z.ZodBoolean]>>;
67
+ prefixCss: z.ZodDefault<z.ZodBoolean>;
68
+ cssVersion: z.ZodDefault<z.ZodString>;
69
+ exposeModules: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
70
+ entryPoints: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
71
+ pathIndex: z.ZodString;
72
+ pathHtml: z.ZodString;
73
+ templateParameters: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
74
+ }, "strip", z.ZodTypeAny, {
75
+ pathIndex: string;
76
+ pathHtml: string;
77
+ templateParameters?: Record<string, string> | undefined;
78
+ }, {
79
+ pathIndex: string;
80
+ pathHtml: string;
81
+ templateParameters?: Record<string, string> | undefined;
82
+ }>>>;
83
+ }, "strip", z.ZodTypeAny, {
84
+ path: string;
85
+ singleBundle: boolean;
86
+ serverSideRendering: boolean | "all" | "build-only";
87
+ prefixCss: boolean;
88
+ cssVersion: string;
89
+ entryPoints: Record<string, {
90
+ pathIndex: string;
91
+ pathHtml: string;
92
+ templateParameters?: Record<string, string> | undefined;
93
+ }>;
94
+ filename?: {
95
+ html?: string | undefined;
96
+ js?: string | undefined;
97
+ css?: string | undefined;
98
+ svg?: string | undefined;
99
+ font?: string | undefined;
100
+ image?: string | undefined;
101
+ media?: string | undefined;
102
+ } | undefined;
103
+ exposeModules?: Record<string, string> | undefined;
104
+ }, {
105
+ path?: string | undefined;
106
+ singleBundle?: boolean | undefined;
107
+ filename?: {
108
+ html?: string | undefined;
109
+ js?: string | undefined;
110
+ css?: string | undefined;
111
+ svg?: string | undefined;
112
+ font?: string | undefined;
113
+ image?: string | undefined;
114
+ media?: string | undefined;
115
+ } | undefined;
116
+ serverSideRendering?: boolean | "all" | "build-only" | undefined;
117
+ prefixCss?: boolean | undefined;
118
+ cssVersion?: string | undefined;
119
+ exposeModules?: Record<string, string> | undefined;
120
+ entryPoints?: Record<string, {
121
+ pathIndex: string;
122
+ pathHtml: string;
123
+ templateParameters?: Record<string, string> | undefined;
124
+ }> | undefined;
125
+ }>, {
126
+ path: string;
127
+ singleBundle: boolean;
128
+ serverSideRendering: boolean | "all" | "build-only";
129
+ prefixCss: boolean;
130
+ cssVersion: string;
131
+ entryPoints: Record<string, {
132
+ pathIndex: string;
133
+ pathHtml: string;
134
+ templateParameters?: Record<string, string> | undefined;
135
+ }>;
136
+ filename?: {
137
+ html?: string | undefined;
138
+ js?: string | undefined;
139
+ css?: string | undefined;
140
+ svg?: string | undefined;
141
+ font?: string | undefined;
142
+ image?: string | undefined;
143
+ media?: string | undefined;
144
+ } | undefined;
145
+ exposeModules?: Record<string, string> | undefined;
146
+ }, {
147
+ path?: string | undefined;
148
+ singleBundle?: boolean | undefined;
149
+ filename?: {
150
+ html?: string | undefined;
151
+ js?: string | undefined;
152
+ css?: string | undefined;
153
+ svg?: string | undefined;
154
+ font?: string | undefined;
155
+ image?: string | undefined;
156
+ media?: string | undefined;
157
+ } | undefined;
158
+ serverSideRendering?: boolean | "all" | "build-only" | undefined;
159
+ prefixCss?: boolean | undefined;
160
+ cssVersion?: string | undefined;
161
+ exposeModules?: Record<string, string> | undefined;
162
+ entryPoints?: Record<string, {
163
+ pathIndex: string;
164
+ pathHtml: string;
165
+ templateParameters?: Record<string, string> | undefined;
166
+ }> | undefined;
167
+ }>>;
168
+ webpack: z.ZodOptional<z.ZodFunction<z.ZodTuple<[z.ZodType<RsbuildConfig, z.ZodTypeDef, RsbuildConfig>, z.ZodObject<{
169
+ dev: z.ZodBoolean;
170
+ target: z.ZodUnion<[z.ZodLiteral<"server">, z.ZodLiteral<"client">, z.ZodNull]>;
171
+ }, "strip", z.ZodTypeAny, {
172
+ dev: boolean;
173
+ target: "client" | "server" | null;
174
+ }, {
175
+ dev: boolean;
176
+ target: "client" | "server" | null;
177
+ }>], z.ZodUnknown>, z.ZodType<RsbuildConfig, z.ZodTypeDef, RsbuildConfig>>>;
178
+ jest: z.ZodOptional<z.ZodFunction<z.ZodTuple<[z.ZodType<Partial<{
179
+ transform: {
180
+ [glob: string]: string | [string, {
181
+ presets: (string | {
182
+ typescriptSupport: boolean;
183
+ flowSupport: boolean;
184
+ transpileModules: string | boolean;
185
+ reactRefreshSupport: boolean;
186
+ })[];
187
+ }];
188
+ };
189
+ moduleFileExtensions: string[];
190
+ testPathIgnorePatterns: string[];
191
+ setupFilesAfterEnv: string[];
192
+ moduleNameMapper: {
193
+ [glob: string]: string;
194
+ };
195
+ testEnvironment: "jsdom" | "node";
196
+ }>, z.ZodTypeDef, Partial<{
197
+ transform: {
198
+ [glob: string]: string | [string, {
199
+ presets: (string | {
200
+ typescriptSupport: boolean;
201
+ flowSupport: boolean;
202
+ transpileModules: string | boolean;
203
+ reactRefreshSupport: boolean;
204
+ })[];
205
+ }];
206
+ };
207
+ moduleFileExtensions: string[];
208
+ testPathIgnorePatterns: string[];
209
+ setupFilesAfterEnv: string[];
210
+ moduleNameMapper: {
211
+ [glob: string]: string;
212
+ };
213
+ testEnvironment: "jsdom" | "node";
214
+ }>>], z.ZodUnknown>, z.ZodType<Partial<{
215
+ transform: {
216
+ [glob: string]: string | [string, {
217
+ presets: (string | {
218
+ typescriptSupport: boolean;
219
+ flowSupport: boolean;
220
+ transpileModules: string | boolean;
221
+ reactRefreshSupport: boolean;
222
+ })[];
223
+ }];
224
+ };
225
+ moduleFileExtensions: string[];
226
+ testPathIgnorePatterns: string[];
227
+ setupFilesAfterEnv: string[];
228
+ moduleNameMapper: {
229
+ [glob: string]: string;
230
+ };
231
+ testEnvironment: "jsdom" | "node";
232
+ }>, z.ZodTypeDef, Partial<{
233
+ transform: {
234
+ [glob: string]: string | [string, {
235
+ presets: (string | {
236
+ typescriptSupport: boolean;
237
+ flowSupport: boolean;
238
+ transpileModules: string | boolean;
239
+ reactRefreshSupport: boolean;
240
+ })[];
241
+ }];
242
+ };
243
+ moduleFileExtensions: string[];
244
+ testPathIgnorePatterns: string[];
245
+ setupFilesAfterEnv: string[];
246
+ moduleNameMapper: {
247
+ [glob: string]: string;
248
+ };
249
+ testEnvironment: "jsdom" | "node";
250
+ }>>>>;
251
+ }, "strip", z.ZodTypeAny, {
252
+ development: {
253
+ host: string;
254
+ port: number;
255
+ ports: {
256
+ client: number;
257
+ server: number;
258
+ };
259
+ cert?: string | undefined;
260
+ key?: string | undefined;
261
+ };
262
+ output: {
263
+ path: string;
264
+ singleBundle: boolean;
265
+ serverSideRendering: boolean | "all" | "build-only";
266
+ prefixCss: boolean;
267
+ cssVersion: string;
268
+ entryPoints: Record<string, {
269
+ pathIndex: string;
270
+ pathHtml: string;
271
+ templateParameters?: Record<string, string> | undefined;
272
+ }>;
273
+ filename?: {
274
+ html?: string | undefined;
275
+ js?: string | undefined;
276
+ css?: string | undefined;
277
+ svg?: string | undefined;
278
+ font?: string | undefined;
279
+ image?: string | undefined;
280
+ media?: string | undefined;
281
+ } | undefined;
282
+ exposeModules?: Record<string, string> | undefined;
283
+ };
284
+ webpack?: ((args_0: RsbuildConfig, args_1: {
285
+ dev: boolean;
286
+ target: "client" | "server" | null;
287
+ }, ...args_2: unknown[]) => RsbuildConfig) | undefined;
288
+ jest?: ((args_0: Partial<{
289
+ transform: {
290
+ [glob: string]: string | [string, {
291
+ presets: (string | {
292
+ typescriptSupport: boolean;
293
+ flowSupport: boolean;
294
+ transpileModules: string | boolean;
295
+ reactRefreshSupport: boolean;
296
+ })[];
297
+ }];
298
+ };
299
+ moduleFileExtensions: string[];
300
+ testPathIgnorePatterns: string[];
301
+ setupFilesAfterEnv: string[];
302
+ moduleNameMapper: {
303
+ [glob: string]: string;
304
+ };
305
+ testEnvironment: "jsdom" | "node";
306
+ }>, ...args_1: unknown[]) => Partial<{
307
+ transform: {
308
+ [glob: string]: string | [string, {
309
+ presets: (string | {
310
+ typescriptSupport: boolean;
311
+ flowSupport: boolean;
312
+ transpileModules: string | boolean;
313
+ reactRefreshSupport: boolean;
314
+ })[];
315
+ }];
316
+ };
317
+ moduleFileExtensions: string[];
318
+ testPathIgnorePatterns: string[];
319
+ setupFilesAfterEnv: string[];
320
+ moduleNameMapper: {
321
+ [glob: string]: string;
322
+ };
323
+ testEnvironment: "jsdom" | "node";
324
+ }>) | undefined;
325
+ }, {
326
+ development?: {
327
+ host?: string | undefined;
328
+ port?: number | undefined;
329
+ ports?: {
330
+ client?: number | undefined;
331
+ server?: number | undefined;
332
+ } | undefined;
333
+ cert?: string | undefined;
334
+ key?: string | undefined;
335
+ } | undefined;
336
+ output?: {
337
+ path?: string | undefined;
338
+ singleBundle?: boolean | undefined;
339
+ filename?: {
340
+ html?: string | undefined;
341
+ js?: string | undefined;
342
+ css?: string | undefined;
343
+ svg?: string | undefined;
344
+ font?: string | undefined;
345
+ image?: string | undefined;
346
+ media?: string | undefined;
347
+ } | undefined;
348
+ serverSideRendering?: boolean | "all" | "build-only" | undefined;
349
+ prefixCss?: boolean | undefined;
350
+ cssVersion?: string | undefined;
351
+ exposeModules?: Record<string, string> | undefined;
352
+ entryPoints?: Record<string, {
353
+ pathIndex: string;
354
+ pathHtml: string;
355
+ templateParameters?: Record<string, string> | undefined;
356
+ }> | undefined;
357
+ } | undefined;
358
+ webpack?: ((args_0: RsbuildConfig, args_1: {
359
+ dev: boolean;
360
+ target: "client" | "server" | null;
361
+ }, ...args_2: unknown[]) => RsbuildConfig) | undefined;
362
+ jest?: ((args_0: Partial<{
363
+ transform: {
364
+ [glob: string]: string | [string, {
365
+ presets: (string | {
366
+ typescriptSupport: boolean;
367
+ flowSupport: boolean;
368
+ transpileModules: string | boolean;
369
+ reactRefreshSupport: boolean;
370
+ })[];
371
+ }];
372
+ };
373
+ moduleFileExtensions: string[];
374
+ testPathIgnorePatterns: string[];
375
+ setupFilesAfterEnv: string[];
376
+ moduleNameMapper: {
377
+ [glob: string]: string;
378
+ };
379
+ testEnvironment: "jsdom" | "node";
380
+ }>, ...args_1: unknown[]) => Partial<{
381
+ transform: {
382
+ [glob: string]: string | [string, {
383
+ presets: (string | {
384
+ typescriptSupport: boolean;
385
+ flowSupport: boolean;
386
+ transpileModules: string | boolean;
387
+ reactRefreshSupport: boolean;
388
+ })[];
389
+ }];
390
+ };
391
+ moduleFileExtensions: string[];
392
+ testPathIgnorePatterns: string[];
393
+ setupFilesAfterEnv: string[];
394
+ moduleNameMapper: {
395
+ [glob: string]: string;
396
+ };
397
+ testEnvironment: "jsdom" | "node";
398
+ }>) | undefined;
399
+ }>;
400
+ export declare type ToolkitConfig = z.input<typeof configSchema>;
401
+ export declare type ParsedToolkitConfig = z.output<typeof configSchema>;
@@ -0,0 +1,63 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.configSchema = void 0;
4
+ const zod_1 = require("zod");
5
+ const developmentSchema = zod_1.z.object({
6
+ host: zod_1.z.string().max(255).default("adaptive"),
7
+ port: zod_1.z.coerce.number().positive().max(65535).default(1234),
8
+ ports: zod_1.z
9
+ .object({
10
+ client: zod_1.z.coerce.number().positive().max(65535).default(1234),
11
+ server: zod_1.z.coerce.number().positive().max(65535).default(1235),
12
+ })
13
+ .default({}),
14
+ cert: zod_1.z.string().optional(),
15
+ key: zod_1.z.string().optional(),
16
+ });
17
+ const outputSchema = zod_1.z
18
+ .object({
19
+ singleBundle: zod_1.z.boolean().default(false),
20
+ filename: zod_1.z
21
+ .object({
22
+ html: zod_1.z.string().optional(),
23
+ js: zod_1.z.string().optional(),
24
+ css: zod_1.z.string().optional(),
25
+ svg: zod_1.z.string().optional(),
26
+ font: zod_1.z.string().optional(),
27
+ image: zod_1.z.string().optional(),
28
+ media: zod_1.z.string().optional(),
29
+ })
30
+ .optional(),
31
+ path: zod_1.z.string().default("build"),
32
+ serverSideRendering: zod_1.z
33
+ .union([zod_1.z.literal("all"), zod_1.z.literal("build-only"), zod_1.z.boolean()])
34
+ .default(false),
35
+ prefixCss: zod_1.z.boolean().default(false),
36
+ cssVersion: zod_1.z
37
+ .string()
38
+ .regex(/^\d+\.\d+$/)
39
+ .default("4.2"),
40
+ exposeModules: zod_1.z.record(zod_1.z.string(), zod_1.z.string()).optional(),
41
+ entryPoints: zod_1.z
42
+ .record(zod_1.z.string(), zod_1.z.object({
43
+ pathIndex: zod_1.z.string(),
44
+ pathHtml: zod_1.z.string(),
45
+ templateParameters: zod_1.z.record(zod_1.z.string(), zod_1.z.string()).optional(),
46
+ }))
47
+ .default({}),
48
+ })
49
+ .refine((data) => Object.keys(data.entryPoints).length || Object.keys(data.exposeModules ?? {}).length, "Need to define at least one key for either entryPoints or exposeModules");
50
+ exports.configSchema = zod_1.z.object({
51
+ development: developmentSchema.default({}),
52
+ output: outputSchema.default({}),
53
+ webpack: zod_1.z
54
+ .function()
55
+ .args(zod_1.z.custom(), zod_1.z.object({
56
+ dev: zod_1.z.boolean(),
57
+ target: zod_1.z.union([zod_1.z.literal("server"), zod_1.z.literal("client"), zod_1.z.null()]),
58
+ }))
59
+ .returns(zod_1.z.custom())
60
+ .optional(),
61
+ jest: zod_1.z.function().args(zod_1.z.custom()).returns(zod_1.z.custom()).optional(),
62
+ });
63
+ //# sourceMappingURL=configSchema.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"configSchema.js","sourceRoot":"","sources":["../../../src/features/config-file/configSchema.ts"],"names":[],"mappings":";;;AAAA,6BAAuB;AAIvB,MAAM,iBAAiB,GAAG,OAAC,CAAC,MAAM,CAAC;IAClC,IAAI,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,OA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ACpC,WAAW,EAAE,iBAAiB,CAAC,OAAO,CAAC,EAAE,CAAC;IAC1C,MAAM,EAAE,YAAY,CAAC,OAAO,CAAC,EAAE,CAAC;IAChC,OAAO,EAAE,OAAC;SACR,QAAQ,EAAE;SACV,IAAI,CACJ,OAAC,CAAC,MAAM,EAAiB,EACzB,OAAC,CAAC,MAAM,CAAC;QACR,GAAG,EAAE,OAAC,CAAC,OAAO,EAAE;QAChB,MAAM,EAAE,OAAC,CAAC,KAAK,CAAC,CAAC,OAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,OAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,OAAC,CAAC,IAAI,EAAE,CAAC,CAAC;KACrE,CAAC,CACF;SACA,OAAO,CAAC,OAAC,CAAC,MAAM,EAAiB,CAAC;SAClC,QAAQ,EAAE;IACZ,IAAI,EAAE,OAAC,CAAC,QAAQ,EAAE,CAAC,IAAI,CAAC,OAAC,CAAC,MAAM,EAAc,CAAC,CAAC,OAAO,CAAC,OAAC,CAAC,MAAM,EAAc,CAAC,CAAC,QAAQ,EAAE;CAC1F,CAAC,CAAA"}
@@ -0,0 +1,3 @@
1
+ import { ParsedToolkitConfig } from "./configSchema";
2
+ export declare function loadConfig(): Promise<ParsedToolkitConfig>;
3
+ export declare const JS_CONFIG_FILENAME = "toolkit.config.js";
@@ -0,0 +1,54 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
+ }) : (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ o[k2] = m[k];
8
+ }));
9
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
10
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
11
+ }) : function(o, v) {
12
+ o["default"] = v;
13
+ });
14
+ var __importStar = (this && this.__importStar) || function (mod) {
15
+ if (mod && mod.__esModule) return mod;
16
+ var result = {};
17
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18
+ __setModuleDefault(result, mod);
19
+ return result;
20
+ };
21
+ Object.defineProperty(exports, "__esModule", { value: true });
22
+ exports.JS_CONFIG_FILENAME = exports.loadConfig = void 0;
23
+ const zod_1 = require("zod");
24
+ const project_1 = require("../../util/project");
25
+ const configSchema_1 = require("./configSchema");
26
+ async function loadConfig() {
27
+ let config = {};
28
+ if (project_1.project.hasFile(exports.JS_CONFIG_FILENAME)) {
29
+ delete require.cache[project_1.project.resolvePath(exports.JS_CONFIG_FILENAME)];
30
+ config = (await Promise.resolve().then(() => __importStar(require(`file://${project_1.project.resolvePath(exports.JS_CONFIG_FILENAME)}?update=${Date.now()}`)))).default;
31
+ }
32
+ try {
33
+ const validatedValue = configSchema_1.configSchema.parse(config);
34
+ const { host, cert, key } = validatedValue.development;
35
+ if (host === "adaptive") {
36
+ const https = Boolean(cert && key);
37
+ validatedValue.development.host = https ? "0.0.0.0" : "localhost";
38
+ }
39
+ return validatedValue;
40
+ }
41
+ catch (error) {
42
+ if (error instanceof zod_1.ZodError) {
43
+ const errorMessage = error.errors
44
+ .map(({ path, message }) => `- ${path.join(".")}: ${message}\n`)
45
+ .join("");
46
+ throw new Error(errorMessage);
47
+ }
48
+ console.error(error);
49
+ throw error;
50
+ }
51
+ }
52
+ exports.loadConfig = loadConfig;
53
+ exports.JS_CONFIG_FILENAME = "toolkit.config.js";
54
+ //# sourceMappingURL=loadConfig.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"loadConfig.js","sourceRoot":"","sources":["../../../src/features/config-file/loadConfig.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA,6BAA8B;AAC9B,gDAA4C;AAC5C,iDAAiF;AAE1E,KAAK,UAAU,UAAU;IAC/B,IAAI,MAAM,GAAkB,EAAE,CAAA;IAE9B,IA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config-file/configSchema";
2
+ export { ToolkitConfig };
3
+ export declare const buildToolkitConfig: (config: ToolkitConfig) => ToolkitConfig;
package/lib/index.js ADDED
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.buildToolkitConfig = void 0;
4
+ const buildToolkitConfig = (config) => config;
5
+ exports.buildToolkitConfig = buildToolkitConfig;
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAGO,MAAM,kBAAkB,GAAG,CAAC,MAAqB,EAAiB,EAAE,CAAC,MAAM,CAAA;AAArE,QAAA,kBAAkB,sBAAmD"}
@@ -0,0 +1,9 @@
1
+ declare type TemplateStringsOrString = TemplateStringsArray | string;
2
+ export declare const fm: {
3
+ path(path: TemplateStringsOrString): string;
4
+ command(command: TemplateStringsOrString): string;
5
+ code(code: TemplateStringsOrString): string;
6
+ alt(text: TemplateStringsOrString): string;
7
+ number(number: string | number): string;
8
+ };
9
+ export {};