diff --git a/dist/npm-to-yarn.mjs b/dist/npm-to-yarn.mjs index dd10517..c545dbb 100644 --- a/dist/npm-to-yarn.mjs +++ b/dist/npm-to-yarn.mjs @@ -1,357 +1,356 @@ -var unchangedCLICommands = ['test', 'login', 'logout', 'link', 'publish', 'cache']; -var yarnCLICommands = [ - 'init', - 'run', - 'add', - 'audit', - 'autoclean', - 'bin', - 'check', - 'config', - 'create', - 'dedupe', - 'generate-lock-entry', - 'global', - 'help', - 'import', - 'info', - 'install', - 'licenses', - 'list', - 'lockfile', - 'outdated', - 'owner', - 'pack', - 'policies', - 'prune', - 'remove', - 'self-update', - 'tag', - 'team', - 'link', - 'unlink', - 'upgrade', - 'upgrade-interactive', - 'version', - 'versions', - 'why', - 'workspace', - 'workspaces' +var unchangedCLICommands = [ + 'test', + 'login', + 'logout', + 'link', + 'unlink', + 'publish', + 'cache', + 'start', + 'stop', + 'test' +]; +var yarnCLICommands = [ + 'init', + 'run', + 'add', + 'audit', + 'autoclean', + 'bin', + 'check', + 'config', + 'create', + 'dedupe', + 'generate-lock-entry', + 'global', + 'help', + 'import', + 'info', + 'install', + 'licenses', + 'list', + 'lockfile', + 'outdated', + 'owner', + 'pack', + 'policies', + 'prune', + 'remove', + 'self-update', + 'tag', + 'team', + 'upgrade', + 'upgrade-interactive', + 'version', + 'versions', + 'why', + 'workspace', + 'workspaces' ]; -function parse(command) { - var args = []; - var lastQuote = false; - var escaped = false; - var part = ''; - for (var i = 0; i < command.length; ++i) { - var char = command.charAt(i); - if (char === '\\') { - part += char; - escaped = true; - } - else { - if (char === ' ' && !lastQuote) { - args.push(part); - part = ''; - } - else if (!escaped && (char === '"' || char === "'")) { - part += char; - if (char === lastQuote) { - lastQuote = false; - } - else if (!lastQuote) { - lastQuote = char; - } - } - else { - part += char; - } - escaped = false; - } - } - args.push(part); - return args; +function parse(command) { + var args = []; + var lastQuote = false; + var escaped = false; + var part = ''; + for (var i = 0; i < command.length; ++i) { + var char = command.charAt(i); + if (char === '\\') { + part += char; + escaped = true; + } + else { + if (char === ' ' && !lastQuote) { + args.push(part); + part = ''; + } + else if (!escaped && (char === '"' || char === "'")) { + part += char; + if (char === lastQuote) { + lastQuote = false; + } + else if (!lastQuote) { + lastQuote = char; + } + } + else { + part += char; + } + escaped = false; + } + } + args.push(part); + return args; } -function convertAddRemoveArgs(args) { - return args.map(function (item) { - switch (item) { - case '--no-lockfile': - return '--no-package-lock'; - case '--production': - return '--save-prod'; - case '--dev': - return '--save-dev'; - case '--optional': - return '--save-optional'; - case '--exact': - return '--save-exact'; - default: - return item; - } - }); -} -var yarnToNpmTable = { - add: function (args) { - if (args.length === 2 && args[1] === '--force') { - return ['rebuild']; - } - args[0] = 'install'; - if (!args.includes('--dev') && - !args.includes('--force') && - !args.includes('--exact') && - !args.includes('--optional') && - !args.includes('--production')) { - args.push('--save'); - } - return convertAddRemoveArgs(args); - }, - remove: function (args) { - args[0] = 'uninstall'; - if (!args.includes('--dev')) { - args.push('--save'); - } - return convertAddRemoveArgs(args); - }, - version: function (args) { - return args.map(function (item) { - switch (item) { - case '--major': - return 'major'; - case '--minor': - return 'minor'; - case '--patch': - return 'patch'; - default: - return item; - } - }); - }, - install: 'install', - list: function (args) { - args[0] = 'ls'; - var patternIndex = args.findIndex(function (item) { return item === '--pattern'; }); - if (patternIndex >= 0 && args[patternIndex + 1]) { - var packages = args[patternIndex + 1].replace(/["']([^"']+)["']/, '$1').split('|'); - args.splice(patternIndex, 2, packages.join(' ')); - } - return args; - }, - init: 'init', - create: 'init', - run: 'run', - start: 'start', - stop: 'stop', - test: 'test', - global: function (args) { - switch (args[1]) { - case 'add': - args.shift(); - args = yarnToNpmTable.add(args); - args.push('--global'); - return args; - case 'remove': - args.shift(); - args = yarnToNpmTable.remove(args); - args.push('--global'); - return args; - case 'list': - args.shift(); - args = yarnToNpmTable.list(args); - args.push('--global'); - return args; - // case 'bin': - // case 'upgrade': - default: - args.push("\n# couldn't auto-convert command"); - return args; - } - } -}; -function yarnToNPM(_m, command) { - command = (command || '').trim(); - if (command === '') { - return 'npm install'; - } - var args = parse(command); - var firstCommand = (/\w+/.exec(command) || [''])[0]; - if (unchangedCLICommands.includes(args[0])) { - return 'npm ' + command; - } - else if (args[0] in yarnToNpmTable) { - var converter = yarnToNpmTable[args[0]]; - if (typeof converter === 'function') { - args = converter(args); - } - else { - args[0] = converter; - } - return 'npm ' + args.filter(Boolean).join(' '); - } - else if (!yarnCLICommands.includes(firstCommand)) { - // i.e., yarn grunt -> npm run grunt - return 'npm run ' + command; - } - else { - return 'npm ' + command + "\n# couldn't auto-convert command"; - } +function convertAddRemoveArgs(args) { + return args.map(function (item) { + switch (item) { + case '--no-lockfile': + return '--no-package-lock'; + case '--production': + return '--save-prod'; + case '--dev': + return '--save-dev'; + case '--optional': + return '--save-optional'; + case '--exact': + return '--save-exact'; + default: + return item; + } + }); +} +var yarnToNpmTable = { + add: function (args) { + if (args.length === 2 && args[1] === '--force') { + return ['rebuild']; + } + args[0] = 'install'; + if (!args.includes('--dev') && + !args.includes('--force') && + !args.includes('--exact') && + !args.includes('--optional') && + !args.includes('--production')) { + args.push('--save'); + } + return convertAddRemoveArgs(args); + }, + remove: function (args) { + args[0] = 'uninstall'; + if (!args.includes('--dev')) { + args.push('--save'); + } + return convertAddRemoveArgs(args); + }, + version: function (args) { + return args.map(function (item) { + switch (item) { + case '--major': + return 'major'; + case '--minor': + return 'minor'; + case '--patch': + return 'patch'; + default: + return item; + } + }); + }, + install: 'install', + list: function (args) { + args[0] = 'ls'; + var patternIndex = args.findIndex(function (item) { return item === '--pattern'; }); + if (patternIndex >= 0 && args[patternIndex + 1]) { + var packages = args[patternIndex + 1].replace(/["']([^"']+)["']/, '$1').split('|'); + args.splice(patternIndex, 2, packages.join(' ')); + } + return args; + }, + init: 'init', + create: 'init', + run: 'run', + global: function (args) { + switch (args[1]) { + case 'add': + args.shift(); + args = yarnToNpmTable.add(args); + args.push('--global'); + return args; + case 'remove': + args.shift(); + args = yarnToNpmTable.remove(args); + args.push('--global'); + return args; + case 'list': + args.shift(); + args = yarnToNpmTable.list(args); + args.push('--global'); + return args; + // case 'bin': + // case 'upgrade': + default: + args.push("\n# couldn't auto-convert command"); + return args; + } + } +}; +function yarnToNPM(_m, command) { + command = (command || '').trim(); + if (command === '') { + return 'npm install'; + } + var args = parse(command); + var firstCommand = (/\w+/.exec(command) || [''])[0]; + if (unchangedCLICommands.includes(args[0])) { + return 'npm ' + command; + } + else if (args[0] in yarnToNpmTable) { + var converter = yarnToNpmTable[args[0]]; + if (typeof converter === 'function') { + args = converter(args); + } + else { + args[0] = converter; + } + return 'npm ' + args.filter(Boolean).join(' '); + } + else if (!yarnCLICommands.includes(firstCommand)) { + // i.e., yarn grunt -> npm run grunt + return 'npm run ' + command; + } + else { + return 'npm ' + command + "\n# couldn't auto-convert command"; + } } -function convertInstallArgs(args) { - if (args.includes('--global') || args.includes('-g')) { - args.unshift('global'); - } - return args.map(function (item) { - switch (item) { - case '--save-dev': - case '-D': - return '--dev'; - case '--save-prod': - case '-P': - return '--production'; - case '--no-package-lock': - return '--no-lockfile'; - case '--save-optional': - case '-O': - return '--optional'; - case '--save-exact': - case '-E': - return '--exact'; - case '--save': - case '-S': - case '--global': - case '-g': - return ''; - default: - return item; - } - }); -} -var npmToYarnTable = { - install: function (args) { - if (args.length === 1) { - return ['install']; - } - args[0] = 'add'; - return convertInstallArgs(args); - }, - i: function (args) { - return npmToYarnTable.install(args); - }, - uninstall: function (args) { - args[0] = 'remove'; - return convertInstallArgs(args); - }, - remove: function (args) { - return npmToYarnTable.uninstall(args); - }, - un: function (args) { - return npmToYarnTable.uninstall(args); - }, - unlink: function (args) { - return npmToYarnTable.uninstall(args); - }, - r: function (args) { - return npmToYarnTable.uninstall(args); - }, - rm: function (args) { - return npmToYarnTable.uninstall(args); - }, - version: function (args) { - return args.map(function (item) { - switch (item) { - case 'major': - return '--major'; - case 'minor': - return '--minor'; - case 'patch': - return '--patch'; - default: - return item; - } - }); - }, - rb: function (args) { - return npmToYarnTable.rebuild(args); - }, - rebuild: function (args) { - args[0] = 'add'; - args.push('--force'); - return args; - }, - run: function (args) { - if (args[1] && !unchangedCLICommands.includes(args[1]) && !yarnCLICommands.includes(args[1])) { - args.splice(0, 1); - } - return args; - }, - exec: function (args) { - args[0] = 'run'; - return npmToYarnTable.run(args); - }, - ls: function (args) { - args[0] = 'list'; - var ended = false; - var packages = args.filter(function (item, id) { - if (id > 0 && !ended) { - ended = item.startsWith('-'); - return !ended; - } - return false; - }); - if (packages.length > 0) { - args.splice(1, packages.length, '--pattern', '"' + packages.join('|') + '"'); - } - return args; - }, - list: function (args) { - return npmToYarnTable.ls(args); - }, - init: function (args) { - if (args[1] && !args[1].startsWith('-')) { - args[0] = 'create'; - } - return args.filter(function (item) { return item !== '--scope'; }); - }, - start: 'start', - stop: 'stop', - test: 'test' -}; -function npmToYarn(_m, command) { - var args = parse((command || '').trim()); - var index = args.findIndex(function (a) { return a === '--'; }); - if (index >= 0) { - args.splice(index, 1); - } - if (unchangedCLICommands.includes(args[0])) { - return 'yarn ' + args.join(' '); - } - else if (args[0] in npmToYarnTable) { - var converter = npmToYarnTable[args[0]]; - if (typeof converter === 'function') { - args = converter(args); - } - else { - args[0] = converter; - } - return 'yarn ' + args.filter(Boolean).join(' '); - } - else { - return 'yarn ' + command + "\n# couldn't auto-convert command"; - } +function convertInstallArgs(args) { + if (args.includes('--global') || args.includes('-g')) { + args.unshift('global'); + } + return args.map(function (item) { + switch (item) { + case '--save-dev': + case '-D': + return '--dev'; + case '--save-prod': + case '-P': + return '--production'; + case '--no-package-lock': + return '--no-lockfile'; + case '--save-optional': + case '-O': + return '--optional'; + case '--save-exact': + case '-E': + return '--exact'; + case '--save': + case '-S': + case '--global': + case '-g': + return ''; + default: + return item; + } + }); +} +var npmToYarnTable = { + install: function (args) { + if (args.length === 1) { + return ['install']; + } + args[0] = 'add'; + return convertInstallArgs(args); + }, + i: function (args) { + return npmToYarnTable.install(args); + }, + uninstall: function (args) { + args[0] = 'remove'; + return convertInstallArgs(args); + }, + remove: function (args) { + return npmToYarnTable.uninstall(args); + }, + r: function (args) { + return npmToYarnTable.uninstall(args); + }, + rm: function (args) { + return npmToYarnTable.uninstall(args); + }, + version: function (args) { + return args.map(function (item) { + switch (item) { + case 'major': + return '--major'; + case 'minor': + return '--minor'; + case 'patch': + return '--patch'; + default: + return item; + } + }); + }, + rb: function (args) { + return npmToYarnTable.rebuild(args); + }, + rebuild: function (args) { + args[0] = 'add'; + args.push('--force'); + return args; + }, + run: function (args) { + if (args[1] && !unchangedCLICommands.includes(args[1]) && !yarnCLICommands.includes(args[1])) { + args.splice(0, 1); + } + return args; + }, + exec: function (args) { + args[0] = 'run'; + return npmToYarnTable.run(args); + }, + ls: function (args) { + args[0] = 'list'; + var ended = false; + var packages = args.filter(function (item, id) { + if (id > 0 && !ended) { + ended = item.startsWith('-'); + return !ended; + } + return false; + }); + if (packages.length > 0) { + args.splice(1, packages.length, '--pattern', '"' + packages.join('|') + '"'); + } + return args; + }, + list: function (args) { + return npmToYarnTable.ls(args); + }, + init: function (args) { + if (args[1] && !args[1].startsWith('-')) { + args[0] = 'create'; + } + return args.filter(function (item) { return item !== '--scope'; }); + }, + ln: 'link', + un: 'unlink' +}; +function npmToYarn(_m, command) { + var args = parse((command || '').trim()); + var index = args.findIndex(function (a) { return a === '--'; }); + if (index >= 0) { + args.splice(index, 1); + } + if (unchangedCLICommands.includes(args[0])) { + return 'yarn ' + args.join(' '); + } + else if (args[0] in npmToYarnTable) { + var converter = npmToYarnTable[args[0]]; + if (typeof converter === 'function') { + args = converter(args); + } + else { + args[0] = converter; + } + return 'yarn ' + args.filter(Boolean).join(' '); + } + else { + return 'yarn ' + command + "\n# couldn't auto-convert command"; + } } -/** - * Converts between npm and yarn command - */ -function convert(str, to) { - if (to === 'npm') { - return str.replace(/yarn(?: +([^&\n\r]*))?/gm, yarnToNPM); - } - else { - return str.replace(/npm(?: +([^&\n\r]*))?/gm, npmToYarn); - } +/** + * Converts between npm and yarn command + */ +function convert(str, to) { + if (to === 'npm') { + return str.replace(/yarn(?: +([^&\n\r]*))?/gm, yarnToNPM); + } + else { + return str.replace(/npm(?: +([^&\n\r]*))?/gm, npmToYarn); + } } export { convert as default }; diff --git a/dist/npm-to-yarn.mjs.map b/dist/npm-to-yarn.mjs.map index 7cc73d6..3ad4f13 100644 --- a/dist/npm-to-yarn.mjs.map +++ b/dist/npm-to-yarn.mjs.map @@ -1 +1 @@ -{"version":3,"file":"npm-to-yarn.mjs","sources":["../src/utils.ts","../src/command.ts","../src/yarnToNpm.ts","../src/npmToYarn.ts","../src/index.ts"],"sourcesContent":["export const unchangedCLICommands = ['test', 'login', 'logout', 'link', 'publish', 'cache']\n\nexport const yarnCLICommands = [\n 'init',\n 'run',\n 'add',\n 'audit',\n 'autoclean',\n 'bin',\n 'check',\n 'config',\n 'create',\n 'dedupe',\n 'generate-lock-entry',\n 'global',\n 'help',\n 'import',\n 'info',\n 'install',\n 'licenses',\n 'list',\n 'lockfile',\n 'outdated',\n 'owner',\n 'pack',\n 'policies',\n 'prune',\n 'remove',\n 'self-update',\n 'tag',\n 'team',\n 'link',\n 'unlink',\n 'upgrade',\n 'upgrade-interactive',\n 'version',\n 'versions',\n 'why',\n 'workspace',\n 'workspaces'\n]\n\nexport const npmCLICommands = [\n 'init',\n 'run',\n 'access',\n 'adduser',\n 'audit',\n 'bin',\n 'bugs',\n 'build',\n 'bundle',\n 'ci',\n 'completion',\n 'config',\n 'dedupe',\n 'deprecate',\n 'dist-tag',\n 'docs',\n 'doctor',\n 'edit',\n 'explore',\n 'exec',\n 'fund',\n 'help-search',\n 'help',\n 'hook',\n 'install-ci-test',\n 'install-test',\n 'install',\n 'ls',\n 'list',\n 'npm',\n 'org',\n 'outdated',\n 'owner',\n 'pack',\n 'ping',\n 'prefix',\n 'profile',\n 'prune',\n 'rebuild',\n 'repo',\n 'restart',\n 'root',\n 'run-script',\n 'search',\n 'shrinkwrap',\n 'star',\n 'stars',\n 'start',\n 'stop',\n 'team',\n 'token',\n 'uninstall',\n 'unpublish',\n 'update',\n 'version',\n 'view',\n 'whoami'\n]\n","export function parse (command: string) {\n const args: string[] = []\n let lastQuote: string | false = false\n let escaped = false\n let part = ''\n for (let i = 0; i < command.length; ++i) {\n const char = command.charAt(i)\n if (char === '\\\\') {\n part += char\n escaped = true\n } else {\n if (char === ' ' && !lastQuote) {\n args.push(part)\n part = ''\n } else if (!escaped && (char === '\"' || char === \"'\")) {\n part += char\n if (char === lastQuote) {\n lastQuote = false\n } else if (!lastQuote) {\n lastQuote = char\n }\n } else {\n part += char\n }\n escaped = false\n }\n }\n args.push(part)\n return args\n}\n","import { unchangedCLICommands, yarnCLICommands } from './utils'\nimport { parse } from './command'\n\nfunction convertAddRemoveArgs (args: string[]) {\n return args.map(item => {\n switch (item) {\n case '--no-lockfile':\n return '--no-package-lock'\n case '--production':\n return '--save-prod'\n case '--dev':\n return '--save-dev'\n case '--optional':\n return '--save-optional'\n case '--exact':\n return '--save-exact'\n default:\n return item\n }\n })\n}\n\nconst yarnToNpmTable = {\n add (args: string[]) {\n if (args.length === 2 && args[1] === '--force') {\n return ['rebuild'];\n }\n args[0] = 'install'\n if (\n !args.includes('--dev') &&\n !args.includes('--force') &&\n !args.includes('--exact') &&\n !args.includes('--optional') &&\n !args.includes('--production')\n ) {\n args.push('--save')\n }\n return convertAddRemoveArgs(args)\n },\n remove (args: string[]) {\n args[0] = 'uninstall'\n if (!args.includes('--dev')) {\n args.push('--save')\n }\n return convertAddRemoveArgs(args)\n },\n version (args: string[]) {\n return args.map(item => {\n switch (item) {\n case '--major':\n return 'major'\n case '--minor':\n return 'minor'\n case '--patch':\n return 'patch'\n default:\n return item\n }\n })\n },\n install: 'install',\n list (args: string[]) {\n args[0] = 'ls'\n const patternIndex = args.findIndex(item => item === '--pattern')\n if (patternIndex >= 0 && args[patternIndex + 1]) {\n const packages = args[patternIndex + 1].replace(/[\"']([^\"']+)[\"']/, '$1').split('|')\n args.splice(patternIndex, 2, packages.join(' '))\n }\n return args\n },\n init: 'init',\n create: 'init',\n run: 'run',\n start: 'start',\n stop: 'stop',\n test: 'test',\n global (args: string[]) {\n switch (args[1]) {\n case 'add':\n args.shift()\n args = yarnToNpmTable.add(args)\n args.push('--global')\n return args\n case 'remove':\n args.shift()\n args = yarnToNpmTable.remove(args)\n args.push('--global')\n return args\n case 'list':\n args.shift()\n args = yarnToNpmTable.list(args)\n args.push('--global')\n return args\n // case 'bin':\n // case 'upgrade':\n default:\n args.push(\"\\n# couldn't auto-convert command\")\n return args\n }\n }\n}\n\nexport function yarnToNPM (_m: string, command: string): string {\n command = (command || '').trim()\n if (command === '') {\n return 'npm install'\n }\n let args = parse(command)\n const firstCommand = (/\\w+/.exec(command) || [''])[0]\n\n if (unchangedCLICommands.includes(args[0])) {\n return 'npm ' + command\n } else if (args[0] in yarnToNpmTable) {\n const converter = yarnToNpmTable[args[0] as keyof typeof yarnToNpmTable]\n\n if (typeof converter === 'function') {\n args = converter(args)\n } else {\n args[0] = converter\n }\n\n return 'npm ' + args.filter(Boolean).join(' ')\n } else if (!yarnCLICommands.includes(firstCommand)) {\n // i.e., yarn grunt -> npm run grunt\n return 'npm run ' + command\n } else {\n return 'npm ' + command + \"\\n# couldn't auto-convert command\"\n }\n}\n","import { unchangedCLICommands, yarnCLICommands } from './utils'\nimport { parse } from './command'\n\nfunction convertInstallArgs (args: string[]) {\n if (args.includes('--global') || args.includes('-g')) {\n args.unshift('global')\n }\n\n return args.map(item => {\n switch (item) {\n case '--save-dev':\n case '-D':\n return '--dev'\n case '--save-prod':\n case '-P':\n return '--production'\n case '--no-package-lock':\n return '--no-lockfile'\n case '--save-optional':\n case '-O':\n return '--optional'\n case '--save-exact':\n case '-E':\n return '--exact'\n case '--save':\n case '-S':\n case '--global':\n case '-g':\n return ''\n default:\n return item\n }\n })\n}\n\nconst npmToYarnTable = {\n install (args: string[]) {\n if (args.length === 1) {\n return ['install']\n }\n args[0] = 'add'\n\n return convertInstallArgs(args)\n },\n i (args: string[]) {\n return npmToYarnTable.install(args)\n },\n uninstall (args: string[]) {\n args[0] = 'remove'\n\n return convertInstallArgs(args)\n },\n remove (args: string[]) {\n return npmToYarnTable.uninstall(args)\n },\n un (args: string[]) {\n return npmToYarnTable.uninstall(args)\n },\n unlink (args: string[]) {\n return npmToYarnTable.uninstall(args)\n },\n r (args: string[]) {\n return npmToYarnTable.uninstall(args)\n },\n rm (args: string[]) {\n return npmToYarnTable.uninstall(args)\n },\n version (args: string[]) {\n return args.map(item => {\n switch (item) {\n case 'major':\n return '--major'\n case 'minor':\n return '--minor'\n case 'patch':\n return '--patch'\n default:\n return item\n }\n })\n },\n rb (args: string[]) {\n return npmToYarnTable.rebuild(args)\n },\n rebuild (args: string[]) {\n args[0] = 'add'\n args.push('--force')\n return args\n },\n run (args: string[]) {\n if (args[1] && !unchangedCLICommands.includes(args[1]) && !yarnCLICommands.includes(args[1])) {\n args.splice(0, 1)\n }\n return args\n },\n exec (args: string[]) {\n args[0] = 'run'\n return npmToYarnTable.run(args)\n },\n ls (args: string[]) {\n args[0] = 'list'\n\n let ended = false\n const packages = args.filter((item, id) => {\n if (id > 0 && !ended) {\n ended = item.startsWith('-')\n return !ended\n }\n return false\n })\n if (packages.length > 0) {\n args.splice(1, packages.length, '--pattern', '\"' + packages.join('|') + '\"')\n }\n return args\n },\n list (args: string[]) {\n return npmToYarnTable.ls(args)\n },\n init (args: string[]) {\n if (args[1] && !args[1].startsWith('-')) {\n args[0] = 'create'\n }\n return args.filter(item => item !== '--scope')\n },\n start: 'start',\n stop: 'stop',\n test: 'test'\n}\n\nexport function npmToYarn (_m: string, command: string): string {\n let args = parse((command || '').trim())\n\n const index = args.findIndex(a => a === '--')\n if (index >= 0) {\n args.splice(index, 1)\n }\n\n if (unchangedCLICommands.includes(args[0])) {\n return 'yarn ' + args.join(' ')\n } else if (args[0] in npmToYarnTable) {\n const converter = npmToYarnTable[args[0] as keyof typeof npmToYarnTable]\n\n if (typeof converter === 'function') {\n args = converter(args)\n } else {\n args[0] = converter\n }\n\n return 'yarn ' + args.filter(Boolean).join(' ')\n } else {\n return 'yarn ' + command + \"\\n# couldn't auto-convert command\"\n }\n}\n","import { yarnToNPM } from './yarnToNpm'\nimport { npmToYarn } from './npmToYarn'\n\n/**\n * Converts between npm and yarn command\n */\nexport default function convert (str: string, to: 'npm' | 'yarn'): string {\n if (to === 'npm') {\n return str.replace(/yarn(?: +([^&\\n\\r]*))?/gm, yarnToNPM)\n } else {\n return str.replace(/npm(?: +([^&\\n\\r]*))?/gm, npmToYarn)\n }\n}\n"],"names":[],"mappings":"AAAO,IAAM,oBAAoB,GAAG,CAAC,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,OAAO,CAAC,CAAA;AAEpF,IAAM,eAAe,GAAG;IAC7B,MAAM;IACN,KAAK;IACL,KAAK;IACL,OAAO;IACP,WAAW;IACX,KAAK;IACL,OAAO;IACP,QAAQ;IACR,QAAQ;IACR,QAAQ;IACR,qBAAqB;IACrB,QAAQ;IACR,MAAM;IACN,QAAQ;IACR,MAAM;IACN,SAAS;IACT,UAAU;IACV,MAAM;IACN,UAAU;IACV,UAAU;IACV,OAAO;IACP,MAAM;IACN,UAAU;IACV,OAAO;IACP,QAAQ;IACR,aAAa;IACb,KAAK;IACL,MAAM;IACN,MAAM;IACN,QAAQ;IACR,SAAS;IACT,qBAAqB;IACrB,SAAS;IACT,UAAU;IACV,KAAK;IACL,WAAW;IACX,YAAY;CACb;;ACxCK,SAAU,KAAK,CAAE,OAAe,EAAA;IACpC,IAAM,IAAI,GAAa,EAAE,CAAA;IACzB,IAAI,SAAS,GAAmB,KAAK,CAAA;IACrC,IAAI,OAAO,GAAG,KAAK,CAAA;IACnB,IAAI,IAAI,GAAG,EAAE,CAAA;AACb,IAAA,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,EAAE;QACvC,IAAM,IAA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-yarn.mjs","sources":["../src/utils.ts","../src/command.ts","../src/yarnToNpm.ts","../src/npmToYarn.ts","../src/index.ts"],"sourcesContent":["export const unchangedCLICommands = [\n 'test',\n 'login',\n 'logout',\n 'link',\n 'unlink',\n 'publish',\n 'cache',\n 'start',\n 'stop',\n 'test'\n]\n\nexport const yarnCLICommands = [\n 'init',\n 'run',\n 'add',\n 'audit',\n 'autoclean',\n 'bin',\n 'check',\n 'config',\n 'create',\n 'dedupe',\n 'generate-lock-entry',\n 'global',\n 'help',\n 'import',\n 'info',\n 'install',\n 'licenses',\n 'list',\n 'lockfile',\n 'outdated',\n 'owner',\n 'pack',\n 'policies',\n 'prune',\n 'remove',\n 'self-update',\n 'tag',\n 'team',\n 'upgrade',\n 'upgrade-interactive',\n 'version',\n 'versions',\n 'why',\n 'workspace',\n 'workspaces'\n]\n\nexport const npmCLICommands = [\n 'init',\n 'run',\n 'access',\n 'adduser',\n 'audit',\n 'bin',\n 'bugs',\n 'build',\n 'bundle',\n 'ci',\n 'completion',\n 'config',\n 'dedupe',\n 'deprecate',\n 'dist-tag',\n 'docs',\n 'doctor',\n 'edit',\n 'explore',\n 'exec',\n 'fund',\n 'help-search',\n 'help',\n 'hook',\n 'install-ci-test',\n 'install-test',\n 'install',\n 'ls',\n 'list',\n 'npm',\n 'org',\n 'outdated',\n 'owner',\n 'pack',\n 'ping',\n 'prefix',\n 'profile',\n 'prune',\n 'rebuild',\n 'repo',\n 'restart',\n 'root',\n 'run-script',\n 'search',\n 'shrinkwrap',\n 'star',\n 'stars',\n 'start',\n 'stop',\n 'team',\n 'token',\n 'uninstall',\n 'unpublish',\n 'update',\n 'version',\n 'view',\n 'whoami'\n]\n","export function parse (command: string) {\n const args: string[] = []\n let lastQuote: string | false = false\n let escaped = false\n let part = ''\n for (let i = 0; i < command.length; ++i) {\n const char = command.charAt(i)\n if (char === '\\\\') {\n part += char\n escaped = true\n } else {\n if (char === ' ' && !lastQuote) {\n args.push(part)\n part = ''\n } else if (!escaped && (char === '\"' || char === \"'\")) {\n part += char\n if (char === lastQuote) {\n lastQuote = false\n } else if (!lastQuote) {\n lastQuote = char\n }\n } else {\n part += char\n }\n escaped = false\n }\n }\n args.push(part)\n return args\n}\n","import { unchangedCLICommands, yarnCLICommands } from './utils'\nimport { parse } from './command'\n\nfunction convertAddRemoveArgs (args: string[]) {\n return args.map(item => {\n switch (item) {\n case '--no-lockfile':\n return '--no-package-lock'\n case '--production':\n return '--save-prod'\n case '--dev':\n return '--save-dev'\n case '--optional':\n return '--save-optional'\n case '--exact':\n return '--save-exact'\n default:\n return item\n }\n })\n}\n\nconst yarnToNpmTable = {\n add (args: string[]) {\n if (args.length === 2 && args[1] === '--force') {\n return ['rebuild']\n }\n args[0] = 'install'\n if (\n !args.includes('--dev') &&\n !args.includes('--force') &&\n !args.includes('--exact') &&\n !args.includes('--optional') &&\n !args.includes('--production')\n ) {\n args.push('--save')\n }\n return convertAddRemoveArgs(args)\n },\n remove (args: string[]) {\n args[0] = 'uninstall'\n if (!args.includes('--dev')) {\n args.push('--save')\n }\n return convertAddRemoveArgs(args)\n },\n version (args: string[]) {\n return args.map(item => {\n switch (item) {\n case '--major':\n return 'major'\n case '--minor':\n return 'minor'\n case '--patch':\n return 'patch'\n default:\n return item\n }\n })\n },\n install: 'install',\n list (args: string[]) {\n args[0] = 'ls'\n const patternIndex = args.findIndex(item => item === '--pattern')\n if (patternIndex >= 0 && args[patternIndex + 1]) {\n const packages = args[patternIndex + 1].replace(/[\"']([^\"']+)[\"']/, '$1').split('|')\n args.splice(patternIndex, 2, packages.join(' '))\n }\n return args\n },\n init: 'init',\n create: 'init',\n run: 'run',\n global (args: string[]) {\n switch (args[1]) {\n case 'add':\n args.shift()\n args = yarnToNpmTable.add(args)\n args.push('--global')\n return args\n case 'remove':\n args.shift()\n args = yarnToNpmTable.remove(args)\n args.push('--global')\n return args\n case 'list':\n args.shift()\n args = yarnToNpmTable.list(args)\n args.push('--global')\n return args\n // case 'bin':\n // case 'upgrade':\n default:\n args.push(\"\\n# couldn't auto-convert command\")\n return args\n }\n }\n}\n\nexport function yarnToNPM (_m: string, command: string): string {\n command = (command || '').trim()\n if (command === '') {\n return 'npm install'\n }\n let args = parse(command)\n const firstCommand = (/\\w+/.exec(command) || [''])[0]\n\n if (unchangedCLICommands.includes(args[0])) {\n return 'npm ' + command\n } else if (args[0] in yarnToNpmTable) {\n const converter = yarnToNpmTable[args[0] as keyof typeof yarnToNpmTable]\n\n if (typeof converter === 'function') {\n args = converter(args)\n } else {\n args[0] = converter\n }\n\n return 'npm ' + args.filter(Boolean).join(' ')\n } else if (!yarnCLICommands.includes(firstCommand)) {\n // i.e., yarn grunt -> npm run grunt\n return 'npm run ' + command\n } else {\n return 'npm ' + command + \"\\n# couldn't auto-convert command\"\n }\n}\n","import { unchangedCLICommands, yarnCLICommands } from './utils'\nimport { parse } from './command'\n\nfunction convertInstallArgs (args: string[]) {\n if (args.includes('--global') || args.includes('-g')) {\n args.unshift('global')\n }\n\n return args.map(item => {\n switch (item) {\n case '--save-dev':\n case '-D':\n return '--dev'\n case '--save-prod':\n case '-P':\n return '--production'\n case '--no-package-lock':\n return '--no-lockfile'\n case '--save-optional':\n case '-O':\n return '--optional'\n case '--save-exact':\n case '-E':\n return '--exact'\n case '--save':\n case '-S':\n case '--global':\n case '-g':\n return ''\n default:\n return item\n }\n })\n}\n\nconst npmToYarnTable = {\n install (args: string[]) {\n if (args.length === 1) {\n return ['install']\n }\n args[0] = 'add'\n\n return convertInstallArgs(args)\n },\n i (args: string[]) {\n return npmToYarnTable.install(args)\n },\n uninstall (args: string[]) {\n args[0] = 'remove'\n\n return convertInstallArgs(args)\n },\n remove (args: string[]) {\n return npmToYarnTable.uninstall(args)\n },\n r (args: string[]) {\n return npmToYarnTable.uninstall(args)\n },\n rm (args: string[]) {\n return npmToYarnTable.uninstall(args)\n },\n version (args: string[]) {\n return args.map(item => {\n switch (item) {\n case 'major':\n return '--major'\n case 'minor':\n return '--minor'\n case 'patch':\n return '--patch'\n default:\n return item\n }\n })\n },\n rb (args: string[]) {\n return npmToYarnTable.rebuild(args)\n },\n rebuild (args: string[]) {\n args[0] = 'add'\n args.push('--force')\n return args\n },\n run (args: string[]) {\n if (args[1] && !unchangedCLICommands.includes(args[1]) && !yarnCLICommands.includes(args[1])) {\n args.splice(0, 1)\n }\n return args\n },\n exec (args: string[]) {\n args[0] = 'run'\n return npmToYarnTable.run(args)\n },\n ls (args: string[]) {\n args[0] = 'list'\n\n let ended = false\n const packages = args.filter((item, id) => {\n if (id > 0 && !ended) {\n ended = item.startsWith('-')\n return !ended\n }\n return false\n })\n if (packages.length > 0) {\n args.splice(1, packages.length, '--pattern', '\"' + packages.join('|') + '\"')\n }\n return args\n },\n list (args: string[]) {\n return npmToYarnTable.ls(args)\n },\n init (args: string[]) {\n if (args[1] && !args[1].startsWith('-')) {\n args[0] = 'create'\n }\n return args.filter(item => item !== '--scope')\n },\n ln: 'link',\n un: 'unlink'\n}\n\nexport function npmToYarn (_m: string, command: string): string {\n let args = parse((command || '').trim())\n\n const index = args.findIndex(a => a === '--')\n if (index >= 0) {\n args.splice(index, 1)\n }\n\n if (unchangedCLICommands.includes(args[0])) {\n return 'yarn ' + args.filter(Boolean).join(' ')\n } else if (args[0] in npmToYarnTable) {\n const converter = npmToYarnTable[args[0] as keyof typeof npmToYarnTable]\n\n if (typeof converter === 'function') {\n args = converter(args)\n } else {\n args[0] = converter\n }\n\n return 'yarn ' + args.filter(Boolean).join(' ')\n } else {\n return 'yarn ' + command + \"\\n# couldn't auto-convert command\"\n }\n}\n","import { yarnToNPM } from './yarnToNpm'\nimport { npmToYarn } from './npmToYarn'\n\n/**\n * Converts between npm and yarn command\n */\nexport default function convert (str: string, to: 'npm' | 'yarn'): string {\n if (to === 'npm') {\n return str.replace(/yarn(?: +([^&\\n\\r]*))?/gm, yarnToNPM)\n } else {\n return str.replace(/npm(?: +([^&\\n\\r]*))?/gm, npmToYarn)\n }\n}\n"],"names":[],"mappings":"AAAO,IA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AAA;AACL,YAAA,IAAI,CAAC,CAAC,CAAC,GAAG,SAAS,CAAA;AACpB,SAAA;AAED,QAAA,OAAO,OAAO,GAAG,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;AAChD,KAAA;AAAM,SAAA;AACL,QAAA,OAAO,OAAO,GAAG,OAAO,GAAG,mCAAmC,CAAA;AAC/D,KAAA;AACH;;AC9IA;;AAEG;AACW,SAAU,OAAO,CAAE,GAAW,EAAE,EAAkB,EAAA;IAC9D,IAAI,EAAE,KAAK,KAAK,EAAE;QAChB,OAAO,GAAG,CAAC,OAAO,CAAC,0BAA0B,EAAE,SAAS,CAAC,CAAA;AAC1D,KAAA;AAAM,SAAA;QACL,OAAO,GAAG,CAAC,OAAO,CAAC,yBAAyB,EAAE,SAAS,CAAC,CAAA;AACzD,KAAA;AACH;;;;"} \ No newline at end of file diff --git a/dist/npm-to-yarn.umd.js b/dist/npm-to-yarn.umd.js index a00ecd5..f973c53 100644 --- a/dist/npm-to-yarn.umd.js +++ b/dist/npm-to-yarn.umd.js @@ -4,7 +4,18 @@ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.n2y = factory()); })(this, (function () { 'use strict'; - var unchangedCLICommands = ['test', 'login', 'logout', 'link', 'publish', 'cache']; + var unchangedCLICommands = [ + 'test', + 'login', + 'logout', + 'link', + 'unlink', + 'publish', + 'cache', + 'start', + 'stop', + 'test' + ]; var yarnCLICommands = [ 'init', 'run', @@ -34,8 +45,6 @@ 'self-update', 'tag', 'team', - 'link', - 'unlink', 'upgrade', 'upgrade-interactive', 'version', @@ -147,9 +156,6 @@ init: 'init', create: 'init', run: 'run', - start: 'start', - stop: 'stop', - test: 'test', global: function (args) { switch (args[1]) { case 'add': @@ -252,12 +258,6 @@ remove: function (args) { return npmToYarnTable.uninstall(args); }, - un: function (args) { - return npmToYarnTable.uninstall(args); - }, - unlink: function (args) { - return npmToYarnTable.uninstall(args); - }, r: function (args) { return npmToYarnTable.uninstall(args); }, @@ -320,9 +320,8 @@ } return args.filter(function (item) { return item !== '--scope'; }); }, - start: 'start', - stop: 'stop', - test: 'test' + ln: 'link', + un: 'unlink' }; function npmToYarn(_m, command) { var args = parse((command || '').trim()); @@ -331,7 +330,7 @@ args.splice(index, 1); } if (unchangedCLICommands.includes(args[0])) { - return 'yarn ' + args.join(' '); + return 'yarn ' + args.filter(Boolean).join(' '); } else if (args[0] in npmToYarnTable) { var converter = npmToYarnTable[args[0]]; diff --git a/dist/npm-to-yarn.umd.js.map b/dist/npm-to-yarn.umd.js.map index 2d4177f..787b845 100644 --- a/dist/npm-to-yarn.umd.js.map +++ b/dist/npm-to-yarn.umd.js.map @@ -1 +1 @@ -{"version":3,"file":"npm-to-yarn.umd.js","sources":["../src/utils.ts","../src/command.ts","../src/yarnToNpm.ts","../src/npmToYarn.ts","../src/index.ts"],"sourcesContent":["export const unchangedCLICommands = ['test', 'login', 'logout', 'link', 'publish', 'cache']\n\nexport const yarnCLICommands = [\n 'init',\n 'run',\n 'add',\n 'audit',\n 'autoclean',\n 'bin',\n 'check',\n 'config',\n 'create',\n 'dedupe',\n 'generate-lock-entry',\n 'global',\n 'help',\n 'import',\n 'info',\n 'install',\n 'licenses',\n 'list',\n 'lockfile',\n 'outdated',\n 'owner',\n 'pack',\n 'policies',\n 'prune',\n 'remove',\n 'self-update',\n 'tag',\n 'team',\n 'link',\n 'unlink',\n 'upgrade',\n 'upgrade-interactive',\n 'version',\n 'versions',\n 'why',\n 'workspace',\n 'workspaces'\n]\n\nexport const npmCLICommands = [\n 'init',\n 'run',\n 'access',\n 'adduser',\n 'audit',\n 'bin',\n 'bugs',\n 'build',\n 'bundle',\n 'ci',\n 'completion',\n 'config',\n 'dedupe',\n 'deprecate',\n 'dist-tag',\n 'docs',\n 'doctor',\n 'edit',\n 'explore',\n 'exec',\n 'fund',\n 'help-search',\n 'help',\n 'hook',\n 'install-ci-test',\n 'install-test',\n 'install',\n 'ls',\n 'list',\n 'npm',\n 'org',\n 'outdated',\n 'owner',\n 'pack',\n 'ping',\n 'prefix',\n 'profile',\n 'prune',\n 'rebuild',\n 'repo',\n 'restart',\n 'root',\n 'run-script',\n 'search',\n 'shrinkwrap',\n 'star',\n 'stars',\n 'start',\n 'stop',\n 'team',\n 'token',\n 'uninstall',\n 'unpublish',\n 'update',\n 'version',\n 'view',\n 'whoami'\n]\n","export function parse (command: string) {\n const args: string[] = []\n let lastQuote: string | false = false\n let escaped = false\n let part = ''\n for (let i = 0; i < command.length; ++i) {\n const char = command.charAt(i)\n if (char === '\\\\') {\n part += char\n escaped = true\n } else {\n if (char === ' ' && !lastQuote) {\n args.push(part)\n part = ''\n } else if (!escaped && (char === '\"' || char === \"'\")) {\n part += char\n if (char === lastQuote) {\n lastQuote = false\n } else if (!lastQuote) {\n lastQuote = char\n }\n } else {\n part += char\n }\n escaped = false\n }\n }\n args.push(part)\n return args\n}\n","import { unchangedCLICommands, yarnCLICommands } from './utils'\nimport { parse } from './command'\n\nfunction convertAddRemoveArgs (args: string[]) {\n return args.map(item => {\n switch (item) {\n case '--no-lockfile':\n return '--no-package-lock'\n case '--production':\n return '--save-prod'\n case '--dev':\n return '--save-dev'\n case '--optional':\n return '--save-optional'\n case '--exact':\n return '--save-exact'\n default:\n return item\n }\n })\n}\n\nconst yarnToNpmTable = {\n add (args: string[]) {\n if (args.length === 2 && args[1] === '--force') {\n return ['rebuild'];\n }\n args[0] = 'install'\n if (\n !args.includes('--dev') &&\n !args.includes('--force') &&\n !args.includes('--exact') &&\n !args.includes('--optional') &&\n !args.includes('--production')\n ) {\n args.push('--save')\n }\n return convertAddRemoveArgs(args)\n },\n remove (args: string[]) {\n args[0] = 'uninstall'\n if (!args.includes('--dev')) {\n args.push('--save')\n }\n return convertAddRemoveArgs(args)\n },\n version (args: string[]) {\n return args.map(item => {\n switch (item) {\n case '--major':\n return 'major'\n case '--minor':\n return 'minor'\n case '--patch':\n return 'patch'\n default:\n return item\n }\n })\n },\n install: 'install',\n list (args: string[]) {\n args[0] = 'ls'\n const patternIndex = args.findIndex(item => item === '--pattern')\n if (patternIndex >= 0 && args[patternIndex + 1]) {\n const packages = args[patternIndex + 1].replace(/[\"']([^\"']+)[\"']/, '$1').split('|')\n args.splice(patternIndex, 2, packages.join(' '))\n }\n return args\n },\n init: 'init',\n create: 'init',\n run: 'run',\n start: 'start',\n stop: 'stop',\n test: 'test',\n global (args: string[]) {\n switch (args[1]) {\n case 'add':\n args.shift()\n args = yarnToNpmTable.add(args)\n args.push('--global')\n return args\n case 'remove':\n args.shift()\n args = yarnToNpmTable.remove(args)\n args.push('--global')\n return args\n case 'list':\n args.shift()\n args = yarnToNpmTable.list(args)\n args.push('--global')\n return args\n // case 'bin':\n // case 'upgrade':\n default:\n args.push(\"\\n# couldn't auto-convert command\")\n return args\n }\n }\n}\n\nexport function yarnToNPM (_m: string, command: string): string {\n command = (command || '').trim()\n if (command === '') {\n return 'npm install'\n }\n let args = parse(command)\n const firstCommand = (/\\w+/.exec(command) || [''])[0]\n\n if (unchangedCLICommands.includes(args[0])) {\n return 'npm ' + command\n } else if (args[0] in yarnToNpmTable) {\n const converter = yarnToNpmTable[args[0] as keyof typeof yarnToNpmTable]\n\n if (typeof converter === 'function') {\n args = converter(args)\n } else {\n args[0] = converter\n }\n\n return 'npm ' + args.filter(Boolean).join(' ')\n } else if (!yarnCLICommands.includes(firstCommand)) {\n // i.e., yarn grunt -> npm run grunt\n return 'npm run ' + command\n } else {\n return 'npm ' + command + \"\\n# couldn't auto-convert command\"\n }\n}\n","import { unchangedCLICommands, yarnCLICommands } from './utils'\nimport { parse } from './command'\n\nfunction convertInstallArgs (args: string[]) {\n if (args.includes('--global') || args.includes('-g')) {\n args.unshift('global')\n }\n\n return args.map(item => {\n switch (item) {\n case '--save-dev':\n case '-D':\n return '--dev'\n case '--save-prod':\n case '-P':\n return '--production'\n case '--no-package-lock':\n return '--no-lockfile'\n case '--save-optional':\n case '-O':\n return '--optional'\n case '--save-exact':\n case '-E':\n return '--exact'\n case '--save':\n case '-S':\n case '--global':\n case '-g':\n return ''\n default:\n return item\n }\n })\n}\n\nconst npmToYarnTable = {\n install (args: string[]) {\n if (args.length === 1) {\n return ['install']\n }\n args[0] = 'add'\n\n return convertInstallArgs(args)\n },\n i (args: string[]) {\n return npmToYarnTable.install(args)\n },\n uninstall (args: string[]) {\n args[0] = 'remove'\n\n return convertInstallArgs(args)\n },\n remove (args: string[]) {\n return npmToYarnTable.uninstall(args)\n },\n un (args: string[]) {\n return npmToYarnTable.uninstall(args)\n },\n unlink (args: string[]) {\n return npmToYarnTable.uninstall(args)\n },\n r (args: string[]) {\n return npmToYarnTable.uninstall(args)\n },\n rm (args: string[]) {\n return npmToYarnTable.uninstall(args)\n },\n version (args: string[]) {\n return args.map(item => {\n switch (item) {\n case 'major':\n return '--major'\n case 'minor':\n return '--minor'\n case 'patch':\n return '--patch'\n default:\n return item\n }\n })\n },\n rb (args: string[]) {\n return npmToYarnTable.rebuild(args)\n },\n rebuild (args: string[]) {\n args[0] = 'add'\n args.push('--force')\n return args\n },\n run (args: string[]) {\n if (args[1] && !unchangedCLICommands.includes(args[1]) && !yarnCLICommands.includes(args[1])) {\n args.splice(0, 1)\n }\n return args\n },\n exec (args: string[]) {\n args[0] = 'run'\n return npmToYarnTable.run(args)\n },\n ls (args: string[]) {\n args[0] = 'list'\n\n let ended = false\n const packages = args.filter((item, id) => {\n if (id > 0 && !ended) {\n ended = item.startsWith('-')\n return !ended\n }\n return false\n })\n if (packages.length > 0) {\n args.splice(1, packages.length, '--pattern', '\"' + packages.join('|') + '\"')\n }\n return args\n },\n list (args: string[]) {\n return npmToYarnTable.ls(args)\n },\n init (args: string[]) {\n if (args[1] && !args[1].startsWith('-')) {\n args[0] = 'create'\n }\n return args.filter(item => item !== '--scope')\n },\n start: 'start',\n stop: 'stop',\n test: 'test'\n}\n\nexport function npmToYarn (_m: string, command: string): string {\n let args = parse((command || '').trim())\n\n const index = args.findIndex(a => a === '--')\n if (index >= 0) {\n args.splice(index, 1)\n }\n\n if (unchangedCLICommands.includes(args[0])) {\n return 'yarn ' + args.join(' ')\n } else if (args[0] in npmToYarnTable) {\n const converter = npmToYarnTable[args[0] as keyof typeof npmToYarnTable]\n\n if (typeof converter === 'function') {\n args = converter(args)\n } else {\n args[0] = converter\n }\n\n return 'yarn ' + args.filter(Boolean).join(' ')\n } else {\n return 'yarn ' + command + \"\\n# couldn't auto-convert command\"\n }\n}\n","import { yarnToNPM } from './yarnToNpm'\nimport { npmToYarn } from './npmToYarn'\n\n/**\n * Converts between npm and yarn command\n */\nexport default function convert (str: string, to: 'npm' | 'yarn'): string {\n if (to === 'npm') {\n return str.replace(/yarn(?: +([^&\\n\\r]*))?/gm, yarnToNPM)\n } else {\n return str.replace(/npm(?: +([^&\\n\\r]*))?/gm, npmToYarn)\n }\n}\n"],"names":[],"mappings":";;;;;;EAAO,IAAM,oBAAoB,GAAG,CAAC,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,OAAO,CAAC,CAAA;EAEpF,IAAM,eAAe,GAAG;MAC7B,MAAM;MACN,KAAK;MACL,KAAK;MACL,OAAO;MACP,WAAW;MACX,KAAK;MACL,OAAO;MACP,QAAQ;MACR,QAAQ;MACR,QAAQ;MACR,qBAAqB;MACrB,QAAQ;MACR,MAAM;MACN,QAAQ;MACR,MAAM;MACN,SAAS;MACT,UAAU;MACV,MAAM;MACN,UAAU;MACV,UAAU;MACV,OAAO;MACP,MAAM;MACN,UAAU;MACV,OAAO;MACP,QAAQ;MACR,aAAa;MACb,KAAK;MACL,MAAM;MACN,MAAM;MACN,QAAQ;MACR,SAAS;MACT,qBAAqB;MACrB,SAAS;MACT,UAAU;MACV,KAAK;MACL,WAAW;MACX,YAAY;GACb;;ECxCK,SAAU,KAAK,CAAE,OAAe,EAAA;MACpC,IAAM,IAAI,GAAa,EAAE,CAAA;MACzB,IAAI,SAAS,GAAmB,KAAK,CAAA;MACrC,IAAI,OA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AA0B,EAAE,SAAS,CAAC,CAAA;EAC1D,KAAA;EAAM,SAAA;UACL,OAAO,GAAG,CAAC,OAAO,CAAC,yBAAyB,EAAE,SAAS,CAAC,CAAA;EACzD,KAAA;EACH;;;;;;;;"} \ No newline at end of file +{"version":3,"file":"npm-to-yarn.umd.js","sources":["../src/utils.ts","../src/command.ts","../src/yarnToNpm.ts","../src/npmToYarn.ts","../src/index.ts"],"sourcesContent":["export const unchangedCLICommands = [\n 'test',\n 'login',\n 'logout',\n 'link',\n 'unlink',\n 'publish',\n 'cache',\n 'start',\n 'stop',\n 'test'\n]\n\nexport const yarnCLICommands = [\n 'init',\n 'run',\n 'add',\n 'audit',\n 'autoclean',\n 'bin',\n 'check',\n 'config',\n 'create',\n 'dedupe',\n 'generate-lock-entry',\n 'global',\n 'help',\n 'import',\n 'info',\n 'install',\n 'licenses',\n 'list',\n 'lockfile',\n 'outdated',\n 'owner',\n 'pack',\n 'policies',\n 'prune',\n 'remove',\n 'self-update',\n 'tag',\n 'team',\n 'upgrade',\n 'upgrade-interactive',\n 'version',\n 'versions',\n 'why',\n 'workspace',\n 'workspaces'\n]\n\nexport const npmCLICommands = [\n 'init',\n 'run',\n 'access',\n 'adduser',\n 'audit',\n 'bin',\n 'bugs',\n 'build',\n 'bundle',\n 'ci',\n 'completion',\n 'config',\n 'dedupe',\n 'deprecate',\n 'dist-tag',\n 'docs',\n 'doctor',\n 'edit',\n 'explore',\n 'exec',\n 'fund',\n 'help-search',\n 'help',\n 'hook',\n 'install-ci-test',\n 'install-test',\n 'install',\n 'ls',\n 'list',\n 'npm',\n 'org',\n 'outdated',\n 'owner',\n 'pack',\n 'ping',\n 'prefix',\n 'profile',\n 'prune',\n 'rebuild',\n 'repo',\n 'restart',\n 'root',\n 'run-script',\n 'search',\n 'shrinkwrap',\n 'star',\n 'stars',\n 'start',\n 'stop',\n 'team',\n 'token',\n 'uninstall',\n 'unpublish',\n 'update',\n 'version',\n 'view',\n 'whoami'\n]\n","export function parse (command: string) {\n const args: string[] = []\n let lastQuote: string | false = false\n let escaped = false\n let part = ''\n for (let i = 0; i < command.length; ++i) {\n const char = command.charAt(i)\n if (char === '\\\\') {\n part += char\n escaped = true\n } else {\n if (char === ' ' && !lastQuote) {\n args.push(part)\n part = ''\n } else if (!escaped && (char === '\"' || char === \"'\")) {\n part += char\n if (char === lastQuote) {\n lastQuote = false\n } else if (!lastQuote) {\n lastQuote = char\n }\n } else {\n part += char\n }\n escaped = false\n }\n }\n args.push(part)\n return args\n}\n","import { unchangedCLICommands, yarnCLICommands } from './utils'\nimport { parse } from './command'\n\nfunction convertAddRemoveArgs (args: string[]) {\n return args.map(item => {\n switch (item) {\n case '--no-lockfile':\n return '--no-package-lock'\n case '--production':\n return '--save-prod'\n case '--dev':\n return '--save-dev'\n case '--optional':\n return '--save-optional'\n case '--exact':\n return '--save-exact'\n default:\n return item\n }\n })\n}\n\nconst yarnToNpmTable = {\n add (args: string[]) {\n if (args.length === 2 && args[1] === '--force') {\n return ['rebuild']\n }\n args[0] = 'install'\n if (\n !args.includes('--dev') &&\n !args.includes('--force') &&\n !args.includes('--exact') &&\n !args.includes('--optional') &&\n !args.includes('--production')\n ) {\n args.push('--save')\n }\n return convertAddRemoveArgs(args)\n },\n remove (args: string[]) {\n args[0] = 'uninstall'\n if (!args.includes('--dev')) {\n args.push('--save')\n }\n return convertAddRemoveArgs(args)\n },\n version (args: string[]) {\n return args.map(item => {\n switch (item) {\n case '--major':\n return 'major'\n case '--minor':\n return 'minor'\n case '--patch':\n return 'patch'\n default:\n return item\n }\n })\n },\n install: 'install',\n list (args: string[]) {\n args[0] = 'ls'\n const patternIndex = args.findIndex(item => item === '--pattern')\n if (patternIndex >= 0 && args[patternIndex + 1]) {\n const packages = args[patternIndex + 1].replace(/[\"']([^\"']+)[\"']/, '$1').split('|')\n args.splice(patternIndex, 2, packages.join(' '))\n }\n return args\n },\n init: 'init',\n create: 'init',\n run: 'run',\n global (args: string[]) {\n switch (args[1]) {\n case 'add':\n args.shift()\n args = yarnToNpmTable.add(args)\n args.push('--global')\n return args\n case 'remove':\n args.shift()\n args = yarnToNpmTable.remove(args)\n args.push('--global')\n return args\n case 'list':\n args.shift()\n args = yarnToNpmTable.list(args)\n args.push('--global')\n return args\n // case 'bin':\n // case 'upgrade':\n default:\n args.push(\"\\n# couldn't auto-convert command\")\n return args\n }\n }\n}\n\nexport function yarnToNPM (_m: string, command: string): string {\n command = (command || '').trim()\n if (command === '') {\n return 'npm install'\n }\n let args = parse(command)\n const firstCommand = (/\\w+/.exec(command) || [''])[0]\n\n if (unchangedCLICommands.includes(args[0])) {\n return 'npm ' + command\n } else if (args[0] in yarnToNpmTable) {\n const converter = yarnToNpmTable[args[0] as keyof typeof yarnToNpmTable]\n\n if (typeof converter === 'function') {\n args = converter(args)\n } else {\n args[0] = converter\n }\n\n return 'npm ' + args.filter(Boolean).join(' ')\n } else if (!yarnCLICommands.includes(firstCommand)) {\n // i.e., yarn grunt -> npm run grunt\n return 'npm run ' + command\n } else {\n return 'npm ' + command + \"\\n# couldn't auto-convert command\"\n }\n}\n","import { unchangedCLICommands, yarnCLICommands } from './utils'\nimport { parse } from './command'\n\nfunction convertInstallArgs (args: string[]) {\n if (args.includes('--global') || args.includes('-g')) {\n args.unshift('global')\n }\n\n return args.map(item => {\n switch (item) {\n case '--save-dev':\n case '-D':\n return '--dev'\n case '--save-prod':\n case '-P':\n return '--production'\n case '--no-package-lock':\n return '--no-lockfile'\n case '--save-optional':\n case '-O':\n return '--optional'\n case '--save-exact':\n case '-E':\n return '--exact'\n case '--save':\n case '-S':\n case '--global':\n case '-g':\n return ''\n default:\n return item\n }\n })\n}\n\nconst npmToYarnTable = {\n install (args: string[]) {\n if (args.length === 1) {\n return ['install']\n }\n args[0] = 'add'\n\n return convertInstallArgs(args)\n },\n i (args: string[]) {\n return npmToYarnTable.install(args)\n },\n uninstall (args: string[]) {\n args[0] = 'remove'\n\n return convertInstallArgs(args)\n },\n remove (args: string[]) {\n return npmToYarnTable.uninstall(args)\n },\n r (args: string[]) {\n return npmToYarnTable.uninstall(args)\n },\n rm (args: string[]) {\n return npmToYarnTable.uninstall(args)\n },\n version (args: string[]) {\n return args.map(item => {\n switch (item) {\n case 'major':\n return '--major'\n case 'minor':\n return '--minor'\n case 'patch':\n return '--patch'\n default:\n return item\n }\n })\n },\n rb (args: string[]) {\n return npmToYarnTable.rebuild(args)\n },\n rebuild (args: string[]) {\n args[0] = 'add'\n args.push('--force')\n return args\n },\n run (args: string[]) {\n if (args[1] && !unchangedCLICommands.includes(args[1]) && !yarnCLICommands.includes(args[1])) {\n args.splice(0, 1)\n }\n return args\n },\n exec (args: string[]) {\n args[0] = 'run'\n return npmToYarnTable.run(args)\n },\n ls (args: string[]) {\n args[0] = 'list'\n\n let ended = false\n const packages = args.filter((item, id) => {\n if (id > 0 && !ended) {\n ended = item.startsWith('-')\n return !ended\n }\n return false\n })\n if (packages.length > 0) {\n args.splice(1, packages.length, '--pattern', '\"' + packages.join('|') + '\"')\n }\n return args\n },\n list (args: string[]) {\n return npmToYarnTable.ls(args)\n },\n init (args: string[]) {\n if (args[1] && !args[1].startsWith('-')) {\n args[0] = 'create'\n }\n return args.filter(item => item !== '--scope')\n },\n ln: 'link',\n un: 'unlink'\n}\n\nexport function npmToYarn (_m: string, command: string): string {\n let args = parse((command || '').trim())\n\n const index = args.findIndex(a => a === '--')\n if (index >= 0) {\n args.splice(index, 1)\n }\n\n if (unchangedCLICommands.includes(args[0])) {\n return 'yarn ' + args.filter(Boolean).join(' ')\n } else if (args[0] in npmToYarnTable) {\n const converter = npmToYarnTable[args[0] as keyof typeof npmToYarnTable]\n\n if (typeof converter === 'function') {\n args = converter(args)\n } else {\n args[0] = converter\n }\n\n return 'yarn ' + args.filter(Boolean).join(' ')\n } else {\n return 'yarn ' + command + \"\\n# couldn't auto-convert command\"\n }\n}\n","import { yarnToNPM } from './yarnToNpm'\nimport { npmToYarn } from './npmToYarn'\n\n/**\n * Converts between npm and yarn command\n */\nexport default function convert (str: string, to: 'npm' | 'yarn'): string {\n if (to === 'npm') {\n return str.replace(/yarn(?: +([^&\\n\\r]*))?/gm, yarnToNPM)\n } else {\n return str.replace(/npm(?: +([^&\\n\\r]*))?/gm, npmToYarn)\n }\n}\n"],"names":[],"mappings":";;;;;;EAAO,IAAM,oBAAoB,GAAG;MAClC,MAAM;MACN,OAAO;MACP,QAAQ;MACR,MAAM;MACN,QAAQ;MACR,SAAS;MACT,OAAO;MACP,OAAO;MACP,MAAM;MACN,MAAM;GACP,CAAA;EAEM,IAAM,eAAe,GAAG;MAC7B,MAAM;MACN,KAAK;MACL,KAAK;MACL,OAAO;MACP,WAAW;MACX,KAAK;MACL,OAAO;MACP,QAAQ;MACR,QAAQ;MACR,QAAQ;MACR,qBAAqB;MACrB,QAAQ;MACR,MAAM;MACN,QAAQ;MACR,MAAM;MACN,SAAS;MACT,UAAU;MACV,MAAM;MACN,UAAU;MACV,UAAU;MACV,OAAO;MACP,MAAM;MACN,UAAU;MACV,OAAO;MACP,QAAQ;MACR,aAAa;MACb,KAAK;MACL,MAAM;MACN,SAAS;MACT,qBAAqB;MACrB,SAAS;MACT,UAAU;MACV,KAAK;MACL,WAAW;MACX,YAAY;GACb;;ECjDK,SAAU,KAAK,CAAE,OAAe,EAAA;MACpC,IAAM,IAAI,GAAa,EAAE,CAAA;MACzB,IAAI,SAAS,GAAmB,KAAK,CAAA;MACrC,IAAI,OAAO,GAAG,KAAK,CAAA;MACnB,IAAI,IAAI,GAAG,EAAE,CAAA;EACb,IAAA,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,EAAE;UACvC,IAAM,IAAI,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAA;UAC9B,IAAI,IAAI,KAAK,IAAI,EAAE;cACjB,IAAI,IAAI,IAAI,CAAA;cACZ,OAAO,GAAG,IAAI,CAAA;EACf,SAAA;EAAM,aAAA;EACL,YAA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AM,SAAS,GAAG,cAAc,CAAC,IAAI,CAAC,CAAC,CAAgC,CAAC,CAAA;EAExE,QAAA,IAAI,OAAO,SAAS,KAAK,UAAU,EAAE;EACnC,YAAA,IAAI,GAAG,SAAS,CAAC,IAAI,CAAC,CAAA;EACvB,SAAA;EAAM,aAAA;EACL,YAAA,IAAI,CAAC,CAAC,CAAC,GAAG,SAAS,CAAA;EACpB,SAAA;EAED,QAAA,OAAO,OAAO,GAAG,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;EAChD,KAAA;EAAM,SAAA;EACL,QAAA,OAAO,OAAO,GAAG,OAAO,GAAG,mCAAmC,CAAA;EAC/D,KAAA;EACH;;EC9IA;;EAEG;EACW,SAAU,OAAO,CAAE,GAAW,EAAE,EAAkB,EAAA;MAC9D,IAAI,EAAE,KAAK,KAAK,EAAE;UAChB,OAAO,GAAG,CAAC,OAAO,CAAC,0BAA0B,EAAE,SAAS,CAAC,CAAA;EAC1D,KAAA;EAAM,SAAA;UACL,OAAO,GAAG,CAAC,OAAO,CAAC,yBAAyB,EAAE,SAAS,CAAC,CAAA;EACzD,KAAA;EACH;;;;;;;;"} \ No newline at end of file diff --git a/src/npmToYarn.ts b/src/npmToYarn.ts index 1210889..7d32091 100644 --- a/src/npmToYarn.ts +++ b/src/npmToYarn.ts @@ -53,12 +53,6 @@ const npmToYarnTable = { remove (args: string[]) { return npmToYarnTable.uninstall(args) }, - un (args: string[]) { - return npmToYarnTable.uninstall(args) - }, - unlink (args: string[]) { - return npmToYarnTable.uninstall(args) - }, r (args: string[]) { return npmToYarnTable.uninstall(args) }, @@ -122,9 +116,8 @@ const npmToYarnTable = { } return args.filter(item => item !== '--scope') }, - start: 'start', - stop: 'stop', - test: 'test' + ln: 'link', + un: 'unlink' } export function npmToYarn (_m: string, command: string): string { @@ -136,7 +129,7 @@ export function npmToYarn (_m: string, command: string): string { } if (unchangedCLICommands.includes(args[0])) { - return 'yarn ' + args.join(' ') + return 'yarn ' + args.filter(Boolean).join(' ') } else if (args[0] in npmToYarnTable) { const converter = npmToYarnTable[args[0] as keyof typeof npmToYarnTable] diff --git a/src/utils.ts b/src/utils.ts index 18d4d1a..095d590 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -1,4 +1,15 @@ -export const unchangedCLICommands = ['test', 'login', 'logout', 'link', 'publish', 'cache'] +export const unchangedCLICommands = [ + 'test', + 'login', + 'logout', + 'link', + 'unlink', + 'publish', + 'cache', + 'start', + 'stop', + 'test' +] export const yarnCLICommands = [ 'init', @@ -29,8 +40,6 @@ export const yarnCLICommands = [ 'self-update', 'tag', 'team', - 'link', - 'unlink', 'upgrade', 'upgrade-interactive', 'version', diff --git a/src/yarnToNpm.ts b/src/yarnToNpm.ts index 3499642..2f9204c 100644 --- a/src/yarnToNpm.ts +++ b/src/yarnToNpm.ts @@ -23,7 +23,7 @@ function convertAddRemoveArgs (args: string[]) { const yarnToNpmTable = { add (args: string[]) { if (args.length === 2 && args[1] === '--force') { - return ['rebuild']; + return ['rebuild'] } args[0] = 'install' if ( @@ -71,9 +71,6 @@ const yarnToNpmTable = { init: 'init', create: 'init', run: 'run', - start: 'start', - stop: 'stop', - test: 'test', global (args: string[]) { switch (args[1]) { case 'add': diff --git a/test/index.spec.ts b/test/index.spec.ts index 265af84..1adfd87 100644 --- a/test/index.spec.ts +++ b/test/index.spec.ts @@ -19,6 +19,8 @@ describe('NPM to Yarn tests', () => { }) it('Simple convert works w/ remove', () => { + expect(convert('npm r squirrelly', 'yarn')).toEqual('yarn remove squirrelly') + expect(convert('npm remove squirrelly', 'yarn')).toEqual('yarn remove squirrelly') expect(convert('npm uninstall squirrelly', 'yarn')).toEqual('yarn remove squirrelly') }) @@ -171,6 +173,13 @@ describe('NPM to Yarn tests', () => { expect(convert('npm ls --production', 'yarn')).toEqual('yarn list --production') expect(convert('npm ls --development', 'yarn')).toEqual('yarn list --development') }) + + it('npm link/unlink', () => { + expect(convert('npm ln custom', 'yarn')).toEqual('yarn link custom') + expect(convert('npm link custom', 'yarn')).toEqual('yarn link custom') + expect(convert('npm unlink custom', 'yarn')).toEqual('yarn unlink custom') + expect(convert('npm un custom', 'yarn')).toEqual('yarn unlink custom') + }) }) describe('Yarn to NPM tests', () => { @@ -295,4 +304,9 @@ describe('Yarn to NPM tests', () => { expect(convert('yarn list --production', 'npm')).toEqual('npm ls --production') expect(convert('yarn list --development', 'npm')).toEqual('npm ls --development') }) + + it('npm link/unlink', () => { + expect(convert('yarn link custom', 'npm')).toEqual('npm link custom') + expect(convert('yarn unlink custom', 'npm')).toEqual('npm unlink custom') + }) })