@docusaurus/remark-plugin-npm2yarn 2.0.0-beta.16 → 2.0.0-beta.19
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 +2 -2
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +5 -6
- package/lib/index.js.map +1 -1
- package/package.json +6 -6
- package/src/index.ts +7 -8
package/lib/index.d.ts
CHANGED
|
@@ -5,9 +5,9 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
import type { Plugin } from 'unified';
|
|
8
|
-
|
|
8
|
+
declare type PluginOptions = {
|
|
9
9
|
sync?: boolean;
|
|
10
|
-
}
|
|
10
|
+
};
|
|
11
11
|
declare const plugin: Plugin<[PluginOptions?]>;
|
|
12
12
|
export = plugin;
|
|
13
13
|
//# sourceMappingURL=index.d.ts.map
|
package/lib/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,KAAK,EAAC,MAAM,
|
|
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
CHANGED
|
@@ -6,8 +6,8 @@
|
|
|
6
6
|
* LICENSE file in the root directory of this source tree.
|
|
7
7
|
*/
|
|
8
8
|
const tslib_1 = require("tslib");
|
|
9
|
-
const unist_util_visit_1 =
|
|
10
|
-
const npm_to_yarn_1 =
|
|
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
11
|
// E.g. global install: 'npm i' -> 'yarn'
|
|
12
12
|
const convertNpmToYarn = (npmCode) => (0, npm_to_yarn_1.default)(npmCode, 'yarn');
|
|
13
13
|
const transformNode = (node, isSync) => {
|
|
@@ -48,9 +48,9 @@ const nodeForImport = {
|
|
|
48
48
|
};
|
|
49
49
|
const plugin = (options = {}) => {
|
|
50
50
|
const { sync = false } = options;
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
51
|
+
return (root) => {
|
|
52
|
+
let transformed = false;
|
|
53
|
+
let alreadyImported = false;
|
|
54
54
|
(0, unist_util_visit_1.default)(root, (node) => {
|
|
55
55
|
if (isImport(node) && node.value.includes('@theme/Tabs')) {
|
|
56
56
|
alreadyImported = true;
|
|
@@ -75,7 +75,6 @@ const plugin = (options = {}) => {
|
|
|
75
75
|
root.children.unshift(nodeForImport);
|
|
76
76
|
}
|
|
77
77
|
};
|
|
78
|
-
return transformer;
|
|
79
78
|
};
|
|
80
79
|
module.exports = plugin;
|
|
81
80
|
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;AAKH,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;AAKH,gFAAqC;AACrC,sEAAoC;AAMpC,yCAAyC;AACzC,MAAM,gBAAgB,GAAG,CAAC,OAAe,EAAE,EAAE,CAAC,IAAA,qBAAS,EAAC,OAAO,EAAE,MAAM,CAAC,CAAC;AAEzE,MAAM,aAAa,GAAG,CAAC,IAAU,EAAE,MAAe,EAAE,EAAE;IACpD,MAAM,WAAW,GAA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KAAK,CAAC;QACxB,IAAI,eAAe,GAAG,KAAK,CAAC;QAC5B,IAAA,0BAAK,EAAC,IAAI,EAAE,CAAC,IAAU,EAAE,EAAE;YACzB,IAAI,QAAQ,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,aAAa,CAAC,EAAE;gBACxD,eAAe,GAAG,IAAI,CAAC;aACxB;YACD,IAAI,QAAQ,CAAC,IAAI,CAAC,EAAE;gBAClB,IAAI,KAAK,GAAG,CAAC,CAAC;gBACd,OAAO,KAAK,GAAG,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE;oBACnC,MAAM,KAAK,GAAG,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAE,CAAC;oBACpC,IAAI,SAAS,CAAC,KAAK,CAAC,EAAE;wBACpB,MAAM,MAAM,GAAG,aAAa,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;wBAC1C,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,EAAE,GAAG,MAAM,CAAC,CAAC;wBAC1C,KAAK,IAAI,MAAM,CAAC,MAAM,CAAC;wBACvB,WAAW,GAAG,IAAI,CAAC;qBACpB;yBAAM;wBACL,KAAK,IAAI,CAAC,CAAC;qBACZ;iBACF;aACF;QACH,CAAC,CAAC,CAAC;QACH,IAAI,WAAW,IAAI,CAAC,eAAe,EAAE;YAClC,IAAe,CAAC,QAAQ,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC;SAClD;IACH,CAAC,CAAC;AACJ,CAAC,CAAC;AAIF,iBAAS,MAAM,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@docusaurus/remark-plugin-npm2yarn",
|
|
3
|
-
"version": "2.0.0-beta.
|
|
3
|
+
"version": "2.0.0-beta.19",
|
|
4
4
|
"description": "Remark plugin for converting npm commands to Yarn commands as tabs.",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"publishConfig": {
|
|
@@ -18,17 +18,17 @@
|
|
|
18
18
|
"license": "MIT",
|
|
19
19
|
"dependencies": {
|
|
20
20
|
"npm-to-yarn": "^1.0.1",
|
|
21
|
-
"tslib": "^2.
|
|
22
|
-
"unist-util-visit": "^2.0.
|
|
21
|
+
"tslib": "^2.4.0",
|
|
22
|
+
"unist-util-visit": "^2.0.3"
|
|
23
23
|
},
|
|
24
24
|
"devDependencies": {
|
|
25
25
|
"@types/mdast": "^3.0.10",
|
|
26
|
-
"remark": "^12.0.
|
|
26
|
+
"remark": "^12.0.1",
|
|
27
27
|
"remark-mdx": "^1.6.21",
|
|
28
|
-
"to-vfile": "^6.
|
|
28
|
+
"to-vfile": "^6.1.0"
|
|
29
29
|
},
|
|
30
30
|
"engines": {
|
|
31
31
|
"node": ">=14"
|
|
32
32
|
},
|
|
33
|
-
"gitHead": "
|
|
33
|
+
"gitHead": "a71e60a49cce93c1006ef10c41ac03187f057102"
|
|
34
34
|
}
|
package/src/index.ts
CHANGED
|
@@ -6,14 +6,14 @@
|
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
import type {Code, Content, Literal} from 'mdast';
|
|
9
|
-
import type {Plugin
|
|
9
|
+
import type {Plugin} from 'unified';
|
|
10
10
|
import type {Node, Parent} from 'unist';
|
|
11
11
|
import visit from 'unist-util-visit';
|
|
12
12
|
import npmToYarn from 'npm-to-yarn';
|
|
13
13
|
|
|
14
|
-
|
|
14
|
+
type PluginOptions = {
|
|
15
15
|
sync?: boolean;
|
|
16
|
-
}
|
|
16
|
+
};
|
|
17
17
|
|
|
18
18
|
// E.g. global install: 'npm i' -> 'yarn'
|
|
19
19
|
const convertNpmToYarn = (npmCode: string) => npmToYarn(npmCode, 'yarn');
|
|
@@ -61,9 +61,9 @@ const nodeForImport: Literal = {
|
|
|
61
61
|
|
|
62
62
|
const plugin: Plugin<[PluginOptions?]> = (options = {}) => {
|
|
63
63
|
const {sync = false} = options;
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
64
|
+
return (root) => {
|
|
65
|
+
let transformed = false;
|
|
66
|
+
let alreadyImported = false;
|
|
67
67
|
visit(root, (node: Node) => {
|
|
68
68
|
if (isImport(node) && node.value.includes('@theme/Tabs')) {
|
|
69
69
|
alreadyImported = true;
|
|
@@ -71,7 +71,7 @@ const plugin: Plugin<[PluginOptions?]> = (options = {}) => {
|
|
|
71
71
|
if (isParent(node)) {
|
|
72
72
|
let index = 0;
|
|
73
73
|
while (index < node.children.length) {
|
|
74
|
-
const child = node.children[index]
|
|
74
|
+
const child = node.children[index]!;
|
|
75
75
|
if (matchNode(child)) {
|
|
76
76
|
const result = transformNode(child, sync);
|
|
77
77
|
node.children.splice(index, 1, ...result);
|
|
@@ -87,7 +87,6 @@ const plugin: Plugin<[PluginOptions?]> = (options = {}) => {
|
|
|
87
87
|
(root as Parent).children.unshift(nodeForImport);
|
|
88
88
|
}
|
|
89
89
|
};
|
|
90
|
-
return transformer;
|
|
91
90
|
};
|
|
92
91
|
|
|
93
92
|
// To continue supporting `require('npm2yarn')` without the `.default` ㄟ(▔,▔)ㄏ
|