@docusaurus/remark-plugin-npm2yarn 2.0.0-beta.2 → 2.0.0-beta.20

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/lib/index.d.ts ADDED
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Copyright (c) Facebook, Inc. and its affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+ import type { Plugin } from 'unified';
8
+ declare type PluginOptions = {
9
+ sync?: boolean;
10
+ };
11
+ declare const plugin: Plugin<[PluginOptions?]>;
12
+ export = plugin;
13
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,SAAS,CAAC;AAKpC,aAAK,aAAa,GAAG;IACnB,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB,CAAC;AA8CF,QAAA,MAAM,MAAM,EAAE,MAAM,CAAC,CAAC,aAAa,CAAC,CAAC,CA4BpC,CAAC;AAIF,SAAS,MAAM,CAAC"}
package/lib/index.js ADDED
@@ -0,0 +1,80 @@
1
+ "use strict";
2
+ /**
3
+ * Copyright (c) Facebook, Inc. and its affiliates.
4
+ *
5
+ * This source code is licensed under the MIT license found in the
6
+ * LICENSE file in the root directory of this source tree.
7
+ */
8
+ const tslib_1 = require("tslib");
9
+ const unist_util_visit_1 = tslib_1.__importDefault(require("unist-util-visit"));
10
+ const npm_to_yarn_1 = tslib_1.__importDefault(require("npm-to-yarn"));
11
+ // E.g. global install: 'npm i' -> 'yarn'
12
+ const convertNpmToYarn = (npmCode) => (0, npm_to_yarn_1.default)(npmCode, 'yarn');
13
+ const transformNode = (node, isSync) => {
14
+ const groupIdProp = isSync ? ' groupId="npm2yarn"' : '';
15
+ const npmCode = node.value;
16
+ const yarnCode = convertNpmToYarn(node.value);
17
+ return [
18
+ {
19
+ type: 'jsx',
20
+ value: `<Tabs${groupIdProp}>\n<TabItem value="npm">`,
21
+ },
22
+ {
23
+ type: node.type,
24
+ lang: node.lang,
25
+ value: npmCode,
26
+ },
27
+ {
28
+ type: 'jsx',
29
+ value: '</TabItem>\n<TabItem value="yarn" label="Yarn">',
30
+ },
31
+ {
32
+ type: node.type,
33
+ lang: node.lang,
34
+ value: yarnCode,
35
+ },
36
+ {
37
+ type: 'jsx',
38
+ value: '</TabItem>\n</Tabs>',
39
+ },
40
+ ];
41
+ };
42
+ const isImport = (node) => node.type === 'import';
43
+ const isParent = (node) => Array.isArray(node.children);
44
+ const matchNode = (node) => node.type === 'code' && node.meta === 'npm2yarn';
45
+ const nodeForImport = {
46
+ type: 'import',
47
+ value: "import Tabs from '@theme/Tabs';\nimport TabItem from '@theme/TabItem';",
48
+ };
49
+ const plugin = (options = {}) => {
50
+ const { sync = false } = options;
51
+ return (root) => {
52
+ let transformed = false;
53
+ let alreadyImported = false;
54
+ (0, unist_util_visit_1.default)(root, (node) => {
55
+ if (isImport(node) && node.value.includes('@theme/Tabs')) {
56
+ alreadyImported = true;
57
+ }
58
+ if (isParent(node)) {
59
+ let index = 0;
60
+ while (index < node.children.length) {
61
+ const child = node.children[index];
62
+ if (matchNode(child)) {
63
+ const result = transformNode(child, sync);
64
+ node.children.splice(index, 1, ...result);
65
+ index += result.length;
66
+ transformed = true;
67
+ }
68
+ else {
69
+ index += 1;
70
+ }
71
+ }
72
+ }
73
+ });
74
+ if (transformed && !alreadyImported) {
75
+ root.children.unshift(nodeForImport);
76
+ }
77
+ };
78
+ };
79
+ module.exports = plugin;
80
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;AAKH,gFAAqC;AACrC,sEAAoC;AAMpC,yCAAyC;AACzC,MAAM,gBAAgB,GAA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n",
3
- "version": "2.0.0-beta.2",
3
+ "version": "2.0.0-beta.20",
4
4
  "description": "Remark plugin for converting npm commands to Yarn commands as tabs.",
5
- "main": "src/index.js",
5
+ "main": "lib/index.js",
6
6
  "publishConfig": {
7
7
  "access": "public"
8
8
  },
9
+ "scripts": {
10
+ "build": "tsc",
11
+ "watch": "tsc --watch"
12
+ },
9
13
  "repository": {
10
14
  "type": "git",
11
15
  "url": "https://github.com/facebook/docusaurus.git",
@@ -13,19 +17,18 @@
13
17
  },
14
18
  "license": "MIT",
15
19
  "dependencies": {
16
- "npm-to-yarn": "^1.0.1"
20
+ "npm-to-yarn": "^1.0.1",
21
+ "tslib": "^2.4.0",
22
+ "unist-util-visit": "^2.0.3"
17
23
  },
18
24
  "devDependencies": {
19
- "remark": "^12.0.0",
25
+ "@types/mdast": "^3.0.10",
26
+ "remark": "^12.0.1",
20
27
  "remark-mdx": "^1.6.21",
21
- "to-vfile": "^6.0.0"
22
- },
23
- "peerDependencies": {
24
- "react": "^16.8.4 || ^17.0.0",
25
- "react-dom": "^16.8.4 || ^17.0.0"
28
+ "to-vfile": "^6.1.0"
26
29
  },
27
30
  "engines": {
28
- "node": ">=12.13.0"
31
+ "node": ">=14"
29
32
  },
30
- "gitHead": "883f07fddffaf1657407c8e202e370cc436e25f7"
33
+ "gitHead": "ed5cdba401a5948e187e927039b142a0decc702d"
31
34
  }
package/src/index.ts ADDED
@@ -0,0 +1,94 @@
1
+ /**
2
+ * Copyright (c) Facebook, Inc. and its affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+
8
+ import type {Code, Content, Literal} from 'mdast';
9
+ import type {Plugin} from 'unified';
10
+ import type {Node, Parent} from 'unist';
11
+ import visit from 'unist-util-visit';
12
+ import npmToYarn from 'npm-to-yarn';
13
+
14
+ type PluginOptions = {
15
+ sync?: boolean;
16
+ };
17
+
18
+ // E.g. global install: 'npm i' -> 'yarn'
19
+ const convertNpmToYarn = (npmCode: string) => npmToYarn(npmCode, 'yarn');
20
+
21
+ const transformNode = (node: Code, isSync: boolean) => {
22
+ const groupIdProp = isSync ? ' groupId="npm2yarn"' : '';
23
+ const npmCode = node.value;
24
+ const yarnCode = convertNpmToYarn(node.value);
25
+ return [
26
+ {
27
+ type: 'jsx',
28
+ value: `<Tabs${groupIdProp}>\n<TabItem value="npm">`,
29
+ },
30
+ {
31
+ type: node.type,
32
+ lang: node.lang,
33
+ value: npmCode,
34
+ },
35
+ {
36
+ type: 'jsx',
37
+ value: '</TabItem>\n<TabItem value="yarn" label="Yarn">',
38
+ },
39
+ {
40
+ type: node.type,
41
+ lang: node.lang,
42
+ value: yarnCode,
43
+ },
44
+ {
45
+ type: 'jsx',
46
+ value: '</TabItem>\n</Tabs>',
47
+ },
48
+ ] as Content[];
49
+ };
50
+
51
+ const isImport = (node: Node): node is Literal => node.type === 'import';
52
+ const isParent = (node: Node): node is Parent =>
53
+ Array.isArray((node as Parent).children);
54
+ const matchNode = (node: Node): node is Code =>
55
+ node.type === 'code' && (node as Code).meta === 'npm2yarn';
56
+ const nodeForImport: Literal = {
57
+ type: 'import',
58
+ value:
59
+ "import Tabs from '@theme/Tabs';\nimport TabItem from '@theme/TabItem';",
60
+ };
61
+
62
+ const plugin: Plugin<[PluginOptions?]> = (options = {}) => {
63
+ const {sync = false} = options;
64
+ return (root) => {
65
+ let transformed = false;
66
+ let alreadyImported = false;
67
+ visit(root, (node: Node) => {
68
+ if (isImport(node) && node.value.includes('@theme/Tabs')) {
69
+ alreadyImported = true;
70
+ }
71
+ if (isParent(node)) {
72
+ let index = 0;
73
+ while (index < node.children.length) {
74
+ const child = node.children[index]!;
75
+ if (matchNode(child)) {
76
+ const result = transformNode(child, sync);
77
+ node.children.splice(index, 1, ...result);
78
+ index += result.length;
79
+ transformed = true;
80
+ } else {
81
+ index += 1;
82
+ }
83
+ }
84
+ }
85
+ });
86
+ if (transformed && !alreadyImported) {
87
+ (root as Parent).children.unshift(nodeForImport);
88
+ }
89
+ };
90
+ };
91
+
92
+ // To continue supporting `require('npm2yarn')` without the `.default` ㄟ(▔,▔)ㄏ
93
+ // TODO change to export default after migrating to ESM
94
+ export = plugin;
@@ -1,130 +0,0 @@
1
- // Jest Snapshot v1, https://goo.gl/fbAQLP
2
-
3
- exports[`npm2yarn plugin test: already imported tabs components above are not re-imported 1`] = `
4
- "import Tabs from '@theme/Tabs';
5
-
6
- import TabItem from '@theme/TabItem';
7
-
8
- <Tabs defaultValue=\\"npm\\" values={[
9
- { label: 'npm', value: 'npm', },
10
- { label: 'Yarn', value: 'yarn', },
11
- ]}
12
- >
13
- <TabItem value=\\"npm\\">
14
-
15
- \`\`\`bash
16
- $ npm install --global docusaurus
17
- \`\`\`
18
-
19
- </TabItem>
20
- <TabItem value=\\"yarn\\">
21
-
22
- \`\`\`bash
23
- $ yarn add --global docusaurus
24
- \`\`\`
25
-
26
- </TabItem>
27
- </Tabs>
28
- "
29
- `;
30
-
31
- exports[`npm2yarn plugin test: already imported tabs components below are not re-imported 1`] = `
32
- "<Tabs defaultValue=\\"npm\\" values={[
33
- { label: 'npm', value: 'npm', },
34
- { label: 'Yarn', value: 'yarn', },
35
- ]}
36
- >
37
- <TabItem value=\\"npm\\">
38
-
39
- \`\`\`bash
40
- $ npm install --global docusaurus
41
- \`\`\`
42
-
43
- </TabItem>
44
- <TabItem value=\\"yarn\\">
45
-
46
- \`\`\`bash
47
- $ yarn add --global docusaurus
48
- \`\`\`
49
-
50
- </TabItem>
51
- </Tabs>
52
-
53
- import Tabs from '@theme/Tabs';
54
-
55
- import TabItem from '@theme/TabItem';
56
- "
57
- `;
58
-
59
- exports[`npm2yarn plugin test: installation file 1`] = `
60
- "import Tabs from '@theme/Tabs';
61
- import TabItem from '@theme/TabItem';
62
-
63
- <Tabs defaultValue=\\"npm\\" values={[
64
- { label: 'npm', value: 'npm', },
65
- { label: 'Yarn', value: 'yarn', },
66
- ]}
67
- >
68
- <TabItem value=\\"npm\\">
69
-
70
- \`\`\`bash
71
- $ npm install --global docusaurus
72
- \`\`\`
73
-
74
- </TabItem>
75
- <TabItem value=\\"yarn\\">
76
-
77
- \`\`\`bash
78
- $ yarn add --global docusaurus
79
- \`\`\`
80
-
81
- </TabItem>
82
- </Tabs>
83
- "
84
- `;
85
-
86
- exports[`npm2yarn plugin test: language was not setted 1`] = `
87
- "\`\`\`npm2yarn
88
- npm install --save docusaurus-plugin-name
89
- \`\`\`
90
-
91
- \`\`\`bash
92
- npm install --save docusaurus-plugin-name
93
- \`\`\`
94
-
95
- \`\`\`shell
96
- npm install --save docusaurus-plugin-name
97
- \`\`\`
98
- "
99
- `;
100
-
101
- exports[`npm2yarn plugin test: plugin file 1`] = `
102
- "import Tabs from '@theme/Tabs';
103
- import TabItem from '@theme/TabItem';
104
-
105
- ## Installing a plugin
106
-
107
- A plugin is usually a npm package, so you install them like other npm packages using npm.
108
-
109
- <Tabs defaultValue=\\"npm\\" values={[
110
- { label: 'npm', value: 'npm', },
111
- { label: 'Yarn', value: 'yarn', },
112
- ]}
113
- >
114
- <TabItem value=\\"npm\\">
115
-
116
- \`\`\`bash
117
- npm install --save docusaurus-plugin-name
118
- \`\`\`
119
-
120
- </TabItem>
121
- <TabItem value=\\"yarn\\">
122
-
123
- \`\`\`bash
124
- yarn add docusaurus-plugin-name
125
- \`\`\`
126
-
127
- </TabItem>
128
- </Tabs>
129
- "
130
- `;
@@ -1,7 +0,0 @@
1
- import Tabs from '@theme/Tabs';
2
-
3
- import TabItem from '@theme/TabItem';
4
-
5
- ```bash npm2yarn
6
- $ npm install --global docusaurus
7
- ```
@@ -1,7 +0,0 @@
1
- ```bash npm2yarn
2
- $ npm install --global docusaurus
3
- ```
4
-
5
- import Tabs from '@theme/Tabs';
6
-
7
- import TabItem from '@theme/TabItem';
@@ -1,3 +0,0 @@
1
- ```bash npm2yarn
2
- $ npm install --global docusaurus
3
- ```
@@ -1,7 +0,0 @@
1
- ## Installing a plugin
2
-
3
- A plugin is usually a npm package, so you install them like other npm packages using npm.
4
-
5
- ```bash npm2yarn
6
- npm install --save docusaurus-plugin-name
7
- ```
@@ -1,11 +0,0 @@
1
- ```npm2yarn
2
- npm install --save docusaurus-plugin-name
3
- ```
4
-
5
- ```bash
6
- npm install --save docusaurus-plugin-name
7
- ```
8
-
9
- ```shell
10
- npm install --save docusaurus-plugin-name
11
- ```
@@ -1,69 +0,0 @@
1
- /**
2
- * Copyright (c) Facebook, Inc. and its affiliates.
3
- *
4
- * This source code is licensed under the MIT license found in the
5
- * LICENSE file in the root directory of this source tree.
6
- */
7
-
8
- /* eslint-disable no-param-reassign */
9
-
10
- import remark from 'remark';
11
- import npm2yarn from '../index';
12
- import vfile from 'to-vfile';
13
- import {join, relative} from 'path';
14
- import mdx from 'remark-mdx';
15
-
16
- const staticDir = `./${relative(process.cwd(), join(__dirname, 'fixtures'))}`;
17
-
18
- const processFixture = async (name, options) => {
19
- const path = join(__dirname, 'fixtures', `${name}.md`);
20
- const file = await vfile.read(path);
21
- const result = await remark()
22
- .use(mdx)
23
- .use(npm2yarn, {...options, filePath: path})
24
- .process(file);
25
-
26
- return result.toString();
27
- };
28
-
29
- describe('npm2yarn plugin', () => {
30
- test('test: installation file', async () => {
31
- const result = await processFixture('installation', {
32
- staticDir,
33
- });
34
-
35
- expect(result).toMatchSnapshot();
36
- });
37
-
38
- test('test: plugin file', async () => {
39
- const result = await processFixture('plugin', {
40
- staticDir,
41
- });
42
-
43
- expect(result).toMatchSnapshot();
44
- });
45
-
46
- test('test: language was not setted', async () => {
47
- const result = await processFixture('syntax-not-properly-set', {
48
- staticDir,
49
- });
50
-
51
- expect(result).toMatchSnapshot();
52
- });
53
-
54
- test('test: already imported tabs components above are not re-imported', async () => {
55
- const result = await processFixture('import-tabs-above', {
56
- staticDir,
57
- });
58
-
59
- expect(result).toMatchSnapshot();
60
- });
61
-
62
- test('test: already imported tabs components below are not re-imported', async () => {
63
- const result = await processFixture('import-tabs-below', {
64
- staticDir,
65
- });
66
-
67
- expect(result).toMatchSnapshot();
68
- });
69
- });
package/src/index.js DELETED
@@ -1,87 +0,0 @@
1
- /**
2
- * Copyright (c) Facebook, Inc. and its affiliates.
3
- *
4
- * This source code is licensed under the MIT license found in the
5
- * LICENSE file in the root directory of this source tree.
6
- */
7
-
8
- const npmToYarn = require('npm-to-yarn');
9
-
10
- // E.g. global install: 'npm i' -> 'yarn'
11
- const convertNpmToYarn = (npmCode) => npmToYarn(npmCode, 'yarn');
12
-
13
- const transformNode = (node, isSync) => {
14
- const groupIdProp = isSync ? 'groupId="npm2yarn" ' : '';
15
- const npmCode = node.value;
16
- const yarnCode = convertNpmToYarn(node.value);
17
- return [
18
- {
19
- type: 'jsx',
20
- value:
21
- `<Tabs defaultValue="npm" ${groupIdProp}` +
22
- `values={[
23
- { label: 'npm', value: 'npm', },
24
- { label: 'Yarn', value: 'yarn', },
25
- ]}
26
- >
27
- <TabItem value="npm">`,
28
- },
29
- {
30
- type: node.type,
31
- lang: node.lang,
32
- value: npmCode,
33
- },
34
- {
35
- type: 'jsx',
36
- value: '</TabItem>\n<TabItem value="yarn">',
37
- },
38
- {
39
- type: node.type,
40
- lang: node.lang,
41
- value: yarnCode,
42
- },
43
- {
44
- type: 'jsx',
45
- value: '</TabItem>\n</Tabs>',
46
- },
47
- ];
48
- };
49
-
50
- const matchNode = (node) => node.type === 'code' && node.meta === 'npm2yarn';
51
- const nodeForImport = {
52
- type: 'import',
53
- value:
54
- "import Tabs from '@theme/Tabs';\nimport TabItem from '@theme/TabItem';",
55
- };
56
-
57
- module.exports = (options = {}) => {
58
- const {sync = false} = options;
59
- let transformed = false;
60
- let alreadyImported = false;
61
- const transformer = (node) => {
62
- if (node.type === 'import' && node.value.includes('@theme/Tabs')) {
63
- alreadyImported = true;
64
- }
65
- if (matchNode(node)) {
66
- transformed = true;
67
- return transformNode(node, sync);
68
- }
69
- if (Array.isArray(node.children)) {
70
- let index = 0;
71
- while (index < node.children.length) {
72
- const result = transformer(node.children[index]);
73
- if (result) {
74
- node.children.splice(index, 1, ...result);
75
- index += result.length;
76
- } else {
77
- index += 1;
78
- }
79
- }
80
- }
81
- if (node.type === 'root' && transformed && !alreadyImported) {
82
- node.children.unshift(nodeForImport);
83
- }
84
- return null;
85
- };
86
- return transformer;
87
- };