@diplodoc/cli 4.0.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 (74) hide show
  1. package/CHANGELOG.md +785 -0
  2. package/LICENSE +21 -0
  3. package/README.md +62 -0
  4. package/README.ru.md +63 -0
  5. package/build/app.client.css +47 -0
  6. package/build/app.client.js +3 -0
  7. package/build/index.js +3993 -0
  8. package/build/index.js.map +7 -0
  9. package/build/lib.js +3374 -0
  10. package/build/lib.js.map +7 -0
  11. package/build/linter.js +1265 -0
  12. package/build/linter.js.map +7 -0
  13. package/package.json +126 -0
  14. package/src/cmd/build/index.ts +304 -0
  15. package/src/cmd/index.ts +4 -0
  16. package/src/cmd/publish/index.ts +92 -0
  17. package/src/cmd/publish/upload.ts +61 -0
  18. package/src/cmd/translate/index.ts +261 -0
  19. package/src/cmd/xliff/compose.ts +222 -0
  20. package/src/cmd/xliff/extract.ts +237 -0
  21. package/src/cmd/xliff/index.ts +27 -0
  22. package/src/constants.ts +122 -0
  23. package/src/globals.d.ts +1 -0
  24. package/src/index.ts +54 -0
  25. package/src/models.ts +249 -0
  26. package/src/packages/credentials/index.ts +1 -0
  27. package/src/packages/credentials/yandex-oauth.ts +42 -0
  28. package/src/resolvers/index.ts +3 -0
  29. package/src/resolvers/lintPage.ts +119 -0
  30. package/src/resolvers/md2html.ts +142 -0
  31. package/src/resolvers/md2md.ts +147 -0
  32. package/src/services/argv.ts +38 -0
  33. package/src/services/authors.ts +64 -0
  34. package/src/services/contributors.ts +104 -0
  35. package/src/services/includers/batteries/common.ts +34 -0
  36. package/src/services/includers/batteries/generic.ts +130 -0
  37. package/src/services/includers/batteries/index.ts +3 -0
  38. package/src/services/includers/batteries/sourcedocs.ts +33 -0
  39. package/src/services/includers/batteries/unarchive.ts +97 -0
  40. package/src/services/includers/index.ts +157 -0
  41. package/src/services/index.ts +6 -0
  42. package/src/services/leading.ts +88 -0
  43. package/src/services/metadata.ts +249 -0
  44. package/src/services/plugins.ts +76 -0
  45. package/src/services/preset.ts +55 -0
  46. package/src/services/tocs.ts +401 -0
  47. package/src/services/utils.ts +151 -0
  48. package/src/steps/index.ts +6 -0
  49. package/src/steps/processAssets.ts +36 -0
  50. package/src/steps/processExcludedFiles.ts +47 -0
  51. package/src/steps/processLinter.ts +100 -0
  52. package/src/steps/processLogs.ts +18 -0
  53. package/src/steps/processMapFile.ts +35 -0
  54. package/src/steps/processPages.ts +312 -0
  55. package/src/steps/processServiceFiles.ts +95 -0
  56. package/src/steps/publishFilesToS3.ts +47 -0
  57. package/src/utils/file.ts +17 -0
  58. package/src/utils/glob.ts +14 -0
  59. package/src/utils/index.ts +8 -0
  60. package/src/utils/logger.ts +42 -0
  61. package/src/utils/markup.ts +125 -0
  62. package/src/utils/path.ts +24 -0
  63. package/src/utils/presets.ts +20 -0
  64. package/src/utils/singlePage.ts +228 -0
  65. package/src/utils/toc.ts +87 -0
  66. package/src/utils/url.ts +3 -0
  67. package/src/utils/worker.ts +10 -0
  68. package/src/validator.ts +150 -0
  69. package/src/vcs-connector/client/github.ts +52 -0
  70. package/src/vcs-connector/connector-models.ts +76 -0
  71. package/src/vcs-connector/connector-validator.ts +114 -0
  72. package/src/vcs-connector/github.ts +333 -0
  73. package/src/vcs-connector/index.ts +15 -0
  74. package/src/workers/linter/index.ts +62 -0
@@ -0,0 +1,27 @@
1
+ import {extract} from './extract';
2
+ import {compose} from './compose';
3
+
4
+ import {Argv} from 'yargs';
5
+
6
+ const command = 'xliff';
7
+
8
+ const description =
9
+ 'extract xliff and skeleton from documentation files\ncompose xliff and skeleton into documentation';
10
+
11
+ const xliff = {
12
+ command,
13
+ description,
14
+ handler: () => {},
15
+ builder,
16
+ };
17
+
18
+ function builder<T>(argv: Argv<T>) {
19
+ return argv
20
+ .command(extract)
21
+ .command(compose)
22
+ .demandCommand(1, `provide one of the folowing ${command} commands: ${extract.command}, ${compose.command}`);
23
+ }
24
+
25
+ export {xliff};
26
+
27
+ export default {xliff};
@@ -0,0 +1,122 @@
1
+ import {dirname} from 'path';
2
+ const os = require('os');
3
+ const notes = require('@doc-tools/transform/lib/plugins/notes');
4
+ const anchors = require('@doc-tools/transform/lib/plugins/anchors');
5
+ const code = require('@doc-tools/transform/lib/plugins/code');
6
+ const cut = require('@doc-tools/transform/lib/plugins/cut');
7
+ const deflist = require('@doc-tools/transform/lib/plugins/deflist');
8
+ const imsize = require('@doc-tools/transform/lib/plugins/imsize');
9
+ const meta = require('@doc-tools/transform/lib/plugins/meta');
10
+ const sup = require('@doc-tools/transform/lib/plugins/sup');
11
+ const tabs = require('@doc-tools/transform/lib/plugins/tabs');
12
+ const video = require('@doc-tools/transform/lib/plugins/video');
13
+ const includes = require('@doc-tools/transform/lib/plugins/includes');
14
+ const links = require('@doc-tools/transform/lib/plugins/links');
15
+ const images = require('@doc-tools/transform/lib/plugins/images');
16
+ const monospace = require('@doc-tools/transform/lib/plugins/monospace');
17
+ const table = require('@doc-tools/transform/lib/plugins/table');
18
+ const term = require('@doc-tools/transform/lib/plugins/term');
19
+ const changelog = require('@doc-tools/transform/lib/plugins/changelog');
20
+ const mermaid = require('@diplodoc/mermaid-extension');
21
+ const openapi = require('@diplodoc/openapi-extension');
22
+
23
+ includes.collect = require('@doc-tools/transform/lib/plugins/includes/collect');
24
+ images.collect = require('@doc-tools/transform/lib/plugins/images/collect');
25
+ changelog.collect = require('@doc-tools/transform/lib/plugins/changelog/collect');
26
+
27
+ export const BUILD_FOLDER = 'build';
28
+ export const BUNDLE_FOLDER = '_bundle';
29
+ export const BUNDLE_JS_FILENAME = 'app.client.js';
30
+ export const BUNDLE_CSS_FILENAME = 'app.client.css';
31
+ export const TMP_INPUT_FOLDER = '.tmp_input';
32
+ export const TMP_OUTPUT_FOLDER = '.tmp_output';
33
+ export const MAIN_TIMER_ID = 'Build time';
34
+ export const YFM_CONFIG_FILENAME = '.yfm';
35
+ export const REDIRECTS_FILENAME = 'redirects.yaml';
36
+ export const LINT_CONFIG_FILENAME = '.yfmlint';
37
+ export const SINGLE_PAGE_FILENAME = 'single-page.html';
38
+ export const SINGLE_PAGE_DATA_FILENAME = 'single-page.json';
39
+ export const CUSTOM_STYLE = 'custom-style';
40
+
41
+ export enum Stage {
42
+ NEW = 'new',
43
+ PREVIEW = 'preview',
44
+ TECH_PREVIEW = 'tech-preview',
45
+ SKIP = 'skip',
46
+ }
47
+
48
+ export enum Lang {
49
+ RU = 'ru',
50
+ EN = 'en',
51
+ }
52
+
53
+ export enum Platforms {
54
+ WINDOWS = 'win32',
55
+ MAC = 'darwin',
56
+ LINUX = 'linux',
57
+ }
58
+
59
+ export enum IncludeMode {
60
+ ROOT_MERGE = 'root_merge',
61
+ MERGE = 'merge',
62
+ LINK = 'link'
63
+ }
64
+
65
+ export enum ResourceType {
66
+ style = 'style',
67
+ script = 'script',
68
+ }
69
+
70
+ export const BUILD_FOLDER_PATH = dirname(require.resolve('@diplodoc/client'));
71
+
72
+ export const YFM_PLUGINS = [
73
+ meta,
74
+ deflist,
75
+ includes,
76
+ cut,
77
+ links,
78
+ images,
79
+ notes,
80
+ anchors,
81
+ tabs,
82
+ code,
83
+ imsize,
84
+ sup,
85
+ video,
86
+ monospace,
87
+ table,
88
+ term,
89
+ openapi.transform(),
90
+ mermaid.transform(),
91
+ changelog,
92
+ ];
93
+
94
+ export const PROCESSING_FINISHED = 'Processing finished:';
95
+ export const LINTING_FINISHED = 'Linting finished:';
96
+ export const GETTING_ALL_CONTRIBUTORS = 'Getting all contributors.';
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`;
100
+
101
+ export const FIRST_COMMIT_FROM_ROBOT_IN_GITHUB = '2dce14271359cd20d7e874956d604de087560cf4';
102
+
103
+ // Include example: 'master\n' or 'nanov94/QUEUE-1234_some_branch_name.1.2.3\n'
104
+ // Regexp result: 'master' or 'nanov94/QUEUE-1234_some_branch_name'
105
+ export const REGEXP_BRANCH_NAME = /([\d\w\-_/.]+)(?=\r?\n)/g;
106
+
107
+ // Include example: {% include [createfolder](create-folder.md) %}
108
+ // Regexp result: [createfolder](create-folder.md)
109
+ export const REGEXP_INCLUDE_CONTENTS = /(?<=[{%]\sinclude\s).+(?=\s[%}])/gm;
110
+
111
+ // Include example: [createfolder](create-folder.md)
112
+ // Regexp result: create-folder.md
113
+ export const REGEXP_INCLUDE_FILE_PATH = /(?<=[(]).+(?=[)])/g;
114
+
115
+ // Include example: author: authorLogin
116
+ // Regexp result: authorLogin
117
+ export const REGEXP_AUTHOR = /(?<=author:\s).+(?=\r?\n)/g;
118
+
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);
121
+
122
+ export const metadataBorder = '---';
@@ -0,0 +1 @@
1
+ declare const VERSION: string;
package/src/index.ts ADDED
@@ -0,0 +1,54 @@
1
+ import yargs from 'yargs';
2
+ import {hideBin} from 'yargs/helpers';
3
+ import log from '@doc-tools/transform/lib/log';
4
+ import 'threads/register';
5
+
6
+ import {MAIN_TIMER_ID} from './constants';
7
+
8
+ import {build, xliff, translate, publish} from './cmd';
9
+
10
+ console.time(MAIN_TIMER_ID);
11
+
12
+ yargs
13
+ .command(build)
14
+ .command(publish)
15
+ .command(xliff)
16
+ .command(translate)
17
+ .option('config', {
18
+ alias: 'c',
19
+ describe: 'YFM configuration file',
20
+ type: 'string',
21
+ })
22
+ .option('strict', {
23
+ alias: 's',
24
+ default: false,
25
+ describe: 'Run in strict mode',
26
+ type: 'boolean',
27
+ })
28
+ .option('quiet', {
29
+ alias: 'q',
30
+ default: false,
31
+ describe: 'Run in quiet mode. Don\'t write logs to stdout',
32
+ type: 'boolean',
33
+ })
34
+ .group(['config', 'strict', 'quiet', 'help', 'version'], 'Common options:')
35
+ .version(typeof VERSION !== 'undefined' ? VERSION : '')
36
+ .help()
37
+ .parse(hideBin(process.argv), {}, (err, {strict}, output) => {
38
+ console.timeEnd(MAIN_TIMER_ID);
39
+
40
+ if (err) {
41
+ console.error(err);
42
+ process.exit(1);
43
+ }
44
+
45
+ const {warn, error} = log.get();
46
+
47
+ if (strict && warn.length || error.length) {
48
+ process.exit(1);
49
+ }
50
+
51
+ console.log(output);
52
+
53
+ process.exit(0);
54
+ });
package/src/models.ts ADDED
@@ -0,0 +1,249 @@
1
+ import {Logger} from '@doc-tools/transform/lib/log';
2
+ import {LintConfig} from '@doc-tools/transform/lib/yfmlint';
3
+
4
+ import {FileContributors, VCSConnector, VCSConnectorConfig} from './vcs-connector/connector-models';
5
+ import {Lang, Stage, IncludeMode, ResourceType} from './constants';
6
+ import {ChangelogItem} from '@doc-tools/transform/lib/plugins/changelog/types';
7
+
8
+ export type VarsPreset = 'internal'|'external';
9
+
10
+ export type YfmPreset = Record<string, string>;
11
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
12
+ export type Metadata = Record<string, any>;
13
+
14
+ export type ExternalAuthorByPathFunction = (path: string) => Contributor | null;
15
+ export type ContributorsByPathFunction = (path: string) => Promise<FileContributors>;
16
+ export type NestedContributorsForPathFunction = (path: string, nestedContributors: Contributors) => void;
17
+ export type UserByLoginFunction = (login: string) => Promise<Contributor | null>;
18
+ export type CollectionOfPluginsFunction = (output: string, options: PluginOptions) => string;
19
+
20
+ interface YfmConfig {
21
+ varsPreset: VarsPreset;
22
+ ignore: string[];
23
+ outputFormat: string;
24
+ allowHTML: boolean;
25
+ vars: Record<string, string>;
26
+ applyPresets: boolean;
27
+ resolveConditions: boolean;
28
+ conditionsInCode: boolean;
29
+ disableLiquid: boolean;
30
+ strict: boolean;
31
+ ignoreStage: string;
32
+ singlePage: boolean;
33
+ removeHiddenTocItems: boolean;
34
+ connector?: VCSConnectorConfig;
35
+ lang?: Lang;
36
+ lintDisabled: boolean;
37
+ buildDisabled: boolean;
38
+ lintConfig: LintConfig;
39
+ resources?: Resources;
40
+ yandexCloudTranslateFolderId: string;
41
+ yandexCloudTranslateGlossaryPairs: YandexCloudTranslateGlossaryPair[];
42
+ }
43
+
44
+ export interface YfmArgv extends YfmConfig {
45
+ rootInput: string;
46
+ input: string;
47
+ output: string;
48
+ quiet: string;
49
+ publish: boolean;
50
+ storageEndpoint: string;
51
+ storageBucket: string;
52
+ storagePrefix: string;
53
+ storageKeyId: string;
54
+ storageSecretKey: string;
55
+ storageRegion: string;
56
+ contributors: boolean;
57
+ ignoreAuthorPatterns: string;
58
+ addSystemMeta: boolean;
59
+ addMapFile: boolean;
60
+ allowCustomResources: boolean;
61
+ staticContent: boolean;
62
+ }
63
+
64
+ export interface DocPreset {
65
+ default: YfmPreset;
66
+ [varsPreset: string]: YfmPreset;
67
+ }
68
+
69
+ export interface YfmToc extends Filter {
70
+ name: string;
71
+ href: string;
72
+ items: YfmToc[];
73
+ stage?: Stage;
74
+ base?: string;
75
+ title?: TextItems;
76
+ include?: YfmTocInclude;
77
+ id?: string;
78
+ singlePage?: boolean;
79
+ hidden?: boolean;
80
+ }
81
+
82
+ export interface YfmTocInclude {
83
+ repo: string;
84
+ path: string;
85
+ mode?: IncludeMode;
86
+ includers?: YfmTocIncluders;
87
+ }
88
+
89
+ export type YfmTocIncluders = YfmTocIncluder[];
90
+
91
+ export type YfmTocIncluder = {
92
+ name: YfmTocIncluderName;
93
+ // arbitrary includer parameters
94
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
95
+ } & Record<string, unknown>;
96
+
97
+ export const includersNames = ['sourcedocs', 'openapi', 'generic', 'unarchive'] as const;
98
+
99
+ export type YfmTocIncluderName = typeof includersNames[number];
100
+
101
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
102
+ export type Includer<FnParams = any> = {
103
+ name: YfmTocIncluderName;
104
+ includerFunction: IncluderFunction<FnParams>;
105
+ };
106
+
107
+ export type IncluderFunction<PassedParams> = (args: IncluderFunctionParams<PassedParams>) => Promise<void>;
108
+
109
+ export type IncluderFunctionParams<PassedParams> = {
110
+ // item that contains include that uses includer
111
+ item: YfmToc;
112
+ // base read directory path
113
+ readBasePath: string;
114
+ // base write directory path
115
+ writeBasePath: string;
116
+ // toc with includer path
117
+ tocPath: string;
118
+ vars: YfmPreset;
119
+ // arbitrary includer parameters
120
+ passedParams: PassedParams;
121
+ index: number;
122
+ };
123
+
124
+ export interface LeadingPage {
125
+ title: TextItems;
126
+ description?: TextItems;
127
+ meta?: {
128
+ title?: TextItems;
129
+ description?: TextItems;
130
+ noIndex?: boolean;
131
+ };
132
+ nav?: {
133
+ title: TextItems;
134
+ };
135
+ links: LeadingPageLinks[];
136
+ }
137
+
138
+ export type TextItems = string | (TextItem | string)[];
139
+
140
+ export interface TextItem extends Filter {
141
+ text: string | string[];
142
+ }
143
+
144
+ export interface LeadingPageLinks extends Filter {
145
+ title?: string;
146
+ description?: string;
147
+ href?: string;
148
+ }
149
+
150
+ export interface Filter {
151
+ when?: boolean|string;
152
+ [key: string]: unknown;
153
+ }
154
+
155
+ export interface SinglePageResult {
156
+ path: string;
157
+ content: string;
158
+ title?: string;
159
+ }
160
+
161
+ export interface Contributor {
162
+ avatar: string;
163
+ email: string;
164
+ login: string;
165
+ name: string;
166
+ url: string;
167
+ }
168
+
169
+ export interface Contributors {
170
+ [email: string]: Contributor;
171
+ }
172
+
173
+ export interface FileData {
174
+ tmpInputFilePath: string;
175
+ inputFolderPathLength: number;
176
+ fileContent: string;
177
+ sourcePath?: string;
178
+ }
179
+
180
+ export interface MetaDataOptions {
181
+ fileData: FileData;
182
+ isContributorsEnabled?: boolean;
183
+ vcsConnector?: VCSConnector;
184
+ addSystemMeta?: boolean;
185
+ addSourcePath?: boolean;
186
+ resources?: Resources;
187
+ }
188
+
189
+ export interface PluginOptions {
190
+ vars: YfmPreset;
191
+ path: string;
192
+ log: Logger;
193
+ copyFile: (targetPath: string, targetDestPath: string, options?: PluginOptions) => void;
194
+ singlePage?: boolean;
195
+ root?: string;
196
+ destPath?: string;
197
+ destRoot?: string;
198
+ collectOfPlugins?: (input: string, options: PluginOptions) => string;
199
+ changelogs?: ChangelogItem[];
200
+ extractChangelogs?: boolean;
201
+ }
202
+
203
+ export interface Plugin {
204
+ collect: (input: string, options: PluginOptions) => string | void;
205
+ }
206
+
207
+ export interface ResolveMd2MdOptions {
208
+ inputPath: string;
209
+ outputPath: string;
210
+ metadata?: MetaDataOptions;
211
+ }
212
+
213
+ export interface ResolverOptions {
214
+ inputPath: string;
215
+ filename: string;
216
+ fileExtension: string;
217
+ outputPath: string;
218
+ outputBundlePath: string;
219
+ metadata?: MetaDataOptions;
220
+ }
221
+
222
+ export interface PathData {
223
+ pathToFile: string;
224
+ resolvedPathToFile: string;
225
+ filename: string;
226
+ fileBaseName: string;
227
+ fileExtension: string;
228
+ outputDir: string;
229
+ outputPath: string;
230
+ outputFormat: string;
231
+ outputBundlePath: string;
232
+ outputTocDir: string;
233
+ inputFolderPath: string;
234
+ outputFolderPath: string;
235
+ }
236
+
237
+ export type Resources = {
238
+ [key in ResourceType]?: string[];
239
+ };
240
+
241
+ export type YandexCloudTranslateGlossaryPair = {
242
+ sourceText: string;
243
+ translatedText: string;
244
+ };
245
+
246
+ export type CommitInfo = {
247
+ email: string;
248
+ hashCommit: string;
249
+ };
@@ -0,0 +1 @@
1
+ export * from './yandex-oauth';
@@ -0,0 +1,42 @@
1
+ import {readFile} from 'fs/promises';
2
+ import {env} from 'process';
3
+ import {homedir} from 'os';
4
+ import {join} from 'path';
5
+
6
+ import {logger} from '../../utils';
7
+
8
+ const YANDEX_OAUTH_TOKEN_FILENAME = '.ya_oauth_token';
9
+
10
+ async function getYandexOAuthToken() {
11
+ const {YANDEX_OAUTH_TOKEN} = env;
12
+
13
+ return YANDEX_OAUTH_TOKEN ?? getYandexOAuthTokenFromHomeDir();
14
+ }
15
+
16
+ async function getYandexOAuthTokenFromHomeDir() {
17
+ const error = 'failed reading yandex oauth token';
18
+
19
+ const path = join(homedir(), YANDEX_OAUTH_TOKEN_FILENAME);
20
+
21
+ let token;
22
+
23
+ try {
24
+ token = await readFile(path, {encoding: 'utf8'});
25
+
26
+ token = token.trim();
27
+
28
+ if (!token?.length) {
29
+ throw new Error(error);
30
+ }
31
+ } catch (err) {
32
+ logger.error(error);
33
+
34
+ throw err;
35
+ }
36
+
37
+ return token;
38
+ }
39
+
40
+ export {getYandexOAuthToken};
41
+
42
+ export default {getYandexOAuthToken};
@@ -0,0 +1,3 @@
1
+ export * from './md2md';
2
+ export * from './md2html';
3
+ export * from './lintPage';
@@ -0,0 +1,119 @@
1
+ import {dirname, relative, resolve} from 'path';
2
+ import log from '@doc-tools/transform/lib/log';
3
+ import {
4
+ default as yfmlint,
5
+ LintMarkdownFunctionOptions,
6
+ PluginOptions,
7
+ } from '@doc-tools/transform/lib/yfmlint';
8
+ import {readFileSync} from 'fs';
9
+ import {bold} from 'chalk';
10
+
11
+ import {ArgvService, PluginService} from '../services';
12
+ import {getVarsPerFile, getVarsPerRelativeFile} from '../utils';
13
+ import {liquidMd2Html} from './md2html';
14
+ import {liquidMd2Md} from './md2md';
15
+
16
+ interface FileTransformOptions {
17
+ path: string;
18
+ root?: string;
19
+ }
20
+
21
+ const FileLinter: Record<string, Function> = {
22
+ '.md': MdFileLinter,
23
+ };
24
+
25
+ export interface ResolverLintOptions {
26
+ inputPath: string;
27
+ fileExtension: string;
28
+ onFinish?: () => void;
29
+ }
30
+
31
+ export function lintPage(options: ResolverLintOptions) {
32
+ const {inputPath, fileExtension, onFinish} = options;
33
+ const {input} = ArgvService.getConfig();
34
+ const resolvedPath: string = resolve(input, inputPath);
35
+
36
+ try {
37
+ const content: string = readFileSync(resolvedPath, 'utf8');
38
+
39
+ const lintFn: Function = FileLinter[fileExtension];
40
+ if (!lintFn) {
41
+ return;
42
+ }
43
+
44
+ lintFn(content, {path: inputPath});
45
+ } catch (e) {
46
+ const message = `No such file or has no access to ${bold(resolvedPath)}`;
47
+ console.error(message, e);
48
+ log.error(message);
49
+ }
50
+
51
+ if (onFinish) {
52
+ onFinish();
53
+ }
54
+ }
55
+
56
+ function MdFileLinter(content: string, lintOptions: FileTransformOptions): void {
57
+ const {
58
+ input,
59
+ lintConfig,
60
+ disableLiquid,
61
+ outputFormat,
62
+ ...options
63
+ } = ArgvService.getConfig();
64
+ const {path: filePath} = lintOptions;
65
+
66
+ const plugins = outputFormat === 'md' ? [] : PluginService.getPlugins();
67
+ const vars = getVarsPerFile(filePath);
68
+ const root = resolve(input);
69
+ const path: string = resolve(input, filePath);
70
+ let preparedContent = content;
71
+
72
+ /* Relative path from folder of .md file to root of user' output folder */
73
+ const assetsPublicPath = relative(dirname(path), root);
74
+
75
+ const lintMarkdown = function lintMarkdown(opts: LintMarkdownFunctionOptions) {
76
+ const {input: localInput, path: localPath, sourceMap} = opts;
77
+
78
+ const pluginOptions: PluginOptions = {
79
+ ...options,
80
+ vars,
81
+ root,
82
+ path: localPath,
83
+ lintMarkdown, // Should pass the function for linting included files
84
+ assetsPublicPath,
85
+ disableLiquid,
86
+ log,
87
+ getVarsPerFile: getVarsPerRelativeFile,
88
+ };
89
+
90
+ yfmlint({
91
+ input: localInput,
92
+ lintConfig,
93
+ pluginOptions,
94
+ plugins,
95
+ defaultLintConfig: PluginService.getDefaultLintConfig(),
96
+ customLintRules: PluginService.getCustomLintRules(),
97
+ sourceMap,
98
+ });
99
+ };
100
+
101
+ let sourceMap;
102
+ if (!disableLiquid) {
103
+ let liquidResult;
104
+ if (outputFormat === 'md') {
105
+ liquidResult = liquidMd2Md(content, vars, path);
106
+ } else {
107
+ liquidResult = liquidMd2Html(content, vars, path);
108
+ }
109
+
110
+ preparedContent = liquidResult.output;
111
+ sourceMap = liquidResult.sourceMap;
112
+ }
113
+
114
+ lintMarkdown({
115
+ input: preparedContent,
116
+ path,
117
+ sourceMap,
118
+ });
119
+ }