mango-cms 0.2.46 → 0.2.47

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
@@ -168,6 +168,13 @@ program
168
168
  fs.mkdirSync(projectDir);
169
169
  fs.copySync(templateDir, projectDir, { filter: (src, dest) => true });
170
170
 
171
+ // Copy gitignore file (npm excludes .gitignore, so we store it as gitignore)
172
+ const gitignoreSource = path.join(templateDir, 'gitignore');
173
+ const gitignoreDest = path.join(projectDir, '.gitignore');
174
+ if (fs.existsSync(gitignoreSource)) {
175
+ fs.copySync(gitignoreSource, gitignoreDest);
176
+ }
177
+
171
178
  // Create config directory if it doesn't exist
172
179
  const configDir = path.join(projectDir, 'mango');
173
180
 
@@ -0,0 +1,5 @@
1
+ node_modules
2
+ .DS_store
3
+ yarn.lock
4
+ build
5
+ dist
@@ -4,7 +4,7 @@ let { PlainText, Select, Timestamp, Relationship } = fields
4
4
  export default {
5
5
 
6
6
  // title: PlainText({ required: true }),
7
- author: Relationship({ collection: 'member', single: true, computed: (doc, req) => [req?.member?.id] || [] }),
7
+ author: Relationship({ collection: 'member', single: true, default: (doc, req) => req?.member?.id || null }),
8
8
  editId: { computed: (doc, req) => req?.member?.id || null },
9
9
  created: { computed: doc => doc.created || new Date, type: 'Float' },
10
10
  updated: { computed: doc => doc.updated ? new Date : doc.created, type: 'Float' },
@@ -23,6 +23,7 @@
23
23
  "s3Bucket": "exampleBucket",
24
24
 
25
25
  "emailProvider": "resend",
26
+ "emailFrom": "Example <info@example.com>",
26
27
  "resendKey": null,
27
28
  "mailgunKey": null,
28
29
  "emailDomain": null,
@@ -87,6 +87,14 @@ const processFields = (fields, collectionName) => {
87
87
  return result
88
88
  }
89
89
 
90
+ // Function for setting cookies
91
+ let setCookie = function (cname, cvalue) {
92
+ var d = new Date();
93
+ d.setTime(d.getTime() + (365 * 24 * 60 * 60 * 1000));
94
+ var expires = "expires=" + d.toUTCString();
95
+ document.cookie = cname + "=" + cvalue + ";" + expires + ";path=/";
96
+ }
97
+
90
98
  const Mango = collections.reduce((a, c) => {
91
99
  let localDB = new LocalDB(c.name, api)
92
100
 
@@ -487,12 +495,22 @@ Mango.login = ({ email, password }) => {
487
495
  window.localStorage.setItem('token', response.data.token)
488
496
  window.localStorage.setItem('user', response.data.memberId)
489
497
  window.localStorage.setItem('email', email)
498
+ setCookie(`Authorization`, `${response.data.token}`)
490
499
  resolve(response.data)
491
500
  })
492
501
  .catch((e) => reject(e))
493
502
  })
494
503
  }
495
504
 
505
+ Mango.logout = (axios) => {
506
+ window.localStorage.removeItem('token')
507
+ window.localStorage.removeItem('user')
508
+ window.localStorage.removeItem('email')
509
+ setCookie(`Authorization`, ``)
510
+ if (axios) delete axios.defaults.headers.common['Authorization']
511
+ return true
512
+ }
513
+
496
514
  // Build endpoints from the generated .endpoints.json
497
515
  Mango.endpoints = Object.keys(endpointsData).reduce((acc, path) => {
498
516
  const methods = endpointsData[path]
@@ -71,5 +71,6 @@ export default defineConfig({
71
71
  },
72
72
  optimizeDeps: {
73
73
  exclude: ['vue', '@collections', '@settings', '@endpoints'], // Prevent Vite from optimizing Vue separately
74
+ include: ['socket.io-client'],
74
75
  },
75
76
  })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mango-cms",
3
- "version": "0.2.46",
3
+ "version": "0.2.47",
4
4
  "main": "./index.js",
5
5
  "exports": {
6
6
  ".": "./index.js",