abstract-buildspec

1.0.2 • Public • Published

AbstractBuildspec

Helps you create buildspec.yml files that inherit from each other.

Usage

Create a buildspec.js file like this:

const AbstractBuildspec = require('abstract-buildspec');
 
class Buildspec extends AbstractBuildspec {
  static version() {
    return '0.2';
  }
 
  static env() {
    return {
      variables: {
        AAA: 'a',
      },
      'parameter-store': {
        BBB: '/a/b',
        CCC: '/c/d',
      },
    };
  }
 
  static phases() {
    return {
      install: {
        commands: ['echo Installing dependencies...'],
        'runtime-versions': {
          nodejs: '10',
        },
      },
      pre_build: {
        commands: [
          'echo Setting something up...',
        ],
      },
      build: {
        commands: [
          'echo Building files...',
        ],
      },
      post_build: {
        commands: [
          'echo Cleaning up...',
        ],
      },
    };
  }
 
  static cache() {
    return {
      paths: ['folder'],
    };
  }
 
  static artifacts() {
    return {
      files: [
        "'item1'",
        "'item2'",
      ],
      'base-directory': "'.'",
      'discard-paths': 'no',
    };
  }
}

Then you can reuse it to generate a slightly different buildspec like this:

class CustomBuildspec extends Buildspec {
  static phases() {
    const base = super.phases();
    const extraCommands = ['echo Migrating the database...'];
    base.post_build.commands = extraCommands.concat(base.post_build.commands);
    return base;
  }
}

Finally, you can emit the buildspecs to the filesystem by doing:

Buildspec.emit('buildspec.yml');
CustomBuildspec.emit('buildspec-custom.yml');

License

MIT License

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 1.0.2
    11
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 1.0.2
    11
  • 1.0.1
    0
  • 1.0.0
    0

Package Sidebar

Install

npm i abstract-buildspec

Weekly Downloads

11

Version

1.0.2

License

MIT

Unpacked Size

3.36 kB

Total Files

3

Last publish

Collaborators

  • igliu