You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

84 satır
2.8KB

  1. <?php
  2. /*
  3. * This file is part of the Fxp Composer Asset Plugin package.
  4. *
  5. * (c) François Pluchino <francois.pluchino@gmail.com>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Fxp\Composer\AssetPlugin\Converter;
  11. /**
  12. * Converter for NPM package to composer package.
  13. *
  14. * @author François Pluchino <francois.pluchino@gmail.com>
  15. */
  16. class NpmPackageConverter extends AbstractPackageConverter
  17. {
  18. /**
  19. * {@inheritdoc}
  20. */
  21. protected function getMapKeys()
  22. {
  23. $assetType = $this->assetType;
  24. return array(
  25. 'name' => array('name', function ($value) use ($assetType) {
  26. return $assetType->formatComposerName($value);
  27. }),
  28. 'type' => array('type', function () use ($assetType) {
  29. return $assetType->getComposerType();
  30. }),
  31. 'version' => array('version', function ($value) use ($assetType) {
  32. return $assetType->getVersionConverter()->convertVersion($value);
  33. }),
  34. 'version_normalized' => 'version_normalized',
  35. 'description' => 'description',
  36. 'keywords' => 'keywords',
  37. 'homepage' => 'homepage',
  38. 'license' => 'license',
  39. 'author' => array('authors', function ($value) {
  40. return NpmPackageUtil::convertAuthor($value);
  41. }),
  42. 'contributors' => array('authors', function ($value, $prevValue) {
  43. return NpmPackageUtil::convertContributors($value, $prevValue);
  44. }),
  45. 'bin' => array('bin', function ($value) {
  46. return (array) $value;
  47. }),
  48. 'dist' => array('dist', function ($value) {
  49. return NpmPackageUtil::convertDist($value);
  50. }),
  51. );
  52. }
  53. /**
  54. * {@inheritdoc}
  55. */
  56. protected function getMapExtras()
  57. {
  58. return array(
  59. 'bugs' => 'npm-asset-bugs',
  60. 'files' => 'npm-asset-files',
  61. 'main' => 'npm-asset-main',
  62. 'man' => 'npm-asset-man',
  63. 'directories' => 'npm-asset-directories',
  64. 'repository' => 'npm-asset-repository',
  65. 'scripts' => 'npm-asset-scripts',
  66. 'config' => 'npm-asset-config',
  67. 'bundledDependencies' => 'npm-asset-bundled-dependencies',
  68. 'optionalDependencies' => 'npm-asset-optional-dependencies',
  69. 'engines' => 'npm-asset-engines',
  70. 'engineStrict' => 'npm-asset-engine-strict',
  71. 'os' => 'npm-asset-os',
  72. 'cpu' => 'npm-asset-cpu',
  73. 'preferGlobal' => 'npm-asset-prefer-global',
  74. 'private' => 'npm-asset-private',
  75. 'publishConfig' => 'npm-asset-publish-config',
  76. );
  77. }
  78. }