@statoscope/cli
Advanced tools
Comparing version 5.3.0-alpha.1 to 5.3.0-alpha.2
@@ -0,1 +1,4 @@ | ||
/// <reference types="node" /> | ||
import { Readable, Writable } from 'stream'; | ||
export declare function waitFinished(stream: Readable | Writable): Promise<void>; | ||
export declare function transform(from: string[], to?: string): Promise<string>; |
"use strict"; | ||
/* global Statoscope */ | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
@@ -7,3 +6,3 @@ return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.transform = void 0; | ||
exports.transform = exports.waitFinished = void 0; | ||
const fs_1 = __importDefault(require("fs")); | ||
@@ -13,11 +12,19 @@ const os_1 = __importDefault(require("os")); | ||
const report_writer_1 = __importDefault(require("@statoscope/report-writer")); | ||
function waitFinished(stream) { | ||
return new Promise((resolve, reject) => { | ||
stream.once('end', resolve); | ||
stream.once('finish', resolve); | ||
stream.once('error', reject); | ||
}); | ||
} | ||
exports.waitFinished = waitFinished; | ||
async function transform(from, to) { | ||
const id = from.length === 1 ? path_1.default.basename(from[0], '.json') : Date.now(); | ||
to = to || path_1.default.join(os_1.default.tmpdir(), `statoscope-report-${id}.html`); | ||
const outputStream = fs_1.default.createWriteStream(to); | ||
const htmlWriter = new report_writer_1.default({ | ||
scripts: [{ type: 'path', path: require.resolve('@statoscope/webpack-ui') }], | ||
init: function (data) { | ||
// @ts-ignore | ||
Statoscope.default(data.map((item) => ({ name: item.id, data: item.data }))); | ||
}, | ||
init: `function (data: InitArg): void { | ||
Statoscope.default(data.map((item) => ({ name: item.id, data: item.data }))); | ||
}`, | ||
}); | ||
@@ -28,4 +35,5 @@ for (const file of from) { | ||
} | ||
htmlWriter.getStream().pipe(fs_1.default.createWriteStream(to)); | ||
await htmlWriter.write(); | ||
htmlWriter.getStream().pipe(outputStream); | ||
htmlWriter.write(); | ||
await waitFinished(outputStream); | ||
return to; | ||
@@ -32,0 +40,0 @@ } |
{ | ||
"name": "@statoscope/cli", | ||
"version": "5.3.0-alpha.1", | ||
"version": "5.3.0-alpha.2", | ||
"description": "Statoscope CLI tools", | ||
@@ -28,6 +28,6 @@ "scripts": { | ||
"@discoveryjs/json-ext": "^0.5.3", | ||
"@statoscope/helpers": "^5.3.0-alpha.1", | ||
"@statoscope/report-writer": "^5.3.0-alpha.1", | ||
"@statoscope/webpack-model": "^5.3.0-alpha.1", | ||
"@statoscope/webpack-ui": "^5.3.0-alpha.1", | ||
"@statoscope/helpers": "^5.3.0-alpha.2", | ||
"@statoscope/report-writer": "^5.3.0-alpha.2", | ||
"@statoscope/webpack-model": "^5.3.0-alpha.2", | ||
"@statoscope/webpack-ui": "^5.3.0-alpha.2", | ||
"open": "^8.0.4", | ||
@@ -39,3 +39,3 @@ "yargs": "^17.0.1" | ||
}, | ||
"gitHead": "f0f59cd81f6f3e8d2161000c386fe17bbee1a872" | ||
"gitHead": "13226c000994fd9af2082bb3e21e303ed710da90" | ||
} |
@@ -61,2 +61,6 @@ # Statoscope CLI | ||
filename: name | ||
}, | ||
{ | ||
message: 'Just info message', | ||
filename: name | ||
} | ||
@@ -74,4 +78,6 @@ ] | ||
stats.json | ||
info: Just info message | ||
error: Lodash usage detected. Please do not use lodash in this project | ||
Info: 1 | ||
Errors: 1 | ||
@@ -125,6 +131,8 @@ ``` | ||
Also, there | ||
are [a lot of jora-helpers](https://github.com/statoscope/statoscope/blob/master/packages/webpack-model/src/jora-helpers.js) | ||
. For example: | ||
Also, there are a lot of jora-helpers that you can use in your rules: | ||
- [common helpers](https://github.com/statoscope/statoscope/blob/master/packages/helpers/src/jora/index.ts) | ||
- [webpack-model helpers](https://github.com/statoscope/statoscope/blob/master/packages/webpack-model/src/jora-helpers.js) | ||
For example: | ||
`rules.jora:` | ||
@@ -131,0 +139,0 @@ |
Sorry, the diff of this file is not supported yet
29141
334
257