@node-cli/bundlesize 4.0.1 → 4.0.3
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/dist/bundlesize.js +1 -1
- package/dist/bundlesize.js.map +1 -1
- package/dist/defaults.js.map +1 -1
- package/dist/getRawStats.js +3 -3
- package/dist/getRawStats.js.map +1 -1
- package/dist/parse.js +1 -1
- package/dist/parse.js.map +1 -1
- package/dist/reportStats.js +1 -1
- package/dist/reportStats.js.map +1 -1
- package/dist/utilities.js +2 -2
- package/dist/utilities.js.map +1 -1
- package/package.json +8 -8
package/dist/bundlesize.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
/* istanbul ignore file */ import { IGNORE, STDOUT } from "./utilities.js";
|
|
3
3
|
import { Logger } from "@node-cli/logger";
|
|
4
|
-
import { config } from "./parse.js";
|
|
5
4
|
import fs from "fs-extra";
|
|
6
5
|
import { getRawStats } from "./getRawStats.js";
|
|
6
|
+
import { config } from "./parse.js";
|
|
7
7
|
import { reportStats } from "./reportStats.js";
|
|
8
8
|
const flags = config.flags;
|
|
9
9
|
const log = new Logger({
|
package/dist/bundlesize.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/bundlesize.ts"],"sourcesContent":["#!/usr/bin/env node\n/* istanbul ignore file */\n\nimport { IGNORE, STDOUT } from \"./utilities.js\";\n\nimport { Logger } from \"@node-cli/logger\";\nimport
|
|
1
|
+
{"version":3,"sources":["../src/bundlesize.ts"],"sourcesContent":["#!/usr/bin/env node\n/* istanbul ignore file */\n\nimport { IGNORE, STDOUT } from \"./utilities.js\";\n\nimport { Logger } from \"@node-cli/logger\";\nimport fs from \"fs-extra\";\nimport { getRawStats } from \"./getRawStats.js\";\nimport { config } from \"./parse.js\";\nimport { reportStats } from \"./reportStats.js\";\n\nconst flags = config.flags;\n\nconst log = new Logger({\n\tboring: flags.boring,\n});\n\nif (flags.type === \"size\") {\n\ttry {\n\t\tconst result = await getRawStats({ flags });\n\n\t\tif (result.outputFile === IGNORE) {\n\t\t\tprocess.exit(result.exitCode);\n\t\t}\n\n\t\tif (result.exitMessage !== \"\") {\n\t\t\tlog.error(result.exitMessage);\n\t\t\tprocess.exit(result.exitCode);\n\t\t}\n\n\t\tif (result.outputFile === STDOUT) {\n\t\t\tlog.info(`Configuration: ${flags.configuration}`);\n\t\t\tlog.info(`Output: ${result.outputFile}`);\n\t\t\tlog.info(`Output prefix: ${result.prefix}`);\n\t\t\tlog.log(result.data);\n\t\t} else {\n\t\t\ttry {\n\t\t\t\tfs.outputJsonSync(result.outputFile, result.data, { spaces: 2 });\n\t\t\t} catch (error) {\n\t\t\t\tlog.error(`Failed to write to file: ${error.message}`);\n\t\t\t\tprocess.exit(1);\n\t\t\t}\n\t\t}\n\t\tprocess.exit(result.exitCode);\n\t} catch (error) {\n\t\tlog.error(error);\n\t\tprocess.exit(1);\n\t}\n}\n\nif (flags.type === \"report\") {\n\ttry {\n\t\tconst result = await reportStats({ flags });\n\n\t\tif (result.exitMessage !== \"\") {\n\t\t\tlog.error(result.exitMessage);\n\t\t\tprocess.exit(result.exitCode);\n\t\t}\n\n\t\tif (result.outputFile === STDOUT) {\n\t\t\tlog.info(`Configuration: ${flags.configuration}`);\n\t\t\tlog.info(`Output: ${result.outputFile}`);\n\t\t\tlog.log(result.data);\n\t\t} else {\n\t\t\ttry {\n\t\t\t\tfs.outputFileSync(result.outputFile, result.data);\n\t\t\t} catch (error) {\n\t\t\t\tlog.error(`Failed to write to file: ${error.message}`);\n\t\t\t\tprocess.exit(1);\n\t\t\t}\n\t\t}\n\t\tprocess.exit(result.exitCode);\n\t} catch (error) {\n\t\tlog.error(error);\n\t\tprocess.exit(1);\n\t}\n}\n\nlog.error(\"Invalid type, please use 'size' or 'report'\");\nprocess.exit(1);\n"],"names":["IGNORE","STDOUT","Logger","fs","getRawStats","config","reportStats","flags","log","boring","type","result","outputFile","process","exit","exitCode","exitMessage","error","info","configuration","prefix","data","outputJsonSync","spaces","message","outputFileSync"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":";AACA,wBAAwB,GAExB,SAASA,MAAM,EAAEC,MAAM,QAAQ,iBAAiB;AAEhD,SAASC,MAAM,QAAQ,mBAAmB;AAC1C,OAAOC,QAAQ,WAAW;AAC1B,SAASC,WAAW,QAAQ,mBAAmB;AAC/C,SAASC,MAAM,QAAQ,aAAa;AACpC,SAASC,WAAW,QAAQ,mBAAmB;AAE/C,MAAMC,QAAQF,OAAOE,KAAK;AAE1B,MAAMC,MAAM,IAAIN,OAAO;IACtBO,QAAQF,MAAME,MAAM;AACrB;AAEA,IAAIF,MAAMG,IAAI,KAAK,QAAQ;IAC1B,IAAI;QACH,MAAMC,SAAS,MAAMP,YAAY;YAAEG;QAAM;QAEzC,IAAII,OAAOC,UAAU,KAAKZ,QAAQ;YACjCa,QAAQC,IAAI,CAACH,OAAOI,QAAQ;QAC7B;QAEA,IAAIJ,OAAOK,WAAW,KAAK,IAAI;YAC9BR,IAAIS,KAAK,CAACN,OAAOK,WAAW;YAC5BH,QAAQC,IAAI,CAACH,OAAOI,QAAQ;QAC7B;QAEA,IAAIJ,OAAOC,UAAU,KAAKX,QAAQ;YACjCO,IAAIU,IAAI,CAAC,CAAC,eAAe,EAAEX,MAAMY,aAAa,CAAC,CAAC;YAChDX,IAAIU,IAAI,CAAC,CAAC,QAAQ,EAAEP,OAAOC,UAAU,CAAC,CAAC;YACvCJ,IAAIU,IAAI,CAAC,CAAC,eAAe,EAAEP,OAAOS,MAAM,CAAC,CAAC;YAC1CZ,IAAIA,GAAG,CAACG,OAAOU,IAAI;QACpB,OAAO;YACN,IAAI;gBACHlB,GAAGmB,cAAc,CAACX,OAAOC,UAAU,EAAED,OAAOU,IAAI,EAAE;oBAAEE,QAAQ;gBAAE;YAC/D,EAAE,OAAON,OAAO;gBACfT,IAAIS,KAAK,CAAC,CAAC,yBAAyB,EAAEA,MAAMO,OAAO,CAAC,CAAC;gBACrDX,QAAQC,IAAI,CAAC;YACd;QACD;QACAD,QAAQC,IAAI,CAACH,OAAOI,QAAQ;IAC7B,EAAE,OAAOE,OAAO;QACfT,IAAIS,KAAK,CAACA;QACVJ,QAAQC,IAAI,CAAC;IACd;AACD;AAEA,IAAIP,MAAMG,IAAI,KAAK,UAAU;IAC5B,IAAI;QACH,MAAMC,SAAS,MAAML,YAAY;YAAEC;QAAM;QAEzC,IAAII,OAAOK,WAAW,KAAK,IAAI;YAC9BR,IAAIS,KAAK,CAACN,OAAOK,WAAW;YAC5BH,QAAQC,IAAI,CAACH,OAAOI,QAAQ;QAC7B;QAEA,IAAIJ,OAAOC,UAAU,KAAKX,QAAQ;YACjCO,IAAIU,IAAI,CAAC,CAAC,eAAe,EAAEX,MAAMY,aAAa,CAAC,CAAC;YAChDX,IAAIU,IAAI,CAAC,CAAC,QAAQ,EAAEP,OAAOC,UAAU,CAAC,CAAC;YACvCJ,IAAIA,GAAG,CAACG,OAAOU,IAAI;QACpB,OAAO;YACN,IAAI;gBACHlB,GAAGsB,cAAc,CAACd,OAAOC,UAAU,EAAED,OAAOU,IAAI;YACjD,EAAE,OAAOJ,OAAO;gBACfT,IAAIS,KAAK,CAAC,CAAC,yBAAyB,EAAEA,MAAMO,OAAO,CAAC,CAAC;gBACrDX,QAAQC,IAAI,CAAC;YACd;QACD;QACAD,QAAQC,IAAI,CAACH,OAAOI,QAAQ;IAC7B,EAAE,OAAOE,OAAO;QACfT,IAAIS,KAAK,CAACA;QACVJ,QAAQC,IAAI,CAAC;IACd;AACD;AAEAN,IAAIS,KAAK,CAAC;AACVJ,QAAQC,IAAI,CAAC"}
|
package/dist/defaults.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/defaults.ts"],"sourcesContent":["/* istanbul ignore file */\n\nexport const defaultFlags = {\n\tboring: false,\n\tconfiguration: \"\",\n\tsilent: false,\n\ttype: \"size\",\n\tforce: false,\n};\n"],"names":["defaultFlags","boring","configuration","silent","type","force"],"mappings":"AAAA,wBAAwB,GAExB,OAAO,MAAMA,eAAe;IAC3BC,QAAQ;IACRC,eAAe;IACfC,QAAQ;IACRC,MAAM;IACNC,OAAO;AACR,EAAE"}
|
|
1
|
+
{"version":3,"sources":["../src/defaults.ts"],"sourcesContent":["/* istanbul ignore file */\n\nexport const defaultFlags = {\n\tboring: false,\n\tconfiguration: \"\",\n\tsilent: false,\n\ttype: \"size\",\n\tforce: false,\n};\n"],"names":["defaultFlags","boring","configuration","silent","type","force"],"rangeMappings":";;;;;;","mappings":"AAAA,wBAAwB,GAExB,OAAO,MAAMA,eAAe;IAC3BC,QAAQ;IACRC,eAAe;IACfC,QAAQ;IACRC,MAAM;IACNC,OAAO;AACR,EAAE"}
|
package/dist/getRawStats.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { GLOB_HASH, GLOB_SEMVER, HASH_KEY, IGNORE, SEMVER_KEY, STDOUT, getOutputFile, gzipSizeFromFileSync, validateConfigurationFile } from "./utilities.js";
|
|
2
1
|
import { basename, dirname, join } from "node:path";
|
|
2
|
+
import { GLOB_HASH, GLOB_SEMVER, HASH_KEY, IGNORE, SEMVER_KEY, STDOUT, getOutputFile, gzipSizeFromFileSync, validateConfigurationFile } from "./utilities.js";
|
|
3
|
+
import { statSync } from "node:fs";
|
|
3
4
|
import bytes from "bytes";
|
|
4
5
|
import fs from "fs-extra";
|
|
5
6
|
import { glob } from "glob";
|
|
6
|
-
import { statSync } from "node:fs";
|
|
7
7
|
export const getRawStats = async ({ flags })=>{
|
|
8
8
|
const result = {
|
|
9
9
|
pass: true,
|
|
@@ -78,7 +78,7 @@ export const getRawStats = async ({ flags })=>{
|
|
|
78
78
|
result.pass = false;
|
|
79
79
|
failed = true;
|
|
80
80
|
}
|
|
81
|
-
|
|
81
|
+
const index = hasHash || hasSemver ? artifact.path : join(artifactPath, basename(file));
|
|
82
82
|
currentResults[index] = {
|
|
83
83
|
fileSize,
|
|
84
84
|
fileSizeGzip,
|
package/dist/getRawStats.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/getRawStats.ts"],"sourcesContent":["import {\n\tGLOB_HASH,\n\tGLOB_SEMVER,\n\tHASH_KEY,\n\tIGNORE,\n\tSEMVER_KEY,\n\tSTDOUT,\n\tgetOutputFile,\n\tgzipSizeFromFileSync,\n\tvalidateConfigurationFile,\n} from \"./utilities.js\";\nimport {
|
|
1
|
+
{"version":3,"sources":["../src/getRawStats.ts"],"sourcesContent":["import { basename, dirname, join } from \"node:path\";\nimport {\n\tGLOB_HASH,\n\tGLOB_SEMVER,\n\tHASH_KEY,\n\tIGNORE,\n\tSEMVER_KEY,\n\tSTDOUT,\n\tgetOutputFile,\n\tgzipSizeFromFileSync,\n\tvalidateConfigurationFile,\n} from \"./utilities.js\";\n\nimport { statSync } from \"node:fs\";\nimport bytes from \"bytes\";\nimport fs from \"fs-extra\";\nimport { glob } from \"glob\";\n\ntype SizesConfiguration = {\n\tlimit: string;\n\tpath: string;\n};\n\ntype ReportStats = {\n\tdata: Record<string, unknown>;\n\texitCode: number;\n\texitMessage: string;\n\toutputFile: string;\n\tpass: boolean;\n\tprefix: string;\n};\n\nexport const getRawStats = async ({ flags }): Promise<ReportStats> => {\n\tconst result: ReportStats = {\n\t\tpass: true,\n\t\texitCode: 0,\n\t\texitMessage: \"\",\n\t\toutputFile: \"\",\n\t\tprefix: \"\",\n\t\tdata: {},\n\t};\n\tlet failed = false;\n\tconst isValidConfigResult = validateConfigurationFile(flags.configuration);\n\tif (isValidConfigResult.exitMessage !== \"\") {\n\t\treturn {\n\t\t\t...result,\n\t\t\t...isValidConfigResult,\n\t\t};\n\t}\n\tconst configurationFile = isValidConfigResult.data;\n\tconst outputFile = getOutputFile(flags.output);\n\tconst prefix = flags.prefix || \"0.0.0\";\n\tconst currentResults = {};\n\n\tconst configuration: { sizes: SizesConfiguration[] } = await import(\n\t\tconfigurationFile\n\t).then((m) => m.default);\n\n\tif (configuration.sizes === undefined) {\n\t\tresult.exitMessage = \"Invalid configuration file: missing sizes object!\";\n\t\tresult.exitCode = 1;\n\t\treturn result;\n\t}\n\n\tfor (const artifact of configuration.sizes) {\n\t\tconst rootPath = artifact.path.startsWith(\"/\")\n\t\t\t? \"\"\n\t\t\t: dirname(configurationFile);\n\t\tconst artifactPath = dirname(artifact.path);\n\t\tconst hasHash = artifact.path.includes(HASH_KEY);\n\t\tconst hasSemver = artifact.path.includes(SEMVER_KEY);\n\n\t\tif (hasSemver && hasHash) {\n\t\t\tresult.exitCode = 1;\n\t\t\tresult.exitMessage = `Invalid path: ${artifact.path}.\\nCannot use ${HASH_KEY} and ${SEMVER_KEY} in the same path.`;\n\t\t\treturn result;\n\t\t}\n\n\t\t/**\n\t\t * if the artifact.path has the string <hash> or <semver> in it,\n\t\t * then we need to check for other characters:\n\t\t * - Double stars ** are allowed.\n\t\t * - Single stars * are not allowed.\n\t\t */\n\t\tif ((hasHash || hasSemver) && /(?<!\\*)\\*(?!\\*)/.test(artifact.path)) {\n\t\t\tresult.exitCode = 1;\n\t\t\tresult.exitMessage = `Invalid path: ${\n\t\t\t\tartifact.path\n\t\t\t}.\\nSingle stars (*) are not allowed when using the special keyword ${\n\t\t\t\thasHash ? HASH_KEY : SEMVER_KEY\n\t\t\t}`;\n\t\t\treturn result;\n\t\t}\n\n\t\tlet location = artifact.path;\n\t\tif (hasHash) {\n\t\t\tlocation = artifact.path.replace(HASH_KEY, GLOB_HASH);\n\t\t}\n\t\tif (hasSemver) {\n\t\t\tlocation = artifact.path.replace(SEMVER_KEY, GLOB_SEMVER);\n\t\t}\n\t\tconst fileGlob = join(rootPath, location);\n\t\tconst files = glob.sync(fileGlob);\n\n\t\tif (files.length === 0) {\n\t\t\tresult.exitCode = 1;\n\t\t\tresult.exitMessage = `File not found: ${fileGlob}`;\n\t\t\treturn result;\n\t\t}\n\n\t\tif (files.length > 1 && hasHash) {\n\t\t\tresult.exitCode = 1;\n\t\t\tresult.exitMessage = `Multiple files found for: ${artifact.path}.\\nPlease use a more specific path when using the special keyword ${HASH_KEY}.`;\n\t\t\treturn result;\n\t\t}\n\n\t\tfor (const file of files) {\n\t\t\tconst fileSize = statSync(file).size;\n\t\t\tconst fileSizeGzip = gzipSizeFromFileSync(file);\n\t\t\tconst passed = fileSizeGzip < bytes(artifact.limit);\n\n\t\t\tif (passed === false) {\n\t\t\t\tresult.pass = false;\n\t\t\t\tfailed = true;\n\t\t\t}\n\t\t\tconst index =\n\t\t\t\thasHash || hasSemver\n\t\t\t\t\t? artifact.path\n\t\t\t\t\t: join(artifactPath, basename(file));\n\n\t\t\tcurrentResults[index] = {\n\t\t\t\tfileSize,\n\t\t\t\tfileSizeGzip,\n\t\t\t\tlimit: artifact.limit,\n\t\t\t\tpassed,\n\t\t\t};\n\t\t}\n\t}\n\n\tlet existingResults = {};\n\tif (outputFile !== STDOUT) {\n\t\ttry {\n\t\t\texistingResults = fs.readJsonSync(outputFile);\n\t\t} catch {\n\t\t\t/**\n\t\t\t * There are no existing results, so we can ignore this error,\n\t\t\t * and simply write the current results to the output file.\n\t\t\t */\n\t\t}\n\t}\n\n\t/**\n\t * If the prefix already exists in the output file,\n\t * - if --force flag is used, overwrite the existing results\n\t * - if --force flag is not used, ignore the new results and\n\t * keep the existing ones.\n\t */\n\tif (existingResults[prefix] !== undefined && flags.force === false) {\n\t\tresult.outputFile = IGNORE;\n\t} else {\n\t\tresult.outputFile = outputFile;\n\t\texistingResults[prefix] = currentResults;\n\t}\n\n\tresult.prefix = prefix;\n\tresult.exitCode = flags.silent === true ? 0 : Number(failed);\n\tresult.data = existingResults;\n\treturn result;\n};\n"],"names":["basename","dirname","join","GLOB_HASH","GLOB_SEMVER","HASH_KEY","IGNORE","SEMVER_KEY","STDOUT","getOutputFile","gzipSizeFromFileSync","validateConfigurationFile","statSync","bytes","fs","glob","getRawStats","flags","result","pass","exitCode","exitMessage","outputFile","prefix","data","failed","isValidConfigResult","configuration","configurationFile","output","currentResults","then","m","default","sizes","undefined","artifact","rootPath","path","startsWith","artifactPath","hasHash","includes","hasSemver","test","location","replace","fileGlob","files","sync","length","file","fileSize","size","fileSizeGzip","passed","limit","index","existingResults","readJsonSync","force","silent","Number"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,SAASA,QAAQ,EAAEC,OAAO,EAAEC,IAAI,QAAQ,YAAY;AACpD,SACCC,SAAS,EACTC,WAAW,EACXC,QAAQ,EACRC,MAAM,EACNC,UAAU,EACVC,MAAM,EACNC,aAAa,EACbC,oBAAoB,EACpBC,yBAAyB,QACnB,iBAAiB;AAExB,SAASC,QAAQ,QAAQ,UAAU;AACnC,OAAOC,WAAW,QAAQ;AAC1B,OAAOC,QAAQ,WAAW;AAC1B,SAASC,IAAI,QAAQ,OAAO;AAgB5B,OAAO,MAAMC,cAAc,OAAO,EAAEC,KAAK,EAAE;IAC1C,MAAMC,SAAsB;QAC3BC,MAAM;QACNC,UAAU;QACVC,aAAa;QACbC,YAAY;QACZC,QAAQ;QACRC,MAAM,CAAC;IACR;IACA,IAAIC,SAAS;IACb,MAAMC,sBAAsBf,0BAA0BM,MAAMU,aAAa;IACzE,IAAID,oBAAoBL,WAAW,KAAK,IAAI;QAC3C,OAAO;YACN,GAAGH,MAAM;YACT,GAAGQ,mBAAmB;QACvB;IACD;IACA,MAAME,oBAAoBF,oBAAoBF,IAAI;IAClD,MAAMF,aAAab,cAAcQ,MAAMY,MAAM;IAC7C,MAAMN,SAASN,MAAMM,MAAM,IAAI;IAC/B,MAAMO,iBAAiB,CAAC;IAExB,MAAMH,gBAAiD,MAAM,MAAM,CAClEC,mBACCG,IAAI,CAAC,CA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,"sources":["../src/parse.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"sources":["../src/parse.ts"],"sourcesContent":["import { parser } from \"@node-cli/parser\";\nimport { defaultFlags } from \"./defaults.js\";\n\nexport type Flags = {\n\tboring?: boolean;\n\thelp?: boolean;\n\tversion?: boolean;\n\tconfiguration?: string;\n\toutput?: string;\n\tprefix?: string;\n\tsilent?: boolean;\n\ttype?: \"size\" | \"report\";\n\tforce?: boolean;\n};\n\nexport type Configuration = {\n\tflags?: Flags;\n\tusage?: boolean;\n\tshowHelp?: () => void;\n};\n\n/* istanbul ignore next */\nexport const config: Configuration = parser({\n\tmeta: import.meta,\n\texamples: [],\n\tflags: {\n\t\tforce: {\n\t\t\tshortFlag: \"f\",\n\t\t\tdescription: \"Overwrite existing results\",\n\t\t\ttype: \"boolean\",\n\t\t\tdefault: defaultFlags.force,\n\t\t},\n\t\ttype: {\n\t\t\tshortFlag: \"t\",\n\t\t\tdescription: \"Specify the type of output: size or report\",\n\t\t\ttype: \"string\",\n\t\t\tdefault: defaultFlags.type,\n\t\t},\n\t\tconfiguration: {\n\t\t\tshortFlag: \"c\",\n\t\t\tdescription: \"Specify a configuration file\",\n\t\t\ttype: \"string\",\n\t\t},\n\t\toutput: {\n\t\t\tshortFlag: \"o\",\n\t\t\tdescription: \"Specify the output file\",\n\t\t\ttype: \"string\",\n\t\t},\n\t\tprefix: {\n\t\t\tshortFlag: \"p\",\n\t\t\tdescription: \"Specify a prefix to use in the output file\",\n\t\t\ttype: \"string\",\n\t\t},\n\t\tsilent: {\n\t\t\tshortFlag: \"s\",\n\t\t\tdefault: defaultFlags.silent,\n\t\t\tdescription: \"Do not exit in error when a limit is exceeded\",\n\t\t\ttype: \"boolean\",\n\t\t},\n\t\tboring: {\n\t\t\tshortFlag: \"b\",\n\t\t\tdefault: defaultFlags.boring,\n\t\t\tdescription: \"Do not use color output\",\n\t\t\ttype: \"boolean\",\n\t\t},\n\t\thelp: {\n\t\t\tshortFlag: \"h\",\n\t\t\tdescription: \"Display help instructions\",\n\t\t\ttype: \"boolean\",\n\t\t},\n\t\tversion: {\n\t\t\tshortFlag: \"v\",\n\t\t\tdescription: \"Output the current version\",\n\t\t\ttype: \"boolean\",\n\t\t},\n\t},\n\tusage: true,\n\tdefaultFlags,\n});\n"],"names":["parser","defaultFlags","config","meta","examples","flags","force","shortFlag","description","type","default","configuration","output","prefix","silent","boring","help","version","usage"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,SAASA,MAAM,QAAQ,mBAAmB;AAC1C,SAASC,YAAY,QAAQ,gBAAgB;AAoB7C,wBAAwB,GACxB,OAAO,MAAMC,SAAwBF,OAAO;IAC3CG,MAAM;IACNC,UAAU,EAAE;IACZC,OAAO;QACNC,OAAO;YACNC,WAAW;YACXC,aAAa;YACbC,MAAM;YACNC,SAAST,aAAaK,KAAK;QAC5B;QACAG,MAAM;YACLF,WAAW;YACXC,aAAa;YACbC,MAAM;YACNC,SAAST,aAAaQ,IAAI;QAC3B;QACAE,eAAe;YACdJ,WAAW;YACXC,aAAa;YACbC,MAAM;QACP;QACAG,QAAQ;YACPL,WAAW;YACXC,aAAa;YACbC,MAAM;QACP;QACAI,QAAQ;YACPN,WAAW;YACXC,aAAa;YACbC,MAAM;QACP;QACAK,QAAQ;YACPP,WAAW;YACXG,SAAST,aAAaa,MAAM;YAC5BN,aAAa;YACbC,MAAM;QACP;QACAM,QAAQ;YACPR,WAAW;YACXG,SAAST,aAAac,MAAM;YAC5BP,aAAa;YACbC,MAAM;QACP;QACAO,MAAM;YACLT,WAAW;YACXC,aAAa;YACbC,MAAM;QACP;QACAQ,SAAS;YACRV,WAAW;YACXC,aAAa;YACbC,MAAM;QACP;IACD;IACAS,OAAO;IACPjB;AACD,GAAG"}
|
package/dist/reportStats.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { addMDrow, formatFooter, getMostRecentVersion, getOutputFile, percentFormatter, readJSONFile, validateConfigurationFile } from "./utilities.js";
|
|
2
1
|
import { basename, dirname, join } from "node:path";
|
|
2
|
+
import { addMDrow, formatFooter, getMostRecentVersion, getOutputFile, percentFormatter, readJSONFile, validateConfigurationFile } from "./utilities.js";
|
|
3
3
|
import bytes from "bytes";
|
|
4
4
|
export const reportStats = async ({ flags })=>{
|
|
5
5
|
const result = {
|
package/dist/reportStats.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/reportStats.ts"],"sourcesContent":["import {\n\taddMDrow,\n\tformatFooter,\n\tgetMostRecentVersion,\n\tgetOutputFile,\n\tpercentFormatter,\n\treadJSONFile,\n\tvalidateConfigurationFile,\n} from \"./utilities.js\";\nimport
|
|
1
|
+
{"version":3,"sources":["../src/reportStats.ts"],"sourcesContent":["import { basename, dirname, join } from \"node:path\";\nimport {\n\taddMDrow,\n\tformatFooter,\n\tgetMostRecentVersion,\n\tgetOutputFile,\n\tpercentFormatter,\n\treadJSONFile,\n\tvalidateConfigurationFile,\n} from \"./utilities.js\";\n\nimport bytes from \"bytes\";\nimport type { FooterProperties } from \"./utilities.js\";\n\ntype ReportConfiguration = {\n\tcurrent: string;\n\tprevious: string;\n\n\theader?: string;\n\tfooter?: (arguments_: FooterProperties) => string;\n\tcolumns?: { [key: string]: string }[];\n};\n\ntype ReportCompare = {\n\tdata: string;\n\texitCode: number;\n\texitMessage: string;\n\toutputFile: string;\n};\n\nexport const reportStats = async ({ flags }): Promise<ReportCompare> => {\n\tconst result: ReportCompare = {\n\t\texitCode: 0,\n\t\texitMessage: \"\",\n\t\toutputFile: \"\",\n\t\tdata: \"\",\n\t};\n\tlet previousStats, previousVersion: string;\n\tconst isValidConfigResult = validateConfigurationFile(flags.configuration);\n\tif (isValidConfigResult.exitMessage !== \"\") {\n\t\treturn {\n\t\t\t...result,\n\t\t\t...isValidConfigResult,\n\t\t};\n\t}\n\tconst configurationFile = isValidConfigResult.data;\n\tconst outputFile = getOutputFile(flags.output);\n\tresult.outputFile = outputFile;\n\n\tconst configuration: { report: ReportConfiguration } = await import(\n\t\tconfigurationFile\n\t).then((m) => m.default);\n\n\tconst currentStats = readJSONFile(\n\t\tjoin(dirname(configurationFile), configuration.report.current),\n\t);\n\tif (currentStats.exitMessage !== \"\") {\n\t\treturn {\n\t\t\t...result,\n\t\t\t...currentStats,\n\t\t};\n\t}\n\n\ttry {\n\t\tpreviousStats = readJSONFile(\n\t\t\tjoin(dirname(configurationFile), configuration.report.previous),\n\t\t);\n\t\tif (previousStats.exitMessage !== \"\") {\n\t\t\treturn {\n\t\t\t\t...result,\n\t\t\t\t...previousStats,\n\t\t\t};\n\t\t}\n\t\tpreviousVersion = getMostRecentVersion(previousStats.data);\n\t} catch {\n\t\t// nothing to declare officer\n\t}\n\tconst currentVersion = getMostRecentVersion(currentStats.data);\n\n\tlet limitReached = false;\n\tlet overallDiff = 0;\n\tlet totalGzipSize = 0;\n\n\tconst headerString = configuration.report.header || \"## Bundle Size\";\n\tconst footerFormatter = configuration.report.footer || formatFooter;\n\tconst columns = configuration.report.columns || [\n\t\t{ status: \"Status\" },\n\t\t{ file: \"File\" },\n\t\t{ size: \"Size (Gzip)\" },\n\t\t{ limits: \"Limits\" },\n\t];\n\n\tconst rowsMD = [];\n\trowsMD.push(addMDrow({ type: \"header\", columns }));\n\n\tfor (const key of Object.keys(currentStats.data[currentVersion])) {\n\t\tconst item = currentStats.data[currentVersion][key];\n\t\tconst name = basename(key);\n\t\tif (!item.passed) {\n\t\t\tlimitReached = true;\n\t\t}\n\n\t\tlet diffString = \"\";\n\t\tif (previousStats && previousVersion) {\n\t\t\tconst previousFileStats =\n\t\t\t\tpreviousStats.data[previousVersion] &&\n\t\t\t\tpreviousStats.data[previousVersion][key];\n\t\t\tconst previousFileSizeGzip = previousFileStats?.fileSizeGzip || 0;\n\t\t\tconst diff = item.fileSizeGzip - previousFileSizeGzip;\n\n\t\t\toverallDiff += diff;\n\t\t\tdiffString =\n\t\t\t\tdiff === 0 || diff === item.fileSizeGzip\n\t\t\t\t\t? \"\"\n\t\t\t\t\t: ` (${diff > 0 ? \"+\" : \"-\"}${bytes(Math.abs(diff), {\n\t\t\t\t\t\t\tunitSeparator: \" \",\n\t\t\t\t\t\t})} ${percentFormatter(diff / previousFileSizeGzip)})`;\n\t\t}\n\n\t\ttotalGzipSize += item.fileSizeGzip;\n\n\t\trowsMD.push(\n\t\t\taddMDrow({\n\t\t\t\ttype: \"row\",\n\t\t\t\tpassed: item.passed,\n\t\t\t\tname: name,\n\t\t\t\tsize: item.fileSizeGzip,\n\t\t\t\tdiff: diffString,\n\t\t\t\tlimit: item.limit,\n\t\t\t\tcolumns,\n\t\t\t}),\n\t\t);\n\t}\n\n\tconst template = `\n${headerString}\n${rowsMD.join(\"\\n\")}\n\n${footerFormatter({\n\tlimitReached,\n\toverallDiff,\n\ttotalGzipSize,\n})}\n`;\n\n\tif (limitReached) {\n\t\tresult.exitCode = 1;\n\t}\n\n\tresult.data = template;\n\n\treturn result;\n};\n"],"names":["basename","dirname","join","addMDrow","formatFooter","getMostRecentVersion","getOutputFile","percentFormatter","readJSONFile","validateConfigurationFile","bytes","reportStats","flags","result","exitCode","exitMessage","outputFile","data","previousStats","previousVersion","isValidConfigResult","configuration","configurationFile","output","then","m","default","currentStats","report","current","previous","currentVersion","limitReached","overallDiff","totalGzipSize","headerString","header","footerFormatter","footer","columns","status","file","size","limits","rowsMD","push","type","key","Object","keys","item","name","passed","diffString","previousFileStats","previousFileSizeGzip","fileSizeGzip","diff","Math","abs","unitSeparator","limit","template"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,SAASA,QAAQ,EAAEC,OAAO,EAAEC,IAAI,QAAQ,YAAY;AACpD,SACCC,QAAQ,EACRC,YAAY,EACZC,oBAA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B,aAAa;AACf,EAAES,OAAO1C,IAAI,CAAC,MAAM;;AAEpB,EAAEmC,gBAAgB;QACjBL;QACAC;QACAC;IACD,GAAG;AACH,CAAC;IAEA,IAAIF,cAAc;QACjBnB,OAAOC,QAAQ,GAAG;IACnB;IAEAD,OAAOI,IAAI,GAAG6C;IAEd,OAAOjD;AACR,EAAE"}
|
package/dist/utilities.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
+
import { join } from "node:path";
|
|
2
|
+
import zlib from "node:zlib";
|
|
1
3
|
import bytes from "bytes";
|
|
2
4
|
import fs from "fs-extra";
|
|
3
|
-
import { join } from "node:path";
|
|
4
5
|
import semver from "semver";
|
|
5
|
-
import zlib from "node:zlib";
|
|
6
6
|
export const STDOUT = "stdout";
|
|
7
7
|
export const IGNORE = "ignore";
|
|
8
8
|
export const HASH_KEY = "<hash>";
|
package/dist/utilities.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/utilities.ts"],"sourcesContent":["import
|
|
1
|
+
{"version":3,"sources":["../src/utilities.ts"],"sourcesContent":["import { join } from \"node:path\";\nimport zlib from \"node:zlib\";\nimport bytes from \"bytes\";\nimport fs from \"fs-extra\";\nimport semver from \"semver\";\n\nexport const STDOUT = \"stdout\";\nexport const IGNORE = \"ignore\";\nexport const HASH_KEY = \"<hash>\";\nexport const SEMVER_KEY = \"<semver>\";\nexport const GLOB_HASH = \"+([a-zA-Z0-9_-])\";\nexport const GLOB_SEMVER = \"+([0-9]).+([0-9]).+([0-9])*([.a-zA-Z0-9_-])\";\n\nconst CWD = process.cwd();\n\nexport const gzipSizeFromFileSync = (file: string): number => {\n\treturn zlib.gzipSync(fs.readFileSync(file)).length;\n};\n\nexport const getOutputFile = (file: string): string => {\n\treturn file === \"\" || file === undefined ? STDOUT : join(CWD, file);\n};\n\nexport const validateConfigurationFile = (file: string): any => {\n\tconst result = {\n\t\texitCode: 0,\n\t\texitMessage: \"\",\n\t\tdata: {},\n\t};\n\tif (file === \"\") {\n\t\tresult.exitMessage = \"Please provide a configuration file\";\n\t\tresult.exitCode = 1;\n\t\treturn result;\n\t}\n\n\tconst configurationFile = file.startsWith(\"/\") ? file : join(CWD, file);\n\n\tif (fs.existsSync(configurationFile) === false) {\n\t\tresult.exitMessage = `Invalid or missing configuration file!\\n${configurationFile}`;\n\t\tresult.exitCode = 1;\n\t\treturn result;\n\t}\n\n\treturn {\n\t\t...result,\n\t\tdata: configurationFile,\n\t};\n};\n\nexport const readJSONFile = (file: string): any => {\n\ttry {\n\t\treturn {\n\t\t\texitCode: 0,\n\t\t\texitMessage: \"\",\n\t\t\tdata: fs.readJsonSync(file),\n\t\t};\n\t} catch (error) {\n\t\treturn {\n\t\t\texitCode: 1,\n\t\t\texitMessage: `Failed to read JSON file: ${error.message}`,\n\t\t};\n\t}\n};\n\nexport const getMostRecentVersion = (data: []) => {\n\tconst keys = [];\n\tfor (const key of Object.keys(data)) {\n\t\tkeys.push(key);\n\t}\n\tkeys.sort(semver.rcompare);\n\treturn keys[0];\n};\n\nexport const percentFormatter = (value: number) => {\n\tconst formatter = new Intl.NumberFormat(\"en\", {\n\t\tstyle: \"percent\",\n\t\tsignDisplay: \"exceptZero\",\n\t\tminimumFractionDigits: 2,\n\t\tmaximumFractionDigits: 2,\n\t});\n\treturn formatter.format(value);\n};\n\nexport type FooterProperties = {\n\tlimitReached: boolean;\n\toverallDiff: number;\n\ttotalGzipSize: number;\n};\nexport const formatFooter = ({\n\tlimitReached,\n\toverallDiff,\n\ttotalGzipSize,\n}: FooterProperties) => {\n\tlet percentageDiff = \"\";\n\tconst result = [];\n\n\tconst totalGzipSizeString = `${bytes(totalGzipSize || 0, {\n\t\tunitSeparator: \" \",\n\t})}`;\n\n\tpercentageDiff = percentFormatter(\n\t\toverallDiff / (totalGzipSize - overallDiff),\n\t);\n\tconst overallDiffString =\n\t\t!overallDiff || overallDiff === 0\n\t\t\t? \"\"\n\t\t\t: `(${overallDiff > 0 ? \"+\" : \"-\"}${bytes(Math.abs(overallDiff), {\n\t\t\t\t\tunitSeparator: \" \",\n\t\t\t\t})} ${percentageDiff})`;\n\n\tresult.push(\n\t\t`Overall bundle size: ${totalGzipSizeString} ${overallDiffString}`.trim(),\n\t\t`Overall status: ${limitReached ? \"🚫\" : \"✅\"}`,\n\t);\n\n\treturn `${result.join(\"\\n\")}`;\n};\n\nexport const addMDrow = ({\n\ttype,\n\tpassed = true,\n\tname = \"\",\n\tsize = 0,\n\tdiff = \"\",\n\tlimit = \"\",\n\tcolumns,\n}: {\n\tcolumns: any;\n\ttype: \"header\" | \"row\";\n\tpassed?: boolean;\n\tname?: string;\n\tsize?: number;\n\tdiff?: string;\n\tlimit?: string;\n}) => {\n\tconst totalColumns = columns.length;\n\n\tif (type === \"header\") {\n\t\tconst separator = \" --- |\".repeat(totalColumns);\n\t\tconst header = columns.map((column) => column[Object.keys(column)[0]]);\n\t\treturn `| ${header.join(\" | \")} |\\n|${separator}`;\n\t}\n\tif (type === \"row\") {\n\t\tconst row = columns\n\t\t\t.map((column: Record<string, any>) => {\n\t\t\t\tconst key = Object.keys(column)[0];\n\t\t\t\tif (key === \"status\") {\n\t\t\t\t\treturn passed ? \"✅\" : \"🚫\";\n\t\t\t\t}\n\t\t\t\tif (key === \"file\") {\n\t\t\t\t\treturn name.replaceAll(\"<\", \"[\").replaceAll(\">\", \"]\");\n\t\t\t\t}\n\t\t\t\tif (key === \"size\") {\n\t\t\t\t\treturn `${bytes(size, {\n\t\t\t\t\t\tunitSeparator: \" \",\n\t\t\t\t\t})}${diff}`;\n\t\t\t\t}\n\t\t\t\tif (key === \"limits\") {\n\t\t\t\t\treturn limit;\n\t\t\t\t}\n\t\t\t\treturn \"\";\n\t\t\t})\n\t\t\t.filter((item: string) => item !== \"\");\n\n\t\treturn `| ${row.join(\" | \")} |`;\n\t}\n};\n"],"names":["join","zlib","bytes","fs","semver","STDOUT","IGNORE","HASH_KEY","SEMVER_KEY","GLOB_HASH","GLOB_SEMVER","CWD","process","cwd","gzipSizeFromFileSync","file","gzipSync","readFileSync","length","getOutputFile","undefined","validateConfigurationFile","result","exitCode","exitMessage","data","configurationFile","startsWith","existsSync","readJSONFile","readJsonSync","error","message","getMostRecentVersion","keys","key","Object","push","sort","rcompare","percentFormatter","value","formatter","Intl","NumberFormat","style","signDisplay","minimumFractionDigits","maximumFractionDigits","format","formatFooter","limitReached","overallDiff","totalGzipSize","percentageDiff","totalGzipSizeString","unitSeparator","overallDiffString","Math","abs","trim","addMDrow","type","passed","name","size","diff","limit","columns","totalColumns","separator","repeat","header","map","column","row","replaceAll","filter","item"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,SAASA,IAAI,QAAQ,YAAY;AACjC,OAAOC,UAAU,YAAY;AAC7B,OAAOC,WAAW,QAAQ;AAC1B,OAAOC,QAAQ,WAAW;AAC1B,OAAOC,YAAY,SAAS;AAE5B,OAAO,MAAMC,SAAS,SAAS;AAC/B,OAAO,MAAMC,SAAS,SAAS;AAC/B,OAAO,MAAMC,WAAW,SAAS;AACjC,OAAO,MAAMC,aAAa,WAAW;AACrC,OAAO,MAAMC,YAAY,mBAAmB;AAC5C,OAAO,MAAMC,cAAc,8CAA8C;AAEzE,MAAMC,MAAMC,QAAQC,GAAG;AAEvB,OAAO,MAAMC,uBAAuB,CAACC;IACpC,OAAOd,KAAKe,QAAQ,CAACb,GAAGc,YAAY,CAACF,OAAOG,MAAM;AACnD,EAAE;AAEF,OAAO,MAAMC,gBAAgB,CAACJ;IAC7B,OAAOA,SAAS,MAAMA,SAASK,YAAYf,SAASL,KAAKW,KAAKI;AAC/D,EAAE;AAEF,OAAO,MAAMM,4BAA4B,CAACN;IACzC,MAAMO,SAAS;QACdC,UAAU;QACVC,aAAa;QACbC,MAAM,CAAC;IACR;IACA,IAA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C,KAAK;YAClD;YACA,IAAIzC,QAAQ,QAAQ;gBACnB,OAAO,CAAC,EAAEjC,MAAM+D,MAAM;oBACrBT,eAAe;gBAChB,GAAG,EAAEU,KAAK,CAAC;YACZ;YACA,IAAI/B,QAAQ,UAAU;gBACrB,OAAOgC;YACR;YACA,OAAO;QACR,GACCU,MAAM,CAAC,CAACC,OAAiBA,SAAS;QAEpC,OAAO,CAAC,EAAE,EAAEH,IAAI3E,IAAI,CAAC,OAAO,EAAE,CAAC;IAChC;AACD,EAAE"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@node-cli/bundlesize",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.3",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": "Arno Versini",
|
|
6
6
|
"description": "Simple CLI tool that checks file(s) size and report if limits have been reached",
|
|
@@ -15,27 +15,27 @@
|
|
|
15
15
|
"scripts": {
|
|
16
16
|
"build": "npm-run-all --serial clean build:types build:js build:barrel",
|
|
17
17
|
"build:barrel": "barrelsby --delete --directory dist --pattern \"**/*.d.ts\" --name \"index.d\"",
|
|
18
|
-
"build:js": "swc --source-maps --out-dir dist src",
|
|
18
|
+
"build:js": "swc --strip-leading-paths --source-maps --out-dir dist src",
|
|
19
19
|
"build:types": "tsc",
|
|
20
20
|
"clean": "rimraf dist types coverage",
|
|
21
|
-
"lint": "
|
|
21
|
+
"lint": "biome lint src",
|
|
22
22
|
"stats": "bundlesize -c bundlesize.config.js -p \"$npm_package_version\"",
|
|
23
23
|
"stats:diff": "bundlesize -t diff",
|
|
24
24
|
"test": "cross-env-shell NODE_OPTIONS=--experimental-vm-modules jest",
|
|
25
25
|
"test:coverage": "npm run test -- --coverage",
|
|
26
26
|
"test:watch": "npm run test -- --watch",
|
|
27
|
-
"watch": "swc --watch --out-dir dist src"
|
|
27
|
+
"watch": "swc --strip-leading-paths --watch --out-dir dist src"
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@node-cli/logger": "
|
|
31
|
-
"@node-cli/parser": "
|
|
30
|
+
"@node-cli/logger": "1.2.5",
|
|
31
|
+
"@node-cli/parser": "2.3.3",
|
|
32
32
|
"bytes": "3.1.2",
|
|
33
33
|
"fs-extra": "11.2.0",
|
|
34
|
-
"glob": "10.3.
|
|
34
|
+
"glob": "10.3.12",
|
|
35
35
|
"semver": "7.6.0"
|
|
36
36
|
},
|
|
37
37
|
"publishConfig": {
|
|
38
38
|
"access": "public"
|
|
39
39
|
},
|
|
40
|
-
"gitHead": "
|
|
40
|
+
"gitHead": "d7d79f8f71fb3225e5a214aba3a42a89470d8340"
|
|
41
41
|
}
|