mango-cms 0.1.13 → 0.1.15

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
@@ -195,6 +195,35 @@ Make sure MongoDB and Redis services are running before starting the application
195
195
  }
196
196
  });
197
197
 
198
+ program
199
+ .command('init')
200
+ .description('Initialize Mango CMS config in the current directory')
201
+ .action(async () => {
202
+ try {
203
+ const currentDir = process.cwd();
204
+ const templateConfigDir = path.join(__dirname, 'default/config');
205
+ const targetConfigDir = path.join(currentDir, 'config');
206
+
207
+ // Check if config directory already exists
208
+ if (fs.existsSync(targetConfigDir)) {
209
+ console.log('⚠️ Config directory already exists. Please remove or rename it first.');
210
+ process.exit(1);
211
+ }
212
+
213
+ console.log('Initializing Mango CMS config...');
214
+
215
+ // Copy config directory
216
+ fs.copySync(templateConfigDir, targetConfigDir);
217
+
218
+ console.log(`
219
+ ✨ Mango CMS config initialized successfully!
220
+ `);
221
+ } catch (error) {
222
+ console.error('Error initializing Mango CMS:', error.message);
223
+ process.exit(1);
224
+ }
225
+ });
226
+
198
227
  program
199
228
  .command('start')
200
229
  .description('Start the Mango CMS in watch mode')
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mango-cms",
3
- "version": "0.1.13",
3
+ "version": "0.1.15",
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,23 +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
8
  process.env.PROJECT_ROOT = process.env.PROJECT_ROOT || process.cwd();
8
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
+
9
19
  const userProjectRoot = process.env.PROJECT_ROOT
10
20
  const mangoRoot = process.env.MANGO_ROOT
21
+ const buildPath = legacyMode ? mangoRoot : userProjectRoot
11
22
 
12
- console.log('mangoRoot', mangoRoot)
23
+ console.log('moduleLocation', moduleLocation)
13
24
 
14
25
  module.exports = {
15
26
  mode: 'production',
16
27
  resolve: {
17
28
  alias: {
18
- // CMS source code lives in @mango-cms/core/src/cms
19
29
  '@mango': path.resolve(mangoRoot),
20
30
  '@cms': path.resolve(mangoRoot, 'src/cms'),
21
31
  '@fields': path.resolve(mangoRoot, 'src/cms/1. build/fields'),
22
- // Config folder is in the user's project root
23
32
  '@config': path.resolve(userProjectRoot, 'config'),
24
33
  },
25
34
  },
@@ -28,7 +37,7 @@ module.exports = {
28
37
  server: path.resolve(mangoRoot, 'src/main.js'), // Entry point in @mango-cms/core
29
38
  },
30
39
  output: {
31
- path: path.resolve(userProjectRoot, 'build'), // Output to user's project root
40
+ path: path.resolve(buildPath, 'build'), // Change to build in mango directory
32
41
  filename: 'index.js',
33
42
  },
34
43
  target: 'node',
@@ -41,7 +50,7 @@ module.exports = {
41
50
  nodeExternals(),
42
51
  // Also check for externals in the mango package
43
52
  nodeExternals({
44
- modulesDir: path.resolve(userProjectRoot, 'node_modules')
53
+ modulesDir: path.resolve(moduleLocation, 'node_modules')
45
54
  })
46
55
  ],
47
56
  };