@lwrjs/shared-utils 0.9.0-alpha.1 → 0.9.0-alpha.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/build/cjs/fs.cjs CHANGED
@@ -44,10 +44,13 @@ var import_chokidar = __toModule(require("chokidar"));
44
44
  var import_diagnostics = __toModule(require("@lwrjs/diagnostics"));
45
45
  var import_mime_types = __toModule(require("mime-types"));
46
46
  var import_logger = __toModule(require("./logger.cjs"));
47
+ var fileCount = 0;
48
+ var files = new Map();
47
49
  function hashContent(source) {
48
50
  return import_crypto.default.createHash("md5").update(source).digest("hex");
49
51
  }
50
52
  function readFile(filePath) {
53
+ logMetrics(filePath);
51
54
  return import_fs.default.readFileSync(filePath, "utf8");
52
55
  }
53
56
  function resolveFileExtension(filePath) {
@@ -125,3 +128,15 @@ function normalizeResourcePath(rawPath, {rootDir, assets, contentDir, layoutsDir
125
128
  return alias;
126
129
  });
127
130
  }
131
+ function logMetrics(filePath) {
132
+ if (import_logger.logger.currentLevel == import_logger.DEBUG || import_logger.logger.currentLevel == import_logger.VERBOSE) {
133
+ let count = files.get(filePath) || 0;
134
+ if (++count % 100 === 0) {
135
+ import_logger.logger.debug(`[${count}] Repeat Read ${filePath}`);
136
+ }
137
+ files.set(filePath, count);
138
+ if (++fileCount % 1e3 === 0) {
139
+ import_logger.logger.debug(`Open file count [${fileCount}]`);
140
+ }
141
+ }
142
+ }
package/build/es/fs.js CHANGED
@@ -6,7 +6,9 @@ import { debounce } from './object.js';
6
6
  import chokidar from 'chokidar';
7
7
  import { LwrUnresolvableError, createSingleDiagnosticError, descriptions } from '@lwrjs/diagnostics';
8
8
  import { lookup } from 'mime-types';
9
- import { logger } from './logger.js';
9
+ import { DEBUG, logger, VERBOSE } from './logger.js';
10
+ let fileCount = 0;
11
+ const files = new Map();
10
12
  /**
11
13
  * Create a hash string for a source
12
14
  * @param source
@@ -19,6 +21,7 @@ export function hashContent(source) {
19
21
  * @param filePath
20
22
  */
21
23
  export function readFile(filePath) {
24
+ logMetrics(filePath);
22
25
  return fs.readFileSync(filePath, 'utf8');
23
26
  }
24
27
  /**
@@ -138,4 +141,16 @@ export function normalizeResourcePath(rawPath, { rootDir, assets, contentDir, la
138
141
  });
139
142
  }
140
143
  export { lookup as mimeLookup };
144
+ function logMetrics(filePath) {
145
+ if (logger.currentLevel == DEBUG || logger.currentLevel == VERBOSE) {
146
+ let count = files.get(filePath) || 0;
147
+ if (++count % 100 === 0) {
148
+ logger.debug(`[${count}] Repeat Read ${filePath}`);
149
+ }
150
+ files.set(filePath, count);
151
+ if (++fileCount % 1000 === 0) {
152
+ logger.debug(`Open file count [${fileCount}]`);
153
+ }
154
+ }
155
+ }
141
156
  //# sourceMappingURL=fs.js.map
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
7
- "version": "0.9.0-alpha.1",
7
+ "version": "0.9.0-alpha.3",
8
8
  "homepage": "https://developer.salesforce.com/docs/platform/lwr/overview",
9
9
  "repository": {
10
10
  "type": "git",
@@ -45,13 +45,13 @@
45
45
  "winston": "^3.7.2"
46
46
  },
47
47
  "devDependencies": {
48
- "@lwrjs/diagnostics": "0.9.0-alpha.1",
49
- "@lwrjs/types": "0.9.0-alpha.1",
48
+ "@lwrjs/diagnostics": "0.9.0-alpha.3",
49
+ "@lwrjs/types": "0.9.0-alpha.3",
50
50
  "@types/mime-types": "2.1.1",
51
51
  "@types/path-to-regexp": "^1.7.0"
52
52
  },
53
53
  "engines": {
54
54
  "node": ">=14.15.4 <19"
55
55
  },
56
- "gitHead": "7a32c273de67d937fcbcd42293d9e251ed01f123"
56
+ "gitHead": "3e96a852db94afbbfbc6558098303a85acd6604d"
57
57
  }