Share resources across projects. Redeploy bower fetched packages to any another location in your project structure.
Perl
Switch branches/tags
Nothing to show
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
README.md
bower-redeployer.json
bower-redeployer.pl

README.md

Introduction

Using the bower package manager, this script redeploys bower fetched packages to any another location in your project structure. This is particularly necessary, for instance, when dealing with a framework which requires files to reside in certain locations as opposed to the standard bower/components directory. Whether you need to share a common library, style sheet or documentation, you can edit the json file and get started. The other problem this script tries to address is the current inability for bower to keep track of local repos in its component.json

Step 1)


Clone the repo

Step 2)


edit bower-redeployer.json

{
  "bower_root": "/var/www/myproject",
  "packages" : [	
	{
		"name": "mypackage",
		"repo_path": "/home/mr/git/mypackage.git",
		"deploy_rel_path": ""
	},
	{
		"name": "mypackage2",
		"repo_path": "/home/mr/git/mypackage2.git",
		"deploy_rel_path": "application/controllers"
	}
  ]
}
  • bower_root: the root directory where you setup bower, usually this is the root location of your project
  • packages: an array of package definitions
  • packages\name: name of the package
  • packages\repo_path: path to your repository (note: the repo must have tags for bower to function properly. for instance after a commit you should tag it with git tag -a 1.0.0 -m "v1.0.0")
  • packages\deploy_rel_path: this is the deploy path relative to your bower_root. Therefore, if this is blank what will happen is the content of your repo /home/mr/git/mypackage will be deployed to bower_root /var/www/myproject. You can either copy your project structure in your repository and then set deploy_rel_path to blank or have your git repository only have your files and reflect the relative extract path in deploy_rel_path as application/controllers

Sample Run

----------------------------------------------------
- Select Action:
----------------------------------------------------
        1. Refresh & Deploy All Packages
        2. Pick Package
        3. -- Quit --
> 2
----------------------------------------------------
- Available Packages:
----------------------------------------------------
        1. << Back
        2. -- Quit --
        3. -----------------------------------------
        4. mypackage
        5. mypackage2
> 4
----------------------------------------------------
- Refreshing package: fonts
----------------------------------------------------
bower cloning /home/mr/git/mypackage.git
bower cached /home/mr/git/mypackage.git
bower fetching mypackage
bower checking out mypackage#1.0.0
bower installing mypackage#1.0.0
>> 7z a -tzip package.zip * -r
7-Zip [64] 9.20  Copyright (c) 1999-2010 Igor Pavlov  2010-11-18
Scanning
Creating archive package.zip
Compressing  component.json
Compressing  application\controllers\mycontroller.php

Everything is Ok
>> 7z d package.zip component.json
7-Zip [64] 9.20  Copyright (c) 1999-2010 Igor Pavlov  2010-11-18
Updating archive package.zip

Everything is Ok
>> 7z x package.zip -o/var/www/myproject/ * -r -aoa
7-Zip [64] 9.20  Copyright (c) 1999-2010 Igor Pavlov  2010-11-18

Processing archive: package.zip
Extracting  application
Extracting  application\controllers
Extracting  application\controllers\mycontroller.php

Everything is Ok

Folders: 2
Files: 1
Size:       67936
Compressed: 40021

----------------------------------------------------
- Select Action:
----------------------------------------------------
        1. Refresh & Deploy All Packages
        2. Pick Package
        3. -- Quit --
>

Command Line

usage: program [--j|json path to json file] [--r|run package_name]  [--help|-?]

        --j|json        Optional path to json file. (perl -j /home/user/config.json)
                        If not specified it will look for bower-deployer.json in current directory.

        --r|run         Array of package names. (perl -r pkg_one -r pkg_two)
                        The names must match with the ones from the json file.

        --h|help        Display help menu

Dependencies

Limitations

  • Currently it seems bower does not support local git repo in the component.json. Unfortunatey this is quite an issue as it means you can't stick to the convention of relying solely on the component.json to track dependencies the way you are use to. So in the meantime we can use this script and write out our own version tracking file.