@fydemy/cms 1.0.2 → 1.0.3
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/admin.template.tsx +661 -0
- package/dist/bin.js +89 -12
- package/dist/bin.js.map +1 -1
- package/dist/bin.mjs +89 -12
- package/dist/bin.mjs.map +1 -1
- package/dist/components/ui/badge.tsx +36 -0
- package/dist/components/ui/button.tsx +56 -0
- package/dist/components/ui/card.tsx +86 -0
- package/dist/components/ui/input.tsx +25 -0
- package/dist/components/ui/label.tsx +24 -0
- package/dist/components/ui/textarea.tsx +24 -0
- package/dist/components.json +16 -0
- package/dist/index.js +89 -12
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +89 -12
- package/dist/index.mjs.map +1 -1
- package/dist/lib/utils.ts +6 -0
- package/dist/login.template.tsx +126 -0
- package/package.json +4 -1
package/dist/index.js
CHANGED
|
@@ -1902,6 +1902,9 @@ function createAuthMiddleware(options = {}) {
|
|
|
1902
1902
|
// src/init/setup.ts
|
|
1903
1903
|
var import_promises2 = __toESM(require("fs/promises"));
|
|
1904
1904
|
var import_path3 = __toESM(require("path"));
|
|
1905
|
+
var import_child_process = require("child_process");
|
|
1906
|
+
var import_util = require("util");
|
|
1907
|
+
var execAsync = (0, import_util.promisify)(import_child_process.exec);
|
|
1905
1908
|
async function initCMS(config = {}) {
|
|
1906
1909
|
const contentDir = config.contentDir || "public/content";
|
|
1907
1910
|
const fullPath = import_path3.default.join(process.cwd(), contentDir);
|
|
@@ -1915,6 +1918,48 @@ async function initCMS(config = {}) {
|
|
|
1915
1918
|
return;
|
|
1916
1919
|
}
|
|
1917
1920
|
console.log("\u{1F680} Initializing @fydemy/cms...");
|
|
1921
|
+
console.log("\u{1F4E6} Checking dependencies...");
|
|
1922
|
+
try {
|
|
1923
|
+
const packageJsonPath = import_path3.default.join(process.cwd(), "package.json");
|
|
1924
|
+
const packageJson = JSON.parse(await import_promises2.default.readFile(packageJsonPath, "utf-8"));
|
|
1925
|
+
const dependencies = {
|
|
1926
|
+
...packageJson.dependencies,
|
|
1927
|
+
...packageJson.devDependencies
|
|
1928
|
+
};
|
|
1929
|
+
const missingDeps = [];
|
|
1930
|
+
if (!dependencies["@fydemy/cms"]) missingDeps.push("@fydemy/cms");
|
|
1931
|
+
if (!dependencies["tailwindcss"]) missingDeps.push("tailwindcss");
|
|
1932
|
+
if (!dependencies["class-variance-authority"])
|
|
1933
|
+
missingDeps.push("class-variance-authority");
|
|
1934
|
+
if (!dependencies["clsx"]) missingDeps.push("clsx");
|
|
1935
|
+
if (!dependencies["tailwind-merge"]) missingDeps.push("tailwind-merge");
|
|
1936
|
+
if (!dependencies["@radix-ui/react-slot"])
|
|
1937
|
+
missingDeps.push("@radix-ui/react-slot");
|
|
1938
|
+
if (!dependencies["@radix-ui/react-label"])
|
|
1939
|
+
missingDeps.push("@radix-ui/react-label");
|
|
1940
|
+
if (missingDeps.length > 0) {
|
|
1941
|
+
console.log(
|
|
1942
|
+
`\u{1F527} Installing missing dependencies: ${missingDeps.join(", ")}...`
|
|
1943
|
+
);
|
|
1944
|
+
let installCmd = "npm install";
|
|
1945
|
+
try {
|
|
1946
|
+
await import_promises2.default.access("pnpm-lock.yaml");
|
|
1947
|
+
installCmd = "pnpm add";
|
|
1948
|
+
} catch {
|
|
1949
|
+
try {
|
|
1950
|
+
await import_promises2.default.access("yarn.lock");
|
|
1951
|
+
installCmd = "yarn add";
|
|
1952
|
+
} catch {
|
|
1953
|
+
}
|
|
1954
|
+
}
|
|
1955
|
+
await execAsync(`${installCmd} ${missingDeps.join(" ")}`);
|
|
1956
|
+
console.log("\u2705 Dependencies installed");
|
|
1957
|
+
}
|
|
1958
|
+
} catch (error) {
|
|
1959
|
+
console.warn(
|
|
1960
|
+
"\u26A0\uFE0F Could not check/install dependencies automatically. Please ensure all dependencies are installed."
|
|
1961
|
+
);
|
|
1962
|
+
}
|
|
1918
1963
|
await import_promises2.default.mkdir(fullPath, { recursive: true });
|
|
1919
1964
|
const exampleContent = `---
|
|
1920
1965
|
title: Example Post
|
|
@@ -1940,23 +1985,55 @@ This is an example markdown file. You can edit or delete it from the admin dashb
|
|
|
1940
1985
|
const adminDir = import_path3.default.join(appDir, "admin");
|
|
1941
1986
|
const loginDir = import_path3.default.join(adminDir, "login");
|
|
1942
1987
|
await import_promises2.default.mkdir(loginDir, { recursive: true });
|
|
1943
|
-
await import_promises2.default.
|
|
1944
|
-
import_path3.default.join(
|
|
1945
|
-
|
|
1946
|
-
|
|
1947
|
-
|
|
1948
|
-
|
|
1988
|
+
const loginTemplate = await import_promises2.default.readFile(
|
|
1989
|
+
import_path3.default.join(__dirname, "login.template.tsx"),
|
|
1990
|
+
"utf-8"
|
|
1991
|
+
);
|
|
1992
|
+
const adminTemplate = await import_promises2.default.readFile(
|
|
1993
|
+
import_path3.default.join(__dirname, "admin.template.tsx"),
|
|
1994
|
+
"utf-8"
|
|
1995
|
+
);
|
|
1996
|
+
await import_promises2.default.writeFile(import_path3.default.join(adminDir, "page.tsx"), adminTemplate, "utf-8");
|
|
1997
|
+
await import_promises2.default.writeFile(import_path3.default.join(loginDir, "page.tsx"), loginTemplate, "utf-8");
|
|
1998
|
+
console.log("\u2705 Scaffolded Admin UI (shadcn/ui components)");
|
|
1999
|
+
const componentsDir = import_path3.default.join(process.cwd(), "components", "ui");
|
|
2000
|
+
const libDir = import_path3.default.join(process.cwd(), "lib");
|
|
2001
|
+
await import_promises2.default.mkdir(componentsDir, { recursive: true });
|
|
2002
|
+
await import_promises2.default.mkdir(libDir, { recursive: true });
|
|
2003
|
+
const utilsTemplate = await import_promises2.default.readFile(
|
|
2004
|
+
import_path3.default.join(__dirname, "lib", "utils.ts"),
|
|
2005
|
+
"utf-8"
|
|
2006
|
+
);
|
|
2007
|
+
await import_promises2.default.writeFile(import_path3.default.join(libDir, "utils.ts"), utilsTemplate, "utf-8");
|
|
2008
|
+
const componentFiles = [
|
|
2009
|
+
"button.tsx",
|
|
2010
|
+
"input.tsx",
|
|
2011
|
+
"card.tsx",
|
|
2012
|
+
"label.tsx",
|
|
2013
|
+
"textarea.tsx",
|
|
2014
|
+
"badge.tsx"
|
|
2015
|
+
];
|
|
2016
|
+
for (const componentFile of componentFiles) {
|
|
2017
|
+
const componentTemplate = await import_promises2.default.readFile(
|
|
2018
|
+
import_path3.default.join(__dirname, "components", "ui", componentFile),
|
|
2019
|
+
"utf-8"
|
|
2020
|
+
);
|
|
2021
|
+
await import_promises2.default.writeFile(
|
|
2022
|
+
import_path3.default.join(componentsDir, componentFile),
|
|
2023
|
+
componentTemplate,
|
|
2024
|
+
"utf-8"
|
|
2025
|
+
);
|
|
2026
|
+
}
|
|
2027
|
+
const componentsJsonTemplate = await import_promises2.default.readFile(
|
|
2028
|
+
import_path3.default.join(__dirname, "components.json"),
|
|
1949
2029
|
"utf-8"
|
|
1950
2030
|
);
|
|
1951
2031
|
await import_promises2.default.writeFile(
|
|
1952
|
-
import_path3.default.join(
|
|
1953
|
-
|
|
1954
|
-
|
|
1955
|
-
export default Login;
|
|
1956
|
-
`,
|
|
2032
|
+
import_path3.default.join(process.cwd(), "components.json"),
|
|
2033
|
+
componentsJsonTemplate,
|
|
1957
2034
|
"utf-8"
|
|
1958
2035
|
);
|
|
1959
|
-
console.log("\u2705
|
|
2036
|
+
console.log("\u2705 Scaffolded shadcn/ui components");
|
|
1960
2037
|
const apiCmsDir = import_path3.default.join(appDir, "api", "cms");
|
|
1961
2038
|
await import_promises2.default.mkdir(import_path3.default.join(apiCmsDir, "login"), { recursive: true });
|
|
1962
2039
|
await import_promises2.default.writeFile(
|