sol2uml 2.5.2 → 2.5.4

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 CHANGED
@@ -112,6 +112,7 @@ Options:
112
112
  -hm, --hideModifiers hide modifier functions from contracts (default: false)
113
113
  -ht, --hideEvents hide events from contracts, interfaces and libraries (default: false)
114
114
  -hc, --hideConstants hide file level constants (default: false)
115
+ -hx, --hideContracts hide contracts (default: false)
115
116
  -he, --hideEnums hide enum types (default: false)
116
117
  -hs, --hideStructs hide data structures (default: false)
117
118
  -hl, --hideLibraries hide libraries (default: false)
@@ -1,6 +1,7 @@
1
1
  import { UmlClass } from './umlClass';
2
2
  export interface ClassOptions {
3
3
  hideConstants?: boolean;
4
+ hideContracts?: boolean;
4
5
  hideVariables?: boolean;
5
6
  hideFunctions?: boolean;
6
7
  hideModifiers?: boolean;
@@ -22,8 +22,9 @@ const filterHiddenClasses = (umlClasses, options) => {
22
22
  !options.hideConstants) ||
23
23
  (u.stereotype === umlClass_1.ClassStereotype.Library &&
24
24
  !options.hideLibraries) ||
25
- u.stereotype === umlClass_1.ClassStereotype.None ||
26
- u.stereotype === umlClass_1.ClassStereotype.Contract);
25
+ ((u.stereotype === umlClass_1.ClassStereotype.None ||
26
+ u.stereotype === umlClass_1.ClassStereotype.Contract) &&
27
+ !options.hideContracts));
27
28
  };
28
29
  exports.filterHiddenClasses = filterHiddenClasses;
29
30
  /**
@@ -137,7 +137,7 @@ class EtherscanParser {
137
137
  // match whitespace before import
138
138
  // and characters after import up to ;
139
139
  // replace all in file and match across multiple lines
140
- const removedImports = removedPragmaSolidity.replace(/(\s)(import.*;)/gm, '$1/* $2 */');
140
+ const removedImports = removedPragmaSolidity.replace(/^\s*?(import.*?;)/gms, '/* $1 */');
141
141
  // Rename SPDX-License-Identifier to SPDX--License-Identifier so the merged file will compile
142
142
  const removedSPDX = removedImports.replace(/SPDX-/, 'SPDX--');
143
143
  solidityCode += removedSPDX;
package/lib/sol2uml.js CHANGED
@@ -63,6 +63,7 @@ program
63
63
  .option('-hm, --hideModifiers', 'hide modifier functions from contracts', false)
64
64
  .option('-ht, --hideEvents', 'hide events from contracts, interfaces and libraries', false)
65
65
  .option('-hc, --hideConstants', 'hide file level constants', false)
66
+ .option('-hx, --hideContracts', 'hide contracts', false)
66
67
  .option('-he, --hideEnums', 'hide enum types', false)
67
68
  .option('-hs, --hideStructs', 'hide data structures', false)
68
69
  .option('-hl, --hideLibraries', 'hide libraries', false)
@@ -81,9 +82,13 @@ program
81
82
  let { umlClasses, contractName } = await (0, parserGeneral_1.parserUmlClasses)(fileFolderAddress, combinedOptions);
82
83
  if (options.squash &&
83
84
  // Must specify base contract(s) or parse from Etherscan to get contractName
84
- !(options.baseContractNames || contractName)) {
85
+ !options.baseContractNames &&
86
+ !contractName) {
85
87
  throw Error('Must specify base contract(s) when using the squash option against local Solidity files.');
86
88
  }
89
+ if (options.squash && options.hideContracts) {
90
+ throw Error('Can not hide contracts when squashing contracts.');
91
+ }
87
92
  const baseContractNames = options.baseContractNames?.split(',');
88
93
  if (baseContractNames) {
89
94
  contractName = baseContractNames[0];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sol2uml",
3
- "version": "2.5.2",
3
+ "version": "2.5.4",
4
4
  "description": "Solidity contract visualisation tool.",
5
5
  "main": "./lib/index.js",
6
6
  "types": "./lib/index.d.ts",
@@ -36,7 +36,7 @@
36
36
  "klaw": "^4.1.0"
37
37
  },
38
38
  "devDependencies": {
39
- "@openzeppelin/contracts": "4.8.0",
39
+ "@openzeppelin/contracts": "^4.8.2",
40
40
  "@types/diff-match-patch": "^1.0.32",
41
41
  "@types/jest": "^29.4.0",
42
42
  "@types/klaw": "^3.0.3",