mushroom-cli 1.2.8 → 2.0.0-alpha.1
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 +63 -18
- package/dist/common.js +0 -143
- package/dist/config.js +0 -7
- package/dist/docs/docs.html +2 -2
- package/dist/docs/docs.v2.html +13 -13
- package/dist/docs/docs.v2.js +143 -73
- package/dist/gen/csharp/extEvents.js +195 -0
- package/dist/gen/gen-api-docs.js +51 -35
- package/dist/gen/gen-csharp.js +188 -421
- package/dist/gen/gen-list-api.js +4 -4
- package/dist/gen.js +4 -9
- package/dist/help.js +5 -5
- package/dist/init/init-netcore.js +26 -5
- package/dist/init/netcore/templateProcessor.js +182 -0
- package/package.json +8 -15
package/dist/gen/gen-api-docs.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import fs from 'fs';
|
|
2
2
|
import open from 'open';
|
|
3
|
-
import { minify } from '
|
|
3
|
+
import { minify } from 'html-minifier-terser';
|
|
4
4
|
import { fileURLToPath } from 'url';
|
|
5
5
|
import path from 'path';
|
|
6
6
|
import * as common from '../common.js';
|
|
@@ -227,42 +227,58 @@ function filterEntityFields(entity) {
|
|
|
227
227
|
async function writeDocs(filePath, strTemplate, strData) {
|
|
228
228
|
const placeholder = '<script id="INJECT-JAVASCRIPT-HERE"></script>';
|
|
229
229
|
const idx = strTemplate.indexOf(placeholder);
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
fs.
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
'jquery.min.js',
|
|
260
|
-
]);
|
|
230
|
+
if (idx === -1) {
|
|
231
|
+
throw new Error(`Docs template does not contain the placeholder ${placeholder}`);
|
|
232
|
+
}
|
|
233
|
+
const docsScript = fs.readFileSync(path.join(__dirname, '../docs/docs.v2.js')).toString();
|
|
234
|
+
let html = strTemplate.substring(0, idx) +
|
|
235
|
+
'<script>window.docs = ' +
|
|
236
|
+
strData +
|
|
237
|
+
';\n' +
|
|
238
|
+
docsScript +
|
|
239
|
+
'</script>' +
|
|
240
|
+
strTemplate.substring(idx + placeholder.length);
|
|
241
|
+
html = await minify(html, {
|
|
242
|
+
removeComments: true,
|
|
243
|
+
collapseWhitespace: true,
|
|
244
|
+
collapseBooleanAttributes: true,
|
|
245
|
+
removeAttributeQuotes: true,
|
|
246
|
+
removeRedundantAttributes: true,
|
|
247
|
+
useShortDoctype: true,
|
|
248
|
+
removeEmptyAttributes: true,
|
|
249
|
+
removeEmptyElements: false,
|
|
250
|
+
removeOptionalTags: true,
|
|
251
|
+
removeScriptTypeAttributes: false,
|
|
252
|
+
removeStyleLinkTypeAttributes: true,
|
|
253
|
+
minifyJS: true,
|
|
254
|
+
minifyCSS: true,
|
|
255
|
+
html5: true,
|
|
256
|
+
});
|
|
257
|
+
html = injectStaticFiles(html, ['bootstrap-theme.min.css', 'bootstrap.min.css', 'bootstrap.min.js', 'jquery.min.js']);
|
|
258
|
+
fs.writeFileSync(filePath, html);
|
|
261
259
|
}
|
|
262
|
-
const
|
|
260
|
+
const injectStaticFiles = (content, files) => {
|
|
261
|
+
let html = content;
|
|
263
262
|
files.forEach((file) => {
|
|
264
|
-
|
|
263
|
+
const sourcePath = path.join(__dirname, '../docs/', file);
|
|
264
|
+
if (!fs.existsSync(sourcePath)) {
|
|
265
|
+
common.logWarning(`Static file ${file} does not exist, skipping...`);
|
|
266
|
+
return;
|
|
267
|
+
}
|
|
268
|
+
const escapedFile = file.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
269
|
+
const isCss = path.extname(file).toLowerCase() === '.css';
|
|
270
|
+
const tagPattern = isCss
|
|
271
|
+
? new RegExp(`<link[^>]*href=["']?${escapedFile}["']?[^>]*>`, 'gi')
|
|
272
|
+
: new RegExp(`<script[^>]*src=["']?${escapedFile}["']?[^>]*>\\s*</script>`, 'gi');
|
|
273
|
+
if (!tagPattern.test(html)) {
|
|
274
|
+
return;
|
|
275
|
+
}
|
|
276
|
+
tagPattern.lastIndex = 0;
|
|
277
|
+
const assetContent = fs.readFileSync(sourcePath).toString();
|
|
278
|
+
const inlined = isCss ? `<style>${assetContent}</style>` : `<script>${assetContent}</script>`;
|
|
279
|
+
html = html.replace(tagPattern, () => inlined);
|
|
265
280
|
});
|
|
281
|
+
return html;
|
|
266
282
|
};
|
|
267
283
|
export default async function genDocs(args, projectName, project, alias, source) {
|
|
268
284
|
const aliasProject = ((project.docs || {}).alias || {})[alias];
|
|
@@ -300,6 +316,7 @@ export default async function genDocs(args, projectName, project, alias, source)
|
|
|
300
316
|
environmentVariables: source.environmentVariables,
|
|
301
317
|
entities: entities,
|
|
302
318
|
});
|
|
319
|
+
common.ensureFolder(aliasProject.output);
|
|
303
320
|
const html = fs.readFileSync(__dirname + '/../docs/docs.v2.html').toString();
|
|
304
321
|
if (args[3] === 'tmp') {
|
|
305
322
|
const htmlFilePath = aliasProject.output + '_tmp.html';
|
|
@@ -320,7 +337,6 @@ export default async function genDocs(args, projectName, project, alias, source)
|
|
|
320
337
|
}
|
|
321
338
|
return;
|
|
322
339
|
}
|
|
323
|
-
common.ensureFolder(aliasProject.output);
|
|
324
340
|
common.logInfo('Writing to', aliasProject.output);
|
|
325
341
|
await writeDocs(aliasProject.output, html, data);
|
|
326
342
|
common.logInfo(`Generated API docs for ${projectName}@${alias} to ${aliasProject.output}`);
|