@diplodoc/cli 4.1.0 → 4.2.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.
Files changed (53) hide show
  1. package/build/app.client.css +2678 -41
  2. package/build/app.client.js +1 -1
  3. package/build/index.js +376 -267
  4. package/build/index.js.map +3 -3
  5. package/build/linter.js +54 -46
  6. package/build/linter.js.map +2 -2
  7. package/package.json +12 -11
  8. package/src/cmd/build/index.ts +29 -15
  9. package/src/cmd/publish/index.ts +1 -6
  10. package/src/cmd/publish/upload.ts +22 -16
  11. package/src/cmd/translate/index.ts +51 -37
  12. package/src/cmd/xliff/compose.ts +16 -7
  13. package/src/cmd/xliff/extract.ts +18 -9
  14. package/src/cmd/xliff/index.ts +4 -1
  15. package/src/constants.ts +4 -4
  16. package/src/index.ts +2 -2
  17. package/src/models.ts +12 -7
  18. package/src/resolvers/lintPage.ts +1 -7
  19. package/src/resolvers/md2html.ts +23 -15
  20. package/src/resolvers/md2md.ts +13 -13
  21. package/src/services/authors.ts +4 -2
  22. package/src/services/contributors.ts +26 -12
  23. package/src/services/includers/batteries/common.ts +14 -2
  24. package/src/services/includers/batteries/generic.ts +27 -9
  25. package/src/services/includers/batteries/sourcedocs.ts +4 -1
  26. package/src/services/includers/batteries/unarchive.ts +8 -4
  27. package/src/services/includers/index.ts +6 -4
  28. package/src/services/leading.ts +23 -26
  29. package/src/services/metadata.ts +35 -10
  30. package/src/services/preset.ts +2 -2
  31. package/src/services/tocs.ts +26 -21
  32. package/src/services/utils.ts +13 -3
  33. package/src/steps/processAssets.ts +2 -8
  34. package/src/steps/processExcludedFiles.ts +11 -20
  35. package/src/steps/processLinter.ts +8 -7
  36. package/src/steps/processLogs.ts +1 -6
  37. package/src/steps/processMapFile.ts +8 -11
  38. package/src/steps/processPages.ts +96 -66
  39. package/src/steps/processServiceFiles.ts +3 -1
  40. package/src/steps/publishFilesToS3.ts +16 -12
  41. package/src/utils/file.ts +5 -1
  42. package/src/utils/glob.ts +1 -3
  43. package/src/utils/markup.ts +28 -13
  44. package/src/utils/singlePage.ts +10 -9
  45. package/src/utils/toc.ts +20 -7
  46. package/src/utils/worker.ts +1 -1
  47. package/src/validator.ts +24 -16
  48. package/src/vcs-connector/client/github.ts +15 -7
  49. package/src/vcs-connector/connector-validator.ts +12 -6
  50. package/src/vcs-connector/github.ts +38 -11
  51. package/src/vcs-connector/index.ts +1 -1
  52. package/src/workers/linter/index.ts +1 -5
  53. package/CHANGELOG.md +0 -793
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "author": "Yandex Data UI Team <data-ui@yandex-team.ru>",
4
4
  "description": "Make documentation using yfm-docs in Markdown and HTML formats",
5
5
  "license": "MIT",
6
- "version": "4.1.0",
6
+ "version": "4.2.0",
7
7
  "repository": {
8
8
  "type": "git",
9
9
  "url": "git@github.com:diplodoc-platform/cli.git"
@@ -21,20 +21,21 @@
21
21
  "start": "node build/index.js",
22
22
  "lint": "eslint \"src/**/*.{js,jsx,ts,tsx}\"",
23
23
  "lint:fix": "npm run lint -- --fix",
24
- "prepublishOnly": "npm run lint && npm run build"
24
+ "prepublishOnly": "npm run lint && npm run build",
25
+ "git:head": "git checkout master && git pull"
25
26
  },
26
27
  "engines": {
27
- "node": "14.*"
28
+ "node": "18.*",
29
+ "npm:": "10.*"
28
30
  },
29
31
  "dependencies": {
30
32
  "@apidevtools/swagger-parser": "^10.1.0",
31
33
  "@aws-sdk/client-s3": "^3.369.0",
32
- "@diplodoc/client": "^0.0.14",
33
- "@diplodoc/markdown-translation": "^1.0.0-beta.1",
34
+ "@diplodoc/client": "^1.0.2",
35
+ "@diplodoc/markdown-translation": "^1.0.0-beta.3",
34
36
  "@diplodoc/mermaid-extension": "^1.1.1",
35
37
  "@diplodoc/openapi-extension": "^1.3.3",
36
38
  "@diplodoc/transform": "^4.0.0",
37
- "@doc-tools/yfm2xliff": "0.0.5",
38
39
  "@octokit/core": "4.2.4",
39
40
  "@types/glob": "^8.0.0",
40
41
  "@types/json-stringify-safe": "^5.0.0",
@@ -65,6 +66,9 @@
65
66
  "yargs": "17.7.2"
66
67
  },
67
68
  "devDependencies": {
69
+ "@diplodoc/eslint-config": "^1.0.14",
70
+ "@diplodoc/prettier-config": "^1.0.0",
71
+ "@diplodoc/tsconfig": "^1.0.2",
68
72
  "@types/async": "^3.2.15",
69
73
  "@types/chalk": "2.2.0",
70
74
  "@types/html-escaper": "^3.0.0",
@@ -75,15 +79,12 @@
75
79
  "@types/shelljs": "0.8.12",
76
80
  "@types/tar-stream": "^2.2.2",
77
81
  "@types/yargs": "17.0.24",
78
- "@typescript-eslint/eslint-plugin": "2.34.0",
79
- "@typescript-eslint/parser": "2.34.0",
80
- "babel-eslint": "10.1.0",
81
82
  "esbuild": "^0.17.17",
82
- "eslint": "6.8.0",
83
- "eslint-plugin-security": "1.7.1",
83
+ "eslint": "^8.0.0",
84
84
  "husky": "8.0.3",
85
85
  "lint-staged": "13.2.2",
86
86
  "lodash": "4.17.21",
87
+ "prettier": "^3.0.3",
87
88
  "ts-jest": "29.1.0",
88
89
  "ts-node": "^10.9.1",
89
90
  "typescript": "4.9.5"
@@ -1,6 +1,7 @@
1
1
  import {Arguments, Argv} from 'yargs';
2
2
  import {
3
- BUNDLE_FOLDER, LINT_CONFIG_FILENAME,
3
+ BUNDLE_FOLDER,
4
+ LINT_CONFIG_FILENAME,
4
5
  REDIRECTS_FILENAME,
5
6
  Stage,
6
7
  TMP_INPUT_FOLDER,
@@ -15,7 +16,8 @@ import {
15
16
  initLinterWorkers,
16
17
  processAssets,
17
18
  processExcludedFiles,
18
- processLinter, processLogs,
19
+ processLinter,
20
+ processLogs,
19
21
  processPages,
20
22
  processServiceFiles,
21
23
  } from '../../steps';
@@ -166,7 +168,10 @@ function builder<T>(argv: Argv<T>) {
166
168
  })
167
169
  .check(argvValidator)
168
170
  .example('yfm -i ./input -o ./output', '')
169
- .demandOption(['input', 'output'], 'Please provide input and output arguments to work with this tool');
171
+ .demandOption(
172
+ ['input', 'output'],
173
+ 'Please provide input and output arguments to work with this tool',
174
+ );
170
175
  }
171
176
 
172
177
  async function handler(args: Arguments<any>) {
@@ -235,8 +240,12 @@ async function handler(args: Arguments<any>) {
235
240
  const resourcePaths: string[] = [];
236
241
 
237
242
  // collect paths of all resources
238
- Object.keys(resources).forEach((type) =>
239
- resources[type as keyof Resources]?.forEach((path: string) => resourcePaths.push(path)));
243
+ Object.keys(resources).forEach(
244
+ (type) =>
245
+ resources[type as keyof Resources]?.forEach((path: string) =>
246
+ resourcePaths.push(path),
247
+ ),
248
+ );
240
249
 
241
250
  //copy resources
242
251
  copyFiles(args.input, tmpOutputFolder, resourcePaths);
@@ -247,7 +256,11 @@ async function handler(args: Arguments<any>) {
247
256
  }
248
257
 
249
258
  // Copy all generated files to user' output folder
250
- shell.cp('-r', [join(tmpOutputFolder, '*'), join(tmpOutputFolder, '.*')], userOutputFolder);
259
+ shell.cp(
260
+ '-r',
261
+ [join(tmpOutputFolder, '*'), join(tmpOutputFolder, '.*')],
262
+ userOutputFolder,
263
+ );
251
264
 
252
265
  if (publish) {
253
266
  const DEFAULT_PREFIX = process.env.YFM_STORAGE_PREFIX ?? '';
@@ -292,13 +305,14 @@ function preparingTemporaryFolders(userOutputFolder: string) {
292
305
  shell.mkdir(args.input, args.output);
293
306
  shell.chmod('-R', 'u+w', args.input);
294
307
 
295
- copyFiles(args.rootInput, args.input, glob.sync('**', {
296
- cwd: args.rootInput,
297
- nodir: true,
298
- follow: true,
299
- ignore: [
300
- 'node_modules/**',
301
- '*/node_modules/**',
302
- ],
303
- }));
308
+ copyFiles(
309
+ args.rootInput,
310
+ args.input,
311
+ glob.sync('**', {
312
+ cwd: args.rootInput,
313
+ nodir: true,
314
+ follow: true,
315
+ ignore: ['node_modules/**', '*/node_modules/**'],
316
+ }),
317
+ );
304
318
  }
@@ -73,12 +73,7 @@ async function handler(args: Arguments<any>) {
73
73
  ...args,
74
74
  });
75
75
 
76
- const {
77
- input,
78
- endpoint,
79
- bucket,
80
- prefix,
81
- } = ArgvService.getConfig();
76
+ const {input, endpoint, bucket, prefix} = ArgvService.getConfig();
82
77
 
83
78
  logger.info('', `Upload artifacts from ${input} to ${join(endpoint, bucket, prefix)}`);
84
79
 
@@ -42,20 +42,26 @@ export async function upload(props: UploadProps): Promise<void> {
42
42
  ignore,
43
43
  });
44
44
 
45
- await mapLimit(filesToPublish, 100, asyncify(async (pathToFile: string) => {
46
- const mimeType = mime.lookup(pathToFile);
47
-
48
- logger.upload(pathToFile);
49
-
50
- try {
51
- await s3Client.send(new PutObjectCommand({
52
- ContentType: mimeType ? mimeType : undefined,
53
- Bucket: bucket,
54
- Key: convertBackSlashToSlash(join(prefix, pathToFile)),
55
- Body: createReadStream(resolve(input, pathToFile)),
56
- }));
57
- } catch (error) {
58
- logger.error(pathToFile, error.message);
59
- }
60
- }));
45
+ await mapLimit(
46
+ filesToPublish,
47
+ 100,
48
+ asyncify(async (pathToFile: string) => {
49
+ const mimeType = mime.lookup(pathToFile);
50
+
51
+ logger.upload(pathToFile);
52
+
53
+ try {
54
+ await s3Client.send(
55
+ new PutObjectCommand({
56
+ ContentType: mimeType ? mimeType : undefined,
57
+ Bucket: bucket,
58
+ Key: convertBackSlashToSlash(join(prefix, pathToFile)),
59
+ Body: createReadStream(resolve(input, pathToFile)),
60
+ }),
61
+ );
62
+ } catch (error) {
63
+ logger.error(pathToFile, error.message);
64
+ }
65
+ }),
66
+ );
61
67
  }
@@ -1,8 +1,4 @@
1
- import {
2
- eachLimit,
3
- retry,
4
- asyncify,
5
- } from 'async';
1
+ import {eachLimit, retry, asyncify} from 'async';
6
2
 
7
3
  import {dirname, resolve, join} from 'path';
8
4
  import {readFile, writeFile, mkdir} from 'fs/promises';
@@ -15,7 +11,7 @@ import {
15
11
  TranslateRequest_Format as Format,
16
12
  } from '@yandex-cloud/nodejs-sdk/dist/generated/yandex/cloud/ai/translate/v2/translation_service';
17
13
 
18
- const yfm2xliff = require('@doc-tools/yfm2xliff/lib/cjs');
14
+ import markdownTranslation from '@diplodoc/markdown-translation';
19
15
 
20
16
  import {ArgvService} from '../../services';
21
17
  import {getYandexOAuthToken} from '../../packages/credentials';
@@ -25,15 +21,6 @@ import {Argv, Arguments} from 'yargs';
25
21
 
26
22
  import {YandexCloudTranslateGlossaryPair} from '../../models';
27
23
 
28
- const composer = async (xliff: string, skeleton: string): Promise<string> => new Promise((res, rej) =>
29
- yfm2xliff.compose(xliff, skeleton, (err: Error, composed: string) => {
30
- if (err) {
31
- rej(err);
32
- }
33
-
34
- return res(composed);
35
- }));
36
-
37
24
  const command = 'translate';
38
25
 
39
26
  const description = 'translate documentation with Yandex.Cloud Translator API';
@@ -64,7 +51,8 @@ function builder<T>(argv: Argv<T>) {
64
51
  })
65
52
  .demandOption(
66
53
  ['source-language', 'target-language'],
67
- 'command requires to specify source and target languages');
54
+ 'command requires to specify source and target languages',
55
+ );
68
56
  }
69
57
 
70
58
  class TranslatorError extends Error {
@@ -83,7 +71,8 @@ async function handler(args: Arguments<any>) {
83
71
  ...args,
84
72
  });
85
73
 
86
- const {input,
74
+ const {
75
+ input,
87
76
  output,
88
77
  yandexCloudTranslateFolderId,
89
78
  yandexCloudTranslateGlossaryPairs,
@@ -91,12 +80,17 @@ async function handler(args: Arguments<any>) {
91
80
  tl: targetLanguage,
92
81
  } = args;
93
82
 
94
- logger.info(input, `translating documentation from ${sourceLanguage} to ${targetLanguage} language`);
83
+ logger.info(
84
+ input,
85
+ `translating documentation from ${sourceLanguage} to ${targetLanguage} language`,
86
+ );
95
87
 
96
88
  try {
97
89
  let found = [];
98
90
 
99
- ({state: {found}} = await glob(join(input, MD_GLOB), {
91
+ ({
92
+ state: {found},
93
+ } = await glob(join(input, MD_GLOB), {
100
94
  nosort: true,
101
95
  }));
102
96
 
@@ -125,7 +119,10 @@ async function handler(args: Arguments<any>) {
125
119
  }
126
120
  }
127
121
 
128
- logger.info(output, `translated documentation from ${sourceLanguage} to ${targetLanguage} language`);
122
+ logger.info(
123
+ output,
124
+ `translated documentation from ${sourceLanguage} to ${targetLanguage} language`,
125
+ );
129
126
  }
130
127
 
131
128
  export type TranslatorParams = {
@@ -158,16 +155,21 @@ function translator(params: TranslatorParams) {
158
155
 
159
156
  const md = await readFile(resolve(mdPath), {encoding: 'utf-8'});
160
157
 
161
- const extracted = await yfm2xliff.extract({
162
- md,
163
- mdPath,
164
- source: sourceLanguage,
165
- target: targetLanguage,
166
- sklPath: '',
167
- xlfPath: '',
158
+ const {xlf, skeleton} = markdownTranslation.extract({
159
+ source: {
160
+ language: sourceLanguage,
161
+ locale: sourceLanguage.toUpperCase(),
162
+ },
163
+ target: {
164
+ language: targetLanguage,
165
+ locale: targetLanguage.toUpperCase(),
166
+ },
167
+ markdown: md,
168
+ markdownPath: mdPath,
169
+ skeletonPath: '',
168
170
  });
169
171
 
170
- const texts = parseSourcesFromXLIFF(extracted.xliff);
172
+ const texts = parseSourcesFromXLIFF(xlf);
171
173
 
172
174
  const machineTranslateParams = TranslateRequest.fromPartial({
173
175
  texts,
@@ -182,14 +184,23 @@ function translator(params: TranslatorParams) {
182
184
  format: Format.PLAIN_TEXT,
183
185
  });
184
186
 
185
- const translations = await retry({times: RETRY_LIMIT, interval: (count: number) => {
186
- // eslint-disable-next-line no-bitwise
187
- return (1 << count) * 1000;
188
- }}, asyncify(async () =>
189
- await client.translate(machineTranslateParams)
190
- .then((results: {translations: {text: string}[]}) =>
191
- results.translations.map(({text}: {text: string}) => text)),
192
- ));
187
+ const translations = await retry(
188
+ {
189
+ times: RETRY_LIMIT,
190
+ interval: (count: number) => {
191
+ // eslint-disable-next-line no-bitwise
192
+ return (1 << count) * 1000;
193
+ },
194
+ },
195
+ asyncify(
196
+ async () =>
197
+ await client
198
+ .translate(machineTranslateParams)
199
+ .then((results: {translations: {text: string}[]}) =>
200
+ results.translations.map(({text}: {text: string}) => text),
201
+ ),
202
+ ),
203
+ );
193
204
 
194
205
  const createXLIFFDocumentParams = {
195
206
  sourceLanguage: sourceLanguage + '-' + MTRANS_LOCALE,
@@ -200,7 +211,10 @@ function translator(params: TranslatorParams) {
200
211
 
201
212
  const translatedXLIFF = createXLIFFDocument(createXLIFFDocumentParams);
202
213
 
203
- const composed = await composer(translatedXLIFF, extracted.skeleton);
214
+ const composed = await markdownTranslation.compose({
215
+ xlf: translatedXLIFF,
216
+ skeleton,
217
+ });
204
218
 
205
219
  const outputPath = mdPath.replace(input, output);
206
220
 
@@ -1,4 +1,6 @@
1
- const {promises: {readFile, writeFile, mkdir}} = require('fs');
1
+ const {
2
+ promises: {readFile, writeFile, mkdir},
3
+ } = require('fs');
2
4
  import {join, extname, dirname} from 'path';
3
5
 
4
6
  import markdownTranslation, {ComposeParameters} from '@diplodoc/markdown-translation';
@@ -28,7 +30,8 @@ class ComposeError extends Error {
28
30
  }
29
31
  }
30
32
 
31
- const USAGE = 'yfm xliff compose \
33
+ const USAGE =
34
+ 'yfm xliff compose \
32
35
  --input <folder-with-xliff-and-skeleton> \
33
36
  --ouput <folder-to-store-translated-markdown>';
34
37
 
@@ -38,11 +41,13 @@ function builder<T>(argv: Argv<T>) {
38
41
  alias: 'i',
39
42
  describe: 'input folder with xliff and skeleton files',
40
43
  type: 'string',
41
- }).option('output', {
44
+ })
45
+ .option('output', {
42
46
  alias: 'o',
43
47
  describe: 'output folder where translated markdown will be stored',
44
48
  type: 'string',
45
- }).demandOption(['input', 'output'], USAGE);
49
+ })
50
+ .demandOption(['input', 'output'], USAGE);
46
51
  }
47
52
 
48
53
  /* eslint-disable-next-line @typescript-eslint/no-explicit-any */
@@ -58,18 +63,22 @@ async function handler(args: Arguments<any>) {
58
63
  let xliffPaths: string[] = [];
59
64
 
60
65
  try {
61
- ({state: {found: skeletonPaths, cache}} = await glob(join(input, SKL_MD_GLOB), {
66
+ ({
67
+ state: {found: skeletonPaths, cache},
68
+ } = await glob(join(input, SKL_MD_GLOB), {
62
69
  nosort: false,
63
70
  cache,
64
71
  }));
65
72
 
66
- ({state: {found: xliffPaths, cache}} = await glob(join(input, XLF_GLOB), {
73
+ ({
74
+ state: {found: xliffPaths, cache},
75
+ } = await glob(join(input, XLF_GLOB), {
67
76
  nosort: false,
68
77
  cache,
69
78
  }));
70
79
 
71
80
  if (xliffPaths.length !== skeletonPaths.length) {
72
- throw new ComposeError('number of xliff and skeleton files does\'not match', input);
81
+ throw new ComposeError("number of xliff and skeleton files does'not match", input);
73
82
  }
74
83
  } catch (err) {
75
84
  if (err instanceof Error || err instanceof ComposeError) {
@@ -1,4 +1,6 @@
1
- const {promises: {readFile, writeFile, mkdir}} = require('fs');
1
+ const {
2
+ promises: {readFile, writeFile, mkdir},
3
+ } = require('fs');
2
4
  import {join, dirname, extname} from 'path';
3
5
 
4
6
  import markdownTranslation, {ExtractParameters} from '@diplodoc/markdown-translation';
@@ -44,19 +46,26 @@ function builder<T>(argv: Argv<T>) {
44
46
  alias: 'sll',
45
47
  describe: 'source language and locale',
46
48
  type: 'string',
47
- }).option('target-language-locale', {
49
+ })
50
+ .option('target-language-locale', {
48
51
  alias: 'tll',
49
52
  describe: 'target language and locale',
50
53
  type: 'string',
51
- }).option('input', {
54
+ })
55
+ .option('input', {
52
56
  alias: 'i',
53
57
  describe: 'input folder with markdown files',
54
58
  type: 'string',
55
- }).option('output', {
59
+ })
60
+ .option('output', {
56
61
  alias: 'o',
57
62
  describe: 'output folder to store xliff and skeleton files',
58
63
  type: 'string',
59
- }).demandOption(['source-language-locale', 'target-language-locale', 'input', 'output'], USAGE);
64
+ })
65
+ .demandOption(
66
+ ['source-language-locale', 'target-language-locale', 'input', 'output'],
67
+ USAGE,
68
+ );
60
69
  }
61
70
 
62
71
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -83,7 +92,9 @@ async function handler(args: Arguments<any>) {
83
92
  let found: string[] = [];
84
93
 
85
94
  try {
86
- ({state: {found, cache}} = await glob(join(input, MD_GLOB), {
95
+ ({
96
+ state: {found, cache},
97
+ } = await glob(join(input, MD_GLOB), {
87
98
  nosort: true,
88
99
  cache,
89
100
  }));
@@ -134,9 +145,7 @@ function pipeline(params: PipelineParameters) {
134
145
  const markdown = await reader({path: markdownPath});
135
146
  const extension = extname(markdownPath);
136
147
 
137
- const outputRelativePath = markdownPath
138
- .replace(extension, '')
139
- .slice(input.length);
148
+ const outputRelativePath = markdownPath.replace(extension, '').slice(input.length);
140
149
 
141
150
  const outputPath = join(output, outputRelativePath);
142
151
  const xlfPath = outputPath + '.xliff';
@@ -19,7 +19,10 @@ function builder<T>(argv: Argv<T>) {
19
19
  return argv
20
20
  .command(extract)
21
21
  .command(compose)
22
- .demandCommand(1, `provide one of the folowing ${command} commands: ${extract.command}, ${compose.command}`);
22
+ .demandCommand(
23
+ 1,
24
+ `provide one of the folowing ${command} commands: ${extract.command}, ${compose.command}`,
25
+ );
23
26
  }
24
27
 
25
28
  export {xliff};
package/src/constants.ts CHANGED
@@ -59,7 +59,7 @@ export enum Platforms {
59
59
  export enum IncludeMode {
60
60
  ROOT_MERGE = 'root_merge',
61
61
  MERGE = 'merge',
62
- LINK = 'link'
62
+ LINK = 'link',
63
63
  }
64
64
 
65
65
  export enum ResourceType {
@@ -95,8 +95,8 @@ export const PROCESSING_FINISHED = 'Processing finished:';
95
95
  export const LINTING_FINISHED = 'Linting finished:';
96
96
  export const GETTING_ALL_CONTRIBUTORS = 'Getting all contributors.';
97
97
  export const ALL_CONTRIBUTORS_RECEIVED = 'All contributors received.';
98
- export const getMsgСonfigurationMustBeProvided =
99
- (repo: string) => `Сonfiguration must be provided for ${repo} like env variables or in .yfm file`;
98
+ export const getMsgСonfigurationMustBeProvided = (repo: string) =>
99
+ `Сonfiguration must be provided for ${repo} like env variables or in .yfm file`;
100
100
 
101
101
  export const FIRST_COMMIT_FROM_ROBOT_IN_GITHUB = '2dce14271359cd20d7e874956d604de087560cf4';
102
102
 
@@ -117,6 +117,6 @@ export const REGEXP_INCLUDE_FILE_PATH = /(?<=[(]).+(?=[)])/g;
117
117
  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
- export const WORKERS_COUNT = Number(process.env.WORKERS_COUNT) || (os.cpus().length - 1);
120
+ export const WORKERS_COUNT = Number(process.env.WORKERS_COUNT) || os.cpus().length - 1;
121
121
 
122
122
  export const metadataBorder = '---';
package/src/index.ts CHANGED
@@ -28,7 +28,7 @@ yargs
28
28
  .option('quiet', {
29
29
  alias: 'q',
30
30
  default: false,
31
- describe: 'Run in quiet mode. Don\'t write logs to stdout',
31
+ describe: "Run in quiet mode. Don't write logs to stdout",
32
32
  type: 'boolean',
33
33
  })
34
34
  .group(['config', 'strict', 'quiet', 'help', 'version'], 'Common options:')
@@ -44,7 +44,7 @@ yargs
44
44
 
45
45
  const {warn, error} = log.get();
46
46
 
47
- if (strict && warn.length || error.length) {
47
+ if ((strict && warn.length) || error.length) {
48
48
  process.exit(1);
49
49
  }
50
50
 
package/src/models.ts CHANGED
@@ -5,7 +5,7 @@ import {FileContributors, VCSConnector, VCSConnectorConfig} from './vcs-connecto
5
5
  import {Lang, Stage, IncludeMode, ResourceType} from './constants';
6
6
  import {ChangelogItem} from '@diplodoc/transform/lib/plugins/changelog/types';
7
7
 
8
- export type VarsPreset = 'internal'|'external';
8
+ export type VarsPreset = 'internal' | 'external';
9
9
 
10
10
  export type YfmPreset = Record<string, string>;
11
11
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -13,7 +13,10 @@ export type Metadata = Record<string, any>;
13
13
 
14
14
  export type ExternalAuthorByPathFunction = (path: string) => Contributor | null;
15
15
  export type ContributorsByPathFunction = (path: string) => Promise<FileContributors>;
16
- export type NestedContributorsForPathFunction = (path: string, nestedContributors: Contributors) => void;
16
+ export type NestedContributorsForPathFunction = (
17
+ path: string,
18
+ nestedContributors: Contributors,
19
+ ) => void;
17
20
  export type UserByLoginFunction = (login: string) => Promise<Contributor | null>;
18
21
  export type CollectionOfPluginsFunction = (output: string, options: PluginOptions) => string;
19
22
 
@@ -96,7 +99,7 @@ export type YfmTocIncluder = {
96
99
 
97
100
  export const includersNames = ['sourcedocs', 'openapi', 'generic', 'unarchive'] as const;
98
101
 
99
- export type YfmTocIncluderName = typeof includersNames[number];
102
+ export type YfmTocIncluderName = (typeof includersNames)[number];
100
103
 
101
104
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
102
105
  export type Includer<FnParams = any> = {
@@ -104,7 +107,9 @@ export type Includer<FnParams = any> = {
104
107
  includerFunction: IncluderFunction<FnParams>;
105
108
  };
106
109
 
107
- export type IncluderFunction<PassedParams> = (args: IncluderFunctionParams<PassedParams>) => Promise<void>;
110
+ export type IncluderFunction<PassedParams> = (
111
+ args: IncluderFunctionParams<PassedParams>,
112
+ ) => Promise<void>;
108
113
 
109
114
  export type IncluderFunctionParams<PassedParams> = {
110
115
  // item that contains include that uses includer
@@ -148,7 +153,7 @@ export interface LeadingPageLinks extends Filter {
148
153
  }
149
154
 
150
155
  export interface Filter {
151
- when?: boolean|string;
156
+ when?: boolean | string;
152
157
  [key: string]: unknown;
153
158
  }
154
159
 
@@ -239,8 +244,8 @@ export type Resources = {
239
244
  };
240
245
 
241
246
  export type YandexCloudTranslateGlossaryPair = {
242
- sourceText: string;
243
- translatedText: string;
247
+ sourceText: string;
248
+ translatedText: string;
244
249
  };
245
250
 
246
251
  export type CommitInfo = {
@@ -54,13 +54,7 @@ export function lintPage(options: ResolverLintOptions) {
54
54
  }
55
55
 
56
56
  function MdFileLinter(content: string, lintOptions: FileTransformOptions): void {
57
- const {
58
- input,
59
- lintConfig,
60
- disableLiquid,
61
- outputFormat,
62
- ...options
63
- } = ArgvService.getConfig();
57
+ const {input, lintConfig, disableLiquid, outputFormat, ...options} = ArgvService.getConfig();
64
58
  const {path: filePath} = lintOptions;
65
59
 
66
60
  const plugins = outputFormat === 'md' ? [] : PluginService.getPlugins();