@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.
- package/CHANGELOG.md +785 -0
- package/LICENSE +21 -0
- package/README.md +62 -0
- package/README.ru.md +63 -0
- package/build/app.client.css +47 -0
- package/build/app.client.js +3 -0
- package/build/index.js +3993 -0
- package/build/index.js.map +7 -0
- package/build/lib.js +3374 -0
- package/build/lib.js.map +7 -0
- package/build/linter.js +1265 -0
- package/build/linter.js.map +7 -0
- package/package.json +126 -0
- package/src/cmd/build/index.ts +304 -0
- package/src/cmd/index.ts +4 -0
- package/src/cmd/publish/index.ts +92 -0
- package/src/cmd/publish/upload.ts +61 -0
- package/src/cmd/translate/index.ts +261 -0
- package/src/cmd/xliff/compose.ts +222 -0
- package/src/cmd/xliff/extract.ts +237 -0
- package/src/cmd/xliff/index.ts +27 -0
- package/src/constants.ts +122 -0
- package/src/globals.d.ts +1 -0
- package/src/index.ts +54 -0
- package/src/models.ts +249 -0
- package/src/packages/credentials/index.ts +1 -0
- package/src/packages/credentials/yandex-oauth.ts +42 -0
- package/src/resolvers/index.ts +3 -0
- package/src/resolvers/lintPage.ts +119 -0
- package/src/resolvers/md2html.ts +142 -0
- package/src/resolvers/md2md.ts +147 -0
- package/src/services/argv.ts +38 -0
- package/src/services/authors.ts +64 -0
- package/src/services/contributors.ts +104 -0
- package/src/services/includers/batteries/common.ts +34 -0
- package/src/services/includers/batteries/generic.ts +130 -0
- package/src/services/includers/batteries/index.ts +3 -0
- package/src/services/includers/batteries/sourcedocs.ts +33 -0
- package/src/services/includers/batteries/unarchive.ts +97 -0
- package/src/services/includers/index.ts +157 -0
- package/src/services/index.ts +6 -0
- package/src/services/leading.ts +88 -0
- package/src/services/metadata.ts +249 -0
- package/src/services/plugins.ts +76 -0
- package/src/services/preset.ts +55 -0
- package/src/services/tocs.ts +401 -0
- package/src/services/utils.ts +151 -0
- package/src/steps/index.ts +6 -0
- package/src/steps/processAssets.ts +36 -0
- package/src/steps/processExcludedFiles.ts +47 -0
- package/src/steps/processLinter.ts +100 -0
- package/src/steps/processLogs.ts +18 -0
- package/src/steps/processMapFile.ts +35 -0
- package/src/steps/processPages.ts +312 -0
- package/src/steps/processServiceFiles.ts +95 -0
- package/src/steps/publishFilesToS3.ts +47 -0
- package/src/utils/file.ts +17 -0
- package/src/utils/glob.ts +14 -0
- package/src/utils/index.ts +8 -0
- package/src/utils/logger.ts +42 -0
- package/src/utils/markup.ts +125 -0
- package/src/utils/path.ts +24 -0
- package/src/utils/presets.ts +20 -0
- package/src/utils/singlePage.ts +228 -0
- package/src/utils/toc.ts +87 -0
- package/src/utils/url.ts +3 -0
- package/src/utils/worker.ts +10 -0
- package/src/validator.ts +150 -0
- package/src/vcs-connector/client/github.ts +52 -0
- package/src/vcs-connector/connector-models.ts +76 -0
- package/src/vcs-connector/connector-validator.ts +114 -0
- package/src/vcs-connector/github.ts +333 -0
- package/src/vcs-connector/index.ts +15 -0
- package/src/workers/linter/index.ts +62 -0
|
@@ -0,0 +1,304 @@
|
|
|
1
|
+
import {Arguments, Argv} from 'yargs';
|
|
2
|
+
import {
|
|
3
|
+
BUNDLE_FOLDER, LINT_CONFIG_FILENAME,
|
|
4
|
+
REDIRECTS_FILENAME,
|
|
5
|
+
Stage,
|
|
6
|
+
TMP_INPUT_FOLDER,
|
|
7
|
+
TMP_OUTPUT_FOLDER,
|
|
8
|
+
YFM_CONFIG_FILENAME,
|
|
9
|
+
} from '../../constants';
|
|
10
|
+
import {argvValidator} from '../../validator';
|
|
11
|
+
import {join, resolve} from 'path';
|
|
12
|
+
import {ArgvService, Includers} from '../../services';
|
|
13
|
+
import OpenapiIncluder from '@diplodoc/openapi-extension/includer';
|
|
14
|
+
import {
|
|
15
|
+
initLinterWorkers,
|
|
16
|
+
processAssets,
|
|
17
|
+
processExcludedFiles,
|
|
18
|
+
processLinter, processLogs,
|
|
19
|
+
processPages,
|
|
20
|
+
processServiceFiles,
|
|
21
|
+
} from '../../steps';
|
|
22
|
+
import {prepareMapFile} from '../../steps/processMapFile';
|
|
23
|
+
import shell from 'shelljs';
|
|
24
|
+
import {Resources} from '../../models';
|
|
25
|
+
import {copyFiles, logger} from '../../utils';
|
|
26
|
+
import {upload as publishFilesToS3} from '../publish/upload';
|
|
27
|
+
import glob from 'glob';
|
|
28
|
+
|
|
29
|
+
export const build = {
|
|
30
|
+
command: ['build', '$0'],
|
|
31
|
+
description: 'Build documentation in target directory',
|
|
32
|
+
handler,
|
|
33
|
+
builder,
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
function builder<T>(argv: Argv<T>) {
|
|
37
|
+
return argv
|
|
38
|
+
.option('input', {
|
|
39
|
+
alias: 'i',
|
|
40
|
+
describe: 'Path to input folder with .md files',
|
|
41
|
+
type: 'string',
|
|
42
|
+
group: 'Build options:',
|
|
43
|
+
})
|
|
44
|
+
.option('output', {
|
|
45
|
+
alias: 'o',
|
|
46
|
+
describe: 'Path to output folder',
|
|
47
|
+
type: 'string',
|
|
48
|
+
group: 'Build options:',
|
|
49
|
+
})
|
|
50
|
+
.option('varsPreset', {
|
|
51
|
+
default: 'default',
|
|
52
|
+
describe: 'Target vars preset of documentation <external|internal>',
|
|
53
|
+
group: 'Build options:',
|
|
54
|
+
})
|
|
55
|
+
.option('output-format', {
|
|
56
|
+
default: 'html',
|
|
57
|
+
describe: 'Format of output file <html|md>',
|
|
58
|
+
group: 'Build options:',
|
|
59
|
+
})
|
|
60
|
+
.option('vars', {
|
|
61
|
+
alias: 'v',
|
|
62
|
+
default: '{}',
|
|
63
|
+
describe: 'List of markdown variables',
|
|
64
|
+
group: 'Build options:',
|
|
65
|
+
})
|
|
66
|
+
.option('apply-presets', {
|
|
67
|
+
default: true,
|
|
68
|
+
describe: 'Should apply presets. Only for --output-format=md',
|
|
69
|
+
type: 'boolean',
|
|
70
|
+
group: 'Build options:',
|
|
71
|
+
})
|
|
72
|
+
.option('resolve-conditions', {
|
|
73
|
+
default: true,
|
|
74
|
+
describe: 'Should resolve conditions. Only for --output-format=md',
|
|
75
|
+
type: 'boolean',
|
|
76
|
+
group: 'Build options:',
|
|
77
|
+
})
|
|
78
|
+
.option('conditions-in-code', {
|
|
79
|
+
default: false,
|
|
80
|
+
describe: 'Meet conditions in code blocks',
|
|
81
|
+
type: 'boolean',
|
|
82
|
+
group: 'Build options:',
|
|
83
|
+
})
|
|
84
|
+
.option('disable-liquid', {
|
|
85
|
+
default: false,
|
|
86
|
+
describe: 'Disable template engine',
|
|
87
|
+
type: 'boolean',
|
|
88
|
+
group: 'Build options:',
|
|
89
|
+
})
|
|
90
|
+
.option('allowHTML', {
|
|
91
|
+
default: false,
|
|
92
|
+
describe: 'Allow to use HTML in Markdown files',
|
|
93
|
+
type: 'boolean',
|
|
94
|
+
group: 'Build options:',
|
|
95
|
+
})
|
|
96
|
+
.option('ignore-stage', {
|
|
97
|
+
default: Stage.SKIP,
|
|
98
|
+
describe: 'Ignore tocs with stage',
|
|
99
|
+
group: 'Build options:',
|
|
100
|
+
})
|
|
101
|
+
.option('ignore-author-patterns', {
|
|
102
|
+
default: [] as string[],
|
|
103
|
+
describe: 'Ignore authors if they contain passed string',
|
|
104
|
+
group: 'Build options:',
|
|
105
|
+
type: 'array',
|
|
106
|
+
})
|
|
107
|
+
.option('contributors', {
|
|
108
|
+
default: false,
|
|
109
|
+
describe: 'Should attach contributors into files',
|
|
110
|
+
type: 'boolean',
|
|
111
|
+
group: 'Build options:',
|
|
112
|
+
})
|
|
113
|
+
.option('add-system-meta', {
|
|
114
|
+
default: false,
|
|
115
|
+
describe: 'Should add system section variables form presets into files meta data',
|
|
116
|
+
type: 'boolean',
|
|
117
|
+
group: 'Build options:',
|
|
118
|
+
})
|
|
119
|
+
.option('add-map-file', {
|
|
120
|
+
default: false,
|
|
121
|
+
describe: 'Should add all paths of documentation into file.json',
|
|
122
|
+
type: 'boolean',
|
|
123
|
+
group: 'Build options:',
|
|
124
|
+
})
|
|
125
|
+
.option('single-page', {
|
|
126
|
+
default: false,
|
|
127
|
+
describe: 'Beta functionality: Build a single page in the output folder also',
|
|
128
|
+
type: 'boolean',
|
|
129
|
+
group: 'Build options:',
|
|
130
|
+
})
|
|
131
|
+
.option('publish', {
|
|
132
|
+
default: false,
|
|
133
|
+
describe: 'Should upload output files to S3 storage',
|
|
134
|
+
type: 'boolean',
|
|
135
|
+
group: 'Build options:',
|
|
136
|
+
})
|
|
137
|
+
.option('remove-hidden-toc-items', {
|
|
138
|
+
default: false,
|
|
139
|
+
describe: 'Remove hidden toc items',
|
|
140
|
+
type: 'boolean',
|
|
141
|
+
group: 'Build options:',
|
|
142
|
+
})
|
|
143
|
+
.option('lint-disabled', {
|
|
144
|
+
default: false,
|
|
145
|
+
describe: 'Disable linting',
|
|
146
|
+
type: 'boolean',
|
|
147
|
+
group: 'Build options:',
|
|
148
|
+
})
|
|
149
|
+
.option('build-disabled', {
|
|
150
|
+
default: false,
|
|
151
|
+
describe: 'Disable building',
|
|
152
|
+
type: 'boolean',
|
|
153
|
+
group: 'Build options:',
|
|
154
|
+
})
|
|
155
|
+
.option('allow-custom-resources', {
|
|
156
|
+
default: false,
|
|
157
|
+
describe: 'Allow loading custom resources',
|
|
158
|
+
type: 'boolean',
|
|
159
|
+
group: 'Build options:',
|
|
160
|
+
})
|
|
161
|
+
.option('static-content', {
|
|
162
|
+
default: false,
|
|
163
|
+
describe: 'Include static content in the page',
|
|
164
|
+
type: 'boolean',
|
|
165
|
+
group: 'Build options:',
|
|
166
|
+
})
|
|
167
|
+
.check(argvValidator)
|
|
168
|
+
.example('yfm -i ./input -o ./output', '')
|
|
169
|
+
.demandOption(['input', 'output'], 'Please provide input and output arguments to work with this tool');
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
async function handler(args: Arguments<any>) {
|
|
173
|
+
const userOutputFolder = resolve(args.output);
|
|
174
|
+
const tmpInputFolder = resolve(args.output, TMP_INPUT_FOLDER);
|
|
175
|
+
const tmpOutputFolder = resolve(args.output, TMP_OUTPUT_FOLDER);
|
|
176
|
+
|
|
177
|
+
try {
|
|
178
|
+
ArgvService.init({
|
|
179
|
+
...args,
|
|
180
|
+
rootInput: args.input,
|
|
181
|
+
input: tmpInputFolder,
|
|
182
|
+
output: tmpOutputFolder,
|
|
183
|
+
});
|
|
184
|
+
Includers.init([OpenapiIncluder as any]);
|
|
185
|
+
|
|
186
|
+
const {
|
|
187
|
+
output: outputFolderPath,
|
|
188
|
+
outputFormat,
|
|
189
|
+
publish,
|
|
190
|
+
lintDisabled,
|
|
191
|
+
buildDisabled,
|
|
192
|
+
addMapFile,
|
|
193
|
+
allowCustomResources,
|
|
194
|
+
resources,
|
|
195
|
+
} = ArgvService.getConfig();
|
|
196
|
+
|
|
197
|
+
preparingTemporaryFolders(userOutputFolder);
|
|
198
|
+
|
|
199
|
+
await processServiceFiles();
|
|
200
|
+
processExcludedFiles();
|
|
201
|
+
|
|
202
|
+
if (addMapFile) {
|
|
203
|
+
prepareMapFile();
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
const outputBundlePath = join(outputFolderPath, BUNDLE_FOLDER);
|
|
207
|
+
const pathToConfig = args.config || join(args.input, YFM_CONFIG_FILENAME);
|
|
208
|
+
const pathToRedirects = join(args.input, REDIRECTS_FILENAME);
|
|
209
|
+
const pathToLintConfig = join(args.input, LINT_CONFIG_FILENAME);
|
|
210
|
+
|
|
211
|
+
if (!lintDisabled) {
|
|
212
|
+
/* Initialize workers in advance to avoid a timeout failure due to not receiving a message from them */
|
|
213
|
+
await initLinterWorkers();
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
const processes = [
|
|
217
|
+
!lintDisabled && processLinter(),
|
|
218
|
+
!buildDisabled && processPages(outputBundlePath),
|
|
219
|
+
].filter(Boolean) as Promise<void>[];
|
|
220
|
+
|
|
221
|
+
await Promise.all(processes);
|
|
222
|
+
|
|
223
|
+
if (!buildDisabled) {
|
|
224
|
+
// process additional files
|
|
225
|
+
switch (outputFormat) {
|
|
226
|
+
case 'html':
|
|
227
|
+
processAssets(outputBundlePath);
|
|
228
|
+
break;
|
|
229
|
+
case 'md': {
|
|
230
|
+
shell.cp(resolve(pathToConfig), tmpOutputFolder);
|
|
231
|
+
shell.cp(resolve(pathToRedirects), tmpOutputFolder);
|
|
232
|
+
shell.cp(resolve(pathToLintConfig), tmpOutputFolder);
|
|
233
|
+
|
|
234
|
+
if (resources && allowCustomResources) {
|
|
235
|
+
const resourcePaths: string[] = [];
|
|
236
|
+
|
|
237
|
+
// collect paths of all resources
|
|
238
|
+
Object.keys(resources).forEach((type) =>
|
|
239
|
+
resources[type as keyof Resources]?.forEach((path: string) => resourcePaths.push(path)));
|
|
240
|
+
|
|
241
|
+
//copy resources
|
|
242
|
+
copyFiles(args.input, tmpOutputFolder, resourcePaths);
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
break;
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
// Copy all generated files to user' output folder
|
|
250
|
+
shell.cp('-r', [join(tmpOutputFolder, '*'), join(tmpOutputFolder, '.*')], userOutputFolder);
|
|
251
|
+
|
|
252
|
+
if (publish) {
|
|
253
|
+
const DEFAULT_PREFIX = process.env.YFM_STORAGE_PREFIX ?? '';
|
|
254
|
+
const {
|
|
255
|
+
ignore = [],
|
|
256
|
+
storageRegion,
|
|
257
|
+
storageEndpoint: endpoint,
|
|
258
|
+
storageBucket: bucket,
|
|
259
|
+
storagePrefix: prefix = DEFAULT_PREFIX,
|
|
260
|
+
storageKeyId: accessKeyId,
|
|
261
|
+
storageSecretKey: secretAccessKey,
|
|
262
|
+
} = ArgvService.getConfig();
|
|
263
|
+
|
|
264
|
+
await publishFilesToS3({
|
|
265
|
+
input: userOutputFolder,
|
|
266
|
+
region: storageRegion,
|
|
267
|
+
ignore,
|
|
268
|
+
endpoint,
|
|
269
|
+
bucket,
|
|
270
|
+
prefix,
|
|
271
|
+
accessKeyId,
|
|
272
|
+
secretAccessKey,
|
|
273
|
+
});
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
} catch (err) {
|
|
277
|
+
logger.error('', err.message);
|
|
278
|
+
} finally {
|
|
279
|
+
processLogs(tmpInputFolder);
|
|
280
|
+
|
|
281
|
+
shell.rm('-rf', tmpInputFolder, tmpOutputFolder);
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
function preparingTemporaryFolders(userOutputFolder: string) {
|
|
286
|
+
const args = ArgvService.getConfig();
|
|
287
|
+
|
|
288
|
+
shell.mkdir('-p', userOutputFolder);
|
|
289
|
+
|
|
290
|
+
// Create temporary input/output folders
|
|
291
|
+
shell.rm('-rf', args.input, args.output);
|
|
292
|
+
shell.mkdir(args.input, args.output);
|
|
293
|
+
shell.chmod('-R', 'u+w', args.input);
|
|
294
|
+
|
|
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
|
+
}));
|
|
304
|
+
}
|
package/src/cmd/index.ts
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import {join} from 'path';
|
|
2
|
+
import {ArgvService} from '../../services';
|
|
3
|
+
import {logger} from '../../utils';
|
|
4
|
+
|
|
5
|
+
import {Argv, Arguments} from 'yargs';
|
|
6
|
+
|
|
7
|
+
import {upload} from './upload';
|
|
8
|
+
|
|
9
|
+
const command = 'publish';
|
|
10
|
+
|
|
11
|
+
const description = 'Upload builded documentation to target S3 bucket';
|
|
12
|
+
|
|
13
|
+
const publish = {
|
|
14
|
+
command,
|
|
15
|
+
description,
|
|
16
|
+
handler,
|
|
17
|
+
builder,
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
function builder<T>(argv: Argv<T>) {
|
|
21
|
+
return argv
|
|
22
|
+
.option('strict', {
|
|
23
|
+
default: true,
|
|
24
|
+
})
|
|
25
|
+
.option('input', {
|
|
26
|
+
alias: 'i',
|
|
27
|
+
describe: 'Path to folder with builded files',
|
|
28
|
+
type: 'string',
|
|
29
|
+
required: true,
|
|
30
|
+
group: 'Upload options',
|
|
31
|
+
})
|
|
32
|
+
.option('endpoint', {
|
|
33
|
+
describe: 'S3 bucket endpoint',
|
|
34
|
+
default: 'https://s3.amazonaws.com',
|
|
35
|
+
type: 'string',
|
|
36
|
+
group: 'Upload options',
|
|
37
|
+
})
|
|
38
|
+
.option('region', {
|
|
39
|
+
describe: 'S3 bucket region',
|
|
40
|
+
default: 'eu-central-1',
|
|
41
|
+
type: 'string',
|
|
42
|
+
group: 'Upload options',
|
|
43
|
+
})
|
|
44
|
+
.option('bucket', {
|
|
45
|
+
describe: 'S3 bucket name',
|
|
46
|
+
type: 'string',
|
|
47
|
+
required: true,
|
|
48
|
+
group: 'Upload options',
|
|
49
|
+
})
|
|
50
|
+
.option('prefix', {
|
|
51
|
+
describe: 'S3 bucket ',
|
|
52
|
+
default: '',
|
|
53
|
+
type: 'string',
|
|
54
|
+
group: 'Upload options',
|
|
55
|
+
})
|
|
56
|
+
.option('access-key-id', {
|
|
57
|
+
describe: 'S3 bucket AccessKeyId',
|
|
58
|
+
type: 'string',
|
|
59
|
+
required: true,
|
|
60
|
+
group: 'Upload options',
|
|
61
|
+
})
|
|
62
|
+
.option('secret-access-key', {
|
|
63
|
+
describe: 'S3 bucket SecretAccessKey',
|
|
64
|
+
type: 'string',
|
|
65
|
+
required: true,
|
|
66
|
+
group: 'Upload options',
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/* eslint-disable-next-line @typescript-eslint/no-explicit-any */
|
|
71
|
+
async function handler(args: Arguments<any>) {
|
|
72
|
+
ArgvService.init({
|
|
73
|
+
...args,
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
const {
|
|
77
|
+
input,
|
|
78
|
+
endpoint,
|
|
79
|
+
bucket,
|
|
80
|
+
prefix,
|
|
81
|
+
} = ArgvService.getConfig();
|
|
82
|
+
|
|
83
|
+
logger.info('', `Upload artifacts from ${input} to ${join(endpoint, bucket, prefix)}`);
|
|
84
|
+
|
|
85
|
+
try {
|
|
86
|
+
await upload(ArgvService.getConfig());
|
|
87
|
+
} catch (error) {
|
|
88
|
+
logger.error('', error.message);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
export {publish};
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import {createReadStream} from 'fs';
|
|
2
|
+
import walkSync from 'walk-sync';
|
|
3
|
+
import {resolve, join} from 'path';
|
|
4
|
+
import {S3Client, PutObjectCommand} from '@aws-sdk/client-s3';
|
|
5
|
+
import mime from 'mime-types';
|
|
6
|
+
|
|
7
|
+
import {convertBackSlashToSlash, logger} from '../../utils';
|
|
8
|
+
import {asyncify, mapLimit} from 'async';
|
|
9
|
+
|
|
10
|
+
interface UploadProps {
|
|
11
|
+
input: string;
|
|
12
|
+
ignore: string[];
|
|
13
|
+
endpoint: string;
|
|
14
|
+
bucket: string;
|
|
15
|
+
prefix: string;
|
|
16
|
+
accessKeyId: string;
|
|
17
|
+
secretAccessKey: string;
|
|
18
|
+
region: string;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export async function upload(props: UploadProps): Promise<void> {
|
|
22
|
+
const {
|
|
23
|
+
input,
|
|
24
|
+
ignore = [],
|
|
25
|
+
endpoint,
|
|
26
|
+
region,
|
|
27
|
+
bucket,
|
|
28
|
+
prefix,
|
|
29
|
+
accessKeyId,
|
|
30
|
+
secretAccessKey,
|
|
31
|
+
} = props;
|
|
32
|
+
|
|
33
|
+
const s3Client = new S3Client({
|
|
34
|
+
endpoint,
|
|
35
|
+
region,
|
|
36
|
+
credentials: {accessKeyId, secretAccessKey},
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
const filesToPublish: string[] = walkSync(resolve(input), {
|
|
40
|
+
directories: false,
|
|
41
|
+
includeBasePath: false,
|
|
42
|
+
ignore,
|
|
43
|
+
});
|
|
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
|
+
}));
|
|
61
|
+
}
|