@ziacik/upgrade-verify 0.0.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 +11 -0
- package/executors.json +9 -0
- package/package.json +18 -0
- package/src/executors/verify-build/__fixtures__/differing-stats.json +15 -0
- package/src/executors/verify-build/__fixtures__/expected-stats.json +15 -0
- package/src/executors/verify-build/dist-stat-comparer.d.ts +8 -0
- package/src/executors/verify-build/dist-stat-comparer.js +46 -0
- package/src/executors/verify-build/dist-stat-comparer.js.map +1 -0
- package/src/executors/verify-build/dist-stats.d.ts +7 -0
- package/src/executors/verify-build/dist-stats.js +54 -0
- package/src/executors/verify-build/dist-stats.js.map +1 -0
- package/src/executors/verify-build/executor.d.ts +5 -0
- package/src/executors/verify-build/executor.js +68 -0
- package/src/executors/verify-build/executor.js.map +1 -0
- package/src/executors/verify-build/schema.d.js +4 -0
- package/src/executors/verify-build/schema.d.js.map +1 -0
- package/src/executors/verify-build/schema.d.ts +1 -0
- package/src/executors/verify-build/schema.json +9 -0
- package/src/index.d.ts +0 -0
- package/src/index.js +3 -0
- package/src/index.js.map +1 -0
package/README.md
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# upgrade-verify
|
|
2
|
+
|
|
3
|
+
This library was generated with [Nx](https://nx.dev).
|
|
4
|
+
|
|
5
|
+
## Building
|
|
6
|
+
|
|
7
|
+
Run `nx build upgrade-verify` to build the library.
|
|
8
|
+
|
|
9
|
+
## Running unit tests
|
|
10
|
+
|
|
11
|
+
Run `nx test upgrade-verify` to execute the unit tests via [Jest](https://jestjs.io).
|
package/executors.json
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
{
|
|
2
|
+
"executors": {
|
|
3
|
+
"verify-build": {
|
|
4
|
+
"implementation": "./src/executors/verify-build/executor",
|
|
5
|
+
"schema": "./src/executors/verify-build/schema.json",
|
|
6
|
+
"description": "Verifies that the build does not differ too much from the previous one after NX upgrade. Or, if this is the first run, creates stats for future verifications."
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@ziacik/upgrade-verify",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"type": "commonjs",
|
|
5
|
+
"executors": "./executors.json",
|
|
6
|
+
"dependencies": {
|
|
7
|
+
"@nx/devkit": "16.4.0"
|
|
8
|
+
},
|
|
9
|
+
"peerDependencies": {
|
|
10
|
+
"@swc/helpers": "0.5.1"
|
|
11
|
+
},
|
|
12
|
+
"main": "./src/index.js",
|
|
13
|
+
"exports": {
|
|
14
|
+
".": {
|
|
15
|
+
"require": "./src/index.js"
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "",
|
|
3
|
+
"size": 33333,
|
|
4
|
+
"items": [
|
|
5
|
+
{ "name": "3rdpartylicenses.txt", "size": 19, "items": [] },
|
|
6
|
+
{ "name": "assets", "size": 100, "items": [{ "name": ".gitkeep", "size": 100, "items": [] }] },
|
|
7
|
+
{ "name": "assetsx", "size": 0, "items": [{ "name": ".gitkeep", "size": 0, "items": [] }] },
|
|
8
|
+
{ "name": "index.xhtml", "size": 608, "items": [] },
|
|
9
|
+
{ "name": "main.0274b0362ab850a9.css", "size": 6168, "items": [] },
|
|
10
|
+
{ "name": "main.3d931a8f6ad8b28f.js", "size": 18760, "items": [] },
|
|
11
|
+
{ "name": "runtime.dd97139be5136261.js", "size": 2109, "items": [] },
|
|
12
|
+
{ "name": "styles.abc.js", "size": 176, "items": [] },
|
|
13
|
+
{ "name": "styles.ef46db3751d8e999.css", "size": 0, "items": [] }
|
|
14
|
+
]
|
|
15
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "",
|
|
3
|
+
"size": 42926,
|
|
4
|
+
"items": [
|
|
5
|
+
{ "name": "3rdpartylicenses.txt", "size": 19, "items": [] },
|
|
6
|
+
{ "name": "assets", "size": 0, "items": [{ "name": ".gitkeep", "size": 0, "items": [] }] },
|
|
7
|
+
{ "name": "favicon.ico", "size": 15086, "items": [] },
|
|
8
|
+
{ "name": "index.html", "size": 608, "items": [] },
|
|
9
|
+
{ "name": "main.0274b0362ab850a9.css", "size": 6168, "items": [] },
|
|
10
|
+
{ "name": "main.3d931a8f6ad8b28f.js", "size": 18760, "items": [] },
|
|
11
|
+
{ "name": "runtime.dd97139be5136261.js", "size": 2109, "items": [] },
|
|
12
|
+
{ "name": "styles.91b7890a3e13c303.js", "size": 176, "items": [] },
|
|
13
|
+
{ "name": "styles.ef46db3751d8e999.css", "size": 0, "items": [] }
|
|
14
|
+
]
|
|
15
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Stat } from './dist-stats';
|
|
2
|
+
export type ComparisonResult = {
|
|
3
|
+
readonly totalSizeDifferencePercentage: number;
|
|
4
|
+
readonly fileCountDifferencePercentage: number;
|
|
5
|
+
readonly newFilesPercentage: number;
|
|
6
|
+
readonly deletedFilesPercentage: number;
|
|
7
|
+
};
|
|
8
|
+
export declare function compareStats(existingStats: Stat, newStats: Stat): ComparisonResult;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "compareStats", {
|
|
3
|
+
enumerable: true,
|
|
4
|
+
get: function() {
|
|
5
|
+
return compareStats;
|
|
6
|
+
}
|
|
7
|
+
});
|
|
8
|
+
function compareStats(existingStats, newStats) {
|
|
9
|
+
const totalSizeDifferencePercentage = countDiffPercentage(existingStats.size, newStats.size);
|
|
10
|
+
const fileCountDifferencePercentage = countDiffPercentage(countFiles(existingStats), countFiles(newStats));
|
|
11
|
+
const newFilesPercentage = countPercentage(countNewFiles(existingStats, newStats), countFiles(newStats));
|
|
12
|
+
const deletedFilesPercentage = countPercentage(countDeletedFiles(existingStats, newStats), countFiles(existingStats));
|
|
13
|
+
return {
|
|
14
|
+
totalSizeDifferencePercentage,
|
|
15
|
+
fileCountDifferencePercentage,
|
|
16
|
+
newFilesPercentage,
|
|
17
|
+
deletedFilesPercentage
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
function countDiffPercentage(existingNumber, newNumber) {
|
|
21
|
+
return countPercentage(newNumber - existingNumber, existingNumber);
|
|
22
|
+
}
|
|
23
|
+
function countPercentage(partNumber, totalNumber) {
|
|
24
|
+
return Math.round(partNumber * 100 / totalNumber);
|
|
25
|
+
}
|
|
26
|
+
function countFiles(stats) {
|
|
27
|
+
return stats.items.length + stats.items.reduce((result, item)=>result + countFiles(item), 0);
|
|
28
|
+
}
|
|
29
|
+
function countNewFiles(existingStats, newStats) {
|
|
30
|
+
const existingNames = flatFileNamesSet(existingStats);
|
|
31
|
+
const newNames = flatFileNamesList(newStats);
|
|
32
|
+
return newNames.filter((name)=>!existingNames.has(name)).length;
|
|
33
|
+
}
|
|
34
|
+
function countDeletedFiles(existingStats, newStats) {
|
|
35
|
+
const existingNames = flatFileNamesList(existingStats);
|
|
36
|
+
const newNames = flatFileNamesSet(newStats);
|
|
37
|
+
return existingNames.filter((name)=>!newNames.has(name)).length;
|
|
38
|
+
}
|
|
39
|
+
function flatFileNamesSet(stats) {
|
|
40
|
+
return new Set(flatFileNamesList(stats));
|
|
41
|
+
}
|
|
42
|
+
function flatFileNamesList(stats, prefix = '') {
|
|
43
|
+
return stats.items.map((item)=>`${prefix}/${item.name}`).concat(stats.items.flatMap((item)=>flatFileNamesList(item, item.name)));
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
//# sourceMappingURL=dist-stat-comparer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../packages/upgrade-verify/src/executors/verify-build/dist-stat-comparer.ts"],"sourcesContent":["import { Stat } from './dist-stats';\n\nexport type ComparisonResult = {\n\treadonly totalSizeDifferencePercentage: number;\n\treadonly fileCountDifferencePercentage: number;\n\treadonly newFilesPercentage: number;\n\treadonly deletedFilesPercentage: number;\n};\n\nexport function compareStats(existingStats: Stat, newStats: Stat): ComparisonResult {\n\tconst totalSizeDifferencePercentage = countDiffPercentage(existingStats.size, newStats.size);\n\tconst fileCountDifferencePercentage = countDiffPercentage(countFiles(existingStats), countFiles(newStats));\n\tconst newFilesPercentage = countPercentage(countNewFiles(existingStats, newStats), countFiles(newStats));\n\tconst deletedFilesPercentage = countPercentage(countDeletedFiles(existingStats, newStats), countFiles(existingStats));\n\treturn {\n\t\ttotalSizeDifferencePercentage,\n\t\tfileCountDifferencePercentage,\n\t\tnewFilesPercentage,\n\t\tdeletedFilesPercentage,\n\t};\n}\n\nfunction countDiffPercentage(existingNumber: number, newNumber: number): number {\n\treturn countPercentage(newNumber - existingNumber, existingNumber);\n}\n\nfunction countPercentage(partNumber: number, totalNumber: number): number {\n\treturn Math.round((partNumber * 100) / totalNumber);\n}\n\nfunction countFiles(stats: Stat): number {\n\treturn stats.items.length + stats.items.reduce((result, item) => result + countFiles(item), 0);\n}\n\nfunction countNewFiles(existingStats: Stat, newStats: Stat): number {\n\tconst existingNames = flatFileNamesSet(existingStats);\n\tconst newNames = flatFileNamesList(newStats);\n\treturn newNames.filter((name) => !existingNames.has(name)).length;\n}\n\nfunction countDeletedFiles(existingStats: Stat, newStats: Stat): number {\n\tconst existingNames = flatFileNamesList(existingStats);\n\tconst newNames = flatFileNamesSet(newStats);\n\treturn existingNames.filter((name) => !newNames.has(name)).length;\n}\n\nfunction flatFileNamesSet(stats: Stat): Set<string> {\n\treturn new Set(flatFileNamesList(stats));\n}\n\nfunction flatFileNamesList(stats: Stat, prefix = ''): string[] {\n\treturn stats.items.map((item) => `${prefix}/${item.name}`).concat(stats.items.flatMap((item) => flatFileNamesList(item, item.name)));\n}\n"],"names":["compareStats","existingStats","newStats","totalSizeDifferencePercentage","countDiffPercentage","size","fileCountDifferencePercentage","countFiles","newFilesPercentage","countPercentage","countNewFiles","deletedFilesPercentage","countDeletedFiles","existingNumber","newNumber","partNumber","totalNumber","Math","round","stats","items","length","reduce","result","item","existingNames","flatFileNamesSet","newNames","flatFileNamesList","filter","name","has","Set","prefix","map","concat","flatMap"],"mappings":";+BASgBA;;;eAAAA;;;AAAT,SAASA,aAAaC,aAAmB,EAAEC,QAAc;IAC/D,MAAMC,gCAAgCC,oBAAoBH,cAAcI,IAAI,EAAEH,SAASG,IAAI;IAC3F,MAAMC,gCAAgCF,oBAAoBG,WAAWN,gBAAgBM,WAAWL;IAChG,MAAMM,qBAAqBC,gBAAgBC,cAAcT,eAAeC,WAAWK,WAAWL;IAC9F,MAAMS,yBAAyBF,gBAAgBG,kBAAkBX,eAAeC,WAAWK,WAAWN;IACtG,OAAO;QACNE;QACAG;QACAE;QACAG;IACD;AACD;AAEA,SAASP,oBAAoBS,cAAsB,EAAEC,SAAiB;IACrE,OAAOL,gBAAgBK,YAAYD,gBAAgBA;AACpD;AAEA,SAASJ,gBAAgBM,UAAkB,EAAEC,WAAmB;IAC/D,OAAOC,KAAKC,KAAK,CAAC,AAACH,aAAa,MAAOC;AACxC;AAEA,SAAST,WAAWY,KAAW;IAC9B,OAAOA,MAAMC,KAAK,CAACC,MAAM,GAAGF,MAAMC,KAAK,CAACE,MAAM,CAAC,CAACC,QAAQC,OAASD,SAAShB,WAAWiB,OAAO;AAC7F;AAEA,SAASd,cAAcT,aAAmB,EAAEC,QAAc;IACzD,MAAMuB,gBAAgBC,iBAAiBzB;IACvC,MAAM0B,WAAWC,kBAAkB1B;IACnC,OAAOyB,SAASE,MAAM,CAAC,CAACC,OAAS,CAACL,cAAcM,GAAG,CAACD,OAAOT,MAAM;AAClE;AAEA,SAAST,kBAAkBX,aAAmB,EAAEC,QAAc;IAC7D,MAAMuB,gBAAgBG,kBAAkB3B;IACxC,MAAM0B,WAAWD,iBAAiBxB;IAClC,OAAOuB,cAAcI,MAAM,CAAC,CAACC,OAAS,CAACH,SAASI,GAAG,CAACD,OAAOT,MAAM;AAClE;AAEA,SAASK,iBAAiBP,KAAW;IACpC,OAAO,IAAIa,IAAIJ,kBAAkBT;AAClC;AAEA,SAASS,kBAAkBT,KAAW,EAAEc,SAAS,EAAE;IAClD,OAAOd,MAAMC,KAAK,CAACc,GAAG,CAAC,CAACV,OAAS,CAAC,EAAES,OAAO,CAAC,EAAET,KAAKM,IAAI,CAAC,CAAC,EAAEK,MAAM,CAAChB,MAAMC,KAAK,CAACgB,OAAO,CAAC,CAACZ,OAASI,kBAAkBJ,MAAMA,KAAKM,IAAI;AAClI"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export type Stat = {
|
|
2
|
+
readonly name: string;
|
|
3
|
+
readonly size: number;
|
|
4
|
+
readonly items: Stat[];
|
|
5
|
+
};
|
|
6
|
+
export declare function loadExistingDistStats(statsPath: string): Promise<Stat | undefined>;
|
|
7
|
+
export declare function calculateDistStats(distDir: string): Promise<Stat>;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
function _export(target, all) {
|
|
3
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
4
|
+
enumerable: true,
|
|
5
|
+
get: all[name]
|
|
6
|
+
});
|
|
7
|
+
}
|
|
8
|
+
_export(exports, {
|
|
9
|
+
loadExistingDistStats: function() {
|
|
10
|
+
return loadExistingDistStats;
|
|
11
|
+
},
|
|
12
|
+
calculateDistStats: function() {
|
|
13
|
+
return calculateDistStats;
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
const _promises = require("fs/promises");
|
|
17
|
+
const _path = require("path");
|
|
18
|
+
async function loadExistingDistStats(statsPath) {
|
|
19
|
+
try {
|
|
20
|
+
const statsStr = await (0, _promises.readFile)(statsPath, 'utf-8');
|
|
21
|
+
return JSON.parse(statsStr);
|
|
22
|
+
} catch (e) {
|
|
23
|
+
return undefined;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
async function calculateDistStats(distDir) {
|
|
27
|
+
return getFolderStats(distDir, '');
|
|
28
|
+
}
|
|
29
|
+
async function getFolderStats(root, relative) {
|
|
30
|
+
return calculateStats(root, relative);
|
|
31
|
+
}
|
|
32
|
+
async function calculateStats(root, relative) {
|
|
33
|
+
const path = (0, _path.join)(root, relative);
|
|
34
|
+
const stats = await (0, _promises.stat)(path);
|
|
35
|
+
if (stats.isFile()) {
|
|
36
|
+
return {
|
|
37
|
+
name: relative,
|
|
38
|
+
size: stats.size,
|
|
39
|
+
items: []
|
|
40
|
+
};
|
|
41
|
+
} else if (stats.isDirectory()) {
|
|
42
|
+
const nestedFiles = await (0, _promises.readdir)(path);
|
|
43
|
+
const nestedStats = await Promise.all(nestedFiles.map((nestedFile)=>calculateStats((0, _path.join)(root, relative), nestedFile)));
|
|
44
|
+
return {
|
|
45
|
+
name: relative,
|
|
46
|
+
size: nestedStats.reduce((result, stat)=>result + stat.size, 0),
|
|
47
|
+
items: nestedStats
|
|
48
|
+
};
|
|
49
|
+
} else {
|
|
50
|
+
throw new Error('What: ' + path);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
//# sourceMappingURL=dist-stats.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../packages/upgrade-verify/src/executors/verify-build/dist-stats.ts"],"sourcesContent":["import { readFile, readdir, stat } from 'fs/promises';\nimport { join } from 'path';\n\nexport type Stat = {\n\treadonly name: string;\n\treadonly size: number;\n\treadonly items: Stat[];\n};\n\nexport async function loadExistingDistStats(statsPath: string): Promise<Stat | undefined> {\n\ttry {\n\t\tconst statsStr = await readFile(statsPath, 'utf-8');\n\t\treturn JSON.parse(statsStr);\n\t} catch {\n\t\treturn undefined;\n\t}\n}\n\nexport async function calculateDistStats(distDir: string): Promise<Stat> {\n\treturn getFolderStats(distDir, '');\n}\n\nasync function getFolderStats(root: string, relative: string): Promise<Stat> {\n\treturn calculateStats(root, relative);\n}\n\nasync function calculateStats(root: string, relative: string): Promise<Stat> {\n\tconst path = join(root, relative);\n\tconst stats = await stat(path);\n\n\tif (stats.isFile()) {\n\t\treturn {\n\t\t\tname: relative,\n\t\t\tsize: stats.size,\n\t\t\titems: [],\n\t\t};\n\t} else if (stats.isDirectory()) {\n\t\tconst nestedFiles = await readdir(path);\n\t\tconst nestedStats = await Promise.all(nestedFiles.map((nestedFile) => calculateStats(join(root, relative), nestedFile)));\n\t\treturn {\n\t\t\tname: relative,\n\t\t\tsize: nestedStats.reduce((result, stat) => result + stat.size, 0),\n\t\t\titems: nestedStats,\n\t\t};\n\t} else {\n\t\tthrow new Error('What: ' + path);\n\t}\n}\n"],"names":["loadExistingDistStats","calculateDistStats","statsPath","statsStr","readFile","JSON","parse","undefined","distDir","getFolderStats","root","relative","calculateStats","path","join","stats","stat","isFile","name","size","items","isDirectory","nestedFiles","readdir","nestedStats","Promise","all","map","nestedFile","reduce","result","Error"],"mappings":";;;;;;;;IASsBA,qBAAqB;eAArBA;;IASAC,kBAAkB;eAAlBA;;;0BAlBkB;sBACnB;AAQd,eAAeD,sBAAsBE,SAAiB;IAC5D,IAAI;QACH,MAAMC,WAAW,MAAMC,IAAAA,kBAAQ,EAACF,WAAW;QAC3C,OAAOG,KAAKC,KAAK,CAACH;IACnB,EAAE,UAAM;QACP,OAAOI;IACR;AACD;AAEO,eAAeN,mBAAmBO,OAAe;IACvD,OAAOC,eAAeD,SAAS;AAChC;AAEA,eAAeC,eAAeC,IAAY,EAAEC,QAAgB;IAC3D,OAAOC,eAAeF,MAAMC;AAC7B;AAEA,eAAeC,eAAeF,IAAY,EAAEC,QAAgB;IAC3D,MAAME,OAAOC,IAAAA,UAAI,EAACJ,MAAMC;IACxB,MAAMI,QAAQ,MAAMC,IAAAA,cAAI,EAACH;IAEzB,IAAIE,MAAME,MAAM,IAAI;QACnB,OAAO;YACNC,MAAMP;YACNQ,MAAMJ,MAAMI,IAAI;YAChBC,OAAO,EAAE;QACV;IACD,OAAO,IAAIL,MAAMM,WAAW,IAAI;QAC/B,MAAMC,cAAc,MAAMC,IAAAA,iBAAO,EAACV;QAClC,MAAMW,cAAc,MAAMC,QAAQC,GAAG,CAACJ,YAAYK,GAAG,CAAC,CAACC,aAAehB,eAAeE,IAAAA,UAAI,EAACJ,MAAMC,WAAWiB;QAC3G,OAAO;YACNV,MAAMP;YACNQ,MAAMK,YAAYK,MAAM,CAAC,CAACC,QAAQd,OAASc,SAASd,KAAKG,IAAI,EAAE;YAC/DC,OAAOI;QACR;IACD,OAAO;QACN,MAAM,IAAIO,MAAM,WAAWlB;IAC5B;AACD"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "default", {
|
|
3
|
+
enumerable: true,
|
|
4
|
+
get: function() {
|
|
5
|
+
return verifyBuild;
|
|
6
|
+
}
|
|
7
|
+
});
|
|
8
|
+
const _devkit = require("@nx/devkit");
|
|
9
|
+
const _promises = require("fs/promises");
|
|
10
|
+
const _path = require("path");
|
|
11
|
+
const _diststatcomparer = require("./dist-stat-comparer");
|
|
12
|
+
const _diststats = require("./dist-stats");
|
|
13
|
+
async function verifyBuild(options, context) {
|
|
14
|
+
if (context.workspace == null) {
|
|
15
|
+
throw new Error('Workspace context info not available.');
|
|
16
|
+
}
|
|
17
|
+
if (context.projectName == null) {
|
|
18
|
+
throw new Error('Project name not specified in context info.');
|
|
19
|
+
}
|
|
20
|
+
const projectConfig = context.workspace.projects[context.projectName];
|
|
21
|
+
if (projectConfig.targets == null) {
|
|
22
|
+
throw new Error('Target info not available for the project in context info.');
|
|
23
|
+
}
|
|
24
|
+
const distDir = (0, _path.join)(context.root, projectConfig.targets['build'].options.outputPath);
|
|
25
|
+
const statsDir = (0, _path.join)(context.root, projectConfig.root, '.stats');
|
|
26
|
+
await tryMkdir(statsDir);
|
|
27
|
+
if (projectConfig.targets['build'].configurations == null) {
|
|
28
|
+
throw new Error('Configurations info not available for the project, target "build", in context info.');
|
|
29
|
+
}
|
|
30
|
+
let success = true;
|
|
31
|
+
for (const configurationName of Object.keys(projectConfig.targets['build'].configurations)){
|
|
32
|
+
const result = await (0, _devkit.runExecutor)({
|
|
33
|
+
project: context.projectName,
|
|
34
|
+
target: 'build',
|
|
35
|
+
configuration: configurationName
|
|
36
|
+
}, {}, context);
|
|
37
|
+
for await (const x of result){
|
|
38
|
+
if (!x.success) {
|
|
39
|
+
return {
|
|
40
|
+
success: false
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
const statsPath = (0, _path.join)(statsDir, configurationName + '.json');
|
|
45
|
+
const existingStats = await (0, _diststats.loadExistingDistStats)(statsPath);
|
|
46
|
+
const newStats = await (0, _diststats.calculateDistStats)(distDir);
|
|
47
|
+
await (0, _promises.writeFile)(statsPath, JSON.stringify(newStats, null, '\t'));
|
|
48
|
+
if (existingStats != null) {
|
|
49
|
+
const comparison = (0, _diststatcomparer.compareStats)(existingStats, newStats);
|
|
50
|
+
_devkit.logger.info(`Stats for ${context.projectName}/${configurationName}: ${comparison.totalSizeDifferencePercentage}% total size difference, ${comparison.fileCountDifferencePercentage}% file count difference, ${comparison.newFilesPercentage}% new files, ${comparison.deletedFilesPercentage}% deleted files`);
|
|
51
|
+
if (Math.abs(comparison.deletedFilesPercentage) > 10 || Math.abs(comparison.fileCountDifferencePercentage) > 10 || Math.abs(comparison.newFilesPercentage) > 10 || Math.abs(comparison.totalSizeDifferencePercentage) > 10) {
|
|
52
|
+
success = false;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
return {
|
|
57
|
+
success
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
async function tryMkdir(statsDir) {
|
|
61
|
+
try {
|
|
62
|
+
await (0, _promises.mkdir)(statsDir);
|
|
63
|
+
} catch (e) {
|
|
64
|
+
// ignore
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
//# sourceMappingURL=executor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../packages/upgrade-verify/src/executors/verify-build/executor.ts"],"sourcesContent":["import { ExecutorContext, logger, runExecutor } from '@nx/devkit';\nimport { mkdir, writeFile } from 'fs/promises';\nimport { join } from 'path';\nimport { compareStats } from './dist-stat-comparer';\nimport { calculateDistStats, loadExistingDistStats } from './dist-stats';\nimport { VerifyBuildExecutorSchema } from './schema';\n\nexport default async function verifyBuild(options: VerifyBuildExecutorSchema, context: ExecutorContext) {\n\tif (context.workspace == null) {\n\t\tthrow new Error('Workspace context info not available.');\n\t}\n\n\tif (context.projectName == null) {\n\t\tthrow new Error('Project name not specified in context info.');\n\t}\n\n\tconst projectConfig = context.workspace.projects[context.projectName];\n\n\tif (projectConfig.targets == null) {\n\t\tthrow new Error('Target info not available for the project in context info.');\n\t}\n\n\tconst distDir = join(context.root, projectConfig.targets['build'].options.outputPath);\n\tconst statsDir = join(context.root, projectConfig.root, '.stats');\n\tawait tryMkdir(statsDir);\n\n\tif (projectConfig.targets['build'].configurations == null) {\n\t\tthrow new Error('Configurations info not available for the project, target \"build\", in context info.');\n\t}\n\n\tlet success = true;\n\n\tfor (const configurationName of Object.keys(projectConfig.targets['build'].configurations)) {\n\t\tconst result = await runExecutor(\n\t\t\t{\n\t\t\t\tproject: context.projectName,\n\t\t\t\ttarget: 'build',\n\t\t\t\tconfiguration: configurationName,\n\t\t\t},\n\t\t\t{},\n\t\t\tcontext\n\t\t);\n\n\t\tfor await (const x of result) {\n\t\t\tif (!x.success) {\n\t\t\t\treturn { success: false };\n\t\t\t}\n\t\t}\n\n\t\tconst statsPath = join(statsDir, configurationName + '.json');\n\t\tconst existingStats = await loadExistingDistStats(statsPath);\n\t\tconst newStats = await calculateDistStats(distDir);\n\n\t\tawait writeFile(statsPath, JSON.stringify(newStats, null, '\\t'));\n\n\t\tif (existingStats != null) {\n\t\t\tconst comparison = compareStats(existingStats, newStats);\n\t\t\tlogger.info(\n\t\t\t\t`Stats for ${context.projectName}/${configurationName}: ${comparison.totalSizeDifferencePercentage}% total size difference, ${comparison.fileCountDifferencePercentage}% file count difference, ${comparison.newFilesPercentage}% new files, ${comparison.deletedFilesPercentage}% deleted files`\n\t\t\t);\n\n\t\t\tif (\n\t\t\t\tMath.abs(comparison.deletedFilesPercentage) > 10 ||\n\t\t\t\tMath.abs(comparison.fileCountDifferencePercentage) > 10 ||\n\t\t\t\tMath.abs(comparison.newFilesPercentage) > 10 ||\n\t\t\t\tMath.abs(comparison.totalSizeDifferencePercentage) > 10\n\t\t\t) {\n\t\t\t\tsuccess = false;\n\t\t\t}\n\t\t}\n\t}\n\n\treturn { success };\n}\n\nasync function tryMkdir(statsDir: string) {\n\ttry {\n\t\tawait mkdir(statsDir);\n\t} catch {\n\t\t// ignore\n\t}\n}\n"],"names":["verifyBuild","options","context","workspace","Error","projectName","projectConfig","projects","targets","distDir","join","root","outputPath","statsDir","tryMkdir","configurations","success","configurationName","Object","keys","result","runExecutor","project","target","configuration","x","statsPath","existingStats","loadExistingDistStats","newStats","calculateDistStats","writeFile","JSON","stringify","comparison","compareStats","logger","info","totalSizeDifferencePercentage","fileCountDifferencePercentage","newFilesPercentage","deletedFilesPercentage","Math","abs","mkdir"],"mappings":";+BAOA;;;eAA8BA;;;wBAPuB;0BACpB;sBACZ;kCACQ;2BAC6B;AAG3C,eAAeA,YAAYC,OAAkC,EAAEC,OAAwB;IACrG,IAAIA,QAAQC,SAAS,IAAI,MAAM;QAC9B,MAAM,IAAIC,MAAM;IACjB;IAEA,IAAIF,QAAQG,WAAW,IAAI,MAAM;QAChC,MAAM,IAAID,MAAM;IACjB;IAEA,MAAME,gBAAgBJ,QAAQC,SAAS,CAACI,QAAQ,CAACL,QAAQG,WAAW,CAAC;IAErE,IAAIC,cAAcE,OAAO,IAAI,MAAM;QAClC,MAAM,IAAIJ,MAAM;IACjB;IAEA,MAAMK,UAAUC,IAAAA,UAAI,EAACR,QAAQS,IAAI,EAAEL,cAAcE,OAAO,CAAC,QAAQ,CAACP,OAAO,CAACW,UAAU;IACpF,MAAMC,WAAWH,IAAAA,UAAI,EAACR,QAAQS,IAAI,EAAEL,cAAcK,IAAI,EAAE;IACxD,MAAMG,SAASD;IAEf,IAAIP,cAAcE,OAAO,CAAC,QAAQ,CAACO,cAAc,IAAI,MAAM;QAC1D,MAAM,IAAIX,MAAM;IACjB;IAEA,IAAIY,UAAU;IAEd,KAAK,MAAMC,qBAAqBC,OAAOC,IAAI,CAACb,cAAcE,OAAO,CAAC,QAAQ,CAACO,cAAc,EAAG;QAC3F,MAAMK,SAAS,MAAMC,IAAAA,mBAAW,EAC/B;YACCC,SAASpB,QAAQG,WAAW;YAC5BkB,QAAQ;YACRC,eAAeP;QAChB,GACA,CAAC,GACDf;QAGD,WAAW,MAAMuB,KAAKL,OAAQ;YAC7B,IAAI,CAACK,EAAET,OAAO,EAAE;gBACf,OAAO;oBAAEA,SAAS;gBAAM;YACzB;QACD;QAEA,MAAMU,YAAYhB,IAAAA,UAAI,EAACG,UAAUI,oBAAoB;QACrD,MAAMU,gBAAgB,MAAMC,IAAAA,gCAAqB,EAACF;QAClD,MAAMG,WAAW,MAAMC,IAAAA,6BAAkB,EAACrB;QAE1C,MAAMsB,IAAAA,mBAAS,EAACL,WAAWM,KAAKC,SAAS,CAACJ,UAAU,MAAM;QAE1D,IAAIF,iBAAiB,MAAM;YAC1B,MAAMO,aAAaC,IAAAA,8BAAY,EAACR,eAAeE;YAC/CO,cAAM,CAACC,IAAI,CACV,CAAC,UAAU,EAAEnC,QAAQG,WAAW,CAAC,CAAC,EAAEY,kBAAkB,EAAE,EAAEiB,WAAWI,6BAA6B,CAAC,yBAAyB,EAAEJ,WAAWK,6BAA6B,CAAC,yBAAyB,EAAEL,WAAWM,kBAAkB,CAAC,aAAa,EAAEN,WAAWO,sBAAsB,CAAC,eAAe,CAAC;YAGlS,IACCC,KAAKC,GAAG,CAACT,WAAWO,sBAAsB,IAAI,MAC9CC,KAAKC,GAAG,CAACT,WAAWK,6BAA6B,IAAI,MACrDG,KAAKC,GAAG,CAACT,WAAWM,kBAAkB,IAAI,MAC1CE,KAAKC,GAAG,CAACT,WAAWI,6BAA6B,IAAI,IACpD;gBACDtB,UAAU;YACX;QACD;IACD;IAEA,OAAO;QAAEA;IAAQ;AAClB;AAEA,eAAeF,SAASD,QAAgB;IACvC,IAAI;QACH,MAAM+B,IAAAA,eAAK,EAAC/B;IACb,EAAE,UAAM;IACP,SAAS;IACV;AACD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../packages/upgrade-verify/src/executors/verify-build/schema.d.ts"],"sourcesContent":["export interface VerifyBuildExecutorSchema {} // eslint-disable-line\n"],"names":[],"mappings":";CAA8C,sBAAsB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export interface VerifyBuildExecutorSchema {} // eslint-disable-line
|
package/src/index.d.ts
ADDED
|
File without changes
|
package/src/index.js
ADDED
package/src/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../packages/upgrade-verify/src/index.ts"],"names":[],"mappings":""}
|