mango-cms 0.3.2 → 0.3.21
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 +2 -2
- package/default/gitignore +2 -0
- package/default/package.json +1 -1
- package/default/public/index.js +45 -1
- package/package.json +4 -5
- package/vite.config.js +27 -4
package/cli.js
CHANGED
|
@@ -613,7 +613,7 @@ async function managePM2Process(settings) {
|
|
|
613
613
|
execSync(`pm2 reload ${processName}`);
|
|
614
614
|
} else {
|
|
615
615
|
console.log(`Starting new PM2 process: ${processName}`);
|
|
616
|
-
execSync(`pm2 start index.js --name ${processName}`, { cwd: './build' });
|
|
616
|
+
execSync(`NODE_ENV=production pm2 start index.js --name ${processName}`, { cwd: './build' });
|
|
617
617
|
}
|
|
618
618
|
|
|
619
619
|
processExists = processListOutput.includes(name);
|
|
@@ -623,7 +623,7 @@ async function managePM2Process(settings) {
|
|
|
623
623
|
execSync(`pm2 reload ${name}`);
|
|
624
624
|
} else {
|
|
625
625
|
console.log(`Starting new PM2 process: ${name}`);
|
|
626
|
-
execSync(`pm2 start index.js --name ${name}`, { cwd: './dist' });
|
|
626
|
+
execSync(`NODE_ENV=production pm2 start index.js --name ${name}`, { cwd: './dist' });
|
|
627
627
|
}
|
|
628
628
|
|
|
629
629
|
} catch (error) {
|
package/default/gitignore
CHANGED
package/default/package.json
CHANGED
package/default/public/index.js
CHANGED
|
@@ -1,6 +1,50 @@
|
|
|
1
1
|
const express = require('express');
|
|
2
2
|
const fs = require('fs')
|
|
3
|
-
const
|
|
3
|
+
const axiosOriginal = require('axios')
|
|
4
|
+
|
|
5
|
+
// Axios wrapper that handles errors gracefully
|
|
6
|
+
const axios = {
|
|
7
|
+
async get(...args) {
|
|
8
|
+
try {
|
|
9
|
+
return await axiosOriginal.get(...args)
|
|
10
|
+
} catch (error) {
|
|
11
|
+
console.error('Axios GET error:', error?.message || error)
|
|
12
|
+
return { data: null }
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
async post(...args) {
|
|
16
|
+
try {
|
|
17
|
+
return await axiosOriginal.post(...args)
|
|
18
|
+
} catch (error) {
|
|
19
|
+
console.error('Axios POST error:', error?.message || error)
|
|
20
|
+
return { data: null }
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
async put(...args) {
|
|
24
|
+
try {
|
|
25
|
+
return await axiosOriginal.put(...args)
|
|
26
|
+
} catch (error) {
|
|
27
|
+
console.error('Axios PUT error:', error?.message || error)
|
|
28
|
+
return { data: null }
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
async delete(...args) {
|
|
32
|
+
try {
|
|
33
|
+
return await axiosOriginal.delete(...args)
|
|
34
|
+
} catch (error) {
|
|
35
|
+
console.error('Axios DELETE error:', error?.message || error)
|
|
36
|
+
return { data: null }
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
async patch(...args) {
|
|
40
|
+
try {
|
|
41
|
+
return await axiosOriginal.patch(...args)
|
|
42
|
+
} catch (error) {
|
|
43
|
+
console.error('Axios PATCH error:', error?.message || error)
|
|
44
|
+
return { data: null }
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
4
48
|
const settings = require('../mango/config/settings.json')
|
|
5
49
|
const collections = require('../mango/config/.collections.json')
|
|
6
50
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mango-cms",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.21",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./index.js",
|
|
6
6
|
"exports": {
|
|
@@ -21,10 +21,9 @@
|
|
|
21
21
|
"mango": "cli.js"
|
|
22
22
|
},
|
|
23
23
|
"scripts": {
|
|
24
|
-
"
|
|
25
|
-
"
|
|
26
|
-
"
|
|
27
|
-
"dev": "vite build --watch"
|
|
24
|
+
"dev": "node cli.js dev",
|
|
25
|
+
"start": "node cli.js start",
|
|
26
|
+
"build": "node cli.js build"
|
|
28
27
|
},
|
|
29
28
|
"peerDependencies": {
|
|
30
29
|
"algoliasearch": "^4.10.3",
|
package/vite.config.js
CHANGED
|
@@ -19,21 +19,43 @@ export default defineConfig(({ mode }) => {
|
|
|
19
19
|
process.env.PROJECT_ROOT = userProjectRoot
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
// Determine config directory -
|
|
22
|
+
// Determine config directory - check for actual config files, not just folder existence
|
|
23
|
+
// 'mango/config' is the new structure, 'config/config' is legacy
|
|
23
24
|
let configDir = 'mango'
|
|
24
|
-
|
|
25
|
+
const mangoConfigPath = path.join(userProjectRoot, 'mango/config/settings.json')
|
|
26
|
+
const legacyConfigPath = path.join(userProjectRoot, 'config/config/settings.json')
|
|
27
|
+
|
|
28
|
+
if (fs.existsSync(mangoConfigPath)) {
|
|
29
|
+
configDir = 'mango'
|
|
30
|
+
} else if (fs.existsSync(legacyConfigPath)) {
|
|
25
31
|
configDir = 'config'
|
|
26
32
|
}
|
|
27
33
|
process.env.CONFIG_ROOT = path.join(userProjectRoot, configDir)
|
|
28
34
|
|
|
29
35
|
const buildPath = legacyMode ? mangoRoot : userProjectRoot
|
|
30
36
|
|
|
37
|
+
// Auto-detect dependencies to externalize (avoids bundling native modules, etc.)
|
|
38
|
+
const getDeps = (pkgPath) => {
|
|
39
|
+
if (!fs.existsSync(pkgPath)) return []
|
|
40
|
+
const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf-8'))
|
|
41
|
+
return [
|
|
42
|
+
...Object.keys(pkg.dependencies || {}),
|
|
43
|
+
...Object.keys(pkg.devDependencies || {})
|
|
44
|
+
]
|
|
45
|
+
}
|
|
46
|
+
const userExternals = [
|
|
47
|
+
...getDeps(path.join(userProjectRoot, 'package.json')),
|
|
48
|
+
...getDeps(path.join(mangoRoot, 'package.json'))
|
|
49
|
+
]
|
|
50
|
+
|
|
51
|
+
const allExternals = [...builtinModules, ...builtinModules.map(m => `node:${m}`), ...userExternals]
|
|
52
|
+
|
|
31
53
|
console.log('Vite config:', {
|
|
32
54
|
PROJECT_ROOT: process.env.PROJECT_ROOT,
|
|
33
55
|
MANGO_ROOT: mangoRoot,
|
|
34
56
|
CONFIG_ROOT: process.env.CONFIG_ROOT,
|
|
35
57
|
legacyMode,
|
|
36
|
-
buildPath
|
|
58
|
+
buildPath,
|
|
37
59
|
})
|
|
38
60
|
|
|
39
61
|
return {
|
|
@@ -44,6 +66,7 @@ export default defineConfig(({ mode }) => {
|
|
|
44
66
|
sourcemap: 'inline',
|
|
45
67
|
minify: mode === 'production',
|
|
46
68
|
rollupOptions: {
|
|
69
|
+
external: allExternals,
|
|
47
70
|
output: {
|
|
48
71
|
entryFileNames: 'index.js',
|
|
49
72
|
format: 'esm'
|
|
@@ -65,7 +88,7 @@ export default defineConfig(({ mode }) => {
|
|
|
65
88
|
]
|
|
66
89
|
},
|
|
67
90
|
ssr: {
|
|
68
|
-
external:
|
|
91
|
+
external: allExternals,
|
|
69
92
|
noExternal: []
|
|
70
93
|
},
|
|
71
94
|
define: {
|