@bundle-stats/cli-utils 4.0.0-alpha.9 → 4.0.0-rc.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/__fixtures__/webpack-stats-baseline.json +1 -15
- package/__fixtures__/webpack-stats-current.json +1 -15
- package/lib/baseline.js +22 -32
- package/lib/baseline.js.map +1 -0
- package/lib/constants.js +10 -13
- package/lib/constants.js.map +1 -0
- package/lib/create-artifacts.js +34 -40
- package/lib/create-artifacts.js.map +1 -0
- package/lib/index.js +35 -63
- package/lib/index.js.map +1 -0
- package/lib/text.js +8 -15
- package/lib/text.js.map +1 -0
- package/lib-esm/baseline.js +18 -0
- package/lib-esm/baseline.js.map +1 -0
- package/lib-esm/constants.js +8 -0
- package/lib-esm/constants.js.map +1 -0
- package/lib-esm/create-artifacts.js +31 -0
- package/lib-esm/create-artifacts.js.map +1 -0
- package/lib-esm/index.js +10 -0
- package/lib-esm/index.js.map +1 -0
- package/lib-esm/text.js +6 -0
- package/lib-esm/text.js.map +1 -0
- package/package.json +13 -11
- package/tsconfig.esm.json +11 -0
- package/tsconfig.json +4 -0
- package/tsconfig.lib.json +7 -0
- package/types/baseline.d.ts +3 -0
- package/types/constants.d.ts +6 -0
- package/types/create-artifacts.d.ts +14 -0
- package/types/index.d.ts +6 -0
- package/types/text.d.ts +5 -0
- package/.babelrc.js +0 -11
|
@@ -79,20 +79,6 @@
|
|
|
79
79
|
"size": 573665
|
|
80
80
|
}
|
|
81
81
|
],
|
|
82
|
-
"entrypoints": {
|
|
83
|
-
"main": {
|
|
84
|
-
"assets": [
|
|
85
|
-
"1.010f5.css",
|
|
86
|
-
"vendor.ae130.js",
|
|
87
|
-
"1.010f5.css.map",
|
|
88
|
-
"vendor.ae130.js.map",
|
|
89
|
-
"main.df5df.css",
|
|
90
|
-
"main.bc8f2337.js",
|
|
91
|
-
"main.df5df.css.map",
|
|
92
|
-
"main.bc8f2337.js.map"
|
|
93
|
-
]
|
|
94
|
-
}
|
|
95
|
-
},
|
|
96
82
|
"chunks": [
|
|
97
83
|
{
|
|
98
84
|
"id": 0,
|
|
@@ -110,7 +96,7 @@
|
|
|
110
96
|
},
|
|
111
97
|
{
|
|
112
98
|
"id": 1,
|
|
113
|
-
"entry":
|
|
99
|
+
"entry": true,
|
|
114
100
|
"initial": true,
|
|
115
101
|
"files": [
|
|
116
102
|
"1.010f5.css",
|
|
@@ -79,20 +79,6 @@
|
|
|
79
79
|
"size": 573665
|
|
80
80
|
}
|
|
81
81
|
],
|
|
82
|
-
"entrypoints": {
|
|
83
|
-
"main": {
|
|
84
|
-
"assets": [
|
|
85
|
-
"1.2428c.css",
|
|
86
|
-
"vendor.6858d.js",
|
|
87
|
-
"1.2428c.css.map",
|
|
88
|
-
"vendor.6858d.js.map",
|
|
89
|
-
"main.bd313.css",
|
|
90
|
-
"main.af1dbc34.js",
|
|
91
|
-
"main.bd313.css.map",
|
|
92
|
-
"main.af1dbc34.js.map"
|
|
93
|
-
]
|
|
94
|
-
}
|
|
95
|
-
},
|
|
96
82
|
"chunks": [
|
|
97
83
|
{
|
|
98
84
|
"id": 0,
|
|
@@ -110,7 +96,7 @@
|
|
|
110
96
|
},
|
|
111
97
|
{
|
|
112
98
|
"id": 1,
|
|
113
|
-
"entry":
|
|
99
|
+
"entry": true,
|
|
114
100
|
"initial": true,
|
|
115
101
|
"files": [
|
|
116
102
|
"1.2428c.css",
|
package/lib/baseline.js
CHANGED
|
@@ -1,37 +1,27 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
});
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.writeBaseline = exports.readBaseline = exports.getBaselineStatsFilepath = void 0;
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
var _findCacheDir = _interopRequireDefault(require("find-cache-dir"));
|
|
13
|
-
|
|
14
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
|
-
|
|
16
|
-
const BASELINE_STATS_DIR = (0, _findCacheDir.default)({
|
|
17
|
-
name: 'bundle-stats'
|
|
18
|
-
});
|
|
7
|
+
const path_1 = __importDefault(require("path"));
|
|
8
|
+
const fs_extra_1 = require("fs-extra");
|
|
9
|
+
const find_cache_dir_1 = __importDefault(require("find-cache-dir"));
|
|
10
|
+
const BASELINE_STATS_DIR = (0, find_cache_dir_1.default)({ name: 'bundle-stats' }) || path_1.default.join(process.cwd(), './node_modules/.cache');
|
|
19
11
|
const BASELINE_STATS_BASE = 'baseline.json';
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
return _path.default.join(_path.default.relative(from, BASELINE_STATS_DIR), BASELINE_STATS_BASE);
|
|
27
|
-
};
|
|
28
|
-
|
|
12
|
+
function getBaselineStatsFilepath(from) {
|
|
13
|
+
if (!from) {
|
|
14
|
+
return path_1.default.join(BASELINE_STATS_DIR, BASELINE_STATS_BASE);
|
|
15
|
+
}
|
|
16
|
+
return path_1.default.join(path_1.default.relative(from, BASELINE_STATS_DIR), BASELINE_STATS_BASE);
|
|
17
|
+
}
|
|
29
18
|
exports.getBaselineStatsFilepath = getBaselineStatsFilepath;
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
19
|
+
async function readBaseline(from) {
|
|
20
|
+
return (0, fs_extra_1.readJSON)(getBaselineStatsFilepath(from));
|
|
21
|
+
}
|
|
33
22
|
exports.readBaseline = readBaseline;
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
exports.writeBaseline = writeBaseline;
|
|
23
|
+
async function writeBaseline(data) {
|
|
24
|
+
return (0, fs_extra_1.outputJSON)(getBaselineStatsFilepath(), data);
|
|
25
|
+
}
|
|
26
|
+
exports.writeBaseline = writeBaseline;
|
|
27
|
+
//# sourceMappingURL=baseline.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"baseline.js","sourceRoot":"","sources":["../src/baseline.ts"],"names":[],"mappings":";;;;;;AAAA,gDAAwB;AACxB,uCAAgD;AAChD,oEAA0C;AAE1C,MAAM,kBAAkB,GAAG,IAAA,wBAAY,EAAC,EAAE,IAAI,EAAE,cAAc,EAAE,CAAC,IAAI,cAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,uBAAuB,CAAC,CAAC;AACvH,MAAM,mBAAmB,GAAG,eAAe,CAAC;AAE5C,SAAgB,wBAAwB,CAAC,IAAa;IACpD,IAAI,CAAC,IAAI,EAAE;QACT,OAAO,cAAI,CAAC,IAAI,CAAC,kBAAkB,EAAE,mBAAmB,CAAC,CAAC;KAC3D;IAED,OAAO,cAAI,CAAC,IAAI,CAAC,cAAI,CAAC,QAAQ,CAAC,IAAI,EAAE,kBAAkB,CAAC,EAAE,mBAAmB,CAAC,CAAC;AACjF,CAAC;AAND,4DAMC;AAEM,KAAK,UAAU,YAAY,CAAC,IAAa;IAC9C,OAAO,IAAA,mBAAQ,EAAC,wBAAwB,CAAC,IAAI,CAAC,CAAC,CAAC;AAClD,CAAC;AAFD,oCAEC;AAEM,KAAK,UAAU,aAAa,CAAC,IAAU;IAC5C,OAAO,IAAA,qBAAU,EAAC,wBAAwB,EAAE,EAAE,IAAI,CAAC,CAAC;AACtD,CAAC;AAFD,sCAEC"}
|
package/lib/constants.js
CHANGED
|
@@ -1,14 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
exports.
|
|
11
|
-
|
|
12
|
-
exports.OUTPUT_FILENAME = OUTPUT_FILENAME;
|
|
13
|
-
const INITIAL_DATA_PATTERN = /window\.__INITIAL_DATA__ = \[\]/;
|
|
14
|
-
exports.INITIAL_DATA_PATTERN = INITIAL_DATA_PATTERN;
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.OutputType = exports.INITIAL_DATA_PATTERN = exports.OUTPUT_FILENAME = void 0;
|
|
4
|
+
exports.OUTPUT_FILENAME = 'bundle-stats';
|
|
5
|
+
exports.INITIAL_DATA_PATTERN = /window\.__INITIAL_DATA__ = \[\]/;
|
|
6
|
+
var OutputType;
|
|
7
|
+
(function (OutputType) {
|
|
8
|
+
OutputType["HTML"] = "html";
|
|
9
|
+
OutputType["JSON"] = "json";
|
|
10
|
+
})(OutputType = exports.OutputType || (exports.OutputType = {}));
|
|
11
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":";;;AAAa,QAAA,eAAe,GAAG,cAAc,CAAC;AAEjC,QAAA,oBAAoB,GAAG,iCAAiC,CAAC;AAEtE,IAAY,UAGX;AAHD,WAAY,UAAU;IACpB,2BAAa,CAAA;IACb,2BAAa,CAAA;AACf,CAAC,EAHW,UAAU,GAAV,kBAAU,KAAV,kBAAU,QAGrB"}
|
package/lib/create-artifacts.js
CHANGED
|
@@ -1,45 +1,39 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
});
|
|
6
|
-
exports.
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
const totalSize = (0, _lodash.get)(jobs, '0.insights.webpack.assetsSizeTotal.data.text');
|
|
17
|
-
|
|
18
|
-
if (totalSize) {
|
|
19
|
-
output = output.replace(/<title>(.*)<\/title>/, `<title>${totalSize} - $1</title>`);
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
return output;
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.createArtifacts = exports.createJSONArtifact = exports.createHTMLArtifact = void 0;
|
|
7
|
+
const html_templates_1 = __importDefault(require("@bundle-stats/html-templates"));
|
|
8
|
+
const constants_1 = require("./constants");
|
|
9
|
+
const createHTMLArtifact = (jobs) => {
|
|
10
|
+
let output = html_templates_1.default.replace(constants_1.INITIAL_DATA_PATTERN, `window.__INITIAL_DATA__ = ${JSON.stringify(jobs)}`);
|
|
11
|
+
const totalSize = jobs?.[0]?.insights?.webpack?.assetsSizeTotal?.data?.text;
|
|
12
|
+
if (totalSize) {
|
|
13
|
+
output = output.replace(/<title>(.*)<\/title>/, `<title>${totalSize} - $1</title>`);
|
|
14
|
+
}
|
|
15
|
+
return output;
|
|
23
16
|
};
|
|
24
|
-
|
|
25
17
|
exports.createHTMLArtifact = createHTMLArtifact;
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
exports.createJSONArtifact = createJSONArtifact;
|
|
30
|
-
const REPORT_HANDLERS = {
|
|
31
|
-
[_constants.OUTPUT_TYPE_HTML]: createHTMLArtifact,
|
|
32
|
-
[_constants.OUTPUT_TYPE_JSON]: createJSONArtifact
|
|
18
|
+
const createJSONArtifact = (_, report) => {
|
|
19
|
+
return JSON.stringify(report, null, 2);
|
|
33
20
|
};
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
21
|
+
exports.createJSONArtifact = createJSONArtifact;
|
|
22
|
+
function createArtifacts(jobs, report, options) {
|
|
23
|
+
const results = {};
|
|
24
|
+
if (options.html) {
|
|
25
|
+
results[constants_1.OutputType.HTML] = {
|
|
26
|
+
output: (0, exports.createHTMLArtifact)(jobs, report),
|
|
27
|
+
filename: `${constants_1.OUTPUT_FILENAME}.${constants_1.OutputType.HTML}`,
|
|
28
|
+
};
|
|
41
29
|
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
30
|
+
if (options.json) {
|
|
31
|
+
results[constants_1.OutputType.JSON] = {
|
|
32
|
+
output: (0, exports.createJSONArtifact)(jobs, report),
|
|
33
|
+
filename: `${constants_1.OUTPUT_FILENAME}.${constants_1.OutputType.JSON}`,
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
return results;
|
|
37
|
+
}
|
|
38
|
+
exports.createArtifacts = createArtifacts;
|
|
39
|
+
//# sourceMappingURL=create-artifacts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-artifacts.js","sourceRoot":"","sources":["../src/create-artifacts.ts"],"names":[],"mappings":";;;;;;AAAA,kFAAyD;AAEzD,2CAAgF;AAIzE,MAAM,kBAAkB,GAAqB,CAAC,IAAI,EAAE,EAAE;IAE3D,IAAI,MAAM,GAAG,wBAAa,CAAC,OAAO,CAChC,gCAAoB,EACpB,6BAA6B,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,CACpD,CAAC;IAGF,MAAM,SAAS,GAAG,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,OAAO,EAAE,eAAe,EAAE,IAAI,EAAE,IAAI,CAAC;IAE5E,IAAI,SAAS,EAAE;QACb,MAAM,GAAG,MAAM,CAAC,OAAO,CAAC,sBAAsB,EAAE,UAAU,SAAS,eAAe,CAAC,CAAC;KACrF;IAED,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC;AAfW,QAAA,kBAAkB,sBAe7B;AAEK,MAAM,kBAAkB,GAAqB,CAAC,CAAC,EAAE,MAAM,EAAE,EAAE;IAChE,OAAO,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;AACzC,CAAC,CAAC;AAFW,QAAA,kBAAkB,sBAE7B;AAcF,SAAgB,eAAe,CAC7B,IAAgB,EAChB,MAAW,EACX,OAAyB;IAEzB,MAAM,OAAO,GAAmB,EAAE,CAAC;IAEnC,IAAI,OAAO,CAAC,IAAI,EAAE;QAChB,OAAO,CAAC,sBAAU,CAAC,IAAI,CAAC,GAAG;YACzB,MAAM,EAAE,IAAA,0BAAkB,EAAC,IAAI,EAAE,MAAM,CAAC;YACxC,QAAQ,EAAE,GAAG,2BAAe,IAAI,sBAAU,CAAC,IAAI,EAAE;SAClD,CAAC;KACH;IAED,IAAI,OAAO,CAAC,IAAI,EAAE;QAChB,OAAO,CAAC,sBAAU,CAAC,IAAI,CAAC,GAAG;YACzB,MAAM,EAAE,IAAA,0BAAkB,EAAC,IAAI,EAAE,MAAM,CAAC;YACxC,QAAQ,EAAE,GAAG,2BAAe,IAAI,sBAAU,CAAC,IAAI,EAAE;SAClD,CAAC;KACH;IAED,OAAO,OAAO,CAAC;AACjB,CAAC;AAtBD,0CAsBC"}
|
package/lib/index.js
CHANGED
|
@@ -1,67 +1,39 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
5
17
|
});
|
|
6
|
-
var
|
|
7
|
-
|
|
8
|
-
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
26
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
9
27
|
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
29
|
exports.getReportInfo = exports.TEXT = void 0;
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
if (key in exports && exports[key] === _baseline[key]) return;
|
|
22
|
-
Object.defineProperty(exports, key, {
|
|
23
|
-
enumerable: true,
|
|
24
|
-
get: function () {
|
|
25
|
-
return _baseline[key];
|
|
26
|
-
}
|
|
27
|
-
});
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
var _createArtifacts = require("./create-artifacts");
|
|
31
|
-
|
|
32
|
-
Object.keys(_createArtifacts).forEach(function (key) {
|
|
33
|
-
if (key === "default" || key === "__esModule") return;
|
|
34
|
-
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
35
|
-
if (key in exports && exports[key] === _createArtifacts[key]) return;
|
|
36
|
-
Object.defineProperty(exports, key, {
|
|
37
|
-
enumerable: true,
|
|
38
|
-
get: function () {
|
|
39
|
-
return _createArtifacts[key];
|
|
40
|
-
}
|
|
41
|
-
});
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
var _constants = require("./constants");
|
|
45
|
-
|
|
46
|
-
Object.keys(_constants).forEach(function (key) {
|
|
47
|
-
if (key === "default" || key === "__esModule") return;
|
|
48
|
-
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
49
|
-
if (key in exports && exports[key] === _constants[key]) return;
|
|
50
|
-
Object.defineProperty(exports, key, {
|
|
51
|
-
enumerable: true,
|
|
52
|
-
get: function () {
|
|
53
|
-
return _constants[key];
|
|
54
|
-
}
|
|
55
|
-
});
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
59
|
-
|
|
60
|
-
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
61
|
-
|
|
62
|
-
const TEXT = T;
|
|
63
|
-
exports.TEXT = TEXT;
|
|
64
|
-
|
|
65
|
-
const getReportInfo = report => (0, _lodash.get)(report, 'insights.webpack.assetsSizeTotal.data');
|
|
66
|
-
|
|
67
|
-
exports.getReportInfo = getReportInfo;
|
|
30
|
+
const T = __importStar(require("./text"));
|
|
31
|
+
__exportStar(require("./baseline"), exports);
|
|
32
|
+
__exportStar(require("./create-artifacts"), exports);
|
|
33
|
+
__exportStar(require("./constants"), exports);
|
|
34
|
+
exports.TEXT = T;
|
|
35
|
+
function getReportInfo(report) {
|
|
36
|
+
return report?.insights?.webpack?.assetsSizeTotal?.data;
|
|
37
|
+
}
|
|
38
|
+
exports.getReportInfo = getReportInfo;
|
|
39
|
+
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,0CAA4B;AAE5B,6CAA2B;AAC3B,qDAAmC;AACnC,8CAA4B;AAEf,QAAA,IAAI,GAAG,CAAC,CAAC;AAEtB,SAAgB,aAAa,CAAC,MAAW;IACvC,OAAO,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,eAAe,EAAE,IAAI,CAAC;AAC1D,CAAC;AAFD,sCAEC"}
|
package/lib/text.js
CHANGED
|
@@ -1,16 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
exports.
|
|
7
|
-
|
|
8
|
-
exports.
|
|
9
|
-
|
|
10
|
-
exports.PLUGIN_BASELINE_MISSING_WARN = PLUGIN_BASELINE_MISSING_WARN;
|
|
11
|
-
const CLI_NO_COMPARE_MODE = 'Not in compare mode (see --compare).';
|
|
12
|
-
exports.CLI_NO_COMPARE_MODE = CLI_NO_COMPARE_MODE;
|
|
13
|
-
const CLI_MULTIPLE_STATS = 'Multiple stat files already set.';
|
|
14
|
-
exports.CLI_MULTIPLE_STATS = CLI_MULTIPLE_STATS;
|
|
15
|
-
const CLI_NO_BASELINE = 'Not a baseline job (see --baseline).';
|
|
16
|
-
exports.CLI_NO_BASELINE = CLI_NO_BASELINE;
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CLI_NO_BASELINE = exports.CLI_MULTIPLE_STATS = exports.CLI_NO_COMPARE_MODE = exports.PLUGIN_BASELINE_MISSING_WARN = exports.CLI_BASELINE_MISSING_WARN = void 0;
|
|
4
|
+
exports.CLI_BASELINE_MISSING_WARN = 'Missing baseline stats, see "--baseline" option.';
|
|
5
|
+
exports.PLUGIN_BASELINE_MISSING_WARN = 'Missing baseline stats, see "baseline" option.';
|
|
6
|
+
exports.CLI_NO_COMPARE_MODE = 'Not in compare mode (see --compare).';
|
|
7
|
+
exports.CLI_MULTIPLE_STATS = 'Multiple stat files already set.';
|
|
8
|
+
exports.CLI_NO_BASELINE = 'Not a baseline job (see --baseline).';
|
|
9
|
+
//# sourceMappingURL=text.js.map
|
package/lib/text.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"text.js","sourceRoot":"","sources":["../src/text.ts"],"names":[],"mappings":";;;AAAa,QAAA,yBAAyB,GAAG,kDAAkD,CAAC;AAC/E,QAAA,4BAA4B,GAAG,gDAAgD,CAAC;AAEhF,QAAA,mBAAmB,GAAG,sCAAsC,CAAC;AAC7D,QAAA,kBAAkB,GAAG,kCAAkC,CAAC;AACxD,QAAA,eAAe,GAAG,sCAAsC,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import path from 'path';
|
|
2
|
+
import { readJSON, outputJSON } from 'fs-extra';
|
|
3
|
+
import findCacheDir from 'find-cache-dir';
|
|
4
|
+
const BASELINE_STATS_DIR = findCacheDir({ name: 'bundle-stats' }) || path.join(process.cwd(), './node_modules/.cache');
|
|
5
|
+
const BASELINE_STATS_BASE = 'baseline.json';
|
|
6
|
+
export function getBaselineStatsFilepath(from) {
|
|
7
|
+
if (!from) {
|
|
8
|
+
return path.join(BASELINE_STATS_DIR, BASELINE_STATS_BASE);
|
|
9
|
+
}
|
|
10
|
+
return path.join(path.relative(from, BASELINE_STATS_DIR), BASELINE_STATS_BASE);
|
|
11
|
+
}
|
|
12
|
+
export async function readBaseline(from) {
|
|
13
|
+
return readJSON(getBaselineStatsFilepath(from));
|
|
14
|
+
}
|
|
15
|
+
export async function writeBaseline(data) {
|
|
16
|
+
return outputJSON(getBaselineStatsFilepath(), data);
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=baseline.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"baseline.js","sourceRoot":"","sources":["../src/baseline.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAChD,OAAO,YAAY,MAAM,gBAAgB,CAAC;AAE1C,MAAM,kBAAkB,GAAG,YAAY,CAAC,EAAE,IAAI,EAAE,cAAc,EAAE,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,uBAAuB,CAAC,CAAC;AACvH,MAAM,mBAAmB,GAAG,eAAe,CAAC;AAE5C,MAAM,UAAU,wBAAwB,CAAC,IAAa;IACpD,IAAI,CAAC,IAAI,EAAE;QACT,OAAO,IAAI,CAAC,IAAI,CAAC,kBAAkB,EAAE,mBAAmB,CAAC,CAAC;KAC3D;IAED,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE,kBAAkB,CAAC,EAAE,mBAAmB,CAAC,CAAC;AACjF,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,YAAY,CAAC,IAAa;IAC9C,OAAO,QAAQ,CAAC,wBAAwB,CAAC,IAAI,CAAC,CAAC,CAAC;AAClD,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,aAAa,CAAC,IAAU;IAC5C,OAAO,UAAU,CAAC,wBAAwB,EAAE,EAAE,IAAI,CAAC,CAAC;AACtD,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export const OUTPUT_FILENAME = 'bundle-stats';
|
|
2
|
+
export const INITIAL_DATA_PATTERN = /window\.__INITIAL_DATA__ = \[\]/;
|
|
3
|
+
export var OutputType;
|
|
4
|
+
(function (OutputType) {
|
|
5
|
+
OutputType["HTML"] = "html";
|
|
6
|
+
OutputType["JSON"] = "json";
|
|
7
|
+
})(OutputType || (OutputType = {}));
|
|
8
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,eAAe,GAAG,cAAc,CAAC;AAE9C,MAAM,CAAC,MAAM,oBAAoB,GAAG,iCAAiC,CAAC;AAEtE,MAAM,CAAN,IAAY,UAGX;AAHD,WAAY,UAAU;IACpB,2BAAa,CAAA;IACb,2BAAa,CAAA;AACf,CAAC,EAHW,UAAU,KAAV,UAAU,QAGrB"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import htmlTemplates from '@bundle-stats/html-templates';
|
|
2
|
+
import { INITIAL_DATA_PATTERN, OUTPUT_FILENAME, OutputType } from './constants';
|
|
3
|
+
export const createHTMLArtifact = (jobs) => {
|
|
4
|
+
var _a, _b, _c, _d, _e;
|
|
5
|
+
let output = htmlTemplates.replace(INITIAL_DATA_PATTERN, `window.__INITIAL_DATA__ = ${JSON.stringify(jobs)}`);
|
|
6
|
+
const totalSize = (_e = (_d = (_c = (_b = (_a = jobs === null || jobs === void 0 ? void 0 : jobs[0]) === null || _a === void 0 ? void 0 : _a.insights) === null || _b === void 0 ? void 0 : _b.webpack) === null || _c === void 0 ? void 0 : _c.assetsSizeTotal) === null || _d === void 0 ? void 0 : _d.data) === null || _e === void 0 ? void 0 : _e.text;
|
|
7
|
+
if (totalSize) {
|
|
8
|
+
output = output.replace(/<title>(.*)<\/title>/, `<title>${totalSize} - $1</title>`);
|
|
9
|
+
}
|
|
10
|
+
return output;
|
|
11
|
+
};
|
|
12
|
+
export const createJSONArtifact = (_, report) => {
|
|
13
|
+
return JSON.stringify(report, null, 2);
|
|
14
|
+
};
|
|
15
|
+
export function createArtifacts(jobs, report, options) {
|
|
16
|
+
const results = {};
|
|
17
|
+
if (options.html) {
|
|
18
|
+
results[OutputType.HTML] = {
|
|
19
|
+
output: createHTMLArtifact(jobs, report),
|
|
20
|
+
filename: `${OUTPUT_FILENAME}.${OutputType.HTML}`,
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
if (options.json) {
|
|
24
|
+
results[OutputType.JSON] = {
|
|
25
|
+
output: createJSONArtifact(jobs, report),
|
|
26
|
+
filename: `${OUTPUT_FILENAME}.${OutputType.JSON}`,
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
return results;
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=create-artifacts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-artifacts.js","sourceRoot":"","sources":["../src/create-artifacts.ts"],"names":[],"mappings":"AAAA,OAAO,aAAa,MAAM,8BAA8B,CAAC;AAEzD,OAAO,EAAE,oBAAoB,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAIhF,MAAM,CAAC,MAAM,kBAAkB,GAAqB,CAAC,IAAI,EAAE,EAAE;;IAE3D,IAAI,MAAM,GAAG,aAAa,CAAC,OAAO,CAChC,oBAAoB,EACpB,6BAA6B,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,CACpD,CAAC;IAGF,MAAM,SAAS,GAAG,MAAA,MAAA,MAAA,MAAA,MAAA,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAG,CAAC,CAAC,0CAAE,QAAQ,0CAAE,OAAO,0CAAE,eAAe,0CAAE,IAAI,0CAAE,IAAI,CAAC;IAE5E,IAAI,SAAS,EAAE;QACb,MAAM,GAAG,MAAM,CAAC,OAAO,CAAC,sBAAsB,EAAE,UAAU,SAAS,eAAe,CAAC,CAAC;KACrF;IAED,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,kBAAkB,GAAqB,CAAC,CAAC,EAAE,MAAM,EAAE,EAAE;IAChE,OAAO,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;AACzC,CAAC,CAAC;AAcF,MAAM,UAAU,eAAe,CAC7B,IAAgB,EAChB,MAAW,EACX,OAAyB;IAEzB,MAAM,OAAO,GAAmB,EAAE,CAAC;IAEnC,IAAI,OAAO,CAAC,IAAI,EAAE;QAChB,OAAO,CAAC,UAAU,CAAC,IAAI,CAAC,GAAG;YACzB,MAAM,EAAE,kBAAkB,CAAC,IAAI,EAAE,MAAM,CAAC;YACxC,QAAQ,EAAE,GAAG,eAAe,IAAI,UAAU,CAAC,IAAI,EAAE;SAClD,CAAC;KACH;IAED,IAAI,OAAO,CAAC,IAAI,EAAE;QAChB,OAAO,CAAC,UAAU,CAAC,IAAI,CAAC,GAAG;YACzB,MAAM,EAAE,kBAAkB,CAAC,IAAI,EAAE,MAAM,CAAC;YACxC,QAAQ,EAAE,GAAG,eAAe,IAAI,UAAU,CAAC,IAAI,EAAE;SAClD,CAAC;KACH;IAED,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
package/lib-esm/index.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import * as T from './text';
|
|
2
|
+
export * from './baseline';
|
|
3
|
+
export * from './create-artifacts';
|
|
4
|
+
export * from './constants';
|
|
5
|
+
export const TEXT = T;
|
|
6
|
+
export function getReportInfo(report) {
|
|
7
|
+
var _a, _b, _c;
|
|
8
|
+
return (_c = (_b = (_a = report === null || report === void 0 ? void 0 : report.insights) === null || _a === void 0 ? void 0 : _a.webpack) === null || _b === void 0 ? void 0 : _b.assetsSizeTotal) === null || _c === void 0 ? void 0 : _c.data;
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,QAAQ,CAAC;AAE5B,cAAc,YAAY,CAAC;AAC3B,cAAc,oBAAoB,CAAC;AACnC,cAAc,aAAa,CAAC;AAE5B,MAAM,CAAC,MAAM,IAAI,GAAG,CAAC,CAAC;AAEtB,MAAM,UAAU,aAAa,CAAC,MAAW;;IACvC,OAAO,MAAA,MAAA,MAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,QAAQ,0CAAE,OAAO,0CAAE,eAAe,0CAAE,IAAI,CAAC;AAC1D,CAAC"}
|
package/lib-esm/text.js
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export const CLI_BASELINE_MISSING_WARN = 'Missing baseline stats, see "--baseline" option.';
|
|
2
|
+
export const PLUGIN_BASELINE_MISSING_WARN = 'Missing baseline stats, see "baseline" option.';
|
|
3
|
+
export const CLI_NO_COMPARE_MODE = 'Not in compare mode (see --compare).';
|
|
4
|
+
export const CLI_MULTIPLE_STATS = 'Multiple stat files already set.';
|
|
5
|
+
export const CLI_NO_BASELINE = 'Not a baseline job (see --baseline).';
|
|
6
|
+
//# sourceMappingURL=text.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"text.js","sourceRoot":"","sources":["../src/text.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,yBAAyB,GAAG,kDAAkD,CAAC;AAC5F,MAAM,CAAC,MAAM,4BAA4B,GAAG,gDAAgD,CAAC;AAE7F,MAAM,CAAC,MAAM,mBAAmB,GAAG,sCAAsC,CAAC;AAC1E,MAAM,CAAC,MAAM,kBAAkB,GAAG,kCAAkC,CAAC;AACrE,MAAM,CAAC,MAAM,eAAe,GAAG,sCAAsC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bundle-stats/cli-utils",
|
|
3
|
-
"version": "4.0.0-
|
|
3
|
+
"version": "4.0.0-rc.1",
|
|
4
4
|
"description": "BundleStats CLI utilities",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
|
+
"module": "lib-esm/index.js",
|
|
7
|
+
"types": "types/index.d.ts",
|
|
6
8
|
"directories": {
|
|
7
9
|
"lib": "lib"
|
|
8
10
|
},
|
|
@@ -10,7 +12,9 @@
|
|
|
10
12
|
"node": ">= 14.0"
|
|
11
13
|
},
|
|
12
14
|
"scripts": {
|
|
13
|
-
"build": "
|
|
15
|
+
"build": "npm run build-lib && npm run build-esm",
|
|
16
|
+
"build-lib": "rm -fr ./lib && ../../node_modules/.bin/tsc --rootDir ./src --project tsconfig.lib.json --outDir ./lib",
|
|
17
|
+
"build-esm": "rm -fr ./lib-esm && rm -fr ./types && ../../node_modules/.bin/tsc --rootDir ./src --project tsconfig.esm.json --outDir ./lib-esm",
|
|
14
18
|
"lint": "../../node_modules/.bin/eslint . --ext .js",
|
|
15
19
|
"test": "jest --passWithNoTests src "
|
|
16
20
|
},
|
|
@@ -30,18 +34,16 @@
|
|
|
30
34
|
},
|
|
31
35
|
"homepage": "https://github.com/relative-ci/bundle-stats/blob/master/packages/cli-utils#readme",
|
|
32
36
|
"dependencies": {
|
|
33
|
-
"@bundle-stats/html-templates": "^4.0.0-
|
|
34
|
-
"@bundle-stats/utils": "^4.0.0-
|
|
37
|
+
"@bundle-stats/html-templates": "^4.0.0-rc.1",
|
|
38
|
+
"@bundle-stats/utils": "^4.0.0-rc.1",
|
|
35
39
|
"core-js": "^3.21.0",
|
|
36
40
|
"find-cache-dir": "^3.1.0",
|
|
37
|
-
"fs-extra": "^10.0.1"
|
|
38
|
-
"lodash": "^4.17.0"
|
|
41
|
+
"fs-extra": "^10.0.1"
|
|
39
42
|
},
|
|
40
43
|
"devDependencies": {
|
|
41
|
-
"@
|
|
42
|
-
"
|
|
43
|
-
"
|
|
44
|
-
"jest": "27.5.1"
|
|
44
|
+
"@types/find-cache-dir": "^3.2.1",
|
|
45
|
+
"jest": "27.5.1",
|
|
46
|
+
"typescript": "4.7.4"
|
|
45
47
|
},
|
|
46
|
-
"gitHead": "
|
|
48
|
+
"gitHead": "8f28ce5d4c570ac11670f5f0f34a3c9c3ea6a162"
|
|
47
49
|
}
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
declare type CreateArtifactFn = (jobs: Array<any>, report: any) => string;
|
|
2
|
+
export declare const createHTMLArtifact: CreateArtifactFn;
|
|
3
|
+
export declare const createJSONArtifact: CreateArtifactFn;
|
|
4
|
+
interface ArtifactsOptions {
|
|
5
|
+
html?: boolean;
|
|
6
|
+
json?: boolean;
|
|
7
|
+
}
|
|
8
|
+
interface Artifact {
|
|
9
|
+
output: string;
|
|
10
|
+
filename: string;
|
|
11
|
+
}
|
|
12
|
+
declare type ArtifactByType = Record<string, Artifact>;
|
|
13
|
+
export declare function createArtifacts(jobs: Array<any>, report: any, options: ArtifactsOptions): ArtifactByType;
|
|
14
|
+
export {};
|
package/types/index.d.ts
ADDED
package/types/text.d.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare const CLI_BASELINE_MISSING_WARN = "Missing baseline stats, see \"--baseline\" option.";
|
|
2
|
+
export declare const PLUGIN_BASELINE_MISSING_WARN = "Missing baseline stats, see \"baseline\" option.";
|
|
3
|
+
export declare const CLI_NO_COMPARE_MODE = "Not in compare mode (see --compare).";
|
|
4
|
+
export declare const CLI_MULTIPLE_STATS = "Multiple stat files already set.";
|
|
5
|
+
export declare const CLI_NO_BASELINE = "Not a baseline job (see --baseline).";
|