Giter VIP home page Giter VIP logo

grunt-bower-release's Introduction

#grunt-bower-release Build Status Dependency Status devDependency Status Coverage Status ####Push tagged Bower package releases to endpoint

##Installation

Install npm package:

npm install grunt-bower-release --save-dev

Add the following to your project's Gruntfile in order to load the task:

grunt.loadNpmTasks('grunt-bower-release');

##Usage

This task is intended primarily for packages which are targeted at both CommonJS ecosystems such as Node.js, as well as web browsers. As such, it is expected that a package.json is available in the source tree, and that we are releasing built assets intended for the browser. This is as opposed to maintaining a separate repository for this process.

In order to make use of this package, several things must be specified:

  1. The files/folders to be added to the tagged release. These should be present in bower.json, as well.
  2. The git endpoint to which the tagged release shall be sent.
  3. The name of the tagged release.
  4. The bower package name (will override setting in bower.json)

As such, a Gruntfile may contain the following:

bowerRelease: {
  options: {
    main: 'library.min.js',
    dependencies: {
      'jquery': '~2.0.3'
    }
  },
  stable: {
    options: {
      endpoint: 'git://github.com/someone/some-package-bower-stable.git',
      packageName: 'some-package-stable.js',
      stageDir: 'staging-stable/'
    },
    files: [
      {
        expand: true,
        cwd: 'build/stable/',
        src: ['library.js', 'library.min.js', 'css/**/*.css'],
      }
    ]
  },
  devel: {
    options: {
      endpoint: 'git://github.com/someone/some-package-bower-devel.git',
      packageName: 'some-package-devel.js',
      stageDir: 'staging-devel/'
    },
    files: [
      {
        expand: true,
        cwd: 'build/devel/',
        src: ['library.js', 'library.min.js', 'css/**/*.css'],
      }
    ]
  }
}

This will enable the publishing of two builds: stable, and devel, via bowerRelease:stable and bowerRelease:devel, respectively. In both cases, bowerRelease.options are merged into target.options, which means that for both releases, we specify a main file 'library.min.js', and specify a bower dependency on jquery#~2.0.3. The dependencies will be added to the dependencies in the template bower.json, while the main files will replace those in the template, if any.

It's super simple stuff, and I hope some people might find it useful!

##Options

  1. endpoint -- A bower endpoint. Currently, only git repositories are supported. Please contribute different endpoint types if you need them!
  2. packageName -- The bower package name. This overrides name in bower.json
  3. stageDir -- A staging directory where the repository is built and tagged.
  4. main -- Enables the grunt task to override bower.json's main parameter. This will be ignored if it is not a string or an array.
  5. dependencies -- Enables the grunt task to add dependencies to a build.
  6. extendDependencies -- If true, the dependencies from the source repository will be extended with the grunt options dependencies.
  7. branchName -- (Optional) Specify the branch used for the endpoint.
  8. overwriteTag -- (Optional) If true, a Git tag will be overwritten. The plug-in creates a Git tag in order to specify a package version for Bower. A tag name is derived from the version attribute in bower.json. If you have already released a certain version of a package and attempt to do overwrite that version, the plug-in will fail, because it won't be able to push the same tag twice. The option ensures that a tag is deleted, before it gets pushed again.
  9. removeVersionTags -- (Optional) If true, all Git tags whose name starts with a value of version in bower.json will be removed.
  10. suffixTagWithTimestamp -- (Optional) If true, a Git tag will be suffixed with +[CURRENT_TIMESTAMP], e.g. 1.0.0-SNAPSHOT+849829134829

Files

Files must currently be specified per-task, which is unfortunate and will hopefully be fixed soon.

They may be specified as per the guidelines in Configuring files

Releasing Snapshot Version

In some development environments developers prefer to have a snapshot version, which indicates a work in progress. The plug-in allows releasing snapshot versions. All you have to do is to set removeVersionTags and suffixTagWithTimestamp to true. Those options will ensure that typing bower update will fetch a new version of a snapshot dependency without having to change bower.json or clean bower cache.

##License

The MIT License (MIT)

Copyright (c) 2013 Caitlin Potter and Contributors

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

grunt-bower-release's People

Contributors

caitp avatar kkruit avatar pdehaan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

grunt-bower-release's Issues

Fatal error: Unable to write "src" file (Error code: EISDIR).

When I try using this I get the above error. It is creating a cwd directory and i'm guessing it's trying to create src directory which already exists.

It does create the dist-push directory with the contents of the endpoint just fine.

My bowerRelease config:

  bowerRelease: {
      options: {
        main: 'lib.tmpl.min.js'
      },
      prod: {
        options: {
          endpoint: 'https://some.domain.com:8443/lib.git',
          stageDir: 'dist-push'
        },
        files: {
          cwd: 'dist',
          src: ['lib.js', 'lib.min.js', 'lib.tmpl.min.js', 'templates.js', 'bower.json']
        }
  }

Push fails: put branchName in docs. if branch is undefined don't put it in the git push args.

After running the code was never pushed.

When run with -v I'd get the following:

git push origin  0.3.15
Username for 'https://git.com/repo.git': kkruit
Password for 'https://[email protected]/repo.git': 
error: src refspec undefined does not match any.
error: failed to push some refs to 'https://git.com/repo.git'

Turns out it is actaully calling:

git push origin undefined 0.3.15

Because "branchName" is undefined.

Suggested Resolution:
Docs needs branchName defined as an option.

git.js endpoint needs to not put branchName in args if it's undefined

I'm planning on making a PR which is a simple fix but I would really like to tighten the testing net to include this which means a test for the endpoint is needed.

Tests Fail

I've cloned the repository and just run 'grunt test' unfortunately I've got a message saying:

Warning: 2/24 assertions failed (179ms) Use --force to continue.

Aborted due to warnings.

Interestingly, I can see the same message in Travis CI. So, the problem is persistent and is not related to my local environment.

fatal: Unable to create '/code/robo-ui/stage/.git/index.lock': File exists.

I have the following options in bowerRelease in Gruntfile.js
Not sure how to fix this.

options: {
                    main: '*.{css,js,eot,svg,woff,tff}',
                    endpoint: myRepoEndpoint,
                    branchName: 'master',
                    packageName: 'robo-ui-bower',
                    stageDir: 'stage/'
                },
                files: [
                    {
                        expand: true,
                        cwd: 'dist/compiled/',
                        src: ['**/*']
                    }
                ]

git checkout -B master
Writing /code/robo-ui/stage/bower.json...OK
git add /code/robo-ui/stage/RoboGlyphs.ttf
fatal: Unable to create '/code/robo-ui/stage/.git/index.lock': File exists.

If no other git process is currently running, this probably means a
git process crashed in this repository earlier. Make sure no other git
process is running and remove the file manually to continue.
git add /code/robo-ui/stage/RoboGlyphs.woff
On branch master
Your branch is up-to-date with 'origin/master'.
Changes not staged for commit:
modified: robo-ui.min.css

Overwriting Existing Versions

Often, you might want to overwrite an existing version. For example, you might want to have a pre-release snapshot dependency (e.g. 1.0.0-SNAPSHOT). A snapshot version indicates that it might change over a course of time.

For example, two people - Alice and Bob - are working on a Sprint that will result in releasing version 1.0.0. While writing code though they put a version number of 1.0.0-SNAPSHOT. If Alice finishes her user story first, her 1.0.0-SNAPSHOT goes into a dependency repository. When Bob finishes his story later on, the snapshot version will be updated and will include both Alice's and Bob's code.

Now, the challenge with Bower is that it uses Git tags as versions. If you push a tag 1.0.0-SNAPSHOT, all subsequent pushes of the same tag will fail - and new code will not land in Git.

One way of doing solving the problem is to delete a git tag before pushing it. The problem with this approach though, if you do 'bower update' or 'bower install' it will not know about a newly released dependency, as it has the same tag name.

Fortunately, there is a solution - one can suffix tags with '+[some unique ID]'. That unique ID can be a commit SHA or a timestamp.

In this case, if you have a specific dependency version expression in your bower.json, e.g.

"dependencies": {
  "your-dependency": "1.0.0-SNAPSHOT"
}

It will easily pick a dependency whose Git tag is '1.0.0-SNAPSHOT+2014', see node-semver for a reference. However, there is a minor issue here. If you simply push a new Git tag (e.g. '1.0.0-SNAPSHOT+2014', '1.0.0-SNAPSHOT+2015'), every time you're invoking grunt-bower-release, Bower will not pick it.

However, there is still a workaround for that - grunt-bower-release can list all tags and delete the tags which correspond to the current version before pushing a new tag. In this case, 'bower update/install' will successfully pick an overwritten dependency without having to clean its cache.

I have verified that behaviour experimentally, however, I am still yet to submit a pull request with the described functionality.

Task is Successful even if Git is Unavailable

This seems to be a bug that can mislead users, because they will think that a release has been successful, while no code has been pushed to Git.

Steps to reproduce

  1. Add an intentionally wrong Git endpoint to Gruntfile.js
  2. Run grunt bowerInstall

Expected Behaviour

  1. The bower task must fail
  2. It must notify that the Git endpoint is not available

Actual Behaviour

  1. The task succeeds
  2. It says Done, without errors.

Additional Information

You can clearly see that the released has failed if you run grunt bowerRelease --v which say something like:

fatal: Not a git repository (or any of the parent directories): .git

Done, without errors.

Solution

Unless there is already a patch for that, I'm going to submit a pull request shortly.

Don't extend bower dependencies from source repository

I just realized that the source repository's bower dependencies may be totally unrelated to release dependencies, IE they may likely contain components for a documentation app. This is certainly the case for my angular-drop project, so this needs to be done differently.

I think it should be okay to say "extendDependencies: true" in order to use the current behaviour, but by default it should really not do this. I suppose it's a breaking change, but there are so few users of this package it doesn't really matter!

Test suite for endpoints

After the last change I made, I'm not terribly confident in how this will work! test suite asap!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.