@modern-js/plugin-docsite 0.0.0-windows-2021101111240 → 0.0.0-windows-202110385642

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 CHANGED
@@ -1,14 +1,15 @@
1
1
  # @modern-js/plugin-docsite
2
2
 
3
- ## 0.0.0-windows-2021101111240
3
+ ## 0.0.0-windows-202110385642
4
4
 
5
5
  ### Patch Changes
6
6
 
7
- - test windows compatibility
7
+ - 6b802b2: use path method from @modern-js/utils
8
+ - windows
8
9
  - Updated dependencies [undefined]
9
- - @modern-js/core@0.0.0-windows-2021101111240
10
- - @modern-js/webpack@0.0.0-windows-2021101111240
11
- - @modern-js/utils@0.0.0-windows-2021101111240
10
+ - @modern-js/core@0.0.0-windows-202110385642
11
+ - @modern-js/webpack@0.0.0-windows-202110385642
12
+ - @modern-js/utils@0.0.0-windows-202110385642
12
13
 
13
14
  ## 1.0.0
14
15
 
@@ -1,4 +1,4 @@
1
- import { path } from '@modern-js/utils';
1
+ import path from 'path';
2
2
  export const UTILS_STATIC = path.join(__dirname, '../../static');
3
3
  export const DOCS_RENDER_PATH = '/api/v1/docs/render';
4
4
  export const MDX_DEFAULT_RENDERER = `
@@ -1,4 +1,5 @@
1
- import { path, logger } from '@modern-js/utils';
1
+ import path from 'path';
2
+ import { logger } from '@modern-js/utils';
2
3
  import webpack from 'webpack';
3
4
  import WebpackDevServer from 'webpack-dev-server';
4
5
  import { chokidarFile } from "./utils/chokidar";
@@ -1,4 +1,5 @@
1
- import { path, fs, Import, logger } from '@modern-js/utils';
1
+ import path from 'path';
2
+ import { fs, Import, logger } from '@modern-js/utils';
2
3
  import { valid } from "./utils/valid";
3
4
  const buildFeat = Import.lazy('./build', require);
4
5
  const devFeat = Import.lazy('./dev', require);
@@ -1,4 +1,5 @@
1
- import { path, logger } from '@modern-js/utils';
1
+ import path from 'path';
2
+ import { logger } from '@modern-js/utils';
2
3
  import chokidar from 'chokidar';
3
4
  import glob from 'glob';
4
5
  import { generateFiles } from "./generate-files";
@@ -10,7 +10,8 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
10
10
 
11
11
  function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
12
12
 
13
- import { path, logger, fs } from '@modern-js/utils';
13
+ import path from 'path';
14
+ import { logger, fs } from '@modern-js/utils';
14
15
  import matter from 'gray-matter';
15
16
  import GithubSlugger from 'github-slugger';
16
17
  import sortPaths from 'sort-paths';
@@ -1,6 +1,5 @@
1
- import * as path from 'path';
2
1
  import * as glob from 'glob';
3
- import { chalk, fs } from '@modern-js/utils';
2
+ import { chalk, fs, path } from '@modern-js/utils';
4
3
  export const valid = ({
5
4
  appDirectory,
6
5
  docsDir
@@ -5,9 +5,11 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.UTILS_STATIC = exports.MDX_DEFAULT_RENDERER = exports.DOCS_RENDER_PATH = void 0;
7
7
 
8
- var _utils = require("@modern-js/utils");
8
+ var _path = _interopRequireDefault(require("path"));
9
9
 
10
- const UTILS_STATIC = _utils.path.join(__dirname, '../../static');
10
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
+
12
+ const UTILS_STATIC = _path.default.join(__dirname, '../../static');
11
13
 
12
14
  exports.UTILS_STATIC = UTILS_STATIC;
13
15
  const DOCS_RENDER_PATH = '/api/v1/docs/render';
@@ -5,6 +5,8 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.dev = dev;
7
7
 
8
+ var _path = _interopRequireDefault(require("path"));
9
+
8
10
  var _utils = require("@modern-js/utils");
9
11
 
10
12
  var _webpack = _interopRequireDefault(require("webpack"));
@@ -26,7 +28,7 @@ async function dev(appDirectory, tmpDir, files, webpackConfig, isDev, port) {
26
28
  port,
27
29
  historyApiFallback: true,
28
30
  static: {
29
- directory: _utils.path.resolve(appDirectory, 'assets'),
31
+ directory: _path.default.resolve(appDirectory, 'assets'),
30
32
  publicPath: '/assets'
31
33
  }
32
34
  }, compiler);
@@ -5,10 +5,14 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.buildDocs = buildDocs;
7
7
 
8
+ var _path = _interopRequireDefault(require("path"));
9
+
8
10
  var _utils = require("@modern-js/utils");
9
11
 
10
12
  var _valid = require("./utils/valid");
11
13
 
14
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
+
12
16
  const buildFeat = _utils.Import.lazy('./build', require);
13
17
 
14
18
  const devFeat = _utils.Import.lazy('./dev', require);
@@ -31,7 +35,7 @@ async function buildDocs({
31
35
  return;
32
36
  }
33
37
 
34
- const docsDir = _utils.path.resolve(appDirectory, 'docs');
38
+ const docsDir = _path.default.resolve(appDirectory, 'docs');
35
39
 
36
40
  if (!_utils.fs.pathExistsSync(docsDir)) {
37
41
  return;
@@ -48,7 +52,7 @@ async function buildDocs({
48
52
  return;
49
53
  }
50
54
 
51
- const tmpDir = _utils.path.join(appDirectory, './node_modules/.modern-js/docs');
55
+ const tmpDir = _path.default.join(appDirectory, './node_modules/.modern-js/docs');
52
56
 
53
57
  _utils.fs.ensureDirSync(tmpDir);
54
58
 
@@ -5,6 +5,8 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.chokidarFile = chokidarFile;
7
7
 
8
+ var _path = _interopRequireDefault(require("path"));
9
+
8
10
  var _utils = require("@modern-js/utils");
9
11
 
10
12
  var _chokidar = _interopRequireDefault(require("chokidar"));
@@ -32,7 +34,7 @@ function chokidarFile(appDirectory, tmpDir, isDev) {
32
34
  _utils.logger.info('changed, collect and rebuild docs');
33
35
 
34
36
  const files = _glob.default.sync('**/*.{md,mdx}', {
35
- cwd: _utils.path.resolve(appDirectory, 'docs'),
37
+ cwd: _path.default.resolve(appDirectory, 'docs'),
36
38
  ignore: '**/_*'
37
39
  });
38
40
 
@@ -15,6 +15,8 @@ var _camelCase2 = _interopRequireDefault(require("lodash/camelCase"));
15
15
 
16
16
  var _startCase2 = _interopRequireDefault(require("lodash/startCase"));
17
17
 
18
+ var _path = _interopRequireDefault(require("path"));
19
+
18
20
  var _utils = require("@modern-js/utils");
19
21
 
20
22
  var _grayMatter = _interopRequireDefault(require("gray-matter"));
@@ -49,7 +51,7 @@ const loadTemplate = async (file, customPath = false) => {
49
51
  if (customPath) {
50
52
  result = await _utils.fs.readFile(file, 'utf-8');
51
53
  } else {
52
- result = await _utils.fs.readFile(_utils.path.join(_constant.UTILS_STATIC, file), 'utf-8');
54
+ result = await _utils.fs.readFile(_path.default.join(_constant.UTILS_STATIC, file), 'utf-8');
53
55
  }
54
56
 
55
57
  return (0, _template2.default)(result, {
@@ -60,11 +62,11 @@ const loadTemplate = async (file, customPath = false) => {
60
62
  // eslint-disable-next-line max-statements
61
63
  async function handleFile(appDirectory, tmpDir, file, images) {
62
64
  const moduleName = file.replace(/\.(md|mdx)$/, '');
63
- const content = await _utils.fs.readFile(_utils.path.resolve(appDirectory, 'docs', file));
65
+ const content = await _utils.fs.readFile(_path.default.resolve(appDirectory, 'docs', file));
64
66
  const parsed = (0, _grayMatter.default)(content);
65
67
 
66
68
  if (!parsed.data.title) {
67
- parsed.data.title = (0, _startCase2.default)((0, _camelCase2.default)(_utils.path.basename(moduleName)));
69
+ parsed.data.title = (0, _startCase2.default)((0, _camelCase2.default)(_path.default.basename(moduleName)));
68
70
  }
69
71
 
70
72
  const slugger = new _githubSlugger.default();
@@ -146,15 +148,15 @@ async function handleFile(appDirectory, tmpDir, file, images) {
146
148
  } = node;
147
149
 
148
150
  if (!url.startsWith('http')) {
149
- const fullPath = _utils.path.resolve(_utils.path.dirname(_utils.path.resolve(appDirectory, 'docs', file)), url);
151
+ const fullPath = _path.default.resolve(_path.default.dirname(_path.default.resolve(appDirectory, 'docs', file)), url);
150
152
 
151
- const relativePath = _utils.path.relative(_utils.path.resolve(appDirectory, 'assets'), fullPath);
153
+ const relativePath = _path.default.relative(_path.default.resolve(appDirectory, 'assets'), fullPath);
152
154
 
153
155
  if (relativePath.startsWith('..')) {
154
156
  _utils.logger.warn(`${url} referenced in ${file} is not under the "assets" folder`);
155
157
  } else {
156
158
  images.push(relativePath);
157
- node.url = `/${_utils.path.relative(_utils.path.dirname(_utils.path.resolve(appDirectory, 'docs', file)), _utils.path.resolve(appDirectory, 'docs/assets', relativePath))}`;
159
+ node.url = `/${_path.default.relative(_path.default.dirname(_path.default.resolve(appDirectory, 'docs', file)), _path.default.resolve(appDirectory, 'docs/assets', relativePath))}`;
158
160
  }
159
161
  }
160
162
  });
@@ -165,19 +167,19 @@ async function handleFile(appDirectory, tmpDir, file, images) {
165
167
  });
166
168
  const totalExported = (0, _union2.default)(imported.map(n => n.id), exported.map(n => n.id));
167
169
 
168
- const outputFile = _utils.path.resolve(tmpDir, `${moduleName}/mdx.jsx`);
170
+ const outputFile = _path.default.resolve(tmpDir, `${moduleName}/mdx.jsx`);
169
171
 
170
172
  await _utils.fs.outputFile(outputFile, _constant.MDX_DEFAULT_RENDERER + transpiled, {
171
173
  encoding: 'utf8'
172
174
  });
173
175
 
174
- const pageFile = _utils.path.resolve(tmpDir, `${moduleName}/index.jsx`);
176
+ const pageFile = _path.default.resolve(tmpDir, `${moduleName}/index.jsx`);
175
177
 
176
178
  const pageTemplate = await loadTemplate('docs-page.jsx.tpl');
177
179
  const pageContent = pageTemplate({
178
180
  moduleName,
179
181
  toc: JSON.stringify(toc),
180
- relRoot: _utils.path.relative(_utils.path.dirname(outputFile), tmpDir),
182
+ relRoot: _path.default.relative(_path.default.dirname(outputFile), tmpDir),
181
183
  imports: totalExported.length ? `import { ${totalExported.join(', ')} } from './mdx';` : '',
182
184
  imported: totalExported.join(',')
183
185
  });
@@ -197,16 +199,16 @@ async function generateFiles(appDirectory, tmpDir, files, isDev) {
197
199
  const meta = await Promise.all(files.map(file => handleFile(appDirectory, tmpDir, file, images)));
198
200
  const sorted = (0, _sortPaths.default)(meta, e => e.moduleName.endsWith('index') ? e.moduleName.replace(/index$/, '') : `${e.moduleName}/`, '/');
199
201
  const routesTemplate = await loadTemplate('DocsRoutes.jsx.tpl');
200
- await _utils.fs.outputFile(_utils.path.resolve(tmpDir, 'DocsRoutes.jsx'), routesTemplate({
202
+ await _utils.fs.outputFile(_path.default.resolve(tmpDir, 'DocsRoutes.jsx'), routesTemplate({
201
203
  meta: sorted
202
204
  }));
203
- const pkgInfo = await _utils.fs.readJson(_utils.path.resolve(appDirectory, 'package.json'));
205
+ const pkgInfo = await _utils.fs.readJson(_path.default.resolve(appDirectory, 'package.json'));
204
206
  const entryTemplate = await loadTemplate('docs-entry.jsx.tpl');
205
- await _utils.fs.outputFile(_utils.path.resolve(tmpDir, 'docs-entry.jsx'), entryTemplate({
207
+ await _utils.fs.outputFile(_path.default.resolve(tmpDir, 'docs-entry.jsx'), entryTemplate({
206
208
  basename: isDev ? '/' : `${_constant.DOCS_RENDER_PATH}/${pkgInfo.name}/${pkgInfo.version}`
207
209
  }));
208
- await Promise.all(['DocsNav.jsx.tpl', 'DocsToc.jsx.tpl', 'docs.css'].map(async file => _utils.fs.copyFile(_utils.path.resolve(_constant.UTILS_STATIC, file), _utils.path.resolve(tmpDir, file.replace('.tpl', '')))));
209
- await _utils.fs.outputJson(_utils.path.resolve(tmpDir, 'meta.json'), sorted.map(({
210
+ await Promise.all(['DocsNav.jsx.tpl', 'DocsToc.jsx.tpl', 'docs.css'].map(async file => _utils.fs.copyFile(_path.default.resolve(_constant.UTILS_STATIC, file), _path.default.resolve(tmpDir, file.replace('.tpl', '')))));
211
+ await _utils.fs.outputJson(_path.default.resolve(tmpDir, 'meta.json'), sorted.map(({
210
212
  title,
211
213
  moduleName
212
214
  }) => ({
@@ -215,7 +217,7 @@ async function generateFiles(appDirectory, tmpDir, files, isDev) {
215
217
  })), {
216
218
  spaces: 2
217
219
  });
218
- await _utils.fs.ensureDir(_utils.path.resolve(appDirectory, 'dist/docs/assets'));
219
- await Promise.all(Array.from(new Set(images)).map(file => _utils.fs.copyFile(_utils.path.resolve(appDirectory, 'assets', file), _utils.path.resolve(appDirectory, 'dist/docs/assets', file))));
220
+ await _utils.fs.ensureDir(_path.default.resolve(appDirectory, 'dist/docs/assets'));
221
+ await Promise.all(Array.from(new Set(images)).map(file => _utils.fs.copyFile(_path.default.resolve(appDirectory, 'assets', file), _path.default.resolve(appDirectory, 'dist/docs/assets', file))));
220
222
  return sorted;
221
223
  }
@@ -5,8 +5,6 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.valid = void 0;
7
7
 
8
- var path = _interopRequireWildcard(require("path"));
9
-
10
8
  var glob = _interopRequireWildcard(require("glob"));
11
9
 
12
10
  var _utils = require("@modern-js/utils");
@@ -19,7 +17,8 @@ const valid = ({
19
17
  appDirectory,
20
18
  docsDir
21
19
  }) => {
22
- const docsAbsPath = path.join(appDirectory, docsDir);
20
+ const docsAbsPath = _utils.path.join(appDirectory, docsDir);
21
+
23
22
  const files = glob.sync(`${docsAbsPath}/**/*.{md,mdx}`);
24
23
 
25
24
  if (!_utils.fs.existsSync(docsAbsPath) || files.length <= 0) {
package/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "modern",
12
12
  "modern.js"
13
13
  ],
14
- "version": "0.0.0-windows-2021101111240",
14
+ "version": "0.0.0-windows-202110385642",
15
15
  "jsnext:source": "./src/index.ts",
16
16
  "types": "./dist/types/index.d.ts",
17
17
  "main": "./dist/js/node/index.js",
@@ -32,8 +32,8 @@
32
32
  "@babel/runtime": "^7",
33
33
  "@mdx-js/mdx": "^1.6.22",
34
34
  "@mdx-js/react": "^1.6.22",
35
- "@modern-js/utils": "^0.0.0-windows-2021101111240",
36
- "@modern-js/webpack": "^0.0.0-windows-2021101111240",
35
+ "@modern-js/utils": "^0.0.0-windows-202110385642",
36
+ "@modern-js/webpack": "^0.0.0-windows-202110385642",
37
37
  "antd": "^4.16.13",
38
38
  "chokidar": "^3.5.2",
39
39
  "core-js": "^3.17.2",
@@ -57,7 +57,7 @@
57
57
  "webpack-dev-server": "^4.1.1"
58
58
  },
59
59
  "devDependencies": {
60
- "@modern-js/module-tools-hooks": "^0.0.0-windows-2021101111240",
60
+ "@modern-js/module-tools-hooks": "^0.0.0-windows-202110385642",
61
61
  "@types/core-js": "^2.5.5",
62
62
  "@types/github-slugger": "^1.3.0",
63
63
  "@types/glob": "^7.1.4",
@@ -68,12 +68,12 @@
68
68
  "@types/react-dom": "^17",
69
69
  "@types/webpack-dev-server": "^4.1.0",
70
70
  "typescript": "^4",
71
- "@modern-js/core": "^0.0.0-windows-2021101111240",
72
- "@modern-js/plugin-testing": "^0.0.0-windows-2021101111240",
73
- "@modern-js/module-tools": "^0.0.0-windows-2021101111240"
71
+ "@modern-js/core": "^0.0.0-windows-202110385642",
72
+ "@modern-js/plugin-testing": "^0.0.0-windows-202110385642",
73
+ "@modern-js/module-tools": "^0.0.0-windows-202110385642"
74
74
  },
75
75
  "peerDependencies": {
76
- "@modern-js/core": "^0.0.0-windows-2021101111240"
76
+ "@modern-js/core": "^0.0.0-windows-202110385642"
77
77
  },
78
78
  "sideEffects": false,
79
79
  "modernConfig": {
@@ -1,4 +1,4 @@
1
- import { path } from '@modern-js/utils';
1
+ import path from 'path';
2
2
 
3
3
  export const UTILS_STATIC = path.join(__dirname, '../../static');
4
4
  export const DOCS_RENDER_PATH = '/api/v1/docs/render';
@@ -1,4 +1,5 @@
1
- import { path, logger } from '@modern-js/utils';
1
+ import path from 'path';
2
+ import { logger } from '@modern-js/utils';
2
3
  import webpack, { Configuration } from 'webpack';
3
4
  import WebpackDevServer from 'webpack-dev-server';
4
5
  import { chokidarFile } from './utils/chokidar';
@@ -1,4 +1,5 @@
1
- import { path, fs, Import, logger } from '@modern-js/utils';
1
+ import path from 'path';
2
+ import { fs, Import, logger } from '@modern-js/utils';
2
3
  import type { Configuration } from 'webpack';
3
4
  import { valid } from './utils/valid';
4
5
 
@@ -1,4 +1,5 @@
1
- import { path, logger } from '@modern-js/utils';
1
+ import path from 'path';
2
+ import { logger } from '@modern-js/utils';
2
3
  import chokidar from 'chokidar';
3
4
  import glob from 'glob';
4
5
  import { generateFiles } from './generate-files';
@@ -1,4 +1,5 @@
1
- import { path, logger, fs } from '@modern-js/utils';
1
+ import path from 'path';
2
+ import { logger, fs } from '@modern-js/utils';
2
3
  import matter from 'gray-matter';
3
4
  import { startCase, camelCase, union, template, difference } from 'lodash';
4
5
  import GithubSlugger from 'github-slugger';
@@ -1,6 +1,5 @@
1
- import * as path from 'path';
2
1
  import * as glob from 'glob';
3
- import { chalk, fs } from '@modern-js/utils';
2
+ import { chalk, fs, path } from '@modern-js/utils';
4
3
 
5
4
  interface ValidOption {
6
5
  appDirectory: string;