mango-cms 0.1.11 → 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 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');
@@ -182,7 +228,6 @@ program
182
228
  stdio: 'inherit',
183
229
  env: {
184
230
  ...process.env,
185
- NODE_PATH: path.resolve(cmsPackagePath, 'node_modules'),
186
231
  MANGO_ROOT: cmsPackagePath,
187
232
  PROJECT_ROOT: userProjectRoot
188
233
  }
@@ -194,4 +239,48 @@ program
194
239
  }
195
240
  });
196
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
+
197
286
  program.parse(process.argv);
@@ -12,7 +12,7 @@
12
12
  can be imported from the CMS.
13
13
  */
14
14
 
15
- import fields from '@cms/1. build/fields'
15
+ import fields from '@fields'
16
16
  let { Relationship, Image } = fields
17
17
 
18
18
  export default {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mango-cms",
3
- "version": "0.1.11",
3
+ "version": "0.1.13",
4
4
  "main": "index.js",
5
5
  "author": "Colton Neifert",
6
6
  "license": "ISC",
@@ -8,7 +8,7 @@
8
8
  "mango": "./cli.js"
9
9
  },
10
10
  "scripts": {
11
- "postinstall": "npm rebuild --force sharp"
11
+ "postinstall": ""
12
12
  },
13
13
  "dependencies": {
14
14
  "@aws-sdk/client-s3": "^3.423.0",
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
- const userProjectRoot = process.env.PROJECT_ROOT || process.cwd();
8
- const mangoRoot = process.env.MANGO_ROOT || __dirname;
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,17 +18,10 @@ 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
  },
22
- modules: [
23
- // Look for modules in mango's node_modules first
24
- path.resolve(mangoRoot, 'node_modules'),
25
- // Then look in the user's project node_modules
26
- path.resolve(userProjectRoot, 'node_modules'),
27
- // Finally fallback to the standard node resolution
28
- 'node_modules'
29
- ]
30
25
  },
31
26
  devtool: 'inline-source-map',
32
27
  entry: {
@@ -46,7 +41,7 @@ module.exports = {
46
41
  nodeExternals(),
47
42
  // Also check for externals in the mango package
48
43
  nodeExternals({
49
- modulesDir: path.resolve(mangoRoot, 'node_modules')
44
+ modulesDir: path.resolve(userProjectRoot, 'node_modules')
50
45
  })
51
46
  ],
52
47
  };
Binary file