@sapphire/docusaurus-plugin-npm2yarn2pnpm 1.1.1 โ†’ 1.1.2

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
@@ -2,6 +2,18 @@
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.2](https://github.com/sapphiredev/documentation-plugins/compare/@sapphire/docusaurus-plugin-npm2yarn2pnpm@1.1.0...@sapphire/docusaurus-plugin-npm2yarn2pnpm@1.1.2) - (2022-07-11)
6
+
7
+ ## ๐Ÿ› Bug Fixes
8
+
9
+ - Fixed converting pnpm with flags ([35aa88c](https://github.com/sapphiredev/documentation-plugins/commit/35aa88c7d811eaa74be673dde8f09b9fd8444972))
10
+ - Switch to @armano's fork of npm-to-yarn ([96fd557](https://github.com/sapphiredev/documentation-plugins/commit/96fd55735b155f784bb877c47cfb3ff1f8aff87c))
11
+ - Manually set versions ([05f4d16](https://github.com/sapphiredev/documentation-plugins/commit/05f4d16dcd5673a208e4ec191e659b3cbd2dc95a))
12
+
13
+ ## ๐Ÿงช Testing
14
+
15
+ - Add unit tests ([dfab541](https://github.com/sapphiredev/documentation-plugins/commit/dfab541b725a5296eb6768c85365f1f1ea3e0b87))
16
+
5
17
  # [@sapphire/docusaurus-plugin-npm2yarn2pnpm@1.1.0](https://github.com/sapphiredev/documentation-plugins/compare/@sapphire/docusaurus-plugin-npm2yarn2pnpm@1.0.3...@sapphire/docusaurus-plugin-npm2yarn2pnpm@1.1.0) - (2022-05-15)
6
18
 
7
19
  ## ๐Ÿ› Bug Fixes
package/dist/index.d.ts CHANGED
@@ -1,3 +1,16 @@
1
- export { npmToPnpm } from './npm2pnpm';
2
- export { npm2yarn2pnpm, PluginOptions } from './npm2yarn2pnpm';
3
- //# sourceMappingURL=index.d.ts.map
1
+ import { Plugin } from 'unified';
2
+
3
+ /**
4
+ * Copyright (c) 2019 Ben Gubler <nebrelbug@gmail.com>
5
+ *
6
+ * This source code is licensed under the MIT license found in the
7
+ * LICENSE file in the root directory of this source tree.
8
+ */
9
+ declare function npmToPnpm(str: string): string;
10
+
11
+ interface PluginOptions {
12
+ sync?: boolean;
13
+ }
14
+ declare const npm2yarn2pnpm: Plugin<[PluginOptions?]>;
15
+
16
+ export { PluginOptions, npm2yarn2pnpm, npmToPnpm };
package/dist/index.js CHANGED
@@ -1,3 +1,4 @@
1
+ "use strict";
1
2
  var __create = Object.create;
2
3
  var __defProp = Object.defineProperty;
3
4
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
@@ -34,10 +35,10 @@ var npmToPnpmTable = {
34
35
  if (/^install *$/.test(command)) {
35
36
  return "install";
36
37
  }
37
- return command.replace("install", "add").replace(/\s*--save/, "--save-prod").replace("--no-package-lock", "");
38
+ return command.replace("install", "add").replace(/(\s*)--save(?!-)/, "$1--save-prod").replace("--no-package-lock", "");
38
39
  },
39
40
  uninstall(command) {
40
- return command.replace("uninstall", "remove").replace(/\s*--save/, "--save-prod").replace("--no-package-lock", "");
41
+ return command.replace("uninstall", "remove").replace(/(\s*)--save(?!-)/, "$1--save-prod").replace("--no-package-lock", "");
41
42
  },
42
43
  version(command) {
43
44
  return command.replace(/(major|minor|patch)/, "--$1");
@@ -65,7 +66,7 @@ function npmToPnpm(str) {
65
66
  }
66
67
 
67
68
  // src/npm2yarn2pnpm.ts
68
- var import_npm_to_yarn = __toESM(require("npm-to-yarn"));
69
+ var import_npm_to_yarn = __toESM(require("@armano/npm-to-yarn"));
69
70
  var import_unist_util_visit = __toESM(require("unist-util-visit"));
70
71
  var transformNode = (node, options) => {
71
72
  const groupIdProp = options.sync ? ' groupId="npm2yarn2pnpm"' : "";
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/, '--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/, '--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 type { Code, Content, Literal } from 'mdast';\nimport npmToYarn from 'npm-to-yarn';\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 = npmToYarn(node.value, 'yarn');\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,QAAQ,WAAW,OAAO;AAElG,IAAM,iBAAiB;AAAA,EACtB,QAAQ,SAAiB;AACxB,QAAI,cAAc,KAAK,OAAO,GAAG;AAChC,aAAO;AAA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AG;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/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 npmToYarn 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 = npmToYarn(node.value, 'yarn');\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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eAAe;AAC1H,IAAM,gBAAyB;AAAA,EAC9B,MAAM;AAAA,EACN,OAAO;AACR;AAMO,IAAM,gBACZ,CAAC,EAAE,OAAO,SAAS,EAAE,MAAM,KAAK,MAChC,CAAC,SAAS;AACT,MAAI,cAAc;AAClB,MAAI,kBAAkB;AACtB,uCAAM,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":[]}
package/dist/index.mjs CHANGED
@@ -5,10 +5,10 @@ var npmToPnpmTable = {
5
5
  if (/^install *$/.test(command)) {
6
6
  return "install";
7
7
  }
8
- return command.replace("install", "add").replace(/\s*--save/, "--save-prod").replace("--no-package-lock", "");
8
+ return command.replace("install", "add").replace(/(\s*)--save(?!-)/, "$1--save-prod").replace("--no-package-lock", "");
9
9
  },
10
10
  uninstall(command) {
11
- return command.replace("uninstall", "remove").replace(/\s*--save/, "--save-prod").replace("--no-package-lock", "");
11
+ return command.replace("uninstall", "remove").replace(/(\s*)--save(?!-)/, "$1--save-prod").replace("--no-package-lock", "");
12
12
  },
13
13
  version(command) {
14
14
  return command.replace(/(major|minor|patch)/, "--$1");
@@ -36,7 +36,7 @@ function npmToPnpm(str) {
36
36
  }
37
37
 
38
38
  // src/npm2yarn2pnpm.ts
39
- import npmToYarn from "npm-to-yarn";
39
+ import npmToYarn from "@armano/npm-to-yarn";
40
40
  import visit from "unist-util-visit";
41
41
  var transformNode = (node, options) => {
42
42
  const groupIdProp = options.sync ? ' groupId="npm2yarn2pnpm"' : "";
@@ -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/, '--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/, '--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 type { Code, Content, Literal } from 'mdast';\nimport npmToYarn from 'npm-to-yarn';\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 = npmToYarn(node.value, 'yarn');\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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ACnB;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/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 npmToYarn 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 = npmToYarn(node.value, 'yarn');\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,iBAAiB,GAAW,SAAiB;AAC5C,YAAW,YAAW,IAAI,KAAK;AAE/B,QAAM,eAAgB,OAAM,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,cA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M,gBAAyB;AAAA,EAC9B,MAAM;AAAA,EACN,OAAO;AACR;AAMO,IAAM,gBACZ,CAAC,EAAE,OAAO,SAAS,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":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sapphire/docusaurus-plugin-npm2yarn2pnpm",
3
- "version": "1.1.1",
3
+ "version": "1.1.2",
4
4
  "description": "Docusaurus Remark plugin for converting NPM Commands to Yarn and Pnpm",
5
5
  "author": "@sapphire",
6
6
  "license": "MIT",
@@ -15,20 +15,21 @@
15
15
  "sideEffects": false,
16
16
  "scripts": {
17
17
  "lint": "eslint src --ext ts --fix",
18
- "build": "tsup && tsc -b src",
18
+ "build": "tsup",
19
19
  "typecheck": "tsc -p tsconfig.eslint.json",
20
20
  "prepack": "yarn build",
21
21
  "bump": "cliff-jumper",
22
- "check-update": "cliff-jumper --dry-run"
22
+ "check-update": "cliff-jumper --dry-run",
23
+ "test": "vitest run"
23
24
  },
24
25
  "dependencies": {
25
- "npm-to-yarn": "^1.0.1",
26
+ "@armano/npm-to-yarn": "^1.1.1",
26
27
  "unist-util-visit": "^2.0.3"
27
28
  },
28
29
  "repository": {
29
30
  "type": "git",
30
31
  "url": "git+https://github.com/sapphiredev/documentation-plugins.git",
31
- "directory": "packages/ts2esm2cjs"
32
+ "directory": "packages/npm2yarn2pnpm"
32
33
  },
33
34
  "files": [
34
35
  "dist/**/*.js*",
@@ -59,7 +60,8 @@
59
60
  "access": "public"
60
61
  },
61
62
  "devDependencies": {
62
- "tsup": "^6.1.2",
63
+ "@favware/cliff-jumper": "^1.8.5",
64
+ "tsup": "^6.1.3",
63
65
  "typescript": "^4.7.4"
64
66
  }
65
67
  }
@@ -1,8 +0,0 @@
1
- /**
2
- * Copyright (c) 2019 Ben Gubler <nebrelbug@gmail.com>
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
- export declare function npmToPnpm(str: string): string;
8
- //# sourceMappingURL=npm2pnpm.d.ts.map
@@ -1,6 +0,0 @@
1
- import type { Plugin } from 'unified';
2
- export interface PluginOptions {
3
- sync?: boolean;
4
- }
5
- export declare const npm2yarn2pnpm: Plugin<[PluginOptions?]>;
6
- //# sourceMappingURL=npm2yarn2pnpm.d.ts.map