配置Homestead以自动下载编写器包

时间:2016-06-23 05:17:18

标签: node.js bash laravel vagrant homestead

我想为我的项目使用宅基流浪盒,这样每个人都可以流浪起来并开始开发,甚至不需要安装节点,npm,composer,gulp等。 对于节点模块,我运行这样的bash文件,它可以正常工作。

cd project-name
npm install

但我不能对作曲家做同样的事情,因为宅基本身就是作曲家包,我尝试运行作曲家更新我得到这个错误

cannot load such file -- path-to-directory/vendor/laravel/
homestead/scripts/homestead.rb

我不想将node_modules或vender文件夹添加到存储库!我只能和lalavel / homeasted到存储库所以它一直存在但仍然不是首选的解决方案。

我的vagrantfile看起来像这样

require 'json'
require 'yaml'

VAGRANTFILE_API_VERSION ||= "2"
confDir = $confDir ||= File.expand_path("vendor/laravel/homestead",          File.dirname(__FILE__))

homesteadYamlPath = "Homestead.yaml"
homesteadJsonPath = "Homestead.json"
afterScriptPath = "after.sh"
aliasesPath = "aliases"

require File.expand_path(confDir + '/scripts/homestead.rb')

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.provision "install requirements", type: "shell", privileged: false, path: "install.sh", args: "/styleguide"

if File.exists? aliasesPath then
    config.vm.provision "file", source: aliasesPath, destination: "~/.bash_aliases"
end

if File.exists? homesteadYamlPath then
    Homestead.configure(config, YAML::load(File.read(homesteadYamlPath)))
elsif File.exists? homesteadJsonPath then
    Homestead.configure(config, JSON.parse(File.read(homesteadJsonPath)))
end

if File.exists? afterScriptPath then
    config.vm.provision "shell", path: afterScriptPath
end
end

我的start.ssh文件就像这样

cd project-name
composer update
npm install

这是我的Homestead.yaml

---
ip: "192.168.30.30"
memory: 2048
cpus: 1
hostname: kiosk
name: kiosk
provider: virtualbox

authorize: ~/.ssh/id_rsa.pub

keys:
    - ~/.ssh/id_rsa

folders:
    - map: "/Users/alirezaahmadi/sib/php/my-project"
      to: "/home/vagrant/my-project"

sites:
    - map: my-project.dev
      to: "/home/vagrant/my-project/public"

databases:
    - homestead

# blackfire:
#     - id: foo
#       token: bar
#       client-id: foo
#       client-token: bar

# ports:
#     - send: 50000
#       to: 5000
#     - send: 7777
#       to: 777
#       protocol: udp

我首选的方法是只将源代码和vagrantfile添加到存储库,当用户获得带有单个流浪者的项目时,将下载所有作曲家包和node_modules。我怎么能解决这个问题?

0 个答案:

没有答案