@nextsparkjs/cli 0.1.0-beta.45 → 0.1.0-beta.47
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.js +52 -0
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -1634,6 +1634,44 @@ async function updatePermissionsConfig(config2) {
|
|
|
1634
1634
|
});
|
|
1635
1635
|
await fs2.writeFile(permissionsConfigPath, content, "utf-8");
|
|
1636
1636
|
}
|
|
1637
|
+
async function updateEntityPermissions(config2) {
|
|
1638
|
+
const permissionsConfigPath = path2.join(
|
|
1639
|
+
getTargetThemesDir2(),
|
|
1640
|
+
config2.projectSlug,
|
|
1641
|
+
"config",
|
|
1642
|
+
"permissions.config.ts"
|
|
1643
|
+
);
|
|
1644
|
+
if (!await fs2.pathExists(permissionsConfigPath)) {
|
|
1645
|
+
return;
|
|
1646
|
+
}
|
|
1647
|
+
let content = await fs2.readFile(permissionsConfigPath, "utf-8");
|
|
1648
|
+
if (config2.contentFeatures.pages) {
|
|
1649
|
+
content = uncommentPermissionBlock(content, "PAGES");
|
|
1650
|
+
}
|
|
1651
|
+
if (config2.contentFeatures.blog) {
|
|
1652
|
+
content = uncommentPermissionBlock(content, "POSTS");
|
|
1653
|
+
}
|
|
1654
|
+
await fs2.writeFile(permissionsConfigPath, content, "utf-8");
|
|
1655
|
+
}
|
|
1656
|
+
function uncommentPermissionBlock(content, markerName) {
|
|
1657
|
+
const startMarker = `// __${markerName}_PERMISSIONS_START__`;
|
|
1658
|
+
const endMarker = `// __${markerName}_PERMISSIONS_END__`;
|
|
1659
|
+
const startIndex = content.indexOf(startMarker);
|
|
1660
|
+
const endIndex = content.indexOf(endMarker);
|
|
1661
|
+
if (startIndex === -1 || endIndex === -1) {
|
|
1662
|
+
return content;
|
|
1663
|
+
}
|
|
1664
|
+
const beforeBlock = content.slice(0, startIndex);
|
|
1665
|
+
const block = content.slice(startIndex + startMarker.length, endIndex);
|
|
1666
|
+
const afterBlock = content.slice(endIndex + endMarker.length);
|
|
1667
|
+
const uncommentedBlock = block.split("\n").map((line) => {
|
|
1668
|
+
if (line.match(/^\s*\/\/\s+/)) {
|
|
1669
|
+
return line.replace(/^(\s*)\/\/\s*/, "$1");
|
|
1670
|
+
}
|
|
1671
|
+
return line;
|
|
1672
|
+
}).join("\n");
|
|
1673
|
+
return beforeBlock + uncommentedBlock + afterBlock;
|
|
1674
|
+
}
|
|
1637
1675
|
async function updateDashboardConfig(config2) {
|
|
1638
1676
|
const dashboardConfigPath = path2.join(
|
|
1639
1677
|
getTargetThemesDir2(),
|
|
@@ -1751,6 +1789,18 @@ async function copyEnvExampleToEnv() {
|
|
|
1751
1789
|
await fs2.copy(envExamplePath, envPath);
|
|
1752
1790
|
}
|
|
1753
1791
|
}
|
|
1792
|
+
async function updateGlobalsCss(config2) {
|
|
1793
|
+
const globalsCssPath = path2.resolve(process.cwd(), "app", "globals.css");
|
|
1794
|
+
if (!await fs2.pathExists(globalsCssPath)) {
|
|
1795
|
+
return;
|
|
1796
|
+
}
|
|
1797
|
+
let content = await fs2.readFile(globalsCssPath, "utf-8");
|
|
1798
|
+
content = content.replace(
|
|
1799
|
+
/@import\s+["']\.\.\/contents\/themes\/[^/]+\/styles\/globals\.css["'];?/,
|
|
1800
|
+
`@import "../contents/themes/${config2.projectSlug}/styles/globals.css";`
|
|
1801
|
+
);
|
|
1802
|
+
await fs2.writeFile(globalsCssPath, content, "utf-8");
|
|
1803
|
+
}
|
|
1754
1804
|
|
|
1755
1805
|
// src/wizard/generators/messages-generator.ts
|
|
1756
1806
|
import fs3 from "fs-extra";
|
|
@@ -2457,6 +2507,7 @@ contents/themes/*/tests/jest/coverage
|
|
|
2457
2507
|
}
|
|
2458
2508
|
async function generateProject(config2) {
|
|
2459
2509
|
await copyProjectFiles();
|
|
2510
|
+
await updateGlobalsCss(config2);
|
|
2460
2511
|
await copyStarterTheme(config2);
|
|
2461
2512
|
await copyContentFeatures(config2);
|
|
2462
2513
|
await updateThemeConfig(config2);
|
|
@@ -2467,6 +2518,7 @@ async function generateProject(config2) {
|
|
|
2467
2518
|
await updateMigrations(config2);
|
|
2468
2519
|
await updateTestFiles(config2);
|
|
2469
2520
|
await updatePermissionsConfig(config2);
|
|
2521
|
+
await updateEntityPermissions(config2);
|
|
2470
2522
|
await updateDashboardConfig(config2);
|
|
2471
2523
|
await updateAuthConfig(config2);
|
|
2472
2524
|
await updateDashboardUIConfig(config2);
|