mushroom-cli 1.1.0-alpha.4 → 1.1.0-alpha.8

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.7"${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
 
@@ -105,8 +105,9 @@ function genTypescriptDriverString(aliasProject, source) {
105
105
  const entities = common.getEntities(source, aliasProject.allowRoles);
106
106
 
107
107
  let code = `import mushroom, { defineAsyncResource, defineAsyncView, fireEvent, createRestfulAsyncFunction, IdType, IMushroom, Mushroom, MushroomRequest, MushroomRequestSetting, MushroomRestfulRequest, MushroomResponse, MushroomResourceBase, MushroomListResource, MushroomFindByIdResource, MushroomCreateResource, MushroomBatchCreateResource, MushroomUpdateResource, MushroomBatchUpdateResource, MushroomPartialUpdateResource, MushroomDeleteResource, MushroomBatchDeleteResource, MushroomExtensibleResource, MushroomViewFunction, MushroomError } from "mushroomjs";
108
- ${Array.isArray(aliasProject.features) && aliasProject.features.includes("auth") ? 'import { IMushroomAuth, useAuth, AuthLocalStorage } from "mushroomjs-auth";' : ""}
109
- ${Array.isArray(aliasProject.features) && aliasProject.features.includes("file") ? 'import { IMushroomFile, useFile } from "mushroomjs-file";' : ""}
108
+ export { defineAsyncResource, defineAsyncView, fireEvent, createRestfulAsyncFunction, IdType, IMushroom, Mushroom, MushroomRequest, MushroomRequestSetting, MushroomRestfulRequest, MushroomResponse, MushroomResourceBase, MushroomListResource, MushroomFindByIdResource, MushroomCreateResource, MushroomBatchCreateResource, MushroomUpdateResource, MushroomBatchUpdateResource, MushroomPartialUpdateResource, MushroomDeleteResource, MushroomBatchDeleteResource, MushroomExtensibleResource, MushroomViewFunction, MushroomError } from "mushroomjs";
109
+ ${Array.isArray(aliasProject.features) && aliasProject.features.includes("auth") ? 'import { IMushroomAuth, useAuth, AuthLocalStorage } from "mushroomjs-auth";\nexport { IMushroomAuth, AuthLocalStorage, useAuth, AuthSessionStorage, AuthStorage, AuthStorageConstructor, IAuthExtension, LogoutMode, NoAuthStorage } from "mushroomjs-auth";' : ""}
110
+ ${Array.isArray(aliasProject.features) && aliasProject.features.includes("file") ? 'import { IMushroomFile, useFile } from "mushroomjs-file";\nexport { IMushroomFile, useFile, FileContentFormat, IFileExtension, ImageHorizontalAlign, ImageOutputFormat, ImageVerticalAlign } from "mushroomjs-file";' : ""}
110
111
 
111
112
  export type ISODateValue = string | Date;
112
113
  export type IdValue = ${source.idType == "AutoIncInt" || source.idType == "AutoIncLong" ? "number" : "string"};
@@ -119,7 +120,7 @@ export type IdValue = ${source.idType == "AutoIncInt" || source.idType == "AutoI
119
120
 
120
121
  const entity = entities[entityName];
121
122
  const typescriptClassName = toTypeScriptClassName(entityName);
122
- code += `interface ${typescriptClassName} ${generateTypescriptClass(entity.fields)};
123
+ code += `export interface ${typescriptClassName} ${generateTypescriptClass(entity.fields)};
123
124
  `;
124
125
 
125
126
 
@@ -186,7 +187,7 @@ export type IdValue = ${source.idType == "AutoIncInt" || source.idType == "AutoI
186
187
  }
187
188
 
188
189
  if (customMethodCode) {
189
- code += `interface ${typescriptClassName}$CustomMethodResource {
190
+ code += `export interface ${typescriptClassName}$CustomMethodResource {
190
191
  ${customMethodCode}}
191
192
  `;
192
193
  iApiClassBody += ` & ${typescriptClassName}$CustomMethodResource`;
@@ -204,7 +205,7 @@ ${customMethodCode}}
204
205
 
205
206
  const viewParameterTypes = viewRoles.map(view => {
206
207
  const type = `${typescriptClassName}$ViewsResource_${viewName}View_${view.grant === "*" ? "" : toTypeScriptClassName(view.grant)}Parameters`;
207
- code += `interface ${type} ${generateTypescriptClassFromViewParameters(view.parameters)};
208
+ code += `export interface ${type} ${generateTypescriptClassFromViewParameters(view.parameters)};
208
209
  `;
209
210
  return `MushroomViewFunction<any, ${type}>`;
210
211
  });
@@ -213,7 +214,7 @@ ${customMethodCode}}
213
214
  }
214
215
 
215
216
  if (viewCode) {
216
- code += `interface ${typescriptClassName}$ViewsResource {
217
+ code += `export interface ${typescriptClassName}$ViewsResource {
217
218
  views: {${viewCode}
218
219
  }
219
220
  }
@@ -234,10 +235,10 @@ ${Array.isArray(aliasProject.features) && aliasProject.features.includes("auth")
234
235
  ${Array.isArray(aliasProject.features) && aliasProject.features.includes("auth") ? "useFile();" : ""}
235
236
  mushroom.$using(${JSON.stringify(common.getRootUrl(source))});
236
237
 
237
- interface IApi extends IMushroom {
238
+ export interface IApi extends IMushroom {
238
239
  ${iApiClassBody}};
239
240
 
240
- type Api = ${Array.isArray(aliasProject.features) && aliasProject.features.includes("auth") ? "IMushroomAuth & " : ""}${Array.isArray(aliasProject.features) && aliasProject.features.includes("file") ? "IMushroomFile & " : ""}IApi;
241
+ export type Api = ${Array.isArray(aliasProject.features) && aliasProject.features.includes("auth") ? "IMushroomAuth & " : ""}${Array.isArray(aliasProject.features) && aliasProject.features.includes("file") ? "IMushroomFile & " : ""}IApi;
241
242
 
242
243
  export default mushroom as Api;`;
243
244
 
@@ -266,7 +267,7 @@ export declare type IdValue = ${source.idType == "AutoIncInt" || source.idType =
266
267
 
267
268
  const entity = entities[entityName];
268
269
  const typescriptClassName = toTypeScriptClassName(entityName);
269
- code += `interface ${typescriptClassName} ${generateTypescriptClass(entity.fields)};
270
+ code += `export interface ${typescriptClassName} ${generateTypescriptClass(entity.fields)};
270
271
  `;
271
272
 
272
273
 
@@ -333,7 +334,7 @@ export declare type IdValue = ${source.idType == "AutoIncInt" || source.idType =
333
334
  }
334
335
 
335
336
  if (customMethodCode) {
336
- code += `interface ${typescriptClassName}$CustomMethodResource {
337
+ code += `export interface ${typescriptClassName}$CustomMethodResource {
337
338
  ${customMethodCode}}
338
339
  `;
339
340
  iApiClassBody += ` & ${typescriptClassName}$CustomMethodResource`;
@@ -351,7 +352,7 @@ ${customMethodCode}}
351
352
 
352
353
  const viewParameterTypes = viewRoles.map(view => {
353
354
  const type = `${typescriptClassName}$ViewsResource_${viewName}View_${view.grant === "*" ? "" : toTypeScriptClassName(view.grant)}Parameters`;
354
- code += `interface ${type} ${generateTypescriptClassFromViewParameters(view.parameters)};
355
+ code += `export interface ${type} ${generateTypescriptClassFromViewParameters(view.parameters)};
355
356
  `;
356
357
  return `MushroomViewFunction<any, ${type}>`;
357
358
  });
@@ -360,7 +361,7 @@ ${customMethodCode}}
360
361
  }
361
362
 
362
363
  if (viewCode) {
363
- code += `interface ${typescriptClassName}$ViewsResource {
364
+ code += `export interface ${typescriptClassName}$ViewsResource {
364
365
  views: {${viewCode}
365
366
  }
366
367
  }
@@ -373,7 +374,7 @@ ${customMethodCode}}
373
374
  }
374
375
 
375
376
  code += `
376
- interface IApi extends IMushroom {
377
+ export interface IApi extends IMushroom {
377
378
  ${iApiClassBody}};
378
379
 
379
380
  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
@@ -62,7 +62,7 @@ async function run(args) {
62
62
 
63
63
  if (checkUpdateTask !== null)
64
64
  try {
65
- var data = await checkUpdateTask;
65
+ var data = await checkUpdateTask;
66
66
  if (data["dist-tags"] && data["dist-tags"][currentDistTag] && data["dist-tags"][currentDistTag] !== package.version) {
67
67
  console.warn(`YOUR mushroom-cli VERSION IS NOT LATEST (dist-tags: ${currentDistTag}). PLEASE RUN: npm i mushroom-cli@${data["dist-tags"][currentDistTag]}`);
68
68
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mushroom-cli",
3
- "version": "1.1.0-alpha.4",
3
+ "version": "1.1.0-alpha.8",
4
4
  "description": "Mushroom CLI",
5
5
  "main": "mr.js",
6
6
  "scripts": {