flarecms 0.2.4 → 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.
- package/dist/cli/commands.js +82 -24
- package/dist/cli/index.js +82 -24
- package/package.json +1 -1
package/dist/cli/commands.js
CHANGED
|
@@ -6494,38 +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
|
|
6498
|
-
const
|
|
6499
|
-
|
|
6500
|
-
|
|
6501
|
-
|
|
6502
|
-
|
|
6503
|
-
|
|
6504
|
-
|
|
6497
|
+
const pluginId = projectName.toLowerCase().replace(/[^a-z0-9]/g, "-");
|
|
6498
|
+
const pluginPackageName = `@flarecms/plugin-${pluginId}`;
|
|
6499
|
+
const pluginNameHuman = projectName.split(/[-_]/).map((word) => word.charAt(0).toUpperCase() + word.slice(1)).join(" ");
|
|
6500
|
+
const playgroundName = `${pluginId}-playground`;
|
|
6501
|
+
const placeholders = {
|
|
6502
|
+
"{{PLUGIN_ID}}": pluginId,
|
|
6503
|
+
"{{PLUGIN_NAME}}": pluginPackageName,
|
|
6504
|
+
"{{PLUGIN_PACKAGE_NAME}}": pluginPackageName,
|
|
6505
|
+
"{{PLUGIN_NAME_HUMAN}}": pluginNameHuman,
|
|
6506
|
+
"{{PLAYGROUND_NAME}}": playgroundName
|
|
6507
|
+
};
|
|
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))
|
|
6526
|
+
return;
|
|
6527
|
+
let content = readFileSync(filePath, "utf-8");
|
|
6528
|
+
for (const [key, value] of Object.entries(placeholders)) {
|
|
6529
|
+
content = content.replaceAll(key, value);
|
|
6530
|
+
}
|
|
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 {}
|
|
6505
6542
|
}
|
|
6543
|
+
writeFileSync(filePath, content);
|
|
6506
6544
|
};
|
|
6507
|
-
|
|
6508
|
-
|
|
6509
|
-
|
|
6510
|
-
|
|
6511
|
-
|
|
6512
|
-
|
|
6513
|
-
|
|
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 });
|
|
6514
6565
|
} else {
|
|
6566
|
+
mkdirSync(projectDir, { recursive: true });
|
|
6515
6567
|
try {
|
|
6516
|
-
await downloadTemplate("github:fhorray/flarecms/templates/plugin-development/starter-plugin", {
|
|
6517
|
-
|
|
6518
|
-
force: true
|
|
6519
|
-
});
|
|
6520
|
-
await downloadTemplate("github:fhorray/flarecms/templates/plugin-development/starter-playground", {
|
|
6521
|
-
dir: resolve(projectDir, "apps/playground"),
|
|
6522
|
-
force: true
|
|
6523
|
-
});
|
|
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 });
|
|
6524
6570
|
} catch (err) {
|
|
6525
6571
|
throw new Error(`Failed to download plugin templates: ${err instanceof Error ? err.message : String(err)}`);
|
|
6526
6572
|
}
|
|
6527
6573
|
}
|
|
6528
|
-
|
|
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"
|
|
6582
|
+
}
|
|
6583
|
+
};
|
|
6584
|
+
writeFileSync(resolve(projectDir, "package.json"), JSON.stringify(rootPkg, null, 2) + `
|
|
6585
|
+
`);
|
|
6586
|
+
patchDir(projectDir);
|
|
6529
6587
|
} else {
|
|
6530
6588
|
const template = TEMPLATES[templateKey];
|
|
6531
6589
|
const localTemplatePath = resolve(localTemplatesRoot, template.dir.split("/").pop() || "");
|
package/dist/cli/index.js
CHANGED
|
@@ -6495,38 +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
|
|
6499
|
-
const
|
|
6500
|
-
|
|
6501
|
-
|
|
6502
|
-
|
|
6503
|
-
|
|
6504
|
-
|
|
6505
|
-
|
|
6498
|
+
const pluginId = projectName.toLowerCase().replace(/[^a-z0-9]/g, "-");
|
|
6499
|
+
const pluginPackageName = `@flarecms/plugin-${pluginId}`;
|
|
6500
|
+
const pluginNameHuman = projectName.split(/[-_]/).map((word) => word.charAt(0).toUpperCase() + word.slice(1)).join(" ");
|
|
6501
|
+
const playgroundName = `${pluginId}-playground`;
|
|
6502
|
+
const placeholders = {
|
|
6503
|
+
"{{PLUGIN_ID}}": pluginId,
|
|
6504
|
+
"{{PLUGIN_NAME}}": pluginPackageName,
|
|
6505
|
+
"{{PLUGIN_PACKAGE_NAME}}": pluginPackageName,
|
|
6506
|
+
"{{PLUGIN_NAME_HUMAN}}": pluginNameHuman,
|
|
6507
|
+
"{{PLAYGROUND_NAME}}": playgroundName
|
|
6508
|
+
};
|
|
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))
|
|
6527
|
+
return;
|
|
6528
|
+
let content = readFileSync(filePath, "utf-8");
|
|
6529
|
+
for (const [key, value] of Object.entries(placeholders)) {
|
|
6530
|
+
content = content.replaceAll(key, value);
|
|
6531
|
+
}
|
|
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 {}
|
|
6506
6543
|
}
|
|
6544
|
+
writeFileSync(filePath, content);
|
|
6507
6545
|
};
|
|
6508
|
-
|
|
6509
|
-
|
|
6510
|
-
|
|
6511
|
-
|
|
6512
|
-
|
|
6513
|
-
|
|
6514
|
-
|
|
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 });
|
|
6515
6566
|
} else {
|
|
6567
|
+
mkdirSync(projectDir, { recursive: true });
|
|
6516
6568
|
try {
|
|
6517
|
-
await downloadTemplate("github:fhorray/flarecms/templates/plugin-development/starter-plugin", {
|
|
6518
|
-
|
|
6519
|
-
force: true
|
|
6520
|
-
});
|
|
6521
|
-
await downloadTemplate("github:fhorray/flarecms/templates/plugin-development/starter-playground", {
|
|
6522
|
-
dir: resolve(projectDir, "apps/playground"),
|
|
6523
|
-
force: true
|
|
6524
|
-
});
|
|
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 });
|
|
6525
6571
|
} catch (err) {
|
|
6526
6572
|
throw new Error(`Failed to download plugin templates: ${err instanceof Error ? err.message : String(err)}`);
|
|
6527
6573
|
}
|
|
6528
6574
|
}
|
|
6529
|
-
|
|
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"
|
|
6583
|
+
}
|
|
6584
|
+
};
|
|
6585
|
+
writeFileSync(resolve(projectDir, "package.json"), JSON.stringify(rootPkg, null, 2) + `
|
|
6586
|
+
`);
|
|
6587
|
+
patchDir(projectDir);
|
|
6530
6588
|
} else {
|
|
6531
6589
|
const template = TEMPLATES[templateKey];
|
|
6532
6590
|
const localTemplatePath = resolve(localTemplatesRoot, template.dir.split("/").pop() || "");
|