flarecms 0.2.5 → 0.2.6

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.
@@ -6494,71 +6494,96 @@ async function createProjectCommand() {
6494
6494
  const cliDir = resolve(currentFilePath, "..");
6495
6495
  const localTemplatesRoot = resolve(cliDir, "..", "..", "..", "..", "templates");
6496
6496
  if (templateKey === "plugin-development") {
6497
- const pkgPath = resolve(projectDir, "package.json");
6498
- const rootPkg = {
6499
- name: projectName,
6500
- version: "0.1.0",
6501
- private: true,
6502
- workspaces: ["plugins/*", "apps/*"],
6503
- scripts: {
6504
- dev: "bun --cwd apps/playground dev"
6505
- }
6506
- };
6507
- mkdirSync(resolve(projectDir, "plugins"), { recursive: true });
6508
- mkdirSync(resolve(projectDir, "apps"), { recursive: true });
6509
- const localPluginPath = resolve(localTemplatesRoot, "plugin-development", "starter-plugin");
6510
- const localPlaygroundPath = resolve(localTemplatesRoot, "plugin-development", "playground");
6511
- if (existsSync2(localPluginPath) && existsSync2(localPlaygroundPath)) {
6512
- cpSync(localPluginPath, resolve(projectDir, "plugins", "starter-plugin"), { recursive: true });
6513
- cpSync(localPlaygroundPath, resolve(projectDir, "apps", "playground"), { recursive: true });
6514
- } else {
6515
- try {
6516
- await downloadTemplate("github:fhorray/flarecms/templates/plugin-development/starter-plugin", {
6517
- dir: resolve(projectDir, "plugins/starter-plugin"),
6518
- force: true
6519
- });
6520
- await downloadTemplate("github:fhorray/flarecms/templates/plugin-development/playground", {
6521
- dir: resolve(projectDir, "apps/playground"),
6522
- force: true
6523
- });
6524
- } catch (err) {
6525
- throw new Error(`Failed to download plugin templates: ${err instanceof Error ? err.message : String(err)}`);
6526
- }
6527
- }
6528
6497
  const pluginId = projectName.toLowerCase().replace(/[^a-z0-9]/g, "-");
6529
6498
  const pluginPackageName = `@flarecms/plugin-${pluginId}`;
6530
6499
  const pluginNameHuman = projectName.split(/[-_]/).map((word) => word.charAt(0).toUpperCase() + word.slice(1)).join(" ");
6500
+ const playgroundName = `${pluginId}-playground`;
6531
6501
  const placeholders = {
6532
6502
  "{{PLUGIN_ID}}": pluginId,
6533
6503
  "{{PLUGIN_NAME}}": pluginPackageName,
6534
6504
  "{{PLUGIN_PACKAGE_NAME}}": pluginPackageName,
6535
6505
  "{{PLUGIN_NAME_HUMAN}}": pluginNameHuman,
6536
- "{{PLAYGROUND_NAME}}": `${pluginId}-playground`
6506
+ "{{PLAYGROUND_NAME}}": playgroundName
6537
6507
  };
6538
- const patchManifest = (path) => {
6539
- if (!existsSync2(path))
6508
+ const TEXT_EXTENSIONS = new Set([
6509
+ ".ts",
6510
+ ".tsx",
6511
+ ".js",
6512
+ ".jsx",
6513
+ ".json",
6514
+ ".html",
6515
+ ".css",
6516
+ ".md",
6517
+ ".txt",
6518
+ ".toml",
6519
+ ".jsonc",
6520
+ ".env",
6521
+ ".env.example"
6522
+ ]);
6523
+ const patchFile = (filePath) => {
6524
+ const ext = filePath.slice(filePath.lastIndexOf(".")).toLowerCase();
6525
+ if (!TEXT_EXTENSIONS.has(ext))
6540
6526
  return;
6541
- let content = readFileSync(path, "utf-8");
6527
+ let content = readFileSync(filePath, "utf-8");
6542
6528
  for (const [key, value] of Object.entries(placeholders)) {
6543
6529
  content = content.replaceAll(key, value);
6544
6530
  }
6545
- const pkg = JSON.parse(content);
6546
- if (pkg.dependencies?.["flarecms"] === "workspace:*") {
6547
- pkg.dependencies["flarecms"] = "latest";
6531
+ if (ext === ".json" && filePath.endsWith("package.json")) {
6532
+ try {
6533
+ const pkg = JSON.parse(content);
6534
+ for (const field of ["dependencies", "devDependencies", "peerDependencies"]) {
6535
+ if (pkg[field]?.["flarecms"] === "workspace:*") {
6536
+ pkg[field]["flarecms"] = "latest";
6537
+ }
6538
+ }
6539
+ content = JSON.stringify(pkg, null, 2) + `
6540
+ `;
6541
+ } catch {}
6542
+ }
6543
+ writeFileSync(filePath, content);
6544
+ };
6545
+ const patchDir = (dir) => {
6546
+ for (const entry of readdirSync2(dir, { withFileTypes: true })) {
6547
+ const full = resolve(dir, entry.name);
6548
+ if (entry.isDirectory()) {
6549
+ if (entry.name !== "node_modules" && entry.name !== ".git") {
6550
+ patchDir(full);
6551
+ }
6552
+ } else {
6553
+ patchFile(full);
6554
+ }
6555
+ }
6556
+ };
6557
+ const localPluginSrc = resolve(localTemplatesRoot, "plugin-development", "starter-plugin");
6558
+ const localPlaygroundSrc = resolve(localTemplatesRoot, "plugin-development", "playground");
6559
+ const destPlugin = resolve(projectDir, "starter-plugin");
6560
+ const destPlayground = resolve(projectDir, "playground");
6561
+ if (existsSync2(localPluginSrc) && existsSync2(localPlaygroundSrc)) {
6562
+ mkdirSync(projectDir, { recursive: true });
6563
+ cpSync(localPluginSrc, destPlugin, { recursive: true });
6564
+ cpSync(localPlaygroundSrc, destPlayground, { recursive: true });
6565
+ } else {
6566
+ mkdirSync(projectDir, { recursive: true });
6567
+ try {
6568
+ await downloadTemplate("github:fhorray/flarecms/templates/plugin-development/starter-plugin", { dir: destPlugin, force: true });
6569
+ await downloadTemplate("github:fhorray/flarecms/templates/plugin-development/playground", { dir: destPlayground, force: true });
6570
+ } catch (err) {
6571
+ throw new Error(`Failed to download plugin templates: ${err instanceof Error ? err.message : String(err)}`);
6548
6572
  }
6549
- if (pkg.devDependencies?.["flarecms"] === "workspace:*") {
6550
- pkg.devDependencies["flarecms"] = "latest";
6573
+ }
6574
+ const rootPkg = {
6575
+ name: projectName,
6576
+ version: "0.1.0",
6577
+ private: true,
6578
+ workspaces: ["starter-plugin", "playground"],
6579
+ scripts: {
6580
+ dev: "bun --cwd playground dev",
6581
+ build: "bun --cwd playground build"
6551
6582
  }
6552
- if (path === pkgPath)
6553
- pkg.name = projectName;
6554
- writeFileSync(path, JSON.stringify(pkg, null, 2) + `
6555
- `);
6556
6583
  };
6557
- writeFileSync(pkgPath, JSON.stringify(rootPkg, null, 2) + `
6584
+ writeFileSync(resolve(projectDir, "package.json"), JSON.stringify(rootPkg, null, 2) + `
6558
6585
  `);
6559
- patchManifest(pkgPath);
6560
- patchManifest(resolve(projectDir, "plugins/starter-plugin/package.json"));
6561
- patchManifest(resolve(projectDir, "apps/playground/package.json"));
6586
+ patchDir(projectDir);
6562
6587
  } else {
6563
6588
  const template = TEMPLATES[templateKey];
6564
6589
  const localTemplatePath = resolve(localTemplatesRoot, template.dir.split("/").pop() || "");
package/dist/cli/index.js CHANGED
@@ -6495,71 +6495,96 @@ async function createProjectCommand() {
6495
6495
  const cliDir = resolve(currentFilePath, "..");
6496
6496
  const localTemplatesRoot = resolve(cliDir, "..", "..", "..", "..", "templates");
6497
6497
  if (templateKey === "plugin-development") {
6498
- const pkgPath = resolve(projectDir, "package.json");
6499
- const rootPkg = {
6500
- name: projectName,
6501
- version: "0.1.0",
6502
- private: true,
6503
- workspaces: ["plugins/*", "apps/*"],
6504
- scripts: {
6505
- dev: "bun --cwd apps/playground dev"
6506
- }
6507
- };
6508
- mkdirSync(resolve(projectDir, "plugins"), { recursive: true });
6509
- mkdirSync(resolve(projectDir, "apps"), { recursive: true });
6510
- const localPluginPath = resolve(localTemplatesRoot, "plugin-development", "starter-plugin");
6511
- const localPlaygroundPath = resolve(localTemplatesRoot, "plugin-development", "playground");
6512
- if (existsSync2(localPluginPath) && existsSync2(localPlaygroundPath)) {
6513
- cpSync(localPluginPath, resolve(projectDir, "plugins", "starter-plugin"), { recursive: true });
6514
- cpSync(localPlaygroundPath, resolve(projectDir, "apps", "playground"), { recursive: true });
6515
- } else {
6516
- try {
6517
- await downloadTemplate("github:fhorray/flarecms/templates/plugin-development/starter-plugin", {
6518
- dir: resolve(projectDir, "plugins/starter-plugin"),
6519
- force: true
6520
- });
6521
- await downloadTemplate("github:fhorray/flarecms/templates/plugin-development/playground", {
6522
- dir: resolve(projectDir, "apps/playground"),
6523
- force: true
6524
- });
6525
- } catch (err) {
6526
- throw new Error(`Failed to download plugin templates: ${err instanceof Error ? err.message : String(err)}`);
6527
- }
6528
- }
6529
6498
  const pluginId = projectName.toLowerCase().replace(/[^a-z0-9]/g, "-");
6530
6499
  const pluginPackageName = `@flarecms/plugin-${pluginId}`;
6531
6500
  const pluginNameHuman = projectName.split(/[-_]/).map((word) => word.charAt(0).toUpperCase() + word.slice(1)).join(" ");
6501
+ const playgroundName = `${pluginId}-playground`;
6532
6502
  const placeholders = {
6533
6503
  "{{PLUGIN_ID}}": pluginId,
6534
6504
  "{{PLUGIN_NAME}}": pluginPackageName,
6535
6505
  "{{PLUGIN_PACKAGE_NAME}}": pluginPackageName,
6536
6506
  "{{PLUGIN_NAME_HUMAN}}": pluginNameHuman,
6537
- "{{PLAYGROUND_NAME}}": `${pluginId}-playground`
6507
+ "{{PLAYGROUND_NAME}}": playgroundName
6538
6508
  };
6539
- const patchManifest = (path) => {
6540
- if (!existsSync2(path))
6509
+ const TEXT_EXTENSIONS = new Set([
6510
+ ".ts",
6511
+ ".tsx",
6512
+ ".js",
6513
+ ".jsx",
6514
+ ".json",
6515
+ ".html",
6516
+ ".css",
6517
+ ".md",
6518
+ ".txt",
6519
+ ".toml",
6520
+ ".jsonc",
6521
+ ".env",
6522
+ ".env.example"
6523
+ ]);
6524
+ const patchFile = (filePath) => {
6525
+ const ext = filePath.slice(filePath.lastIndexOf(".")).toLowerCase();
6526
+ if (!TEXT_EXTENSIONS.has(ext))
6541
6527
  return;
6542
- let content = readFileSync(path, "utf-8");
6528
+ let content = readFileSync(filePath, "utf-8");
6543
6529
  for (const [key, value] of Object.entries(placeholders)) {
6544
6530
  content = content.replaceAll(key, value);
6545
6531
  }
6546
- const pkg = JSON.parse(content);
6547
- if (pkg.dependencies?.["flarecms"] === "workspace:*") {
6548
- pkg.dependencies["flarecms"] = "latest";
6532
+ if (ext === ".json" && filePath.endsWith("package.json")) {
6533
+ try {
6534
+ const pkg = JSON.parse(content);
6535
+ for (const field of ["dependencies", "devDependencies", "peerDependencies"]) {
6536
+ if (pkg[field]?.["flarecms"] === "workspace:*") {
6537
+ pkg[field]["flarecms"] = "latest";
6538
+ }
6539
+ }
6540
+ content = JSON.stringify(pkg, null, 2) + `
6541
+ `;
6542
+ } catch {}
6543
+ }
6544
+ writeFileSync(filePath, content);
6545
+ };
6546
+ const patchDir = (dir) => {
6547
+ for (const entry of readdirSync2(dir, { withFileTypes: true })) {
6548
+ const full = resolve(dir, entry.name);
6549
+ if (entry.isDirectory()) {
6550
+ if (entry.name !== "node_modules" && entry.name !== ".git") {
6551
+ patchDir(full);
6552
+ }
6553
+ } else {
6554
+ patchFile(full);
6555
+ }
6556
+ }
6557
+ };
6558
+ const localPluginSrc = resolve(localTemplatesRoot, "plugin-development", "starter-plugin");
6559
+ const localPlaygroundSrc = resolve(localTemplatesRoot, "plugin-development", "playground");
6560
+ const destPlugin = resolve(projectDir, "starter-plugin");
6561
+ const destPlayground = resolve(projectDir, "playground");
6562
+ if (existsSync2(localPluginSrc) && existsSync2(localPlaygroundSrc)) {
6563
+ mkdirSync(projectDir, { recursive: true });
6564
+ cpSync(localPluginSrc, destPlugin, { recursive: true });
6565
+ cpSync(localPlaygroundSrc, destPlayground, { recursive: true });
6566
+ } else {
6567
+ mkdirSync(projectDir, { recursive: true });
6568
+ try {
6569
+ await downloadTemplate("github:fhorray/flarecms/templates/plugin-development/starter-plugin", { dir: destPlugin, force: true });
6570
+ await downloadTemplate("github:fhorray/flarecms/templates/plugin-development/playground", { dir: destPlayground, force: true });
6571
+ } catch (err) {
6572
+ throw new Error(`Failed to download plugin templates: ${err instanceof Error ? err.message : String(err)}`);
6549
6573
  }
6550
- if (pkg.devDependencies?.["flarecms"] === "workspace:*") {
6551
- pkg.devDependencies["flarecms"] = "latest";
6574
+ }
6575
+ const rootPkg = {
6576
+ name: projectName,
6577
+ version: "0.1.0",
6578
+ private: true,
6579
+ workspaces: ["starter-plugin", "playground"],
6580
+ scripts: {
6581
+ dev: "bun --cwd playground dev",
6582
+ build: "bun --cwd playground build"
6552
6583
  }
6553
- if (path === pkgPath)
6554
- pkg.name = projectName;
6555
- writeFileSync(path, JSON.stringify(pkg, null, 2) + `
6556
- `);
6557
6584
  };
6558
- writeFileSync(pkgPath, JSON.stringify(rootPkg, null, 2) + `
6585
+ writeFileSync(resolve(projectDir, "package.json"), JSON.stringify(rootPkg, null, 2) + `
6559
6586
  `);
6560
- patchManifest(pkgPath);
6561
- patchManifest(resolve(projectDir, "plugins/starter-plugin/package.json"));
6562
- patchManifest(resolve(projectDir, "apps/playground/package.json"));
6587
+ patchDir(projectDir);
6563
6588
  } else {
6564
6589
  const template = TEMPLATES[templateKey];
6565
6590
  const localTemplatePath = resolve(localTemplatesRoot, template.dir.split("/").pop() || "");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "flarecms",
3
- "version": "0.2.5",
3
+ "version": "0.2.6",
4
4
  "license": "MIT",
5
5
  "description": "FlareCMS Monorepo: A lightweight CMS for the AI era.",
6
6
  "files": [