mushroom-cli 2.0.0-alpha.3 → 2.0.0-alpha.5

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/README.md CHANGED
@@ -130,6 +130,19 @@ npx mushroom-cli parameters --no-check-update
130
130
 
131
131
  ## Version
132
132
 
133
+ ### 2.0.0-alpha.4
134
+
135
+ Bug fixes:
136
+
137
+ - gen c#-mongo: fix missing the function handlers in extensions when generating RefactorHelper.cs file
138
+
139
+ ### 2.0.0-alpha.4
140
+
141
+ Bug fixes:
142
+
143
+ - gen ts-driver: fix the swapped extension exports. The `auth` feature now exports `Auth: AuthExtension` and the
144
+ `file` feature now exports `File: FileExtension` (previously the two were swapped)
145
+
133
146
  ### 2.0.0-alpha.3
134
147
 
135
148
  New features:
@@ -247,13 +247,13 @@ export function genTypescriptDriverString(aliasProject, source) {
247
247
  if (Array.isArray(aliasProject.features)) {
248
248
  if (aliasProject.features.includes('auth')) {
249
249
  extensionsImportLines.push('import * as AuthExtension from "mushroomjs-auth";');
250
- extensionsExportLines.push('File: FileExtension');
250
+ extensionsExportLines.push('Auth: AuthExtension');
251
251
  extensionsTypes.push('AuthExtension.IMushroomAuth & ');
252
252
  extensionsCodeLines.push('AuthExtension.useAuth(AuthExtension.AuthLocalStorage, mushroom);');
253
253
  }
254
254
  if (aliasProject.features.includes('file')) {
255
255
  extensionsImportLines.push('import * as FileExtension from "mushroomjs-file";');
256
- extensionsExportLines.push('Auth: AuthExtension');
256
+ extensionsExportLines.push('File: FileExtension');
257
257
  extensionsTypes.push('FileExtension.IMushroomFile & ');
258
258
  extensionsCodeLines.push('FileExtension.useFile(mushroom);');
259
259
  }
@@ -29,6 +29,17 @@ function transformViewNode(view) {
29
29
  return;
30
30
  view.parameters.forEach((p) => transformValidationNode(p.validation));
31
31
  }
32
+ function mergeObject(total, fragment, excludeFields = []) {
33
+ if (!fragment)
34
+ return;
35
+ Object.keys(fragment).forEach(key => {
36
+ if (excludeFields.includes(key))
37
+ return;
38
+ const newValue = fragment[key];
39
+ if (newValue !== undefined && newValue !== null)
40
+ total[key] = fragment[key];
41
+ });
42
+ }
32
43
  function mergeApiProject(totalProject, fragmentProject, options) {
33
44
  if (totalProject.name != null && fragmentProject.name != null && fragmentProject.name != totalProject.name)
34
45
  throw new Error(`Unable merge project '${fragmentProject.name}' into '${totalProject.name}'`);
@@ -108,11 +119,23 @@ function mergeApiProject(totalProject, fragmentProject, options) {
108
119
  fragmentProject.views[viewName].forEach(transformViewNode);
109
120
  }
110
121
  }
111
- for (const name in fragmentProject) {
112
- if (name === 'environmentVariables' || name === 'entities' || name === 'views' || name === '$schema')
113
- continue;
114
- totalProject[name] = fragmentProject[name];
122
+ if (fragmentProject.extensions) {
123
+ const fragmentExtensions = fragmentProject.extensions;
124
+ const totalExtensions = totalProject.extensions || {};
125
+ totalProject.extensions = totalExtensions;
126
+ Object.keys(fragmentExtensions).forEach(ext => {
127
+ const fragmentExtension = fragmentExtensions[ext];
128
+ const totalExtension = totalExtensions[ext] = totalExtensions[ext] || {};
129
+ if (fragmentExtension.description !== undefined && fragmentExtension.description !== null)
130
+ totalExtension.description = fragmentExtension.description;
131
+ if (fragmentExtension.startup !== undefined && fragmentExtension.startup !== null)
132
+ totalExtension.startup = fragmentExtension.startup;
133
+ mergeObject(totalExtension.config = totalExtension.config || {}, fragmentExtension.config);
134
+ mergeObject(totalExtension.ensureIndex = totalExtension.ensureIndex || {}, fragmentExtension.ensureIndex);
135
+ mergeObject(totalExtension.routes = totalExtension.routes || {}, fragmentExtension.routes);
136
+ });
115
137
  }
138
+ mergeObject(totalProject, fragmentProject, ['environmentVariables', 'extensions', 'entities', 'views', '$schema']);
116
139
  return totalProject;
117
140
  }
118
141
  export function processMasterFile(basePath, master) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mushroom-cli",
3
- "version": "2.0.0-alpha.3",
3
+ "version": "2.0.0-alpha.5",
4
4
  "description": "Mushroom CLI",
5
5
  "type": "module",
6
6
  "scripts": {