flarecms 0.2.7 → 0.2.8

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.
@@ -6701,28 +6701,56 @@ async function createPluginCommand() {
6701
6701
  "{{PLUGIN_PACKAGE_NAME}}": pluginPackageName,
6702
6702
  "{{PLAYGROUND_NAME}}": playgroundName
6703
6703
  };
6704
- const processFiles = (dir) => {
6705
- const entries = readdirSync2(dir, { withFileTypes: true });
6706
- for (const entry of entries) {
6707
- const fullPath = resolve(dir, entry.name);
6708
- if (entry.isDirectory()) {
6709
- processFiles(fullPath);
6710
- } else {
6711
- let content = readFileSync(fullPath, "utf8");
6712
- let changed = false;
6713
- for (const [placeholder, value] of Object.entries(placeholders)) {
6714
- if (content.includes(placeholder)) {
6715
- content = content.replaceAll(placeholder, value);
6716
- changed = true;
6704
+ const TEXT_EXTENSIONS = new Set([
6705
+ ".ts",
6706
+ ".tsx",
6707
+ ".js",
6708
+ ".jsx",
6709
+ ".json",
6710
+ ".html",
6711
+ ".css",
6712
+ ".md",
6713
+ ".txt",
6714
+ ".toml",
6715
+ ".jsonc",
6716
+ ".env",
6717
+ ".env.example"
6718
+ ]);
6719
+ const patchFile = (filePath) => {
6720
+ const ext = filePath.slice(filePath.lastIndexOf(".")).toLowerCase();
6721
+ if (!TEXT_EXTENSIONS.has(ext))
6722
+ return;
6723
+ let content = readFileSync(filePath, "utf-8");
6724
+ for (const [key, value] of Object.entries(placeholders)) {
6725
+ content = content.replaceAll(key, value);
6726
+ }
6727
+ if (ext === ".json" && filePath.endsWith("package.json")) {
6728
+ try {
6729
+ const pkg = JSON.parse(content);
6730
+ for (const field of ["dependencies", "devDependencies", "peerDependencies"]) {
6731
+ if (pkg[field]?.["flarecms"] === "workspace:*") {
6732
+ pkg[field]["flarecms"] = "latest";
6717
6733
  }
6718
6734
  }
6719
- if (changed)
6720
- writeFileSync(fullPath, content);
6735
+ content = JSON.stringify(pkg, null, 2) + `
6736
+ `;
6737
+ } catch {}
6738
+ }
6739
+ writeFileSync(filePath, content);
6740
+ };
6741
+ const patchDir = (dir) => {
6742
+ for (const entry of readdirSync2(dir, { withFileTypes: true })) {
6743
+ const full = resolve(dir, entry.name);
6744
+ if (entry.isDirectory()) {
6745
+ if (entry.name !== "node_modules" && entry.name !== ".git")
6746
+ patchDir(full);
6747
+ } else {
6748
+ patchFile(full);
6721
6749
  }
6722
6750
  }
6723
6751
  };
6724
- processFiles(paths.targetPlugin);
6725
- processFiles(paths.targetPlayground);
6752
+ patchDir(paths.targetPlugin);
6753
+ patchDir(paths.targetPlayground);
6726
6754
  s3.stop("Plugin created!");
6727
6755
  wt(`cd apps/${playgroundName}
6728
6756
  bun install
package/dist/cli/index.js CHANGED
@@ -6702,28 +6702,56 @@ async function createPluginCommand() {
6702
6702
  "{{PLUGIN_PACKAGE_NAME}}": pluginPackageName,
6703
6703
  "{{PLAYGROUND_NAME}}": playgroundName
6704
6704
  };
6705
- const processFiles = (dir) => {
6706
- const entries = readdirSync2(dir, { withFileTypes: true });
6707
- for (const entry of entries) {
6708
- const fullPath = resolve(dir, entry.name);
6709
- if (entry.isDirectory()) {
6710
- processFiles(fullPath);
6711
- } else {
6712
- let content = readFileSync(fullPath, "utf8");
6713
- let changed = false;
6714
- for (const [placeholder, value] of Object.entries(placeholders)) {
6715
- if (content.includes(placeholder)) {
6716
- content = content.replaceAll(placeholder, value);
6717
- changed = true;
6705
+ const TEXT_EXTENSIONS = new Set([
6706
+ ".ts",
6707
+ ".tsx",
6708
+ ".js",
6709
+ ".jsx",
6710
+ ".json",
6711
+ ".html",
6712
+ ".css",
6713
+ ".md",
6714
+ ".txt",
6715
+ ".toml",
6716
+ ".jsonc",
6717
+ ".env",
6718
+ ".env.example"
6719
+ ]);
6720
+ const patchFile = (filePath) => {
6721
+ const ext = filePath.slice(filePath.lastIndexOf(".")).toLowerCase();
6722
+ if (!TEXT_EXTENSIONS.has(ext))
6723
+ return;
6724
+ let content = readFileSync(filePath, "utf-8");
6725
+ for (const [key, value] of Object.entries(placeholders)) {
6726
+ content = content.replaceAll(key, value);
6727
+ }
6728
+ if (ext === ".json" && filePath.endsWith("package.json")) {
6729
+ try {
6730
+ const pkg = JSON.parse(content);
6731
+ for (const field of ["dependencies", "devDependencies", "peerDependencies"]) {
6732
+ if (pkg[field]?.["flarecms"] === "workspace:*") {
6733
+ pkg[field]["flarecms"] = "latest";
6718
6734
  }
6719
6735
  }
6720
- if (changed)
6721
- writeFileSync(fullPath, content);
6736
+ content = JSON.stringify(pkg, null, 2) + `
6737
+ `;
6738
+ } catch {}
6739
+ }
6740
+ writeFileSync(filePath, content);
6741
+ };
6742
+ const patchDir = (dir) => {
6743
+ for (const entry of readdirSync2(dir, { withFileTypes: true })) {
6744
+ const full = resolve(dir, entry.name);
6745
+ if (entry.isDirectory()) {
6746
+ if (entry.name !== "node_modules" && entry.name !== ".git")
6747
+ patchDir(full);
6748
+ } else {
6749
+ patchFile(full);
6722
6750
  }
6723
6751
  }
6724
6752
  };
6725
- processFiles(paths.targetPlugin);
6726
- processFiles(paths.targetPlayground);
6753
+ patchDir(paths.targetPlugin);
6754
+ patchDir(paths.targetPlayground);
6727
6755
  s3.stop("Plugin created!");
6728
6756
  wt(`cd apps/${playgroundName}
6729
6757
  bun install
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "flarecms",
3
- "version": "0.2.7",
3
+ "version": "0.2.8",
4
4
  "license": "MIT",
5
5
  "description": "FlareCMS Monorepo: A lightweight CMS for the AI era.",
6
6
  "files": [