@diplodoc/cli 4.19.2 → 4.19.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/index.js +27 -19
- package/build/index.js.map +3 -3
- package/package.json +1 -1
- package/src/steps/processAssets.ts +19 -10
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.19.
|
|
6
|
+
"version": "4.19.3",
|
|
7
7
|
"repository": {
|
|
8
8
|
"type": "git",
|
|
9
9
|
"url": "git@github.com:diplodoc-platform/cli.git"
|
|
@@ -2,7 +2,7 @@ import walkSync from 'walk-sync';
|
|
|
2
2
|
import {load} from 'js-yaml';
|
|
3
3
|
import {readFileSync} from 'fs';
|
|
4
4
|
import shell from 'shelljs';
|
|
5
|
-
import {join, resolve} from 'path';
|
|
5
|
+
import {join, resolve, sep} from 'path';
|
|
6
6
|
|
|
7
7
|
import {ArgvService, TocService} from '../services';
|
|
8
8
|
import {checkPathExists, copyFiles, findAllValuesByKeys} from '../utils';
|
|
@@ -18,6 +18,7 @@ import {
|
|
|
18
18
|
YFM_CONFIG_FILENAME,
|
|
19
19
|
} from '../constants';
|
|
20
20
|
import {Resources} from '../models';
|
|
21
|
+
import {resolveRelativePath} from '@diplodoc/transform/lib/utilsFS';
|
|
21
22
|
|
|
22
23
|
/**
|
|
23
24
|
* Processes assets files (everything except .md files)
|
|
@@ -99,17 +100,25 @@ function processAssetsMdRun({args, tmpOutputFolder}) {
|
|
|
99
100
|
}
|
|
100
101
|
|
|
101
102
|
const contentLinks = findAllValuesByKeys(content, LINK_KEYS);
|
|
102
|
-
const localMediaLinks = contentLinks.
|
|
103
|
-
(link) =>
|
|
104
|
-
new RegExp(
|
|
105
|
-
|
|
103
|
+
const localMediaLinks = contentLinks.reduce(
|
|
104
|
+
(acc, link) => {
|
|
105
|
+
const linkHasMediaExt = new RegExp(
|
|
106
|
+
/^\S.*\.(svg|png|gif|jpg|jpeg|bmp|webp|ico)$/gm,
|
|
107
|
+
).test(link);
|
|
108
|
+
|
|
109
|
+
if (linkHasMediaExt && isLocalUrl(link) && checkPathExists(link, yamlFile)) {
|
|
110
|
+
const linkAbsolutePath = resolveRelativePath(yamlFile, link);
|
|
111
|
+
const linkRootPath = linkAbsolutePath.replace(`${inputFolderPath}${sep}`, '');
|
|
112
|
+
|
|
113
|
+
acc.push(linkRootPath);
|
|
114
|
+
}
|
|
115
|
+
return acc;
|
|
116
|
+
},
|
|
117
|
+
|
|
118
|
+
[],
|
|
106
119
|
);
|
|
107
120
|
|
|
108
|
-
copyFiles(
|
|
109
|
-
args.input,
|
|
110
|
-
tmpOutputFolder,
|
|
111
|
-
localMediaLinks.filter((link) => checkPathExists(link, yamlFile)),
|
|
112
|
-
);
|
|
121
|
+
copyFiles(args.input, tmpOutputFolder, localMediaLinks);
|
|
113
122
|
});
|
|
114
123
|
}
|
|
115
124
|
|