mango-cms 0.1.12 → 0.1.13
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/cli.js +90 -0
- package/default/config/collections/examples.js +1 -1
- package/package.json +1 -1
- package/webpack.config.js +5 -2
package/cli.js
CHANGED
|
@@ -71,6 +71,42 @@ async function ensureLicenseExists(configPath) {
|
|
|
71
71
|
return settings.license;
|
|
72
72
|
}
|
|
73
73
|
|
|
74
|
+
// Helper function to check system dependencies
|
|
75
|
+
async function checkSystemDependencies() {
|
|
76
|
+
const checks = {
|
|
77
|
+
mongodb: false,
|
|
78
|
+
redis: false
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
console.log('Checking system dependencies...');
|
|
82
|
+
|
|
83
|
+
try {
|
|
84
|
+
execSync('mongod --version', { stdio: 'ignore' });
|
|
85
|
+
checks.mongodb = true;
|
|
86
|
+
} catch (error) {
|
|
87
|
+
console.log('❌ MongoDB is not installed. Please install MongoDB:');
|
|
88
|
+
console.log('Mac: brew install mongodb-community');
|
|
89
|
+
console.log('Linux: https://www.mongodb.com/docs/manual/administration/install-on-linux/');
|
|
90
|
+
console.log('Windows: https://www.mongodb.com/docs/manual/tutorial/install-mongodb-on-windows/\n');
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
try {
|
|
94
|
+
execSync('redis-cli --version', { stdio: 'ignore' });
|
|
95
|
+
checks.redis = true;
|
|
96
|
+
} catch (error) {
|
|
97
|
+
console.log('❌ Redis is not installed. Please install Redis:');
|
|
98
|
+
console.log('Mac: brew install redis');
|
|
99
|
+
console.log('Linux: https://redis.io/docs/getting-started/installation/install-redis-on-linux/');
|
|
100
|
+
console.log('Windows: https://redis.io/docs/getting-started/installation/install-redis-on-windows/\n');
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
if (checks.mongodb && checks.redis) {
|
|
104
|
+
console.log('✅ All system dependencies are installed.\n');
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
return checks;
|
|
108
|
+
}
|
|
109
|
+
|
|
74
110
|
program
|
|
75
111
|
.name('mango')
|
|
76
112
|
.description('Mango CMS CLI');
|
|
@@ -80,6 +116,7 @@ program
|
|
|
80
116
|
.description('Create a new Mango CMS project')
|
|
81
117
|
.action(async () => {
|
|
82
118
|
try {
|
|
119
|
+
|
|
83
120
|
const answers = await inquirer.prompt([
|
|
84
121
|
{
|
|
85
122
|
type: 'input',
|
|
@@ -144,7 +181,14 @@ To get started:
|
|
|
144
181
|
cd ${answers.projectName}
|
|
145
182
|
npm install
|
|
146
183
|
npm run mango start
|
|
184
|
+
|
|
185
|
+
Make sure MongoDB and Redis services are running before starting the application:
|
|
186
|
+
brew services start mongodb-community
|
|
187
|
+
brew services start redis
|
|
147
188
|
`);
|
|
189
|
+
|
|
190
|
+
await checkSystemDependencies();
|
|
191
|
+
|
|
148
192
|
} catch (error) {
|
|
149
193
|
console.error('Error creating project:', error.message);
|
|
150
194
|
process.exit(1);
|
|
@@ -156,6 +200,8 @@ program
|
|
|
156
200
|
.description('Start the Mango CMS in watch mode')
|
|
157
201
|
.action(async () => {
|
|
158
202
|
try {
|
|
203
|
+
// Check system dependencies first
|
|
204
|
+
await checkSystemDependencies();
|
|
159
205
|
|
|
160
206
|
// Check for license in settings.json
|
|
161
207
|
const settingsPath = path.join(process.cwd(), 'config/config/settings.json');
|
|
@@ -193,4 +239,48 @@ program
|
|
|
193
239
|
}
|
|
194
240
|
});
|
|
195
241
|
|
|
242
|
+
program
|
|
243
|
+
.command('build')
|
|
244
|
+
.description('Build the Mango CMS for production')
|
|
245
|
+
.action(async () => {
|
|
246
|
+
try {
|
|
247
|
+
// Check for license in settings.json
|
|
248
|
+
const settingsPath = path.join(process.cwd(), 'config/config/settings.json');
|
|
249
|
+
await ensureLicenseExists(settingsPath);
|
|
250
|
+
|
|
251
|
+
// Ensure src exists
|
|
252
|
+
await ensureSrcExists(__dirname);
|
|
253
|
+
|
|
254
|
+
// Path to @mango-cms/core inside node_modules
|
|
255
|
+
const cmsPackagePath = path.resolve(__dirname);
|
|
256
|
+
// User's project root (where they run "mango build")
|
|
257
|
+
const userProjectRoot = process.cwd();
|
|
258
|
+
|
|
259
|
+
console.log(`Building Mango CMS for production...`);
|
|
260
|
+
console.log(`CMS package located at: ${cmsPackagePath}`);
|
|
261
|
+
console.log(`Building in context of: ${userProjectRoot}`);
|
|
262
|
+
|
|
263
|
+
// Run Webpack with the config from @mango-cms/core in production mode
|
|
264
|
+
const webpackConfigPath = path.join(cmsPackagePath, 'webpack.config.js');
|
|
265
|
+
execSync(
|
|
266
|
+
`npx webpack --config "${webpackConfigPath}" --mode production`,
|
|
267
|
+
{
|
|
268
|
+
cwd: cmsPackagePath,
|
|
269
|
+
stdio: 'inherit',
|
|
270
|
+
env: {
|
|
271
|
+
...process.env,
|
|
272
|
+
NODE_ENV: 'production',
|
|
273
|
+
MANGO_ROOT: cmsPackagePath,
|
|
274
|
+
PROJECT_ROOT: userProjectRoot
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
);
|
|
278
|
+
|
|
279
|
+
console.log('\n✨ Build completed successfully!');
|
|
280
|
+
} catch (error) {
|
|
281
|
+
console.error('Error building Mango CMS:', error.message);
|
|
282
|
+
process.exit(1);
|
|
283
|
+
}
|
|
284
|
+
});
|
|
285
|
+
|
|
196
286
|
program.parse(process.argv);
|
package/package.json
CHANGED
package/webpack.config.js
CHANGED
|
@@ -4,8 +4,10 @@ const nodeExternals = require('webpack-node-externals');
|
|
|
4
4
|
const NodemonPlugin = require('nodemon-webpack-plugin');
|
|
5
5
|
|
|
6
6
|
// Get the user's project root from the execution context (passed via CLI or fallback to cwd)
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
process.env.PROJECT_ROOT = process.env.PROJECT_ROOT || process.cwd();
|
|
8
|
+
process.env.MANGO_ROOT = process.env.MANGO_ROOT || __dirname;
|
|
9
|
+
const userProjectRoot = process.env.PROJECT_ROOT
|
|
10
|
+
const mangoRoot = process.env.MANGO_ROOT
|
|
9
11
|
|
|
10
12
|
console.log('mangoRoot', mangoRoot)
|
|
11
13
|
|
|
@@ -16,6 +18,7 @@ module.exports = {
|
|
|
16
18
|
// CMS source code lives in @mango-cms/core/src/cms
|
|
17
19
|
'@mango': path.resolve(mangoRoot),
|
|
18
20
|
'@cms': path.resolve(mangoRoot, 'src/cms'),
|
|
21
|
+
'@fields': path.resolve(mangoRoot, 'src/cms/1. build/fields'),
|
|
19
22
|
// Config folder is in the user's project root
|
|
20
23
|
'@config': path.resolve(userProjectRoot, 'config'),
|
|
21
24
|
},
|