Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
2fc17b4
License and contribution agreement
sam-github May 21, 2014
b6e34c2
Add package.json and slb stub
sam-github May 21, 2014
f65da5d
Add tap test script
sam-github May 21, 2014
45468e0
Implement npm install without build scripts
sam-github May 21, 2014
dfa9fda
Implement usage and version options
sam-github May 22, 2014
5ea2f53
Implement running of custom package build script
sam-github May 22, 2014
ed8a7df
Use option parser, and test option parsing
sam-github May 22, 2014
b64f480
Refactor build test setup so it can be reused
sam-github May 22, 2014
36f190c
Implement --scripts, to build binary addons
sam-github May 22, 2014
8211314
Implement --pack, to create an archive
sam-github May 22, 2014
a3f4fca
Implement --bundle, so dependencies are packed
sam-github May 23, 2014
8123af7
test: use strong-cli as a dev dependency
sam-github May 23, 2014
e7afc8e
pack: place archive in parent directory
sam-github May 23, 2014
0c93daa
doc: add README.md and update --help output
sam-github May 23, 2014
0530f3e
onto: commit source tree onto a deploy branch
sam-github May 26, 2014
a0ab12c
bundle: warn on problematic or incomplete config
sam-github May 27, 2014
2b9b56f
bundle: bundle only dependencies and optional deps
sam-github May 28, 2014
5ee4342
commit: commit build products into git
sam-github May 28, 2014
1e06a37
git: remove unused $0 argument to git.onto()
sam-github May 28, 2014
31ca4cb
bundle,pack: log the actions taken
sam-github May 28, 2014
0315419
fixup! TODO (will rebase away before when complete)
sam-github May 22, 2014
5a1928e
readme: update with latest usage
sam-github May 28, 2014
8209351
log: ensure each action logs on complete
sam-github May 28, 2014
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
node_modules
npm-debug.log
sls-sample-app-2.0.3.tgz
_suite
_onto
187 changes: 187 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,187 @@
### Contributing ###

Thank you for your interest in strong-build, an open source project
administered by StrongLoop.

Contributing to strong-build is easy. In a few simple steps:

* Ensure that your effort is aligned with the project's roadmap by
talking to the maintainers, especially if you are going to spend a
lot of time on it.

* Make something better or fix a bug.

* Adhere to code style outlined in the [Google C++ Style Guide][] and
[Google Javascript Style Guide][].

* [Sign your patches](#signing-patches) to indicate that your are
making your contribution available under the terms of the
[Contributor License Agreement](#contributor-license-agreement).

* Submit a pull request through Github.


### Signing patches ###

Like many open source projects, we need a contributor license agreement
from you before we can merge in your changes.

In summary, by submitting your code, you are granting us a right to use
that code under the terms of this Agreement, including providing it to
others. You are also certifying that you wrote it, and that you are
allowed to license it to us. You are not giving up your copyright in
your work. The license does not change your rights to use your own
contributions for any other purpose.

Contributor License Agreements are important because they define the
chain of ownership of a piece of software. Some companies won't allow
the use of free software without clear agreements around code ownership.
That's why many open source projects collect similar agreements from
contributors. The CLA here is based on the Apache CLA.

To signify your agreement to these terms, add the following line to the
bottom of your commit message. Use your real name and an actual e-mail
address.

```
Signed-off-by: Random J Developer <random@developer.example.org>
```

Alternatively you can use the git command line to automatically add this
line, as follows:

```
$ git commit -sm "Replace rainbows by unicorns"
```


### Contributor License Agreement ###

```
Individual Contributor License Agreement

By signing this Individual Contributor License Agreement
("Agreement"), and making a Contribution (as defined below) to
StrongLoop, Inc. ("StrongLoop"), You (as defined below) accept and
agree to the following terms and conditions for Your present and
future Contributions submitted to StrongLoop. Except for the license
granted in this Agreement to StrongLoop and recipients of software
distributed by StrongLoop, You reserve all right, title, and interest
in and to Your Contributions.

1. Definitions

"You" or "Your" shall mean the copyright owner or the individual
authorized by the copyright owner that is entering into this
Agreement with StrongLoop.

"Contribution" shall mean any original work of authorship,
including any modifications or additions to an existing work, that
is intentionally submitted by You to StrongLoop for inclusion in,
or documentation of, any of the products owned or managed by
StrongLoop ("Work"). For purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication
sent to StrongLoop or its representatives, including but not
limited to communication or electronic mailing lists, source code
control systems, and issue tracking systems that are managed by,
or on behalf of, StrongLoop for the purpose of discussing and
improving the Work, but excluding communication that is
conspicuously marked or otherwise designated in writing by You as
"Not a Contribution."

2. You Grant a Copyright License to StrongLoop

Subject to the terms and conditions of this Agreement, You hereby
grant to StrongLoop and recipients of software distributed by
StrongLoop, a perpetual, worldwide, non-exclusive, no-charge,
royalty-free, irrevocable copyright license to reproduce, prepare
derivative works of, publicly display, publicly perform,
sublicense, and distribute Your Contributions and such derivative
works under any license and without any restrictions.

3. You Grant a Patent License to StrongLoop

Subject to the terms and conditions of this Agreement, You hereby
grant to StrongLoop and to recipients of software distributed by
StrongLoop a perpetual, worldwide, non-exclusive, no-charge,
royalty-free, irrevocable (except as stated in this Section)
patent license to make, have made, use, offer to sell, sell,
import, and otherwise transfer the Work under any license and
without any restrictions. The patent license You grant to
StrongLoop under this Section applies only to those patent claims
licensable by You that are necessarily infringed by Your
Contributions(s) alone or by combination of Your Contributions(s)
with the Work to which such Contribution(s) was submitted. If any
entity institutes a patent litigation against You or any other
entity (including a cross-claim or counterclaim in a lawsuit)
alleging that Your Contribution, or the Work to which You have
contributed, constitutes direct or contributory patent
infringement, any patent licenses granted to that entity under
this Agreement for that Contribution or Work shall terminate as
of the date such litigation is filed.

4. You Have the Right to Grant Licenses to StrongLoop

You represent that You are legally entitled to grant the licenses
in this Agreement.

If Your employer(s) has rights to intellectual property that You
create, You represent that You have received permission to make
the Contributions on behalf of that employer, that Your employer
has waived such rights for Your Contributions, or that Your
employer has executed a separate Corporate Contributor License
Agreement with StrongLoop.

5. The Contributions Are Your Original Work

You represent that each of Your Contributions are Your original
works of authorship (see Section 8 (Submissions on Behalf of
Others) for submission on behalf of others). You represent that to
Your knowledge, no other person claims, or has the right to claim,
any right in any intellectual property right related to Your
Contributions.

You also represent that You are not legally obligated, whether by
entering into an agreement or otherwise, in any way that conflicts
with the terms of this Agreement.

You represent that Your Contribution submissions include complete
details of any third-party license or other restriction (including,
but not limited to, related patents and trademarks) of which You
are personally aware and which are associated with any part of
Your Contributions.

6. You Don't Have an Obligation to Provide Support for Your Contributions

You are not expected to provide support for Your Contributions,
except to the extent You desire to provide support. You may provide
support for free, for a fee, or not at all.

6. No Warranties or Conditions

StrongLoop acknowledges that unless required by applicable law or
agreed to in writing, You provide Your Contributions on an "AS IS"
BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER
EXPRESS OR IMPLIED, INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES
OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY, OR
FITNESS FOR A PARTICULAR PURPOSE.

7. Submission on Behalf of Others

If You wish to submit work that is not Your original creation, You
may submit it to StrongLoop separately from any Contribution,
identifying the complete details of its source and of any license
or other restriction (including, but not limited to, related
patents, trademarks, and license agreements) of which You are
personally aware, and conspicuously marking the work as
"Submitted on Behalf of a Third-Party: [named here]".

8. Agree to Notify of Change of Circumstances

You agree to notify StrongLoop of any facts or circumstances of
which You become aware that would make these representations
inaccurate in any respect. Email us at callback@strongloop.com.
```

[Google C++ Style Guide]: https://google-styleguide.googlecode.com/svn/trunk/cppguide.xml
[Google Javascript Style Guide]: https://google-styleguide.googlecode.com/svn/trunk/javascriptguide.xml
7 changes: 7 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
strong-build uses a dual license model.

You may use this library under the terms of the [Artistic 2.0 license][],
or under the terms of the [StrongLoop Subscription Agreement][].

[Artistic 2.0 license]: http://opensource.org/licenses/Artistic-2.0
[StrongLoop Subscription Agreement]: http://strongloop.com/license
45 changes: 45 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# strong-build

usage: `slb [options]`

Build a node application package.

With no options, the default is to install, bundle, and pack.

When using git, the current branch can be committed onto a deployment
branch before the build. This allows the build products to be
committed and synchronized with a source-only branch. Afterwards, the
deployment branch will be checked-out, ready for build and commit.

Packages are built without running scripts (by default, see --scripts)
to avoid compiling any binary addons. Compilation and install scripts
should be run on the deployment server using:

npm rebuild
npm install

Custom build steps, such as `grunt build`, can be specified as a
'build' script in the package.json's `scripts` property and will
be run after installing dependencies.

Bundling configures the package.json and .npmignore so deployment (not
development) dependencies as well as any 'build' script output will
not be ignored by `npm pack`. If an .npmignore is created, check it
carefully to ensure build products are packed, but editor and test
ephemera are not.

Pack output is a tar file in the format produced by `npm pack` and
accepted by `npm install`.

Committing the build output allows it to be pushed to a PaaS, or
tracked in git. It is committed to current branch (but see `--onto`).

Options:
* -h,--help Print this message and exit.
* -v,--version Print version and exit.
* -onto BRANCH Merge git HEAD to deployment BRANCH.
* -i,--install Install dependencies (without scripts, by default).
* --scripts If installing, run scripts (to build addons).
* -b,--bundle Modify package to bundle deployment dependencies.
* -p,--pack Pack into a publishable archive (with dependencies).
* -c,--commit Commit build output to current branch.
105 changes: 105 additions & 0 deletions TODO.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
Options:

X append git build to another branch
X build and package node binaries, or not
- (do later, could be useful for testing) bundle dev dependencies, or not
- `-v,--verbose`, to print all commands and their output to stdout

https://github.com/davepacheco/node-vasync

# GIT

X merge current branch onto a destination branch before building it

- (later?) TBD support a --from option to merge from other than current branch, or else
a current state that is NOT a branch (like `git co v2.0.2`, a detached head)

- (later?) TBD Might need to give a commit message or template for the new commit

X commit build products

$ git add --force --all . && git commit

- remove $0 from lib/git.js

Build:

X npm install --ignore-scripts (don't ignore scripts if --binary is requested)
- (no, we don't know the target to run) ... run grunt?
- (could run bower, do later, use build script for now) ... run bower?
X ... npm run build (sl specific) ... maybe make people put "grunt" in as
the build script? maybe just run it if its there? note: don't have
to check return of npm run build, it suceeds if no such script...

https://www.npmjs.org/doc/misc/npm-scripts.html

can't use prepublish... because it will be run later on deploy server
during `npm install` :-(

Package:

X git add --force --all . && git commit

- TBD git archive HEAD --prefix=package -o out.tar.gz/out.tar (autodetects format)

Script the archive, but ensure that the tarballs have same format as
npm packed tarballs.

Don't do, since we aren't building a development-branch:

- .gitignore update: npm rebuild; git status|grep new >> .gitignore
- git ci --amend .gitignore

Problem with npm rebuild... loopback oracle :-( It downloads at run-time,
so demonstrates that a sufficiently weird npm package might still require
network access:

```
sam@samtu:~/w/sn/sls-sample-app (try-build) % npm rebuild

> loopback-oracle-installer@1.2.0 install /home/sam/w/sn/sls-sample-app/node_modules/loopback-connector-oracle/node_modules/loopback-oracle-installer
> node pkginstall.js

Downloading/Extracting http://7e9918db41dd01dbf98e-ec15952f71452bc0809d79c86f5751b6.r22.cf1.rackcdn.com/loopback-oracle-Linux-x64-1.2.0.tar.gz
```

# non-git

Build:

(as above)

Package:

X create an empty .npmignore if one doesn't exist but .gitignore does,
otherwise npm ignores any build products in .gitignore

node_modules is unconditionally ignored, see
https://www.npmjs.org/doc/developers.html. So, we will have to bundle the deps.

X npm dependency bundling

Note an issue with my approach of looking in node_modules... it means that peer
deps of dev dependencies will get packaged... perhaps I should use only the
deps in the package.json (and MAYBE check for existence in node_modules for
optional packages). recall the npm install on build server will attempt to
install any missing optional packages, so having optional packages for a
deployable app that are missing is pretty suspicous, and not likely to do
anything useful.

X don't read node_modules to find deps to bundle, require presence
in package.json

X don't bundle deps if they already have a spec for bundled, otherwise,
bundle all non-dev

X npm pack

X put tarball one directory up, instead of CWD?

- TBD test against a repo with a build script, perhaps grunt or bower

Tried git@github.com:strongloop/loopback-example-full-stack

Doesn't work for now... I can't get the app to work manually, I need a
walk-through.
8 changes: 8 additions & 0 deletions bin/slb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/usr/bin/env node

require('../').build(process.argv, function(er) {
if (!er) {
process.exit(0);
}
process.exit(1);
});
Loading