mango-cms 0.1.12 → 0.1.14

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');
@@ -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);
@@ -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.12",
3
+ "version": "0.1.14",
4
4
  "main": "index.js",
5
5
  "author": "Colton Neifert",
6
6
  "license": "ISC",
@@ -8,7 +8,10 @@
8
8
  "mango": "./cli.js"
9
9
  },
10
10
  "scripts": {
11
- "postinstall": ""
11
+ "postinstall": "",
12
+ "build": "npx webpack",
13
+ "watch": "NODE_OPTIONS='--trace-warnings' npx webpack --watch --mode development",
14
+ "dev": "NODE_OPTIONS='--trace-warnings' npx webpack --watch --mode development"
12
15
  },
13
16
  "dependencies": {
14
17
  "@aws-sdk/client-s3": "^3.423.0",
package/webpack.config.js CHANGED
@@ -3,20 +3,32 @@ const webpack = require('webpack');
3
3
  const nodeExternals = require('webpack-node-externals');
4
4
  const NodemonPlugin = require('nodemon-webpack-plugin');
5
5
 
6
+
6
7
  // 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;
8
+ process.env.PROJECT_ROOT = process.env.PROJECT_ROOT || process.cwd();
9
+ process.env.MANGO_ROOT = process.env.MANGO_ROOT || __dirname;
10
+ let moduleLocation = process.env.PROJECT_ROOT
11
+
12
+ let legacyMode = process.env.PROJECT_ROOT == process.env.MANGO_ROOT
13
+ if (legacyMode) {
14
+ moduleLocation = __dirname
15
+ process.env.PROJECT_ROOT = path.join(__dirname, '..')
16
+ }
17
+ console.log('env', process.env.PROJECT_ROOT, process.env.MANGO_ROOT, legacyMode, path.resolve(moduleLocation, 'node_modules'))
18
+
19
+ const userProjectRoot = process.env.PROJECT_ROOT
20
+ const mangoRoot = process.env.MANGO_ROOT
21
+ const buildPath = legacyMode ? mangoRoot : userProjectRoot
9
22
 
10
- console.log('mangoRoot', mangoRoot)
23
+ console.log('moduleLocation', moduleLocation)
11
24
 
12
25
  module.exports = {
13
26
  mode: 'production',
14
27
  resolve: {
15
28
  alias: {
16
- // CMS source code lives in @mango-cms/core/src/cms
17
29
  '@mango': path.resolve(mangoRoot),
18
30
  '@cms': path.resolve(mangoRoot, 'src/cms'),
19
- // Config folder is in the user's project root
31
+ '@fields': path.resolve(mangoRoot, 'src/cms/1. build/fields'),
20
32
  '@config': path.resolve(userProjectRoot, 'config'),
21
33
  },
22
34
  },
@@ -25,7 +37,7 @@ module.exports = {
25
37
  server: path.resolve(mangoRoot, 'src/main.js'), // Entry point in @mango-cms/core
26
38
  },
27
39
  output: {
28
- path: path.resolve(userProjectRoot, 'build'), // Output to user's project root
40
+ path: path.resolve(buildPath, 'build'), // Change to build in mango directory
29
41
  filename: 'index.js',
30
42
  },
31
43
  target: 'node',
@@ -38,7 +50,7 @@ module.exports = {
38
50
  nodeExternals(),
39
51
  // Also check for externals in the mango package
40
52
  nodeExternals({
41
- modulesDir: path.resolve(userProjectRoot, 'node_modules')
53
+ modulesDir: path.resolve(moduleLocation, 'node_modules')
42
54
  })
43
55
  ],
44
56
  };