mushroom-cli 1.1.0-alpha.3 → 1.1.0-alpha.7

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.
@@ -9,6 +9,8 @@ function processGenDocs(aliasProject, entities, source, html, args, projectName,
9
9
  console.log('Received html');
10
10
  console.log("Parsing html");
11
11
 
12
+ const roles = aliasProject.allowRoles.includes("*") ? source.roles : source.roles?.filter(r => aliasProject.allowRoles.includes(r.name));
13
+
12
14
  html = html.replace(/^\uFEFF/, '');
13
15
  html = html.replace(/<script src=(["'])\/\//g, "<script src=$1http://");
14
16
  html = html.replace("</body>", `<script data-mt-cond='{"x": 1}'>
@@ -16,9 +18,11 @@ function processGenDocs(aliasProject, entities, source, html, args, projectName,
16
18
  window.data.description = ${JSON.stringify(source.description)};
17
19
  window.data.rootUrl = ${JSON.stringify(common.getRootUrl(source))};
18
20
  window.data.environmentVariables = ${JSON.stringify(source.environmentVariables)};
21
+ window.data.roles = ${JSON.stringify(roles)};
19
22
  window.data.entities = ${JSON.stringify(entities)};
20
23
  window.data.features = ${JSON.stringify(aliasProject.features)};
21
- try{
24
+ try {
25
+ console.info("MUSHROOM-CLI: START");
22
26
  window.generateDocument();
23
27
  console.info("MUSHROOM-CLI: FINISH");
24
28
  }
@@ -31,6 +35,12 @@ function processGenDocs(aliasProject, entities, source, html, args, projectName,
31
35
  return new Promise((resolve, reject) => {
32
36
  const virtualConsole = new jsdom.VirtualConsole();
33
37
  virtualConsole.on("info", function(msg, err) {
38
+ if (typeof msg != "string") return;
39
+
40
+ if (msg.indexOf("MUSHROOM-CLI:") === 0) {
41
+ console.log("GenDocEngine:" + msg.substr("MUSHROOM-CLI:".length));
42
+ }
43
+
34
44
  if (msg === "MUSHROOM-CLI: FAIL"){
35
45
  dom = null;
36
46
  reject(err);
@@ -3,6 +3,7 @@ const path = require('path');
3
3
  var targz = require('targz');
4
4
  const javascriptDriverGenerator = require("./gen-js-driver");
5
5
  const typescriptDriverGenerator = require("./gen-ts-driver");
6
+ const package = require("./../package.json");
6
7
 
7
8
  function compressAsync(src, dest, folderName) {
8
9
  return new Promise((resolve, reject) => {
@@ -37,9 +38,18 @@ async function genJavascriptDriverTarball(args, projectName, project, alias, sou
37
38
  tarballName = tarballName.toLowerCase().replace(/[^a-z-]/g, "-");
38
39
 
39
40
  const dirPath = path.join(path.dirname(aliasProject.output), tarballName);
40
- //const mainFileName = path.basename(aliasProject.output);
41
- //const dtsFileName = mainFileName.replace(/\.js$/i, ".d.ts");
42
41
 
42
+ const versionGroup = package.version.match(/([^-]+)(-(\w+).*)?/);
43
+ const currentDistTag = versionGroup[3] ? versionGroup[3] : "latest";
44
+
45
+ const dependencies = [`"mushroomjs": "${currentDistTag}"`];
46
+ if (Array.isArray(aliasProject.features) && aliasProject.features.includes("auth")) {
47
+ dependencies.push(`"mushroomjs-auth": "${currentDistTag}"`);
48
+ }
49
+ if (Array.isArray(aliasProject.features) && aliasProject.features.includes("file")) {
50
+ dependencies.push(`"mushroomjs-file": "${currentDistTag}"`);
51
+ }
52
+
43
53
  const packageContent = `{
44
54
  "version": "1.0.${new Date().getTime()}",
45
55
  "name": "${tarballName}",
@@ -47,7 +57,7 @@ async function genJavascriptDriverTarball(args, projectName, project, alias, sou
47
57
  "main": "${tarballName}.js",
48
58
  "types": "${tarballName}.d.ts",
49
59
  "dependencies": {
50
- "mushroomjs": "^1.1.0-alpha.6"${Array.isArray(aliasProject.features) && aliasProject.features.includes("auth") ? ',\n "mushroomjs-auth": "^1.1.0-alpha.4"' : ""}${Array.isArray(aliasProject.features) && aliasProject.features.includes("file") ? ',\n "mushroomjs-file": "^1.1.0-alpha.1"' : ""}
60
+ ${dependencies.join(',\n ')}
51
61
  }
52
62
  }`;
53
63
 
@@ -119,7 +119,7 @@ export type IdValue = ${source.idType == "AutoIncInt" || source.idType == "AutoI
119
119
 
120
120
  const entity = entities[entityName];
121
121
  const typescriptClassName = toTypeScriptClassName(entityName);
122
- code += `interface ${typescriptClassName} ${generateTypescriptClass(entity.fields)};
122
+ code += `export interface ${typescriptClassName} ${generateTypescriptClass(entity.fields)};
123
123
  `;
124
124
 
125
125
 
@@ -186,7 +186,7 @@ export type IdValue = ${source.idType == "AutoIncInt" || source.idType == "AutoI
186
186
  }
187
187
 
188
188
  if (customMethodCode) {
189
- code += `interface ${typescriptClassName}$CustomMethodResource {
189
+ code += `export interface ${typescriptClassName}$CustomMethodResource {
190
190
  ${customMethodCode}}
191
191
  `;
192
192
  iApiClassBody += ` & ${typescriptClassName}$CustomMethodResource`;
@@ -204,7 +204,7 @@ ${customMethodCode}}
204
204
 
205
205
  const viewParameterTypes = viewRoles.map(view => {
206
206
  const type = `${typescriptClassName}$ViewsResource_${viewName}View_${view.grant === "*" ? "" : toTypeScriptClassName(view.grant)}Parameters`;
207
- code += `interface ${type} ${generateTypescriptClassFromViewParameters(view.parameters)};
207
+ code += `export interface ${type} ${generateTypescriptClassFromViewParameters(view.parameters)};
208
208
  `;
209
209
  return `MushroomViewFunction<any, ${type}>`;
210
210
  });
@@ -213,7 +213,7 @@ ${customMethodCode}}
213
213
  }
214
214
 
215
215
  if (viewCode) {
216
- code += `interface ${typescriptClassName}$ViewsResource {
216
+ code += `export interface ${typescriptClassName}$ViewsResource {
217
217
  views: {${viewCode}
218
218
  }
219
219
  }
@@ -234,10 +234,10 @@ ${Array.isArray(aliasProject.features) && aliasProject.features.includes("auth")
234
234
  ${Array.isArray(aliasProject.features) && aliasProject.features.includes("auth") ? "useFile();" : ""}
235
235
  mushroom.$using(${JSON.stringify(common.getRootUrl(source))});
236
236
 
237
- interface IApi extends IMushroom {
237
+ export interface IApi extends IMushroom {
238
238
  ${iApiClassBody}};
239
239
 
240
- type Api = ${Array.isArray(aliasProject.features) && aliasProject.features.includes("auth") ? "IMushroomAuth & " : ""}${Array.isArray(aliasProject.features) && aliasProject.features.includes("file") ? "IMushroomFile & " : ""}IApi;
240
+ export type Api = ${Array.isArray(aliasProject.features) && aliasProject.features.includes("auth") ? "IMushroomAuth & " : ""}${Array.isArray(aliasProject.features) && aliasProject.features.includes("file") ? "IMushroomFile & " : ""}IApi;
241
241
 
242
242
  export default mushroom as Api;`;
243
243
 
@@ -266,7 +266,7 @@ export declare type IdValue = ${source.idType == "AutoIncInt" || source.idType =
266
266
 
267
267
  const entity = entities[entityName];
268
268
  const typescriptClassName = toTypeScriptClassName(entityName);
269
- code += `interface ${typescriptClassName} ${generateTypescriptClass(entity.fields)};
269
+ code += `export interface ${typescriptClassName} ${generateTypescriptClass(entity.fields)};
270
270
  `;
271
271
 
272
272
 
@@ -333,7 +333,7 @@ export declare type IdValue = ${source.idType == "AutoIncInt" || source.idType =
333
333
  }
334
334
 
335
335
  if (customMethodCode) {
336
- code += `interface ${typescriptClassName}$CustomMethodResource {
336
+ code += `export interface ${typescriptClassName}$CustomMethodResource {
337
337
  ${customMethodCode}}
338
338
  `;
339
339
  iApiClassBody += ` & ${typescriptClassName}$CustomMethodResource`;
@@ -351,7 +351,7 @@ ${customMethodCode}}
351
351
 
352
352
  const viewParameterTypes = viewRoles.map(view => {
353
353
  const type = `${typescriptClassName}$ViewsResource_${viewName}View_${view.grant === "*" ? "" : toTypeScriptClassName(view.grant)}Parameters`;
354
- code += `interface ${type} ${generateTypescriptClassFromViewParameters(view.parameters)};
354
+ code += `export interface ${type} ${generateTypescriptClassFromViewParameters(view.parameters)};
355
355
  `;
356
356
  return `MushroomViewFunction<any, ${type}>`;
357
357
  });
@@ -360,7 +360,7 @@ ${customMethodCode}}
360
360
  }
361
361
 
362
362
  if (viewCode) {
363
- code += `interface ${typescriptClassName}$ViewsResource {
363
+ code += `export interface ${typescriptClassName}$ViewsResource {
364
364
  views: {${viewCode}
365
365
  }
366
366
  }
@@ -373,7 +373,7 @@ ${customMethodCode}}
373
373
  }
374
374
 
375
375
  code += `
376
- interface IApi extends IMushroom {
376
+ export interface IApi extends IMushroom {
377
377
  ${iApiClassBody}};
378
378
 
379
379
  declare type Api = ${Array.isArray(aliasProject.features) && aliasProject.features.includes("auth") ? "IMushroomAuth & " : ""}${Array.isArray(aliasProject.features) && aliasProject.features.includes("file") ? "IMushroomFile & " : ""}IApi;
package/mr.js CHANGED
@@ -8,7 +8,9 @@ const help = require("./help.js");
8
8
  const package = require("./package.json");
9
9
  const checkUpdate = require("./check-update");
10
10
 
11
- const currentDistTag = 'alpha';
11
+ const versionGroup = package.version.match(/([^-]+)(-(\w+).*)?/);
12
+ const currentDistTag = versionGroup[3] ? versionGroup[3] : "latest";
13
+ console.log("Mushroom CLI version " + package.version);
12
14
 
13
15
  async function run(args) {
14
16
  let debugMode = false;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mushroom-cli",
3
- "version": "1.1.0-alpha.3",
3
+ "version": "1.1.0-alpha.7",
4
4
  "description": "Mushroom CLI",
5
5
  "main": "mr.js",
6
6
  "scripts": {