@storm-software/tsdown 0.24.10 → 0.24.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -21,7 +21,7 @@ This package is part of the <b>⚡Storm-Ops</b> monorepo. The Storm-Ops packages
21
21
 
22
22
  <h3 align="center">💻 Visit <a href="https://stormsoftware.com" target="_blank">stormsoftware.com</a> to stay up to date with this developer</h3><br />
23
23
 
24
- [![Version](https://img.shields.io/badge/version-0.24.9-1fb2a6.svg?style=for-the-badge&color=1fb2a6)](https://prettier.io/)&nbsp;[![Nx](https://img.shields.io/badge/Nx-17.0.2-lightgrey?style=for-the-badge&logo=nx&logoWidth=20&&color=1fb2a6)](http://nx.dev/)&nbsp;[![NextJs](https://img.shields.io/badge/Next.js-14.0.2-lightgrey?style=for-the-badge&logo=nextdotjs&logoWidth=20&color=1fb2a6)](https://nextjs.org/)&nbsp;[![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg?style=for-the-badge&logo=commitlint&color=1fb2a6)](http://commitizen.github.io/cz-cli/)&nbsp;![Semantic-Release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg?style=for-the-badge&color=1fb2a6)&nbsp;[![documented with Fumadocs](https://img.shields.io/badge/documented_with-fumadocs-success.svg?style=for-the-badge&logo=readthedocs&color=1fb2a6)](https://fumadocs.vercel.app/)&nbsp;![GitHub Workflow Status (with event)](https://img.shields.io/github/actions/workflow/status/storm-software/storm-ops/cr.yml?style=for-the-badge&logo=github-actions&color=1fb2a6)
24
+ [![Version](https://img.shields.io/badge/version-0.24.11-1fb2a6.svg?style=for-the-badge&color=1fb2a6)](https://prettier.io/)&nbsp;[![Nx](https://img.shields.io/badge/Nx-17.0.2-lightgrey?style=for-the-badge&logo=nx&logoWidth=20&&color=1fb2a6)](http://nx.dev/)&nbsp;[![NextJs](https://img.shields.io/badge/Next.js-14.0.2-lightgrey?style=for-the-badge&logo=nextdotjs&logoWidth=20&color=1fb2a6)](https://nextjs.org/)&nbsp;[![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg?style=for-the-badge&logo=commitlint&color=1fb2a6)](http://commitizen.github.io/cz-cli/)&nbsp;![Semantic-Release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg?style=for-the-badge&color=1fb2a6)&nbsp;[![documented with Fumadocs](https://img.shields.io/badge/documented_with-fumadocs-success.svg?style=for-the-badge&logo=readthedocs&color=1fb2a6)](https://fumadocs.vercel.app/)&nbsp;![GitHub Workflow Status (with event)](https://img.shields.io/github/actions/workflow/status/storm-software/storm-ops/cr.yml?style=for-the-badge&logo=github-actions&color=1fb2a6)
25
25
 
26
26
  <!-- prettier-ignore-start -->
27
27
  <!-- markdownlint-disable -->
package/bin/tsdown.cjs ADDED
@@ -0,0 +1,474 @@
1
+ #!/usr/bin/env node
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
18
+ // If the importer is in node compatibility mode or this is not an ESM
19
+ // file that has been converted to a CommonJS file using a Babel-
20
+ // compatible transform (i.e. "__esModule" has not been set), then set
21
+ // "default" to the CommonJS "module.exports" for node compatibility.
22
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
23
+ mod
24
+ ));
25
+
26
+ // bin/tsdown.ts
27
+ var import_get_config2 = require("@storm-software/config-tools/get-config");
28
+ var import_console3 = require("@storm-software/config-tools/logger/console");
29
+ var import_find_workspace_root2 = require("@storm-software/config-tools/utilities/find-workspace-root");
30
+ var import_process_handler = require("@storm-software/config-tools/utilities/process-handler");
31
+ var import_commander = require("commander");
32
+
33
+ // src/build.ts
34
+ var import_devkit = require("@nx/devkit");
35
+ var import_build_tools = require("@storm-software/build-tools");
36
+ var import_get_config = require("@storm-software/config-tools/get-config");
37
+ var import_console2 = require("@storm-software/config-tools/logger/console");
38
+ var import_get_log_level = require("@storm-software/config-tools/logger/get-log-level");
39
+ var import_correct_paths = require("@storm-software/config-tools/utilities/correct-paths");
40
+
41
+ // ../../node_modules/.pnpm/defu@6.1.4/node_modules/defu/dist/defu.mjs
42
+ function isPlainObject(value) {
43
+ if (value === null || typeof value !== "object") {
44
+ return false;
45
+ }
46
+ const prototype = Object.getPrototypeOf(value);
47
+ if (prototype !== null && prototype !== Object.prototype && Object.getPrototypeOf(prototype) !== null) {
48
+ return false;
49
+ }
50
+ if (Symbol.iterator in value) {
51
+ return false;
52
+ }
53
+ if (Symbol.toStringTag in value) {
54
+ return Object.prototype.toString.call(value) === "[object Module]";
55
+ }
56
+ return true;
57
+ }
58
+ __name(isPlainObject, "isPlainObject");
59
+ function _defu(baseObject, defaults, namespace = ".", merger) {
60
+ if (!isPlainObject(defaults)) {
61
+ return _defu(baseObject, {}, namespace, merger);
62
+ }
63
+ const object = Object.assign({}, defaults);
64
+ for (const key in baseObject) {
65
+ if (key === "__proto__" || key === "constructor") {
66
+ continue;
67
+ }
68
+ const value = baseObject[key];
69
+ if (value === null || value === void 0) {
70
+ continue;
71
+ }
72
+ if (merger && merger(object, key, value, namespace)) {
73
+ continue;
74
+ }
75
+ if (Array.isArray(value) && Array.isArray(object[key])) {
76
+ object[key] = [...value, ...object[key]];
77
+ } else if (isPlainObject(value) && isPlainObject(object[key])) {
78
+ object[key] = _defu(
79
+ value,
80
+ object[key],
81
+ (namespace ? `${namespace}.` : "") + key.toString(),
82
+ merger
83
+ );
84
+ } else {
85
+ object[key] = value;
86
+ }
87
+ }
88
+ return object;
89
+ }
90
+ __name(_defu, "_defu");
91
+ function createDefu(merger) {
92
+ return (...arguments_) => (
93
+ // eslint-disable-next-line unicorn/no-array-reduce
94
+ arguments_.reduce((p, c) => _defu(p, c, "", merger), {})
95
+ );
96
+ }
97
+ __name(createDefu, "createDefu");
98
+ var defu = createDefu();
99
+ var defuFn = createDefu((object, key, currentValue) => {
100
+ if (object[key] !== void 0 && typeof currentValue === "function") {
101
+ object[key] = currentValue(object[key]);
102
+ return true;
103
+ }
104
+ });
105
+ var defuArrayFn = createDefu((object, key, currentValue) => {
106
+ if (Array.isArray(object[key]) && typeof currentValue === "function") {
107
+ object[key] = currentValue(object[key]);
108
+ return true;
109
+ }
110
+ });
111
+
112
+ // src/build.ts
113
+ var import_node_fs = require("fs");
114
+ var import_promises2 = __toESM(require("fs/promises"), 1);
115
+ var import_find_workspace_root = require("nx/src/utils/find-workspace-root");
116
+ var import_tsdown = require("tsdown");
117
+
118
+ // src/clean.ts
119
+ var import_console = require("@storm-software/config-tools/logger/console");
120
+ var import_promises = require("fs/promises");
121
+ async function clean(name = "TSDown", directory, config) {
122
+ (0, import_console.writeDebug)(` \u{1F9F9} Cleaning ${name} output path: ${directory}`, config);
123
+ const stopwatch = (0, import_console.getStopwatch)(`${name} output clean`);
124
+ await cleanDirectories(name, directory, config);
125
+ stopwatch();
126
+ }
127
+ __name(clean, "clean");
128
+ async function cleanDirectories(name = "TSDown", directory, config) {
129
+ await (0, import_promises.rm)(directory, {
130
+ recursive: true,
131
+ force: true
132
+ });
133
+ }
134
+ __name(cleanDirectories, "cleanDirectories");
135
+
136
+ // src/config.ts
137
+ var DEFAULT_BUILD_OPTIONS = {
138
+ platform: "node",
139
+ target: "node22",
140
+ format: [
141
+ "esm",
142
+ "cjs"
143
+ ],
144
+ tsconfig: "tsconfig.json",
145
+ envName: "production",
146
+ globalName: "globalThis",
147
+ unused: {
148
+ level: "error"
149
+ },
150
+ injectShims: true,
151
+ watch: false,
152
+ bundle: true,
153
+ treeshake: true,
154
+ clean: true,
155
+ debug: false
156
+ };
157
+
158
+ // src/build.ts
159
+ var resolveOptions = /* @__PURE__ */ __name(async (userOptions) => {
160
+ const projectRoot = userOptions.projectRoot;
161
+ const workspaceRoot = (0, import_find_workspace_root.findWorkspaceRoot)(projectRoot);
162
+ if (!workspaceRoot) {
163
+ throw new Error("Cannot find Nx workspace root");
164
+ }
165
+ const config = await (0, import_get_config.getConfig)(workspaceRoot.dir);
166
+ (0, import_console2.writeDebug)(" \u2699\uFE0F Resolving build options", config);
167
+ const stopwatch = (0, import_console2.getStopwatch)("Build options resolution");
168
+ const projectGraph = await (0, import_devkit.createProjectGraphAsync)({
169
+ exitOnError: true
170
+ });
171
+ const projectJsonPath = (0, import_correct_paths.joinPaths)(workspaceRoot.dir, projectRoot, "project.json");
172
+ if (!(0, import_node_fs.existsSync)(projectJsonPath)) {
173
+ throw new Error("Cannot find project.json configuration");
174
+ }
175
+ const projectJsonFile = await import_promises2.default.readFile(projectJsonPath, "utf8");
176
+ const projectJson = JSON.parse(projectJsonFile);
177
+ const projectName = projectJson.name;
178
+ const projectConfigurations = (0, import_devkit.readProjectsConfigurationFromProjectGraph)(projectGraph);
179
+ if (!projectConfigurations?.projects?.[projectName]) {
180
+ throw new Error("The Build process failed because the project does not have a valid configuration in the project.json file. Check if the file exists in the root of the project.");
181
+ }
182
+ const options = defu(userOptions, DEFAULT_BUILD_OPTIONS);
183
+ options.name ??= `${projectName}-${options.format}`;
184
+ options.target ??= import_build_tools.DEFAULT_TARGET;
185
+ const packageJsonPath = (0, import_correct_paths.joinPaths)(workspaceRoot.dir, options.projectRoot, "package.json");
186
+ if (!(0, import_node_fs.existsSync)(packageJsonPath)) {
187
+ throw new Error("Cannot find package.json configuration");
188
+ }
189
+ const env = (0, import_build_tools.getEnv)("tsdown", options);
190
+ const result = {
191
+ ...options,
192
+ config,
193
+ ...userOptions,
194
+ tsconfig: (0, import_correct_paths.joinPaths)(projectRoot, userOptions.tsconfig ? userOptions.tsconfig.replace(projectRoot, "") : "tsconfig.json"),
195
+ format: options.format || "cjs",
196
+ entryPoints: await (0, import_build_tools.getEntryPoints)(config, projectRoot, projectJson.sourceRoot, userOptions.entry || [
197
+ "./src/index.ts"
198
+ ], userOptions.emitOnAll),
199
+ outdir: userOptions.outputPath || (0, import_correct_paths.joinPaths)("dist", projectRoot),
200
+ plugins: [],
201
+ name: userOptions.name || projectName,
202
+ projectConfigurations,
203
+ projectName,
204
+ projectGraph,
205
+ sourceRoot: userOptions.sourceRoot || projectJson.sourceRoot || (0, import_correct_paths.joinPaths)(projectRoot, "src"),
206
+ minify: userOptions.minify || !userOptions.debug,
207
+ verbose: userOptions.verbose || (0, import_get_log_level.isVerbose)() || userOptions.debug === true,
208
+ includeSrc: userOptions.includeSrc === true,
209
+ metafile: userOptions.metafile !== false,
210
+ generatePackageJson: userOptions.generatePackageJson !== false,
211
+ clean: userOptions.clean !== false,
212
+ emitOnAll: userOptions.emitOnAll === true,
213
+ dts: userOptions.emitTypes === true ? {
214
+ transformer: "oxc"
215
+ } : userOptions.emitTypes,
216
+ bundleDts: userOptions.emitTypes,
217
+ assets: userOptions.assets ?? [],
218
+ shims: userOptions.injectShims !== true,
219
+ bundle: userOptions.bundle !== false,
220
+ watch: userOptions.watch === true,
221
+ define: {
222
+ STORM_FORMAT: JSON.stringify(options.format || "cjs"),
223
+ ...options.format === "cjs" && options.injectShims ? {
224
+ "import.meta.url": "importMetaUrl"
225
+ } : {},
226
+ ...Object.keys(env || {}).reduce((res, key) => {
227
+ const value = JSON.stringify(env[key]);
228
+ return {
229
+ ...res,
230
+ [`process.env.${key}`]: value,
231
+ [`import.meta.env.${key}`]: value
232
+ };
233
+ }, {}),
234
+ ...options.define
235
+ }
236
+ };
237
+ stopwatch();
238
+ return result;
239
+ }, "resolveOptions");
240
+ async function generatePackageJson(options) {
241
+ if (options.generatePackageJson !== false && (0, import_node_fs.existsSync)((0, import_correct_paths.joinPaths)(options.projectRoot, "package.json"))) {
242
+ (0, import_console2.writeDebug)(" \u270D\uFE0F Writing package.json file", options.config);
243
+ const stopwatch = (0, import_console2.getStopwatch)("Write package.json file");
244
+ const packageJsonPath = (0, import_correct_paths.joinPaths)(options.projectRoot, "project.json");
245
+ if (!(0, import_node_fs.existsSync)(packageJsonPath)) {
246
+ throw new Error("Cannot find package.json configuration");
247
+ }
248
+ const packageJsonFile = await import_promises2.default.readFile((0, import_correct_paths.joinPaths)(options.config.workspaceRoot, options.projectRoot, "package.json"), "utf8");
249
+ if (!packageJsonFile) {
250
+ throw new Error("Cannot find package.json configuration file");
251
+ }
252
+ let packageJson = JSON.parse(packageJsonFile);
253
+ packageJson = await (0, import_build_tools.addPackageDependencies)(options.config.workspaceRoot, options.projectRoot, options.projectName, packageJson);
254
+ packageJson = await (0, import_build_tools.addWorkspacePackageJsonFields)(options.config, options.projectRoot, options.sourceRoot, options.projectName, false, packageJson);
255
+ packageJson.exports ??= {};
256
+ packageJson.exports["./package.json"] ??= "./package.json";
257
+ packageJson.exports["."] ??= (0, import_build_tools.addPackageJsonExport)("index", packageJson.type, options.sourceRoot);
258
+ let entryPoints = [
259
+ {
260
+ in: "./src/index.ts",
261
+ out: "./src/index.ts"
262
+ }
263
+ ];
264
+ if (options.entryPoints) {
265
+ if (Array.isArray(options.entryPoints)) {
266
+ entryPoints = options.entryPoints.map((entryPoint) => typeof entryPoint === "string" ? {
267
+ in: entryPoint,
268
+ out: entryPoint
269
+ } : entryPoint);
270
+ }
271
+ for (const entryPoint of entryPoints) {
272
+ const split = entryPoint.out.split(".");
273
+ split.pop();
274
+ const entry = split.join(".").replaceAll("\\", "/");
275
+ packageJson.exports[`./${entry}`] ??= (0, import_build_tools.addPackageJsonExport)(entry, packageJson.type, options.sourceRoot);
276
+ }
277
+ }
278
+ packageJson.main = packageJson.type === "commonjs" ? "./dist/index.js" : "./dist/index.cjs";
279
+ packageJson.module = packageJson.type === "module" ? "./dist/index.js" : "./dist/index.mjs";
280
+ packageJson.types = "./dist/index.d.ts";
281
+ packageJson.exports = Object.keys(packageJson.exports).reduce((ret, key) => {
282
+ if (key.endsWith("/index") && !ret[key.replace("/index", "")]) {
283
+ ret[key.replace("/index", "")] = packageJson.exports[key];
284
+ }
285
+ return ret;
286
+ }, packageJson.exports);
287
+ await (0, import_devkit.writeJsonFile)((0, import_correct_paths.joinPaths)(options.outdir, "package.json"), packageJson);
288
+ stopwatch();
289
+ }
290
+ return options;
291
+ }
292
+ __name(generatePackageJson, "generatePackageJson");
293
+ async function executeTSDown(options) {
294
+ (0, import_console2.writeDebug)(` \u{1F680} Running ${options.name} build`, options.config);
295
+ const stopwatch = (0, import_console2.getStopwatch)(`${options.name} build`);
296
+ await (0, import_tsdown.build)({
297
+ ...options,
298
+ entry: options.entryPoints,
299
+ outDir: options.outdir,
300
+ config: false
301
+ });
302
+ stopwatch();
303
+ return options;
304
+ }
305
+ __name(executeTSDown, "executeTSDown");
306
+ async function copyBuildAssets(options) {
307
+ (0, import_console2.writeDebug)(` \u{1F4CB} Copying asset files to output directory: ${options.outdir}`, options.config);
308
+ const stopwatch = (0, import_console2.getStopwatch)(`${options.name} asset copy`);
309
+ await (0, import_build_tools.copyAssets)(options.config, options.assets ?? [], options.outdir, options.projectRoot, options.sourceRoot, true, false);
310
+ stopwatch();
311
+ return options;
312
+ }
313
+ __name(copyBuildAssets, "copyBuildAssets");
314
+ async function reportResults(options) {
315
+ (0, import_console2.writeSuccess)(` \u{1F4E6} The ${options.name} build completed successfully`, options.config);
316
+ }
317
+ __name(reportResults, "reportResults");
318
+ async function cleanOutputPath(options) {
319
+ if (options.clean !== false && options.outdir) {
320
+ (0, import_console2.writeDebug)(` \u{1F9F9} Cleaning ${options.name} output path: ${options.outdir}`, options.config);
321
+ const stopwatch = (0, import_console2.getStopwatch)(`${options.name} output clean`);
322
+ await cleanDirectories(options.name, options.outdir, options.config);
323
+ stopwatch();
324
+ }
325
+ return options;
326
+ }
327
+ __name(cleanOutputPath, "cleanOutputPath");
328
+ async function build(options) {
329
+ (0, import_console2.writeDebug)(` \u26A1 Executing Storm TSDown pipeline`);
330
+ const stopwatch = (0, import_console2.getStopwatch)("TSDown pipeline");
331
+ try {
332
+ const opts = Array.isArray(options) ? options : [
333
+ options
334
+ ];
335
+ if (opts.length === 0) {
336
+ throw new Error("No build options were provided");
337
+ }
338
+ const resolved = await Promise.all(opts.map(async (opt) => await resolveOptions(opt)));
339
+ if (resolved.length > 0) {
340
+ await cleanOutputPath(resolved[0]);
341
+ await generatePackageJson(resolved[0]);
342
+ await Promise.all(resolved.map(async (opt) => {
343
+ await executeTSDown(opt);
344
+ await copyBuildAssets(opt);
345
+ await reportResults(opt);
346
+ }));
347
+ } else {
348
+ (0, import_console2.writeWarning)(" \u{1F6A7} No options were passed to TSBuild. Please check the parameters passed to the `build` function.");
349
+ }
350
+ (0, import_console2.writeSuccess)(" \u{1F3C1} TSDown pipeline build completed successfully");
351
+ } catch (error) {
352
+ (0, import_console2.writeFatal)(" \u274C Fatal errors occurred during the build that could not be recovered from. The build process has been terminated.");
353
+ throw error;
354
+ } finally {
355
+ stopwatch();
356
+ }
357
+ }
358
+ __name(build, "build");
359
+
360
+ // bin/tsdown.ts
361
+ async function createProgram(config) {
362
+ try {
363
+ (0, import_console3.writeInfo)("\u26A1 Running Storm TSDown pipeline", config);
364
+ const root = (0, import_find_workspace_root2.findWorkspaceRootSafe)();
365
+ process.env.STORM_WORKSPACE_ROOT ??= root;
366
+ process.env.NX_WORKSPACE_ROOT_PATH ??= root;
367
+ root && process.chdir(root);
368
+ const program = new import_commander.Command("storm-tsdown");
369
+ program.version("1.0.0", "-v --version", "display CLI version");
370
+ program.description("\u26A1 Run the Storm TSDown pipeline").showHelpAfterError().showSuggestionAfterError();
371
+ const projectRootOption = new import_commander.Option("-p --project-root <path>", "The path to the root of the project to build. This path is defined relative to the workspace root.").makeOptionMandatory(true);
372
+ const sourceRootOption = new import_commander.Option("-s --source-root <path>", "The path of the project's source folder to build");
373
+ const nameOption = new import_commander.Option("-n --name <value>", "The name of the project to build");
374
+ const outputPathOption = new import_commander.Option("-o --output-path <path>", "The path of the project's source folder to build").default("dist/{projectRoot}");
375
+ const platformOption = new import_commander.Option("-p --platform <value>", "The platform to build the distribution for").choices([
376
+ "node",
377
+ "neutral",
378
+ "browser"
379
+ ]).default("node");
380
+ const formatOption = new import_commander.Option("-f, --format <value...>", "The format to build the distribution in").choices([
381
+ "esm",
382
+ "cjs",
383
+ "iife"
384
+ ]).argParser((value, previous) => {
385
+ if (previous === void 0) {
386
+ return [
387
+ value
388
+ ];
389
+ } else if (!previous.includes(value)) {
390
+ previous.push(value);
391
+ }
392
+ return previous;
393
+ }).default("esm");
394
+ const cleanOption = new import_commander.Option("-c --clean", "Should the output directory be cleaned before building").default(true);
395
+ const noCleanOption = new import_commander.Option("--no-clean", "Should the output directory be cleaned before building").default(false);
396
+ const bundleOption = new import_commander.Option("-b --bundle", "Should the output be bundled").default(true);
397
+ const noBundleOption = new import_commander.Option("--no-bundle", "Should the output be bundled").default(false);
398
+ const targetOption = new import_commander.Option("-t --target <value>", "The target to build the distribution for").choices([
399
+ "ESNext",
400
+ "ES2015",
401
+ "ES2016",
402
+ "ES2017",
403
+ "ES2018",
404
+ "ES2019",
405
+ "ES2020",
406
+ "ES2021",
407
+ "ES2022",
408
+ "ES2023"
409
+ ]).default("ESNext");
410
+ const watchOption = new import_commander.Option("-w --watch", "Should the build process watch for changes").default(false);
411
+ const debugOption = new import_commander.Option("-d --debug", "Should the build process run in debug mode").default(false);
412
+ const bannerOption = new import_commander.Option("--banner <value>", "The banner to prepend to the output");
413
+ const footerOption = new import_commander.Option("--footer <value>", "The footer to prepend to the output");
414
+ const splittingOption = new import_commander.Option("--splitting", "Should the output be split into multiple files").default(true);
415
+ const treeShakingOption = new import_commander.Option("--tree-shaking", "Should tree shaking be enabled").default(true);
416
+ const generatePackageJsonOption = new import_commander.Option("--generate-package-json", "Should a package.json be generated for the output").default(true);
417
+ const emitOnAllOption = new import_commander.Option("--emit-on-all", "Should the output be emitted on all platforms").default(false);
418
+ const metafileOption = new import_commander.Option("--metafile", "Should a metafile be generated for the output").default(true);
419
+ const minifyOption = new import_commander.Option("--minify", "Should the output be minified").default(true);
420
+ const includeSrcOption = new import_commander.Option("--include-src", "Should the source files be included in the output").default(false);
421
+ const verboseOption = new import_commander.Option("--verbose", "Should the build process be verbose").default(false);
422
+ const injectShimsOption = new import_commander.Option("--inject-shims", "Should shims be injected into the output").default(true);
423
+ const emitTypesOption = new import_commander.Option("--emit-types", "Should types be emitted for the output").default(true);
424
+ program.command("build", {
425
+ isDefault: true
426
+ }).alias("bundle").description("Run a TypeScript build using TSDown, API-Extractor, and TSC (for type generation).").addOption(nameOption).addOption(projectRootOption).addOption(sourceRootOption).addOption(outputPathOption).addOption(platformOption).addOption(formatOption).addOption(targetOption).addOption(bundleOption).addOption(noBundleOption).addOption(cleanOption).addOption(noCleanOption).addOption(watchOption).addOption(debugOption).addOption(bannerOption).addOption(footerOption).addOption(splittingOption).addOption(treeShakingOption).addOption(generatePackageJsonOption).addOption(emitOnAllOption).addOption(metafileOption).addOption(minifyOption).addOption(includeSrcOption).addOption(verboseOption).addOption(injectShimsOption).addOption(emitTypesOption).action(buildAction(config));
427
+ program.command("clean").alias("clear").description("Clean the output directory of the project. This command will remove the 'dist' folder.").addOption(nameOption).action(cleanAction(config));
428
+ return program;
429
+ } catch (e) {
430
+ (0, import_console3.writeFatal)(`A fatal error occurred while running the program: ${e.message}`, config);
431
+ process.exit(1);
432
+ }
433
+ }
434
+ __name(createProgram, "createProgram");
435
+ var buildAction = /* @__PURE__ */ __name((config) => async (options) => {
436
+ try {
437
+ await build({
438
+ ...options,
439
+ format: options.format
440
+ });
441
+ } catch (e) {
442
+ (0, import_console3.writeFatal)(`A fatal error occurred while cleaning the TSDown output directory: ${e.message}`, config);
443
+ (0, import_process_handler.exitWithError)(config);
444
+ process.exit(1);
445
+ }
446
+ }, "buildAction");
447
+ var cleanAction = /* @__PURE__ */ __name((config) => async (options) => {
448
+ try {
449
+ await clean(options.name, options.output, config);
450
+ } catch (e) {
451
+ (0, import_console3.writeFatal)(`A fatal error occurred while cleaning the TSDown output directory: ${e.message}`, config);
452
+ (0, import_process_handler.exitWithError)(config);
453
+ process.exit(1);
454
+ }
455
+ }, "cleanAction");
456
+ void (async () => {
457
+ const config = await (0, import_get_config2.getConfig)();
458
+ const stopwatch = (0, import_console3.getStopwatch)("Storm TSDown executable");
459
+ try {
460
+ (0, import_process_handler.handleProcess)(config);
461
+ const program = await createProgram(config);
462
+ await program.parseAsync(process.argv);
463
+ (0, import_console3.writeSuccess)(`\u{1F389} Storm TSDown executable has completed successfully!`, config);
464
+ (0, import_process_handler.exitWithSuccess)(config);
465
+ } catch (error) {
466
+ (0, import_console3.writeFatal)(`A fatal error occurred while running Storm TSDown executable:
467
+
468
+ ${error.message}`, config);
469
+ (0, import_process_handler.exitWithError)(config);
470
+ process.exit(1);
471
+ } finally {
472
+ stopwatch();
473
+ }
474
+ })();
package/dist/build.cjs CHANGED
@@ -1,11 +1,11 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
2
 
3
3
 
4
- var _chunkESRFPDLRcjs = require('./chunk-ESRFPDLR.cjs');
5
- require('./chunk-IHU462CN.cjs');
4
+ var _chunk75765MSLcjs = require('./chunk-75765MSL.cjs');
5
+ require('./chunk-52NJUFUL.cjs');
6
6
  require('./chunk-5KRF6IVW.cjs');
7
7
  require('./chunk-USNT2KNT.cjs');
8
8
 
9
9
 
10
10
 
11
- exports.build = _chunkESRFPDLRcjs.build; exports.cleanOutputPath = _chunkESRFPDLRcjs.cleanOutputPath;
11
+ exports.build = _chunk75765MSLcjs.build; exports.cleanOutputPath = _chunk75765MSLcjs.cleanOutputPath;
package/dist/build.js CHANGED
@@ -1,8 +1,8 @@
1
1
  import {
2
2
  build,
3
3
  cleanOutputPath
4
- } from "./chunk-FG4EBMPW.js";
5
- import "./chunk-TXAM2HUM.js";
4
+ } from "./chunk-UR5MYUPB.js";
5
+ import "./chunk-KB6FL5TT.js";
6
6
  import "./chunk-UQLCBJOS.js";
7
7
  import "./chunk-SHUYVCID.js";
8
8
  export {
@@ -203,28 +203,131 @@ var _promises = require('fs/promises');
203
203
  var _path = require('path');
204
204
 
205
205
  // ../config-tools/src/utilities/correct-paths.ts
206
-
207
- var removeWindowsDriveLetter = /* @__PURE__ */ _chunkUSNT2KNTcjs.__name.call(void 0, (osSpecificPath) => {
208
- return osSpecificPath.replace(/^[A-Z]:/, "");
209
- }, "removeWindowsDriveLetter");
210
- var correctPaths = /* @__PURE__ */ _chunkUSNT2KNTcjs.__name.call(void 0, (path) => {
211
- if (!path) {
212
- return "";
206
+ var _DRIVE_LETTER_START_RE = /^[A-Za-z]:\//;
207
+ function normalizeWindowsPath(input = "") {
208
+ if (!input) {
209
+ return input;
210
+ }
211
+ return input.replace(/\\/g, "/").replace(_DRIVE_LETTER_START_RE, (r) => r.toUpperCase());
212
+ }
213
+ _chunkUSNT2KNTcjs.__name.call(void 0, normalizeWindowsPath, "normalizeWindowsPath");
214
+ var _UNC_REGEX = /^[/\\]{2}/;
215
+ var _IS_ABSOLUTE_RE = /^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Za-z]:[/\\]/;
216
+ var _DRIVE_LETTER_RE = /^[A-Za-z]:$/;
217
+ var correctPaths = /* @__PURE__ */ _chunkUSNT2KNTcjs.__name.call(void 0, function(path) {
218
+ if (!path || path.length === 0) {
219
+ return ".";
213
220
  }
214
- if (path.includes("\\")) {
215
- if (!path.toUpperCase().startsWith("C:")) {
216
- path = `C:${path}`;
221
+ path = normalizeWindowsPath(path);
222
+ const isUNCPath = path.match(_UNC_REGEX);
223
+ const isPathAbsolute = isAbsolute(path);
224
+ const trailingSeparator = path[path.length - 1] === "/";
225
+ path = normalizeString(path, !isPathAbsolute);
226
+ if (path.length === 0) {
227
+ if (isPathAbsolute) {
228
+ return "/";
217
229
  }
218
- return path.replaceAll("/", "\\");
230
+ return trailingSeparator ? "./" : ".";
231
+ }
232
+ if (trailingSeparator) {
233
+ path += "/";
234
+ }
235
+ if (_DRIVE_LETTER_RE.test(path)) {
236
+ path += "/";
219
237
  }
220
- return removeWindowsDriveLetter(path).split("\\").join("/");
238
+ if (isUNCPath) {
239
+ if (!isPathAbsolute) {
240
+ return `//./${path}`;
241
+ }
242
+ return `//${path}`;
243
+ }
244
+ return isPathAbsolute && !isAbsolute(path) ? `/${path}` : path;
221
245
  }, "correctPaths");
222
- var joinPaths = /* @__PURE__ */ _chunkUSNT2KNTcjs.__name.call(void 0, (...paths) => {
223
- if (!paths || paths.length === 0) {
224
- return "";
246
+ var joinPaths = /* @__PURE__ */ _chunkUSNT2KNTcjs.__name.call(void 0, function(...segments) {
247
+ let path = "";
248
+ for (const seg of segments) {
249
+ if (!seg) {
250
+ continue;
251
+ }
252
+ if (path.length > 0) {
253
+ const pathTrailing = path[path.length - 1] === "/";
254
+ const segLeading = seg[0] === "/";
255
+ const both = pathTrailing && segLeading;
256
+ if (both) {
257
+ path += seg.slice(1);
258
+ } else {
259
+ path += pathTrailing || segLeading ? seg : `/${seg}`;
260
+ }
261
+ } else {
262
+ path += seg;
263
+ }
225
264
  }
226
- return correctPaths(_path.join.call(void 0, ...paths));
265
+ return correctPaths(path);
227
266
  }, "joinPaths");
267
+ function normalizeString(path, allowAboveRoot) {
268
+ let res = "";
269
+ let lastSegmentLength = 0;
270
+ let lastSlash = -1;
271
+ let dots = 0;
272
+ let char = null;
273
+ for (let index = 0; index <= path.length; ++index) {
274
+ if (index < path.length) {
275
+ char = path[index];
276
+ } else if (char === "/") {
277
+ break;
278
+ } else {
279
+ char = "/";
280
+ }
281
+ if (char === "/") {
282
+ if (lastSlash === index - 1 || dots === 1) {
283
+ } else if (dots === 2) {
284
+ if (res.length < 2 || lastSegmentLength !== 2 || res[res.length - 1] !== "." || res[res.length - 2] !== ".") {
285
+ if (res.length > 2) {
286
+ const lastSlashIndex = res.lastIndexOf("/");
287
+ if (lastSlashIndex === -1) {
288
+ res = "";
289
+ lastSegmentLength = 0;
290
+ } else {
291
+ res = res.slice(0, lastSlashIndex);
292
+ lastSegmentLength = res.length - 1 - res.lastIndexOf("/");
293
+ }
294
+ lastSlash = index;
295
+ dots = 0;
296
+ continue;
297
+ } else if (res.length > 0) {
298
+ res = "";
299
+ lastSegmentLength = 0;
300
+ lastSlash = index;
301
+ dots = 0;
302
+ continue;
303
+ }
304
+ }
305
+ if (allowAboveRoot) {
306
+ res += res.length > 0 ? "/.." : "..";
307
+ lastSegmentLength = 2;
308
+ }
309
+ } else {
310
+ if (res.length > 0) {
311
+ res += `/${path.slice(lastSlash + 1, index)}`;
312
+ } else {
313
+ res = path.slice(lastSlash + 1, index);
314
+ }
315
+ lastSegmentLength = index - lastSlash - 1;
316
+ }
317
+ lastSlash = index;
318
+ dots = 0;
319
+ } else if (char === "." && dots !== -1) {
320
+ ++dots;
321
+ } else {
322
+ dots = -1;
323
+ }
324
+ }
325
+ return res;
326
+ }
327
+ _chunkUSNT2KNTcjs.__name.call(void 0, normalizeString, "normalizeString");
328
+ var isAbsolute = /* @__PURE__ */ _chunkUSNT2KNTcjs.__name.call(void 0, function(p) {
329
+ return _IS_ABSOLUTE_RE.test(p);
330
+ }, "isAbsolute");
228
331
 
229
332
  // ../config-tools/src/utilities/find-up.ts
230
333