@diplodoc/cli 4.0.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 (57) hide show
  1. package/build/app.client.css +2678 -41
  2. package/build/app.client.js +1 -1
  3. package/build/index.js +418 -309
  4. package/build/index.js.map +3 -3
  5. package/build/linter.js +89 -81
  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 +24 -24
  16. package/src/index.ts +3 -3
  17. package/src/models.ts +15 -10
  18. package/src/resolvers/lintPage.ts +3 -9
  19. package/src/resolvers/md2html.ts +27 -19
  20. package/src/resolvers/md2md.ts +16 -16
  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 +24 -27
  29. package/src/services/metadata.ts +35 -10
  30. package/src/services/plugins.ts +1 -1
  31. package/src/services/preset.ts +2 -2
  32. package/src/services/tocs.ts +28 -23
  33. package/src/services/utils.ts +15 -5
  34. package/src/steps/processAssets.ts +2 -8
  35. package/src/steps/processExcludedFiles.ts +11 -20
  36. package/src/steps/processLinter.ts +9 -8
  37. package/src/steps/processLogs.ts +2 -7
  38. package/src/steps/processMapFile.ts +8 -11
  39. package/src/steps/processPages.ts +97 -67
  40. package/src/steps/processServiceFiles.ts +4 -2
  41. package/src/steps/publishFilesToS3.ts +16 -12
  42. package/src/utils/file.ts +5 -1
  43. package/src/utils/glob.ts +1 -3
  44. package/src/utils/logger.ts +1 -1
  45. package/src/utils/markup.ts +28 -13
  46. package/src/utils/singlePage.ts +11 -10
  47. package/src/utils/toc.ts +20 -7
  48. package/src/utils/worker.ts +1 -1
  49. package/src/validator.ts +25 -17
  50. package/src/vcs-connector/client/github.ts +16 -8
  51. package/src/vcs-connector/connector-validator.ts +13 -7
  52. package/src/vcs-connector/github.ts +38 -11
  53. package/src/vcs-connector/index.ts +1 -1
  54. package/src/workers/linter/index.ts +2 -6
  55. package/CHANGELOG.md +0 -785
  56. package/build/lib.js +0 -3374
  57. package/build/lib.js.map +0 -7
@@ -3,8 +3,8 @@ import {copyFileSync, readFileSync, writeFileSync, existsSync} from 'fs';
3
3
  import {load, dump} from 'js-yaml';
4
4
  import shell from 'shelljs';
5
5
  import walkSync from 'walk-sync';
6
- import liquid from '@doc-tools/transform/lib/liquid';
7
- import log from '@doc-tools/transform/lib/log';
6
+ import liquid from '@diplodoc/transform/lib/liquid';
7
+ import log from '@diplodoc/transform/lib/log';
8
8
  import {bold} from 'chalk';
9
9
 
10
10
  import {ArgvService, PresetService} from './index';
@@ -49,11 +49,9 @@ async function add(path: string) {
49
49
  };
50
50
 
51
51
  if (parsedToc.title) {
52
- parsedToc.title = firstFilterTextItems(
53
- parsedToc.title,
54
- combinedVars,
55
- {resolveConditions: true},
56
- );
52
+ parsedToc.title = firstFilterTextItems(parsedToc.title, combinedVars, {
53
+ resolveConditions: true,
54
+ });
57
55
  }
58
56
 
59
57
  if (typeof parsedToc.title === 'string') {
@@ -92,10 +90,7 @@ async function processTocItems(
92
90
  sourcesDir: string,
93
91
  vars: Record<string, string>,
94
92
  ) {
95
- const {
96
- resolveConditions,
97
- removeHiddenTocItems,
98
- } = ArgvService.getConfig();
93
+ const {resolveConditions, removeHiddenTocItems} = ArgvService.getConfig();
99
94
 
100
95
  let preparedItems = items;
101
96
 
@@ -115,7 +110,7 @@ async function processTocItems(
115
110
  return _replaceIncludes(path, preparedItems, tocDir, sourcesDir, vars);
116
111
  }
117
112
 
118
- function getForPath(path: string): YfmToc|undefined {
113
+ function getForPath(path: string): YfmToc | undefined {
119
114
  return storage.get(path);
120
115
  }
121
116
 
@@ -131,11 +126,11 @@ function prepareNavigationPaths(parsedToc: YfmToc, dirPath: string) {
131
126
  function processItems(items: YfmToc[], pathToDir: string) {
132
127
  items.forEach((item) => {
133
128
  if (!parsedToc.singlePage && item.items) {
134
- const preparedSubItems = item.items.map(((yfmToc: YfmToc, index: number) => {
129
+ const preparedSubItems = item.items.map((yfmToc: YfmToc, index: number) => {
135
130
  // Generate personal id for each navigation item
136
131
  yfmToc.id = `${yfmToc.name}-${index}-${Math.random()}`;
137
132
  return yfmToc;
138
- }));
133
+ });
139
134
  processItems(preparedSubItems, pathToDir);
140
135
  }
141
136
 
@@ -308,9 +303,10 @@ async function _replaceIncludes(
308
303
 
309
304
  if (item.include) {
310
305
  const {mode = IncludeMode.ROOT_MERGE} = item.include;
311
- const includeTocPath = mode === IncludeMode.ROOT_MERGE
312
- ? resolve(sourcesDir, item.include.path)
313
- : resolve(tocDir, item.include.path);
306
+ const includeTocPath =
307
+ mode === IncludeMode.ROOT_MERGE
308
+ ? resolve(sourcesDir, item.include.path)
309
+ : resolve(tocDir, item.include.path);
314
310
  const includeTocDir = dirname(includeTocPath);
315
311
 
316
312
  try {
@@ -332,11 +328,21 @@ async function _replaceIncludes(
332
328
 
333
329
  /* Resolve nested toc inclusions */
334
330
  const baseTocDir = mode === IncludeMode.LINK ? includeTocDir : tocDir;
335
- includedTocItems = await processTocItems(path, includedTocItems, baseTocDir, sourcesDir, vars);
331
+ includedTocItems = await processTocItems(
332
+ path,
333
+ includedTocItems,
334
+ baseTocDir,
335
+ sourcesDir,
336
+ vars,
337
+ );
336
338
 
337
339
  /* Make hrefs relative to the main toc */
338
340
  if (mode === IncludeMode.LINK) {
339
- includedTocItems = _replaceIncludesHrefs(includedTocItems, includeTocDir, tocDir);
341
+ includedTocItems = _replaceIncludesHrefs(
342
+ includedTocItems,
343
+ includeTocDir,
344
+ tocDir,
345
+ );
340
346
  }
341
347
 
342
348
  if (item.name) {
@@ -345,9 +351,9 @@ async function _replaceIncludes(
345
351
  includedInlineItems = includedTocItems;
346
352
  }
347
353
  } catch (err) {
348
- const message = (
349
- `Error while including toc: ${bold(includeTocPath)} to ${bold(join(tocDir, 'toc.yaml'))}`
350
- );
354
+ const message = `Error while including toc: ${bold(includeTocPath)} to ${bold(
355
+ join(tocDir, 'toc.yaml'),
356
+ )}`;
351
357
 
352
358
  log.error(message);
353
359
 
@@ -375,7 +381,6 @@ function getTocDir(pagePath: string): string {
375
381
  const tocDir = dirname(pagePath);
376
382
  const tocPath = resolve(tocDir, 'toc.yaml');
377
383
 
378
-
379
384
  if (!tocDir.includes(inputFolderPath)) {
380
385
  throw new Error('Error while finding toc dir');
381
386
  }
@@ -1,6 +1,6 @@
1
- import evalExp from '@doc-tools/transform/lib/liquid/evaluation';
1
+ import evalExp from '@diplodoc/transform/lib/liquid/evaluation';
2
2
  import {Filter, TextItems} from '../models';
3
- import liquid from '@doc-tools/transform/lib/liquid';
3
+ import liquid from '@diplodoc/transform/lib/liquid';
4
4
  import {ArgvService} from './index';
5
5
 
6
6
  export interface FilterFilesOptions {
@@ -93,14 +93,20 @@ export function firstFilterTextItems(
93
93
  return filteredItems[0] || '';
94
94
  }
95
95
 
96
- function shouldProcessItem<T extends Filter>(item: T, vars: Record<string, string>, options?: FilterFilesOptions) {
96
+ function shouldProcessItem<T extends Filter>(
97
+ item: T,
98
+ vars: Record<string, string>,
99
+ options?: FilterFilesOptions,
100
+ ) {
97
101
  const {resolveConditions, removeHiddenTocItems} = options || {};
98
102
  let useItem = true;
99
103
 
100
104
  if (resolveConditions) {
101
105
  const {when} = item;
102
106
  useItem =
103
- when === true || when === undefined || (typeof when === 'string' && evalExp(when, vars));
107
+ when === true ||
108
+ when === undefined ||
109
+ (typeof when === 'string' && evalExp(when, vars));
104
110
 
105
111
  delete item.when;
106
112
  }
@@ -114,7 +120,11 @@ function shouldProcessItem<T extends Filter>(item: T, vars: Record<string, strin
114
120
  return useItem;
115
121
  }
116
122
 
117
- export function liquidFields(fields: undefined | string | string[], vars: Record<string, unknown>, path: string) {
123
+ export function liquidFields(
124
+ fields: undefined | string | string[],
125
+ vars: Record<string, unknown>,
126
+ path: string,
127
+ ) {
118
128
  if (typeof fields === 'string') {
119
129
  return liquidField(fields, vars, path);
120
130
  }
@@ -11,18 +11,12 @@ import {copyFiles} from '../utils';
11
11
  * @return {void}
12
12
  */
13
13
  export function processAssets(outputBundlePath: string) {
14
- const {
15
- input: inputFolderPath,
16
- output: outputFolderPath,
17
- } = ArgvService.getConfig();
14
+ const {input: inputFolderPath, output: outputFolderPath} = ArgvService.getConfig();
18
15
 
19
16
  const assetFilePath: string[] = walkSync(inputFolderPath, {
20
17
  directories: false,
21
18
  includeBasePath: false,
22
- ignore: [
23
- '**/*.yaml',
24
- '**/*.md',
25
- ],
19
+ ignore: ['**/*.yaml', '**/*.md'],
26
20
  });
27
21
 
28
22
  copyFiles(inputFolderPath, outputFolderPath, assetFilePath);
@@ -10,38 +10,29 @@ import {convertBackSlashToSlash} from '../utils';
10
10
  * @return {void}
11
11
  */
12
12
  export function processExcludedFiles() {
13
- const {
14
- input: inputFolderPath,
15
- output: outputFolderPath,
16
- ignore,
17
- } = ArgvService.getConfig();
13
+ const {input: inputFolderPath, output: outputFolderPath, ignore} = ArgvService.getConfig();
18
14
 
19
15
  const allContentFiles: string[] = walkSync(inputFolderPath, {
20
16
  directories: false,
21
17
  includeBasePath: true,
22
- globs: [
23
- '**/*.md',
24
- '**/index.yaml',
25
- ...ignore,
26
- ],
18
+ globs: ['**/*.md', '**/index.yaml', ...ignore],
27
19
  // Ignores service directories like "_includes", "_templates" and etc.
28
20
  ignore: ['**/_*/**/*'],
29
21
  });
30
- const navigationPaths = TocService.getNavigationPaths()
31
- .map((filePath) => convertBackSlashToSlash(resolve(inputFolderPath, filePath)));
22
+ const navigationPaths = TocService.getNavigationPaths().map((filePath) =>
23
+ convertBackSlashToSlash(resolve(inputFolderPath, filePath)),
24
+ );
32
25
  const tocSpecifiedFiles = new Set(navigationPaths);
33
- const excludedFiles = allContentFiles
34
- .filter((filePath) => !tocSpecifiedFiles.has(filePath));
26
+ const excludedFiles = allContentFiles.filter((filePath) => !tocSpecifiedFiles.has(filePath));
35
27
 
36
28
  shell.rm('-f', excludedFiles);
37
29
 
38
- const includedTocPaths = TocService.getIncludedTocPaths()
39
- .map((filePath) => {
40
- const relativeTocPath = relative(inputFolderPath, filePath);
41
- const destTocPath = resolve(outputFolderPath, relativeTocPath);
30
+ const includedTocPaths = TocService.getIncludedTocPaths().map((filePath) => {
31
+ const relativeTocPath = relative(inputFolderPath, filePath);
32
+ const destTocPath = resolve(outputFolderPath, relativeTocPath);
42
33
 
43
- return convertBackSlashToSlash(destTocPath);
44
- });
34
+ return convertBackSlashToSlash(destTocPath);
35
+ });
45
36
 
46
37
  shell.rm('-rf', includedTocPaths);
47
38
  }
@@ -1,4 +1,4 @@
1
- import log from '@doc-tools/transform/lib/log';
1
+ import log from '@diplodoc/transform/lib/log';
2
2
  import {spawn, Worker, Thread} from 'threads';
3
3
  import {extname} from 'path';
4
4
 
@@ -10,7 +10,7 @@ import {lintPage} from '../resolvers';
10
10
  import {splitOnChunks} from '../utils/worker';
11
11
 
12
12
  let processLinterWorkers: (ProcessLinterWorker & Thread)[];
13
- let navigationPathsChunks: (string[])[];
13
+ let navigationPathsChunks: string[][];
14
14
 
15
15
  export async function processLinter(): Promise<void> {
16
16
  const argvConfig = ArgvService.getConfig();
@@ -70,15 +70,16 @@ export async function initLinterWorkers() {
70
70
  return;
71
71
  }
72
72
 
73
- navigationPathsChunks = splitOnChunks(navigationPaths, chunkSize)
74
- .filter((arr) => arr.length);
73
+ navigationPathsChunks = splitOnChunks(navigationPaths, chunkSize).filter((arr) => arr.length);
75
74
 
76
75
  const workersCount = navigationPathsChunks.length;
77
76
 
78
- processLinterWorkers = await Promise.all((new Array(workersCount)).fill(null).map(() => {
79
- // TODO: get linter path from env
80
- return spawn<ProcessLinterWorker>(new Worker('./linter'), {timeout: 60000});
81
- }));
77
+ processLinterWorkers = await Promise.all(
78
+ new Array(workersCount).fill(null).map(() => {
79
+ // TODO: get linter path from env
80
+ return spawn<ProcessLinterWorker>(new Worker('./linter'), {timeout: 60000});
81
+ }),
82
+ );
82
83
  }
83
84
 
84
85
  function getChunkSize(arr: string[]) {
@@ -1,15 +1,10 @@
1
- import log from '@doc-tools/transform/lib/log';
1
+ import log from '@diplodoc/transform/lib/log';
2
2
  import _uniq from 'lodash/uniq';
3
3
 
4
4
  export function processLogs(inputFolder: string) {
5
5
  const replacementRegExp = new RegExp(inputFolder, 'ig');
6
6
  const {info, warn, error} = log.get();
7
- const outputLogs = _uniq([
8
- '', ...info,
9
- '', ...warn,
10
- '', ...error,
11
- '',
12
- ]);
7
+ const outputLogs = _uniq(['', ...info, '', ...warn, '', ...error, '']);
13
8
 
14
9
  for (const outputLog of outputLogs) {
15
10
  const preparedLog = outputLog.replace(replacementRegExp, '');
@@ -13,20 +13,17 @@ type TocItem = {
13
13
  type TocItems = TocItem[];
14
14
 
15
15
  export function prepareMapFile(): void {
16
- const {
17
- output: outputFolderPath,
18
- } = ArgvService.getConfig();
16
+ const {output: outputFolderPath} = ArgvService.getConfig();
19
17
 
20
- const navigationPathsWithoutExtensions =
21
- TocService.getNavigationPaths().map((path) => {
22
- let preparedPath = convertBackSlashToSlash(path.replace(extname(path), ''));
18
+ const navigationPathsWithoutExtensions = TocService.getNavigationPaths().map((path) => {
19
+ let preparedPath = convertBackSlashToSlash(path.replace(extname(path), ''));
23
20
 
24
- if (preparedPath.endsWith('/index')) {
25
- preparedPath = preparedPath.substring(0, preparedPath.length - 5);
26
- }
21
+ if (preparedPath.endsWith('/index')) {
22
+ preparedPath = preparedPath.substring(0, preparedPath.length - 5);
23
+ }
27
24
 
28
- return preparedPath;
29
- });
25
+ return preparedPath;
26
+ });
30
27
  const navigationPaths = {files: [...new Set(navigationPathsWithoutExtensions)]};
31
28
  const filesMapBuffer = Buffer.from(JSON.stringify(navigationPaths, null, '\t'), 'utf8');
32
29
  const mapFile = join(outputFolderPath, 'files.json');
@@ -6,11 +6,16 @@ import {bold} from 'chalk';
6
6
  import {dump, load} from 'js-yaml';
7
7
  import {mapLimit, asyncify} from 'async';
8
8
 
9
- import log from '@doc-tools/transform/lib/log';
9
+ import log from '@diplodoc/transform/lib/log';
10
10
 
11
11
  import {ArgvService, LeadingService, TocService, PluginService} from '../services';
12
12
  import {resolveMd2HTML, resolveMd2Md} from '../resolvers';
13
- import {generateStaticMarkup, joinSinglePageResults, logger, transformTocForSinglePage} from '../utils';
13
+ import {
14
+ generateStaticMarkup,
15
+ joinSinglePageResults,
16
+ logger,
17
+ transformTocForSinglePage,
18
+ } from '../utils';
14
19
  import {
15
20
  MetaDataOptions,
16
21
  SinglePageResult,
@@ -21,11 +26,7 @@ import {
21
26
  } from '../models';
22
27
  import {VCSConnector} from '../vcs-connector/connector-models';
23
28
  import {getVCSConnector} from '../vcs-connector';
24
- import {
25
- SINGLE_PAGE_FILENAME,
26
- SINGLE_PAGE_DATA_FILENAME,
27
- Lang, ResourceType,
28
- } from '../constants';
29
+ import {SINGLE_PAGE_FILENAME, SINGLE_PAGE_DATA_FILENAME, Lang, ResourceType} from '../constants';
29
30
 
30
31
  const singlePageResults: Record<string, SinglePageResult[]> = {};
31
32
  const singlePagePaths: Record<string, Set<string>> = {};
@@ -47,15 +48,34 @@ export async function processPages(outputBundlePath: string): Promise<void> {
47
48
  const navigationPaths = TocService.getNavigationPaths();
48
49
  const concurrency = 500;
49
50
 
50
- await mapLimit(navigationPaths, concurrency, asyncify(async (pathToFile: string) => {
51
- const pathData = getPathData(pathToFile, inputFolderPath, outputFolderPath, outputFormat, outputBundlePath);
52
-
53
- logger.proc(pathToFile);
54
-
55
- const metaDataOptions = getMetaDataOptions(pathData, inputFolderPath.length, vcsConnector);
56
-
57
- await preparingPagesByOutputFormat(pathData, metaDataOptions, resolveConditions, singlePage);
58
- }));
51
+ await mapLimit(
52
+ navigationPaths,
53
+ concurrency,
54
+ asyncify(async (pathToFile: string) => {
55
+ const pathData = getPathData(
56
+ pathToFile,
57
+ inputFolderPath,
58
+ outputFolderPath,
59
+ outputFormat,
60
+ outputBundlePath,
61
+ );
62
+
63
+ logger.proc(pathToFile);
64
+
65
+ const metaDataOptions = getMetaDataOptions(
66
+ pathData,
67
+ inputFolderPath.length,
68
+ vcsConnector,
69
+ );
70
+
71
+ await preparingPagesByOutputFormat(
72
+ pathData,
73
+ metaDataOptions,
74
+ resolveConditions,
75
+ singlePage,
76
+ );
77
+ }),
78
+ );
59
79
 
60
80
  if (singlePage) {
61
81
  await saveSinglePages(outputBundlePath);
@@ -106,44 +126,50 @@ async function saveSinglePages(outputBundlePath: string) {
106
126
  } = ArgvService.getConfig();
107
127
 
108
128
  try {
109
- await Promise.all(Object.keys(singlePageResults).map(async (tocDir) => {
110
- if (!singlePageResults[tocDir].length) {
111
- return;
112
- }
129
+ await Promise.all(
130
+ Object.keys(singlePageResults).map(async (tocDir) => {
131
+ if (!singlePageResults[tocDir].length) {
132
+ return;
133
+ }
113
134
 
114
- const singlePageBody = joinSinglePageResults(singlePageResults[tocDir], inputFolderPath, tocDir);
115
- const tocPath = join(relative(inputFolderPath, tocDir), 'toc.yaml');
116
- const toc: YfmToc|null = TocService.getForPath(tocPath) || null;
117
- const preparedToc = transformTocForSinglePage(toc, {
118
- root: inputFolderPath,
119
- currentPath: join(tocDir, SINGLE_PAGE_FILENAME),
120
- }) as YfmToc;
121
-
122
- const pageData = {
123
- data: {
124
- leading: false as const,
125
- html: singlePageBody,
126
- headings: [],
127
- meta: resources || {},
128
- toc: preparedToc,
129
- },
130
- router: {
131
- pathname: SINGLE_PAGE_FILENAME,
132
- },
133
- lang: lang || Lang.RU,
134
- };
135
-
136
- const outputTocDir = resolve(outputFolderPath, relative(inputFolderPath, tocDir));
137
- const relativeOutputBundlePath = relative(outputTocDir, outputBundlePath);
138
-
139
- // Save the full single page for viewing locally
140
- const singlePageFn = join(tocDir, SINGLE_PAGE_FILENAME);
141
- const singlePageDataFn = join(tocDir, SINGLE_PAGE_DATA_FILENAME);
142
- const singlePageContent = generateStaticMarkup(pageData, relativeOutputBundlePath);
143
-
144
- writeFileSync(singlePageFn, singlePageContent);
145
- writeFileSync(singlePageDataFn, JSON.stringify(pageData));
146
- }));
135
+ const singlePageBody = joinSinglePageResults(
136
+ singlePageResults[tocDir],
137
+ inputFolderPath,
138
+ tocDir,
139
+ );
140
+ const tocPath = join(relative(inputFolderPath, tocDir), 'toc.yaml');
141
+ const toc: YfmToc | null = TocService.getForPath(tocPath) || null;
142
+ const preparedToc = transformTocForSinglePage(toc, {
143
+ root: inputFolderPath,
144
+ currentPath: join(tocDir, SINGLE_PAGE_FILENAME),
145
+ }) as YfmToc;
146
+
147
+ const pageData = {
148
+ data: {
149
+ leading: false as const,
150
+ html: singlePageBody,
151
+ headings: [],
152
+ meta: resources || {},
153
+ toc: preparedToc,
154
+ },
155
+ router: {
156
+ pathname: SINGLE_PAGE_FILENAME,
157
+ },
158
+ lang: lang || Lang.RU,
159
+ };
160
+
161
+ const outputTocDir = resolve(outputFolderPath, relative(inputFolderPath, tocDir));
162
+ const relativeOutputBundlePath = relative(outputTocDir, outputBundlePath);
163
+
164
+ // Save the full single page for viewing locally
165
+ const singlePageFn = join(tocDir, SINGLE_PAGE_FILENAME);
166
+ const singlePageDataFn = join(tocDir, SINGLE_PAGE_DATA_FILENAME);
167
+ const singlePageContent = generateStaticMarkup(pageData, relativeOutputBundlePath);
168
+
169
+ writeFileSync(singlePageFn, singlePageContent);
170
+ writeFileSync(singlePageDataFn, JSON.stringify(pageData));
171
+ }),
172
+ );
147
173
  } catch (error) {
148
174
  console.log(error);
149
175
  }
@@ -172,7 +198,10 @@ function savePageResultForSinglePage(pageProps: DocInnerProps, pathData: PathDat
172
198
  });
173
199
  }
174
200
 
175
- function getMetaDataOptions(pathData: PathData, inputFolderPathLength: number, vcsConnector?: VCSConnector,
201
+ function getMetaDataOptions(
202
+ pathData: PathData,
203
+ inputFolderPathLength: number,
204
+ vcsConnector?: VCSConnector,
176
205
  ): MetaDataOptions {
177
206
  const {contributors, addSystemMeta, resources, allowCustomResources} = ArgvService.getConfig();
178
207
 
@@ -187,7 +216,6 @@ function getMetaDataOptions(pathData: PathData, inputFolderPathLength: number, v
187
216
  addSystemMeta,
188
217
  };
189
218
 
190
-
191
219
  if (allowCustomResources && resources) {
192
220
  const allowedResources = Object.entries(resources).reduce((acc: Resources, [key, val]) => {
193
221
  if (Object.keys(ResourceType).includes(key)) {
@@ -199,7 +227,6 @@ function getMetaDataOptions(pathData: PathData, inputFolderPathLength: number, v
199
227
  metaDataOptions.resources = allowedResources;
200
228
  }
201
229
 
202
-
203
230
  return metaDataOptions;
204
231
  }
205
232
 
@@ -234,8 +261,10 @@ async function preparingPagesByOutputFormat(
234
261
  return;
235
262
  }
236
263
 
237
- if (outputFormat === 'md' && isYamlFileExtension ||
238
- outputFormat === 'html' && !isYamlFileExtension && fileExtension !== '.md') {
264
+ if (
265
+ (outputFormat === 'md' && isYamlFileExtension) ||
266
+ (outputFormat === 'html' && !isYamlFileExtension && fileExtension !== '.md')
267
+ ) {
239
268
  copyFileWithoutChanges(resolvedPathToFile, outputDir, filename);
240
269
  return;
241
270
  }
@@ -275,7 +304,11 @@ function processingYamlFile(path: PathData, metaDataOptions: MetaDataOptions) {
275
304
  writeFileSync(resolve(outputFolderPath, pathToFile), dump(parsedContent));
276
305
  }
277
306
 
278
- function copyFileWithoutChanges(resolvedPathToFile: string, outputDir: string, filename: string): void {
307
+ function copyFileWithoutChanges(
308
+ resolvedPathToFile: string,
309
+ outputDir: string,
310
+ filename: string,
311
+ ): void {
279
312
  const from = resolvedPathToFile;
280
313
  const to = resolve(outputDir, filename);
281
314
 
@@ -292,14 +325,11 @@ async function processingFileToMd(path: PathData, metaDataOptions: MetaDataOptio
292
325
  });
293
326
  }
294
327
 
295
- async function processingFileToHtml(path: PathData, metaDataOptions: MetaDataOptions): Promise<DocInnerProps> {
296
- const {
297
- outputBundlePath,
298
- filename,
299
- fileExtension,
300
- outputPath,
301
- pathToFile,
302
- } = path;
328
+ async function processingFileToHtml(
329
+ path: PathData,
330
+ metaDataOptions: MetaDataOptions,
331
+ ): Promise<DocInnerProps> {
332
+ const {outputBundlePath, filename, fileExtension, outputPath, pathToFile} = path;
303
333
 
304
334
  return resolveMd2HTML({
305
335
  inputPath: pathToFile,
@@ -2,7 +2,7 @@ import {dirname, resolve} from 'path';
2
2
  import walkSync from 'walk-sync';
3
3
  import {readFileSync, writeFileSync} from 'fs';
4
4
  import {load, dump} from 'js-yaml';
5
- import log from '@doc-tools/transform/lib/log';
5
+ import log from '@diplodoc/transform/lib/log';
6
6
 
7
7
  import {ArgvService, PresetService, TocService} from '../services';
8
8
  import {logger} from '../utils';
@@ -79,7 +79,9 @@ function saveFilteredPresets(path: string, parsedPreset: DocPreset): void {
79
79
  writeFileSync(outputPath, outputPreset);
80
80
  }
81
81
 
82
- async function preparingTocFiles(getFilePathsByGlobals: GetFilePathsByGlobalsFunction): Promise<void> {
82
+ async function preparingTocFiles(
83
+ getFilePathsByGlobals: GetFilePathsByGlobalsFunction,
84
+ ): Promise<void> {
83
85
  try {
84
86
  const tocFilePaths = getFilePathsByGlobals(['**/toc.yaml']);
85
87
 
@@ -21,7 +21,9 @@ export async function publishFilesToS3(): Promise<void> {
21
21
  } = ArgvService.getConfig();
22
22
 
23
23
  const s3Client = new S3({
24
- endpoint, accessKeyId, secretAccessKey,
24
+ endpoint,
25
+ accessKeyId,
26
+ secretAccessKey,
25
27
  });
26
28
 
27
29
  const filesToPublish: string[] = walkSync(resolve(outputFolderPath), {
@@ -30,18 +32,20 @@ export async function publishFilesToS3(): Promise<void> {
30
32
  ignore,
31
33
  });
32
34
 
33
- await Promise.all(filesToPublish.map(async (pathToFile) => {
34
- const mimeType = mime.lookup(pathToFile);
35
+ await Promise.all(
36
+ filesToPublish.map(async (pathToFile) => {
37
+ const mimeType = mime.lookup(pathToFile);
35
38
 
36
- const params: S3.Types.PutObjectRequest = {
37
- ContentType: mimeType ? mimeType : undefined,
38
- Bucket: bucket,
39
- Key: convertBackSlashToSlash(join(prefix, pathToFile)),
40
- Body: readFileSync(resolve(outputFolderPath, pathToFile)),
41
- };
39
+ const params: S3.Types.PutObjectRequest = {
40
+ ContentType: mimeType ? mimeType : undefined,
41
+ Bucket: bucket,
42
+ Key: convertBackSlashToSlash(join(prefix, pathToFile)),
43
+ Body: readFileSync(resolve(outputFolderPath, pathToFile)),
44
+ };
42
45
 
43
- logger.upload(pathToFile);
46
+ logger.upload(pathToFile);
44
47
 
45
- return s3Client.upload(params).promise();
46
- }));
48
+ return s3Client.upload(params).promise();
49
+ }),
50
+ );
47
51
  }
package/src/utils/file.ts CHANGED
@@ -3,7 +3,11 @@ import shell from 'shelljs';
3
3
  import {copyFileSync} from 'fs';
4
4
  import {logger} from './logger';
5
5
 
6
- export function copyFiles(inputFolderPath: string, outputFolderPath: string, files: string[]): void {
6
+ export function copyFiles(
7
+ inputFolderPath: string,
8
+ outputFolderPath: string,
9
+ files: string[],
10
+ ): void {
7
11
  for (const pathToAsset of files) {
8
12
  const outputDir: string = resolve(outputFolderPath, dirname(pathToAsset));
9
13
  const from = resolve(inputFolderPath, pathToAsset);
package/src/utils/glob.ts CHANGED
@@ -4,9 +4,7 @@ export type Glob = {state: IGlob};
4
4
 
5
5
  const glob = async (pattern: string, options: IOptions): Promise<Glob> =>
6
6
  new Promise((res, rej) => {
7
- const state: IGlob = libglob(pattern, options, (err) =>
8
- err ? rej(err) : res({state}),
9
- );
7
+ const state: IGlob = libglob(pattern, options, (err) => (err ? rej(err) : res({state})));
10
8
  });
11
9
 
12
10
  export {glob};
@@ -1,4 +1,4 @@
1
- import log from '@doc-tools/transform/lib/log';
1
+ import log from '@diplodoc/transform/lib/log';
2
2
  import {blue, green, grey, red, yellow} from 'chalk';
3
3
  import {ArgvService} from '../services';
4
4