flarecms 0.2.6 → 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.
- package/dist/cli/commands.js +46 -18
- package/dist/cli/index.js +57 -19
- package/package.json +1 -1
package/dist/cli/commands.js
CHANGED
|
@@ -6693,7 +6693,7 @@ async function createPluginCommand() {
|
|
|
6693
6693
|
s3.start(`Creating ${import_picocolors.default.cyan(pluginNameHuman)}...`);
|
|
6694
6694
|
try {
|
|
6695
6695
|
cpSync(resolve(templateBase, "starter-plugin"), paths.targetPlugin, { recursive: true });
|
|
6696
|
-
cpSync(resolve(templateBase, "
|
|
6696
|
+
cpSync(resolve(templateBase, "playground"), paths.targetPlayground, { recursive: true });
|
|
6697
6697
|
const placeholders = {
|
|
6698
6698
|
"{{PLUGIN_NAME}}": pluginPackageName,
|
|
6699
6699
|
"{{PLUGIN_ID}}": pluginId,
|
|
@@ -6701,28 +6701,56 @@ async function createPluginCommand() {
|
|
|
6701
6701
|
"{{PLUGIN_PACKAGE_NAME}}": pluginPackageName,
|
|
6702
6702
|
"{{PLAYGROUND_NAME}}": playgroundName
|
|
6703
6703
|
};
|
|
6704
|
-
const
|
|
6705
|
-
|
|
6706
|
-
|
|
6707
|
-
|
|
6708
|
-
|
|
6709
|
-
|
|
6710
|
-
|
|
6711
|
-
|
|
6712
|
-
|
|
6713
|
-
|
|
6714
|
-
|
|
6715
|
-
|
|
6716
|
-
|
|
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
|
-
|
|
6720
|
-
|
|
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
|
-
|
|
6725
|
-
|
|
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
|
@@ -6694,7 +6694,7 @@ async function createPluginCommand() {
|
|
|
6694
6694
|
s3.start(`Creating ${import_picocolors.default.cyan(pluginNameHuman)}...`);
|
|
6695
6695
|
try {
|
|
6696
6696
|
cpSync(resolve(templateBase, "starter-plugin"), paths.targetPlugin, { recursive: true });
|
|
6697
|
-
cpSync(resolve(templateBase, "
|
|
6697
|
+
cpSync(resolve(templateBase, "playground"), paths.targetPlayground, { recursive: true });
|
|
6698
6698
|
const placeholders = {
|
|
6699
6699
|
"{{PLUGIN_NAME}}": pluginPackageName,
|
|
6700
6700
|
"{{PLUGIN_ID}}": pluginId,
|
|
@@ -6702,28 +6702,56 @@ async function createPluginCommand() {
|
|
|
6702
6702
|
"{{PLUGIN_PACKAGE_NAME}}": pluginPackageName,
|
|
6703
6703
|
"{{PLAYGROUND_NAME}}": playgroundName
|
|
6704
6704
|
};
|
|
6705
|
-
const
|
|
6706
|
-
|
|
6707
|
-
|
|
6708
|
-
|
|
6709
|
-
|
|
6710
|
-
|
|
6711
|
-
|
|
6712
|
-
|
|
6713
|
-
|
|
6714
|
-
|
|
6715
|
-
|
|
6716
|
-
|
|
6717
|
-
|
|
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
|
-
|
|
6721
|
-
|
|
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
|
-
|
|
6726
|
-
|
|
6753
|
+
patchDir(paths.targetPlugin);
|
|
6754
|
+
patchDir(paths.targetPlayground);
|
|
6727
6755
|
s3.stop("Plugin created!");
|
|
6728
6756
|
wt(`cd apps/${playgroundName}
|
|
6729
6757
|
bun install
|
|
@@ -6755,8 +6783,18 @@ async function mcpCommand(args) {
|
|
|
6755
6783
|
}
|
|
6756
6784
|
|
|
6757
6785
|
// src/cli/index.ts
|
|
6786
|
+
import { readFileSync as readFileSync2 } from "fs";
|
|
6787
|
+
import { resolve as resolve2, dirname } from "path";
|
|
6788
|
+
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
6789
|
+
var __dirname2 = dirname(fileURLToPath2(import.meta.url));
|
|
6790
|
+
var pkg = JSON.parse(readFileSync2(resolve2(__dirname2, "../../package.json"), "utf8"));
|
|
6791
|
+
var version = pkg.version;
|
|
6758
6792
|
async function main() {
|
|
6759
6793
|
const args = process.argv.slice(2);
|
|
6794
|
+
if (args.includes("-v") || args.includes("--version") || args[0] === "version") {
|
|
6795
|
+
console.log(version);
|
|
6796
|
+
process.exit(0);
|
|
6797
|
+
}
|
|
6760
6798
|
if (args[0] === "mcp") {
|
|
6761
6799
|
await mcpCommand(args.slice(1));
|
|
6762
6800
|
} else if (args[0] === "plugin" && args[1] === "create") {
|
|
@@ -6764,7 +6802,7 @@ async function main() {
|
|
|
6764
6802
|
} else if (args.length === 0 || args[0] === "create") {
|
|
6765
6803
|
await createProjectCommand();
|
|
6766
6804
|
} else {
|
|
6767
|
-
console.log("Unknown command. Available commands: create, plugin create, mcp");
|
|
6805
|
+
console.log("Unknown command. Available commands: create, plugin create, mcp, version");
|
|
6768
6806
|
process.exit(1);
|
|
6769
6807
|
}
|
|
6770
6808
|
}
|