PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Thursday, January 20, 2022

[FIXED] Composer still includes .git directory with --prefer-dist

 January 20, 2022     composer-php     No comments   

Issue

I added mypackage to the repositories key in composer.json:

"repositories": {
    "packagist": {
        "type": "composer",
        "url": "https://packages.drupal.org/8"
    },
    "mypackage": {
        "type": "package",
        "package": {
            "name": "company_name/mypackage",
            "type": "drupal-module",
            "version": "dev-master",
            "source": {
                "type": "git",
                "url": "https://github.com/company_name/mypackage",
                "reference": "master"
            }
        }
    }
},

I run composer require company_name/mypackage-master --prefer-dist

The package does get downloaded but it still adds the .git directory. I would like the package to download without the .git directory. How would I accomplish this? I only have a master branch and no releases in github.


Solution

Posted issue in composer issues here. To fix the issue I did the following:

  1. Add composer.json file to my package:

    {"name": "company_name/mymodule",
    "type": "drupal-custom-module",
    "description": "My description",
    "keywords": ["Drupal"],
    "license": "GPL-2.0+",
    "homepage": "https://github.com/company_name/mymodule",
    "support": {
      "issues": "https://github.com/company_name/mymodule/issues",
      "source": "https://github.com/company_name/mymodule"
    },
    "require": { }}
    
  2. Update repositories to in composer.json file (not the module composer.json file)

      "repositories": {
      "drupal-packagist": {
          "type": "composer",
          "url": "https://packages.drupal.org/8"
      },
      "my-package": {
          "type": "vcs",
          "url": "https://github.com/company_name/mypackage"
      }},
    
  3. Run composer require company_name/mymodule --prefer-dist.



Answered By - albertski
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing