@sapphire/docusaurus-plugin-npm2yarn2pnpm 1.1.4-next.f54ccb2.0 → 1.1.4
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 +10 -0
- package/dist/index.d.ts +3 -1
- package/dist/index.js +176 -8
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +174 -7
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -4
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,16 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
|
|
5
|
+
# [@sapphire/docusaurus-plugin-npm2yarn2pnpm@1.1.4](https://github.com/sapphiredev/documentation-plugins/compare/@sapphire/docusaurus-plugin-npm2yarn2pnpm@1.1.3...@sapphire/docusaurus-plugin-npm2yarn2pnpm@1.1.4) - (2022-10-08)
|
|
6
|
+
|
|
7
|
+
## 🏠 Refactor
|
|
8
|
+
|
|
9
|
+
- Switch from `@armano/npm-to-yarn` to own implementation ([c4a2543](https://github.com/sapphiredev/documentation-plugins/commit/c4a254318b6ad0609c1be9c556f2dcdd7c853b3b))
|
|
10
|
+
|
|
11
|
+
## 📝 Documentation
|
|
12
|
+
|
|
13
|
+
- Add @vladfrangu as a contributor ([cd26f50](https://github.com/sapphiredev/documentation-plugins/commit/cd26f50dffcd964a86bd0b0431615621a472dba7))
|
|
14
|
+
|
|
5
15
|
# [@sapphire/docusaurus-plugin-npm2yarn2pnpm@1.1.3](https://github.com/sapphiredev/documentation-plugins/compare/@sapphire/docusaurus-plugin-npm2yarn2pnpm@1.1.2...@sapphire/docusaurus-plugin-npm2yarn2pnpm@1.1.3) - (2022-07-12)
|
|
6
16
|
|
|
7
17
|
## 🐛 Bug Fixes
|
package/dist/index.d.ts
CHANGED
|
@@ -8,9 +8,11 @@ import { Plugin } from 'unified';
|
|
|
8
8
|
*/
|
|
9
9
|
declare function npmToPnpm(str: string): string;
|
|
10
10
|
|
|
11
|
+
declare function npmToYarn(str: string): string;
|
|
12
|
+
|
|
11
13
|
interface PluginOptions {
|
|
12
14
|
sync?: boolean;
|
|
13
15
|
}
|
|
14
16
|
declare const npm2yarn2pnpm: Plugin<[PluginOptions?]>;
|
|
15
17
|
|
|
16
|
-
export { PluginOptions, npm2yarn2pnpm, npmToPnpm };
|
|
18
|
+
export { PluginOptions, npm2yarn2pnpm, npmToPnpm, npmToYarn };
|
package/dist/index.js
CHANGED
|
@@ -27,18 +27,25 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
27
27
|
var src_exports = {};
|
|
28
28
|
__export(src_exports, {
|
|
29
29
|
npm2yarn2pnpm: () => npm2yarn2pnpm,
|
|
30
|
-
npmToPnpm: () => npmToPnpm
|
|
30
|
+
npmToPnpm: () => npmToPnpm,
|
|
31
|
+
npmToYarn: () => npmToYarn
|
|
31
32
|
});
|
|
32
33
|
module.exports = __toCommonJS(src_exports);
|
|
33
34
|
|
|
34
35
|
// src/npm2pnpm.ts
|
|
35
36
|
var unchangedCLICommands = ["init", "run", "test", "login", "logout", "link", "publish", "cache"];
|
|
37
|
+
function parseNpmInstall(command, isShortHand = false) {
|
|
38
|
+
if (/^install *$/.test(command)) {
|
|
39
|
+
return "install";
|
|
40
|
+
}
|
|
41
|
+
return command.replace(isShortHand ? "i " : "install ", "add ").replace(/(\s*)--save(?!-)/, "$1--save-prod").replace("--no-package-lock", "");
|
|
42
|
+
}
|
|
36
43
|
var npmToPnpmTable = {
|
|
37
44
|
install(command) {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
return command
|
|
45
|
+
return parseNpmInstall(command);
|
|
46
|
+
},
|
|
47
|
+
i(command) {
|
|
48
|
+
return parseNpmInstall(command, true);
|
|
42
49
|
},
|
|
43
50
|
uninstall(command) {
|
|
44
51
|
return command.replace("uninstall", "remove").replace(/(\s*)--save(?!-)/, "$1--save-prod").replace("--no-package-lock", "");
|
|
@@ -68,13 +75,173 @@ function npmToPnpm(str) {
|
|
|
68
75
|
return str.replace(/npm(?: +([^&\n\r]*))?/gm, convert);
|
|
69
76
|
}
|
|
70
77
|
|
|
78
|
+
// src/npm2yarn.ts
|
|
79
|
+
var unchangedCLICommands2 = ["test", "login", "logout", "link", "publish", "cache"];
|
|
80
|
+
var yarnCLICommands = [
|
|
81
|
+
"init",
|
|
82
|
+
"run",
|
|
83
|
+
"add",
|
|
84
|
+
"audit",
|
|
85
|
+
"autoclean",
|
|
86
|
+
"bin",
|
|
87
|
+
"check",
|
|
88
|
+
"config",
|
|
89
|
+
"create",
|
|
90
|
+
"dedupe",
|
|
91
|
+
"generate-lock-entry",
|
|
92
|
+
"global",
|
|
93
|
+
"help",
|
|
94
|
+
"import",
|
|
95
|
+
"info",
|
|
96
|
+
"install",
|
|
97
|
+
"licenses",
|
|
98
|
+
"list",
|
|
99
|
+
"lockfile",
|
|
100
|
+
"outdated",
|
|
101
|
+
"owner",
|
|
102
|
+
"pack",
|
|
103
|
+
"policies",
|
|
104
|
+
"prune",
|
|
105
|
+
"remove",
|
|
106
|
+
"self-update",
|
|
107
|
+
"tag",
|
|
108
|
+
"team",
|
|
109
|
+
"link",
|
|
110
|
+
"unlink",
|
|
111
|
+
"upgrade",
|
|
112
|
+
"upgrade-interactive",
|
|
113
|
+
"version",
|
|
114
|
+
"versions",
|
|
115
|
+
"why",
|
|
116
|
+
"workspace",
|
|
117
|
+
"workspaces"
|
|
118
|
+
];
|
|
119
|
+
function parseNpmInstall2(command, isShortHand = false) {
|
|
120
|
+
if (/^install *$/.test(command)) {
|
|
121
|
+
return "install";
|
|
122
|
+
}
|
|
123
|
+
let yarnAddCommand = command.replace(isShortHand ? "i " : "install ", "add ").replace("--save-dev", "--dev").replace(/\s*--save(?!-)/, "").replace("--no-package-lock", "--no-lockfile").replace("--save-optional", "--optional").replace("--save-exact", "--exact");
|
|
124
|
+
if (/ -(?:-global|g)(?![^\b])/.test(yarnAddCommand)) {
|
|
125
|
+
yarnAddCommand = yarnAddCommand.replace(/ -(?:-global|g)(?![^\b])/, "");
|
|
126
|
+
yarnAddCommand = `global ${yarnAddCommand}`;
|
|
127
|
+
}
|
|
128
|
+
return yarnAddCommand;
|
|
129
|
+
}
|
|
130
|
+
var npmToYarnTable = {
|
|
131
|
+
install(command) {
|
|
132
|
+
return parseNpmInstall2(command);
|
|
133
|
+
},
|
|
134
|
+
i(command) {
|
|
135
|
+
return parseNpmInstall2(command, true);
|
|
136
|
+
},
|
|
137
|
+
uninstall(command) {
|
|
138
|
+
let yarnRemoveCommand = command.replace("uninstall", "remove").replace("--save-dev", "--dev").replace(/\s*--save(?!-)/, "").replace("--no-package-lock", "--no-lockfile");
|
|
139
|
+
if (/ -(?:-global|g)(?![^\b])/.test(yarnRemoveCommand)) {
|
|
140
|
+
yarnRemoveCommand = yarnRemoveCommand.replace(/ -(?:-global|g)(?![^\b])/, "");
|
|
141
|
+
yarnRemoveCommand = `global ${yarnRemoveCommand}`;
|
|
142
|
+
}
|
|
143
|
+
return yarnRemoveCommand;
|
|
144
|
+
},
|
|
145
|
+
rebuild(command) {
|
|
146
|
+
return command.replace("rebuild", "add --force");
|
|
147
|
+
},
|
|
148
|
+
exec(command) {
|
|
149
|
+
return command.replace(/^exec\s?([^\s]+)?(\s--\s--)?(.*)$/, (_, data, dash, rest) => {
|
|
150
|
+
let result = "";
|
|
151
|
+
if (data && !unchangedCLICommands2.includes(data) && !yarnCLICommands.includes(data)) {
|
|
152
|
+
result += data;
|
|
153
|
+
} else {
|
|
154
|
+
result += `run ${data || ""}`;
|
|
155
|
+
}
|
|
156
|
+
if (dash) {
|
|
157
|
+
result += dash.replace(/^\s--/, "");
|
|
158
|
+
}
|
|
159
|
+
if (rest) {
|
|
160
|
+
result += rest;
|
|
161
|
+
}
|
|
162
|
+
return result;
|
|
163
|
+
});
|
|
164
|
+
},
|
|
165
|
+
run(command) {
|
|
166
|
+
return command.replace(/^run\s?([^\s]+)?(\s--\s--)?(.*)$/, (_, data, dash, rest) => {
|
|
167
|
+
let result = "";
|
|
168
|
+
if (data && !unchangedCLICommands2.includes(data) && !yarnCLICommands.includes(data)) {
|
|
169
|
+
result += data;
|
|
170
|
+
} else {
|
|
171
|
+
result += `run ${data || ""}`;
|
|
172
|
+
}
|
|
173
|
+
if (dash) {
|
|
174
|
+
result += dash.replace(/^\s--/, "");
|
|
175
|
+
}
|
|
176
|
+
if (rest) {
|
|
177
|
+
result += rest;
|
|
178
|
+
}
|
|
179
|
+
return result;
|
|
180
|
+
});
|
|
181
|
+
},
|
|
182
|
+
ls(command) {
|
|
183
|
+
return command.replace(/^(ls|list)(.*)$/, (_1, _2, args) => {
|
|
184
|
+
let result = "list";
|
|
185
|
+
if (args) {
|
|
186
|
+
let ended = false;
|
|
187
|
+
let packages = [];
|
|
188
|
+
const items = args.split(" ").filter(Boolean);
|
|
189
|
+
for (const item of items) {
|
|
190
|
+
if (ended) {
|
|
191
|
+
result += ` ${item}`;
|
|
192
|
+
} else if (item.startsWith("-")) {
|
|
193
|
+
result += ` --pattern "${packages.join("|")}"`;
|
|
194
|
+
packages = [];
|
|
195
|
+
ended = true;
|
|
196
|
+
result += ` ${item}`;
|
|
197
|
+
} else {
|
|
198
|
+
packages.push(item);
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
if (packages.length > 0) {
|
|
202
|
+
result += ` --pattern "${packages.join("|")}"`;
|
|
203
|
+
}
|
|
204
|
+
return result;
|
|
205
|
+
}
|
|
206
|
+
return "list";
|
|
207
|
+
});
|
|
208
|
+
},
|
|
209
|
+
list(command) {
|
|
210
|
+
return npmToYarnTable.ls(command);
|
|
211
|
+
},
|
|
212
|
+
init(command) {
|
|
213
|
+
if (/^init (?!-).*$/.test(command)) {
|
|
214
|
+
return command.replace("init", "create");
|
|
215
|
+
}
|
|
216
|
+
return command.replace(" --scope", "");
|
|
217
|
+
}
|
|
218
|
+
};
|
|
219
|
+
function convert2(_, command) {
|
|
220
|
+
command = (command || "").trim();
|
|
221
|
+
const firstCommand = (/\w+/.exec(command) || [""])[0];
|
|
222
|
+
if (unchangedCLICommands2.includes(firstCommand)) {
|
|
223
|
+
return `yarn ${command}`;
|
|
224
|
+
}
|
|
225
|
+
if (firstCommand in npmToYarnTable) {
|
|
226
|
+
const converter = npmToYarnTable[firstCommand];
|
|
227
|
+
if (typeof converter === "function") {
|
|
228
|
+
return `yarn ${converter(command)}`;
|
|
229
|
+
}
|
|
230
|
+
return `yarn ${command.replace(firstCommand, converter)}`;
|
|
231
|
+
}
|
|
232
|
+
return `yarn ${command}
|
|
233
|
+
# couldn't auto-convert command`;
|
|
234
|
+
}
|
|
235
|
+
function npmToYarn(str) {
|
|
236
|
+
return str.replace(/npm(?: +([^&\n\r]*))?/gm, convert2);
|
|
237
|
+
}
|
|
238
|
+
|
|
71
239
|
// src/npm2yarn2pnpm.ts
|
|
72
|
-
var import_npm_to_yarn = require("@armano/npm-to-yarn");
|
|
73
240
|
var import_unist_util_visit = __toESM(require("unist-util-visit"));
|
|
74
241
|
var transformNode = (node, options) => {
|
|
75
242
|
const groupIdProp = options.sync ? ' groupId="npm2yarn2pnpm"' : "";
|
|
76
243
|
const npmCode = node.value;
|
|
77
|
-
const yarnCode = (
|
|
244
|
+
const yarnCode = npmToYarn(node.value);
|
|
78
245
|
const pnpmCode = npmToPnpm(node.value);
|
|
79
246
|
const [, highlight] = (node.meta ?? "").split("|");
|
|
80
247
|
return [
|
|
@@ -158,6 +325,7 @@ var npm2yarn2pnpm = ({ sync = true } = { sync: true }) => (root) => {
|
|
|
158
325
|
// Annotate the CommonJS export names for ESM import in node:
|
|
159
326
|
0 && (module.exports = {
|
|
160
327
|
npm2yarn2pnpm,
|
|
161
|
-
npmToPnpm
|
|
328
|
+
npmToPnpm,
|
|
329
|
+
npmToYarn
|
|
162
330
|
});
|
|
163
331
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/npm2pnpm.ts","../src/npm2yarn2pnpm.ts"],"sourcesContent":["export { npmToPnpm } from './npm2pnpm';\nexport { npm2yarn2pnpm, PluginOptions } from './npm2yarn2pnpm';\n","/**\n * Copyright (c) 2019 Ben Gubler <nebrelbug@gmail.com>\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nconst unchangedCLICommands = ['init', 'run', 'test', 'login', 'logout', 'link', 'publish', 'cache'];\n\nconst npmToPnpmTable = {\n\tinstall(command: string) {\n\t\tif (/^install *$/.test(command)) {\n\t\t\treturn 'install';\n\t\t}\n\n\t\treturn command\n\t\t\t.replace('install', 'add')\n\t\t\t.replace(/(\\s*)--save(?!-)/, '$1--save-prod')\n\t\t\t.replace('--no-package-lock', '');\n\t},\n\n\tuninstall(command: string) {\n\t\treturn command\n\t\t\t.replace('uninstall', 'remove')\n\t\t\t.replace(/(\\s*)--save(?!-)/, '$1--save-prod')\n\t\t\t.replace('--no-package-lock', '');\n\t},\n\n\tversion(command: string) {\n\t\treturn command.replace(/(major|minor|patch)/, '--$1');\n\t},\n\n\trebuild(command: string) {\n\t\treturn command.replace('rebuild', 'add --force');\n\t}\n} as const;\n\nfunction convert(_: string, command: string) {\n\tcommand = (command ?? '').trim();\n\n\tconst firstCommand = (/\\w+/.exec(command) || [''])[0] as keyof typeof npmToPnpmTable;\n\n\tif (unchangedCLICommands.includes(firstCommand)) {\n\t\treturn `pnpm ${command}`;\n\t} else if (Object.prototype.hasOwnProperty.call(npmToPnpmTable, firstCommand) && npmToPnpmTable[firstCommand]) {\n\t\tif (typeof npmToPnpmTable[firstCommand] === 'function') {\n\t\t\treturn `pnpm ${npmToPnpmTable[firstCommand](command)}`;\n\t\t}\n\t\treturn `pnpm ${command.replace(firstCommand, npmToPnpmTable[firstCommand])}`;\n\t}\n\n\treturn `pnpm ${command}\\n# couldn't auto-convert command`;\n}\n\nexport function npmToPnpm(str: string) {\n\treturn str.replace(/npm(?: +([^&\\n\\r]*))?/gm, convert);\n}\n","import { convertToYarn } from '@armano/npm-to-yarn';\nimport type { Code, Content, Literal } from 'mdast';\nimport type { Plugin } from 'unified';\nimport type { Node, Parent } from 'unist';\nimport visit from 'unist-util-visit';\nimport { npmToPnpm } from './npm2pnpm';\n\n/**\n * Transforms a Docusaurus node from NPM to Yarn and Pnpm\n * @param node The Docusaurus node to transform\n * @param options The plugin options to pass to the transformer\n * @returns The transformed node in the form of Tabs.\n */\nconst transformNode = (node: Code, options: PluginOptions) => {\n\tconst groupIdProp = options.sync ? ' groupId=\"npm2yarn2pnpm\"' : '';\n\tconst npmCode = node.value;\n\n\tconst yarnCode = convertToYarn(node.value);\n\tconst pnpmCode = npmToPnpm(node.value);\n\n\tconst [, highlight] = (node.meta ?? '').split('|');\n\n\treturn [\n\t\t{\n\t\t\ttype: 'jsx',\n\t\t\tvalue: `<Tabs${groupIdProp}\n\t\t\t\t\t\tdefaultValue=\"npm\"\n\t\t\t\t\t\tvalues={[\n\t\t\t\t\t\t\t{ label: \"npm\", value: \"npm\" },\n\t\t\t\t\t\t\t{ label: \"yarn\", value: \"yarn\" },\n\t\t\t\t\t\t\t{ label: \"pnpm\", value: \"pnpm\" },\n\t\t\t\t\t\t]}\n\t\t\t>\\n<TabItem value=\"npm\">`\n\t\t},\n\t\t{\n\t\t\ttype: node.type,\n\t\t\tlang: node.lang,\n\t\t\tmeta: `${highlight} showLineNumbers`,\n\t\t\tvalue: npmCode\n\t\t},\n\t\t{\n\t\t\ttype: 'jsx',\n\t\t\tvalue: '</TabItem>\\n<TabItem value=\"yarn\" label=\"Yarn\">'\n\t\t},\n\t\t{\n\t\t\ttype: node.type,\n\t\t\tlang: node.lang,\n\t\t\tmeta: `${highlight} showLineNumbers`,\n\t\t\tvalue: yarnCode\n\t\t},\n\t\t{\n\t\t\ttype: 'jsx',\n\t\t\tvalue: '</TabItem>\\n<TabItem value=\"pnpm\">'\n\t\t},\n\t\t{\n\t\t\ttype: node.type,\n\t\t\tlang: node.lang,\n\t\t\tmeta: `${highlight} showLineNumbers`,\n\t\t\tvalue: pnpmCode\n\t\t},\n\t\t{\n\t\t\ttype: 'jsx',\n\t\t\tvalue: '</TabItem>\\n</Tabs>'\n\t\t}\n\t] as Content[];\n};\n\nconst isImport = (node: Node): node is Literal => node.type === 'import';\nconst isParent = (node: Node): node is Parent => Array.isArray((node as Parent).children);\nconst matchNode = (node: Node): node is Code =>\n\tnode.type === 'code' && typeof (node as Code).meta === 'string' && ((node as Code).meta ?? '').startsWith('npm2yarn2pnpm');\nconst nodeForImport: Literal = {\n\ttype: 'import',\n\tvalue: \"import Tabs from '@theme/Tabs';\\nimport TabItem from '@theme/TabItem';\"\n};\n\nexport interface PluginOptions {\n\tsync?: boolean;\n}\n\nexport const npm2yarn2pnpm: Plugin<[PluginOptions?]> =\n\t({ sync = true } = { sync: true }) =>\n\t(root) => {\n\t\tlet transformed = false;\n\t\tlet alreadyImported = false;\n\t\tvisit(root, (node: Node) => {\n\t\t\tif (isImport(node) && node.value.includes('@theme/Tabs')) {\n\t\t\t\talreadyImported = true;\n\t\t\t}\n\t\t\tif (isParent(node)) {\n\t\t\t\tlet index = 0;\n\t\t\t\twhile (index < node.children.length) {\n\t\t\t\t\tconst child = node.children[index]!;\n\t\t\t\t\tif (matchNode(child)) {\n\t\t\t\t\t\tconst result = transformNode(child, { sync });\n\t\t\t\t\t\tnode.children.splice(index, 1, ...result);\n\t\t\t\t\t\tindex += result.length;\n\t\t\t\t\t\ttransformed = true;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tindex += 1;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t\tif (transformed && !alreadyImported) {\n\t\t\t(root as Parent).children.unshift(nodeForImport);\n\t\t}\n\t};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACOA,IAAM,uBAAuB,CAAC,QAAQ,OAAO,QAAQ,SAAS,UAAU,Q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AACA,QAAI,SAAS,IAAI,GAAG;AACnB,UAAI,QAAQ;AACZ,aAAO,QAAQ,KAAK,SAAS,QAAQ;AACpC,cAAM,QAAQ,KAAK,SAAS;AAC5B,YAAI,UAAU,KAAK,GAAG;AACrB,gBAAM,SAAS,cAAc,OAAO,EAAE,KAAK,CAAC;AAC5C,eAAK,SAAS,OAAO,OAAO,GAAG,GAAG,MAAM;AACxC,mBAAS,OAAO;AAChB,wBAAc;AAAA,QACf,OAAO;AACN,mBAAS;AAAA,QACV;AAAA,MACD;AAAA,IACD;AAAA,EACD,CAAC;AACD,MAAI,eAAe,CAAC,iBAAiB;AACpC,IAAC,KAAgB,SAAS,QAAQ,aAAa;AAAA,EAChD;AACD;","names":["visit"]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/npm2pnpm.ts","../src/npm2yarn.ts","../src/npm2yarn2pnpm.ts"],"sourcesContent":["export { npmToPnpm } from './npm2pnpm';\nexport { npmToYarn } from './npm2yarn';\nexport { npm2yarn2pnpm, PluginOptions } from './npm2yarn2pnpm';\n","/**\n * Copyright (c) 2019 Ben Gubler <nebrelbug@gmail.com>\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nconst unchangedCLICommands = ['init', 'run', 'test', 'login', 'logout', 'link', 'publish', 'cache'];\n\nfunction parseNpmInstall(command: string, isShortHand = false) {\n\tif (/^install *$/.test(command)) {\n\t\treturn 'install';\n\t}\n\n\treturn command\n\t\t.replace(isShortHand ? 'i ' : 'install ', 'add ')\n\t\t.replace(/(\\s*)--save(?!-)/, '$1--save-prod')\n\t\t.replace('--no-package-lock', '');\n}\n\nconst npmToPnpmTable = {\n\tinstall(command: string) {\n\t\treturn parseNpmInstall(command);\n\t},\n\n\ti(command: string) {\n\t\treturn parseNpmInstall(command, true);\n\t},\n\n\tuninstall(command: string) {\n\t\treturn command\n\t\t\t.replace('uninstall', 'remove')\n\t\t\t.replace(/(\\s*)--save(?!-)/, '$1--save-prod')\n\t\t\t.replace('--no-package-lock', '');\n\t},\n\n\tversion(command: string) {\n\t\treturn command.replace(/(major|minor|patch)/, '--$1');\n\t},\n\n\trebuild(command: string) {\n\t\treturn command.replace('rebuild', 'add --force');\n\t}\n} as const;\n\nfunction convert(_: string, command: string) {\n\tcommand = (command ?? '').trim();\n\n\tconst firstCommand = (/\\w+/.exec(command) || [''])[0] as keyof typeof npmToPnpmTable;\n\n\tif (unchangedCLICommands.includes(firstCommand)) {\n\t\treturn `pnpm ${command}`;\n\t} else if (Object.prototype.hasOwnProperty.call(npmToPnpmTable, firstCommand) && npmToPnpmTable[firstCommand]) {\n\t\tif (typeof npmToPnpmTable[firstCommand] === 'function') {\n\t\t\treturn `pnpm ${npmToPnpmTable[firstCommand](command)}`;\n\t\t}\n\t\treturn `pnpm ${command.replace(firstCommand, npmToPnpmTable[firstCommand])}`;\n\t}\n\n\treturn `pnpm ${command}\\n# couldn't auto-convert command`;\n}\n\nexport function npmToPnpm(str: string) {\n\treturn str.replace(/npm(?: +([^&\\n\\r]*))?/gm, convert);\n}\n","/**\n * Copyright (c) 2019 Ben Gubler <nebrelbug@gmail.com>\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nexport const unchangedCLICommands = ['test', 'login', 'logout', 'link', 'publish', 'cache'];\nexport const yarnCLICommands = [\n\t'init',\n\t'run',\n\t'add',\n\t'audit',\n\t'autoclean',\n\t'bin',\n\t'check',\n\t'config',\n\t'create',\n\t'dedupe',\n\t'generate-lock-entry',\n\t'global',\n\t'help',\n\t'import',\n\t'info',\n\t'install',\n\t'licenses',\n\t'list',\n\t'lockfile',\n\t'outdated',\n\t'owner',\n\t'pack',\n\t'policies',\n\t'prune',\n\t'remove',\n\t'self-update',\n\t'tag',\n\t'team',\n\t'link',\n\t'unlink',\n\t'upgrade',\n\t'upgrade-interactive',\n\t'version',\n\t'versions',\n\t'why',\n\t'workspace',\n\t'workspaces'\n];\n\nfunction parseNpmInstall(command: string, isShortHand = false) {\n\tif (/^install *$/.test(command)) {\n\t\treturn 'install';\n\t}\n\n\tlet yarnAddCommand = command\n\t\t.replace(isShortHand ? 'i ' : 'install ', 'add ')\n\t\t.replace('--save-dev', '--dev')\n\t\t.replace(/\\s*--save(?!-)/, '')\n\t\t.replace('--no-package-lock', '--no-lockfile')\n\t\t.replace('--save-optional', '--optional')\n\t\t.replace('--save-exact', '--exact');\n\n\tif (/ -(?:-global|g)(?![^\\b])/.test(yarnAddCommand)) {\n\t\tyarnAddCommand = yarnAddCommand.replace(/ -(?:-global|g)(?![^\\b])/, '');\n\t\tyarnAddCommand = `global ${yarnAddCommand}`;\n\t}\n\n\treturn yarnAddCommand;\n}\n\nconst npmToYarnTable = {\n\tinstall(command: string) {\n\t\treturn parseNpmInstall(command);\n\t},\n\n\ti(command: string) {\n\t\treturn parseNpmInstall(command, true);\n\t},\n\n\tuninstall(command: string) {\n\t\tlet yarnRemoveCommand = command\n\t\t\t.replace('uninstall', 'remove')\n\t\t\t.replace('--save-dev', '--dev')\n\t\t\t.replace(/\\s*--save(?!-)/, '')\n\t\t\t.replace('--no-package-lock', '--no-lockfile');\n\n\t\tif (/ -(?:-global|g)(?![^\\b])/.test(yarnRemoveCommand)) {\n\t\t\tyarnRemoveCommand = yarnRemoveCommand.replace(/ -(?:-global|g)(?![^\\b])/, '');\n\t\t\tyarnRemoveCommand = `global ${yarnRemoveCommand}`;\n\t\t}\n\n\t\treturn yarnRemoveCommand;\n\t},\n\n\trebuild(command: string) {\n\t\treturn command.replace('rebuild', 'add --force');\n\t},\n\n\texec(command: string) {\n\t\treturn command.replace(/^exec\\s?([^\\s]+)?(\\s--\\s--)?(.*)$/, (_, data?: string, dash?: string, rest?: string): string => {\n\t\t\tlet result = '';\n\n\t\t\tif (data && !unchangedCLICommands.includes(data) && !yarnCLICommands.includes(data)) {\n\t\t\t\tresult += data;\n\t\t\t} else {\n\t\t\t\tresult += `run ${data || ''}`;\n\t\t\t}\n\n\t\t\tif (dash) {\n\t\t\t\tresult += dash.replace(/^\\s--/, '');\n\t\t\t}\n\n\t\t\tif (rest) {\n\t\t\t\tresult += rest;\n\t\t\t}\n\n\t\t\treturn result;\n\t\t});\n\t},\n\n\trun(command: string) {\n\t\treturn command.replace(/^run\\s?([^\\s]+)?(\\s--\\s--)?(.*)$/, (_, data?: string, dash?: string, rest?: string): string => {\n\t\t\tlet result = '';\n\n\t\t\tif (data && !unchangedCLICommands.includes(data) && !yarnCLICommands.includes(data)) {\n\t\t\t\tresult += data;\n\t\t\t} else {\n\t\t\t\tresult += `run ${data || ''}`;\n\t\t\t}\n\n\t\t\tif (dash) {\n\t\t\t\tresult += dash.replace(/^\\s--/, '');\n\t\t\t}\n\n\t\t\tif (rest) {\n\t\t\t\tresult += rest;\n\t\t\t}\n\n\t\t\treturn result;\n\t\t});\n\t},\n\n\tls(command: string) {\n\t\treturn command.replace(/^(ls|list)(.*)$/, (_1, _2: string, args: string): string => {\n\t\t\tlet result = 'list';\n\n\t\t\tif (args) {\n\t\t\t\tlet ended = false;\n\t\t\t\tlet packages = [];\n\t\t\t\tconst items = args.split(' ').filter(Boolean);\n\n\t\t\t\tfor (const item of items) {\n\t\t\t\t\tif (ended) {\n\t\t\t\t\t\tresult += ` ${item}`;\n\t\t\t\t\t} else if (item.startsWith('-')) {\n\t\t\t\t\t\tresult += ` --pattern \"${packages.join('|')}\"`;\n\t\t\t\t\t\tpackages = [];\n\t\t\t\t\t\tended = true;\n\t\t\t\t\t\tresult += ` ${item}`;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tpackages.push(item);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif (packages.length > 0) {\n\t\t\t\t\tresult += ` --pattern \"${packages.join('|')}\"`;\n\t\t\t\t}\n\n\t\t\t\treturn result;\n\t\t\t}\n\n\t\t\treturn 'list';\n\t\t});\n\t},\n\n\tlist(command: string) {\n\t\treturn npmToYarnTable.ls(command);\n\t},\n\n\tinit(command: string) {\n\t\tif (/^init (?!-).*$/.test(command)) {\n\t\t\treturn command.replace('init', 'create');\n\t\t}\n\n\t\treturn command.replace(' --scope', '');\n\t}\n} as const;\n\nfunction convert(_: string, command: string) {\n\tcommand = (command || '').trim();\n\tconst firstCommand = (/\\w+/.exec(command) || [''])[0];\n\n\tif (unchangedCLICommands.includes(firstCommand)) {\n\t\treturn `yarn ${command}`;\n\t}\n\n\tif (firstCommand in npmToYarnTable) {\n\t\tconst converter = npmToYarnTable[firstCommand as keyof typeof npmToYarnTable];\n\n\t\tif (typeof converter === 'function') {\n\t\t\treturn `yarn ${converter(command)}`;\n\t\t}\n\n\t\treturn `yarn ${command.replace(firstCommand, converter)}`;\n\t}\n\n\treturn `yarn ${command}\\n# couldn't auto-convert command`;\n}\n\nexport function npmToYarn(str: string) {\n\treturn str.replace(/npm(?: +([^&\\n\\r]*))?/gm, convert);\n}\n","import type { Code, Content, Literal } from 'mdast';\nimport type { Plugin } from 'unified';\nimport type { Node, Parent } from 'unist';\nimport visit from 'unist-util-visit';\nimport { npmToPnpm } from './npm2pnpm';\nimport { npmToYarn } from './npm2yarn';\n\n/**\n * Transforms a Docusaurus node from NPM to Yarn and Pnpm\n * @param node The Docusaurus node to transform\n * @param options The plugin options to pass to the transformer\n * @returns The transformed node in the form of Tabs.\n */\nconst transformNode = (node: Code, options: PluginOptions) => {\n\tconst groupIdProp = options.sync ? ' groupId=\"npm2yarn2pnpm\"' : '';\n\tconst npmCode = node.value;\n\n\tconst yarnCode = npmToYarn(node.value);\n\tconst pnpmCode = npmToPnpm(node.value);\n\n\tconst [, highlight] = (node.meta ?? '').split('|');\n\n\treturn [\n\t\t{\n\t\t\ttype: 'jsx',\n\t\t\tvalue: `<Tabs${groupIdProp}\n\t\t\t\t\t\tdefaultValue=\"npm\"\n\t\t\t\t\t\tvalues={[\n\t\t\t\t\t\t\t{ label: \"npm\", value: \"npm\" },\n\t\t\t\t\t\t\t{ label: \"yarn\", value: \"yarn\" },\n\t\t\t\t\t\t\t{ label: \"pnpm\", value: \"pnpm\" },\n\t\t\t\t\t\t]}\n\t\t\t>\\n<TabItem value=\"npm\">`\n\t\t},\n\t\t{\n\t\t\ttype: node.type,\n\t\t\tlang: node.lang,\n\t\t\tmeta: `${highlight} showLineNumbers`,\n\t\t\tvalue: npmCode\n\t\t},\n\t\t{\n\t\t\ttype: 'jsx',\n\t\t\tvalue: '</TabItem>\\n<TabItem value=\"yarn\" label=\"Yarn\">'\n\t\t},\n\t\t{\n\t\t\ttype: node.type,\n\t\t\tlang: node.lang,\n\t\t\tmeta: `${highlight} showLineNumbers`,\n\t\t\tvalue: yarnCode\n\t\t},\n\t\t{\n\t\t\ttype: 'jsx',\n\t\t\tvalue: '</TabItem>\\n<TabItem value=\"pnpm\">'\n\t\t},\n\t\t{\n\t\t\ttype: node.type,\n\t\t\tlang: node.lang,\n\t\t\tmeta: `${highlight} showLineNumbers`,\n\t\t\tvalue: pnpmCode\n\t\t},\n\t\t{\n\t\t\ttype: 'jsx',\n\t\t\tvalue: '</TabItem>\\n</Tabs>'\n\t\t}\n\t] as Content[];\n};\n\nconst isImport = (node: Node): node is Literal => node.type === 'import';\nconst isParent = (node: Node): node is Parent => Array.isArray((node as Parent).children);\nconst matchNode = (node: Node): node is Code =>\n\tnode.type === 'code' && typeof (node as Code).meta === 'string' && ((node as Code).meta ?? '').startsWith('npm2yarn2pnpm');\nconst nodeForImport: Literal = {\n\ttype: 'import',\n\tvalue: \"import Tabs from '@theme/Tabs';\\nimport TabItem from '@theme/TabItem';\"\n};\n\nexport interface PluginOptions {\n\tsync?: boolean;\n}\n\nexport const npm2yarn2pnpm: Plugin<[PluginOptions?]> =\n\t({ sync = true } = { sync: true }) =>\n\t(root) => {\n\t\tlet transformed = false;\n\t\tlet alreadyImported = false;\n\t\tvisit(root, (node: Node) => {\n\t\t\tif (isImport(node) && node.value.includes('@theme/Tabs')) {\n\t\t\t\talreadyImported = true;\n\t\t\t}\n\t\t\tif (isParent(node)) {\n\t\t\t\tlet index = 0;\n\t\t\t\twhile (index < node.children.length) {\n\t\t\t\t\tconst child = node.children[index]!;\n\t\t\t\t\tif (matchNode(child)) {\n\t\t\t\t\t\tconst result = transformNode(child, { sync });\n\t\t\t\t\t\tnode.children.splice(index, 1, ...result);\n\t\t\t\t\t\tindex += result.length;\n\t\t\t\t\t\ttransformed = true;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tindex += 1;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t\tif (transformed && !alreadyImported) {\n\t\t\t(root as Parent).children.unshift(nodeForImport);\n\t\t}\n\t};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACOA,IAAM,uBAAuB,CAAC,QAAQ,OAAO,QAAQ,SAAS,UAAU,QAAQ,WAAW,OAAO;AAElG,SAAS,gBAAgB,SAAiB,cAAc,OAAO;AAC9D,MAAI,cAAc,KAAK,OAAO,GAAG;AAChC,WAAO;AAAA,EACR;AAEA,SAAO,QACL,QAAQ,cAAc,OAAO,YAAY,MAAM,EAC/C,QAAQ,oBAAoB,eAAe,EAC3C,QAAQ,qBAAqB,EAAE;AAClC;AAEA,IAAM,iBAAiB;AAAA,EACtB,QAAQ,SAAiB;AACxB,WAAO,gBAAgB,OAAO;AAAA,EAC/B;AAAA,EAEA,EAAE,SAAiB;AAClB,WAAO,gBAAgB,SAAS,IAAI;AAAA,EACrC;AAAA,EAEA,UAAU,SAAiB;AAC1B,WAAO,QACL,QAAQ,aAAa,QAAQ,EAC7B,QAAQ,oBAAoB,eAAe,EAC3C,QAAQ,qBAAqB,EAAE;AAAA,EAClC;AAAA,EAEA,QAAQ,SAAiB;AACxB,WAAO,QAAQ,QAAQ,uBAAuB,MAAM;AAAA,EACrD;AAAA,EAEA,QAAQ,SAAiB;AACxB,WAAO,QAAQ,QAAQ,WAAW,aAAa;AAAA,EAChD;AACD;AAEA,SAAS,QAAQ,GAAW,SAAiB;AAC5C,aA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;AAAA,IACA;AAAA,MACC,MAAM;AAAA,MACN,OAAO;AAAA,IACR;AAAA,EACD;AACD;AAEA,IAAM,WAAW,CAAC,SAAgC,KAAK,SAAS;AAChE,IAAM,WAAW,CAAC,SAA+B,MAAM,QAAS,KAAgB,QAAQ;AACxF,IAAM,YAAY,CAAC,SAClB,KAAK,SAAS,UAAU,OAAQ,KAAc,SAAS,aAAc,KAAc,QAAQ,IAAI,WAAW,eAAe;AAC1H,IAAM,gBAAyB;AAAA,EAC9B,MAAM;AAAA,EACN,OAAO;AACR;AAMO,IAAM,gBACZ,CAAC,EAAE,OAAO,KAAK,IAAI,EAAE,MAAM,KAAK,MAChC,CAAC,SAAS;AACT,MAAI,cAAc;AAClB,MAAI,kBAAkB;AACtB,8BAAAC,SAAM,MAAM,CAAC,SAAe;AAC3B,QAAI,SAAS,IAAI,KAAK,KAAK,MAAM,SAAS,aAAa,GAAG;AACzD,wBAAkB;AAAA,IACnB;AACA,QAAI,SAAS,IAAI,GAAG;AACnB,UAAI,QAAQ;AACZ,aAAO,QAAQ,KAAK,SAAS,QAAQ;AACpC,cAAM,QAAQ,KAAK,SAAS;AAC5B,YAAI,UAAU,KAAK,GAAG;AACrB,gBAAM,SAAS,cAAc,OAAO,EAAE,KAAK,CAAC;AAC5C,eAAK,SAAS,OAAO,OAAO,GAAG,GAAG,MAAM;AACxC,mBAAS,OAAO;AAChB,wBAAc;AAAA,QACf,OAAO;AACN,mBAAS;AAAA,QACV;AAAA,MACD;AAAA,IACD;AAAA,EACD,CAAC;AACD,MAAI,eAAe,CAAC,iBAAiB;AACpC,IAAC,KAAgB,SAAS,QAAQ,aAAa;AAAA,EAChD;AACD;","names":["unchangedCLICommands","parseNpmInstall","convert","visit"]}
|
package/dist/index.mjs
CHANGED
|
@@ -1,11 +1,17 @@
|
|
|
1
1
|
// src/npm2pnpm.ts
|
|
2
2
|
var unchangedCLICommands = ["init", "run", "test", "login", "logout", "link", "publish", "cache"];
|
|
3
|
+
function parseNpmInstall(command, isShortHand = false) {
|
|
4
|
+
if (/^install *$/.test(command)) {
|
|
5
|
+
return "install";
|
|
6
|
+
}
|
|
7
|
+
return command.replace(isShortHand ? "i " : "install ", "add ").replace(/(\s*)--save(?!-)/, "$1--save-prod").replace("--no-package-lock", "");
|
|
8
|
+
}
|
|
3
9
|
var npmToPnpmTable = {
|
|
4
10
|
install(command) {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
return command
|
|
11
|
+
return parseNpmInstall(command);
|
|
12
|
+
},
|
|
13
|
+
i(command) {
|
|
14
|
+
return parseNpmInstall(command, true);
|
|
9
15
|
},
|
|
10
16
|
uninstall(command) {
|
|
11
17
|
return command.replace("uninstall", "remove").replace(/(\s*)--save(?!-)/, "$1--save-prod").replace("--no-package-lock", "");
|
|
@@ -35,13 +41,173 @@ function npmToPnpm(str) {
|
|
|
35
41
|
return str.replace(/npm(?: +([^&\n\r]*))?/gm, convert);
|
|
36
42
|
}
|
|
37
43
|
|
|
44
|
+
// src/npm2yarn.ts
|
|
45
|
+
var unchangedCLICommands2 = ["test", "login", "logout", "link", "publish", "cache"];
|
|
46
|
+
var yarnCLICommands = [
|
|
47
|
+
"init",
|
|
48
|
+
"run",
|
|
49
|
+
"add",
|
|
50
|
+
"audit",
|
|
51
|
+
"autoclean",
|
|
52
|
+
"bin",
|
|
53
|
+
"check",
|
|
54
|
+
"config",
|
|
55
|
+
"create",
|
|
56
|
+
"dedupe",
|
|
57
|
+
"generate-lock-entry",
|
|
58
|
+
"global",
|
|
59
|
+
"help",
|
|
60
|
+
"import",
|
|
61
|
+
"info",
|
|
62
|
+
"install",
|
|
63
|
+
"licenses",
|
|
64
|
+
"list",
|
|
65
|
+
"lockfile",
|
|
66
|
+
"outdated",
|
|
67
|
+
"owner",
|
|
68
|
+
"pack",
|
|
69
|
+
"policies",
|
|
70
|
+
"prune",
|
|
71
|
+
"remove",
|
|
72
|
+
"self-update",
|
|
73
|
+
"tag",
|
|
74
|
+
"team",
|
|
75
|
+
"link",
|
|
76
|
+
"unlink",
|
|
77
|
+
"upgrade",
|
|
78
|
+
"upgrade-interactive",
|
|
79
|
+
"version",
|
|
80
|
+
"versions",
|
|
81
|
+
"why",
|
|
82
|
+
"workspace",
|
|
83
|
+
"workspaces"
|
|
84
|
+
];
|
|
85
|
+
function parseNpmInstall2(command, isShortHand = false) {
|
|
86
|
+
if (/^install *$/.test(command)) {
|
|
87
|
+
return "install";
|
|
88
|
+
}
|
|
89
|
+
let yarnAddCommand = command.replace(isShortHand ? "i " : "install ", "add ").replace("--save-dev", "--dev").replace(/\s*--save(?!-)/, "").replace("--no-package-lock", "--no-lockfile").replace("--save-optional", "--optional").replace("--save-exact", "--exact");
|
|
90
|
+
if (/ -(?:-global|g)(?![^\b])/.test(yarnAddCommand)) {
|
|
91
|
+
yarnAddCommand = yarnAddCommand.replace(/ -(?:-global|g)(?![^\b])/, "");
|
|
92
|
+
yarnAddCommand = `global ${yarnAddCommand}`;
|
|
93
|
+
}
|
|
94
|
+
return yarnAddCommand;
|
|
95
|
+
}
|
|
96
|
+
var npmToYarnTable = {
|
|
97
|
+
install(command) {
|
|
98
|
+
return parseNpmInstall2(command);
|
|
99
|
+
},
|
|
100
|
+
i(command) {
|
|
101
|
+
return parseNpmInstall2(command, true);
|
|
102
|
+
},
|
|
103
|
+
uninstall(command) {
|
|
104
|
+
let yarnRemoveCommand = command.replace("uninstall", "remove").replace("--save-dev", "--dev").replace(/\s*--save(?!-)/, "").replace("--no-package-lock", "--no-lockfile");
|
|
105
|
+
if (/ -(?:-global|g)(?![^\b])/.test(yarnRemoveCommand)) {
|
|
106
|
+
yarnRemoveCommand = yarnRemoveCommand.replace(/ -(?:-global|g)(?![^\b])/, "");
|
|
107
|
+
yarnRemoveCommand = `global ${yarnRemoveCommand}`;
|
|
108
|
+
}
|
|
109
|
+
return yarnRemoveCommand;
|
|
110
|
+
},
|
|
111
|
+
rebuild(command) {
|
|
112
|
+
return command.replace("rebuild", "add --force");
|
|
113
|
+
},
|
|
114
|
+
exec(command) {
|
|
115
|
+
return command.replace(/^exec\s?([^\s]+)?(\s--\s--)?(.*)$/, (_, data, dash, rest) => {
|
|
116
|
+
let result = "";
|
|
117
|
+
if (data && !unchangedCLICommands2.includes(data) && !yarnCLICommands.includes(data)) {
|
|
118
|
+
result += data;
|
|
119
|
+
} else {
|
|
120
|
+
result += `run ${data || ""}`;
|
|
121
|
+
}
|
|
122
|
+
if (dash) {
|
|
123
|
+
result += dash.replace(/^\s--/, "");
|
|
124
|
+
}
|
|
125
|
+
if (rest) {
|
|
126
|
+
result += rest;
|
|
127
|
+
}
|
|
128
|
+
return result;
|
|
129
|
+
});
|
|
130
|
+
},
|
|
131
|
+
run(command) {
|
|
132
|
+
return command.replace(/^run\s?([^\s]+)?(\s--\s--)?(.*)$/, (_, data, dash, rest) => {
|
|
133
|
+
let result = "";
|
|
134
|
+
if (data && !unchangedCLICommands2.includes(data) && !yarnCLICommands.includes(data)) {
|
|
135
|
+
result += data;
|
|
136
|
+
} else {
|
|
137
|
+
result += `run ${data || ""}`;
|
|
138
|
+
}
|
|
139
|
+
if (dash) {
|
|
140
|
+
result += dash.replace(/^\s--/, "");
|
|
141
|
+
}
|
|
142
|
+
if (rest) {
|
|
143
|
+
result += rest;
|
|
144
|
+
}
|
|
145
|
+
return result;
|
|
146
|
+
});
|
|
147
|
+
},
|
|
148
|
+
ls(command) {
|
|
149
|
+
return command.replace(/^(ls|list)(.*)$/, (_1, _2, args) => {
|
|
150
|
+
let result = "list";
|
|
151
|
+
if (args) {
|
|
152
|
+
let ended = false;
|
|
153
|
+
let packages = [];
|
|
154
|
+
const items = args.split(" ").filter(Boolean);
|
|
155
|
+
for (const item of items) {
|
|
156
|
+
if (ended) {
|
|
157
|
+
result += ` ${item}`;
|
|
158
|
+
} else if (item.startsWith("-")) {
|
|
159
|
+
result += ` --pattern "${packages.join("|")}"`;
|
|
160
|
+
packages = [];
|
|
161
|
+
ended = true;
|
|
162
|
+
result += ` ${item}`;
|
|
163
|
+
} else {
|
|
164
|
+
packages.push(item);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
if (packages.length > 0) {
|
|
168
|
+
result += ` --pattern "${packages.join("|")}"`;
|
|
169
|
+
}
|
|
170
|
+
return result;
|
|
171
|
+
}
|
|
172
|
+
return "list";
|
|
173
|
+
});
|
|
174
|
+
},
|
|
175
|
+
list(command) {
|
|
176
|
+
return npmToYarnTable.ls(command);
|
|
177
|
+
},
|
|
178
|
+
init(command) {
|
|
179
|
+
if (/^init (?!-).*$/.test(command)) {
|
|
180
|
+
return command.replace("init", "create");
|
|
181
|
+
}
|
|
182
|
+
return command.replace(" --scope", "");
|
|
183
|
+
}
|
|
184
|
+
};
|
|
185
|
+
function convert2(_, command) {
|
|
186
|
+
command = (command || "").trim();
|
|
187
|
+
const firstCommand = (/\w+/.exec(command) || [""])[0];
|
|
188
|
+
if (unchangedCLICommands2.includes(firstCommand)) {
|
|
189
|
+
return `yarn ${command}`;
|
|
190
|
+
}
|
|
191
|
+
if (firstCommand in npmToYarnTable) {
|
|
192
|
+
const converter = npmToYarnTable[firstCommand];
|
|
193
|
+
if (typeof converter === "function") {
|
|
194
|
+
return `yarn ${converter(command)}`;
|
|
195
|
+
}
|
|
196
|
+
return `yarn ${command.replace(firstCommand, converter)}`;
|
|
197
|
+
}
|
|
198
|
+
return `yarn ${command}
|
|
199
|
+
# couldn't auto-convert command`;
|
|
200
|
+
}
|
|
201
|
+
function npmToYarn(str) {
|
|
202
|
+
return str.replace(/npm(?: +([^&\n\r]*))?/gm, convert2);
|
|
203
|
+
}
|
|
204
|
+
|
|
38
205
|
// src/npm2yarn2pnpm.ts
|
|
39
|
-
import { convertToYarn } from "@armano/npm-to-yarn";
|
|
40
206
|
import visit from "unist-util-visit";
|
|
41
207
|
var transformNode = (node, options) => {
|
|
42
208
|
const groupIdProp = options.sync ? ' groupId="npm2yarn2pnpm"' : "";
|
|
43
209
|
const npmCode = node.value;
|
|
44
|
-
const yarnCode =
|
|
210
|
+
const yarnCode = npmToYarn(node.value);
|
|
45
211
|
const pnpmCode = npmToPnpm(node.value);
|
|
46
212
|
const [, highlight] = (node.meta ?? "").split("|");
|
|
47
213
|
return [
|
|
@@ -124,6 +290,7 @@ var npm2yarn2pnpm = ({ sync = true } = { sync: true }) => (root) => {
|
|
|
124
290
|
};
|
|
125
291
|
export {
|
|
126
292
|
npm2yarn2pnpm,
|
|
127
|
-
npmToPnpm
|
|
293
|
+
npmToPnpm,
|
|
294
|
+
npmToYarn
|
|
128
295
|
};
|
|
129
296
|
//# sourceMappingURL=index.mjs.map
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/npm2pnpm.ts","../src/npm2yarn2pnpm.ts"],"sourcesContent":["/**\n * Copyright (c) 2019 Ben Gubler <nebrelbug@gmail.com>\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nconst unchangedCLICommands = ['init', 'run', 'test', 'login', 'logout', 'link', 'publish', 'cache'];\n\nconst npmToPnpmTable = {\n\tinstall(command: string) {\n\t\tif (/^install *$/.test(command)) {\n\t\t\treturn 'install';\n\t\t}\n\n\t\treturn command\n\t\t\t.replace('install', 'add')\n\t\t\t.replace(/(\\s*)--save(?!-)/, '$1--save-prod')\n\t\t\t.replace('--no-package-lock', '');\n\t},\n\n\tuninstall(command: string) {\n\t\treturn command\n\t\t\t.replace('uninstall', 'remove')\n\t\t\t.replace(/(\\s*)--save(?!-)/, '$1--save-prod')\n\t\t\t.replace('--no-package-lock', '');\n\t},\n\n\tversion(command: string) {\n\t\treturn command.replace(/(major|minor|patch)/, '--$1');\n\t},\n\n\trebuild(command: string) {\n\t\treturn command.replace('rebuild', 'add --force');\n\t}\n} as const;\n\nfunction convert(_: string, command: string) {\n\tcommand = (command ?? '').trim();\n\n\tconst firstCommand = (/\\w+/.exec(command) || [''])[0] as keyof typeof npmToPnpmTable;\n\n\tif (unchangedCLICommands.includes(firstCommand)) {\n\t\treturn `pnpm ${command}`;\n\t} else if (Object.prototype.hasOwnProperty.call(npmToPnpmTable, firstCommand) && npmToPnpmTable[firstCommand]) {\n\t\tif (typeof npmToPnpmTable[firstCommand] === 'function') {\n\t\t\treturn `pnpm ${npmToPnpmTable[firstCommand](command)}`;\n\t\t}\n\t\treturn `pnpm ${command.replace(firstCommand, npmToPnpmTable[firstCommand])}`;\n\t}\n\n\treturn `pnpm ${command}\\n# couldn't auto-convert command`;\n}\n\nexport function npmToPnpm(str: string) {\n\treturn str.replace(/npm(?: +([^&\\n\\r]*))?/gm, convert);\n}\n","import { convertToYarn } from '@armano/npm-to-yarn';\nimport type { Code, Content, Literal } from 'mdast';\nimport type { Plugin } from 'unified';\nimport type { Node, Parent } from 'unist';\nimport visit from 'unist-util-visit';\nimport { npmToPnpm } from './npm2pnpm';\n\n/**\n * Transforms a Docusaurus node from NPM to Yarn and Pnpm\n * @param node The Docusaurus node to transform\n * @param options The plugin options to pass to the transformer\n * @returns The transformed node in the form of Tabs.\n */\nconst transformNode = (node: Code, options: PluginOptions) => {\n\tconst groupIdProp = options.sync ? ' groupId=\"npm2yarn2pnpm\"' : '';\n\tconst npmCode = node.value;\n\n\tconst yarnCode = convertToYarn(node.value);\n\tconst pnpmCode = npmToPnpm(node.value);\n\n\tconst [, highlight] = (node.meta ?? '').split('|');\n\n\treturn [\n\t\t{\n\t\t\ttype: 'jsx',\n\t\t\tvalue: `<Tabs${groupIdProp}\n\t\t\t\t\t\tdefaultValue=\"npm\"\n\t\t\t\t\t\tvalues={[\n\t\t\t\t\t\t\t{ label: \"npm\", value: \"npm\" },\n\t\t\t\t\t\t\t{ label: \"yarn\", value: \"yarn\" },\n\t\t\t\t\t\t\t{ label: \"pnpm\", value: \"pnpm\" },\n\t\t\t\t\t\t]}\n\t\t\t>\\n<TabItem value=\"npm\">`\n\t\t},\n\t\t{\n\t\t\ttype: node.type,\n\t\t\tlang: node.lang,\n\t\t\tmeta: `${highlight} showLineNumbers`,\n\t\t\tvalue: npmCode\n\t\t},\n\t\t{\n\t\t\ttype: 'jsx',\n\t\t\tvalue: '</TabItem>\\n<TabItem value=\"yarn\" label=\"Yarn\">'\n\t\t},\n\t\t{\n\t\t\ttype: node.type,\n\t\t\tlang: node.lang,\n\t\t\tmeta: `${highlight} showLineNumbers`,\n\t\t\tvalue: yarnCode\n\t\t},\n\t\t{\n\t\t\ttype: 'jsx',\n\t\t\tvalue: '</TabItem>\\n<TabItem value=\"pnpm\">'\n\t\t},\n\t\t{\n\t\t\ttype: node.type,\n\t\t\tlang: node.lang,\n\t\t\tmeta: `${highlight} showLineNumbers`,\n\t\t\tvalue: pnpmCode\n\t\t},\n\t\t{\n\t\t\ttype: 'jsx',\n\t\t\tvalue: '</TabItem>\\n</Tabs>'\n\t\t}\n\t] as Content[];\n};\n\nconst isImport = (node: Node): node is Literal => node.type === 'import';\nconst isParent = (node: Node): node is Parent => Array.isArray((node as Parent).children);\nconst matchNode = (node: Node): node is Code =>\n\tnode.type === 'code' && typeof (node as Code).meta === 'string' && ((node as Code).meta ?? '').startsWith('npm2yarn2pnpm');\nconst nodeForImport: Literal = {\n\ttype: 'import',\n\tvalue: \"import Tabs from '@theme/Tabs';\\nimport TabItem from '@theme/TabItem';\"\n};\n\nexport interface PluginOptions {\n\tsync?: boolean;\n}\n\nexport const npm2yarn2pnpm: Plugin<[PluginOptions?]> =\n\t({ sync = true } = { sync: true }) =>\n\t(root) => {\n\t\tlet transformed = false;\n\t\tlet alreadyImported = false;\n\t\tvisit(root, (node: Node) => {\n\t\t\tif (isImport(node) && node.value.includes('@theme/Tabs')) {\n\t\t\t\talreadyImported = true;\n\t\t\t}\n\t\t\tif (isParent(node)) {\n\t\t\t\tlet index = 0;\n\t\t\t\twhile (index < node.children.length) {\n\t\t\t\t\tconst child = node.children[index]!;\n\t\t\t\t\tif (matchNode(child)) {\n\t\t\t\t\t\tconst result = transformNode(child, { sync });\n\t\t\t\t\t\tnode.children.splice(index, 1, ...result);\n\t\t\t\t\t\tindex += result.length;\n\t\t\t\t\t\ttransformed = true;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tindex += 1;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t\tif (transformed && !alreadyImported) {\n\t\t\t(root as Parent).children.unshift(nodeForImport);\n\t\t}\n\t};\n"],"mappings":";AAOA,IAAM,uBAAuB,CAAC,QAAQ,OAAO,QAAQ,SAAS,UAAU,QAAQ,WAAW,OAAO;AAElG,IAAM,iBAAiB;AAAA,EACtB,QAAQ,SAAiB;AACxB,QAAI,cAAc,KAAK,OAAO,GAAG;AAChC,aAAO;AAAA,IACR;AAEA,WAAO,QACL,QAAQ,WAAW,KAAK,EACxB,QAAQ,oBAAoB,eAAe,EAC3C,QAAQ,qBAAqB,EAAE;AAAA,EAClC;AAAA,EAEA,UAAU,SAAiB;AAC1B,WAAO,QACL,QAAQ,aAAa,QAAQ,EAC7B,QAAQ,oBAAoB,eAAe,EAC3C,QAAQ,qBAAqB,EAAE;AAAA,EAClC;AAAA,EAEA,QAAQ,SAAiB;AACxB,WAAO,QAAQ,QAAQ,uBAAuB,MAAM;AAAA,EACrD;AAAA,EAEA,QAAQ,SAAiB;AACxB,WAAO,QAAQ,QAAQ,WAAW,aAAa;AAAA,EAChD;AACD;AAEA,SAAS,QAAQ,GAAW,SAAiB;AAC5C,aAAW,WAAW,IAAI,KAAK;AAE/B,QAAM,gBAAgB,MAAM,KAAK,OAAO,KAAK,CAAC,EAAE,GAAG;AAEnD,MAAI,qBAAqB,SAAS,YAAY,GAAG;AAChD,WAAO,QAAQ;AAAA,EAChB,WAAW,OAAO,UAAU,eAAe,KAAK,gBAAgB,YAAY,KAAK,eAAe,eAAe;AAC9G,QAAI,OAAO,eAAe,kBAAkB,YAAY;AACvD,aAAO,QAAQ,eAAe,cAAc,OAAO;AAAA,IACpD;AACA,WAAO,QAAQ,QAAQ,QAAQ,cAAc,eAAe,aAAa;AAAA,EAC1E;A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AM,gBAAyB;AAAA,EAC9B,MAAM;AAAA,EACN,OAAO;AACR;AAMO,IAAM,gBACZ,CAAC,EAAE,OAAO,KAAK,IAAI,EAAE,MAAM,KAAK,MAChC,CAAC,SAAS;AACT,MAAI,cAAc;AAClB,MAAI,kBAAkB;AACtB,QAAM,MAAM,CAAC,SAAe;AAC3B,QAAI,SAAS,IAAI,KAAK,KAAK,MAAM,SAAS,aAAa,GAAG;AACzD,wBAAkB;AAAA,IACnB;AACA,QAAI,SAAS,IAAI,GAAG;AACnB,UAAI,QAAQ;AACZ,aAAO,QAAQ,KAAK,SAAS,QAAQ;AACpC,cAAM,QAAQ,KAAK,SAAS;AAC5B,YAAI,UAAU,KAAK,GAAG;AACrB,gBAAM,SAAS,cAAc,OAAO,EAAE,KAAK,CAAC;AAC5C,eAAK,SAAS,OAAO,OAAO,GAAG,GAAG,MAAM;AACxC,mBAAS,OAAO;AAChB,wBAAc;AAAA,QACf,OAAO;AACN,mBAAS;AAAA,QACV;AAAA,MACD;AAAA,IACD;AAAA,EACD,CAAC;AACD,MAAI,eAAe,CAAC,iBAAiB;AACpC,IAAC,KAAgB,SAAS,QAAQ,aAAa;AAAA,EAChD;AACD;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../src/npm2pnpm.ts","../src/npm2yarn.ts","../src/npm2yarn2pnpm.ts"],"sourcesContent":["/**\n * Copyright (c) 2019 Ben Gubler <nebrelbug@gmail.com>\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nconst unchangedCLICommands = ['init', 'run', 'test', 'login', 'logout', 'link', 'publish', 'cache'];\n\nfunction parseNpmInstall(command: string, isShortHand = false) {\n\tif (/^install *$/.test(command)) {\n\t\treturn 'install';\n\t}\n\n\treturn command\n\t\t.replace(isShortHand ? 'i ' : 'install ', 'add ')\n\t\t.replace(/(\\s*)--save(?!-)/, '$1--save-prod')\n\t\t.replace('--no-package-lock', '');\n}\n\nconst npmToPnpmTable = {\n\tinstall(command: string) {\n\t\treturn parseNpmInstall(command);\n\t},\n\n\ti(command: string) {\n\t\treturn parseNpmInstall(command, true);\n\t},\n\n\tuninstall(command: string) {\n\t\treturn command\n\t\t\t.replace('uninstall', 'remove')\n\t\t\t.replace(/(\\s*)--save(?!-)/, '$1--save-prod')\n\t\t\t.replace('--no-package-lock', '');\n\t},\n\n\tversion(command: string) {\n\t\treturn command.replace(/(major|minor|patch)/, '--$1');\n\t},\n\n\trebuild(command: string) {\n\t\treturn command.replace('rebuild', 'add --force');\n\t}\n} as const;\n\nfunction convert(_: string, command: string) {\n\tcommand = (command ?? '').trim();\n\n\tconst firstCommand = (/\\w+/.exec(command) || [''])[0] as keyof typeof npmToPnpmTable;\n\n\tif (unchangedCLICommands.includes(firstCommand)) {\n\t\treturn `pnpm ${command}`;\n\t} else if (Object.prototype.hasOwnProperty.call(npmToPnpmTable, firstCommand) && npmToPnpmTable[firstCommand]) {\n\t\tif (typeof npmToPnpmTable[firstCommand] === 'function') {\n\t\t\treturn `pnpm ${npmToPnpmTable[firstCommand](command)}`;\n\t\t}\n\t\treturn `pnpm ${command.replace(firstCommand, npmToPnpmTable[firstCommand])}`;\n\t}\n\n\treturn `pnpm ${command}\\n# couldn't auto-convert command`;\n}\n\nexport function npmToPnpm(str: string) {\n\treturn str.replace(/npm(?: +([^&\\n\\r]*))?/gm, convert);\n}\n","/**\n * Copyright (c) 2019 Ben Gubler <nebrelbug@gmail.com>\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nexport const unchangedCLICommands = ['test', 'login', 'logout', 'link', 'publish', 'cache'];\nexport const yarnCLICommands = [\n\t'init',\n\t'run',\n\t'add',\n\t'audit',\n\t'autoclean',\n\t'bin',\n\t'check',\n\t'config',\n\t'create',\n\t'dedupe',\n\t'generate-lock-entry',\n\t'global',\n\t'help',\n\t'import',\n\t'info',\n\t'install',\n\t'licenses',\n\t'list',\n\t'lockfile',\n\t'outdated',\n\t'owner',\n\t'pack',\n\t'policies',\n\t'prune',\n\t'remove',\n\t'self-update',\n\t'tag',\n\t'team',\n\t'link',\n\t'unlink',\n\t'upgrade',\n\t'upgrade-interactive',\n\t'version',\n\t'versions',\n\t'why',\n\t'workspace',\n\t'workspaces'\n];\n\nfunction parseNpmInstall(command: string, isShortHand = false) {\n\tif (/^install *$/.test(command)) {\n\t\treturn 'install';\n\t}\n\n\tlet yarnAddCommand = command\n\t\t.replace(isShortHand ? 'i ' : 'install ', 'add ')\n\t\t.replace('--save-dev', '--dev')\n\t\t.replace(/\\s*--save(?!-)/, '')\n\t\t.replace('--no-package-lock', '--no-lockfile')\n\t\t.replace('--save-optional', '--optional')\n\t\t.replace('--save-exact', '--exact');\n\n\tif (/ -(?:-global|g)(?![^\\b])/.test(yarnAddCommand)) {\n\t\tyarnAddCommand = yarnAddCommand.replace(/ -(?:-global|g)(?![^\\b])/, '');\n\t\tyarnAddCommand = `global ${yarnAddCommand}`;\n\t}\n\n\treturn yarnAddCommand;\n}\n\nconst npmToYarnTable = {\n\tinstall(command: string) {\n\t\treturn parseNpmInstall(command);\n\t},\n\n\ti(command: string) {\n\t\treturn parseNpmInstall(command, true);\n\t},\n\n\tuninstall(command: string) {\n\t\tlet yarnRemoveCommand = command\n\t\t\t.replace('uninstall', 'remove')\n\t\t\t.replace('--save-dev', '--dev')\n\t\t\t.replace(/\\s*--save(?!-)/, '')\n\t\t\t.replace('--no-package-lock', '--no-lockfile');\n\n\t\tif (/ -(?:-global|g)(?![^\\b])/.test(yarnRemoveCommand)) {\n\t\t\tyarnRemoveCommand = yarnRemoveCommand.replace(/ -(?:-global|g)(?![^\\b])/, '');\n\t\t\tyarnRemoveCommand = `global ${yarnRemoveCommand}`;\n\t\t}\n\n\t\treturn yarnRemoveCommand;\n\t},\n\n\trebuild(command: string) {\n\t\treturn command.replace('rebuild', 'add --force');\n\t},\n\n\texec(command: string) {\n\t\treturn command.replace(/^exec\\s?([^\\s]+)?(\\s--\\s--)?(.*)$/, (_, data?: string, dash?: string, rest?: string): string => {\n\t\t\tlet result = '';\n\n\t\t\tif (data && !unchangedCLICommands.includes(data) && !yarnCLICommands.includes(data)) {\n\t\t\t\tresult += data;\n\t\t\t} else {\n\t\t\t\tresult += `run ${data || ''}`;\n\t\t\t}\n\n\t\t\tif (dash) {\n\t\t\t\tresult += dash.replace(/^\\s--/, '');\n\t\t\t}\n\n\t\t\tif (rest) {\n\t\t\t\tresult += rest;\n\t\t\t}\n\n\t\t\treturn result;\n\t\t});\n\t},\n\n\trun(command: string) {\n\t\treturn command.replace(/^run\\s?([^\\s]+)?(\\s--\\s--)?(.*)$/, (_, data?: string, dash?: string, rest?: string): string => {\n\t\t\tlet result = '';\n\n\t\t\tif (data && !unchangedCLICommands.includes(data) && !yarnCLICommands.includes(data)) {\n\t\t\t\tresult += data;\n\t\t\t} else {\n\t\t\t\tresult += `run ${data || ''}`;\n\t\t\t}\n\n\t\t\tif (dash) {\n\t\t\t\tresult += dash.replace(/^\\s--/, '');\n\t\t\t}\n\n\t\t\tif (rest) {\n\t\t\t\tresult += rest;\n\t\t\t}\n\n\t\t\treturn result;\n\t\t});\n\t},\n\n\tls(command: string) {\n\t\treturn command.replace(/^(ls|list)(.*)$/, (_1, _2: string, args: string): string => {\n\t\t\tlet result = 'list';\n\n\t\t\tif (args) {\n\t\t\t\tlet ended = false;\n\t\t\t\tlet packages = [];\n\t\t\t\tconst items = args.split(' ').filter(Boolean);\n\n\t\t\t\tfor (const item of items) {\n\t\t\t\t\tif (ended) {\n\t\t\t\t\t\tresult += ` ${item}`;\n\t\t\t\t\t} else if (item.startsWith('-')) {\n\t\t\t\t\t\tresult += ` --pattern \"${packages.join('|')}\"`;\n\t\t\t\t\t\tpackages = [];\n\t\t\t\t\t\tended = true;\n\t\t\t\t\t\tresult += ` ${item}`;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tpackages.push(item);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif (packages.length > 0) {\n\t\t\t\t\tresult += ` --pattern \"${packages.join('|')}\"`;\n\t\t\t\t}\n\n\t\t\t\treturn result;\n\t\t\t}\n\n\t\t\treturn 'list';\n\t\t});\n\t},\n\n\tlist(command: string) {\n\t\treturn npmToYarnTable.ls(command);\n\t},\n\n\tinit(command: string) {\n\t\tif (/^init (?!-).*$/.test(command)) {\n\t\t\treturn command.replace('init', 'create');\n\t\t}\n\n\t\treturn command.replace(' --scope', '');\n\t}\n} as const;\n\nfunction convert(_: string, command: string) {\n\tcommand = (command || '').trim();\n\tconst firstCommand = (/\\w+/.exec(command) || [''])[0];\n\n\tif (unchangedCLICommands.includes(firstCommand)) {\n\t\treturn `yarn ${command}`;\n\t}\n\n\tif (firstCommand in npmToYarnTable) {\n\t\tconst converter = npmToYarnTable[firstCommand as keyof typeof npmToYarnTable];\n\n\t\tif (typeof converter === 'function') {\n\t\t\treturn `yarn ${converter(command)}`;\n\t\t}\n\n\t\treturn `yarn ${command.replace(firstCommand, converter)}`;\n\t}\n\n\treturn `yarn ${command}\\n# couldn't auto-convert command`;\n}\n\nexport function npmToYarn(str: string) {\n\treturn str.replace(/npm(?: +([^&\\n\\r]*))?/gm, convert);\n}\n","import type { Code, Content, Literal } from 'mdast';\nimport type { Plugin } from 'unified';\nimport type { Node, Parent } from 'unist';\nimport visit from 'unist-util-visit';\nimport { npmToPnpm } from './npm2pnpm';\nimport { npmToYarn } from './npm2yarn';\n\n/**\n * Transforms a Docusaurus node from NPM to Yarn and Pnpm\n * @param node The Docusaurus node to transform\n * @param options The plugin options to pass to the transformer\n * @returns The transformed node in the form of Tabs.\n */\nconst transformNode = (node: Code, options: PluginOptions) => {\n\tconst groupIdProp = options.sync ? ' groupId=\"npm2yarn2pnpm\"' : '';\n\tconst npmCode = node.value;\n\n\tconst yarnCode = npmToYarn(node.value);\n\tconst pnpmCode = npmToPnpm(node.value);\n\n\tconst [, highlight] = (node.meta ?? '').split('|');\n\n\treturn [\n\t\t{\n\t\t\ttype: 'jsx',\n\t\t\tvalue: `<Tabs${groupIdProp}\n\t\t\t\t\t\tdefaultValue=\"npm\"\n\t\t\t\t\t\tvalues={[\n\t\t\t\t\t\t\t{ label: \"npm\", value: \"npm\" },\n\t\t\t\t\t\t\t{ label: \"yarn\", value: \"yarn\" },\n\t\t\t\t\t\t\t{ label: \"pnpm\", value: \"pnpm\" },\n\t\t\t\t\t\t]}\n\t\t\t>\\n<TabItem value=\"npm\">`\n\t\t},\n\t\t{\n\t\t\ttype: node.type,\n\t\t\tlang: node.lang,\n\t\t\tmeta: `${highlight} showLineNumbers`,\n\t\t\tvalue: npmCode\n\t\t},\n\t\t{\n\t\t\ttype: 'jsx',\n\t\t\tvalue: '</TabItem>\\n<TabItem value=\"yarn\" label=\"Yarn\">'\n\t\t},\n\t\t{\n\t\t\ttype: node.type,\n\t\t\tlang: node.lang,\n\t\t\tmeta: `${highlight} showLineNumbers`,\n\t\t\tvalue: yarnCode\n\t\t},\n\t\t{\n\t\t\ttype: 'jsx',\n\t\t\tvalue: '</TabItem>\\n<TabItem value=\"pnpm\">'\n\t\t},\n\t\t{\n\t\t\ttype: node.type,\n\t\t\tlang: node.lang,\n\t\t\tmeta: `${highlight} showLineNumbers`,\n\t\t\tvalue: pnpmCode\n\t\t},\n\t\t{\n\t\t\ttype: 'jsx',\n\t\t\tvalue: '</TabItem>\\n</Tabs>'\n\t\t}\n\t] as Content[];\n};\n\nconst isImport = (node: Node): node is Literal => node.type === 'import';\nconst isParent = (node: Node): node is Parent => Array.isArray((node as Parent).children);\nconst matchNode = (node: Node): node is Code =>\n\tnode.type === 'code' && typeof (node as Code).meta === 'string' && ((node as Code).meta ?? '').startsWith('npm2yarn2pnpm');\nconst nodeForImport: Literal = {\n\ttype: 'import',\n\tvalue: \"import Tabs from '@theme/Tabs';\\nimport TabItem from '@theme/TabItem';\"\n};\n\nexport interface PluginOptions {\n\tsync?: boolean;\n}\n\nexport const npm2yarn2pnpm: Plugin<[PluginOptions?]> =\n\t({ sync = true } = { sync: true }) =>\n\t(root) => {\n\t\tlet transformed = false;\n\t\tlet alreadyImported = false;\n\t\tvisit(root, (node: Node) => {\n\t\t\tif (isImport(node) && node.value.includes('@theme/Tabs')) {\n\t\t\t\talreadyImported = true;\n\t\t\t}\n\t\t\tif (isParent(node)) {\n\t\t\t\tlet index = 0;\n\t\t\t\twhile (index < node.children.length) {\n\t\t\t\t\tconst child = node.children[index]!;\n\t\t\t\t\tif (matchNode(child)) {\n\t\t\t\t\t\tconst result = transformNode(child, { sync });\n\t\t\t\t\t\tnode.children.splice(index, 1, ...result);\n\t\t\t\t\t\tindex += result.length;\n\t\t\t\t\t\ttransformed = true;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tindex += 1;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t\tif (transformed && !alreadyImported) {\n\t\t\t(root as Parent).children.unshift(nodeForImport);\n\t\t}\n\t};\n"],"mappings":";AAOA,IAAM,uBAAuB,CAAC,QAAQ,OAAO,QAAQ,SAAS,UAAU,QAAQ,WAAW,OAAO;AAElG,SAAS,gBAAgB,SAAiB,cAAc,OAAO;AAC9D,MAAI,cAAc,KAAK,OAAO,GAAG;AAChC,WAAO;AAAA,EACR;AAEA,SAAO,QACL,QAAQ,cAAc,OAAO,YAAY,MAAM,EAC/C,QAAQ,oBAAoB,eAAe,EAC3C,QAAQ,qBAAqB,EAAE;AAClC;AAEA,IAAM,iBAAiB;AAAA,EACtB,QAAQ,SAAiB;AACxB,WAAO,gBAAgB,OAAO;AAAA,EAC/B;AAAA,EAEA,EAAE,SAAiB;AAClB,WAAO,gBAAgB,SAAS,IAAI;AAAA,EACrC;AAAA,EAEA,UAAU,SAAiB;AAC1B,WAAO,QACL,QAAQ,aAAa,QAAQ,EAC7B,QAAQ,oBAAoB,eAAe,EAC3C,QAAQ,qBAAqB,EAAE;AAAA,EAClC;AAAA,EAEA,QAAQ,SAAiB;AACxB,WAAO,QAAQ,QAAQ,uBAAuB,MAAM;AAAA,EACrD;AAAA,EAEA,QAAQ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2
2
|
"name": "@sapphire/docusaurus-plugin-npm2yarn2pnpm",
|
|
3
|
-
"version": "1.1.4
|
|
3
|
+
"version": "1.1.4",
|
|
4
4
|
"description": "Docusaurus Remark plugin for converting NPM Commands to Yarn and Pnpm",
|
|
5
5
|
"author": "@sapphire",
|
|
6
6
|
"license": "MIT",
|
|
@@ -23,7 +23,6 @@
|
|
|
23
23
|
"test": "vitest run"
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@armano/npm-to-yarn": "^1.1.3",
|
|
27
26
|
"unist-util-visit": "^2.0.3"
|
|
28
27
|
},
|
|
29
28
|
"repository": {
|
|
@@ -61,7 +60,7 @@
|
|
|
61
60
|
},
|
|
62
61
|
"devDependencies": {
|
|
63
62
|
"@favware/cliff-jumper": "^1.8.7",
|
|
64
|
-
"tsup": "^6.2.
|
|
65
|
-
"typescript": "^4.
|
|
63
|
+
"tsup": "^6.2.3",
|
|
64
|
+
"typescript": "^4.8.4"
|
|
66
65
|
}
|
|
67
66
|
}
|