@sse-ui/builder 1.2.0 → 1.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +76 -0
- package/dist/{babel-RJOLF3H5.js → babel-2PBTAJV6.js} +2 -3
- package/dist/babel-config.js +3 -3
- package/dist/{chunk-MBPIJFGX.js → chunk-6NNEV5YX.js} +15 -10
- package/dist/{chunk-B6FMAT44.js → chunk-N46AJ2OI.js} +3 -1
- package/dist/cli.js +164 -78
- package/dist/config.d.ts +2 -2
- package/dist/config.js +0 -2
- package/dist/typescript-2XUZHHI2.js +286 -0
- package/package.json +2 -3
- package/dist/acorn-RZKYEOCN.js +0 -3130
- package/dist/angular-65ZVA2AO.js +0 -3070
- package/dist/babel-6NAC7UZ3.js +0 -7296
- package/dist/chunk-MLKGABMK.js +0 -9
- package/dist/estree-SLPC3MKU.js +0 -4612
- package/dist/flow-JKSA2WQA.js +0 -27546
- package/dist/glimmer-KH4FHVWK.js +0 -2894
- package/dist/graphql-X7RDVKKC.js +0 -1266
- package/dist/html-A2DZMMEZ.js +0 -2933
- package/dist/markdown-35RS3VXW.js +0 -3553
- package/dist/meriyah-UIMGFPH2.js +0 -2684
- package/dist/postcss-CITECRUH.js +0 -5080
- package/dist/typescript-6QWCIZ3Q.js +0 -20526
- package/dist/typescript-CFZSZQGQ.js +0 -13203
- package/dist/yaml-RAY3ED75.js +0 -4224
package/dist/cli.js
CHANGED
|
@@ -1,18 +1,17 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
3
|
getVersionEnvVariables
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-6NNEV5YX.js";
|
|
5
5
|
import {
|
|
6
6
|
addLicense,
|
|
7
7
|
getOutExtension,
|
|
8
8
|
mapConcurrently,
|
|
9
9
|
validatePkgJson,
|
|
10
10
|
writePackageJson
|
|
11
|
-
} from "./chunk-
|
|
12
|
-
import "./chunk-MLKGABMK.js";
|
|
11
|
+
} from "./chunk-N46AJ2OI.js";
|
|
13
12
|
|
|
14
13
|
// src/cli.ts
|
|
15
|
-
import
|
|
14
|
+
import chalk11 from "chalk";
|
|
16
15
|
import { Command as Command11 } from "commander";
|
|
17
16
|
|
|
18
17
|
// src/core/build.ts
|
|
@@ -102,7 +101,7 @@ var buildCommand = new Command("build").description(chalk.cyan("Builds the packa
|
|
|
102
101
|
"--exportExtensions <exts...>",
|
|
103
102
|
"Available extensions for generating exports wildcards.",
|
|
104
103
|
[".js", ".mjs", ".cjs"]
|
|
105
|
-
).action(async (cliOptions) => {
|
|
104
|
+
).option("--minify", "Minify the generated output.").action(async (cliOptions) => {
|
|
106
105
|
const fileConfig = await loadConfig();
|
|
107
106
|
const isVerbose = cliOptions.verbose || fileConfig.verbose || process.env.SSE_BUILD_VERBOSE === "true";
|
|
108
107
|
if (isVerbose) process.env.SSE_BUILD_VERBOSE = "true";
|
|
@@ -110,6 +109,7 @@ var buildCommand = new Command("build").description(chalk.cyan("Builds the packa
|
|
|
110
109
|
const builder = isEsbuild ? "esbuild" : "babel";
|
|
111
110
|
const bundles = cliOptions.bundle || fileConfig.bundle || ["esm", "cjs"];
|
|
112
111
|
const isFlat = cliOptions.flat ?? fileConfig.flat ?? false;
|
|
112
|
+
const minify = cliOptions.minify ?? fileConfig.minify ?? false;
|
|
113
113
|
const buildTypes = cliOptions.buildTypes ?? fileConfig.buildTypes ?? true;
|
|
114
114
|
const skipTsc = cliOptions.skipTsc ?? fileConfig.skipTsc ?? false;
|
|
115
115
|
const skipBundlePackageJson = cliOptions.skipBundlePackageJson ?? fileConfig.skipBundlePackageJson ?? false;
|
|
@@ -132,8 +132,9 @@ var buildCommand = new Command("build").description(chalk.cyan("Builds the packa
|
|
|
132
132
|
const buildDir = path.join(cwd, buildDirBase);
|
|
133
133
|
const packageType = packageJson.type === "module" ? "module" : "commonjs";
|
|
134
134
|
if (isVerbose) {
|
|
135
|
-
console.log(`Selected output directory: "${buildDirBase}"`);
|
|
136
|
-
if (isFlat)
|
|
135
|
+
console.log(chalk.blue(`Selected output directory: "${buildDirBase}"`));
|
|
136
|
+
if (isFlat)
|
|
137
|
+
console.log(chalk.blue("Building package in flat structure."));
|
|
137
138
|
}
|
|
138
139
|
await fs.rm(buildDir, { recursive: true, force: true });
|
|
139
140
|
const pm = getPackageManager();
|
|
@@ -168,7 +169,9 @@ var buildCommand = new Command("build").description(chalk.cyan("Builds the packa
|
|
|
168
169
|
}
|
|
169
170
|
if (!bundles || bundles.length === 0) {
|
|
170
171
|
console.error(
|
|
171
|
-
|
|
172
|
+
chalk.red(
|
|
173
|
+
"No bundles specified. Use --bundle to specify which bundles to build."
|
|
174
|
+
)
|
|
172
175
|
);
|
|
173
176
|
return;
|
|
174
177
|
}
|
|
@@ -183,12 +186,16 @@ var buildCommand = new Command("build").description(chalk.cyan("Builds the packa
|
|
|
183
186
|
}
|
|
184
187
|
if (builder === "esbuild") {
|
|
185
188
|
if (isVerbose)
|
|
186
|
-
console.log(
|
|
189
|
+
console.log(
|
|
190
|
+
chalk.green("\u{1F4E6} Bundling package into single files via esbuild...")
|
|
191
|
+
);
|
|
187
192
|
const esbuildConfig = fileConfig.esbuild || { entry: "src/index.ts" };
|
|
188
193
|
let rawEntryPoints = cliOptions.entry || esbuildConfig.entry;
|
|
189
194
|
if (!rawEntryPoints) {
|
|
190
195
|
throw new Error(
|
|
191
|
-
|
|
196
|
+
chalk.red(
|
|
197
|
+
"Esbuild requires an 'entry' point. Please define it in your config (esbuild.entry) or via --entry."
|
|
198
|
+
)
|
|
192
199
|
);
|
|
193
200
|
}
|
|
194
201
|
const entryPoints = typeof rawEntryPoints === "string" ? [rawEntryPoints] : rawEntryPoints;
|
|
@@ -208,7 +215,7 @@ var buildCommand = new Command("build").description(chalk.cyan("Builds the packa
|
|
|
208
215
|
outdir: outputDir,
|
|
209
216
|
format: bundle === "esm" ? "esm" : "cjs",
|
|
210
217
|
target: esbuildConfig.target || ["es2020", "node14"],
|
|
211
|
-
minify
|
|
218
|
+
minify,
|
|
212
219
|
outExtension: { ".js": outExtension },
|
|
213
220
|
// Forces the correct extension output
|
|
214
221
|
external: [
|
|
@@ -238,8 +245,9 @@ var buildCommand = new Command("build").description(chalk.cyan("Builds the packa
|
|
|
238
245
|
})
|
|
239
246
|
);
|
|
240
247
|
} else {
|
|
241
|
-
if (isVerbose)
|
|
242
|
-
|
|
248
|
+
if (isVerbose)
|
|
249
|
+
console.log(chalk.green("\u{1F4E6} Transpiling package via Babel..."));
|
|
250
|
+
const { build: babelBuild, cjsCopy } = await import("./babel-2PBTAJV6.js");
|
|
243
251
|
const hasLargeFiles = cliOptions.hasLargeFiles ?? fileConfig.babel?.hasLargeFiles ?? false;
|
|
244
252
|
const extraIgnores = [
|
|
245
253
|
...fileConfig.babel?.ignore || [],
|
|
@@ -265,6 +273,7 @@ var buildCommand = new Command("build").description(chalk.cyan("Builds the packa
|
|
|
265
273
|
hasLargeFiles,
|
|
266
274
|
bundle,
|
|
267
275
|
verbose: isVerbose,
|
|
276
|
+
minify,
|
|
268
277
|
optimizeClsx: packageJson.dependencies?.clsx !== void 0 || packageJson.dependencies?.classnames !== void 0,
|
|
269
278
|
removePropTypes: packageJson.dependencies?.["prop-types"] !== void 0,
|
|
270
279
|
pkgVersion: packageJson.version,
|
|
@@ -304,8 +313,9 @@ var buildCommand = new Command("build").description(chalk.cyan("Builds the packa
|
|
|
304
313
|
}
|
|
305
314
|
}
|
|
306
315
|
if (buildTypes === true) {
|
|
307
|
-
if (isVerbose)
|
|
308
|
-
|
|
316
|
+
if (isVerbose)
|
|
317
|
+
console.log(chalk.cyan("\u{1F4DD} Generating TypeScript declarations..."));
|
|
318
|
+
const tsMod = await import("./typescript-2XUZHHI2.js");
|
|
309
319
|
const bundleMap = bundles.map((type) => ({
|
|
310
320
|
type,
|
|
311
321
|
dir: relativeOutDirs[type]
|
|
@@ -356,6 +366,7 @@ var buildCommand = new Command("build").description(chalk.cyan("Builds the packa
|
|
|
356
366
|
buildDir,
|
|
357
367
|
verbose: isVerbose
|
|
358
368
|
});
|
|
369
|
+
console.log(chalk.green.bold("\u2714 Build completed successfully"));
|
|
359
370
|
});
|
|
360
371
|
async function copyHandler({
|
|
361
372
|
cwd,
|
|
@@ -456,7 +467,7 @@ async function recursiveCopy({
|
|
|
456
467
|
try {
|
|
457
468
|
await fs.cp(source, target, { recursive: true });
|
|
458
469
|
if (verbose) {
|
|
459
|
-
console.log(
|
|
470
|
+
console.log(chalk.gray(`\u{1F4C4} Copied ${source} \u2192 ${target}`));
|
|
460
471
|
}
|
|
461
472
|
return true;
|
|
462
473
|
} catch (err) {
|
|
@@ -464,7 +475,7 @@ async function recursiveCopy({
|
|
|
464
475
|
throw err;
|
|
465
476
|
}
|
|
466
477
|
if (verbose) {
|
|
467
|
-
console.warn(
|
|
478
|
+
console.warn(chalk.yellow(`\u26A0 Source does not exist: ${source}`));
|
|
468
479
|
}
|
|
469
480
|
throw err;
|
|
470
481
|
}
|
|
@@ -475,6 +486,7 @@ import * as fs2 from "fs/promises";
|
|
|
475
486
|
import * as path2 from "path";
|
|
476
487
|
import { Command as Command2 } from "commander";
|
|
477
488
|
import { $ as $2 } from "execa";
|
|
489
|
+
import chalk2 from "chalk";
|
|
478
490
|
var publishCommand = new Command2("publish").description(
|
|
479
491
|
"Automatically publishes the built package from the publishConfig.directory"
|
|
480
492
|
).option("--tag <tag>", "Registers the published package with the given tag").option(
|
|
@@ -514,7 +526,9 @@ var publishCommand = new Command2("publish").description(
|
|
|
514
526
|
const pm = options.pm || getPackageManager();
|
|
515
527
|
if (isVerbose) {
|
|
516
528
|
console.log(
|
|
517
|
-
|
|
529
|
+
chalk2.blue(
|
|
530
|
+
`\u{1F680} Publishing via ${pm.toUpperCase()} from directory: ${publishDirBase}`
|
|
531
|
+
)
|
|
518
532
|
);
|
|
519
533
|
}
|
|
520
534
|
const args = ["publish"];
|
|
@@ -528,11 +542,11 @@ var publishCommand = new Command2("publish").description(
|
|
|
528
542
|
stdio: "inherit",
|
|
529
543
|
cwd: publishDir
|
|
530
544
|
})`${pm} ${args}`;
|
|
531
|
-
console.log("\u2705 Successfully published!");
|
|
545
|
+
console.log(chalk2.green("\u2705 Successfully published!"));
|
|
532
546
|
} catch (error) {
|
|
533
|
-
console.error("\u274C Error executing publish command:");
|
|
547
|
+
console.error(chalk2.red("\u274C Error executing publish command:"));
|
|
534
548
|
if (error instanceof Error) {
|
|
535
|
-
console.error(error.message);
|
|
549
|
+
console.error(chalk2.red(error.message));
|
|
536
550
|
}
|
|
537
551
|
process.exit(1);
|
|
538
552
|
}
|
|
@@ -542,6 +556,7 @@ var publishCommand = new Command2("publish").description(
|
|
|
542
556
|
import * as fs3 from "fs/promises";
|
|
543
557
|
import * as path3 from "path";
|
|
544
558
|
import { Command as Command3 } from "commander";
|
|
559
|
+
import chalk3 from "chalk";
|
|
545
560
|
var cleanCommand = new Command3("clean").description(
|
|
546
561
|
"Removes the build directory specified in package.json to start fresh"
|
|
547
562
|
).action(async () => {
|
|
@@ -556,13 +571,15 @@ var cleanCommand = new Command3("clean").description(
|
|
|
556
571
|
const buildDirBase = packageJson.publishConfig?.directory || "build";
|
|
557
572
|
const buildDir = path3.join(cwd, buildDirBase);
|
|
558
573
|
if (isVerbose)
|
|
559
|
-
console.log(
|
|
574
|
+
console.log(
|
|
575
|
+
chalk3.blue(`\u{1F9F9} Cleaning build directory: ${buildDirBase}...`)
|
|
576
|
+
);
|
|
560
577
|
await fs3.rm(buildDir, { recursive: true, force: true });
|
|
561
|
-
console.log("\u2728 Cleaned successfully!");
|
|
578
|
+
console.log(chalk3.green("\u2728 Cleaned successfully!"));
|
|
562
579
|
} catch (error) {
|
|
563
|
-
console.error("\u274C Error executing clean command:");
|
|
580
|
+
console.error(chalk3.red("\u274C Error executing clean command:"));
|
|
564
581
|
if (error instanceof Error) {
|
|
565
|
-
console.error(error.message);
|
|
582
|
+
console.error(chalk3.red(error.message));
|
|
566
583
|
}
|
|
567
584
|
process.exit(1);
|
|
568
585
|
}
|
|
@@ -571,11 +588,12 @@ var cleanCommand = new Command3("clean").description(
|
|
|
571
588
|
// src/core/typecheck.ts
|
|
572
589
|
import { Command as Command4 } from "commander";
|
|
573
590
|
import { $ as $3 } from "execa";
|
|
591
|
+
import chalk4 from "chalk";
|
|
574
592
|
var typecheckCommand = new Command4("typecheck").description(
|
|
575
593
|
"Runs TypeScript validation across the project without emitting files"
|
|
576
594
|
).option("--watch", "Run typechecking in watch mode").action(async (options) => {
|
|
577
595
|
const isVerbose = process.env.SSE_BUILD_VERBOSE === "true";
|
|
578
|
-
if (isVerbose) console.log("\u{1F50D} Running typecheck...");
|
|
596
|
+
if (isVerbose) console.log(chalk4.blue("\u{1F50D} Running typecheck..."));
|
|
579
597
|
try {
|
|
580
598
|
const args = ["tsc", "--noEmit"];
|
|
581
599
|
if (options.watch) {
|
|
@@ -583,11 +601,13 @@ var typecheckCommand = new Command4("typecheck").description(
|
|
|
583
601
|
}
|
|
584
602
|
await $3({ stdio: "inherit" })`${args.join(" ")}`;
|
|
585
603
|
if (!options.watch) {
|
|
586
|
-
console.log("\u2705 Typecheck passed! No errors found.");
|
|
604
|
+
console.log(chalk4.green("\u2705 Typecheck passed! No errors found."));
|
|
587
605
|
}
|
|
588
606
|
} catch (error) {
|
|
589
607
|
console.error(
|
|
590
|
-
|
|
608
|
+
chalk4.red(
|
|
609
|
+
"\u274C Typecheck failed. Please fix the TypeScript errors above."
|
|
610
|
+
)
|
|
591
611
|
);
|
|
592
612
|
process.exit(1);
|
|
593
613
|
}
|
|
@@ -598,6 +618,7 @@ import * as fs4 from "fs/promises";
|
|
|
598
618
|
import * as path4 from "path";
|
|
599
619
|
import { Command as Command5 } from "commander";
|
|
600
620
|
import { $ as $4 } from "execa";
|
|
621
|
+
import chalk5 from "chalk";
|
|
601
622
|
var packCommand = new Command5("pack").description(
|
|
602
623
|
"Creates a tarball (.tgz) of the built package to inspect before publishing"
|
|
603
624
|
).action(async () => {
|
|
@@ -616,17 +637,21 @@ var packCommand = new Command5("pack").description(
|
|
|
616
637
|
}
|
|
617
638
|
const publishDir = path4.join(cwd, publishDirBase);
|
|
618
639
|
if (isVerbose)
|
|
619
|
-
console.log(
|
|
640
|
+
console.log(
|
|
641
|
+
chalk5.blue(`\u{1F4E6} Packing package from directory: ${publishDirBase}...`)
|
|
642
|
+
);
|
|
620
643
|
await $4({
|
|
621
644
|
stdio: "inherit",
|
|
622
645
|
cwd: publishDir
|
|
623
646
|
})`${pm} pack`;
|
|
624
647
|
console.log(
|
|
625
|
-
|
|
648
|
+
chalk5.green(
|
|
649
|
+
"\u2705 Pack successful! You can inspect the generated .tgz file."
|
|
650
|
+
)
|
|
626
651
|
);
|
|
627
652
|
} catch (error) {
|
|
628
|
-
console.error("\u274C Error executing pack command:");
|
|
629
|
-
if (error instanceof Error) console.error(error.message);
|
|
653
|
+
console.error(chalk5.red("\u274C Error executing pack command:"));
|
|
654
|
+
if (error instanceof Error) console.error(chalk5.red(error.message));
|
|
630
655
|
process.exit(1);
|
|
631
656
|
}
|
|
632
657
|
});
|
|
@@ -638,6 +663,7 @@ import { Command as Command6 } from "commander";
|
|
|
638
663
|
import { $ as $5 } from "execa";
|
|
639
664
|
import enquirer from "enquirer";
|
|
640
665
|
import * as semver2 from "semver";
|
|
666
|
+
import chalk6 from "chalk";
|
|
641
667
|
var versionCommand = new Command6("version").description("Bumps the package version interactively or manually").argument(
|
|
642
668
|
"[type]",
|
|
643
669
|
"Version update type (patch, minor, major, or specific version like 1.2.3). If omitted, an interactive prompt will appear."
|
|
@@ -664,7 +690,9 @@ var versionCommand = new Command6("version").description("Bumps the package vers
|
|
|
664
690
|
} catch (err) {
|
|
665
691
|
if (isVerbose)
|
|
666
692
|
console.warn(
|
|
667
|
-
|
|
693
|
+
chalk6.yellow(
|
|
694
|
+
"\u26A0\uFE0F Could not read current version from package.json. Defaulting to 0.0.0"
|
|
695
|
+
)
|
|
668
696
|
);
|
|
669
697
|
}
|
|
670
698
|
const choices = validTypes.map((bump) => {
|
|
@@ -699,22 +727,26 @@ var versionCommand = new Command6("version").description("Bumps the package vers
|
|
|
699
727
|
} else {
|
|
700
728
|
if (!validTypes.includes(selectedType) && !semver2.valid(selectedType)) {
|
|
701
729
|
console.error(
|
|
702
|
-
|
|
730
|
+
chalk6.red(
|
|
731
|
+
`\u274C Invalid version type: ${selectedType}. Use patch, minor, major, or a valid semver.`
|
|
732
|
+
)
|
|
703
733
|
);
|
|
704
734
|
process.exit(1);
|
|
705
735
|
}
|
|
706
736
|
}
|
|
707
737
|
if (isVerbose)
|
|
708
|
-
console.log(
|
|
738
|
+
console.log(
|
|
739
|
+
chalk6.cyan(`\u{1F4C8} Bumping version (${selectedType}) via ${pm}...`)
|
|
740
|
+
);
|
|
709
741
|
try {
|
|
710
742
|
const args = ["version", selectedType];
|
|
711
743
|
if (!options.gitTagVersion) {
|
|
712
744
|
args.push("--no-git-tag-version");
|
|
713
745
|
}
|
|
714
746
|
await $5({ stdio: isVerbose ? "inherit" : "pipe" })`${pm} ${args}`;
|
|
715
|
-
console.log("\u2705 Version bumped successfully!");
|
|
747
|
+
console.log(chalk6.green("\u2705 Version bumped successfully!"));
|
|
716
748
|
} catch (error) {
|
|
717
|
-
console.error("\u274C Failed to bump version.");
|
|
749
|
+
console.error(chalk6.red("\u274C Failed to bump version."));
|
|
718
750
|
process.exit(1);
|
|
719
751
|
}
|
|
720
752
|
});
|
|
@@ -723,6 +755,7 @@ var versionCommand = new Command6("version").description("Bumps the package vers
|
|
|
723
755
|
import * as fs6 from "fs/promises";
|
|
724
756
|
import * as path6 from "path";
|
|
725
757
|
import { Command as Command7 } from "commander";
|
|
758
|
+
import chalk7 from "chalk";
|
|
726
759
|
async function getDirSize(dirPath) {
|
|
727
760
|
let size = 0;
|
|
728
761
|
const files = await fs6.readdir(dirPath, { withFileTypes: true });
|
|
@@ -754,24 +787,29 @@ var infoCommand = new Command7("info").description("Displays size and file stati
|
|
|
754
787
|
const sizeBytes = await getDirSize(publishDir);
|
|
755
788
|
const sizeKB = (sizeBytes / 1024).toFixed(2);
|
|
756
789
|
const sizeMB = (sizeBytes / (1024 * 1024)).toFixed(2);
|
|
757
|
-
if (isVerbose)
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
790
|
+
if (isVerbose)
|
|
791
|
+
console.log(chalk7.gray(`Gathering info from ${publishDir}...`));
|
|
792
|
+
console.log(
|
|
793
|
+
chalk7.cyan(`
|
|
794
|
+
\u{1F4CA} Package Info: `) + chalk7.bold(packageJson.name)
|
|
795
|
+
);
|
|
796
|
+
console.log(chalk7.gray(`================================`));
|
|
797
|
+
console.log(`Version: ${chalk7.white(packageJson.version)}`);
|
|
798
|
+
console.log(`Build Folder: ${chalk7.white(`./${publishDirBase}`)}`);
|
|
763
799
|
if (sizeBytes > 1024 * 1024) {
|
|
764
800
|
console.log(
|
|
765
|
-
`Total Size: ${sizeMB} MB \u26A0\uFE0F (Consider keeping packages under 1MB)`
|
|
801
|
+
`Total Size: ${chalk7.yellow(`${sizeMB} MB`)} ${chalk7.red("\u26A0\uFE0F (Consider keeping packages under 1MB)")}`
|
|
766
802
|
);
|
|
767
803
|
} else {
|
|
768
|
-
console.log(`Total Size: ${sizeKB} KB \u2705`);
|
|
804
|
+
console.log(`Total Size: ${chalk7.green(`${sizeKB} KB \u2705`)}`);
|
|
769
805
|
}
|
|
770
|
-
console.log(`================================
|
|
771
|
-
`);
|
|
806
|
+
console.log(chalk7.gray(`================================
|
|
807
|
+
`));
|
|
772
808
|
} catch (error) {
|
|
773
809
|
console.error(
|
|
774
|
-
|
|
810
|
+
chalk7.red(
|
|
811
|
+
"\u274C Error fetching package info. Did you build the project first?"
|
|
812
|
+
)
|
|
775
813
|
);
|
|
776
814
|
process.exit(1);
|
|
777
815
|
}
|
|
@@ -782,6 +820,7 @@ import * as fs7 from "fs/promises";
|
|
|
782
820
|
import * as path7 from "path";
|
|
783
821
|
import { Command as Command8 } from "commander";
|
|
784
822
|
import { $ as $6 } from "execa";
|
|
823
|
+
import chalk8 from "chalk";
|
|
785
824
|
var linkCommand = new Command8("link").description(
|
|
786
825
|
"Symlinks the built package directory so it can be tested in other local projects"
|
|
787
826
|
).action(async () => {
|
|
@@ -800,20 +839,22 @@ var linkCommand = new Command8("link").description(
|
|
|
800
839
|
}
|
|
801
840
|
const publishDir = path7.join(cwd, publishDirBase);
|
|
802
841
|
if (isVerbose)
|
|
803
|
-
console.log(
|
|
842
|
+
console.log(
|
|
843
|
+
chalk8.blue(`\u{1F517} Linking package from: ./${publishDirBase}...`)
|
|
844
|
+
);
|
|
804
845
|
await $6({
|
|
805
846
|
stdio: isVerbose ? "inherit" : "pipe",
|
|
806
847
|
cwd: publishDir
|
|
807
848
|
})`${pm} link`;
|
|
808
|
-
console.log(`
|
|
809
|
-
\u2705 Successfully linked!`);
|
|
849
|
+
console.log(chalk8.green(`
|
|
850
|
+
\u2705 Successfully linked!`));
|
|
810
851
|
console.log(
|
|
811
852
|
`To use this in another project, go to that project and run:`
|
|
812
853
|
);
|
|
813
|
-
console.log(`\u{1F449} ${pm} link ${packageJson.name}`);
|
|
854
|
+
console.log(chalk8.cyan(`\u{1F449} ${pm} link ${packageJson.name}`));
|
|
814
855
|
} catch (error) {
|
|
815
|
-
console.error("\u274C Error executing link command:");
|
|
816
|
-
if (error instanceof Error) console.error(error.message);
|
|
856
|
+
console.error(chalk8.red("\u274C Error executing link command:"));
|
|
857
|
+
if (error instanceof Error) console.error(chalk8.red(error.message));
|
|
817
858
|
process.exit(1);
|
|
818
859
|
}
|
|
819
860
|
});
|
|
@@ -822,6 +863,8 @@ var linkCommand = new Command8("link").description(
|
|
|
822
863
|
import * as fs8 from "fs/promises";
|
|
823
864
|
import * as path8 from "path";
|
|
824
865
|
import { Command as Command9 } from "commander";
|
|
866
|
+
import chalk9 from "chalk";
|
|
867
|
+
import { globby as globby2 } from "globby";
|
|
825
868
|
async function fileExists(filePath) {
|
|
826
869
|
return fs8.stat(filePath).then(() => true).catch(() => false);
|
|
827
870
|
}
|
|
@@ -859,32 +902,59 @@ var checkExportsCommand = new Command9("check-exports").description(
|
|
|
859
902
|
});
|
|
860
903
|
const buildPkg = JSON.parse(buildPkgContent);
|
|
861
904
|
if (!buildPkg.exports) {
|
|
862
|
-
if (isVerbose)
|
|
905
|
+
if (isVerbose)
|
|
906
|
+
console.log(chalk9.yellow("\u26A0\uFE0F No 'exports' field found to check."));
|
|
863
907
|
return;
|
|
864
908
|
}
|
|
865
|
-
console.log(
|
|
909
|
+
console.log(
|
|
910
|
+
chalk9.blue(`\u{1F575}\uFE0F Checking exports mapping in ./${publishDirBase}...`)
|
|
911
|
+
);
|
|
866
912
|
const allPaths = extractPaths(buildPkg.exports);
|
|
913
|
+
const uniquePaths = Array.from(new Set(allPaths));
|
|
867
914
|
let hasErrors = false;
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
915
|
+
const publishDirFullPath = path8.join(cwd, publishDirBase);
|
|
916
|
+
for (const relativePath of uniquePaths) {
|
|
917
|
+
if (relativePath.includes("*")) {
|
|
918
|
+
const matchedFiles = await globby2(relativePath, {
|
|
919
|
+
cwd: publishDirFullPath
|
|
920
|
+
});
|
|
921
|
+
if (matchedFiles.length > 0) {
|
|
922
|
+
if (isVerbose)
|
|
923
|
+
console.log(
|
|
924
|
+
chalk9.green(` \u2705 Found matches for pattern: ${relativePath}`)
|
|
925
|
+
);
|
|
926
|
+
} else {
|
|
927
|
+
console.error(
|
|
928
|
+
chalk9.red(` \u274C No files match pattern: ${relativePath}`)
|
|
929
|
+
);
|
|
930
|
+
hasErrors = true;
|
|
931
|
+
}
|
|
873
932
|
} else {
|
|
874
|
-
|
|
875
|
-
|
|
933
|
+
const absolutePath = path8.join(publishDirFullPath, relativePath);
|
|
934
|
+
const exists = await fileExists(absolutePath);
|
|
935
|
+
if (exists) {
|
|
936
|
+
if (isVerbose)
|
|
937
|
+
console.log(chalk9.green(` \u2705 Found: ${relativePath}`));
|
|
938
|
+
} else {
|
|
939
|
+
console.error(chalk9.red(` \u274C Missing: ${relativePath}`));
|
|
940
|
+
hasErrors = true;
|
|
941
|
+
}
|
|
876
942
|
}
|
|
877
943
|
}
|
|
878
944
|
if (hasErrors) {
|
|
879
945
|
console.error(
|
|
880
|
-
|
|
946
|
+
chalk9.red(
|
|
947
|
+
"\n\u274C Export check failed! Some files declared in package.json are missing."
|
|
948
|
+
)
|
|
881
949
|
);
|
|
882
950
|
process.exit(1);
|
|
883
951
|
} else {
|
|
884
|
-
console.log(
|
|
952
|
+
console.log(
|
|
953
|
+
chalk9.green("\n\u2728 All exported files are present and accounted for!")
|
|
954
|
+
);
|
|
885
955
|
}
|
|
886
956
|
} catch (error) {
|
|
887
|
-
if (error instanceof Error) console.error(error.message);
|
|
957
|
+
if (error instanceof Error) console.error(chalk9.red(error.message));
|
|
888
958
|
process.exit(1);
|
|
889
959
|
}
|
|
890
960
|
});
|
|
@@ -2630,6 +2700,7 @@ var chokidar_default = { watch, FSWatcher };
|
|
|
2630
2700
|
import { $ as $7 } from "execa";
|
|
2631
2701
|
import { build as esbuild2 } from "esbuild";
|
|
2632
2702
|
import { findWorkspacesRoot as findWorkspacesRoot2 } from "find-workspaces";
|
|
2703
|
+
import chalk10 from "chalk";
|
|
2633
2704
|
var watchCommand = new Command10("watch").description(
|
|
2634
2705
|
"Watches the src directory and incrementally rebuilds files on changes (Vite-style)"
|
|
2635
2706
|
).action(async () => {
|
|
@@ -2644,8 +2715,10 @@ var watchCommand = new Command10("watch").description(
|
|
|
2644
2715
|
}
|
|
2645
2716
|
const isVerbose = process.env.SSE_BUILD_VERBOSE === "true";
|
|
2646
2717
|
if (isReload) {
|
|
2647
|
-
console.log(
|
|
2648
|
-
|
|
2718
|
+
console.log(
|
|
2719
|
+
chalk10.cyan(`
|
|
2720
|
+
\u{1F504} Configuration change detected. Reloading...`)
|
|
2721
|
+
);
|
|
2649
2722
|
}
|
|
2650
2723
|
const packageJsonContent = await fs9.readFile(pkgJsonPath, "utf8");
|
|
2651
2724
|
const packageJson = JSON.parse(packageJsonContent);
|
|
@@ -2663,22 +2736,29 @@ var watchCommand = new Command10("watch").description(
|
|
|
2663
2736
|
const pmExec = getPmExec();
|
|
2664
2737
|
let babelRuntimeVersion = packageJson.dependencies?.["@babel/runtime"];
|
|
2665
2738
|
const reactVersion = packageJson.peerDependencies?.react || "latest";
|
|
2666
|
-
console.log(
|
|
2739
|
+
console.log(
|
|
2740
|
+
chalk10.blue(`\u{1F440} Watching for changes (Builder: ${builder})...`)
|
|
2741
|
+
);
|
|
2667
2742
|
try {
|
|
2668
2743
|
await $7({
|
|
2669
2744
|
stdio: "inherit",
|
|
2670
2745
|
preferLocal: true
|
|
2671
2746
|
})`${pmExec} sse-tools build`;
|
|
2672
2747
|
} catch (err) {
|
|
2673
|
-
console.error(
|
|
2674
|
-
|
|
2748
|
+
console.error(
|
|
2749
|
+
chalk10.red(`\u274C Initial build failed. Waiting for changes...
|
|
2750
|
+
`)
|
|
2751
|
+
);
|
|
2675
2752
|
}
|
|
2676
2753
|
const buildFile = async (filePath) => {
|
|
2677
2754
|
const relativePath = path9.relative(srcDir, filePath);
|
|
2755
|
+
const minify = fileConfig.minify ?? false;
|
|
2678
2756
|
if (builder === "esbuild") {
|
|
2679
2757
|
if (isVerbose)
|
|
2680
2758
|
console.log(
|
|
2681
|
-
|
|
2759
|
+
chalk10.gray(
|
|
2760
|
+
`\u{1F680} [esbuild] Incremental rebuild triggered by ${relativePath}...`
|
|
2761
|
+
)
|
|
2682
2762
|
);
|
|
2683
2763
|
const esbuildConfig = fileConfig.esbuild;
|
|
2684
2764
|
const entryPoints = typeof esbuildConfig.entry === "string" ? [esbuildConfig.entry] : esbuildConfig.entry;
|
|
@@ -2697,7 +2777,7 @@ var watchCommand = new Command10("watch").description(
|
|
|
2697
2777
|
outdir: outputDir,
|
|
2698
2778
|
format: bundle === "esm" ? "esm" : "cjs",
|
|
2699
2779
|
target: esbuildConfig.target || ["es2020", "node14"],
|
|
2700
|
-
minify
|
|
2780
|
+
minify,
|
|
2701
2781
|
outExtension: { ".js": outExtension },
|
|
2702
2782
|
external: [
|
|
2703
2783
|
...Object.keys(packageJson.dependencies || {}),
|
|
@@ -2707,9 +2787,13 @@ var watchCommand = new Command10("watch").description(
|
|
|
2707
2787
|
});
|
|
2708
2788
|
})
|
|
2709
2789
|
);
|
|
2710
|
-
if (isVerbose)
|
|
2790
|
+
if (isVerbose)
|
|
2791
|
+
console.log(chalk10.green(`\u2705 [esbuild] Rebuild complete.`));
|
|
2711
2792
|
} catch (err) {
|
|
2712
|
-
console.error(
|
|
2793
|
+
console.error(
|
|
2794
|
+
chalk10.red(`\u274C [esbuild] Rebuild failed:`),
|
|
2795
|
+
err.message
|
|
2796
|
+
);
|
|
2713
2797
|
}
|
|
2714
2798
|
} else {
|
|
2715
2799
|
const ext = path9.extname(filePath);
|
|
@@ -2736,6 +2820,7 @@ var watchCommand = new Command10("watch").description(
|
|
|
2736
2820
|
NODE_ENV: "production",
|
|
2737
2821
|
BABEL_ENV: bundle === "esm" ? "stable" : "node",
|
|
2738
2822
|
SSE_OUT_FILE_EXTENSION: outExtension,
|
|
2823
|
+
SSE_MINIFY: minify ? "true" : void 0,
|
|
2739
2824
|
SSE_BABEL_RUNTIME_VERSION: babelRuntimeVersion,
|
|
2740
2825
|
...getVersionEnvVariables(packageJson.version)
|
|
2741
2826
|
};
|
|
@@ -2746,7 +2831,8 @@ var watchCommand = new Command10("watch").description(
|
|
|
2746
2831
|
})`babel --config-file ${babelConfigFile} --extensions .js,.jsx,.ts,.tsx ${filePath} --out-file ${outFilePath}`;
|
|
2747
2832
|
})
|
|
2748
2833
|
);
|
|
2749
|
-
if (isVerbose)
|
|
2834
|
+
if (isVerbose)
|
|
2835
|
+
console.log(chalk10.green(`\u2705 [babel] Updated ${relativePath}`));
|
|
2750
2836
|
}
|
|
2751
2837
|
};
|
|
2752
2838
|
const updateExports = async () => {
|
|
@@ -2769,7 +2855,7 @@ var watchCommand = new Command10("watch").description(
|
|
|
2769
2855
|
exportExtensions: fileConfig.exportExtensions
|
|
2770
2856
|
});
|
|
2771
2857
|
} catch (e) {
|
|
2772
|
-
console.error(`\u274C Failed to update exports: ${e.message}`);
|
|
2858
|
+
console.error(chalk10.red(`\u274C Failed to update exports: ${e.message}`));
|
|
2773
2859
|
}
|
|
2774
2860
|
};
|
|
2775
2861
|
let exportTimeout;
|
|
@@ -2842,7 +2928,7 @@ var watchCommand = new Command10("watch").description(
|
|
|
2842
2928
|
async function main() {
|
|
2843
2929
|
const program = new Command11();
|
|
2844
2930
|
program.name("sse-tools").description(
|
|
2845
|
-
|
|
2931
|
+
chalk11.cyan("CLI utilities for managing and building SSE packages")
|
|
2846
2932
|
).version("1.0.0").option("-v, --verbose", "Enable verbose logging across all commands");
|
|
2847
2933
|
program.hook("preAction", (thisCommand) => {
|
|
2848
2934
|
if (thisCommand.opts().verbose) {
|
package/dist/config.d.ts
CHANGED
|
@@ -13,8 +13,6 @@ interface EsbuildOptions {
|
|
|
13
13
|
* Example: "src/index.ts" or ["src/index.ts"] or { main: "src/index.ts" }
|
|
14
14
|
*/
|
|
15
15
|
entry: string | string[] | Record<string, string>;
|
|
16
|
-
/** Minify the generated bundle. */
|
|
17
|
-
minify?: boolean;
|
|
18
16
|
/** Target environment for the generated JavaScript. */
|
|
19
17
|
target?: string | string[];
|
|
20
18
|
/** External dependencies to exclude from the bundle. */
|
|
@@ -39,6 +37,8 @@ interface BaseBuildConfig {
|
|
|
39
37
|
copy?: string[];
|
|
40
38
|
/** Skip generating a package.json file in the bundle output */
|
|
41
39
|
skipBundlePackageJson?: boolean;
|
|
40
|
+
/** Minify the generated bundle. */
|
|
41
|
+
minify?: boolean;
|
|
42
42
|
}
|
|
43
43
|
/**
|
|
44
44
|
* The user can define EITHER `babel` OR `esbuild` configuration.
|