@catalystsoftware/ui 1.0.17 → 1.0.19

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.
Files changed (2) hide show
  1. package/dist/index.js +311 -171
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -200582,6 +200582,7 @@ import { pathToFileURL } from "url";
200582
200582
  var SOURCE_COMPONENTS_FOLDER = "./dist/components/catalyst-ui";
200583
200583
  var SOURCE_DATA_FOLDER = "./dist/components/catalyst-ui/data";
200584
200584
  var DEFAULT_CONFIG = {
200585
+ version: "1.0.124",
200585
200586
  theme: "blue",
200586
200587
  preset: "MODERN",
200587
200588
  font: "Geist",
@@ -200594,37 +200595,6 @@ var DEFAULT_CONFIG = {
200594
200595
  css: "app/routes/styles/tailwind.css",
200595
200596
  components: "app/"
200596
200597
  };
200597
- async function loadConfig() {
200598
- const configPath = path2.join(process.cwd(), "config.catalyst");
200599
- try {
200600
- await fs.access(configPath);
200601
- const content = await fs.readFile(configPath, "utf-8");
200602
- const jsonContent = content.replace(/\/\/.*$/gm, "").replace(/\/\*[\s\S]*?\*\//g, "");
200603
- const config = JSON.parse(jsonContent);
200604
- return { ...DEFAULT_CONFIG, ...config };
200605
- } catch {
200606
- return null;
200607
- }
200608
- }
200609
- async function createConfig() {
200610
- const configPath = path2.join(process.cwd(), "config.catalyst");
200611
- const configContent = `
200612
- {
200613
- "theme": "blue",
200614
- "preset": "MODERN",
200615
- "font": "Geist",
200616
- "all-components": false,
200617
- "install-tailwind": true,
200618
- "configure-tailwind": true,
200619
- "configure-tailwind.config": true,
200620
- "install-postcss": true,
200621
- "configure-postcss": true,
200622
- "css": "app/routes/styles/tailwind.css",
200623
- "components": "app/"
200624
- }`;
200625
- await fs.writeFile(configPath, configContent, "utf-8");
200626
- console.log(source_default.green("\u2713 Created config.catalyst"));
200627
- }
200628
200598
  var API_URL = "https://catalyst-software.vercel.app/Catalyst/UI/code/verify/premium";
200629
200599
  var API_TIMEOUT = 5000;
200630
200600
  function hashKey(key) {
@@ -200759,41 +200729,37 @@ async function getComponentsData(includePremium) {
200759
200729
  throw error;
200760
200730
  }
200761
200731
  }
200762
- async function installSpecificComponent(componentName, isPremium, config) {
200732
+ async function installSpecificComponent(componentName, isPremium, targetPath, config) {
200763
200733
  const components = await getComponentsData(isPremium);
200764
200734
  const component = components.find((c) => c.value === componentName || c.name.toLowerCase() === componentName.toLowerCase());
200765
- if (!component) {
200735
+ if (!component)
200766
200736
  throw new Error(`Component "${componentName}" not found`);
200767
- }
200768
- if (component.premium && !isPremium) {
200769
- throw new Error(`Component "${componentName}" is premium only. Use a valid access key to install.`);
200770
- }
200771
- await createComponentFile(component, config);
200737
+ await createComponentFile(component, targetPath, config);
200772
200738
  const sourceFullPath = path2.join(SOURCE_COMPONENTS_FOLDER, component.path);
200773
200739
  const content = await fs.readFile(sourceFullPath, "utf-8");
200774
200740
  const dependencies = extractImportsFromFile(content, component.path);
200775
200741
  if (dependencies.size > 0) {
200776
- await installDependencies(Array.from(dependencies));
200742
+ await installDependencies(Array.from(dependencies), targetPath);
200777
200743
  }
200778
- await ensureUtilsFile(config);
200744
+ await ensureUtilsFile(targetPath, config);
200779
200745
  }
200780
- async function createComponentFile(component, config) {
200746
+ async function createComponentFile(component, targetPath, config) {
200781
200747
  const componentsBase = config?.components || "app/";
200782
200748
  const sourcePath = component.path;
200783
- const targetPath = path2.join(process.cwd(), componentsBase, sourcePath.replace(/^\/?(app\/)?/, ""));
200784
- await fs.mkdir(path2.dirname(targetPath), { recursive: true });
200749
+ const destPath = path2.join(targetPath, componentsBase, sourcePath.replace(/^\/?(app\/)?/, ""));
200750
+ await fs.mkdir(path2.dirname(destPath), { recursive: true });
200785
200751
  const sourceFullPath = path2.join(SOURCE_COMPONENTS_FOLDER, sourcePath);
200786
200752
  const content = await fs.readFile(sourceFullPath, "utf-8");
200787
- await fs.writeFile(targetPath, content, "utf-8");
200788
- console.log(source_default.green(`\u2713 Created ${path2.relative(process.cwd(), targetPath)}`));
200753
+ await fs.writeFile(destPath, content, "utf-8");
200754
+ console.log(source_default.green(`\u2713 Created ${path2.relative(targetPath, destPath)}`));
200789
200755
  }
200790
- async function installAllComponents(includePremium, config) {
200756
+ async function installAllComponents(includePremium, targetPath, config) {
200791
200757
  const components = await getComponentsData(includePremium);
200792
200758
  const spinner = ora2({ frames: ["\u28F7", "\u28EF", "\u28DF", "\u287F", "\u28BF", "\u28FB", "\u28FD", "\u28FE"], suffixText: `Installing ${components.length} components...` }).start();
200793
200759
  let installed = 0;
200794
200760
  for (const component of components) {
200795
200761
  try {
200796
- await createComponentFile(component, config);
200762
+ await createComponentFile(component, targetPath, config);
200797
200763
  installed++;
200798
200764
  spinner.text = `Installing components... (${installed}/${components.length})`;
200799
200765
  } catch (error) {
@@ -200802,21 +200768,26 @@ async function installAllComponents(includePremium, config) {
200802
200768
  }
200803
200769
  }
200804
200770
  spinner.succeed(source_default.green(`Installed ${installed} components`));
200805
- await createIndexFiles();
200806
- await configureProjectPaths();
200771
+ await createIndexFiles(targetPath, config);
200772
+ await configureProjectPaths(targetPath, config);
200807
200773
  }
200808
- async function createIndexFiles() {
200809
- const spinner = ora2({ frames: ["\u28F7", "\u28EF", "\u28DF", "\u287F", "\u28BF", "\u28FB", "\u28FD", "\u28FE"], suffixText: "Creating index files..." }).start();
200810
- const componentsDir = path2.join(process.cwd(), "components", "catalyst-ui");
200811
- const folders = await fs.readdir(componentsDir, { withFileTypes: true });
200812
- for (const folder of folders) {
200813
- if (folder.isDirectory()) {
200814
- const folderPath = path2.join(componentsDir, folder.name);
200815
- await createIndexForFolder(folderPath);
200816
- }
200817
- }
200818
- await createMainIndex(componentsDir);
200819
- spinner.succeed(source_default.green("Created index files"));
200774
+ async function createIndexFiles(targetPath, config) {
200775
+ const spinner = ora2("Creating index files...").start();
200776
+ const componentsBase = config?.components || "app/";
200777
+ const componentsDir = path2.join(targetPath, componentsBase, "components", "catalyst-ui");
200778
+ try {
200779
+ const folders = await fs.readdir(componentsDir, { withFileTypes: true });
200780
+ for (const folder of folders) {
200781
+ if (folder.isDirectory()) {
200782
+ const folderPath = path2.join(componentsDir, folder.name);
200783
+ await createIndexForFolder(folderPath);
200784
+ }
200785
+ }
200786
+ await createMainIndex(componentsDir);
200787
+ spinner.succeed(source_default.green("Created index files"));
200788
+ } catch (e) {
200789
+ spinner.fail(source_default.red("Index creation failed"));
200790
+ }
200820
200791
  }
200821
200792
  async function createMainIndex(componentsDir) {
200822
200793
  try {
@@ -200866,28 +200837,24 @@ function generateIndexContent(files, basePath) {
200866
200837
  `) + `
200867
200838
  `;
200868
200839
  }
200869
- async function installDependencies(deps) {
200870
- const spinner = ora2({ frames: ["\u28F7", "\u28EF", "\u28DF", "\u287F", "\u28BF", "\u28FB", "\u28FD", "\u28FE"], suffixText: "Installing dependencies..." }).start();
200840
+ async function installDependencies(deps, targetPath) {
200841
+ const spinner = ora2("Installing dependencies...").start();
200871
200842
  try {
200872
- const packageManager = await detectPackageManager();
200843
+ const packageManager = await detectPackageManager(targetPath);
200873
200844
  const installCmd = packageManager === "npm" ? "install" : "add";
200874
- execSync(`${packageManager} ${installCmd} ${deps.join(" ")}`, {
200875
- stdio: "inherit",
200876
- cwd: process.cwd()
200877
- });
200845
+ execSync(`${packageManager} ${installCmd} ${deps.join(" ")}`, { stdio: "inherit", cwd: targetPath });
200878
200846
  spinner.succeed(source_default.green("Dependencies installed"));
200879
200847
  } catch (error) {
200880
- spinner.fail(source_default.red("Failed to install dependencies"));
200881
- throw error;
200848
+ spinner.fail(source_default.red("Dependency installation failed"));
200882
200849
  }
200883
200850
  }
200884
- async function detectPackageManager() {
200851
+ async function detectPackageManager(targetPath) {
200885
200852
  try {
200886
- await fs.access(path2.join(process.cwd(), "pnpm-lock.yaml"));
200853
+ await fs.access(path2.join(targetPath, "pnpm-lock.yaml"));
200887
200854
  return "pnpm";
200888
200855
  } catch {}
200889
200856
  try {
200890
- await fs.access(path2.join(process.cwd(), "yarn.lock"));
200857
+ await fs.access(path2.join(targetPath, "yarn.lock"));
200891
200858
  return "yarn";
200892
200859
  } catch {}
200893
200860
  return "npm";
@@ -200912,86 +200879,78 @@ function extractImportsFromFile(fileContent, filename) {
200912
200879
  visit(sourceFile);
200913
200880
  return imports;
200914
200881
  }
200915
- async function installAllLibraries(includeAll) {
200882
+ async function installAllLibraries(includeAll, targetPath) {
200916
200883
  const libsPath = path2.join(SOURCE_DATA_FOLDER, "requiredLibs.ts");
200917
200884
  const { requiredLibs, requiredLibsAll } = await import(libsPath);
200918
200885
  const libs = includeAll ? requiredLibsAll : requiredLibs;
200919
- await installDependencies(libs.split(" "));
200886
+ await installDependencies(libs.split(" "), targetPath);
200920
200887
  }
200921
- async function ensureUtilsFile(config) {
200888
+ async function ensureUtilsFile(targetPath, config) {
200922
200889
  const componentsBase = config?.components || "app/";
200923
- const utilsPath = path2.join(process.cwd(), componentsBase, "components", "catalyst-ui", "utils", "utils.ts");
200890
+ const utilsDest = path2.join(targetPath, componentsBase, "components", "catalyst-ui", "utils", "utils.ts");
200924
200891
  try {
200925
- await fs.access(utilsPath);
200892
+ await fs.access(utilsDest);
200926
200893
  return;
200927
200894
  } catch {}
200928
- await fs.mkdir(path2.dirname(utilsPath), { recursive: true });
200929
- const sourceUtilsPath = path2.join(SOURCE_COMPONENTS_FOLDER, "utils", "utils.ts");
200930
- await fs.copyFile(sourceUtilsPath, utilsPath);
200931
- console.log(source_default.green(`\u2713 Created ${path2.relative(process.cwd(), utilsPath)}`));
200932
- }
200933
- async function configureTailwind(useNgin, config) {
200934
- const spinner = ora2({ frames: ["\u28F7", "\u28EF", "\u28DF", "\u287F", "\u28BF", "\u28FB", "\u28FD", "\u28FE"], suffixText: "Configuring Tailwind..." }).start();
200935
- if (config?.["configure-tailwind"]) {
200936
- const tailwindCssPath = config.css || "app/routes/styles/tailwind.css";
200937
- await copyFile(path2.join(SOURCE_DATA_FOLDER, "tailwind.css"), path2.join(process.cwd(), tailwindCssPath));
200938
- } else {
200939
- const tailwindCssPath = await getTailwindCssPath();
200940
- await copyFile(path2.join(SOURCE_DATA_FOLDER, "tailwind.css"), tailwindCssPath);
200941
- }
200942
- if (config?.["configure-tailwind.config"] !== false) {
200943
- const configType = config?.["configure-tailwind.config"] === "ngin" ? "ngin" : useNgin ? "ngin" : "basic";
200944
- const configFileName = configType === "ngin" ? "tailwind.config.ngin.js" : "tailwind.config.js";
200945
- await copyFile(path2.join(SOURCE_DATA_FOLDER, configFileName), path2.join(process.cwd(), "tailwind.config.js"));
200946
- }
200947
- if (config?.["configure-postcss"]) {
200948
- await copyFile(path2.join(SOURCE_DATA_FOLDER, "postcss.config.js"), path2.join(process.cwd(), "postcss.config.js"));
200949
- }
200950
- spinner.succeed(source_default.green("Tailwind configured"));
200895
+ await fs.mkdir(path2.dirname(utilsDest), { recursive: true });
200896
+ await fs.copyFile(path2.join(SOURCE_COMPONENTS_FOLDER, "utils", "utils.ts"), utilsDest);
200897
+ console.log(source_default.green(`\u2713 Created ${path2.relative(targetPath, utilsDest)}`));
200951
200898
  }
200952
- async function getTailwindCssPath() {
200953
- const { customPath } = await lib_default.prompt([
200899
+ async function getTailwindCssPath(targetPath) {
200900
+ const { useDefault } = await lib_default.prompt([
200954
200901
  {
200955
200902
  type: "confirm",
200956
- name: "customPath",
200903
+ name: "useDefault",
200957
200904
  message: "Use default path for tailwind.css? (app/routes/styles/tailwind.css)",
200958
200905
  default: true
200959
200906
  }
200960
200907
  ]);
200961
- if (customPath) {
200962
- return path2.join(process.cwd(), "app", "routes", "styles", "tailwind.css");
200908
+ if (useDefault) {
200909
+ return path2.join(targetPath, "app", "routes", "styles", "tailwind.css");
200963
200910
  }
200964
- const { path: userPath } = await lib_default.prompt([
200911
+ const { userPath } = await lib_default.prompt([
200965
200912
  {
200966
200913
  type: "input",
200967
- name: "path",
200914
+ name: "userPath",
200968
200915
  message: "Enter path for tailwind.css:",
200969
200916
  default: "app/routes/styles/tailwind.css"
200970
200917
  }
200971
200918
  ]);
200972
- return path2.join(process.cwd(), userPath);
200919
+ return path2.join(targetPath, userPath);
200973
200920
  }
200974
- async function copyFile(src, dest) {
200921
+ async function configureTailwind(useNgin, targetPath, config) {
200922
+ const spinner = ora2("Configuring Tailwind...").start();
200923
+ const cssPath = config?.css ? path2.join(targetPath, config.css) : await getTailwindCssPath(targetPath);
200924
+ const configType = config?.["configure-tailwind.config"] === "ngin" || useNgin ? "ngin" : "basic";
200925
+ const configFile = configType === "ngin" ? "tailwind.config.ngin.js" : "tailwind.config.js";
200926
+ try {
200927
+ await copyFile(path2.join(SOURCE_DATA_FOLDER, "tailwind.css"), cssPath, targetPath);
200928
+ await copyFile(path2.join(SOURCE_DATA_FOLDER, configFile), path2.join(targetPath, "tailwind.config.js"), targetPath);
200929
+ await copyFile(path2.join(SOURCE_DATA_FOLDER, "postcss.config.js"), path2.join(targetPath, "postcss.config.js"), targetPath);
200930
+ spinner.succeed(source_default.green("Tailwind and PostCSS configured!"));
200931
+ } catch (error) {
200932
+ spinner.fail(source_default.red("Failed to configure Tailwind"));
200933
+ throw error;
200934
+ }
200935
+ }
200936
+ async function copyFile(src, dest, targetPath) {
200975
200937
  await fs.mkdir(path2.dirname(dest), { recursive: true });
200976
200938
  await fs.copyFile(src, dest);
200977
- console.log(source_default.green(`\u2713 Created ${path2.relative(process.cwd(), dest)}`));
200939
+ console.log(source_default.green(`\u2713 Created ${path2.relative(targetPath, dest)}`));
200978
200940
  }
200979
- async function fullInstall(includePremium, useNgin, config) {
200980
- await installAllComponents(includePremium, config);
200981
- if (config?.["install-tailwind"]) {
200982
- await installAllLibraries(includePremium);
200983
- }
200984
- if (config?.["configure-tailwind"] || config?.["configure-postcss"]) {
200985
- await configureTailwind(useNgin, config);
200941
+ async function fullInstall(includePremium, useNgin, targetPath, config) {
200942
+ await installAllComponents(includePremium, targetPath, config);
200943
+ if (config?.["configure-tailwind"]) {
200944
+ await configureTailwind(useNgin, targetPath, config);
200986
200945
  }
200987
- await ensureUtilsFile(config);
200946
+ await ensureUtilsFile(targetPath, config);
200988
200947
  }
200989
- async function installComponentsAndLibs(includePremium) {
200990
- await installAllComponents(includePremium);
200991
- await installAllLibraries(includePremium);
200992
- await ensureUtilsFile();
200948
+ async function installComponentsAndLibs(includePremium, targetPath, config) {
200949
+ await installAllComponents(includePremium, targetPath, config);
200950
+ await installAllLibraries(includePremium, targetPath);
200951
+ await ensureUtilsFile(targetPath, config);
200993
200952
  }
200994
- async function selectComponentsInteractive(includePremium) {
200953
+ async function selectComponentsInteractive(includePremium, targetPath, config) {
200995
200954
  const allComponents = await getComponentsData(includePremium);
200996
200955
  const categories = [...new Set(allComponents.map((c) => c.category))];
200997
200956
  const { selectedCategory } = await lib_default.prompt([
@@ -201025,106 +200984,146 @@ async function selectComponentsInteractive(includePremium) {
201025
200984
  for (const componentValue of selectedComponents) {
201026
200985
  const component = componentsToShow.find((c) => c.value === componentValue);
201027
200986
  if (component) {
201028
- await createComponentFile(component);
200987
+ await createComponentFile(component, targetPath, config);
201029
200988
  }
201030
200989
  }
201031
- await ensureUtilsFile();
201032
- await createIndexFiles();
200990
+ await ensureUtilsFile(targetPath, config);
200991
+ await createIndexFiles(targetPath, config);
201033
200992
  spinner.succeed(source_default.green(`Installed ${selectedComponents.length} components`));
201034
200993
  }
201035
- async function configureProjectPaths() {
200994
+ async function configureProjectPaths(targetPath, config) {
201036
200995
  const spinner = ora2("Configuring project paths...").start();
200996
+ let base = config?.components;
200997
+ if (!base) {
200998
+ const possibleRoots = ["app", "src", "lib"];
200999
+ for (const root of possibleRoots) {
201000
+ try {
201001
+ await fs.access(path2.join(targetPath, root));
201002
+ base = root;
201003
+ break;
201004
+ } catch {
201005
+ continue;
201006
+ }
201007
+ }
201008
+ if (!base)
201009
+ base = "app";
201010
+ }
201011
+ base = base.trim().replace(/\/+$/, "") + "/";
201037
201012
  const pathsToAdd = {
201038
- "#catalyst/*": "./app/components/catalyst-ui/*",
201039
201013
  "#icons": "@catalystsoftware/icons",
201040
- "#utils/*": "./app/components/catalyst-ui/utils/*",
201041
- "#prisma": "./app/components/catalyst-ui/utils/prisma.ts",
201042
- "#auth": "./app/components/catalyst-ui/utils/auth.ts",
201043
- "#auth_session": "./app/components/catalyst-ui/utils/auth_session.ts",
201044
- "#access": "./app/components/catalyst-ui/utils/user-based-access-rules.tsx",
201045
- "#blocks": "./app/components/catalyst-ui/blocks/index.ts",
201046
- "#hooks": "./app/components/catalyst-ui/hooks/index.ts"
201014
+ "#catalyst": `./${base}components/catalyst-ui/index.ts`,
201015
+ "#catalyst/*": `./${base}components/catalyst-ui/*`,
201016
+ "#utils": `./${base}components/catalyst-ui/utils/index.ts`,
201017
+ "#utils/*": `./${base}components/catalyst-ui/utils/*`,
201018
+ "#blocks": `./${base}components/catalyst-ui/blocks/index.ts`,
201019
+ "#blocks/*": `./${base}components/catalyst-ui/blocks/*`,
201020
+ "#hooks": `./${base}components/catalyst-ui/hooks/index.ts`,
201021
+ "#hooks/*": `./${base}components/catalyst-ui/hooks/*`,
201022
+ "#prisma": `./${base}components/catalyst-ui/utils/prisma.ts`,
201023
+ "#auth": `./${base}components/catalyst-ui/utils/auth.ts`,
201024
+ "#auth_session": `./${base}components/catalyst-ui/utils/auth_session.ts`,
201025
+ "#access": `./${base}components/catalyst-ui/utils/user-based-access-rules.tsx`
201047
201026
  };
201048
201027
  try {
201049
- const pkgPath = path2.join(process.cwd(), "package.json");
201028
+ const pkgPath = path2.join(targetPath, "package.json");
201050
201029
  const pkg = JSON.parse(await fs.readFile(pkgPath, "utf-8"));
201051
201030
  pkg.imports = { ...pkg.imports, ...pathsToAdd };
201052
201031
  await fs.writeFile(pkgPath, JSON.stringify(pkg, null, 2));
201053
- const tsPath = path2.join(process.cwd(), "tsconfig.json");
201054
- const tsConfigText = await fs.readFile(tsPath, "utf-8");
201055
- const tsConfig = JSON.parse(tsConfigText);
201056
- if (!tsConfig.compilerOptions)
201057
- tsConfig.compilerOptions = {};
201058
- if (!tsConfig.compilerOptions.paths)
201059
- tsConfig.compilerOptions.paths = {};
201060
- Object.entries(pathsToAdd).forEach(([key, val]) => {
201061
- const tsVal = key === "#icons" ? ["node_modules/@catalystsoftware/icons"] : [val];
201062
- tsConfig.compilerOptions.paths[key] = tsVal;
201063
- });
201064
- await fs.writeFile(tsPath, JSON.stringify(tsConfig, null, 2));
201065
- spinner.succeed(source_default.green("Project paths configured successfully"));
201066
- } catch (error) {
201067
- spinner.fail(source_default.red("Failed to configure project paths"));
201068
- console.error(error);
201032
+ const tsPath = path2.join(targetPath, "tsconfig.json");
201033
+ let exists = false;
201034
+ try {
201035
+ await fs.access(tsPath);
201036
+ exists = true;
201037
+ } catch {}
201038
+ if (exists) {
201039
+ const tsConfig = JSON.parse(await fs.readFile(tsPath, "utf-8"));
201040
+ tsConfig.compilerOptions = tsConfig.compilerOptions || {};
201041
+ tsConfig.compilerOptions.paths = tsConfig.compilerOptions.paths || {};
201042
+ Object.entries(pathsToAdd).forEach(([key, value]) => {
201043
+ const tsValue = value.startsWith("./") ? [value] : [`node_modules/${value}`];
201044
+ tsConfig.compilerOptions.paths[key] = tsValue;
201045
+ });
201046
+ await fs.writeFile(tsPath, JSON.stringify(tsConfig, null, 2));
201047
+ }
201048
+ spinner.succeed(source_default.green("Aliases added to package.json"));
201049
+ } catch (e) {
201050
+ spinner.fail(source_default.red("Alias configuration failed"));
201051
+ }
201052
+ }
201053
+ async function loadConfig(targetPath) {
201054
+ const configPath = path2.join(targetPath, "config.catalyst");
201055
+ try {
201056
+ await fs.access(configPath);
201057
+ const content = await fs.readFile(configPath, "utf-8");
201058
+ const jsonContent = content.replace(/\/\/.*$/gm, "").replace(/\/\*[\s\S]*?\*\//g, "");
201059
+ const config = JSON.parse(jsonContent);
201060
+ return { ...DEFAULT_CONFIG, ...config };
201061
+ } catch {
201062
+ return null;
201069
201063
  }
201070
201064
  }
201071
- async function handleAction(action, isPremium) {
201072
- let spinner;
201065
+ async function createConfig(targetPath) {
201066
+ const configPath = path2.join(targetPath, "config.catalyst");
201067
+ const configContent = JSON.stringify(DEFAULT_CONFIG, null, 2);
201068
+ await fs.writeFile(configPath, configContent, "utf-8");
201069
+ console.log(source_default.green("\u2713 Created config.catalyst"));
201070
+ }
201071
+ async function handleAction(action, isPremium, targetPath, config) {
201073
201072
  try {
201074
201073
  switch (action) {
201075
201074
  case "create-config":
201076
- await createConfig();
201075
+ await createConfig(targetPath);
201077
201076
  console.log(source_default.green(`
201078
201077
  \u2714 Config file created!`));
201079
201078
  break;
201080
201079
  case "full-premium-install":
201081
- await fullInstall(true, false);
201080
+ await fullInstall(true, false, targetPath, config);
201082
201081
  console.log(source_default.green(`
201083
201082
  \u2605 Full premium installation complete!`));
201084
201083
  break;
201085
201084
  case "full-premium-ngin":
201086
- await fullInstall(true, true);
201085
+ await fullInstall(true, true, targetPath, config);
201087
201086
  console.log(source_default.green(`
201088
201087
  \u2605 Full premium installation with Ngin complete!`));
201089
201088
  break;
201090
201089
  case "components-and-libs-premium":
201091
- await installComponentsAndLibs(true);
201090
+ await installComponentsAndLibs(true, targetPath, config);
201092
201091
  console.log(source_default.green(`
201093
201092
  \u2605 All premium components and libraries installed!`));
201094
201093
  break;
201095
201094
  case "full-install":
201096
- await fullInstall(isPremium, false);
201095
+ await fullInstall(isPremium, false, targetPath, config);
201097
201096
  console.log(source_default.green(`
201098
201097
  \u2714 Installation complete!`));
201099
201098
  break;
201100
201099
  case "full-install-ngin":
201101
- await fullInstall(isPremium, true);
201100
+ await fullInstall(isPremium, true, targetPath, config);
201102
201101
  console.log(source_default.green(`
201103
201102
  \u2714 Installation with Ngin complete!`));
201104
201103
  break;
201105
201104
  case "components-and-libs":
201106
- await installComponentsAndLibs(isPremium);
201105
+ await installComponentsAndLibs(isPremium, targetPath, config);
201107
201106
  console.log(source_default.green(`
201108
201107
  \u2714 Components and libraries installed!`));
201109
201108
  break;
201110
201109
  case "configure-tailwind-postcss":
201111
- await configureTailwind(false);
201110
+ await configureTailwind(false, targetPath, config);
201112
201111
  console.log(source_default.green(`
201113
201112
  \u2714 Tailwind and PostCSS configured!`));
201114
201113
  break;
201115
201114
  case "configure-ngin":
201116
- await configureTailwind(true);
201115
+ await configureTailwind(true, targetPath, config);
201117
201116
  console.log(source_default.green(`
201118
201117
  \u2714 Configured with Ngin preset!`));
201119
201118
  break;
201120
201119
  case "select-components":
201121
- await selectComponentsInteractive(false);
201120
+ await selectComponentsInteractive(false, targetPath, config);
201122
201121
  break;
201123
201122
  case "select-all-components":
201124
- await selectComponentsInteractive(true);
201123
+ await selectComponentsInteractive(true, targetPath, config);
201125
201124
  break;
201126
201125
  case "import-call":
201127
- await configureProjectPaths();
201126
+ await configureProjectPaths(targetPath, config);
201128
201127
  break;
201129
201128
  case "exit":
201130
201129
  console.log(source_default.cyan(`
@@ -201142,17 +201141,158 @@ async function handleAction(action, isPremium) {
201142
201141
  }
201143
201142
  async function main2() {
201144
201143
  const args = process.argv.slice(2);
201145
- const config = await loadConfig();
201144
+ const pathFlagIndex = args.indexOf("-p");
201145
+ let customPath = process.cwd();
201146
+ if (pathFlagIndex !== -1 && args[pathFlagIndex + 1]) {
201147
+ customPath = path2.resolve(args[pathFlagIndex + 1]);
201148
+ args.splice(pathFlagIndex, 2);
201149
+ }
201150
+ const config = await loadConfig(customPath);
201146
201151
  const hasSecretAccess = await checkSecretAccess(args);
201147
201152
  const cleanArgs = args.filter((arg) => !arg.startsWith("-") && arg.length <= 50);
201148
201153
  const componentArg = cleanArgs.find((arg) => arg.length < 50 && !arg.includes("/"));
201154
+ if (componentArg === "full-w-ngin") {
201155
+ console.log(source_default.blue(`
201156
+ \u2605 Installing...
201157
+ `));
201158
+ const spinner = ora2({ frames: ["\u28F7", "\u28EF", "\u28DF", "\u287F", "\u28BF", "\u28FB", "\u28FD", "\u28FE"], suffixText: "Installing component..." }).start();
201159
+ try {
201160
+ await handleAction("full-install-ngin", false, customPath, config);
201161
+ spinner.succeed(source_default.green(`Successfully installed`));
201162
+ } catch (error) {
201163
+ spinner.fail(source_default.red(`Failed to install`));
201164
+ console.error(error);
201165
+ process.exit(1);
201166
+ }
201167
+ return;
201168
+ }
201169
+ if (componentArg === "select-components") {
201170
+ console.log(source_default.blue(`
201171
+ \u2605 Installing...
201172
+ `));
201173
+ const spinner = ora2({ frames: ["\u28F7", "\u28EF", "\u28DF", "\u287F", "\u28BF", "\u28FB", "\u28FD", "\u28FE"], suffixText: "Installing component..." }).start();
201174
+ try {
201175
+ await handleAction("select-components", false, customPath, config);
201176
+ spinner.succeed(source_default.green(`Successfully installed`));
201177
+ } catch (error) {
201178
+ spinner.fail(source_default.red(`Failed to install`));
201179
+ console.error(error);
201180
+ process.exit(1);
201181
+ }
201182
+ return;
201183
+ }
201184
+ if (componentArg === "full-install") {
201185
+ console.log(source_default.blue(`
201186
+ \u2605 Installing...
201187
+ `));
201188
+ const spinner = ora2({ frames: ["\u28F7", "\u28EF", "\u28DF", "\u287F", "\u28BF", "\u28FB", "\u28FD", "\u28FE"], suffixText: "Installing component..." }).start();
201189
+ try {
201190
+ await handleAction("full-install", false, customPath, config);
201191
+ spinner.succeed(source_default.green(`Successfully installed`));
201192
+ } catch (error) {
201193
+ spinner.fail(source_default.red(`Failed to install`));
201194
+ console.error(error);
201195
+ process.exit(1);
201196
+ }
201197
+ return;
201198
+ }
201199
+ if (componentArg === "comps-and-libs") {
201200
+ console.log(source_default.blue(`
201201
+ \u2605 Installing...
201202
+ `));
201203
+ const spinner = ora2({ frames: ["\u28F7", "\u28EF", "\u28DF", "\u287F", "\u28BF", "\u28FB", "\u28FD", "\u28FE"], suffixText: "Installing component..." }).start();
201204
+ try {
201205
+ await handleAction("components-and-libs", false, customPath, config);
201206
+ spinner.succeed(source_default.green(`Successfully installed`));
201207
+ } catch (error) {
201208
+ spinner.fail(source_default.red(`Failed to install`));
201209
+ console.error(error);
201210
+ process.exit(1);
201211
+ }
201212
+ return;
201213
+ }
201214
+ if (componentArg === "create-config") {
201215
+ console.log(source_default.blue(`
201216
+ \u2605 Installing...
201217
+ `));
201218
+ const spinner = ora2({ frames: ["\u28F7", "\u28EF", "\u28DF", "\u287F", "\u28BF", "\u28FB", "\u28FD", "\u28FE"], suffixText: "Installing component..." }).start();
201219
+ try {
201220
+ await handleAction("create-config", false, customPath, config);
201221
+ spinner.succeed(source_default.green(`Successfully installed`));
201222
+ } catch (error) {
201223
+ spinner.fail(source_default.red(`Failed to install`));
201224
+ console.error(error);
201225
+ process.exit(1);
201226
+ }
201227
+ return;
201228
+ }
201229
+ if (componentArg === "configure-tailwind-postcss") {
201230
+ console.log(source_default.blue(`
201231
+ \u2605 Installing...
201232
+ `));
201233
+ const spinner = ora2({ frames: ["\u28F7", "\u28EF", "\u28DF", "\u287F", "\u28BF", "\u28FB", "\u28FD", "\u28FE"], suffixText: "Installing component..." }).start();
201234
+ try {
201235
+ await handleAction("configure-tailwind-postcss", false, customPath, config);
201236
+ spinner.succeed(source_default.green(`Successfully installed`));
201237
+ } catch (error) {
201238
+ spinner.fail(source_default.red(`Failed to install`));
201239
+ console.error(error);
201240
+ process.exit(1);
201241
+ }
201242
+ return;
201243
+ }
201244
+ if (componentArg === "configure-ngin") {
201245
+ console.log(source_default.blue(`
201246
+ \u2605 Installing...
201247
+ `));
201248
+ const spinner = ora2({ frames: ["\u28F7", "\u28EF", "\u28DF", "\u287F", "\u28BF", "\u28FB", "\u28FD", "\u28FE"], suffixText: "Installing component..." }).start();
201249
+ try {
201250
+ await handleAction("configure-ngin", false, customPath, config);
201251
+ spinner.succeed(source_default.green(`Successfully installed`));
201252
+ } catch (error) {
201253
+ spinner.fail(source_default.red(`Failed to install`));
201254
+ console.error(error);
201255
+ process.exit(1);
201256
+ }
201257
+ return;
201258
+ }
201259
+ if (componentArg === "create-config") {
201260
+ console.log(source_default.blue(`
201261
+ \u2605 Installing...
201262
+ `));
201263
+ const spinner = ora2({ frames: ["\u28F7", "\u28EF", "\u28DF", "\u287F", "\u28BF", "\u28FB", "\u28FD", "\u28FE"], suffixText: "Installing component..." }).start();
201264
+ try {
201265
+ await handleAction("create-config", false, customPath, config);
201266
+ spinner.succeed(source_default.green(`Successfully installed`));
201267
+ } catch (error) {
201268
+ spinner.fail(source_default.red(`Failed to install`));
201269
+ console.error(error);
201270
+ process.exit(1);
201271
+ }
201272
+ return;
201273
+ }
201274
+ if (componentArg === "import-call") {
201275
+ console.log(source_default.blue(`
201276
+ \u2605 Installing...
201277
+ `));
201278
+ const spinner = ora2({ frames: ["\u28F7", "\u28EF", "\u28DF", "\u287F", "\u28BF", "\u28FB", "\u28FD", "\u28FE"], suffixText: "Installing component..." }).start();
201279
+ try {
201280
+ await handleAction("import-call", false, customPath, config);
201281
+ spinner.succeed(source_default.green(`Successfully installed`));
201282
+ } catch (error) {
201283
+ spinner.fail(source_default.red(`Failed to install`));
201284
+ console.error(error);
201285
+ process.exit(1);
201286
+ }
201287
+ return;
201288
+ }
201149
201289
  if (componentArg && componentArg.length < 20) {
201150
201290
  console.log(source_default.blue(`
201151
201291
  \u2605 Installing component: ${componentArg}
201152
201292
  `));
201153
201293
  const spinner = ora2({ frames: ["\u28F7", "\u28EF", "\u28DF", "\u287F", "\u28BF", "\u28FB", "\u28FD", "\u28FE"], suffixText: "Installing component..." }).start();
201154
201294
  try {
201155
- await installSpecificComponent(componentArg, hasSecretAccess, config);
201295
+ await installSpecificComponent(componentArg, hasSecretAccess, customPath, config);
201156
201296
  spinner.succeed(source_default.green(`Successfully installed ${componentArg}`));
201157
201297
  } catch (error) {
201158
201298
  spinner.fail(source_default.red(`Failed to install ${componentArg}`));
@@ -201166,7 +201306,7 @@ async function main2() {
201166
201306
  \u2605 Auto-installing based on catalyst.config.jsonc
201167
201307
  `));
201168
201308
  const useNgin = config["configure-tailwind.config"] === "ngin";
201169
- await fullInstall(hasSecretAccess, useNgin, config);
201309
+ await fullInstall(hasSecretAccess, useNgin, customPath, config);
201170
201310
  console.log(source_default.green(`
201171
201311
  \u2714 Auto-installation complete!`));
201172
201312
  return;
@@ -201177,6 +201317,6 @@ async function main2() {
201177
201317
  } else {
201178
201318
  action = await showFreeMenu();
201179
201319
  }
201180
- await handleAction(action, hasSecretAccess);
201320
+ await handleAction(action, hasSecretAccess, customPath, config);
201181
201321
  }
201182
201322
  main2().catch(console.error);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@catalystsoftware/ui",
3
- "version": "1.0.17",
3
+ "version": "1.0.19",
4
4
  "description": "Catalyst UI Component Library CLI",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",