@modern-js/plugin-docsite 1.2.3 → 1.2.6
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 +41 -0
- package/dist/js/modern/features/build.js +1 -2
- package/dist/js/modern/features/dev.js +1 -2
- package/dist/js/modern/features/index.js +1 -2
- package/dist/js/modern/features/utils/chokidar.js +2 -5
- package/dist/js/modern/features/utils/generate-files.js +5 -15
- package/dist/js/modern/features/utils/valid.js +1 -2
- package/dist/js/modern/index.js +45 -45
- package/dist/js/node/features/build.js +1 -2
- package/dist/js/node/features/dev.js +0 -1
- package/dist/js/node/features/index.js +1 -3
- package/dist/js/node/features/utils/chokidar.js +3 -8
- package/dist/js/node/features/utils/generate-files.js +6 -15
- package/dist/js/node/features/utils/valid.js +1 -7
- package/dist/js/node/index.js +44 -45
- package/dist/types/index.d.ts +3 -18
- package/jest.config.js +0 -1
- package/package.json +8 -17
package/CHANGELOG.md
CHANGED
@@ -1,5 +1,46 @@
|
|
1
1
|
# @modern-js/plugin-docsite
|
2
2
|
|
3
|
+
## 1.2.6
|
4
|
+
|
5
|
+
### Patch Changes
|
6
|
+
|
7
|
+
- 17d0cc46: feat: prebundle lodash to @modern-js/utils/lodash
|
8
|
+
- Updated dependencies [ec1b7367]
|
9
|
+
- Updated dependencies [77ff9754]
|
10
|
+
- Updated dependencies [d2d1d6b2]
|
11
|
+
- Updated dependencies [07a4887e]
|
12
|
+
- Updated dependencies [ea2ae711]
|
13
|
+
- Updated dependencies [17d0cc46]
|
14
|
+
- Updated dependencies [d2d1d6b2]
|
15
|
+
- @modern-js/webpack@1.5.4
|
16
|
+
- @modern-js/utils@1.4.0
|
17
|
+
|
18
|
+
## 1.2.5
|
19
|
+
|
20
|
+
### Patch Changes
|
21
|
+
|
22
|
+
- bebb39b6: chore: improve devDependencies and peerDependencies
|
23
|
+
- 133a5dd7: remove module hooks dep
|
24
|
+
- Updated dependencies [bebb39b6]
|
25
|
+
- Updated dependencies [4b4e73b7]
|
26
|
+
- Updated dependencies [da60172c]
|
27
|
+
- Updated dependencies [6cff93dc]
|
28
|
+
- Updated dependencies [132f7b53]
|
29
|
+
- Updated dependencies [9d4a005b]
|
30
|
+
- @modern-js/webpack@1.5.3
|
31
|
+
- @modern-js/utils@1.3.7
|
32
|
+
|
33
|
+
## 1.2.4
|
34
|
+
|
35
|
+
### Patch Changes
|
36
|
+
|
37
|
+
- 3e6d9f6d: convert to new plugin
|
38
|
+
- 681a1ff9: feat: remove unnecessary peerDependencies
|
39
|
+
- Updated dependencies [c2046f37]
|
40
|
+
- Updated dependencies [66cbef42]
|
41
|
+
- @modern-js/utils@1.3.6
|
42
|
+
- @modern-js/webpack@1.5.0
|
43
|
+
|
3
44
|
## 1.2.3
|
4
45
|
|
5
46
|
### Patch Changes
|
@@ -1,7 +1,6 @@
|
|
1
1
|
import { logger, Import, chalk } from '@modern-js/utils';
|
2
2
|
const wp = Import.lazy('./utils/webpack', require);
|
3
|
-
const gen = Import.lazy('./utils/generate-files', require);
|
4
|
-
|
3
|
+
const gen = Import.lazy('./utils/generate-files', require);
|
5
4
|
export async function build(appDirectory, tmpDir, files, webpackConfig, isDev) {
|
6
5
|
const meta = await gen.generateFiles(appDirectory, tmpDir, files, isDev);
|
7
6
|
|
@@ -3,8 +3,7 @@ import { logger } from '@modern-js/utils';
|
|
3
3
|
import webpack from 'webpack';
|
4
4
|
import WebpackDevServer from 'webpack-dev-server';
|
5
5
|
import { chokidarFile } from "./utils/chokidar";
|
6
|
-
import { generateFiles } from "./utils/generate-files";
|
7
|
-
|
6
|
+
import { generateFiles } from "./utils/generate-files";
|
8
7
|
export async function dev(appDirectory, tmpDir, files, webpackConfig, isDev, port) {
|
9
8
|
await generateFiles(appDirectory, tmpDir, files, isDev);
|
10
9
|
const compiler = webpack(webpackConfig);
|
@@ -1,10 +1,9 @@
|
|
1
1
|
import path from 'path';
|
2
|
-
import { fs, Import, logger } from '@modern-js/utils';
|
2
|
+
import { fs, glob, Import, logger } from '@modern-js/utils';
|
3
3
|
import { valid } from "./utils/valid";
|
4
4
|
const buildFeat = Import.lazy('./build', require);
|
5
5
|
const devFeat = Import.lazy('./dev', require);
|
6
6
|
const wp = Import.lazy('./utils/webpack', require);
|
7
|
-
const glob = Import.lazy('glob', require);
|
8
7
|
const DEFAULT_PORT = 5000;
|
9
8
|
export async function buildDocs({
|
10
9
|
appDirectory,
|
@@ -1,7 +1,5 @@
|
|
1
1
|
import path from 'path';
|
2
|
-
import { logger } from '@modern-js/utils';
|
3
|
-
import chokidar from 'chokidar';
|
4
|
-
import glob from 'glob';
|
2
|
+
import { glob, logger, chokidar } from '@modern-js/utils';
|
5
3
|
import { generateFiles } from "./generate-files";
|
6
4
|
export function chokidarFile(appDirectory, tmpDir, isDev) {
|
7
5
|
let dirty = false;
|
@@ -24,8 +22,7 @@ export function chokidarFile(appDirectory, tmpDir, isDev) {
|
|
24
22
|
if (files.length) {
|
25
23
|
await generateFiles(appDirectory, tmpDir, files, isDev);
|
26
24
|
logger.info('built');
|
27
|
-
}
|
28
|
-
|
25
|
+
}
|
29
26
|
|
30
27
|
building = false;
|
31
28
|
|
@@ -1,9 +1,3 @@
|
|
1
|
-
import _difference from "lodash/difference";
|
2
|
-
import _template from "lodash/template";
|
3
|
-
import _union from "lodash/union";
|
4
|
-
import _camelCase from "lodash/camelCase";
|
5
|
-
import _startCase from "lodash/startCase";
|
6
|
-
|
7
1
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
8
2
|
|
9
3
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
@@ -13,6 +7,7 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
|
|
13
7
|
import path from 'path';
|
14
8
|
import { logger, fs } from '@modern-js/utils';
|
15
9
|
import matter from 'gray-matter';
|
10
|
+
import { startCase, camelCase, union, template, difference } from '@modern-js/utils/lodash';
|
16
11
|
import GithubSlugger from 'github-slugger';
|
17
12
|
import sortPaths from 'sort-paths';
|
18
13
|
import visit from 'unist-util-visit';
|
@@ -31,19 +26,18 @@ const loadTemplate = async (file, customPath = false) => {
|
|
31
26
|
result = await fs.readFile(path.join(UTILS_STATIC, file), 'utf-8');
|
32
27
|
}
|
33
28
|
|
34
|
-
return
|
29
|
+
return template(result, {
|
35
30
|
interpolate: /<%=([\s\S]+?)%>/g
|
36
31
|
});
|
37
32
|
};
|
38
33
|
|
39
|
-
// eslint-disable-next-line max-statements
|
40
34
|
async function handleFile(appDirectory, tmpDir, file, images) {
|
41
35
|
const moduleName = file.replace(/\.(md|mdx)$/, '');
|
42
36
|
const content = await fs.readFile(path.resolve(appDirectory, 'docs', file));
|
43
37
|
const parsed = matter(content);
|
44
38
|
|
45
39
|
if (!parsed.data.title) {
|
46
|
-
parsed.data.title =
|
40
|
+
parsed.data.title = startCase(camelCase(path.basename(moduleName)));
|
47
41
|
}
|
48
42
|
|
49
43
|
const slugger = new GithubSlugger();
|
@@ -85,12 +79,10 @@ async function handleFile(appDirectory, tmpDir, file, images) {
|
|
85
79
|
}
|
86
80
|
});
|
87
81
|
});
|
88
|
-
|
89
|
-
const extraImported = _difference(imported.map(n => n.id), exported.map(n => n.id)); // we have to put the export statement with the import,
|
82
|
+
const extraImported = difference(imported.map(n => n.id), exported.map(n => n.id)); // we have to put the export statement with the import,
|
90
83
|
// otherwise the mdx's babel transformer cannot found
|
91
84
|
// the corresponding imports
|
92
85
|
|
93
|
-
|
94
86
|
extraImported.forEach(id => {
|
95
87
|
const {
|
96
88
|
node
|
@@ -141,9 +133,7 @@ async function handleFile(appDirectory, tmpDir, file, images) {
|
|
141
133
|
const transpiled = await mdx(parsed.content, {
|
142
134
|
remarkPlugins: [modifier]
|
143
135
|
});
|
144
|
-
|
145
|
-
const totalExported = _union(imported.map(n => n.id), exported.map(n => n.id));
|
146
|
-
|
136
|
+
const totalExported = union(imported.map(n => n.id), exported.map(n => n.id));
|
147
137
|
const outputFile = path.resolve(tmpDir, `${moduleName}/mdx.jsx`);
|
148
138
|
await fs.outputFile(outputFile, MDX_DEFAULT_RENDERER + transpiled, {
|
149
139
|
encoding: 'utf8'
|
package/dist/js/modern/index.js
CHANGED
@@ -1,55 +1,55 @@
|
|
1
1
|
import { Import } from '@modern-js/utils';
|
2
|
-
const core = Import.lazy('@modern-js/core', require);
|
3
2
|
const features = Import.lazy('./features', require);
|
4
|
-
export default
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
3
|
+
export default (() => ({
|
4
|
+
name: '@modern-js/plugin-docsite',
|
5
|
+
setup: api => ({
|
6
|
+
commands({
|
7
|
+
program
|
8
|
+
}) {
|
9
|
+
const {
|
10
|
+
appDirectory,
|
11
|
+
internalDirectory
|
12
|
+
} = api.useAppContext();
|
13
|
+
const devCommand = program.commandsMap.get('dev');
|
13
14
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
15
|
+
if (devCommand) {
|
16
|
+
devCommand.command('docs').action(async () => {
|
17
|
+
await features.buildDocs({
|
18
|
+
appDirectory,
|
19
|
+
internalDirectory,
|
20
|
+
isDev: true
|
21
|
+
});
|
20
22
|
});
|
21
|
-
}
|
22
|
-
}
|
23
|
-
},
|
23
|
+
}
|
24
|
+
},
|
24
25
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
appDirectory,
|
29
|
-
internalDirectory,
|
30
|
-
port
|
31
|
-
} = core.useAppContext();
|
32
|
-
return {
|
33
|
-
name: 'Docsite 调试',
|
34
|
-
value: 'docsite',
|
35
|
-
runTask: async () => features.buildDocs({
|
26
|
+
// module-tools menu mode
|
27
|
+
moduleToolsMenu() {
|
28
|
+
const {
|
36
29
|
appDirectory,
|
37
30
|
internalDirectory,
|
38
|
-
isDev: true,
|
39
31
|
port
|
40
|
-
})
|
41
|
-
|
42
|
-
|
32
|
+
} = api.useAppContext();
|
33
|
+
return {
|
34
|
+
name: 'Docsite 调试',
|
35
|
+
value: 'docsite',
|
36
|
+
runTask: async () => features.buildDocs({
|
37
|
+
appDirectory,
|
38
|
+
internalDirectory,
|
39
|
+
isDev: true,
|
40
|
+
port
|
41
|
+
})
|
42
|
+
};
|
43
|
+
},
|
43
44
|
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
45
|
+
platformBuild() {
|
46
|
+
return {
|
47
|
+
name: 'docsite',
|
48
|
+
title: 'Run Docsite log',
|
49
|
+
taskPath: require.resolve("./build-task"),
|
50
|
+
params: []
|
51
|
+
};
|
52
|
+
}
|
52
53
|
|
53
|
-
})
|
54
|
-
|
55
|
-
});
|
54
|
+
})
|
55
|
+
}));
|
@@ -9,8 +9,7 @@ var _utils = require("@modern-js/utils");
|
|
9
9
|
|
10
10
|
const wp = _utils.Import.lazy('./utils/webpack', require);
|
11
11
|
|
12
|
-
const gen = _utils.Import.lazy('./utils/generate-files', require);
|
13
|
-
|
12
|
+
const gen = _utils.Import.lazy('./utils/generate-files', require);
|
14
13
|
|
15
14
|
async function build(appDirectory, tmpDir, files, webpackConfig, isDev) {
|
16
15
|
const meta = await gen.generateFiles(appDirectory, tmpDir, files, isDev);
|
@@ -19,7 +19,6 @@ var _generateFiles = require("./utils/generate-files");
|
|
19
19
|
|
20
20
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
21
21
|
|
22
|
-
// eslint-disable-next-line max-params
|
23
22
|
async function dev(appDirectory, tmpDir, files, webpackConfig, isDev, port) {
|
24
23
|
await (0, _generateFiles.generateFiles)(appDirectory, tmpDir, files, isDev);
|
25
24
|
const compiler = (0, _webpack.default)(webpackConfig);
|
@@ -19,8 +19,6 @@ const devFeat = _utils.Import.lazy('./dev', require);
|
|
19
19
|
|
20
20
|
const wp = _utils.Import.lazy('./utils/webpack', require);
|
21
21
|
|
22
|
-
const glob = _utils.Import.lazy('glob', require);
|
23
|
-
|
24
22
|
const DEFAULT_PORT = 5000;
|
25
23
|
|
26
24
|
async function buildDocs({
|
@@ -42,7 +40,7 @@ async function buildDocs({
|
|
42
40
|
return;
|
43
41
|
}
|
44
42
|
|
45
|
-
const files = glob.sync('**/*.{md,mdx}', {
|
43
|
+
const files = _utils.glob.sync('**/*.{md,mdx}', {
|
46
44
|
cwd: docsDir,
|
47
45
|
ignore: '**/_*'
|
48
46
|
});
|
@@ -9,10 +9,6 @@ var _path = _interopRequireDefault(require("path"));
|
|
9
9
|
|
10
10
|
var _utils = require("@modern-js/utils");
|
11
11
|
|
12
|
-
var _chokidar = _interopRequireDefault(require("chokidar"));
|
13
|
-
|
14
|
-
var _glob = _interopRequireDefault(require("glob"));
|
15
|
-
|
16
12
|
var _generateFiles = require("./generate-files");
|
17
13
|
|
18
14
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
@@ -21,7 +17,7 @@ function chokidarFile(appDirectory, tmpDir, isDev) {
|
|
21
17
|
let dirty = false;
|
22
18
|
let building = false;
|
23
19
|
|
24
|
-
|
20
|
+
_utils.chokidar.watch('docs/**/*.{md,mdx}', {
|
25
21
|
cwd: appDirectory,
|
26
22
|
ignoreInitial: true
|
27
23
|
}).on('all', async () => {
|
@@ -33,7 +29,7 @@ function chokidarFile(appDirectory, tmpDir, isDev) {
|
|
33
29
|
|
34
30
|
_utils.logger.info('changed, collect and rebuild docs');
|
35
31
|
|
36
|
-
const files =
|
32
|
+
const files = _utils.glob.sync('**/*.{md,mdx}', {
|
37
33
|
cwd: _path.default.resolve(appDirectory, 'docs'),
|
38
34
|
ignore: '**/_*'
|
39
35
|
});
|
@@ -42,8 +38,7 @@ function chokidarFile(appDirectory, tmpDir, isDev) {
|
|
42
38
|
await (0, _generateFiles.generateFiles)(appDirectory, tmpDir, files, isDev);
|
43
39
|
|
44
40
|
_utils.logger.info('built');
|
45
|
-
}
|
46
|
-
|
41
|
+
}
|
47
42
|
|
48
43
|
building = false;
|
49
44
|
|
@@ -5,22 +5,14 @@ Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
});
|
6
6
|
exports.generateFiles = generateFiles;
|
7
7
|
|
8
|
-
var _difference2 = _interopRequireDefault(require("lodash/difference"));
|
9
|
-
|
10
|
-
var _template2 = _interopRequireDefault(require("lodash/template"));
|
11
|
-
|
12
|
-
var _union2 = _interopRequireDefault(require("lodash/union"));
|
13
|
-
|
14
|
-
var _camelCase2 = _interopRequireDefault(require("lodash/camelCase"));
|
15
|
-
|
16
|
-
var _startCase2 = _interopRequireDefault(require("lodash/startCase"));
|
17
|
-
|
18
8
|
var _path = _interopRequireDefault(require("path"));
|
19
9
|
|
20
10
|
var _utils = require("@modern-js/utils");
|
21
11
|
|
22
12
|
var _grayMatter = _interopRequireDefault(require("gray-matter"));
|
23
13
|
|
14
|
+
var _lodash = require("@modern-js/utils/lodash");
|
15
|
+
|
24
16
|
var _githubSlugger = _interopRequireDefault(require("github-slugger"));
|
25
17
|
|
26
18
|
var _sortPaths = _interopRequireDefault(require("sort-paths"));
|
@@ -54,19 +46,18 @@ const loadTemplate = async (file, customPath = false) => {
|
|
54
46
|
result = await _utils.fs.readFile(_path.default.join(_constant.UTILS_STATIC, file), 'utf-8');
|
55
47
|
}
|
56
48
|
|
57
|
-
return (0,
|
49
|
+
return (0, _lodash.template)(result, {
|
58
50
|
interpolate: /<%=([\s\S]+?)%>/g
|
59
51
|
});
|
60
52
|
};
|
61
53
|
|
62
|
-
// eslint-disable-next-line max-statements
|
63
54
|
async function handleFile(appDirectory, tmpDir, file, images) {
|
64
55
|
const moduleName = file.replace(/\.(md|mdx)$/, '');
|
65
56
|
const content = await _utils.fs.readFile(_path.default.resolve(appDirectory, 'docs', file));
|
66
57
|
const parsed = (0, _grayMatter.default)(content);
|
67
58
|
|
68
59
|
if (!parsed.data.title) {
|
69
|
-
parsed.data.title = (0,
|
60
|
+
parsed.data.title = (0, _lodash.startCase)((0, _lodash.camelCase)(_path.default.basename(moduleName)));
|
70
61
|
}
|
71
62
|
|
72
63
|
const slugger = new _githubSlugger.default();
|
@@ -110,7 +101,7 @@ async function handleFile(appDirectory, tmpDir, file, images) {
|
|
110
101
|
}
|
111
102
|
});
|
112
103
|
});
|
113
|
-
const extraImported = (0,
|
104
|
+
const extraImported = (0, _lodash.difference)(imported.map(n => n.id), exported.map(n => n.id)); // we have to put the export statement with the import,
|
114
105
|
// otherwise the mdx's babel transformer cannot found
|
115
106
|
// the corresponding imports
|
116
107
|
|
@@ -165,7 +156,7 @@ async function handleFile(appDirectory, tmpDir, file, images) {
|
|
165
156
|
const transpiled = await (0, _mdx.default)(parsed.content, {
|
166
157
|
remarkPlugins: [modifier]
|
167
158
|
});
|
168
|
-
const totalExported = (0,
|
159
|
+
const totalExported = (0, _lodash.union)(imported.map(n => n.id), exported.map(n => n.id));
|
169
160
|
|
170
161
|
const outputFile = _path.default.resolve(tmpDir, `${moduleName}/mdx.jsx`);
|
171
162
|
|
@@ -7,14 +7,8 @@ exports.valid = void 0;
|
|
7
7
|
|
8
8
|
var _path = _interopRequireDefault(require("path"));
|
9
9
|
|
10
|
-
var glob = _interopRequireWildcard(require("glob"));
|
11
|
-
|
12
10
|
var _utils = require("@modern-js/utils");
|
13
11
|
|
14
|
-
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
15
|
-
|
16
|
-
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
17
|
-
|
18
12
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
19
13
|
|
20
14
|
const valid = ({
|
@@ -23,7 +17,7 @@ const valid = ({
|
|
23
17
|
}) => {
|
24
18
|
const docsAbsPath = _path.default.join(appDirectory, docsDir);
|
25
19
|
|
26
|
-
const files = glob.sync(`${docsAbsPath}/**/*.{md,mdx}`);
|
20
|
+
const files = _utils.glob.sync(`${docsAbsPath}/**/*.{md,mdx}`);
|
27
21
|
|
28
22
|
if (!_utils.fs.existsSync(docsAbsPath) || files.length <= 0) {
|
29
23
|
console.info(_utils.chalk.yellow('No docs found, create directory "./docs" and add md(x) files'));
|
package/dist/js/node/index.js
CHANGED
@@ -7,61 +7,60 @@ exports.default = void 0;
|
|
7
7
|
|
8
8
|
var _utils = require("@modern-js/utils");
|
9
9
|
|
10
|
-
const core = _utils.Import.lazy('@modern-js/core', require);
|
11
|
-
|
12
10
|
const features = _utils.Import.lazy('./features', require);
|
13
11
|
|
14
|
-
var _default =
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
12
|
+
var _default = () => ({
|
13
|
+
name: '@modern-js/plugin-docsite',
|
14
|
+
setup: api => ({
|
15
|
+
commands({
|
16
|
+
program
|
17
|
+
}) {
|
18
|
+
const {
|
19
|
+
appDirectory,
|
20
|
+
internalDirectory
|
21
|
+
} = api.useAppContext();
|
22
|
+
const devCommand = program.commandsMap.get('dev');
|
23
23
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
24
|
+
if (devCommand) {
|
25
|
+
devCommand.command('docs').action(async () => {
|
26
|
+
await features.buildDocs({
|
27
|
+
appDirectory,
|
28
|
+
internalDirectory,
|
29
|
+
isDev: true
|
30
|
+
});
|
30
31
|
});
|
31
|
-
}
|
32
|
-
}
|
33
|
-
},
|
32
|
+
}
|
33
|
+
},
|
34
34
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
appDirectory,
|
39
|
-
internalDirectory,
|
40
|
-
port
|
41
|
-
} = core.useAppContext();
|
42
|
-
return {
|
43
|
-
name: 'Docsite 调试',
|
44
|
-
value: 'docsite',
|
45
|
-
runTask: async () => features.buildDocs({
|
35
|
+
// module-tools menu mode
|
36
|
+
moduleToolsMenu() {
|
37
|
+
const {
|
46
38
|
appDirectory,
|
47
39
|
internalDirectory,
|
48
|
-
isDev: true,
|
49
40
|
port
|
50
|
-
})
|
51
|
-
|
52
|
-
|
41
|
+
} = api.useAppContext();
|
42
|
+
return {
|
43
|
+
name: 'Docsite 调试',
|
44
|
+
value: 'docsite',
|
45
|
+
runTask: async () => features.buildDocs({
|
46
|
+
appDirectory,
|
47
|
+
internalDirectory,
|
48
|
+
isDev: true,
|
49
|
+
port
|
50
|
+
})
|
51
|
+
};
|
52
|
+
},
|
53
53
|
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
54
|
+
platformBuild() {
|
55
|
+
return {
|
56
|
+
name: 'docsite',
|
57
|
+
title: 'Run Docsite log',
|
58
|
+
taskPath: require.resolve("./build-task"),
|
59
|
+
params: []
|
60
|
+
};
|
61
|
+
}
|
62
62
|
|
63
|
-
})
|
64
|
-
name: '@modern-js/plugin-docsite'
|
63
|
+
})
|
65
64
|
});
|
66
65
|
|
67
66
|
exports.default = _default;
|
package/dist/types/index.d.ts
CHANGED
@@ -1,20 +1,5 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
resolved: import("@modern-js/core").NormalizedConfig;
|
5
|
-
}>;
|
6
|
-
validateSchema: import("@modern-js/core").ParallelWorkflow<void, unknown>;
|
7
|
-
prepare: import("@modern-js/core").AsyncWorkflow<void, void>;
|
8
|
-
commands: import("@modern-js/core").AsyncWorkflow<{
|
9
|
-
program: import("commander").Command;
|
10
|
-
}, void>;
|
11
|
-
watchFiles: import("@modern-js/core").ParallelWorkflow<void, unknown>;
|
12
|
-
fileChange: import("@modern-js/core").AsyncWorkflow<{
|
13
|
-
filename: string;
|
14
|
-
eventType: "add" | "unlink" | "change";
|
15
|
-
}, void>;
|
16
|
-
beforeExit: import("@modern-js/core").AsyncWorkflow<void, void>;
|
17
|
-
beforeRestart: import("@modern-js/core").AsyncWorkflow<void, void>;
|
18
|
-
} & import("@modern-js/core").ClearDraftProgress<import("@modern-js/core").Hooks>>>>;
|
1
|
+
import type { CliPlugin } from '@modern-js/core';
|
2
|
+
|
3
|
+
declare const _default: () => CliPlugin;
|
19
4
|
|
20
5
|
export default _default;
|
package/jest.config.js
CHANGED
package/package.json
CHANGED
@@ -11,7 +11,7 @@
|
|
11
11
|
"modern",
|
12
12
|
"modern.js"
|
13
13
|
],
|
14
|
-
"version": "1.2.
|
14
|
+
"version": "1.2.6",
|
15
15
|
"jsnext:source": "./src/index.ts",
|
16
16
|
"types": "./dist/types/index.d.ts",
|
17
17
|
"main": "./dist/js/node/index.js",
|
@@ -37,16 +37,13 @@
|
|
37
37
|
"@babel/runtime": "^7",
|
38
38
|
"@mdx-js/mdx": "^1.6.22",
|
39
39
|
"@mdx-js/react": "^1.6.22",
|
40
|
-
"@modern-js/utils": "^1.
|
41
|
-
"@modern-js/webpack": "^1.4
|
40
|
+
"@modern-js/utils": "^1.4.0",
|
41
|
+
"@modern-js/webpack": "^1.5.4",
|
42
42
|
"antd": "^4.16.13",
|
43
|
-
"chokidar": "^3.5.2",
|
44
43
|
"core-js": "^3.17.2",
|
45
44
|
"github-slugger": "^1.4.0",
|
46
|
-
"glob": "^7.1.6",
|
47
45
|
"gray-matter": "^4.0.3",
|
48
46
|
"html-webpack-plugin": "^5.3.2",
|
49
|
-
"lodash": "^4.17.21",
|
50
47
|
"mdast-util-to-string": "^2.0.0",
|
51
48
|
"path-browserify": "^1.0.1",
|
52
49
|
"prism-react-renderer": "^1.2.1",
|
@@ -55,31 +52,25 @@
|
|
55
52
|
"react-live": "^2.3.0",
|
56
53
|
"react-router-dom": "^5.3.0",
|
57
54
|
"sort-paths": "^1.1.1",
|
58
|
-
"styled-components": "^5.3.1",
|
59
55
|
"unist-builder": "^2.0.3",
|
60
56
|
"unist-util-visit": "^2.0.3",
|
61
|
-
"webpack": "^5.
|
57
|
+
"webpack": "^5.71.0",
|
62
58
|
"webpack-dev-server": "^4.1.1"
|
63
59
|
},
|
64
60
|
"devDependencies": {
|
65
|
-
"@modern-js/
|
61
|
+
"@modern-js/core": "1.7.0",
|
62
|
+
"@scripts/build": "0.0.0",
|
63
|
+
"@scripts/jest-config": "0.0.0",
|
66
64
|
"@types/core-js": "^2.5.5",
|
67
65
|
"@types/github-slugger": "^1.3.0",
|
68
66
|
"@types/glob": "^7.1.4",
|
69
67
|
"@types/jest": "^26",
|
70
|
-
"@types/lodash": "^4.14.168",
|
71
68
|
"@types/node": "^14",
|
72
69
|
"@types/react": "^17",
|
73
70
|
"@types/react-dom": "^17",
|
74
71
|
"@types/webpack-dev-server": "^4.1.0",
|
75
|
-
"typescript": "^4",
|
76
|
-
"@modern-js/core": "^1.4.4",
|
77
|
-
"@scripts/build": "0.0.0",
|
78
72
|
"jest": "^27",
|
79
|
-
"
|
80
|
-
},
|
81
|
-
"peerDependencies": {
|
82
|
-
"@modern-js/core": "^1.4.4"
|
73
|
+
"typescript": "^4"
|
83
74
|
},
|
84
75
|
"sideEffects": false,
|
85
76
|
"modernConfig": {
|