@catalystsoftware/ui 1.0.16 → 1.0.18
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 +11 -1
- package/dist/index.js +269 -129
- package/package.json +2 -1
package/README.md
CHANGED
|
@@ -2,6 +2,16 @@
|
|
|
2
2
|
|
|
3
3
|
A comprehensive React component library with 100+ production-ready components for building modern web applications.
|
|
4
4
|
|
|
5
|
+
## UPDATE
|
|
6
|
+
|
|
7
|
+
Adding a new line option 'Configure Import Call'. Configures your package.json and tsconfig.json files to allow the use of '#icons' and '#catalyst' in-place of the traditional '~/components/catalyst-ui' and '@catalystsoftware/icons'
|
|
8
|
+
|
|
9
|
+
```javascript
|
|
10
|
+
import { Command, CommandGroup, CommandItem, CommandList, cn } from '#catalyst'
|
|
11
|
+
import { X } from '#icons'
|
|
12
|
+
```
|
|
13
|
+
Selecting the full installation will also configure your project for this use as well.
|
|
14
|
+
|
|
5
15
|
## Installation
|
|
6
16
|
|
|
7
17
|
### Quick Start
|
|
@@ -101,7 +111,7 @@ Catalyst UI automatically detects and uses your package manager:
|
|
|
101
111
|
|
|
102
112
|
### Config File (Optional)
|
|
103
113
|
|
|
104
|
-
Create a `
|
|
114
|
+
Create a `config.catalyst` file in your project root to customize installation behavior:
|
|
105
115
|
|
|
106
116
|
```bash
|
|
107
117
|
bunx @catalystsoftware/ui
|
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(), "catalyst.config.jsonc");
|
|
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(), "catalyst.config.jsonc");
|
|
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 catalyst.config.jsonc"));
|
|
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) {
|
|
@@ -200695,6 +200665,7 @@ async function showPremiumMenu() {
|
|
|
200695
200665
|
{ name: `${source_default.bold("Configure Only")} ${source_default.gray("\u2192 Tailwind + PostCSS setup")}`, value: "configure-tailwind-postcss" },
|
|
200696
200666
|
{ name: `${source_default.bold("Configure with Ngin")} ${source_default.gray("\u2192 Tailwind + PostCSS + Ngin preset")}`, value: "configure-ngin" },
|
|
200697
200667
|
{ name: `${source_default.bold("Create Config")} ${source_default.gray("\u2192 Configure installation options with pre-configured config file")}`, value: "create-config" },
|
|
200668
|
+
{ name: `${source_default.bold("Configure Import Call")} ${source_default.gray("\u2192 Allows the use of #catalyst & #icons")}`, value: "import-call" },
|
|
200698
200669
|
{ name: `${source_default.red("\u2717 Exit")}`, value: "exit" }
|
|
200699
200670
|
];
|
|
200700
200671
|
const notToggled = "\u25C7";
|
|
@@ -200725,6 +200696,7 @@ async function showFreeMenu() {
|
|
|
200725
200696
|
{ name: `${source_default.bold("Configure Only")} ${source_default.gray("\u2192 Tailwind + PostCSS setup")}`, value: "configure-tailwind-postcss" },
|
|
200726
200697
|
{ name: `${source_default.bold("Configure with Ngin")} ${source_default.gray("\u2192 Tailwind + PostCSS + Ngin preset")}`, value: "configure-ngin" },
|
|
200727
200698
|
{ name: `${source_default.bold("Create Config")} ${source_default.gray("\u2192 Configure installation options with pre-configured config file")}`, value: "create-config" },
|
|
200699
|
+
{ name: `${source_default.bold("Configure Import Call")} ${source_default.gray("\u2192 Allows the use of #catalyst & #icons")}`, value: "import-call" },
|
|
200728
200700
|
{ name: `${source_default.red("\u2717 Exit")}`, value: "exit" }
|
|
200729
200701
|
];
|
|
200730
200702
|
const notToggled = "\u25C7";
|
|
@@ -200757,41 +200729,37 @@ async function getComponentsData(includePremium) {
|
|
|
200757
200729
|
throw error;
|
|
200758
200730
|
}
|
|
200759
200731
|
}
|
|
200760
|
-
async function installSpecificComponent(componentName, isPremium, config) {
|
|
200732
|
+
async function installSpecificComponent(componentName, isPremium, targetPath, config) {
|
|
200761
200733
|
const components = await getComponentsData(isPremium);
|
|
200762
200734
|
const component = components.find((c) => c.value === componentName || c.name.toLowerCase() === componentName.toLowerCase());
|
|
200763
|
-
if (!component)
|
|
200735
|
+
if (!component)
|
|
200764
200736
|
throw new Error(`Component "${componentName}" not found`);
|
|
200765
|
-
|
|
200766
|
-
if (component.premium && !isPremium) {
|
|
200767
|
-
throw new Error(`Component "${componentName}" is premium only. Use a valid access key to install.`);
|
|
200768
|
-
}
|
|
200769
|
-
await createComponentFile(component, config);
|
|
200737
|
+
await createComponentFile(component, targetPath, config);
|
|
200770
200738
|
const sourceFullPath = path2.join(SOURCE_COMPONENTS_FOLDER, component.path);
|
|
200771
200739
|
const content = await fs.readFile(sourceFullPath, "utf-8");
|
|
200772
200740
|
const dependencies = extractImportsFromFile(content, component.path);
|
|
200773
200741
|
if (dependencies.size > 0) {
|
|
200774
|
-
await installDependencies(Array.from(dependencies));
|
|
200742
|
+
await installDependencies(Array.from(dependencies), targetPath);
|
|
200775
200743
|
}
|
|
200776
|
-
await ensureUtilsFile(config);
|
|
200744
|
+
await ensureUtilsFile(targetPath, config);
|
|
200777
200745
|
}
|
|
200778
|
-
async function createComponentFile(component, config) {
|
|
200746
|
+
async function createComponentFile(component, targetPath, config) {
|
|
200779
200747
|
const componentsBase = config?.components || "app/";
|
|
200780
200748
|
const sourcePath = component.path;
|
|
200781
|
-
const
|
|
200782
|
-
await fs.mkdir(path2.dirname(
|
|
200749
|
+
const destPath = path2.join(targetPath, componentsBase, sourcePath.replace(/^\/?(app\/)?/, ""));
|
|
200750
|
+
await fs.mkdir(path2.dirname(destPath), { recursive: true });
|
|
200783
200751
|
const sourceFullPath = path2.join(SOURCE_COMPONENTS_FOLDER, sourcePath);
|
|
200784
200752
|
const content = await fs.readFile(sourceFullPath, "utf-8");
|
|
200785
|
-
await fs.writeFile(
|
|
200786
|
-
console.log(source_default.green(`\u2713 Created ${path2.relative(
|
|
200753
|
+
await fs.writeFile(destPath, content, "utf-8");
|
|
200754
|
+
console.log(source_default.green(`\u2713 Created ${path2.relative(targetPath, destPath)}`));
|
|
200787
200755
|
}
|
|
200788
|
-
async function installAllComponents(includePremium, config) {
|
|
200756
|
+
async function installAllComponents(includePremium, targetPath, config) {
|
|
200789
200757
|
const components = await getComponentsData(includePremium);
|
|
200790
200758
|
const spinner = ora2({ frames: ["\u28F7", "\u28EF", "\u28DF", "\u287F", "\u28BF", "\u28FB", "\u28FD", "\u28FE"], suffixText: `Installing ${components.length} components...` }).start();
|
|
200791
200759
|
let installed = 0;
|
|
200792
200760
|
for (const component of components) {
|
|
200793
200761
|
try {
|
|
200794
|
-
await createComponentFile(component, config);
|
|
200762
|
+
await createComponentFile(component, targetPath, config);
|
|
200795
200763
|
installed++;
|
|
200796
200764
|
spinner.text = `Installing components... (${installed}/${components.length})`;
|
|
200797
200765
|
} catch (error) {
|
|
@@ -200800,20 +200768,26 @@ async function installAllComponents(includePremium, config) {
|
|
|
200800
200768
|
}
|
|
200801
200769
|
}
|
|
200802
200770
|
spinner.succeed(source_default.green(`Installed ${installed} components`));
|
|
200803
|
-
await createIndexFiles();
|
|
200771
|
+
await createIndexFiles(targetPath, config);
|
|
200772
|
+
await configureProjectPaths(targetPath, config);
|
|
200804
200773
|
}
|
|
200805
|
-
async function createIndexFiles() {
|
|
200806
|
-
const spinner = ora2(
|
|
200807
|
-
const
|
|
200808
|
-
const
|
|
200809
|
-
|
|
200810
|
-
|
|
200811
|
-
|
|
200812
|
-
|
|
200813
|
-
|
|
200814
|
-
|
|
200815
|
-
|
|
200816
|
-
|
|
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
|
+
}
|
|
200817
200791
|
}
|
|
200818
200792
|
async function createMainIndex(componentsDir) {
|
|
200819
200793
|
try {
|
|
@@ -200863,28 +200837,24 @@ function generateIndexContent(files, basePath) {
|
|
|
200863
200837
|
`) + `
|
|
200864
200838
|
`;
|
|
200865
200839
|
}
|
|
200866
|
-
async function installDependencies(deps) {
|
|
200867
|
-
const spinner = ora2(
|
|
200840
|
+
async function installDependencies(deps, targetPath) {
|
|
200841
|
+
const spinner = ora2("Installing dependencies...").start();
|
|
200868
200842
|
try {
|
|
200869
|
-
const packageManager = await detectPackageManager();
|
|
200843
|
+
const packageManager = await detectPackageManager(targetPath);
|
|
200870
200844
|
const installCmd = packageManager === "npm" ? "install" : "add";
|
|
200871
|
-
execSync(`${packageManager} ${installCmd} ${deps.join(" ")}`, {
|
|
200872
|
-
stdio: "inherit",
|
|
200873
|
-
cwd: process.cwd()
|
|
200874
|
-
});
|
|
200845
|
+
execSync(`${packageManager} ${installCmd} ${deps.join(" ")}`, { stdio: "inherit", cwd: targetPath });
|
|
200875
200846
|
spinner.succeed(source_default.green("Dependencies installed"));
|
|
200876
200847
|
} catch (error) {
|
|
200877
|
-
spinner.fail(source_default.red("
|
|
200878
|
-
throw error;
|
|
200848
|
+
spinner.fail(source_default.red("Dependency installation failed"));
|
|
200879
200849
|
}
|
|
200880
200850
|
}
|
|
200881
|
-
async function detectPackageManager() {
|
|
200851
|
+
async function detectPackageManager(targetPath) {
|
|
200882
200852
|
try {
|
|
200883
|
-
await fs.access(path2.join(
|
|
200853
|
+
await fs.access(path2.join(targetPath, "pnpm-lock.yaml"));
|
|
200884
200854
|
return "pnpm";
|
|
200885
200855
|
} catch {}
|
|
200886
200856
|
try {
|
|
200887
|
-
await fs.access(path2.join(
|
|
200857
|
+
await fs.access(path2.join(targetPath, "yarn.lock"));
|
|
200888
200858
|
return "yarn";
|
|
200889
200859
|
} catch {}
|
|
200890
200860
|
return "npm";
|
|
@@ -200915,73 +200885,65 @@ async function installAllLibraries(includeAll) {
|
|
|
200915
200885
|
const libs = includeAll ? requiredLibsAll : requiredLibs;
|
|
200916
200886
|
await installDependencies(libs.split(" "));
|
|
200917
200887
|
}
|
|
200918
|
-
async function ensureUtilsFile(config) {
|
|
200888
|
+
async function ensureUtilsFile(targetPath, config) {
|
|
200919
200889
|
const componentsBase = config?.components || "app/";
|
|
200920
|
-
const
|
|
200890
|
+
const utilsDest = path2.join(targetPath, componentsBase, "components", "catalyst-ui", "utils", "utils.ts");
|
|
200921
200891
|
try {
|
|
200922
|
-
await fs.access(
|
|
200892
|
+
await fs.access(utilsDest);
|
|
200923
200893
|
return;
|
|
200924
200894
|
} catch {}
|
|
200925
|
-
await fs.mkdir(path2.dirname(
|
|
200926
|
-
|
|
200927
|
-
|
|
200928
|
-
console.log(source_default.green(`\u2713 Created ${path2.relative(process.cwd(), utilsPath)}`));
|
|
200929
|
-
}
|
|
200930
|
-
async function configureTailwind(useNgin, config) {
|
|
200931
|
-
const spinner = ora2({ frames: ["\u28F7", "\u28EF", "\u28DF", "\u287F", "\u28BF", "\u28FB", "\u28FD", "\u28FE"], suffixText: "Configuring Tailwind..." }).start();
|
|
200932
|
-
if (config?.["configure-tailwind"]) {
|
|
200933
|
-
const tailwindCssPath = config.css || "app/routes/styles/tailwind.css";
|
|
200934
|
-
await copyFile(path2.join(SOURCE_DATA_FOLDER, "tailwind.css"), path2.join(process.cwd(), tailwindCssPath));
|
|
200935
|
-
} else {
|
|
200936
|
-
const tailwindCssPath = await getTailwindCssPath();
|
|
200937
|
-
await copyFile(path2.join(SOURCE_DATA_FOLDER, "tailwind.css"), tailwindCssPath);
|
|
200938
|
-
}
|
|
200939
|
-
if (config?.["configure-tailwind.config"] !== false) {
|
|
200940
|
-
const configType = config?.["configure-tailwind.config"] === "ngin" ? "ngin" : useNgin ? "ngin" : "basic";
|
|
200941
|
-
const configFileName = configType === "ngin" ? "tailwind.config.ngin.js" : "tailwind.config.js";
|
|
200942
|
-
await copyFile(path2.join(SOURCE_DATA_FOLDER, configFileName), path2.join(process.cwd(), "tailwind.config.js"));
|
|
200943
|
-
}
|
|
200944
|
-
if (config?.["configure-postcss"]) {
|
|
200945
|
-
await copyFile(path2.join(SOURCE_DATA_FOLDER, "postcss.config.js"), path2.join(process.cwd(), "postcss.config.js"));
|
|
200946
|
-
}
|
|
200947
|
-
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)}`));
|
|
200948
200898
|
}
|
|
200949
|
-
async function getTailwindCssPath() {
|
|
200950
|
-
const {
|
|
200899
|
+
async function getTailwindCssPath(targetPath) {
|
|
200900
|
+
const { useDefault } = await lib_default.prompt([
|
|
200951
200901
|
{
|
|
200952
200902
|
type: "confirm",
|
|
200953
|
-
name: "
|
|
200903
|
+
name: "useDefault",
|
|
200954
200904
|
message: "Use default path for tailwind.css? (app/routes/styles/tailwind.css)",
|
|
200955
200905
|
default: true
|
|
200956
200906
|
}
|
|
200957
200907
|
]);
|
|
200958
|
-
if (
|
|
200959
|
-
return path2.join(
|
|
200908
|
+
if (useDefault) {
|
|
200909
|
+
return path2.join(targetPath, "app", "routes", "styles", "tailwind.css");
|
|
200960
200910
|
}
|
|
200961
|
-
const {
|
|
200911
|
+
const { userPath } = await lib_default.prompt([
|
|
200962
200912
|
{
|
|
200963
200913
|
type: "input",
|
|
200964
|
-
name: "
|
|
200914
|
+
name: "userPath",
|
|
200965
200915
|
message: "Enter path for tailwind.css:",
|
|
200966
200916
|
default: "app/routes/styles/tailwind.css"
|
|
200967
200917
|
}
|
|
200968
200918
|
]);
|
|
200969
|
-
return path2.join(
|
|
200919
|
+
return path2.join(targetPath, userPath);
|
|
200970
200920
|
}
|
|
200971
|
-
async function
|
|
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) {
|
|
200972
200937
|
await fs.mkdir(path2.dirname(dest), { recursive: true });
|
|
200973
200938
|
await fs.copyFile(src, dest);
|
|
200974
|
-
console.log(source_default.green(`\u2713 Created ${path2.relative(
|
|
200939
|
+
console.log(source_default.green(`\u2713 Created ${path2.relative(targetPath, dest)}`));
|
|
200975
200940
|
}
|
|
200976
|
-
async function fullInstall(includePremium, useNgin, config) {
|
|
200977
|
-
await installAllComponents(includePremium, config);
|
|
200978
|
-
if (config?.["
|
|
200979
|
-
await
|
|
200980
|
-
}
|
|
200981
|
-
if (config?.["configure-tailwind"] || config?.["configure-postcss"]) {
|
|
200982
|
-
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);
|
|
200983
200945
|
}
|
|
200984
|
-
await ensureUtilsFile(config);
|
|
200946
|
+
await ensureUtilsFile(targetPath, config);
|
|
200985
200947
|
}
|
|
200986
200948
|
async function installComponentsAndLibs(includePremium) {
|
|
200987
200949
|
await installAllComponents(includePremium);
|
|
@@ -201029,60 +200991,97 @@ async function selectComponentsInteractive(includePremium) {
|
|
|
201029
200991
|
await createIndexFiles();
|
|
201030
200992
|
spinner.succeed(source_default.green(`Installed ${selectedComponents.length} components`));
|
|
201031
200993
|
}
|
|
201032
|
-
async function
|
|
201033
|
-
|
|
200994
|
+
async function configureProjectPaths(targetPath, config) {
|
|
200995
|
+
const spinner = ora2("Configuring project paths...").start();
|
|
200996
|
+
const base = config?.components || "app/";
|
|
200997
|
+
const pathsToAdd = {
|
|
200998
|
+
"#catalyst/*": `./${base}components/catalyst-ui/*`,
|
|
200999
|
+
"#icons": "@catalystsoftware/icons"
|
|
201000
|
+
};
|
|
201001
|
+
try {
|
|
201002
|
+
const pkgPath = path2.join(targetPath, "package.json");
|
|
201003
|
+
const pkg = JSON.parse(await fs.readFile(pkgPath, "utf-8"));
|
|
201004
|
+
pkg.imports = { ...pkg.imports, ...pathsToAdd };
|
|
201005
|
+
await fs.writeFile(pkgPath, JSON.stringify(pkg, null, 2));
|
|
201006
|
+
spinner.succeed(source_default.green("Aliases added to package.json"));
|
|
201007
|
+
} catch (e) {
|
|
201008
|
+
spinner.fail(source_default.red("Alias configuration failed"));
|
|
201009
|
+
}
|
|
201010
|
+
}
|
|
201011
|
+
async function loadConfig(targetPath) {
|
|
201012
|
+
const configPath = path2.join(targetPath, "config.catalyst");
|
|
201013
|
+
try {
|
|
201014
|
+
await fs.access(configPath);
|
|
201015
|
+
const content = await fs.readFile(configPath, "utf-8");
|
|
201016
|
+
const jsonContent = content.replace(/\/\/.*$/gm, "").replace(/\/\*[\s\S]*?\*\//g, "");
|
|
201017
|
+
const config = JSON.parse(jsonContent);
|
|
201018
|
+
return { ...DEFAULT_CONFIG, ...config };
|
|
201019
|
+
} catch {
|
|
201020
|
+
return null;
|
|
201021
|
+
}
|
|
201022
|
+
}
|
|
201023
|
+
async function createConfig(targetPath) {
|
|
201024
|
+
const configPath = path2.join(targetPath, "config.catalyst");
|
|
201025
|
+
const configContent = JSON.stringify(DEFAULT_CONFIG, null, 2);
|
|
201026
|
+
await fs.writeFile(configPath, configContent, "utf-8");
|
|
201027
|
+
console.log(source_default.green("\u2713 Created config.catalyst"));
|
|
201028
|
+
}
|
|
201029
|
+
async function handleAction(action, isPremium, targetPath, config) {
|
|
201034
201030
|
try {
|
|
201035
201031
|
switch (action) {
|
|
201036
201032
|
case "create-config":
|
|
201037
|
-
await createConfig();
|
|
201033
|
+
await createConfig(targetPath);
|
|
201038
201034
|
console.log(source_default.green(`
|
|
201039
201035
|
\u2714 Config file created!`));
|
|
201040
201036
|
break;
|
|
201041
201037
|
case "full-premium-install":
|
|
201042
|
-
await fullInstall(true, false);
|
|
201038
|
+
await fullInstall(true, false, targetPath, config);
|
|
201043
201039
|
console.log(source_default.green(`
|
|
201044
201040
|
\u2605 Full premium installation complete!`));
|
|
201045
201041
|
break;
|
|
201046
201042
|
case "full-premium-ngin":
|
|
201047
|
-
await fullInstall(true, true);
|
|
201043
|
+
await fullInstall(true, true, targetPath, config);
|
|
201048
201044
|
console.log(source_default.green(`
|
|
201049
201045
|
\u2605 Full premium installation with Ngin complete!`));
|
|
201050
201046
|
break;
|
|
201051
201047
|
case "components-and-libs-premium":
|
|
201052
|
-
await installComponentsAndLibs(true);
|
|
201048
|
+
await installComponentsAndLibs(true, targetPath, config);
|
|
201053
201049
|
console.log(source_default.green(`
|
|
201054
201050
|
\u2605 All premium components and libraries installed!`));
|
|
201055
201051
|
break;
|
|
201056
201052
|
case "full-install":
|
|
201057
|
-
await fullInstall(isPremium, false);
|
|
201053
|
+
await fullInstall(isPremium, false, targetPath, config);
|
|
201058
201054
|
console.log(source_default.green(`
|
|
201059
201055
|
\u2714 Installation complete!`));
|
|
201060
201056
|
break;
|
|
201061
201057
|
case "full-install-ngin":
|
|
201062
|
-
await fullInstall(isPremium, true);
|
|
201058
|
+
await fullInstall(isPremium, true, targetPath, config);
|
|
201063
201059
|
console.log(source_default.green(`
|
|
201064
201060
|
\u2714 Installation with Ngin complete!`));
|
|
201065
201061
|
break;
|
|
201066
201062
|
case "components-and-libs":
|
|
201067
|
-
await installComponentsAndLibs(isPremium);
|
|
201063
|
+
await installComponentsAndLibs(isPremium, targetPath, config);
|
|
201068
201064
|
console.log(source_default.green(`
|
|
201069
201065
|
\u2714 Components and libraries installed!`));
|
|
201070
201066
|
break;
|
|
201071
201067
|
case "configure-tailwind-postcss":
|
|
201072
|
-
await configureTailwind(false);
|
|
201068
|
+
await configureTailwind(false, targetPath, config);
|
|
201073
201069
|
console.log(source_default.green(`
|
|
201074
201070
|
\u2714 Tailwind and PostCSS configured!`));
|
|
201075
201071
|
break;
|
|
201076
201072
|
case "configure-ngin":
|
|
201077
|
-
await configureTailwind(true);
|
|
201073
|
+
await configureTailwind(true, targetPath, config);
|
|
201078
201074
|
console.log(source_default.green(`
|
|
201079
201075
|
\u2714 Configured with Ngin preset!`));
|
|
201080
201076
|
break;
|
|
201081
201077
|
case "select-components":
|
|
201082
|
-
await selectComponentsInteractive(false);
|
|
201078
|
+
await selectComponentsInteractive(false, targetPath, config);
|
|
201083
201079
|
break;
|
|
201084
201080
|
case "select-all-components":
|
|
201085
|
-
await selectComponentsInteractive(true);
|
|
201081
|
+
await selectComponentsInteractive(true, targetPath, config);
|
|
201082
|
+
break;
|
|
201083
|
+
case "import-call":
|
|
201084
|
+
await configureProjectPaths(targetPath, config);
|
|
201086
201085
|
break;
|
|
201087
201086
|
case "exit":
|
|
201088
201087
|
console.log(source_default.cyan(`
|
|
@@ -201100,10 +201099,151 @@ async function handleAction(action, isPremium) {
|
|
|
201100
201099
|
}
|
|
201101
201100
|
async function main2() {
|
|
201102
201101
|
const args = process.argv.slice(2);
|
|
201102
|
+
const pathFlagIndex = args.indexOf("-p");
|
|
201103
|
+
let customPath = process.cwd();
|
|
201104
|
+
if (pathFlagIndex !== -1 && args[pathFlagIndex + 1]) {
|
|
201105
|
+
customPath = path2.resolve(args[pathFlagIndex + 1]);
|
|
201106
|
+
args.splice(pathFlagIndex, 2);
|
|
201107
|
+
}
|
|
201103
201108
|
const config = await loadConfig();
|
|
201104
201109
|
const hasSecretAccess = await checkSecretAccess(args);
|
|
201105
201110
|
const cleanArgs = args.filter((arg) => !arg.startsWith("-") && arg.length <= 50);
|
|
201106
201111
|
const componentArg = cleanArgs.find((arg) => arg.length < 50 && !arg.includes("/"));
|
|
201112
|
+
if (componentArg === "full-w-ngin") {
|
|
201113
|
+
console.log(source_default.blue(`
|
|
201114
|
+
\u2605 Installing...
|
|
201115
|
+
`));
|
|
201116
|
+
const spinner = ora2({ frames: ["\u28F7", "\u28EF", "\u28DF", "\u287F", "\u28BF", "\u28FB", "\u28FD", "\u28FE"], suffixText: "Installing component..." }).start();
|
|
201117
|
+
try {
|
|
201118
|
+
await handleAction("full-install-ngin", false, customPath, config);
|
|
201119
|
+
spinner.succeed(source_default.green(`Successfully installed`));
|
|
201120
|
+
} catch (error) {
|
|
201121
|
+
spinner.fail(source_default.red(`Failed to install`));
|
|
201122
|
+
console.error(error);
|
|
201123
|
+
process.exit(1);
|
|
201124
|
+
}
|
|
201125
|
+
return;
|
|
201126
|
+
}
|
|
201127
|
+
if (componentArg === "select-components") {
|
|
201128
|
+
console.log(source_default.blue(`
|
|
201129
|
+
\u2605 Installing...
|
|
201130
|
+
`));
|
|
201131
|
+
const spinner = ora2({ frames: ["\u28F7", "\u28EF", "\u28DF", "\u287F", "\u28BF", "\u28FB", "\u28FD", "\u28FE"], suffixText: "Installing component..." }).start();
|
|
201132
|
+
try {
|
|
201133
|
+
await handleAction("select-components", false, customPath, config);
|
|
201134
|
+
spinner.succeed(source_default.green(`Successfully installed`));
|
|
201135
|
+
} catch (error) {
|
|
201136
|
+
spinner.fail(source_default.red(`Failed to install`));
|
|
201137
|
+
console.error(error);
|
|
201138
|
+
process.exit(1);
|
|
201139
|
+
}
|
|
201140
|
+
return;
|
|
201141
|
+
}
|
|
201142
|
+
if (componentArg === "full-install") {
|
|
201143
|
+
console.log(source_default.blue(`
|
|
201144
|
+
\u2605 Installing...
|
|
201145
|
+
`));
|
|
201146
|
+
const spinner = ora2({ frames: ["\u28F7", "\u28EF", "\u28DF", "\u287F", "\u28BF", "\u28FB", "\u28FD", "\u28FE"], suffixText: "Installing component..." }).start();
|
|
201147
|
+
try {
|
|
201148
|
+
await handleAction("full-install", false, customPath, config);
|
|
201149
|
+
spinner.succeed(source_default.green(`Successfully installed`));
|
|
201150
|
+
} catch (error) {
|
|
201151
|
+
spinner.fail(source_default.red(`Failed to install`));
|
|
201152
|
+
console.error(error);
|
|
201153
|
+
process.exit(1);
|
|
201154
|
+
}
|
|
201155
|
+
return;
|
|
201156
|
+
}
|
|
201157
|
+
if (componentArg === "comps-and-libs") {
|
|
201158
|
+
console.log(source_default.blue(`
|
|
201159
|
+
\u2605 Installing...
|
|
201160
|
+
`));
|
|
201161
|
+
const spinner = ora2({ frames: ["\u28F7", "\u28EF", "\u28DF", "\u287F", "\u28BF", "\u28FB", "\u28FD", "\u28FE"], suffixText: "Installing component..." }).start();
|
|
201162
|
+
try {
|
|
201163
|
+
await handleAction("components-and-libs", false, customPath, config);
|
|
201164
|
+
spinner.succeed(source_default.green(`Successfully installed`));
|
|
201165
|
+
} catch (error) {
|
|
201166
|
+
spinner.fail(source_default.red(`Failed to install`));
|
|
201167
|
+
console.error(error);
|
|
201168
|
+
process.exit(1);
|
|
201169
|
+
}
|
|
201170
|
+
return;
|
|
201171
|
+
}
|
|
201172
|
+
if (componentArg === "create-config") {
|
|
201173
|
+
console.log(source_default.blue(`
|
|
201174
|
+
\u2605 Installing...
|
|
201175
|
+
`));
|
|
201176
|
+
const spinner = ora2({ frames: ["\u28F7", "\u28EF", "\u28DF", "\u287F", "\u28BF", "\u28FB", "\u28FD", "\u28FE"], suffixText: "Installing component..." }).start();
|
|
201177
|
+
try {
|
|
201178
|
+
await handleAction("create-config", false, customPath, config);
|
|
201179
|
+
spinner.succeed(source_default.green(`Successfully installed`));
|
|
201180
|
+
} catch (error) {
|
|
201181
|
+
spinner.fail(source_default.red(`Failed to install`));
|
|
201182
|
+
console.error(error);
|
|
201183
|
+
process.exit(1);
|
|
201184
|
+
}
|
|
201185
|
+
return;
|
|
201186
|
+
}
|
|
201187
|
+
if (componentArg === "configure-tailwind-postcss") {
|
|
201188
|
+
console.log(source_default.blue(`
|
|
201189
|
+
\u2605 Installing...
|
|
201190
|
+
`));
|
|
201191
|
+
const spinner = ora2({ frames: ["\u28F7", "\u28EF", "\u28DF", "\u287F", "\u28BF", "\u28FB", "\u28FD", "\u28FE"], suffixText: "Installing component..." }).start();
|
|
201192
|
+
try {
|
|
201193
|
+
await handleAction("configure-tailwind-postcss", false, customPath, config);
|
|
201194
|
+
spinner.succeed(source_default.green(`Successfully installed`));
|
|
201195
|
+
} catch (error) {
|
|
201196
|
+
spinner.fail(source_default.red(`Failed to install`));
|
|
201197
|
+
console.error(error);
|
|
201198
|
+
process.exit(1);
|
|
201199
|
+
}
|
|
201200
|
+
return;
|
|
201201
|
+
}
|
|
201202
|
+
if (componentArg === "configure-ngin") {
|
|
201203
|
+
console.log(source_default.blue(`
|
|
201204
|
+
\u2605 Installing...
|
|
201205
|
+
`));
|
|
201206
|
+
const spinner = ora2({ frames: ["\u28F7", "\u28EF", "\u28DF", "\u287F", "\u28BF", "\u28FB", "\u28FD", "\u28FE"], suffixText: "Installing component..." }).start();
|
|
201207
|
+
try {
|
|
201208
|
+
await handleAction("configure-ngin", false, customPath, config);
|
|
201209
|
+
spinner.succeed(source_default.green(`Successfully installed`));
|
|
201210
|
+
} catch (error) {
|
|
201211
|
+
spinner.fail(source_default.red(`Failed to install`));
|
|
201212
|
+
console.error(error);
|
|
201213
|
+
process.exit(1);
|
|
201214
|
+
}
|
|
201215
|
+
return;
|
|
201216
|
+
}
|
|
201217
|
+
if (componentArg === "create-config") {
|
|
201218
|
+
console.log(source_default.blue(`
|
|
201219
|
+
\u2605 Installing...
|
|
201220
|
+
`));
|
|
201221
|
+
const spinner = ora2({ frames: ["\u28F7", "\u28EF", "\u28DF", "\u287F", "\u28BF", "\u28FB", "\u28FD", "\u28FE"], suffixText: "Installing component..." }).start();
|
|
201222
|
+
try {
|
|
201223
|
+
await handleAction("create-config", false, customPath, config);
|
|
201224
|
+
spinner.succeed(source_default.green(`Successfully installed`));
|
|
201225
|
+
} catch (error) {
|
|
201226
|
+
spinner.fail(source_default.red(`Failed to install`));
|
|
201227
|
+
console.error(error);
|
|
201228
|
+
process.exit(1);
|
|
201229
|
+
}
|
|
201230
|
+
return;
|
|
201231
|
+
}
|
|
201232
|
+
if (componentArg === "import-call") {
|
|
201233
|
+
console.log(source_default.blue(`
|
|
201234
|
+
\u2605 Installing...
|
|
201235
|
+
`));
|
|
201236
|
+
const spinner = ora2({ frames: ["\u28F7", "\u28EF", "\u28DF", "\u287F", "\u28BF", "\u28FB", "\u28FD", "\u28FE"], suffixText: "Installing component..." }).start();
|
|
201237
|
+
try {
|
|
201238
|
+
await handleAction("import-call", false, customPath, config);
|
|
201239
|
+
spinner.succeed(source_default.green(`Successfully installed`));
|
|
201240
|
+
} catch (error) {
|
|
201241
|
+
spinner.fail(source_default.red(`Failed to install`));
|
|
201242
|
+
console.error(error);
|
|
201243
|
+
process.exit(1);
|
|
201244
|
+
}
|
|
201245
|
+
return;
|
|
201246
|
+
}
|
|
201107
201247
|
if (componentArg && componentArg.length < 20) {
|
|
201108
201248
|
console.log(source_default.blue(`
|
|
201109
201249
|
\u2605 Installing component: ${componentArg}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@catalystsoftware/ui",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.18",
|
|
4
4
|
"description": "Catalyst UI Component Library CLI",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -39,6 +39,7 @@
|
|
|
39
39
|
"ora": "^7.0.1"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
|
+
"@types/bun": "^1.3.6",
|
|
42
43
|
"@types/inquirer": "^9.0.7",
|
|
43
44
|
"@types/node": "^20.10.5",
|
|
44
45
|
"esbuild": "^0.19.10",
|