@ziacik/upgrade-verify 1.0.0 → 1.1.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/CHANGELOG.md CHANGED
@@ -7,9 +7,22 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [1.1.0] - 2023-10-22
11
+
12
+ ### Changed
13
+
14
+ - Upgraded nx to 17.0.1.
15
+
16
+ ## [1.0.1] - 2023-10-21
17
+
18
+ ### Fixed
19
+
20
+ - Fixed the "Package subpath './package.json' is not defined by "exports"" error. #20
21
+ - Generated stats are now properly sorted when remove hashes option is used. #19
22
+
10
23
  ## [1.0.0] - 2023-10-21
11
24
 
12
- ## Added
25
+ ### Added
13
26
 
14
27
  - `removeHashes` option added to the `verify-build` executor, with a default of `true`, which removes hashes from file names, making the comparisons more deterministic.
15
28
  - `check-issues` executor added.
@@ -51,7 +64,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
51
64
  - READMEs updated and props added to package.json.
52
65
  - A _Package subpath './package.json' is not defined by "exports"_ error hopefully fixed.
53
66
 
54
- [unreleased]: https://github.com/ziacik/nx-tools/compare/upgrade-verify-1.0.0...HEAD
67
+ [unreleased]: https://github.com/ziacik/nx-tools/compare/upgrade-verify-1.1.0...HEAD
68
+ [1.1.0]: https://github.com/ziacik/nx-tools/compare/upgrade-verify-1.0.1...upgrade-verify-1.1.0
69
+ [1.0.1]: https://github.com/ziacik/nx-tools/compare/upgrade-verify-1.0.0...upgrade-verify-1.0.1
55
70
  [1.0.0]: https://github.com/ziacik/nx-tools/compare/upgrade-verify-0.2.0...upgrade-verify-1.0.0
56
71
  [0.2.0]: https://github.com/ziacik/nx-tools/compare/upgrade-verify-0.1.1...upgrade-verify-0.2.0
57
72
  [0.1.1]: https://github.com/ziacik/nx-tools/compare/upgrade-verify-0.1.0...upgrade-verify-0.1.1
package/package.json CHANGED
@@ -1,8 +1,14 @@
1
1
  {
2
2
  "name": "@ziacik/upgrade-verify",
3
- "version": "1.0.0",
3
+ "version": "1.1.0",
4
+ "dependencies": {
5
+ "@nx/devkit": "17.0.1",
6
+ "@swc/helpers": "0.5.2"
7
+ },
4
8
  "type": "commonjs",
5
- "executors": "./executors.json",
9
+ "main": "./src/index.js",
10
+ "typings": "./src/index.d.ts",
11
+ "author": "František Žiačik",
6
12
  "keywords": [
7
13
  "nx",
8
14
  "upgrade-verify",
@@ -12,23 +18,11 @@
12
18
  "upgrade",
13
19
  "plugin"
14
20
  ],
15
- "author": "František Žiačik",
16
21
  "repository": {
17
22
  "type": "git",
18
- "url": "https://github.com/ziacik/nx-tools"
23
+ "url": "https://github.com/ziacik/nx-tools",
24
+ "directory": "packages/upgrade-verify"
19
25
  },
20
26
  "license": "MIT",
21
- "exports": {
22
- ".": {
23
- "require": "./package.json"
24
- }
25
- },
26
- "dependencies": {
27
- "@nx/devkit": "16.10.0",
28
- "process": "0.11.10"
29
- },
30
- "peerDependencies": {
31
- "@swc/helpers": "0.5.2"
32
- },
33
- "main": "./src/index.js"
27
+ "executors": "./executors.json"
34
28
  }
@@ -6,7 +6,7 @@
6
6
  <base href="/">
7
7
  <meta name="viewport" content="width=device-width, initial-scale=1" />
8
8
  <link rel="icon" type="image/x-icon" href="favicon.ico" />
9
- <link rel="stylesheet" href="styles.ef46db3751d8e999.css"><link rel="stylesheet" href="main.0274b0362ab850a9.css"></head>
9
+ <link rel="stylesheet" href="styles.ef46db3751d8e999.css"><link rel="stylesheet" href="main.4274b0362ab850a9.css"></head>
10
10
  <body>
11
11
  <app-root></app-root>
12
12
  <script src="runtime.dd97139be5136261.js" type="module"></script><script src="styles.91b7890a3e13c303.js" type="module"></script><script src="main.3d931a8f6ad8b28f.js" type="module"></script></body>
@@ -6,8 +6,8 @@
6
6
  { "name": "assets", "size": 100, "items": [{ "name": ".gitkeep", "size": 100, "items": [] }] },
7
7
  { "name": "assetsx", "size": 0, "items": [{ "name": ".gitkeep", "size": 0, "items": [] }] },
8
8
  { "name": "index.xhtml", "size": 608, "items": [] },
9
- { "name": "main.0274b0362ab850a9.css", "size": 6168, "items": [] },
10
9
  { "name": "main.3d931a8f6ad8b28f.js", "size": 18760, "items": [] },
10
+ { "name": "main.4274b0362ab850a9.css", "size": 6168, "items": [] },
11
11
  { "name": "runtime.dd97139be5136261.js", "size": 2109, "items": [] },
12
12
  { "name": "styles.abc.js", "size": 176, "items": [] },
13
13
  { "name": "styles.ef46db3751d8e999.css", "size": 0, "items": [] }
@@ -9,7 +9,7 @@
9
9
  { "name": "main.css", "size": 6168, "items": [] },
10
10
  { "name": "main.js", "size": 18760, "items": [] },
11
11
  { "name": "runtime.js", "size": 2109, "items": [] },
12
- { "name": "styles.js", "size": 176, "items": [] },
13
- { "name": "styles.css", "size": 0, "items": [] }
12
+ { "name": "styles.css", "size": 0, "items": [] },
13
+ { "name": "styles.js", "size": 176, "items": [] }
14
14
  ]
15
15
  }
@@ -6,8 +6,8 @@
6
6
  { "name": "assets", "size": 0, "items": [{ "name": ".gitkeep", "size": 0, "items": [] }] },
7
7
  { "name": "favicon.ico", "size": 15086, "items": [] },
8
8
  { "name": "index.html", "size": 608, "items": [] },
9
- { "name": "main.0274b0362ab850a9.css", "size": 6168, "items": [] },
10
9
  { "name": "main.3d931a8f6ad8b28f.js", "size": 18760, "items": [] },
10
+ { "name": "main.4274b0362ab850a9.css", "size": 6168, "items": [] },
11
11
  { "name": "runtime.dd97139be5136261.js", "size": 2109, "items": [] },
12
12
  { "name": "styles.91b7890a3e13c303.js", "size": 176, "items": [] },
13
13
  { "name": "styles.ef46db3751d8e999.css", "size": 0, "items": [] }
@@ -15,6 +15,7 @@ _export(exports, {
15
15
  });
16
16
  const _promises = require("fs/promises");
17
17
  const _path = require("path");
18
+ const _withhashremoved = require("./with-hash-removed");
18
19
  async function loadExistingDistStats(statsPath) {
19
20
  try {
20
21
  const statsStr = await (0, _promises.readFile)(statsPath, 'utf-8');
@@ -34,7 +35,7 @@ async function calculateStats(root, relative, removeHashes) {
34
35
  const stats = await (0, _promises.stat)(path);
35
36
  if (stats.isFile()) {
36
37
  return {
37
- name: removeHashes ? withHashRemoved(relative) : relative,
38
+ name: removeHashes ? (0, _withhashremoved.withHashRemoved)(relative) : relative,
38
39
  size: stats.size,
39
40
  items: []
40
41
  };
@@ -44,15 +45,11 @@ async function calculateStats(root, relative, removeHashes) {
44
45
  return {
45
46
  name: relative,
46
47
  size: nestedStats.reduce((result, stat)=>result + stat.size, 0),
47
- items: nestedStats
48
+ items: nestedStats.sort((a, b)=>a.name.localeCompare(b.name))
48
49
  };
49
50
  } else {
50
51
  throw new Error('What: ' + path);
51
52
  }
52
53
  }
53
- const HASH_REGEX = /\.[a-f0-9]{16}\./g;
54
- function withHashRemoved(fileName) {
55
- return fileName.replace(HASH_REGEX, '.');
56
- }
57
54
 
58
55
  //# sourceMappingURL=dist-stats.js.map
@@ -1 +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, removeHashes: boolean): Promise<Stat> {\n\treturn getFolderStats(distDir, '', removeHashes);\n}\n\nasync function getFolderStats(root: string, relative: string, removeHashes: boolean): Promise<Stat> {\n\treturn calculateStats(root, relative, removeHashes);\n}\n\nasync function calculateStats(root: string, relative: string, removeHashes: boolean): 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: removeHashes ? withHashRemoved(relative) : 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, removeHashes)));\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\nconst HASH_REGEX = /\\.[a-f0-9]{16}\\./g;\n\nfunction withHashRemoved(fileName: string): string {\n\treturn fileName.replace(HASH_REGEX, '.');\n}\n"],"names":["loadExistingDistStats","calculateDistStats","statsPath","statsStr","readFile","JSON","parse","undefined","distDir","removeHashes","getFolderStats","root","relative","calculateStats","path","join","stats","stat","isFile","name","withHashRemoved","size","items","isDirectory","nestedFiles","readdir","nestedStats","Promise","all","map","nestedFile","reduce","result","Error","HASH_REGEX","fileName","replace"],"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,EAAEC,YAAqB;IAC9E,OAAOC,eAAeF,SAAS,IAAIC;AACpC;AAEA,eAAeC,eAAeC,IAAY,EAAEC,QAAgB,EAAEH,YAAqB;IAClF,OAAOI,eAAeF,MAAMC,UAAUH;AACvC;AAEA,eAAeI,eAAeF,IAAY,EAAEC,QAAgB,EAAEH,YAAqB;IAClF,MAAMK,OAAOC,IAAAA,UAAI,EAACJ,MAAMC;IACxB,MAAMI,QAAQ,MAAMC,IAAAA,cAAI,EAACH;IAEzB,IAAIE,MAAME,MAAM,IAAI;QACnB,OAAO;YACNC,MAAMV,eAAeW,gBAAgBR,YAAYA;YACjDS,MAAML,MAAMK,IAAI;YAChBC,OAAO,EAAE;QACV;IACD,OAAO,IAAIN,MAAMO,WAAW,IAAI;QAC/B,MAAMC,cAAc,MAAMC,IAAAA,iBAAO,EAACX;QAClC,MAAMY,cAAc,MAAMC,QAAQC,GAAG,CAACJ,YAAYK,GAAG,CAAC,CAACC,aAAejB,eAAeE,IAAAA,UAAI,EAACJ,MAAMC,WAAWkB,YAAYrB;QACvH,OAAO;YACNU,MAAMP;YACNS,MAAMK,YAAYK,MAAM,CAAC,CAACC,QAAQf,OAASe,SAASf,KAAKI,IAAI,EAAE;YAC/DC,OAAOI;QACR;IACD,OAAO;QACN,MAAM,IAAIO,MAAM,WAAWnB;IAC5B;AACD;AAEA,MAAMoB,aAAa;AAEnB,SAASd,gBAAgBe,QAAgB;IACxC,OAAOA,SAASC,OAAO,CAACF,YAAY;AACrC"}
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';\nimport { withHashRemoved } from './with-hash-removed';\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, removeHashes: boolean): Promise<Stat> {\n\treturn getFolderStats(distDir, '', removeHashes);\n}\n\nasync function getFolderStats(root: string, relative: string, removeHashes: boolean): Promise<Stat> {\n\treturn calculateStats(root, relative, removeHashes);\n}\n\nasync function calculateStats(root: string, relative: string, removeHashes: boolean): 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: removeHashes ? withHashRemoved(relative) : 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, removeHashes)));\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.sort((a, b) => a.name.localeCompare(b.name)),\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","removeHashes","getFolderStats","root","relative","calculateStats","path","join","stats","stat","isFile","name","withHashRemoved","size","items","isDirectory","nestedFiles","readdir","nestedStats","Promise","all","map","nestedFile","reduce","result","sort","a","b","localeCompare","Error"],"mappings":";;;;;;;;IAUsBA,qBAAqB;eAArBA;;IASAC,kBAAkB;eAAlBA;;;0BAnBkB;sBACnB;iCACW;AAQzB,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,EAAEC,YAAqB;IAC9E,OAAOC,eAAeF,SAAS,IAAIC;AACpC;AAEA,eAAeC,eAAeC,IAAY,EAAEC,QAAgB,EAAEH,YAAqB;IAClF,OAAOI,eAAeF,MAAMC,UAAUH;AACvC;AAEA,eAAeI,eAAeF,IAAY,EAAEC,QAAgB,EAAEH,YAAqB;IAClF,MAAMK,OAAOC,IAAAA,UAAI,EAACJ,MAAMC;IACxB,MAAMI,QAAQ,MAAMC,IAAAA,cAAI,EAACH;IAEzB,IAAIE,MAAME,MAAM,IAAI;QACnB,OAAO;YACNC,MAAMV,eAAeW,IAAAA,gCAAe,EAACR,YAAYA;YACjDS,MAAML,MAAMK,IAAI;YAChBC,OAAO,EAAE;QACV;IACD,OAAO,IAAIN,MAAMO,WAAW,IAAI;QAC/B,MAAMC,cAAc,MAAMC,IAAAA,iBAAO,EAACX;QAClC,MAAMY,cAAc,MAAMC,QAAQC,GAAG,CAACJ,YAAYK,GAAG,CAAC,CAACC,aAAejB,eAAeE,IAAAA,UAAI,EAACJ,MAAMC,WAAWkB,YAAYrB;QACvH,OAAO;YACNU,MAAMP;YACNS,MAAMK,YAAYK,MAAM,CAAC,CAACC,QAAQf,OAASe,SAASf,KAAKI,IAAI,EAAE;YAC/DC,OAAOI,YAAYO,IAAI,CAAC,CAACC,GAAGC,IAAMD,EAAEf,IAAI,CAACiB,aAAa,CAACD,EAAEhB,IAAI;QAC9D;IACD,OAAO;QACN,MAAM,IAAIkB,MAAM,WAAWvB;IAC5B;AACD"}
@@ -9,7 +9,6 @@ const _extends = require("@swc/helpers/_/_extends");
9
9
  const _devkit = require("@nx/devkit");
10
10
  const _promises = require("fs/promises");
11
11
  const _path = require("path");
12
- const _process = require("process");
13
12
  const _diststatcomparer = require("./dist-stat-comparer");
14
13
  const _diststats = require("./dist-stats");
15
14
  async function verifyBuild(options, context) {
@@ -30,7 +29,7 @@ async function verifyBuild(options, context) {
30
29
  throw new Error('Configurations info not available for the project, target "build", in context info.');
31
30
  }
32
31
  let success = true;
33
- const envBackup = _extends._({}, _process.env);
32
+ const envBackup = _extends._({}, process.env);
34
33
  for (const configurationName of Object.keys(projectConfig.targets['build'].configurations)){
35
34
  retainEnv(envBackup);
36
35
  const runContext = JSON.parse(JSON.stringify(context));
@@ -72,10 +71,10 @@ async function tryMkdir(statsDir) {
72
71
  }
73
72
  }
74
73
  function retainEnv(envBackup) {
75
- for (const key of Object.keys(_process.env)){
76
- delete _process.env[key];
74
+ for (const key of Object.keys(process.env)){
75
+ delete process.env[key];
77
76
  }
78
- Object.assign(_process.env, envBackup);
77
+ Object.assign(process.env, envBackup);
79
78
  }
80
79
 
81
80
  //# sourceMappingURL=executor.js.map
@@ -1 +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 { env } from 'process';\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\tconst envBackup = { ...env };\n\n\tfor (const configurationName of Object.keys(projectConfig.targets['build'].configurations)) {\n\t\tretainEnv(envBackup);\n\t\tconst runContext: ExecutorContext = JSON.parse(JSON.stringify(context));\n\n\t\tconst results = await runExecutor(\n\t\t\t{\n\t\t\t\tproject: runContext.projectName ?? '',\n\t\t\t\ttarget: 'build',\n\t\t\t\tconfiguration: configurationName,\n\t\t\t},\n\t\t\t{},\n\t\t\trunContext\n\t\t);\n\n\t\tfor await (const result of results) {\n\t\t\tif (!result.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, options.removeHashes ?? true);\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 ${runContext.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\nfunction retainEnv(envBackup: Record<string, unknown>): void {\n\tfor (const key of Object.keys(env)) {\n\t\tdelete env[key];\n\t}\n\tObject.assign(env, envBackup);\n}\n"],"names":["verifyBuild","options","context","workspace","Error","projectName","projectConfig","projects","targets","distDir","join","root","outputPath","statsDir","tryMkdir","configurations","success","envBackup","env","configurationName","Object","keys","retainEnv","runContext","JSON","parse","stringify","results","runExecutor","project","target","configuration","result","statsPath","existingStats","loadExistingDistStats","newStats","calculateDistStats","removeHashes","writeFile","comparison","compareStats","logger","info","totalSizeDifferencePercentage","fileCountDifferencePercentage","newFilesPercentage","deletedFilesPercentage","Math","abs","mkdir","key","assign"],"mappings":";+BAQA;;;eAA8BA;;;;wBARuB;0BACpB;sBACZ;yBACD;kCACS;2BAC6B;AAG3C,eAAeA,YAAYC,OAAkC,EAAEC,OAAwB;IACrG,IAAIA,QAAQC,SAAS,IAAI,MAAM;QAC9B,MAAM,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QAAQqC,YAAY,YAApBrC,wBAAwB;QAE3E,MAAMsC,IAAAA,mBAAS,EAACN,WAAWT,KAAKE,SAAS,CAACU,UAAU,MAAM;QAE1D,IAAIF,iBAAiB,MAAM;YAC1B,MAAMM,aAAaC,IAAAA,8BAAY,EAACP,eAAeE;YAC/CM,cAAM,CAACC,IAAI,CACV,CAAC,UAAU,EAAEpB,WAAWlB,WAAW,CAAC,CAAC,EAAEc,kBAAkB,EAAE,EAAEqB,WAAWI,6BAA6B,CAAC,yBAAyB,EAAEJ,WAAWK,6BAA6B,CAAC,yBAAyB,EAAEL,WAAWM,kBAAkB,CAAC,aAAa,EAAEN,WAAWO,sBAAsB,CAAC,eAAe,CAAC;YAGrS,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;gBACD5B,UAAU;YACX;QACD;IACD;IAEA,OAAO;QAAEA;IAAQ;AAClB;AAEA,eAAeF,SAASD,QAAgB;IACvC,IAAI;QACH,MAAMqC,IAAAA,eAAK,EAACrC;IACb,EAAE,UAAM;IACP,SAAS;IACV;AACD;AAEA,SAASS,UAAUL,SAAkC;IACpD,KAAK,MAAMkC,OAAO/B,OAAOC,IAAI,CAACH,YAAG,EAAG;QACnC,OAAOA,YAAG,CAACiC,IAAI;IAChB;IACA/B,OAAOgC,MAAM,CAAClC,YAAG,EAAED;AACpB"}
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\tconst envBackup = { ...process.env };\n\n\tfor (const configurationName of Object.keys(projectConfig.targets['build'].configurations)) {\n\t\tretainEnv(envBackup);\n\t\tconst runContext: ExecutorContext = JSON.parse(JSON.stringify(context));\n\n\t\tconst results = await runExecutor(\n\t\t\t{\n\t\t\t\tproject: runContext.projectName ?? '',\n\t\t\t\ttarget: 'build',\n\t\t\t\tconfiguration: configurationName,\n\t\t\t},\n\t\t\t{},\n\t\t\trunContext\n\t\t);\n\n\t\tfor await (const result of results) {\n\t\t\tif (!result.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, options.removeHashes ?? true);\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 ${runContext.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\nfunction retainEnv(envBackup: Record<string, unknown>): void {\n\tfor (const key of Object.keys(process.env)) {\n\t\tdelete process.env[key];\n\t}\n\tObject.assign(process.env, envBackup);\n}\n"],"names":["verifyBuild","options","context","workspace","Error","projectName","projectConfig","projects","targets","distDir","join","root","outputPath","statsDir","tryMkdir","configurations","success","envBackup","process","env","configurationName","Object","keys","retainEnv","runContext","JSON","parse","stringify","results","runExecutor","project","target","configuration","result","statsPath","existingStats","loadExistingDistStats","newStats","calculateDistStats","removeHashes","writeFile","comparison","compareStats","logger","info","totalSizeDifferencePercentage","fileCountDifferencePercentage","newFilesPercentage","deletedFilesPercentage","Math","abs","mkdir","key","assign"],"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,C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,6BAA6B,CAAC,yBAAyB,EAAEJ,WAAWK,6BAA6B,CAAC,yBAAyB,EAAEL,WAAWM,kBAAkB,CAAC,aAAa,EAAEN,WAAWO,sBAAsB,CAAC,eAAe,CAAC;YAGrS,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;gBACD7B,UAAU;YACX;QACD;IACD;IAEA,OAAO;QAAEA;IAAQ;AAClB;AAEA,eAAeF,SAASD,QAAgB;IACvC,IAAI;QACH,MAAMsC,IAAAA,eAAK,EAACtC;IACb,EAAE,UAAM;IACP,SAAS;IACV;AACD;AAEA,SAASU,UAAUN,SAAkC;IACpD,KAAK,MAAMmC,OAAO/B,OAAOC,IAAI,CAACJ,QAAQC,GAAG,EAAG;QAC3C,OAAOD,QAAQC,GAAG,CAACiC,IAAI;IACxB;IACA/B,OAAOgC,MAAM,CAACnC,QAAQC,GAAG,EAAEF;AAC5B"}
@@ -0,0 +1 @@
1
+ export declare function withHashRemoved(fileName: string): string;
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "withHashRemoved", {
3
+ enumerable: true,
4
+ get: function() {
5
+ return withHashRemoved;
6
+ }
7
+ });
8
+ const HASH_REGEX = /\.[a-f0-9]{16}\./g;
9
+ function withHashRemoved(fileName) {
10
+ return fileName.replace(HASH_REGEX, '.');
11
+ }
12
+
13
+ //# sourceMappingURL=with-hash-removed.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../../packages/upgrade-verify/src/executors/verify-build/with-hash-removed.ts"],"sourcesContent":["const HASH_REGEX = /\\.[a-f0-9]{16}\\./g;\n\nexport function withHashRemoved(fileName: string): string {\n\treturn fileName.replace(HASH_REGEX, '.');\n}\n"],"names":["withHashRemoved","HASH_REGEX","fileName","replace"],"mappings":";+BAEgBA;;;eAAAA;;;AAFhB,MAAMC,aAAa;AAEZ,SAASD,gBAAgBE,QAAgB;IAC/C,OAAOA,SAASC,OAAO,CAACF,YAAY;AACrC"}