diff --git a/dist/npm-to-yarn.mjs b/dist/npm-to-yarn.mjs index 9e00a04..d8b0556 100644 --- a/dist/npm-to-yarn.mjs +++ b/dist/npm-to-yarn.mjs @@ -96,7 +96,7 @@ var yarnToNpmTable = { return ['rebuild']; } args[0] = 'install'; - if (!args.includes('--dev')) { + if (!args.includes('--dev') && !args.includes('--exact') && !args.includes('--optional')) { args.push('--save'); } return convertAddRemoveArgs(args); @@ -188,15 +188,15 @@ var npmToYarnTable = { args.unshift('global'); } return args.map(function (item) { - if (item === '--save-dev') + if (item === '--save-dev' || item === '-D') return '--dev'; - else if (item === '--save') + else if (item === '--save' || item === '-S') return ''; else if (item === '--no-package-lock') return '--no-lockfile'; else if (item === '--save-optional') return '--optional'; - else if (item === '--save-exact') + else if (item === '--save-exact' || item === '-E') return '--exact'; else if (item === '--global' || item === '-g') return ''; @@ -204,6 +204,7 @@ var npmToYarnTable = { }); }, i: function (args) { + args[0] = 'install'; return npmToYarnTable.install(args); }, uninstall: function (args) { diff --git a/dist/npm-to-yarn.mjs.map b/dist/npm-to-yarn.mjs.map index 2bfba9a..c007256 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 '--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[1] === '--force') {\n return ['rebuild']\n }\n args[0] = 'install'\n if (!args.includes('--dev')) {\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 && 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 if (args[1] === 'add' || args[1] === 'remove') {\n args.splice(0, 2, args[1] === 'add' ? 'install' : 'uninstall')\n args.push('--global')\n return convertAddRemoveArgs(args)\n }\n // TODO: find better way\n args.push(\"\\n# couldn't auto-convert command\")\n return args\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\nconst npmToYarnTable = {\n install(args: string[]) {\n if (args.length === 1) {\n return args\n }\n args[0] = 'add'\n\n if (args.includes('--global') || args.includes('-g')) {\n args.unshift('global')\n }\n\n return args.map((item) => {\n if (item === '--save-dev') return '--dev'\n else if (item === '--save') return ''\n else if (item === '--no-package-lock') return '--no-lockfile'\n else if (item === '--save-optional') return '--optional'\n else if (item === '--save-exact') return '--exact'\n else if (item === '--global' || item === '-g') return ''\n return item\n })\n },\n i(args: string[]) {\n return npmToYarnTable.install(args)\n },\n uninstall(args: string[]) {\n args[0] = 'remove'\n\n if (args.includes('--global') || args.includes('-g')) {\n args.unshift('global')\n }\n\n return args.map((item) => {\n if (item === '--save-dev') return '--dev'\n else if (item === '--save') return ''\n else if (item === '--no-package-lock') return '--no-lockfile'\n else if (item === '--global' || item === '-g') return ''\n return item\n })\n },\n version(args: string[]) {\n return args.map((item) => {\n if (['major', 'minor', 'patch'].includes(item)) return `--${item}`\n return item\n })\n },\n rebuild(args: string[]) {\n args[0] = 'add --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 yarn to npm command\n */\nfunction convertToNpm(str: string) {\n return str.replace(/yarn(?: +([^&\\n\\r]*))?/gm, yarnToNPM)\n}\n\n/**\n * Converts npm to yarn command\n */\nfunction convertToYarn(str: string) {\n return str.replace(/npm(?: +([^&\\n\\r]*))?/gm, npmToYarn)\n}\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 convertToNpm(str)\n } else {\n return convertToYarn(str)\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,CAAC,OAAe,EAAA;IACnC,IAAM,IAAI,GAAa,EAAE,CAAA;IACzB,IAAI,SAAS,GAAmB,KAAK,CAAA;IACrC,IAAI,OAAO,GAAG,KAAK,CAAA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AAA;AAC3D,CAAC;AAED;;AAEG;AACH,SAAS,aAAa,CAAC,GAAW,EAAA;IAChC,OAAO,GAAG,CAAC,OAAO,CAAC,yBAAyB,EAAE,SAAS,CAAC,CAAA;AAC1D,CAAC;AAED;;AAEG;AACW,SAAU,OAAO,CAAC,GAAW,EAAE,EAAkB,EAAA;IAC7D,IAAI,EAAE,KAAK,KAAK,EAAE;AAChB,QAAA,OAAO,YAAY,CAAC,GAAG,CAAC,CAAA;AACzB,KAAA;AAAM,SAAA;AACL,QAAA,OAAO,aAAa,CAAC,GAAG,CAAC,CAAA;AAC1B,KAAA;AACH;;;;"} \ No newline at end of file +{"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 '--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[1] === '--force') {\n return ['rebuild']\n }\n args[0] = 'install'\n if (!args.includes('--dev') && !args.includes('--exact') && !args.includes('--optional')) {\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 && 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 if (args[1] === 'add' || args[1] === 'remove') {\n args.splice(0, 2, args[1] === 'add' ? 'install' : 'uninstall')\n args.push('--global')\n return convertAddRemoveArgs(args)\n }\n // TODO: find better way\n args.push(\"\\n# couldn't auto-convert command\")\n return args\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\nconst npmToYarnTable = {\n install(args: string[]) {\n if (args.length === 1) {\n return args\n }\n args[0] = 'add'\n\n if (args.includes('--global') || args.includes('-g')) {\n args.unshift('global')\n }\n\n return args.map((item) => {\n if (item === '--save-dev' || item === '-D') return '--dev'\n else if (item === '--save' || item === '-S') return ''\n else if (item === '--no-package-lock') return '--no-lockfile'\n else if (item === '--save-optional') return '--optional'\n else if (item === '--save-exact' || item === '-E') return '--exact'\n else if (item === '--global' || item === '-g') return ''\n return item\n })\n },\n i(args: string[]) {\n args[0] = 'install'\n return npmToYarnTable.install(args)\n },\n uninstall(args: string[]) {\n args[0] = 'remove'\n\n if (args.includes('--global') || args.includes('-g')) {\n args.unshift('global')\n }\n\n return args.map((item) => {\n if (item === '--save-dev') return '--dev'\n else if (item === '--save') return ''\n else if (item === '--no-package-lock') return '--no-lockfile'\n else if (item === '--global' || item === '-g') return ''\n return item\n })\n },\n version(args: string[]) {\n return args.map((item) => {\n if (['major', 'minor', 'patch'].includes(item)) return `--${item}`\n return item\n })\n },\n rebuild(args: string[]) {\n args[0] = 'add --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 yarn to npm command\n */\nfunction convertToNpm(str: string) {\n return str.replace(/yarn(?: +([^&\\n\\r]*))?/gm, yarnToNPM)\n}\n\n/**\n * Converts npm to yarn command\n */\nfunction convertToYarn(str: string) {\n return str.replace(/npm(?: +([^&\\n\\r]*))?/gm, npmToYarn)\n}\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 convertToNpm(str)\n } else {\n return convertToYarn(str)\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,CAAC,OAAe,EAAA;IACnC,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,IAAI,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAA;QAC9B,IAAI,IAAI,KAAK,IAAI,EAAE;YACjB,IAAI,IAAI,IAAI,CAAA;YACZ,OAAO,GAAG,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GAAW,EAAA;IAChC,OAAO,GAAG,CAAC,OAAO,CAAC,yBAAyB,EAAE,SAAS,CAAC,CAAA;AAC1D,CAAC;AAED;;AAEG;AACW,SAAU,OAAO,CAAC,GAAW,EAAE,EAAkB,EAAA;IAC7D,IAAI,EAAE,KAAK,KAAK,EAAE;AAChB,QAAA,OAAO,YAAY,CAAC,GAAG,CAAC,CAAA;AACzB,KAAA;AAAM,SAAA;AACL,QAAA,OAAO,aAAa,CAAC,GAAG,CAAC,CAAA;AAC1B,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 77b8be3..06cae3b 100644 --- a/dist/npm-to-yarn.umd.js +++ b/dist/npm-to-yarn.umd.js @@ -102,7 +102,7 @@ return ['rebuild']; } args[0] = 'install'; - if (!args.includes('--dev')) { + if (!args.includes('--dev') && !args.includes('--exact') && !args.includes('--optional')) { args.push('--save'); } return convertAddRemoveArgs(args); @@ -194,15 +194,15 @@ args.unshift('global'); } return args.map(function (item) { - if (item === '--save-dev') + if (item === '--save-dev' || item === '-D') return '--dev'; - else if (item === '--save') + else if (item === '--save' || item === '-S') return ''; else if (item === '--no-package-lock') return '--no-lockfile'; else if (item === '--save-optional') return '--optional'; - else if (item === '--save-exact') + else if (item === '--save-exact' || item === '-E') return '--exact'; else if (item === '--global' || item === '-g') return ''; @@ -210,6 +210,7 @@ }); }, i: function (args) { + args[0] = 'install'; return npmToYarnTable.install(args); }, uninstall: function (args) { diff --git a/dist/npm-to-yarn.umd.js.map b/dist/npm-to-yarn.umd.js.map index 924dcc2..05829d2 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 '--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[1] === '--force') {\n return ['rebuild']\n }\n args[0] = 'install'\n if (!args.includes('--dev')) {\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 && 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 if (args[1] === 'add' || args[1] === 'remove') {\n args.splice(0, 2, args[1] === 'add' ? 'install' : 'uninstall')\n args.push('--global')\n return convertAddRemoveArgs(args)\n }\n // TODO: find better way\n args.push(\"\\n# couldn't auto-convert command\")\n return args\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\nconst npmToYarnTable = {\n install(args: string[]) {\n if (args.length === 1) {\n return args\n }\n args[0] = 'add'\n\n if (args.includes('--global') || args.includes('-g')) {\n args.unshift('global')\n }\n\n return args.map((item) => {\n if (item === '--save-dev') return '--dev'\n else if (item === '--save') return ''\n else if (item === '--no-package-lock') return '--no-lockfile'\n else if (item === '--save-optional') return '--optional'\n else if (item === '--save-exact') return '--exact'\n else if (item === '--global' || item === '-g') return ''\n return item\n })\n },\n i(args: string[]) {\n return npmToYarnTable.install(args)\n },\n uninstall(args: string[]) {\n args[0] = 'remove'\n\n if (args.includes('--global') || args.includes('-g')) {\n args.unshift('global')\n }\n\n return args.map((item) => {\n if (item === '--save-dev') return '--dev'\n else if (item === '--save') return ''\n else if (item === '--no-package-lock') return '--no-lockfile'\n else if (item === '--global' || item === '-g') return ''\n return item\n })\n },\n version(args: string[]) {\n return args.map((item) => {\n if (['major', 'minor', 'patch'].includes(item)) return `--${item}`\n return item\n })\n },\n rebuild(args: string[]) {\n args[0] = 'add --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 yarn to npm command\n */\nfunction convertToNpm(str: string) {\n return str.replace(/yarn(?: +([^&\\n\\r]*))?/gm, yarnToNPM)\n}\n\n/**\n * Converts npm to yarn command\n */\nfunction convertToYarn(str: string) {\n return str.replace(/npm(?: +([^&\\n\\r]*))?/gm, npmToYarn)\n}\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 convertToNpm(str)\n } else {\n return convertToYarn(str)\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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B,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;;EChHA;;EAEG;EACH,SAAS,YAAY,CAAC,GAAW,EAAA;MAC/B,OAAO,GAAG,CAAC,OAAO,CAAC,0BAA0B,EAAE,SAAS,CAAC,CAAA;EAC3D,CAAC;EAED;;EAEG;EACH,SAAS,aAAa,CAAC,GAAW,EAAA;MAChC,OAAO,GAAG,CAAC,OAAO,CAAC,yBAAyB,EAAE,SAAS,CAAC,CAAA;EAC1D,CAAC;EAED;;EAEG;EACW,SAAU,OAAO,CAAC,GAAW,EAAE,EAAkB,EAAA;MAC7D,IAAI,EAAE,KAAK,KAAK,EAAE;EAChB,QAAA,OAAO,YAAY,CAAC,GAAG,CAAC,CAAA;EACzB,KAAA;EAAM,SAAA;EACL,QAAA,OAAO,aAAa,CAAC,GAAG,CAAC,CAAA;EAC1B,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 = ['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 '--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[1] === '--force') {\n return ['rebuild']\n }\n args[0] = 'install'\n if (!args.includes('--dev') && !args.includes('--exact') && !args.includes('--optional')) {\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 && 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 if (args[1] === 'add' || args[1] === 'remove') {\n args.splice(0, 2, args[1] === 'add' ? 'install' : 'uninstall')\n args.push('--global')\n return convertAddRemoveArgs(args)\n }\n // TODO: find better way\n args.push(\"\\n# couldn't auto-convert command\")\n return args\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\nconst npmToYarnTable = {\n install(args: string[]) {\n if (args.length === 1) {\n return args\n }\n args[0] = 'add'\n\n if (args.includes('--global') || args.includes('-g')) {\n args.unshift('global')\n }\n\n return args.map((item) => {\n if (item === '--save-dev' || item === '-D') return '--dev'\n else if (item === '--save' || item === '-S') return ''\n else if (item === '--no-package-lock') return '--no-lockfile'\n else if (item === '--save-optional') return '--optional'\n else if (item === '--save-exact' || item === '-E') return '--exact'\n else if (item === '--global' || item === '-g') return ''\n return item\n })\n },\n i(args: string[]) {\n args[0] = 'install'\n return npmToYarnTable.install(args)\n },\n uninstall(args: string[]) {\n args[0] = 'remove'\n\n if (args.includes('--global') || args.includes('-g')) {\n args.unshift('global')\n }\n\n return args.map((item) => {\n if (item === '--save-dev') return '--dev'\n else if (item === '--save') return ''\n else if (item === '--no-package-lock') return '--no-lockfile'\n else if (item === '--global' || item === '-g') return ''\n return item\n })\n },\n version(args: string[]) {\n return args.map((item) => {\n if (['major', 'minor', 'patch'].includes(item)) return `--${item}`\n return item\n })\n },\n rebuild(args: string[]) {\n args[0] = 'add --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 yarn to npm command\n */\nfunction convertToNpm(str: string) {\n return str.replace(/yarn(?: +([^&\\n\\r]*))?/gm, yarnToNPM)\n}\n\n/**\n * Converts npm to yarn command\n */\nfunction convertToYarn(str: string) {\n return str.replace(/npm(?: +([^&\\n\\r]*))?/gm, npmToYarn)\n}\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 convertToNpm(str)\n } else {\n return convertToYarn(str)\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,CAAC,OAAe,EAAA;MACnC,IAAM,IAAI,GAAa,EAAE,CAAA;MACzB,IAAI,SAAS,GAAmB,KAA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,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;;ECjHA;;EAEG;EACH,SAAS,YAAY,CAAC,GAAW,EAAA;MAC/B,OAAO,GAAG,CAAC,OAAO,CAAC,0BAA0B,EAAE,SAAS,CAAC,CAAA;EAC3D,CAAC;EAED;;EAEG;EACH,SAAS,aAAa,CAAC,GAAW,EAAA;MAChC,OAAO,GAAG,CAAC,OAAO,CAAC,yBAAyB,EAAE,SAAS,CAAC,CAAA;EAC1D,CAAC;EAED;;EAEG;EACW,SAAU,OAAO,CAAC,GAAW,EAAE,EAAkB,EAAA;MAC7D,IAAI,EAAE,KAAK,KAAK,EAAE;EAChB,QAAA,OAAO,YAAY,CAAC,GAAG,CAAC,CAAA;EACzB,KAAA;EAAM,SAAA;EACL,QAAA,OAAO,aAAa,CAAC,GAAG,CAAC,CAAA;EAC1B,KAAA;EACH;;;;;;;;"} \ No newline at end of file diff --git a/src/npmToYarn.ts b/src/npmToYarn.ts index cd287e6..fe1319e 100644 --- a/src/npmToYarn.ts +++ b/src/npmToYarn.ts @@ -13,16 +13,17 @@ const npmToYarnTable = { } return args.map((item) => { - if (item === '--save-dev') return '--dev' - else if (item === '--save') return '' + if (item === '--save-dev' || item === '-D') return '--dev' + else if (item === '--save' || item === '-S') return '' else if (item === '--no-package-lock') return '--no-lockfile' else if (item === '--save-optional') return '--optional' - else if (item === '--save-exact') return '--exact' + else if (item === '--save-exact' || item === '-E') return '--exact' else if (item === '--global' || item === '-g') return '' return item }) }, i(args: string[]) { + args[0] = 'install' return npmToYarnTable.install(args) }, uninstall(args: string[]) { diff --git a/src/yarnToNpm.ts b/src/yarnToNpm.ts index e0f93fd..8fc9789 100644 --- a/src/yarnToNpm.ts +++ b/src/yarnToNpm.ts @@ -24,7 +24,7 @@ const yarnToNpmTable = { return ['rebuild'] } args[0] = 'install' - if (!args.includes('--dev')) { + if (!args.includes('--dev') && !args.includes('--exact') && !args.includes('--optional')) { args.push('--save') } return convertAddRemoveArgs(args) diff --git a/test/index.spec.ts b/test/index.spec.ts index 487aad4..07393a7 100644 --- a/test/index.spec.ts +++ b/test/index.spec.ts @@ -48,13 +48,32 @@ describe('NPM to Yarn tests', () => { it('npm install', () => { expect(convert('npm install', 'yarn')).toEqual('yarn install') + expect(convert('npm i', 'yarn')).toEqual('yarn install') + }) + + it('npm install --save', () => { + expect(convert('npm install --save test', 'yarn')).toEqual('yarn add test') + expect(convert('npm install -S test', 'yarn')).toEqual('yarn add test') + expect(convert('npm i --save test', 'yarn')).toEqual('yarn add test') + expect(convert('npm i -S test', 'yarn')).toEqual('yarn add test') }) it('npm install --save-exact', () => { expect(convert('npm install --save-exact', 'yarn')).toEqual('yarn add --exact') + expect(convert('npm install -E', 'yarn')).toEqual('yarn add --exact') + expect(convert('npm i --save-exact', 'yarn')).toEqual('yarn add --exact') + expect(convert('npm i -E', 'yarn')).toEqual('yarn add --exact') }) it('npm install --save-optional', () => { expect(convert('npm install --save-optional', 'yarn')).toEqual('yarn add --optional') + expect(convert('npm i --save-optional', 'yarn')).toEqual('yarn add --optional') + expect(convert('npm i --save-optional test', 'yarn')).toEqual('yarn add --optional test') + }) + it('npm install --save-dev', () => { + expect(convert('npm install --save-dev', 'yarn')).toEqual('yarn add --dev') + expect(convert('npm install -D', 'yarn')).toEqual('yarn add --dev') + expect(convert('npm i --save-dev', 'yarn')).toEqual('yarn add --dev') + expect(convert('npm i -D', 'yarn')).toEqual('yarn add --dev') }) it('npm rebuild', () => { @@ -145,10 +164,10 @@ describe('Yarn to NPM tests', () => { 'npm install squirrelly --no-package-lock --save' ) expect(convert('yarn add squirrelly --optional', 'npm')).toEqual( - 'npm install squirrelly --save-optional --save' + 'npm install squirrelly --save-optional' ) expect(convert('yarn add squirrelly --exact', 'npm')).toEqual( - 'npm install squirrelly --save-exact --save' + 'npm install squirrelly --save-exact' ) })