aegir
JavaScript project management
Last updated a month ago by hugomrdias .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install aegir 
SYNC missed versions from official npm registry.

AEgir

Travis CI Dependency Status

Automated JavaScript project management.

Lead Maintainer

Hugo Dias

Project Structure

The project structure when using this is quite strict, to ease replication and configuration overhead.

All source code should be placed under src, with the main entry point being src/index.js.

All test files should be placed under test. Individual test files should end in .spec.js and setup files for the node and the browser should be test/node.js and test/browser.js respectively.

Your package.json should have the following entries and should pass aegir lint-package-json.

"main": "src/index.js",
"files": [
  "src",
  "dist"
],
"scripts": {
  "lint": "aegir lint",
  "release": "aegir release",
  "build": "aegir build",
  "test": "aegir test",
  "test:node": "aegir test --target node",
  "test:browser": "aegir test --target browser"
}

Travis Setup

Check this tutorial https://github.com/ipfs/aegir/wiki/Travis-Setup

Stack Requirements

To bring you its many benefits, aegir requires

Testing helpers

In addition to running the tests aegir also provides several helpers to be used by the tests.

Fixtures

Loading fixture files in node and the browser can be painful, that's why aegir provides a method to do this. For it to work you have to put your fixtures in the folder test/fixtures, and then

// test/awesome.spec.js
const loadFixture = require('aegir/fixtures')

const myFixture = loadFixture('test/fixtures/largefixture')

The path to the fixture is relative to the module root.

If you write a module like interface-ipfs-core which is to be consumed by other modules tests you need to pass in a third parameter such that the server is able to serve the correct files.

For example

// awesome-tests module
const loadFixture = require('aegir/fixtures')

const myFixture = loadFixture('test/fixtures/coolfixture', 'awesome-tests')
// tests for module using the awesome-tests
require('awesome-tests')
// .aegir.js file in the module using the awesome-tests module
'use strict'

module.exports = {
  karma: {
    files: [{
      pattern: 'node_modules/awesome-tests/test/fixtures/**/*',
      watched: false,
      served: true,
      included: false
    }]
  }
}

Echo Server

HTTP echo server for testing purposes.

const EchoServer = require('aegir/utils/echo-server')
const server = new EchoServer()
await server.start()

// search params echo endpoint
const req = await fetch('http://127.0.0.1:3000/echo/query?test=one')
console.log(await req.text())

// body echo endpoint
const req = await fetch('http://127.0.0.1:3000/echo', {
  method: 'POST',
  body: '{"key": "value"}'
})
console.log(await req.text())

// redirect endpoint
const req = await fetch('http://127.0.0.1:3000/redirect?to=http://127.0.0.1:3000/echo')
console.log(await req.text())

// download endpoint
const req = await fetch('http://127.0.0.1:3000/download?data=helloWorld')
console.log(await req.text())

await server.stop()

Get Port

Helper to find an available port to put a server listening on.

const getPort = require('aegir/utils/get-port')
const port = await getPort(3000, '127.0.0.1')
// if 3000 is available returns 3000 if not returns a free port.

Tasks

Linting

Linting uses eslint and standard with some custom rules to enforce some more strictness.

You can run it using

$ aegir lint
$ aegir lint-package-json

Testing

You can run it using

$ aegir test

There are also browser and node specific tasks

$ aegir test --target node
$ aegir test --target browser
$ aegir test --target webworker

Coverage

Node

You can run your tests with nyc using

$ npx nyc -s aegir test -t node
# to check the report locally 
$ npx nyc report --reporter=html && open coverage/index.html
# or just for a text based reporter
$ npx nyc report

Browser

Not available yet PR open.

To auto publish coverage reports from Travis to Codecov add this to your .travis.yml file.

after_success: npx nyc report --reporter=text-lcov > coverage.lcov && npx codecov

Building

You can run it using

$ aegir build

This will build a browser ready version into dist, so after publishing the results will be available under

https://unpkg.com/<module-name>/dist/index.js
https://unpkg.com/<module-name>/dist/index.min.js

Specifying a custom entry file for Webpack

By default, aegir uses src/index.js as the entry file for Webpack. You can customize which file to use as the entry point by specifying entry field in your user configuration file. To do this, create .aegir.js file in your project's root diretory and add point the entry field to the file Webpack should use as the entry:

module.exports = {
  entry: "src/browser-index.js",
}

Webpack will use the specified file as the entry point and output it to dist/<filename>, eg. dist/browser-index.js.

If .aegir.js file is not present in the project, webpack will use src/index.js as the default entry file.

Generating Webpack stats.json

Pass the --analyze option to have Webpack generate a stats.json file for the bundle and save it in the project root (see https://webpack.js.org/api/stats/). e.g.

aegir build --analyze

Releasing

  1. Run linting
  2. Run tests
  3. Build everything
  4. Bump the version in package.json
  5. Generate a changelog based on the git log
  6. Commit the version change & CHANGELOG.md
  7. Create a git tag
  8. Run git push to origin/master
  9. Publish a release to Github releases
  10. Generate documentation and push to github
  11. Publish to npm
# Major release
$ aegir release --type major
# Minor relase
$ aegir release --type minor
# Patch release
$ aegir release

# Major prerelease (1.0.0 -> 2.0.0-rc.0)
$ aegir release --type premajor --preid rc --dist-tag next
# Minor prerelease (1.0.0 -> 1.1.0-rc.0)
$ aegir release --type preminor --preid rc --dist-tag next
# Patch prerelease (1.0.0 -> 1.0.1-rc.0)
$ aegir release --type prepatch --preid rc --dist-tag next

# Increment prerelease (1.1.0-rc.0 -> 1.1.0-rc.1)
$ aegir release --type prerelease --preid rc --dist-tag next

This requires AEGIR_GHTOKEN to be set.

You can also specify the same targets as for test.

If no CHANGELOG.md is present, one is generated the first time a release is done.

You can skip all changelog generation and the github release by passing in --no-changelog.

If you want no documentation generation you can pass --no-docs to the release task to disable documentation builds.

Scoped Github Token

Performing a release involves creating new commits and tags and then pushing them back to the repository you are releasing from. In order to do this you should create a GitHub personal access token and store it in the environmental variable AEGIR_GHTOKEN.

The only access scope it needs is public_repo.

Be aware that by storing it in ~/.profile or similar you will make it available to any program that runs on your computer.

Documentation

You can use aegir docs to generate documentation. This uses documentation.js with the theme clean-documentation-theme.

To publish the documentation automatically to the gh-pages branch you can run

$ aegir docs --publish

License

MIT

Current Tags

  • 22.0.0                                ...           latest (a month ago)

129 Versions

  • 22.0.0                                ...           a month ago
  • 21.10.2                                ...           a month ago
  • 21.10.1                                ...           a month ago
  • 21.10.0 [deprecated]           ...           a month ago
  • 21.9.2 [deprecated]           ...           a month ago
  • 21.9.1 [deprecated]           ...           a month ago
  • 21.9.0 [deprecated]           ...           2 months ago
  • 21.8.1 [deprecated]           ...           2 months ago
  • 21.8.0 [deprecated]           ...           2 months ago
  • 21.7.0 [deprecated]           ...           2 months ago
  • 21.6.0                                ...           2 months ago
  • 21.5.1                                ...           2 months ago
  • 21.5.0                                ...           2 months ago
  • 21.4.5                                ...           2 months ago
  • 21.4.4                                ...           2 months ago
  • 21.4.3                                ...           3 months ago
  • 21.4.2                                ...           3 months ago
  • 21.4.1                                ...           3 months ago
  • 21.4.0                                ...           3 months ago
  • 21.3.3                                ...           3 months ago
  • 21.3.2                                ...           3 months ago
  • 21.3.0                                ...           4 months ago
  • 21.2.0                                ...           4 months ago
  • 21.1.0                                ...           4 months ago
  • 21.0.2                                ...           4 months ago
  • 21.0.1                                ...           4 months ago
  • 21.0.0                                ...           4 months ago
  • 20.6.1                                ...           4 months ago
  • 20.6.0                                ...           4 months ago
  • 20.5.1                                ...           5 months ago
  • 20.5.0                                ...           6 months ago
  • 20.4.1                                ...           8 months ago
  • 20.4.0                                ...           8 months ago
  • 20.3.2                                ...           8 months ago
  • 20.3.1                                ...           9 months ago
  • 20.3.0                                ...           9 months ago
  • 20.2.0                                ...           9 months ago
  • 20.1.0                                ...           9 months ago
  • 20.0.0                                ...           a year ago
  • 19.0.5                                ...           a year ago
  • 19.0.4                                ...           a year ago
  • 19.0.3                                ...           a year ago
  • 19.0.0                                ...           a year ago
  • 18.2.2                                ...           a year ago
  • 18.2.1                                ...           a year ago
  • 18.2.0                                ...           a year ago
  • 18.1.1                                ...           a year ago
  • 18.1.0                                ...           a year ago
  • 18.0.3                                ...           a year ago
  • 18.0.2                                ...           a year ago
  • 18.0.1                                ...           a year ago
  • 18.0.0                                ...           a year ago
  • 17.1.1                                ...           2 years ago
  • 17.1.0                                ...           2 years ago
  • 17.0.1                                ...           2 years ago
  • 17.0.0                                ...           2 years ago
  • 15.3.1                                ...           2 years ago
  • 15.3.0                                ...           2 years ago
  • 15.2.0                                ...           2 years ago
  • 15.1.0                                ...           2 years ago
  • 15.0.1                                ...           2 years ago
  • 15.0.0                                ...           2 years ago
  • 14.0.0                                ...           2 years ago
  • 13.1.0                                ...           2 years ago
  • 13.0.7                                ...           2 years ago
  • 13.0.6                                ...           2 years ago
  • 13.0.5                                ...           2 years ago
  • 13.0.1                                ...           2 years ago
  • 13.0.0                                ...           2 years ago
  • 12.4.0                                ...           2 years ago
  • 12.3.0                                ...           2 years ago
  • 12.2.0                                ...           3 years ago
  • 12.1.3                                ...           3 years ago
  • 12.1.2                                ...           3 years ago
  • 12.1.1                                ...           3 years ago
  • 12.1.0                                ...           3 years ago
  • 12.0.8                                ...           3 years ago
  • 12.0.6                                ...           3 years ago
  • 12.0.5                                ...           3 years ago
  • 12.0.4                                ...           3 years ago
  • 12.0.3                                ...           3 years ago
  • 12.0.2                                ...           3 years ago
  • 12.0.1                                ...           3 years ago
  • 12.0.0                                ...           3 years ago
  • 11.0.2                                ...           3 years ago
  • 11.0.1                                ...           3 years ago
  • 11.0.0                                ...           3 years ago
  • 10.0.0                                ...           3 years ago
  • 9.4.0                                ...           3 years ago
  • 9.3.3                                ...           3 years ago
  • 9.3.2                                ...           3 years ago
  • 9.3.1                                ...           3 years ago
  • 9.3.0                                ...           3 years ago
  • 9.2.2                                ...           3 years ago
  • 9.2.1                                ...           3 years ago
  • 9.2.0                                ...           3 years ago
  • 9.1.2                                ...           4 years ago
  • 9.1.1                                ...           4 years ago
  • 9.1.0                                ...           4 years ago
  • 9.0.1                                ...           4 years ago
  • 9.0.0                                ...           4 years ago
  • 8.1.2                                ...           4 years ago
  • 8.1.1                                ...           4 years ago
  • 8.1.0                                ...           4 years ago
  • 8.0.1                                ...           4 years ago
  • 8.0.0                                ...           4 years ago
  • 7.0.1                                ...           4 years ago
  • 7.0.0                                ...           4 years ago
  • 6.0.1                                ...           4 years ago
  • 6.0.0                                ...           4 years ago
  • 5.0.1                                ...           4 years ago
  • 5.0.0                                ...           4 years ago
  • 4.0.0                                ...           4 years ago
  • 3.2.0                                ...           4 years ago
  • 3.1.1                                ...           4 years ago
  • 3.1.0                                ...           4 years ago
  • 3.0.5                                ...           4 years ago
  • 3.0.4                                ...           4 years ago
  • 3.0.3                                ...           4 years ago
  • 3.0.2                                ...           4 years ago
  • 3.0.1                                ...           4 years ago
  • 3.0.0                                ...           4 years ago
  • 2.1.2                                ...           4 years ago
  • 2.1.1                                ...           4 years ago
  • 2.1.0                                ...           4 years ago
  • 2.0.3                                ...           4 years ago
  • 2.0.2                                ...           4 years ago
  • 2.0.1                                ...           4 years ago
  • 2.0.0                                ...           4 years ago
Downloads
Today 2
This Week 13
This Month 13
Last Day 0
Last Week 9
Last Month 683
Dependencies (87)
Dev Dependencies (4)

Copyright 2014 - 2017 © taobao.org |