@diplodoc/cli 4.6.3 → 4.7.0-beta-1

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/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.6.3",
6
+ "version": "4.7.0-beta-1",
7
7
  "repository": {
8
8
  "type": "git",
9
9
  "url": "git@github.com:diplodoc-platform/cli.git"
@@ -14,6 +14,7 @@
14
14
  "main": "build/index.js",
15
15
  "files": [
16
16
  "build",
17
+ "assets",
17
18
  "src"
18
19
  ],
19
20
  "scripts": {
@@ -25,27 +26,21 @@
25
26
  "git:head": "git checkout master && git pull"
26
27
  },
27
28
  "engines": {
28
- "node": ">=18.*",
29
- "npm:": ">=9.*"
29
+ "node": ">=18.*"
30
30
  },
31
31
  "dependencies": {
32
- "@apidevtools/swagger-parser": "^10.1.0",
33
32
  "@aws-sdk/client-s3": "^3.369.0",
34
- "@diplodoc/client": "^1.0.2",
35
- "@diplodoc/markdown-translation": "^1.0.1",
36
- "@diplodoc/mermaid-extension": "^1.1.3",
37
- "@diplodoc/openapi-extension": "^1.4.4",
38
- "@diplodoc/transform": "^4.3.0",
33
+ "@diplodoc/client": "^2.0.0-beta-1",
34
+ "@diplodoc/latex-extension": "^1.0.0",
35
+ "@diplodoc/markdown-translation": "^1.0.2",
36
+ "@diplodoc/mermaid-extension": "^1.2.1",
37
+ "@diplodoc/openapi-extension": "^1.4.10",
38
+ "@diplodoc/transform": "^4.7.3",
39
39
  "@octokit/core": "4.2.4",
40
- "@types/glob": "^8.0.0",
41
- "@types/json-stringify-safe": "^5.0.0",
42
40
  "@yandex-cloud/nodejs-sdk": "^2.2.2",
43
41
  "ajv": "^8.11.0",
44
42
  "async": "^3.2.4",
45
- "aws-sdk": "^2.1425.0",
46
- "bem-cn-lite": "^4.1.0",
47
43
  "chalk": "4.1.2",
48
- "dotenv": "^16.0.3",
49
44
  "fast-xml-parser": "^4.0.11",
50
45
  "glob": "^8.0.3",
51
46
  "highlight.js": "^11.7.0",
@@ -66,13 +61,15 @@
66
61
  "yargs": "17.7.2"
67
62
  },
68
63
  "devDependencies": {
69
- "@diplodoc/eslint-config": "^1.0.14",
70
- "@diplodoc/prettier-config": "^1.0.0",
64
+ "@diplodoc/eslint-config": "^2.0.0",
65
+ "@diplodoc/prettier-config": "^2.0.0",
71
66
  "@diplodoc/tsconfig": "^1.0.2",
72
67
  "@types/async": "^3.2.15",
73
68
  "@types/chalk": "2.2.0",
69
+ "@types/glob": "^8.1.0",
74
70
  "@types/html-escaper": "^3.0.0",
75
71
  "@types/js-yaml": "4.0.5",
72
+ "@types/json-stringify-safe": "^5.0.3",
76
73
  "@types/lodash": "4.14.195",
77
74
  "@types/mime-types": "2.1.1",
78
75
  "@types/node": "14.*",
@@ -80,21 +77,11 @@
80
77
  "@types/tar-stream": "^2.2.2",
81
78
  "@types/yargs": "17.0.24",
82
79
  "esbuild": "^0.17.17",
83
- "eslint": "^8.0.0",
84
80
  "husky": "8.0.3",
85
81
  "lint-staged": "13.2.2",
86
82
  "lodash": "4.17.21",
87
- "prettier": "^3.0.3",
88
- "ts-jest": "29.1.0",
89
- "ts-node": "^10.9.1",
90
83
  "typescript": "4.9.5"
91
84
  },
92
- "overrides": {
93
- "react-sortable-hoc": {
94
- "react": "^18.2.0",
95
- "react-dom": "^18.2.0"
96
- }
97
- },
98
85
  "husky": {
99
86
  "hooks": {
100
87
  "pre-commit": "lint-staged"
@@ -106,20 +93,6 @@
106
93
  "git add"
107
94
  ]
108
95
  },
109
- "pkg": {
110
- "scripts": [
111
- "build/index.js",
112
- "build/linter.js",
113
- "build/plugins/*.js",
114
- "build/lint-rules/*.js",
115
- "build/default-lint-config.js",
116
- "build/head-content.js"
117
- ],
118
- "assets": [
119
- "build/app.client.js",
120
- "build/app.client.css"
121
- ]
122
- },
123
96
  "keywords": [
124
97
  "markdown",
125
98
  "yandex",
package/src/constants.ts CHANGED
@@ -1,4 +1,4 @@
1
- import {dirname} from 'path';
1
+ import {resolve} from 'path';
2
2
  const os = require('os');
3
3
  const notes = require('@diplodoc/transform/lib/plugins/notes');
4
4
  const anchors = require('@diplodoc/transform/lib/plugins/anchors');
@@ -18,16 +18,15 @@ const table = require('@diplodoc/transform/lib/plugins/table');
18
18
  const term = require('@diplodoc/transform/lib/plugins/term');
19
19
  const changelog = require('@diplodoc/transform/lib/plugins/changelog');
20
20
  const mermaid = require('@diplodoc/mermaid-extension');
21
+ const latex = require('@diplodoc/latex-extension');
21
22
  const openapi = require('@diplodoc/openapi-extension');
22
23
 
23
24
  includes.collect = require('@diplodoc/transform/lib/plugins/includes/collect');
24
25
  images.collect = require('@diplodoc/transform/lib/plugins/images/collect');
25
26
  changelog.collect = require('@diplodoc/transform/lib/plugins/changelog/collect');
26
27
 
27
- export const BUILD_FOLDER = 'build';
28
+ export const ASSETS_FOLDER = resolve(__dirname, '../assets');
28
29
  export const BUNDLE_FOLDER = '_bundle';
29
- export const BUNDLE_JS_FILENAME = 'app.client.js';
30
- export const BUNDLE_CSS_FILENAME = 'app.client.css';
31
30
  export const TMP_INPUT_FOLDER = '.tmp_input';
32
31
  export const TMP_OUTPUT_FOLDER = '.tmp_output';
33
32
  export const MAIN_TIMER_ID = 'Build time';
@@ -67,8 +66,6 @@ export enum ResourceType {
67
66
  script = 'script',
68
67
  }
69
68
 
70
- export const BUILD_FOLDER_PATH = dirname(require.resolve('@diplodoc/client'));
71
-
72
69
  export const YFM_PLUGINS = [
73
70
  meta,
74
71
  deflist,
@@ -88,6 +85,7 @@ export const YFM_PLUGINS = [
88
85
  term,
89
86
  openapi.transform(),
90
87
  mermaid.transform(),
88
+ latex.transform(),
91
89
  changelog,
92
90
  ];
93
91
 
@@ -1,10 +1,11 @@
1
1
  import walkSync from 'walk-sync';
2
2
  import shell from 'shelljs';
3
3
 
4
- import client from '../../scripts/client';
5
4
  import {ArgvService} from '../services';
6
5
  import {copyFiles} from '../utils';
7
6
 
7
+ import {ASSETS_FOLDER} from '../constants';
8
+
8
9
  /**
9
10
  * Processes assets files (everything except .yaml and .md files)
10
11
  * @param {string} outputBundlePath
@@ -23,8 +24,5 @@ export function processAssets(outputBundlePath: string) {
23
24
 
24
25
  /* Copy js bundle to user' output folder */
25
26
  shell.mkdir('-p', outputBundlePath);
26
-
27
- for (const path of Object.values(client.dst)) {
28
- shell.cp(path, outputBundlePath);
29
- }
27
+ shell.cp(ASSETS_FOLDER + '/*', outputBundlePath);
30
28
  }
@@ -1,11 +1,15 @@
1
+ import {join} from 'path';
1
2
  import {platform} from 'process';
2
3
 
3
4
  import {CUSTOM_STYLE, Platforms, ResourceType} from '../constants';
4
5
  import {Resources, SinglePageResult} from '../models';
5
6
  import {ArgvService, PluginService} from '../services';
6
7
  import {preprocessPageHtmlForSinglePage} from './singlePage';
7
- import {DocInnerProps, DocPageData, render} from '@diplodoc/client';
8
- import client from '../../scripts/client';
8
+
9
+ import {DocInnerProps, DocPageData, render} from '@diplodoc/client/ssr';
10
+ import manifest from '@diplodoc/client/manifest';
11
+
12
+ const dst = (bundlePath: string) => (target: string) => join(bundlePath, target);
9
13
 
10
14
  export interface TitleMeta {
11
15
  title?: string;
@@ -44,7 +48,10 @@ export function generateStaticMarkup(
44
48
  height: 100vh;
45
49
  }
46
50
  </style>
47
- <link type="text/css" rel="stylesheet" href="${client.bundle.css(pathToBundle)}" />
51
+ ${manifest.css
52
+ .map(dst(pathToBundle))
53
+ .map((src: string) => `<link type="text/css" rel="stylesheet" href="${src}" />`)
54
+ .join('\n')}
48
55
  ${PluginService.getHeadContent()}
49
56
  ${resources}
50
57
  </head>
@@ -54,9 +61,13 @@ export function generateStaticMarkup(
54
61
  window.STATIC_CONTENT = ${staticContent}
55
62
  window.__DATA__ = ${JSON.stringify(props)};
56
63
  </script>
57
- <script type="application/javascript" src="${client.bundle.js(
58
- pathToBundle,
59
- )}"></script>
64
+ ${manifest.js
65
+ .map(dst(pathToBundle))
66
+ .map(
67
+ (src: string) =>
68
+ `<script type="application/javascript" src="${src}"></script>`,
69
+ )
70
+ .join('\n')}
60
71
  </body>
61
72
  </html>
62
73
  `;
@@ -1,51 +0,0 @@
1
- import {readFileSync} from 'fs';
2
- import walkSync from 'walk-sync';
3
- import {join, resolve} from 'path';
4
- import S3 from 'aws-sdk/clients/s3';
5
- import mime from 'mime-types';
6
-
7
- import {ArgvService} from '../services';
8
- import {convertBackSlashToSlash, logger} from '../utils';
9
-
10
- const DEFAULT_PREFIX = process.env.YFM_STORAGE_PREFIX ?? '';
11
-
12
- export async function publishFilesToS3(): Promise<void> {
13
- const {
14
- output: outputFolderPath,
15
- ignore = [],
16
- storageEndpoint: endpoint,
17
- storageBucket: bucket,
18
- storagePrefix: prefix = DEFAULT_PREFIX,
19
- storageKeyId: accessKeyId,
20
- storageSecretKey: secretAccessKey,
21
- } = ArgvService.getConfig();
22
-
23
- const s3Client = new S3({
24
- endpoint,
25
- accessKeyId,
26
- secretAccessKey,
27
- });
28
-
29
- const filesToPublish: string[] = walkSync(resolve(outputFolderPath), {
30
- directories: false,
31
- includeBasePath: false,
32
- ignore,
33
- });
34
-
35
- await Promise.all(
36
- filesToPublish.map(async (pathToFile) => {
37
- const mimeType = mime.lookup(pathToFile);
38
-
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
- };
45
-
46
- logger.upload(pathToFile);
47
-
48
- return s3Client.upload(params).promise();
49
- }),
50
- );
51
- }