@sse-ui/builder 1.3.0 → 1.3.2

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/dist/cli.js CHANGED
@@ -9,11 +9,10 @@ import {
9
9
  validatePkgJson,
10
10
  writePackageJson
11
11
  } from "./chunk-N46AJ2OI.js";
12
- import "./chunk-MLKGABMK.js";
13
12
 
14
13
  // src/cli.ts
15
- import chalk11 from "chalk";
16
- import { Command as Command11 } from "commander";
14
+ import chalk13 from "chalk";
15
+ import { Command as Command13 } from "commander";
17
16
 
18
17
  // src/core/build.ts
19
18
  import { findWorkspacesRoot } from "find-workspaces";
@@ -248,7 +247,7 @@ var buildCommand = new Command("build").description(chalk.cyan("Builds the packa
248
247
  } else {
249
248
  if (isVerbose)
250
249
  console.log(chalk.green("\u{1F4E6} Transpiling package via Babel..."));
251
- const { build: babelBuild, cjsCopy } = await import("./babel-6NHCDM3A.js");
250
+ const { build: babelBuild, cjsCopy } = await import("./babel-2PBTAJV6.js");
252
251
  const hasLargeFiles = cliOptions.hasLargeFiles ?? fileConfig.babel?.hasLargeFiles ?? false;
253
252
  const extraIgnores = [
254
253
  ...fileConfig.babel?.ignore || [],
@@ -316,7 +315,7 @@ var buildCommand = new Command("build").description(chalk.cyan("Builds the packa
316
315
  if (buildTypes === true) {
317
316
  if (isVerbose)
318
317
  console.log(chalk.cyan("\u{1F4DD} Generating TypeScript declarations..."));
319
- const tsMod = await import("./typescript-42L4XZEH.js");
318
+ const tsMod = await import("./typescript-2XUZHHI2.js");
320
319
  const bundleMap = bundles.map((type) => ({
321
320
  type,
322
321
  dir: relativeOutDirs[type]
@@ -1055,7 +1054,7 @@ var ReaddirpStream = class extends Readable {
1055
1054
  this._directoryFilter = normalizeFilter(opts.directoryFilter);
1056
1055
  const statMethod = opts.lstat ? lstat : stat5;
1057
1056
  if (wantBigintFsStats) {
1058
- this._stat = (path10) => statMethod(path10, { bigint: true });
1057
+ this._stat = (path12) => statMethod(path12, { bigint: true });
1059
1058
  } else {
1060
1059
  this._stat = statMethod;
1061
1060
  }
@@ -1080,8 +1079,8 @@ var ReaddirpStream = class extends Readable {
1080
1079
  const par = this.parent;
1081
1080
  const fil = par && par.files;
1082
1081
  if (fil && fil.length > 0) {
1083
- const { path: path10, depth } = par;
1084
- const slice = fil.splice(0, batch).map((dirent) => this._formatEntry(dirent, path10));
1082
+ const { path: path12, depth } = par;
1083
+ const slice = fil.splice(0, batch).map((dirent) => this._formatEntry(dirent, path12));
1085
1084
  const awaited = await Promise.all(slice);
1086
1085
  for (const entry of awaited) {
1087
1086
  if (!entry)
@@ -1121,20 +1120,20 @@ var ReaddirpStream = class extends Readable {
1121
1120
  this.reading = false;
1122
1121
  }
1123
1122
  }
1124
- async _exploreDir(path10, depth) {
1123
+ async _exploreDir(path12, depth) {
1125
1124
  let files;
1126
1125
  try {
1127
- files = await readdir2(path10, this._rdOptions);
1126
+ files = await readdir2(path12, this._rdOptions);
1128
1127
  } catch (error) {
1129
1128
  this._onError(error);
1130
1129
  }
1131
- return { files, depth, path: path10 };
1130
+ return { files, depth, path: path12 };
1132
1131
  }
1133
- async _formatEntry(dirent, path10) {
1132
+ async _formatEntry(dirent, path12) {
1134
1133
  let entry;
1135
1134
  const basename4 = this._isDirent ? dirent.name : dirent;
1136
1135
  try {
1137
- const fullPath = presolve(pjoin(path10, basename4));
1136
+ const fullPath = presolve(pjoin(path12, basename4));
1138
1137
  entry = { path: prelative(this._root, fullPath), fullPath, basename: basename4 };
1139
1138
  entry[this._statsProp] = this._isDirent ? dirent : await this._stat(fullPath);
1140
1139
  } catch (err) {
@@ -1534,16 +1533,16 @@ var delFromSet = (main2, prop, item) => {
1534
1533
  };
1535
1534
  var isEmptySet = (val) => val instanceof Set ? val.size === 0 : !val;
1536
1535
  var FsWatchInstances = /* @__PURE__ */ new Map();
1537
- function createFsWatchInstance(path10, options, listener, errHandler, emitRaw) {
1536
+ function createFsWatchInstance(path12, options, listener, errHandler, emitRaw) {
1538
1537
  const handleEvent = (rawEvent, evPath) => {
1539
- listener(path10);
1540
- emitRaw(rawEvent, evPath, { watchedPath: path10 });
1541
- if (evPath && path10 !== evPath) {
1542
- fsWatchBroadcast(sp.resolve(path10, evPath), KEY_LISTENERS, sp.join(path10, evPath));
1538
+ listener(path12);
1539
+ emitRaw(rawEvent, evPath, { watchedPath: path12 });
1540
+ if (evPath && path12 !== evPath) {
1541
+ fsWatchBroadcast(sp.resolve(path12, evPath), KEY_LISTENERS, sp.join(path12, evPath));
1543
1542
  }
1544
1543
  };
1545
1544
  try {
1546
- return fs_watch(path10, {
1545
+ return fs_watch(path12, {
1547
1546
  persistent: options.persistent
1548
1547
  }, handleEvent);
1549
1548
  } catch (error) {
@@ -1559,12 +1558,12 @@ var fsWatchBroadcast = (fullPath, listenerType, val1, val2, val3) => {
1559
1558
  listener(val1, val2, val3);
1560
1559
  });
1561
1560
  };
1562
- var setFsWatchListener = (path10, fullPath, options, handlers) => {
1561
+ var setFsWatchListener = (path12, fullPath, options, handlers) => {
1563
1562
  const { listener, errHandler, rawEmitter } = handlers;
1564
1563
  let cont = FsWatchInstances.get(fullPath);
1565
1564
  let watcher;
1566
1565
  if (!options.persistent) {
1567
- watcher = createFsWatchInstance(path10, options, listener, errHandler, rawEmitter);
1566
+ watcher = createFsWatchInstance(path12, options, listener, errHandler, rawEmitter);
1568
1567
  if (!watcher)
1569
1568
  return;
1570
1569
  return watcher.close.bind(watcher);
@@ -1575,7 +1574,7 @@ var setFsWatchListener = (path10, fullPath, options, handlers) => {
1575
1574
  addAndConvert(cont, KEY_RAW, rawEmitter);
1576
1575
  } else {
1577
1576
  watcher = createFsWatchInstance(
1578
- path10,
1577
+ path12,
1579
1578
  options,
1580
1579
  fsWatchBroadcast.bind(null, fullPath, KEY_LISTENERS),
1581
1580
  errHandler,
@@ -1590,7 +1589,7 @@ var setFsWatchListener = (path10, fullPath, options, handlers) => {
1590
1589
  cont.watcherUnusable = true;
1591
1590
  if (isWindows && error.code === "EPERM") {
1592
1591
  try {
1593
- const fd = await open(path10, "r");
1592
+ const fd = await open(path12, "r");
1594
1593
  await fd.close();
1595
1594
  broadcastErr(error);
1596
1595
  } catch (err) {
@@ -1621,7 +1620,7 @@ var setFsWatchListener = (path10, fullPath, options, handlers) => {
1621
1620
  };
1622
1621
  };
1623
1622
  var FsWatchFileInstances = /* @__PURE__ */ new Map();
1624
- var setFsWatchFileListener = (path10, fullPath, options, handlers) => {
1623
+ var setFsWatchFileListener = (path12, fullPath, options, handlers) => {
1625
1624
  const { listener, rawEmitter } = handlers;
1626
1625
  let cont = FsWatchFileInstances.get(fullPath);
1627
1626
  const copts = cont && cont.options;
@@ -1643,7 +1642,7 @@ var setFsWatchFileListener = (path10, fullPath, options, handlers) => {
1643
1642
  });
1644
1643
  const currmtime = curr.mtimeMs;
1645
1644
  if (curr.size !== prev.size || currmtime > prev.mtimeMs || currmtime === 0) {
1646
- foreach(cont.listeners, (listener2) => listener2(path10, curr));
1645
+ foreach(cont.listeners, (listener2) => listener2(path12, curr));
1647
1646
  }
1648
1647
  })
1649
1648
  };
@@ -1673,13 +1672,13 @@ var NodeFsHandler = class {
1673
1672
  * @param listener on fs change
1674
1673
  * @returns closer for the watcher instance
1675
1674
  */
1676
- _watchWithNodeFs(path10, listener) {
1675
+ _watchWithNodeFs(path12, listener) {
1677
1676
  const opts = this.fsw.options;
1678
- const directory = sp.dirname(path10);
1679
- const basename4 = sp.basename(path10);
1677
+ const directory = sp.dirname(path12);
1678
+ const basename4 = sp.basename(path12);
1680
1679
  const parent = this.fsw._getWatchedDir(directory);
1681
1680
  parent.add(basename4);
1682
- const absolutePath = sp.resolve(path10);
1681
+ const absolutePath = sp.resolve(path12);
1683
1682
  const options = {
1684
1683
  persistent: opts.persistent
1685
1684
  };
@@ -1689,12 +1688,12 @@ var NodeFsHandler = class {
1689
1688
  if (opts.usePolling) {
1690
1689
  const enableBin = opts.interval !== opts.binaryInterval;
1691
1690
  options.interval = enableBin && isBinaryPath(basename4) ? opts.binaryInterval : opts.interval;
1692
- closer = setFsWatchFileListener(path10, absolutePath, options, {
1691
+ closer = setFsWatchFileListener(path12, absolutePath, options, {
1693
1692
  listener,
1694
1693
  rawEmitter: this.fsw._emitRaw
1695
1694
  });
1696
1695
  } else {
1697
- closer = setFsWatchListener(path10, absolutePath, options, {
1696
+ closer = setFsWatchListener(path12, absolutePath, options, {
1698
1697
  listener,
1699
1698
  errHandler: this._boundHandleError,
1700
1699
  rawEmitter: this.fsw._emitRaw
@@ -1716,7 +1715,7 @@ var NodeFsHandler = class {
1716
1715
  let prevStats = stats;
1717
1716
  if (parent.has(basename4))
1718
1717
  return;
1719
- const listener = async (path10, newStats) => {
1718
+ const listener = async (path12, newStats) => {
1720
1719
  if (!this.fsw._throttle(THROTTLE_MODE_WATCH, file, 5))
1721
1720
  return;
1722
1721
  if (!newStats || newStats.mtimeMs === 0) {
@@ -1730,11 +1729,11 @@ var NodeFsHandler = class {
1730
1729
  this.fsw._emit(EV.CHANGE, file, newStats2);
1731
1730
  }
1732
1731
  if ((isMacos || isLinux || isFreeBSD) && prevStats.ino !== newStats2.ino) {
1733
- this.fsw._closeFile(path10);
1732
+ this.fsw._closeFile(path12);
1734
1733
  prevStats = newStats2;
1735
1734
  const closer2 = this._watchWithNodeFs(file, listener);
1736
1735
  if (closer2)
1737
- this.fsw._addPathCloser(path10, closer2);
1736
+ this.fsw._addPathCloser(path12, closer2);
1738
1737
  } else {
1739
1738
  prevStats = newStats2;
1740
1739
  }
@@ -1766,7 +1765,7 @@ var NodeFsHandler = class {
1766
1765
  * @param item basename of this item
1767
1766
  * @returns true if no more processing is needed for this entry.
1768
1767
  */
1769
- async _handleSymlink(entry, directory, path10, item) {
1768
+ async _handleSymlink(entry, directory, path12, item) {
1770
1769
  if (this.fsw.closed) {
1771
1770
  return;
1772
1771
  }
@@ -1776,7 +1775,7 @@ var NodeFsHandler = class {
1776
1775
  this.fsw._incrReadyCount();
1777
1776
  let linkPath;
1778
1777
  try {
1779
- linkPath = await fsrealpath(path10);
1778
+ linkPath = await fsrealpath(path12);
1780
1779
  } catch (e) {
1781
1780
  this.fsw._emitReady();
1782
1781
  return true;
@@ -1786,12 +1785,12 @@ var NodeFsHandler = class {
1786
1785
  if (dir.has(item)) {
1787
1786
  if (this.fsw._symlinkPaths.get(full) !== linkPath) {
1788
1787
  this.fsw._symlinkPaths.set(full, linkPath);
1789
- this.fsw._emit(EV.CHANGE, path10, entry.stats);
1788
+ this.fsw._emit(EV.CHANGE, path12, entry.stats);
1790
1789
  }
1791
1790
  } else {
1792
1791
  dir.add(item);
1793
1792
  this.fsw._symlinkPaths.set(full, linkPath);
1794
- this.fsw._emit(EV.ADD, path10, entry.stats);
1793
+ this.fsw._emit(EV.ADD, path12, entry.stats);
1795
1794
  }
1796
1795
  this.fsw._emitReady();
1797
1796
  return true;
@@ -1821,9 +1820,9 @@ var NodeFsHandler = class {
1821
1820
  return;
1822
1821
  }
1823
1822
  const item = entry.path;
1824
- let path10 = sp.join(directory, item);
1823
+ let path12 = sp.join(directory, item);
1825
1824
  current.add(item);
1826
- if (entry.stats.isSymbolicLink() && await this._handleSymlink(entry, directory, path10, item)) {
1825
+ if (entry.stats.isSymbolicLink() && await this._handleSymlink(entry, directory, path12, item)) {
1827
1826
  return;
1828
1827
  }
1829
1828
  if (this.fsw.closed) {
@@ -1832,8 +1831,8 @@ var NodeFsHandler = class {
1832
1831
  }
1833
1832
  if (item === target || !target && !previous.has(item)) {
1834
1833
  this.fsw._incrReadyCount();
1835
- path10 = sp.join(dir, sp.relative(dir, path10));
1836
- this._addToNodeFs(path10, initialAdd, wh, depth + 1);
1834
+ path12 = sp.join(dir, sp.relative(dir, path12));
1835
+ this._addToNodeFs(path12, initialAdd, wh, depth + 1);
1837
1836
  }
1838
1837
  }).on(EV.ERROR, this._boundHandleError);
1839
1838
  return new Promise((resolve4, reject) => {
@@ -1902,13 +1901,13 @@ var NodeFsHandler = class {
1902
1901
  * @param depth Child path actually targeted for watch
1903
1902
  * @param target Child path actually targeted for watch
1904
1903
  */
1905
- async _addToNodeFs(path10, initialAdd, priorWh, depth, target) {
1904
+ async _addToNodeFs(path12, initialAdd, priorWh, depth, target) {
1906
1905
  const ready = this.fsw._emitReady;
1907
- if (this.fsw._isIgnored(path10) || this.fsw.closed) {
1906
+ if (this.fsw._isIgnored(path12) || this.fsw.closed) {
1908
1907
  ready();
1909
1908
  return false;
1910
1909
  }
1911
- const wh = this.fsw._getWatchHelpers(path10);
1910
+ const wh = this.fsw._getWatchHelpers(path12);
1912
1911
  if (priorWh) {
1913
1912
  wh.filterPath = (entry) => priorWh.filterPath(entry);
1914
1913
  wh.filterDir = (entry) => priorWh.filterDir(entry);
@@ -1924,8 +1923,8 @@ var NodeFsHandler = class {
1924
1923
  const follow = this.fsw.options.followSymlinks;
1925
1924
  let closer;
1926
1925
  if (stats.isDirectory()) {
1927
- const absPath = sp.resolve(path10);
1928
- const targetPath = follow ? await fsrealpath(path10) : path10;
1926
+ const absPath = sp.resolve(path12);
1927
+ const targetPath = follow ? await fsrealpath(path12) : path12;
1929
1928
  if (this.fsw.closed)
1930
1929
  return;
1931
1930
  closer = await this._handleDir(wh.watchPath, stats, initialAdd, depth, target, wh, targetPath);
@@ -1935,29 +1934,29 @@ var NodeFsHandler = class {
1935
1934
  this.fsw._symlinkPaths.set(absPath, targetPath);
1936
1935
  }
1937
1936
  } else if (stats.isSymbolicLink()) {
1938
- const targetPath = follow ? await fsrealpath(path10) : path10;
1937
+ const targetPath = follow ? await fsrealpath(path12) : path12;
1939
1938
  if (this.fsw.closed)
1940
1939
  return;
1941
1940
  const parent = sp.dirname(wh.watchPath);
1942
1941
  this.fsw._getWatchedDir(parent).add(wh.watchPath);
1943
1942
  this.fsw._emit(EV.ADD, wh.watchPath, stats);
1944
- closer = await this._handleDir(parent, stats, initialAdd, depth, path10, wh, targetPath);
1943
+ closer = await this._handleDir(parent, stats, initialAdd, depth, path12, wh, targetPath);
1945
1944
  if (this.fsw.closed)
1946
1945
  return;
1947
1946
  if (targetPath !== void 0) {
1948
- this.fsw._symlinkPaths.set(sp.resolve(path10), targetPath);
1947
+ this.fsw._symlinkPaths.set(sp.resolve(path12), targetPath);
1949
1948
  }
1950
1949
  } else {
1951
1950
  closer = this._handleFile(wh.watchPath, stats, initialAdd);
1952
1951
  }
1953
1952
  ready();
1954
1953
  if (closer)
1955
- this.fsw._addPathCloser(path10, closer);
1954
+ this.fsw._addPathCloser(path12, closer);
1956
1955
  return false;
1957
1956
  } catch (error) {
1958
1957
  if (this.fsw._handleError(error)) {
1959
1958
  ready();
1960
- return path10;
1959
+ return path12;
1961
1960
  }
1962
1961
  }
1963
1962
  }
@@ -2000,24 +1999,24 @@ function createPattern(matcher) {
2000
1999
  }
2001
2000
  return () => false;
2002
2001
  }
2003
- function normalizePath(path10) {
2004
- if (typeof path10 !== "string")
2002
+ function normalizePath(path12) {
2003
+ if (typeof path12 !== "string")
2005
2004
  throw new Error("string expected");
2006
- path10 = sp2.normalize(path10);
2007
- path10 = path10.replace(/\\/g, "/");
2005
+ path12 = sp2.normalize(path12);
2006
+ path12 = path12.replace(/\\/g, "/");
2008
2007
  let prepend = false;
2009
- if (path10.startsWith("//"))
2008
+ if (path12.startsWith("//"))
2010
2009
  prepend = true;
2011
- path10 = path10.replace(DOUBLE_SLASH_RE, "/");
2010
+ path12 = path12.replace(DOUBLE_SLASH_RE, "/");
2012
2011
  if (prepend)
2013
- path10 = "/" + path10;
2014
- return path10;
2012
+ path12 = "/" + path12;
2013
+ return path12;
2015
2014
  }
2016
2015
  function matchPatterns(patterns, testString, stats) {
2017
- const path10 = normalizePath(testString);
2016
+ const path12 = normalizePath(testString);
2018
2017
  for (let index = 0; index < patterns.length; index++) {
2019
2018
  const pattern = patterns[index];
2020
- if (pattern(path10, stats)) {
2019
+ if (pattern(path12, stats)) {
2021
2020
  return true;
2022
2021
  }
2023
2022
  }
@@ -2055,19 +2054,19 @@ var toUnix = (string) => {
2055
2054
  }
2056
2055
  return str;
2057
2056
  };
2058
- var normalizePathToUnix = (path10) => toUnix(sp2.normalize(toUnix(path10)));
2059
- var normalizeIgnored = (cwd = "") => (path10) => {
2060
- if (typeof path10 === "string") {
2061
- return normalizePathToUnix(sp2.isAbsolute(path10) ? path10 : sp2.join(cwd, path10));
2057
+ var normalizePathToUnix = (path12) => toUnix(sp2.normalize(toUnix(path12)));
2058
+ var normalizeIgnored = (cwd = "") => (path12) => {
2059
+ if (typeof path12 === "string") {
2060
+ return normalizePathToUnix(sp2.isAbsolute(path12) ? path12 : sp2.join(cwd, path12));
2062
2061
  } else {
2063
- return path10;
2062
+ return path12;
2064
2063
  }
2065
2064
  };
2066
- var getAbsolutePath = (path10, cwd) => {
2067
- if (sp2.isAbsolute(path10)) {
2068
- return path10;
2065
+ var getAbsolutePath = (path12, cwd) => {
2066
+ if (sp2.isAbsolute(path12)) {
2067
+ return path12;
2069
2068
  }
2070
- return sp2.join(cwd, path10);
2069
+ return sp2.join(cwd, path12);
2071
2070
  };
2072
2071
  var EMPTY_SET = Object.freeze(/* @__PURE__ */ new Set());
2073
2072
  var DirEntry = class {
@@ -2132,10 +2131,10 @@ var WatchHelper = class {
2132
2131
  dirParts;
2133
2132
  followSymlinks;
2134
2133
  statMethod;
2135
- constructor(path10, follow, fsw) {
2134
+ constructor(path12, follow, fsw) {
2136
2135
  this.fsw = fsw;
2137
- const watchPath = path10;
2138
- this.path = path10 = path10.replace(REPLACER_RE, "");
2136
+ const watchPath = path12;
2137
+ this.path = path12 = path12.replace(REPLACER_RE, "");
2139
2138
  this.watchPath = watchPath;
2140
2139
  this.fullWatchPath = sp2.resolve(watchPath);
2141
2140
  this.dirParts = [];
@@ -2275,20 +2274,20 @@ var FSWatcher = class extends EventEmitter {
2275
2274
  this._closePromise = void 0;
2276
2275
  let paths = unifyPaths(paths_);
2277
2276
  if (cwd) {
2278
- paths = paths.map((path10) => {
2279
- const absPath = getAbsolutePath(path10, cwd);
2277
+ paths = paths.map((path12) => {
2278
+ const absPath = getAbsolutePath(path12, cwd);
2280
2279
  return absPath;
2281
2280
  });
2282
2281
  }
2283
- paths.forEach((path10) => {
2284
- this._removeIgnoredPath(path10);
2282
+ paths.forEach((path12) => {
2283
+ this._removeIgnoredPath(path12);
2285
2284
  });
2286
2285
  this._userIgnored = void 0;
2287
2286
  if (!this._readyCount)
2288
2287
  this._readyCount = 0;
2289
2288
  this._readyCount += paths.length;
2290
- Promise.all(paths.map(async (path10) => {
2291
- const res = await this._nodeFsHandler._addToNodeFs(path10, !_internal, void 0, 0, _origAdd);
2289
+ Promise.all(paths.map(async (path12) => {
2290
+ const res = await this._nodeFsHandler._addToNodeFs(path12, !_internal, void 0, 0, _origAdd);
2292
2291
  if (res)
2293
2292
  this._emitReady();
2294
2293
  return res;
@@ -2310,17 +2309,17 @@ var FSWatcher = class extends EventEmitter {
2310
2309
  return this;
2311
2310
  const paths = unifyPaths(paths_);
2312
2311
  const { cwd } = this.options;
2313
- paths.forEach((path10) => {
2314
- if (!sp2.isAbsolute(path10) && !this._closers.has(path10)) {
2312
+ paths.forEach((path12) => {
2313
+ if (!sp2.isAbsolute(path12) && !this._closers.has(path12)) {
2315
2314
  if (cwd)
2316
- path10 = sp2.join(cwd, path10);
2317
- path10 = sp2.resolve(path10);
2315
+ path12 = sp2.join(cwd, path12);
2316
+ path12 = sp2.resolve(path12);
2318
2317
  }
2319
- this._closePath(path10);
2320
- this._addIgnoredPath(path10);
2321
- if (this._watched.has(path10)) {
2318
+ this._closePath(path12);
2319
+ this._addIgnoredPath(path12);
2320
+ if (this._watched.has(path12)) {
2322
2321
  this._addIgnoredPath({
2323
- path: path10,
2322
+ path: path12,
2324
2323
  recursive: true
2325
2324
  });
2326
2325
  }
@@ -2384,38 +2383,38 @@ var FSWatcher = class extends EventEmitter {
2384
2383
  * @param stats arguments to be passed with event
2385
2384
  * @returns the error if defined, otherwise the value of the FSWatcher instance's `closed` flag
2386
2385
  */
2387
- async _emit(event, path10, stats) {
2386
+ async _emit(event, path12, stats) {
2388
2387
  if (this.closed)
2389
2388
  return;
2390
2389
  const opts = this.options;
2391
2390
  if (isWindows)
2392
- path10 = sp2.normalize(path10);
2391
+ path12 = sp2.normalize(path12);
2393
2392
  if (opts.cwd)
2394
- path10 = sp2.relative(opts.cwd, path10);
2395
- const args = [path10];
2393
+ path12 = sp2.relative(opts.cwd, path12);
2394
+ const args = [path12];
2396
2395
  if (stats != null)
2397
2396
  args.push(stats);
2398
2397
  const awf = opts.awaitWriteFinish;
2399
2398
  let pw;
2400
- if (awf && (pw = this._pendingWrites.get(path10))) {
2399
+ if (awf && (pw = this._pendingWrites.get(path12))) {
2401
2400
  pw.lastChange = /* @__PURE__ */ new Date();
2402
2401
  return this;
2403
2402
  }
2404
2403
  if (opts.atomic) {
2405
2404
  if (event === EVENTS.UNLINK) {
2406
- this._pendingUnlinks.set(path10, [event, ...args]);
2405
+ this._pendingUnlinks.set(path12, [event, ...args]);
2407
2406
  setTimeout(() => {
2408
- this._pendingUnlinks.forEach((entry, path11) => {
2407
+ this._pendingUnlinks.forEach((entry, path13) => {
2409
2408
  this.emit(...entry);
2410
2409
  this.emit(EVENTS.ALL, ...entry);
2411
- this._pendingUnlinks.delete(path11);
2410
+ this._pendingUnlinks.delete(path13);
2412
2411
  });
2413
2412
  }, typeof opts.atomic === "number" ? opts.atomic : 100);
2414
2413
  return this;
2415
2414
  }
2416
- if (event === EVENTS.ADD && this._pendingUnlinks.has(path10)) {
2415
+ if (event === EVENTS.ADD && this._pendingUnlinks.has(path12)) {
2417
2416
  event = EVENTS.CHANGE;
2418
- this._pendingUnlinks.delete(path10);
2417
+ this._pendingUnlinks.delete(path12);
2419
2418
  }
2420
2419
  }
2421
2420
  if (awf && (event === EVENTS.ADD || event === EVENTS.CHANGE) && this._readyEmitted) {
@@ -2433,16 +2432,16 @@ var FSWatcher = class extends EventEmitter {
2433
2432
  this.emitWithAll(event, args);
2434
2433
  }
2435
2434
  };
2436
- this._awaitWriteFinish(path10, awf.stabilityThreshold, event, awfEmit);
2435
+ this._awaitWriteFinish(path12, awf.stabilityThreshold, event, awfEmit);
2437
2436
  return this;
2438
2437
  }
2439
2438
  if (event === EVENTS.CHANGE) {
2440
- const isThrottled = !this._throttle(EVENTS.CHANGE, path10, 50);
2439
+ const isThrottled = !this._throttle(EVENTS.CHANGE, path12, 50);
2441
2440
  if (isThrottled)
2442
2441
  return this;
2443
2442
  }
2444
2443
  if (opts.alwaysStat && stats === void 0 && (event === EVENTS.ADD || event === EVENTS.ADD_DIR || event === EVENTS.CHANGE)) {
2445
- const fullPath = opts.cwd ? sp2.join(opts.cwd, path10) : path10;
2444
+ const fullPath = opts.cwd ? sp2.join(opts.cwd, path12) : path12;
2446
2445
  let stats2;
2447
2446
  try {
2448
2447
  stats2 = await stat7(fullPath);
@@ -2473,23 +2472,23 @@ var FSWatcher = class extends EventEmitter {
2473
2472
  * @param timeout duration of time to suppress duplicate actions
2474
2473
  * @returns tracking object or false if action should be suppressed
2475
2474
  */
2476
- _throttle(actionType, path10, timeout) {
2475
+ _throttle(actionType, path12, timeout) {
2477
2476
  if (!this._throttled.has(actionType)) {
2478
2477
  this._throttled.set(actionType, /* @__PURE__ */ new Map());
2479
2478
  }
2480
2479
  const action = this._throttled.get(actionType);
2481
2480
  if (!action)
2482
2481
  throw new Error("invalid throttle");
2483
- const actionPath = action.get(path10);
2482
+ const actionPath = action.get(path12);
2484
2483
  if (actionPath) {
2485
2484
  actionPath.count++;
2486
2485
  return false;
2487
2486
  }
2488
2487
  let timeoutObject;
2489
2488
  const clear = () => {
2490
- const item = action.get(path10);
2489
+ const item = action.get(path12);
2491
2490
  const count = item ? item.count : 0;
2492
- action.delete(path10);
2491
+ action.delete(path12);
2493
2492
  clearTimeout(timeoutObject);
2494
2493
  if (item)
2495
2494
  clearTimeout(item.timeoutObject);
@@ -2497,7 +2496,7 @@ var FSWatcher = class extends EventEmitter {
2497
2496
  };
2498
2497
  timeoutObject = setTimeout(clear, timeout);
2499
2498
  const thr = { timeoutObject, clear, count: 0 };
2500
- action.set(path10, thr);
2499
+ action.set(path12, thr);
2501
2500
  return thr;
2502
2501
  }
2503
2502
  _incrReadyCount() {
@@ -2511,44 +2510,44 @@ var FSWatcher = class extends EventEmitter {
2511
2510
  * @param event
2512
2511
  * @param awfEmit Callback to be called when ready for event to be emitted.
2513
2512
  */
2514
- _awaitWriteFinish(path10, threshold, event, awfEmit) {
2513
+ _awaitWriteFinish(path12, threshold, event, awfEmit) {
2515
2514
  const awf = this.options.awaitWriteFinish;
2516
2515
  if (typeof awf !== "object")
2517
2516
  return;
2518
2517
  const pollInterval = awf.pollInterval;
2519
2518
  let timeoutHandler;
2520
- let fullPath = path10;
2521
- if (this.options.cwd && !sp2.isAbsolute(path10)) {
2522
- fullPath = sp2.join(this.options.cwd, path10);
2519
+ let fullPath = path12;
2520
+ if (this.options.cwd && !sp2.isAbsolute(path12)) {
2521
+ fullPath = sp2.join(this.options.cwd, path12);
2523
2522
  }
2524
2523
  const now = /* @__PURE__ */ new Date();
2525
2524
  const writes = this._pendingWrites;
2526
2525
  function awaitWriteFinishFn(prevStat) {
2527
2526
  statcb(fullPath, (err, curStat) => {
2528
- if (err || !writes.has(path10)) {
2527
+ if (err || !writes.has(path12)) {
2529
2528
  if (err && err.code !== "ENOENT")
2530
2529
  awfEmit(err);
2531
2530
  return;
2532
2531
  }
2533
2532
  const now2 = Number(/* @__PURE__ */ new Date());
2534
2533
  if (prevStat && curStat.size !== prevStat.size) {
2535
- writes.get(path10).lastChange = now2;
2534
+ writes.get(path12).lastChange = now2;
2536
2535
  }
2537
- const pw = writes.get(path10);
2536
+ const pw = writes.get(path12);
2538
2537
  const df = now2 - pw.lastChange;
2539
2538
  if (df >= threshold) {
2540
- writes.delete(path10);
2539
+ writes.delete(path12);
2541
2540
  awfEmit(void 0, curStat);
2542
2541
  } else {
2543
2542
  timeoutHandler = setTimeout(awaitWriteFinishFn, pollInterval, curStat);
2544
2543
  }
2545
2544
  });
2546
2545
  }
2547
- if (!writes.has(path10)) {
2548
- writes.set(path10, {
2546
+ if (!writes.has(path12)) {
2547
+ writes.set(path12, {
2549
2548
  lastChange: now,
2550
2549
  cancelWait: () => {
2551
- writes.delete(path10);
2550
+ writes.delete(path12);
2552
2551
  clearTimeout(timeoutHandler);
2553
2552
  return event;
2554
2553
  }
@@ -2559,8 +2558,8 @@ var FSWatcher = class extends EventEmitter {
2559
2558
  /**
2560
2559
  * Determines whether user has asked to ignore this path.
2561
2560
  */
2562
- _isIgnored(path10, stats) {
2563
- if (this.options.atomic && DOT_RE.test(path10))
2561
+ _isIgnored(path12, stats) {
2562
+ if (this.options.atomic && DOT_RE.test(path12))
2564
2563
  return true;
2565
2564
  if (!this._userIgnored) {
2566
2565
  const { cwd } = this.options;
@@ -2570,17 +2569,17 @@ var FSWatcher = class extends EventEmitter {
2570
2569
  const list = [...ignoredPaths.map(normalizeIgnored(cwd)), ...ignored];
2571
2570
  this._userIgnored = anymatch(list, void 0);
2572
2571
  }
2573
- return this._userIgnored(path10, stats);
2572
+ return this._userIgnored(path12, stats);
2574
2573
  }
2575
- _isntIgnored(path10, stat9) {
2576
- return !this._isIgnored(path10, stat9);
2574
+ _isntIgnored(path12, stat10) {
2575
+ return !this._isIgnored(path12, stat10);
2577
2576
  }
2578
2577
  /**
2579
2578
  * Provides a set of common helpers and properties relating to symlink handling.
2580
2579
  * @param path file or directory pattern being watched
2581
2580
  */
2582
- _getWatchHelpers(path10) {
2583
- return new WatchHelper(path10, this.options.followSymlinks, this);
2581
+ _getWatchHelpers(path12) {
2582
+ return new WatchHelper(path12, this.options.followSymlinks, this);
2584
2583
  }
2585
2584
  // Directory helpers
2586
2585
  // -----------------
@@ -2612,63 +2611,63 @@ var FSWatcher = class extends EventEmitter {
2612
2611
  * @param item base path of item/directory
2613
2612
  */
2614
2613
  _remove(directory, item, isDirectory) {
2615
- const path10 = sp2.join(directory, item);
2616
- const fullPath = sp2.resolve(path10);
2617
- isDirectory = isDirectory != null ? isDirectory : this._watched.has(path10) || this._watched.has(fullPath);
2618
- if (!this._throttle("remove", path10, 100))
2614
+ const path12 = sp2.join(directory, item);
2615
+ const fullPath = sp2.resolve(path12);
2616
+ isDirectory = isDirectory != null ? isDirectory : this._watched.has(path12) || this._watched.has(fullPath);
2617
+ if (!this._throttle("remove", path12, 100))
2619
2618
  return;
2620
2619
  if (!isDirectory && this._watched.size === 1) {
2621
2620
  this.add(directory, item, true);
2622
2621
  }
2623
- const wp = this._getWatchedDir(path10);
2622
+ const wp = this._getWatchedDir(path12);
2624
2623
  const nestedDirectoryChildren = wp.getChildren();
2625
- nestedDirectoryChildren.forEach((nested) => this._remove(path10, nested));
2624
+ nestedDirectoryChildren.forEach((nested) => this._remove(path12, nested));
2626
2625
  const parent = this._getWatchedDir(directory);
2627
2626
  const wasTracked = parent.has(item);
2628
2627
  parent.remove(item);
2629
2628
  if (this._symlinkPaths.has(fullPath)) {
2630
2629
  this._symlinkPaths.delete(fullPath);
2631
2630
  }
2632
- let relPath = path10;
2631
+ let relPath = path12;
2633
2632
  if (this.options.cwd)
2634
- relPath = sp2.relative(this.options.cwd, path10);
2633
+ relPath = sp2.relative(this.options.cwd, path12);
2635
2634
  if (this.options.awaitWriteFinish && this._pendingWrites.has(relPath)) {
2636
2635
  const event = this._pendingWrites.get(relPath).cancelWait();
2637
2636
  if (event === EVENTS.ADD)
2638
2637
  return;
2639
2638
  }
2640
- this._watched.delete(path10);
2639
+ this._watched.delete(path12);
2641
2640
  this._watched.delete(fullPath);
2642
2641
  const eventName = isDirectory ? EVENTS.UNLINK_DIR : EVENTS.UNLINK;
2643
- if (wasTracked && !this._isIgnored(path10))
2644
- this._emit(eventName, path10);
2645
- this._closePath(path10);
2642
+ if (wasTracked && !this._isIgnored(path12))
2643
+ this._emit(eventName, path12);
2644
+ this._closePath(path12);
2646
2645
  }
2647
2646
  /**
2648
2647
  * Closes all watchers for a path
2649
2648
  */
2650
- _closePath(path10) {
2651
- this._closeFile(path10);
2652
- const dir = sp2.dirname(path10);
2653
- this._getWatchedDir(dir).remove(sp2.basename(path10));
2649
+ _closePath(path12) {
2650
+ this._closeFile(path12);
2651
+ const dir = sp2.dirname(path12);
2652
+ this._getWatchedDir(dir).remove(sp2.basename(path12));
2654
2653
  }
2655
2654
  /**
2656
2655
  * Closes only file-specific watchers
2657
2656
  */
2658
- _closeFile(path10) {
2659
- const closers = this._closers.get(path10);
2657
+ _closeFile(path12) {
2658
+ const closers = this._closers.get(path12);
2660
2659
  if (!closers)
2661
2660
  return;
2662
2661
  closers.forEach((closer) => closer());
2663
- this._closers.delete(path10);
2662
+ this._closers.delete(path12);
2664
2663
  }
2665
- _addPathCloser(path10, closer) {
2664
+ _addPathCloser(path12, closer) {
2666
2665
  if (!closer)
2667
2666
  return;
2668
- let list = this._closers.get(path10);
2667
+ let list = this._closers.get(path12);
2669
2668
  if (!list) {
2670
2669
  list = [];
2671
- this._closers.set(path10, list);
2670
+ this._closers.set(path12, list);
2672
2671
  }
2673
2672
  list.push(closer);
2674
2673
  }
@@ -2925,17 +2924,314 @@ var watchCommand = new Command10("watch").description(
2925
2924
  await startWatcher();
2926
2925
  });
2927
2926
 
2927
+ // src/core/init.ts
2928
+ import * as fs10 from "fs/promises";
2929
+ import * as path10 from "path";
2930
+ import { Command as Command11 } from "commander";
2931
+ import enquirer2 from "enquirer";
2932
+ import chalk11 from "chalk";
2933
+ import { $ as $8 } from "execa";
2934
+ import { findWorkspacesRoot as findWorkspacesRoot3 } from "find-workspaces";
2935
+ var initCommand = new Command11("init").description("Initializes the package with the required configuration files").action(async () => {
2936
+ const cwd = process.cwd();
2937
+ const pkgJsonPath = path10.join(cwd, "package.json");
2938
+ try {
2939
+ const pkgExists = await fs10.stat(pkgJsonPath).then(() => true).catch(() => false);
2940
+ if (!pkgExists) {
2941
+ throw new Error("No package.json found in the current directory.");
2942
+ }
2943
+ const packageJsonContent = await fs10.readFile(pkgJsonPath, "utf8");
2944
+ const packageJson = JSON.parse(packageJsonContent);
2945
+ const { builder } = await enquirer2.prompt({
2946
+ type: "select",
2947
+ name: "builder",
2948
+ message: "Which bundler would you like to use?",
2949
+ choices: ["babel", "esbuild"]
2950
+ });
2951
+ const { buildDir } = await enquirer2.prompt({
2952
+ type: "input",
2953
+ name: "buildDir",
2954
+ message: "What is your build output directory?",
2955
+ initial: "build"
2956
+ });
2957
+ const { dts } = await enquirer2.prompt({
2958
+ type: "confirm",
2959
+ name: "dts",
2960
+ message: "Want .d.ts output also",
2961
+ initial: true
2962
+ });
2963
+ let esbuildEntry = "src/index.ts";
2964
+ if (builder === "esbuild") {
2965
+ const response = await enquirer2.prompt({
2966
+ type: "input",
2967
+ name: "entry",
2968
+ message: "What is your esbuild entry point?",
2969
+ initial: "src/index.ts"
2970
+ });
2971
+ esbuildEntry = response.entry;
2972
+ }
2973
+ console.log(chalk11.blue("\n\u2699\uFE0F Applying configuration..."));
2974
+ packageJson.publishConfig = packageJson.publishConfig || {};
2975
+ packageJson.publishConfig.directory = buildDir;
2976
+ await fs10.writeFile(
2977
+ pkgJsonPath,
2978
+ JSON.stringify(packageJson, null, 2) + "\n",
2979
+ "utf8"
2980
+ );
2981
+ console.log(
2982
+ chalk11.gray(
2983
+ `\u{1F4DD} Updated publishConfig.directory to "${buildDir}" in package.json`
2984
+ )
2985
+ );
2986
+ const configPath = path10.join(cwd, "sse.config.ts");
2987
+ let configContent = `import { defineConfig } from "@sse-ui/builder/config";
2988
+
2989
+ export default defineConfig({
2990
+ `;
2991
+ if (builder === "esbuild") {
2992
+ configContent += ` bundle: ["esm", "cjs"],
2993
+ `;
2994
+ configContent += ` buildTypes: ${dts},
2995
+ `;
2996
+ configContent += ` esbuild: {
2997
+ entry: "${esbuildEntry}",
2998
+ external: [],
2999
+ },
3000
+ `;
3001
+ } else {
3002
+ configContent += ` bundle: ["esm", "cjs"],
3003
+ `;
3004
+ configContent += ` buildTypes: ${dts},
3005
+ `;
3006
+ configContent += ` babel: {
3007
+ // enableReactCompiler: false
3008
+ // }
3009
+ `;
3010
+ }
3011
+ configContent += `});
3012
+ `;
3013
+ await fs10.writeFile(configPath, configContent, "utf8");
3014
+ console.log(chalk11.gray(`\u{1F4DD} Created sse.config.ts`));
3015
+ const tsconfigBuildPath = path10.join(cwd, "tsconfig.build.json");
3016
+ const tsconfigBuildExists = await fs10.stat(tsconfigBuildPath).then(() => true).catch(() => false);
3017
+ if (!tsconfigBuildExists) {
3018
+ await fs10.writeFile(
3019
+ tsconfigBuildPath,
3020
+ `{
3021
+ "extends": "./tsconfig.json",
3022
+ , "compilerOptions": {
3023
+ "types": [],
3024
+ }}
3025
+ `,
3026
+ "utf8"
3027
+ );
3028
+ console.log(chalk11.gray(`\u{1F4DD} Created tsconfig.build.json`));
3029
+ }
3030
+ if (builder === "babel") {
3031
+ const workspaceDir = await findWorkspacesRoot3(cwd);
3032
+ const rootDir = workspaceDir ? workspaceDir.location : cwd;
3033
+ let hasBabelConfig = false;
3034
+ for (const ext of [".js", ".mjs"]) {
3035
+ if (await fs10.stat(path10.join(rootDir, `babel.config${ext}`)).then(() => true).catch(() => false)) {
3036
+ hasBabelConfig = true;
3037
+ break;
3038
+ }
3039
+ }
3040
+ if (!hasBabelConfig) {
3041
+ const babelConfigPath = path10.join(rootDir, "babel.config.mjs");
3042
+ const babelConfigContent = `import getBaseConfig from "@sse-ui/builder/babel-config";
3043
+
3044
+ export default function getBabelConfig(api) {
3045
+ const baseConfig = getBaseConfig(api);
3046
+
3047
+ return {
3048
+ ...baseConfig,
3049
+ // Add custom overrides here if needed
3050
+ };
3051
+ }
3052
+ `;
3053
+ await fs10.writeFile(babelConfigPath, babelConfigContent, "utf8");
3054
+ console.log(
3055
+ chalk11.gray(
3056
+ `\u{1F4DD} Created babel.config.mjs in ${workspaceDir ? "workspace root" : "project root"}`
3057
+ )
3058
+ );
3059
+ } else {
3060
+ console.log(
3061
+ chalk11.gray(
3062
+ `\u2139\uFE0F Babel config already exists in ${workspaceDir ? "workspace root" : "project root"}, skipping creation.`
3063
+ )
3064
+ );
3065
+ }
3066
+ const pm = getPackageManager();
3067
+ console.log(
3068
+ chalk11.cyan(`
3069
+ \u23F3 Installing @babel/runtime using ${pm}...`)
3070
+ );
3071
+ try {
3072
+ const ora = (await import("ora")).default;
3073
+ const spinner = ora(`Installing dependencies...`).start();
3074
+ if (pm === "yarn") {
3075
+ await $8`${pm} add @babel/runtime`;
3076
+ } else {
3077
+ await $8`${pm} install @babel/runtime`;
3078
+ }
3079
+ spinner.succeed("Installed @babel/runtime successfully");
3080
+ } catch (installError) {
3081
+ console.log(chalk11.gray(`Falling back to silent install...`));
3082
+ const args = pm === "yarn" ? ["add", "@babel/runtime"] : ["install", "@babel/runtime"];
3083
+ await $8({ stdio: "ignore" })`${pm} ${args}`;
3084
+ console.log(chalk11.green(`\u2705 Installed @babel/runtime successfully`));
3085
+ }
3086
+ }
3087
+ console.log(
3088
+ chalk11.green.bold(
3089
+ "\n\u2728 Initialization complete! You are ready to build."
3090
+ )
3091
+ );
3092
+ } catch (error) {
3093
+ console.error(chalk11.red("\n\u274C Error initializing project:"));
3094
+ if (error instanceof Error) {
3095
+ console.error(chalk11.red(error.message));
3096
+ }
3097
+ process.exit(1);
3098
+ }
3099
+ });
3100
+
3101
+ // src/core/remove.ts
3102
+ import * as fs11 from "fs/promises";
3103
+ import * as path11 from "path";
3104
+ import { Command as Command12 } from "commander";
3105
+ import enquirer3 from "enquirer";
3106
+ import chalk12 from "chalk";
3107
+ import { $ as $9 } from "execa";
3108
+ import { findWorkspacesRoot as findWorkspacesRoot4 } from "find-workspaces";
3109
+ var removeCommand = new Command12("remove").description(
3110
+ "Removes all configuration files and dependencies added by the init command"
3111
+ ).action(async () => {
3112
+ const cwd = process.cwd();
3113
+ const pkgJsonPath = path11.join(cwd, "package.json");
3114
+ try {
3115
+ const { confirm } = await enquirer3.prompt({
3116
+ type: "confirm",
3117
+ name: "confirm",
3118
+ message: chalk12.yellow(
3119
+ "Are you sure you want to remove all sse-tools configurations and the build directory?"
3120
+ ),
3121
+ initial: false
3122
+ });
3123
+ if (!confirm) {
3124
+ console.log(chalk12.gray("Operation cancelled."));
3125
+ return;
3126
+ }
3127
+ console.log(
3128
+ chalk12.blue("\n\u{1F9F9} Removing configurations and build files...")
3129
+ );
3130
+ const configExts = [".ts", ".js", ".mjs", ".cjs"];
3131
+ for (const ext of configExts) {
3132
+ const configPath = path11.join(cwd, `sse.config${ext}`);
3133
+ try {
3134
+ await fs11.unlink(configPath);
3135
+ console.log(chalk12.gray(`\u{1F5D1}\uFE0F Removed sse.config${ext}`));
3136
+ } catch (e) {
3137
+ }
3138
+ }
3139
+ try {
3140
+ await fs11.unlink(path11.join(cwd, "tsconfig.build.json"));
3141
+ console.log(chalk12.gray(`\u{1F5D1}\uFE0F Removed tsconfig.build.json`));
3142
+ } catch (e) {
3143
+ }
3144
+ try {
3145
+ const workspaceDir = await findWorkspacesRoot4(cwd);
3146
+ const rootDir = workspaceDir ? workspaceDir.location : cwd;
3147
+ const babelConfigPath = path11.join(rootDir, "babel.config.mjs");
3148
+ const content = await fs11.readFile(babelConfigPath, "utf8");
3149
+ if (content.includes("@sse-ui/builder/babel-config")) {
3150
+ await fs11.unlink(babelConfigPath);
3151
+ console.log(
3152
+ chalk12.gray(
3153
+ `\u{1F5D1}\uFE0F Removed babel.config.mjs from ${workspaceDir ? "workspace root" : "project root"}`
3154
+ )
3155
+ );
3156
+ }
3157
+ } catch (e) {
3158
+ }
3159
+ try {
3160
+ const packageJsonContent = await fs11.readFile(pkgJsonPath, "utf8");
3161
+ const packageJson = JSON.parse(packageJsonContent);
3162
+ let pkgModified = false;
3163
+ const buildDirBase = packageJson.publishConfig?.directory || "build";
3164
+ const buildDir = path11.join(cwd, buildDirBase);
3165
+ try {
3166
+ await fs11.rm(buildDir, { recursive: true, force: true });
3167
+ console.log(
3168
+ chalk12.gray(`\u{1F5D1}\uFE0F Removed build directory: ./${buildDirBase}`)
3169
+ );
3170
+ } catch (e) {
3171
+ }
3172
+ if (packageJson.publishConfig?.directory) {
3173
+ delete packageJson.publishConfig.directory;
3174
+ if (Object.keys(packageJson.publishConfig).length === 0) {
3175
+ delete packageJson.publishConfig;
3176
+ }
3177
+ pkgModified = true;
3178
+ console.log(
3179
+ chalk12.gray(`\u{1F4DD} Removed publishConfig.directory from package.json`)
3180
+ );
3181
+ }
3182
+ if (pkgModified) {
3183
+ await fs11.writeFile(
3184
+ pkgJsonPath,
3185
+ JSON.stringify(packageJson, null, 2) + "\n",
3186
+ "utf8"
3187
+ );
3188
+ }
3189
+ const hasBabelRuntime = packageJson.dependencies?.["@babel/runtime"] || packageJson.devDependencies?.["@babel/runtime"];
3190
+ if (hasBabelRuntime) {
3191
+ const pm = getPackageManager();
3192
+ console.log(
3193
+ chalk12.cyan(`
3194
+ \u23F3 Uninstalling @babel/runtime using ${pm}...`)
3195
+ );
3196
+ const args = pm === "yarn" ? ["remove", "@babel/runtime"] : ["uninstall", "@babel/runtime"];
3197
+ try {
3198
+ const ora = (await import("ora")).default;
3199
+ const spinner = ora(`Uninstalling dependencies...`).start();
3200
+ await $9({ stdio: "ignore" })`${pm} ${args}`;
3201
+ spinner.succeed("Uninstalled @babel/runtime successfully");
3202
+ } catch (err) {
3203
+ console.log(chalk12.gray(`Falling back to silent uninstall...`));
3204
+ await $9({ stdio: "ignore" })`${pm} ${args}`;
3205
+ console.log(
3206
+ chalk12.green(`\u2705 Uninstalled @babel/runtime successfully`)
3207
+ );
3208
+ }
3209
+ }
3210
+ } catch (e) {
3211
+ console.error(chalk12.red("\u26A0\uFE0F Could not read or update package.json"));
3212
+ }
3213
+ console.log(chalk12.green.bold("\n\u2728 Clean up complete!"));
3214
+ } catch (error) {
3215
+ console.error(chalk12.red("\n\u274C Error removing configuration:"));
3216
+ if (error instanceof Error) {
3217
+ console.error(chalk12.red(error.message));
3218
+ }
3219
+ process.exit(1);
3220
+ }
3221
+ });
3222
+
2928
3223
  // src/cli.ts
2929
3224
  async function main() {
2930
- const program = new Command11();
3225
+ const program = new Command13();
2931
3226
  program.name("sse-tools").description(
2932
- chalk11.cyan("CLI utilities for managing and building SSE packages")
3227
+ chalk13.cyan("CLI utilities for managing and building SSE packages")
2933
3228
  ).version("1.0.0").option("-v, --verbose", "Enable verbose logging across all commands");
2934
3229
  program.hook("preAction", (thisCommand) => {
2935
3230
  if (thisCommand.opts().verbose) {
2936
3231
  process.env.SSE_BUILD_VERBOSE = "true";
2937
3232
  }
2938
3233
  });
3234
+ program.addCommand(initCommand);
2939
3235
  program.addCommand(buildCommand);
2940
3236
  program.addCommand(publishCommand);
2941
3237
  program.addCommand(cleanCommand);
@@ -2946,6 +3242,7 @@ async function main() {
2946
3242
  program.addCommand(linkCommand);
2947
3243
  program.addCommand(checkExportsCommand);
2948
3244
  program.addCommand(watchCommand);
3245
+ program.addCommand(removeCommand);
2949
3246
  try {
2950
3247
  await program.parseAsync(process.argv);
2951
3248
  } catch (error) {