@catalystsoftware/ui 1.0.18 → 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.
- package/dist/index.js +58 -16
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -200879,11 +200879,11 @@ function extractImportsFromFile(fileContent, filename) {
|
|
|
200879
200879
|
visit(sourceFile);
|
|
200880
200880
|
return imports;
|
|
200881
200881
|
}
|
|
200882
|
-
async function installAllLibraries(includeAll) {
|
|
200882
|
+
async function installAllLibraries(includeAll, targetPath) {
|
|
200883
200883
|
const libsPath = path2.join(SOURCE_DATA_FOLDER, "requiredLibs.ts");
|
|
200884
200884
|
const { requiredLibs, requiredLibsAll } = await import(libsPath);
|
|
200885
200885
|
const libs = includeAll ? requiredLibsAll : requiredLibs;
|
|
200886
|
-
await installDependencies(libs.split(" "));
|
|
200886
|
+
await installDependencies(libs.split(" "), targetPath);
|
|
200887
200887
|
}
|
|
200888
200888
|
async function ensureUtilsFile(targetPath, config) {
|
|
200889
200889
|
const componentsBase = config?.components || "app/";
|
|
@@ -200945,12 +200945,12 @@ async function fullInstall(includePremium, useNgin, targetPath, config) {
|
|
|
200945
200945
|
}
|
|
200946
200946
|
await ensureUtilsFile(targetPath, config);
|
|
200947
200947
|
}
|
|
200948
|
-
async function installComponentsAndLibs(includePremium) {
|
|
200949
|
-
await installAllComponents(includePremium);
|
|
200950
|
-
await installAllLibraries(includePremium);
|
|
200951
|
-
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);
|
|
200952
200952
|
}
|
|
200953
|
-
async function selectComponentsInteractive(includePremium) {
|
|
200953
|
+
async function selectComponentsInteractive(includePremium, targetPath, config) {
|
|
200954
200954
|
const allComponents = await getComponentsData(includePremium);
|
|
200955
200955
|
const categories = [...new Set(allComponents.map((c) => c.category))];
|
|
200956
200956
|
const { selectedCategory } = await lib_default.prompt([
|
|
@@ -200984,25 +200984,67 @@ async function selectComponentsInteractive(includePremium) {
|
|
|
200984
200984
|
for (const componentValue of selectedComponents) {
|
|
200985
200985
|
const component = componentsToShow.find((c) => c.value === componentValue);
|
|
200986
200986
|
if (component) {
|
|
200987
|
-
await createComponentFile(component);
|
|
200987
|
+
await createComponentFile(component, targetPath, config);
|
|
200988
200988
|
}
|
|
200989
200989
|
}
|
|
200990
|
-
await ensureUtilsFile();
|
|
200991
|
-
await createIndexFiles();
|
|
200990
|
+
await ensureUtilsFile(targetPath, config);
|
|
200991
|
+
await createIndexFiles(targetPath, config);
|
|
200992
200992
|
spinner.succeed(source_default.green(`Installed ${selectedComponents.length} components`));
|
|
200993
200993
|
}
|
|
200994
200994
|
async function configureProjectPaths(targetPath, config) {
|
|
200995
200995
|
const spinner = ora2("Configuring project paths...").start();
|
|
200996
|
-
|
|
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(/\/+$/, "") + "/";
|
|
200997
201012
|
const pathsToAdd = {
|
|
201013
|
+
"#icons": "@catalystsoftware/icons",
|
|
201014
|
+
"#catalyst": `./${base}components/catalyst-ui/index.ts`,
|
|
200998
201015
|
"#catalyst/*": `./${base}components/catalyst-ui/*`,
|
|
200999
|
-
"#
|
|
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`
|
|
201000
201026
|
};
|
|
201001
201027
|
try {
|
|
201002
201028
|
const pkgPath = path2.join(targetPath, "package.json");
|
|
201003
201029
|
const pkg = JSON.parse(await fs.readFile(pkgPath, "utf-8"));
|
|
201004
201030
|
pkg.imports = { ...pkg.imports, ...pathsToAdd };
|
|
201005
201031
|
await fs.writeFile(pkgPath, JSON.stringify(pkg, null, 2));
|
|
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
|
+
}
|
|
201006
201048
|
spinner.succeed(source_default.green("Aliases added to package.json"));
|
|
201007
201049
|
} catch (e) {
|
|
201008
201050
|
spinner.fail(source_default.red("Alias configuration failed"));
|
|
@@ -201105,7 +201147,7 @@ async function main2() {
|
|
|
201105
201147
|
customPath = path2.resolve(args[pathFlagIndex + 1]);
|
|
201106
201148
|
args.splice(pathFlagIndex, 2);
|
|
201107
201149
|
}
|
|
201108
|
-
const config = await loadConfig();
|
|
201150
|
+
const config = await loadConfig(customPath);
|
|
201109
201151
|
const hasSecretAccess = await checkSecretAccess(args);
|
|
201110
201152
|
const cleanArgs = args.filter((arg) => !arg.startsWith("-") && arg.length <= 50);
|
|
201111
201153
|
const componentArg = cleanArgs.find((arg) => arg.length < 50 && !arg.includes("/"));
|
|
@@ -201250,7 +201292,7 @@ async function main2() {
|
|
|
201250
201292
|
`));
|
|
201251
201293
|
const spinner = ora2({ frames: ["\u28F7", "\u28EF", "\u28DF", "\u287F", "\u28BF", "\u28FB", "\u28FD", "\u28FE"], suffixText: "Installing component..." }).start();
|
|
201252
201294
|
try {
|
|
201253
|
-
await installSpecificComponent(componentArg, hasSecretAccess, config);
|
|
201295
|
+
await installSpecificComponent(componentArg, hasSecretAccess, customPath, config);
|
|
201254
201296
|
spinner.succeed(source_default.green(`Successfully installed ${componentArg}`));
|
|
201255
201297
|
} catch (error) {
|
|
201256
201298
|
spinner.fail(source_default.red(`Failed to install ${componentArg}`));
|
|
@@ -201264,7 +201306,7 @@ async function main2() {
|
|
|
201264
201306
|
\u2605 Auto-installing based on catalyst.config.jsonc
|
|
201265
201307
|
`));
|
|
201266
201308
|
const useNgin = config["configure-tailwind.config"] === "ngin";
|
|
201267
|
-
await fullInstall(hasSecretAccess, useNgin, config);
|
|
201309
|
+
await fullInstall(hasSecretAccess, useNgin, customPath, config);
|
|
201268
201310
|
console.log(source_default.green(`
|
|
201269
201311
|
\u2714 Auto-installation complete!`));
|
|
201270
201312
|
return;
|
|
@@ -201275,6 +201317,6 @@ async function main2() {
|
|
|
201275
201317
|
} else {
|
|
201276
201318
|
action = await showFreeMenu();
|
|
201277
201319
|
}
|
|
201278
|
-
await handleAction(action, hasSecretAccess);
|
|
201320
|
+
await handleAction(action, hasSecretAccess, customPath, config);
|
|
201279
201321
|
}
|
|
201280
201322
|
main2().catch(console.error);
|