mushroom-cli 1.2.0-alpha.8 → 1.2.0
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 +199 -154
- package/dist/check-update.js +6 -0
- package/dist/common.js +280 -0
- package/dist/config.js +394 -0
- package/dist/docs/bootstrap-theme.min.css +6 -0
- package/dist/docs/bootstrap.min.css +6 -0
- package/dist/docs/bootstrap.min.js +7 -0
- package/dist/docs/doc-mt.js +633 -0
- package/dist/docs/docs.html +5380 -0
- package/{docs → dist/docs}/docs.v2.html +5205 -6615
- package/dist/docs/docs.v2.js +2036 -0
- package/dist/docs/jquery.min.js +4 -0
- package/dist/docs/mt-dom-1.0.js +1398 -0
- package/dist/docs/mt.extension.js +199 -0
- package/dist/gen/gen-api-docs-v1.js +110 -0
- package/dist/gen/gen-api-docs.js +327 -0
- package/{gen → dist/gen}/gen-csharp.js +1256 -1399
- package/{gen → dist/gen}/gen-db-docs.js +204 -222
- package/{gen → dist/gen}/gen-js-driver-tarball.js +81 -101
- package/{gen → dist/gen}/gen-js-driver.js +116 -133
- package/dist/gen/gen-ts-driver.js +600 -0
- package/{gen.js → dist/gen.js} +109 -124
- package/{help.js → dist/help.js} +53 -55
- package/dist/init/init-json.js +92 -0
- package/dist/init/init-netcore.js +30 -0
- package/dist/init.js +23 -0
- package/dist/master-file/master-file.js +185 -0
- package/dist/merge.js +70 -0
- package/dist/mr.js +77 -0
- package/dist/types.js +1 -0
- package/dist/update/tsCode.js +82 -0
- package/dist/update.js +20 -0
- package/package.json +64 -28
- package/check-update.js +0 -9
- package/common.js +0 -273
- package/config.js +0 -445
- package/docs/doc-mt.js +0 -523
- package/docs/docs.html +0 -5190
- package/docs/mt-dom-1.0.js +0 -1268
- package/docs/mt.extension.js +0 -174
- package/gen/gen-api-docs-v1.js +0 -125
- package/gen/gen-api-docs.js +0 -259
- package/gen/gen-ts-driver.js +0 -471
- package/init/init-json.js +0 -106
- package/init/init-netcore.js +0 -32
- package/init.js +0 -28
- package/master-file/master-file.js +0 -234
- package/merge.js +0 -84
- package/mr.js +0 -86
- package/update/tsCode.js +0 -20
- package/update.js +0 -24
|
@@ -1,133 +1,116 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
let
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
!action.cache ||
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
var
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
mushroom
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
common.ensureFolder(aliasProject.output);
|
|
119
|
-
|
|
120
|
-
fs.writeFileSync(aliasProject.output, code);
|
|
121
|
-
console.log(`Generated ${aliasProject.output}`);
|
|
122
|
-
|
|
123
|
-
code = typescriptDriverGenerator.genDtsString(aliasProject, source);
|
|
124
|
-
const dtsFilePath = aliasProject.output.replace(/\.js$/i, ".d.ts");
|
|
125
|
-
fs.writeFileSync(dtsFilePath, code);
|
|
126
|
-
console.log(`Generated ${dtsFilePath}`);
|
|
127
|
-
console.log(`Generated Javascript driver for ${projectName}@${alias}`);
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
module.exports = {
|
|
131
|
-
genJavascriptDriver,
|
|
132
|
-
genJavascriptDriverString
|
|
133
|
-
};
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import * as common from '../common.js';
|
|
3
|
+
import * as typescriptDriverGenerator from './gen-ts-driver.js';
|
|
4
|
+
function isAllowCache(actions, defaultValue) {
|
|
5
|
+
let result = defaultValue;
|
|
6
|
+
for (let i = 0; i < actions.length; i++) {
|
|
7
|
+
const action = actions[i];
|
|
8
|
+
if (!action ||
|
|
9
|
+
!action.cache ||
|
|
10
|
+
!action.cache.client ||
|
|
11
|
+
!action.cache.client.policy ||
|
|
12
|
+
action.cache.client.policy === 'unset')
|
|
13
|
+
continue;
|
|
14
|
+
if (action.cache.client.policy === 'disabled')
|
|
15
|
+
return false;
|
|
16
|
+
if (action.cache.client.policy === 'allow' || action.cache.client.policy === 'required')
|
|
17
|
+
result = true;
|
|
18
|
+
}
|
|
19
|
+
return result;
|
|
20
|
+
}
|
|
21
|
+
export function genJavascriptDriverString(aliasProject, source) {
|
|
22
|
+
if (!aliasProject) {
|
|
23
|
+
return '';
|
|
24
|
+
}
|
|
25
|
+
const entities = common.getEntities(source, aliasProject.allowRoles);
|
|
26
|
+
const extensionsImportLines = [];
|
|
27
|
+
const extensionsExportLines = [];
|
|
28
|
+
const extensionsCodeLines = [];
|
|
29
|
+
if (Array.isArray(aliasProject.features)) {
|
|
30
|
+
if (aliasProject.features.includes('auth')) {
|
|
31
|
+
extensionsImportLines.push('//import * as AuthExtension from "mushroomjs-auth";');
|
|
32
|
+
extensionsImportLines.push('var AuthExtension = require("mushroomjs-auth");');
|
|
33
|
+
extensionsExportLines.push('Auth: AuthExtension');
|
|
34
|
+
extensionsCodeLines.push('AuthExtension.useAuth(AuthExtension.AuthLocalStorage, mushroom_1.default);');
|
|
35
|
+
}
|
|
36
|
+
if (aliasProject.features.includes('file')) {
|
|
37
|
+
extensionsImportLines.push('//import * as FileExtension from "mushroomjs-file";');
|
|
38
|
+
extensionsImportLines.push('var FileExtension = require("mushroomjs-file");');
|
|
39
|
+
extensionsExportLines.push('File: FileExtension');
|
|
40
|
+
extensionsCodeLines.push('FileExtension.useFile(mushroom_1.default);');
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
let code = `//import mushroom, {defineAsyncResource} from "mushroomjs";
|
|
44
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
45
|
+
var mushroom_1 = require("mushroomjs");
|
|
46
|
+
var mushroom = mushroom_1.default;
|
|
47
|
+
var defineAsyncResource = mushroom_1.defineAsyncResource;
|
|
48
|
+
|
|
49
|
+
//export * from "mushroomjs";
|
|
50
|
+
for (var m in mushroom_1) exports[m] = mushroom_1[m];
|
|
51
|
+
|
|
52
|
+
${extensionsImportLines.join('\n')}
|
|
53
|
+
//export const extensions = {
|
|
54
|
+
var extensions = {
|
|
55
|
+
${extensionsExportLines.join(',\n ')}
|
|
56
|
+
};
|
|
57
|
+
exports.extensions = extensions;
|
|
58
|
+
|
|
59
|
+
"use strict";
|
|
60
|
+
|
|
61
|
+
`;
|
|
62
|
+
for (const entityName in entities) {
|
|
63
|
+
const entity = entities[entityName];
|
|
64
|
+
const actions = {};
|
|
65
|
+
for (const actionName in entity.actions) {
|
|
66
|
+
let clientCache = undefined;
|
|
67
|
+
let includeTotal = undefined;
|
|
68
|
+
let offlineMode = undefined;
|
|
69
|
+
if ((actionName === 'findById' || actionName === 'findMany') && entity.actions[actionName]) {
|
|
70
|
+
if (isAllowCache(entity.actions[actionName], true))
|
|
71
|
+
clientCache = true;
|
|
72
|
+
if (actionName === 'findMany' && entity.actions[actionName].some((a) => a.includeTotal))
|
|
73
|
+
includeTotal = true;
|
|
74
|
+
if (entity.actions[actionName].some((a) => a.offlineMode === 'disallow'))
|
|
75
|
+
offlineMode = 'disallow';
|
|
76
|
+
else if (!entity.actions[actionName].length ||
|
|
77
|
+
entity.actions[actionName].some((a) => a.offlineMode === 'allow'))
|
|
78
|
+
offlineMode = 'allow';
|
|
79
|
+
}
|
|
80
|
+
actions[actionName] = {
|
|
81
|
+
clientCache,
|
|
82
|
+
includeTotal,
|
|
83
|
+
offlineMode,
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
const views = {};
|
|
87
|
+
for (const viewName in entity.views) {
|
|
88
|
+
views[viewName] = {};
|
|
89
|
+
}
|
|
90
|
+
code += `defineAsyncResource({name:${JSON.stringify(entityName)},actions:${JSON.stringify(actions)},views:${JSON.stringify(views)}});
|
|
91
|
+
`;
|
|
92
|
+
}
|
|
93
|
+
code += `
|
|
94
|
+
mushroom.$using(${JSON.stringify(common.getRootUrl(source))});
|
|
95
|
+
|
|
96
|
+
${extensionsCodeLines.join('\n')}
|
|
97
|
+
|
|
98
|
+
//export default mushroom;
|
|
99
|
+
exports.default = mushroom;`;
|
|
100
|
+
return code;
|
|
101
|
+
}
|
|
102
|
+
export function genJavascriptDriver(args, projectName, project, alias, source) {
|
|
103
|
+
const aliasProject = ((project.jsDriver || {}).alias || {})[alias];
|
|
104
|
+
if (!aliasProject) {
|
|
105
|
+
throw new Error(`Not found gen js-driver configuration. Please run 'npx mushroom-cli config gen ${projectName} js-driver OUTPUT_FILE.js${alias === 'default' ? '' : ' alias ' + alias}' first`);
|
|
106
|
+
}
|
|
107
|
+
let code = genJavascriptDriverString(aliasProject, source);
|
|
108
|
+
common.ensureFolder(aliasProject.output);
|
|
109
|
+
fs.writeFileSync(aliasProject.output, code);
|
|
110
|
+
common.logInfo('Generated', aliasProject.output);
|
|
111
|
+
code = typescriptDriverGenerator.genDtsString(aliasProject, source);
|
|
112
|
+
const dtsFilePath = aliasProject.output.replace(/\.js$/i, '.d.ts');
|
|
113
|
+
fs.writeFileSync(dtsFilePath, code);
|
|
114
|
+
common.logInfo('Generated', dtsFilePath);
|
|
115
|
+
common.logInfo(`Generated Javascript driver for ${projectName}@${alias}`);
|
|
116
|
+
}
|