@diplodoc/cli 4.4.0 → 4.5.1-beta.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/src/constants.ts CHANGED
@@ -118,5 +118,6 @@ export const REGEXP_AUTHOR = /(?<=author:\s).+(?=\r?\n)/g;
118
118
 
119
119
  export const MIN_CHUNK_SIZE = Number(process.env.MIN_CHUNK_SIZE) || 1000;
120
120
  export const WORKERS_COUNT = Number(process.env.WORKERS_COUNT) || os.cpus().length - 1;
121
+ export const PAGE_PROCESS_CONCURRENCY = Number(process.env.PAGE_PROCESS_CONCURRENCY) || 500;
121
122
 
122
123
  export const metadataBorder = '---';
@@ -26,7 +26,13 @@ import {
26
26
  } from '../models';
27
27
  import {VCSConnector} from '../vcs-connector/connector-models';
28
28
  import {getVCSConnector} from '../vcs-connector';
29
- import {Lang, ResourceType, SINGLE_PAGE_DATA_FILENAME, SINGLE_PAGE_FILENAME} from '../constants';
29
+ import {
30
+ Lang,
31
+ PAGE_PROCESS_CONCURRENCY,
32
+ ResourceType,
33
+ SINGLE_PAGE_DATA_FILENAME,
34
+ SINGLE_PAGE_FILENAME,
35
+ } from '../constants';
30
36
 
31
37
  const singlePageResults: Record<string, SinglePageResult[]> = {};
32
38
  const singlePagePaths: Record<string, Set<string>> = {};
@@ -46,11 +52,10 @@ export async function processPages(outputBundlePath: string): Promise<void> {
46
52
  PluginService.setPlugins();
47
53
 
48
54
  const navigationPaths = TocService.getNavigationPaths();
49
- const concurrency = 500;
50
55
 
51
56
  await mapLimit(
52
57
  navigationPaths,
53
- concurrency,
58
+ PAGE_PROCESS_CONCURRENCY,
54
59
  asyncify(async (pathToFile: string) => {
55
60
  const pathData = getPathData(
56
61
  pathToFile,
@@ -32,6 +32,7 @@ const authorByGitEmail: Map<string, Contributor | null> = new Map();
32
32
  const authorByPath: Map<string, Contributor | null> = new Map();
33
33
  const contributorsByPath: Map<string, FileContributors> = new Map();
34
34
  const contributorsData: Map<string, Contributor | null> = new Map();
35
+ const loginUserMap: Map<string, Contributor | null> = new Map();
35
36
 
36
37
  async function getGitHubVCSConnector(): Promise<VCSConnector | undefined> {
37
38
  const {contributors} = ArgvService.getConfig();
@@ -277,21 +278,27 @@ async function getFileContributorsByPath(path: string): Promise<FileContributors
277
278
  }
278
279
 
279
280
  async function getUserByLogin(octokit: Octokit, userLogin: string): Promise<Contributor | null> {
280
- const user = await github.getRepoUser(octokit, userLogin);
281
+ let result = loginUserMap.get(userLogin);
282
+ if (!result) {
283
+ const user = await github.getRepoUser(octokit, userLogin);
284
+ if (!user) {
285
+ return null;
286
+ }
281
287
 
282
- if (!user) {
283
- return null;
284
- }
288
+ const {avatar_url: avatar, html_url: url, email, login, name} = user;
285
289
 
286
- const {avatar_url: avatar, html_url: url, email, login, name} = user;
290
+ result = {
291
+ avatar,
292
+ email,
293
+ login,
294
+ name,
295
+ url,
296
+ };
287
297
 
288
- return {
289
- avatar,
290
- email,
291
- login,
292
- name,
293
- url,
294
- };
298
+ loginUserMap.set(userLogin, result);
299
+ }
300
+
301
+ return result;
295
302
  }
296
303
 
297
304
  function addNestedContributorsForPathFunction(