Skip to content

Commit

Permalink
1.0.0
Browse files Browse the repository at this point in the history
- fixes pipeline to find times recursively
  - cleans up duplicate code
- handles if git is not present
- removes the dependency on having a package.json to get name and description
- removes the qs module uses native querystring
- cleans up stages markup to have the title inlined
- adds report tab to show report in JSON
- adds times to all pipeline nodes
  - the end now shows a cumulative time
- fixes bug if output is not defined in config
- config is now the pipeline parsed
- adds an output flag to the CLI that sets the output of the report
- adds an browser flag to CLI that allows setting browser to be configured to be open or not
- abstracts execution logic from binary and tests it separately
- cleans up and rearranges UI
- adds story to storybook stories to reflect a full report view
- removes babel-minify-webpack-plugin
  • Loading branch information
gabrielcsapo committed Dec 1, 2017
1 parent 0dd382b commit cc530a0
Show file tree
Hide file tree
Showing 91 changed files with 21,678 additions and 3,652 deletions.
2 changes: 1 addition & 1 deletion .babelrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"presets": ["react", "es2015"]
"presets": ["react", "env"]
}
2 changes: 1 addition & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"react/jsx-key": 0
},
"parserOptions": {
"ecmaVersion": 6,
"ecmaVersion": 2017,
"sourceType": "module",
"ecmaFeatures": {
"jsx": true
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@ package-lock.json
build.json
packed
npm-debug.log
test/fixtures/build
build
20 changes: 20 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,23 @@
# 1.0.0 (11/29/2017)

- fixes pipeline to find times recursively
- cleans up duplicate code
- handles if git is not present
- removes the dependency on having a package.json to get name and description
- removes the qs module uses native querystring
- cleans up stages markup to have the title inlined
- adds report tab to show report in JSON
- adds times to all pipeline nodes
- the end now shows a cumulative time
- fixes bug if output is not defined in config
- config is now the pipeline parsed
- adds an `output` flag to the CLI that sets the output of the report
- adds an `browser` flag to CLI that allows setting browser to be configured to be open or not
- abstracts execution logic from binary and tests it separately
- cleans up and rearranges UI
- adds story to storybook stories to reflect a full report view
- removes `babel-minify-webpack-plugin`

# 0.2.9 (11/13/2017)

- adds qs module to dependencies
Expand Down
20 changes: 13 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,17 @@ npm install build.sh -g
## Usage

```
Usage: build [options]
Usage: build [options] <steps>
Options:
-V, --version output the version number
-c, --config [file] the input file for the build pipeline to run
-d, --debug outputs a debug file of the build process and data captured
-h, --help output usage information
-V, --version output the version number
-c, --config [file] the input file for the build pipeline to run (default: /Users/gabrielcsapo/Documents/build.sh/build.yml)
-d, --debug outputs a debug file of the build process and data captured
-o, --output [output] set the output path for the build artifact
-b, --browser doesn't open browser
-h, --help output usage information
```

## How To
Expand Down Expand Up @@ -79,7 +81,7 @@ pipeline:
- npm run generate-docs
```
> there is also the ability to run parts of pipeline by specifying which ones to run for example `build install:npm,lint,coverage,test` will only run the nested npm install, lint, coverage and test scripts
> there is also the ability to run parts of pipeline by specifying which ones to run for example `build lint,coverage,test` will only run the nested npm install, lint, coverage and test scripts

![subset.png](./docs/subset.png)

Expand All @@ -95,6 +97,10 @@ An important factor when dealing with build pipelines is the persistence of envi

![environment.png](./docs/environment.png)

If the build report was ran and built using `build.sh` it will also record the yaml file that it ran with under the `Config` tab.
If the build report was ran and built using `build.sh` it will also record the yaml file that it ran with under the `Config` tab:

![config.png](./docs/config.png)

To view the raw build data simply navigate to the `Report` tab and you will get a view similar to this:

![report.png](./docs/report.png)
1 change: 0 additions & 1 deletion TODO.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
- [ ] capture any changes that weren't committed to git
- [ ] document and test using build.sh as a module
- [ ] add prop types
- [ ] add the option to to take in a build.json file and generate a report from that
- [ ] generate a multi line pipeline
```
Expand Down
118 changes: 13 additions & 105 deletions bin/build.js
Original file line number Diff line number Diff line change
@@ -1,123 +1,31 @@
#!/usr/bin/env node

const program = require('commander');
const path = require('path');

const fs = require('fs');
const fs = require('fs');
const yaml = require('js-yaml');
const open = require('opn');
const logUpdate = require('log-update');
const qs = require('qs');
const execute = require('../lib/execute');

const Git = require('../lib/git');
const Compile = require('../lib/compile');
const Pipeline = require('../lib/pipeline');
const { ms, renderAsciiPipe } = require('../lib/util');

let refinedSteps = '';
let runOnly = '';

program
.version(require('../package.json').version)
.arguments('<steps>')
.action(function (actions) {
// creates an array of steps allowed
refinedSteps = actions.split(',')
runOnly = actions.split(',')
})
.option('-c, --config [file]', 'the input file for the build pipeline to run', path.resolve(process.cwd(), 'build.yml'))
.option('-c, --config [file]', 'the input file for the build pipeline to run', process.cwd() + '/build.yml')
.option('-d, --debug', 'outputs a debug file of the build process and data captured', false)
.option('-o, --output [output]', 'set the output path for the build artifact')
.option('-b, --browser', 'doesn\'t open browser')
.parse(process.argv);

const { config, debug } = program;

try {
const pkg = require(path.resolve(process.cwd(), 'package.json'));
const buildFile = fs.readFileSync(config, 'utf8');
const doc = yaml.safeLoad(buildFile);
const { pipeline, output, env } = doc;

if(env) {
env.forEach((e) => {
let q = qs.parse(e);
let k = Object.keys(q)[0];
process.env[k] = q[k];
});
}

const start = process.hrtime();
const events = Pipeline(pipeline, refinedSteps);
let completed = [];

events.on('stage:end', (stage) => {
completed.push(stage);

logUpdate(renderAsciiPipe(pipeline, completed));
});

logUpdate(renderAsciiPipe(pipeline, completed));

events.on('end', (results) => {
console.log('Capturing git information'); // eslint-disable-line

Git()
.then((info) => {
if(debug) {
fs.writeFileSync('build.json', JSON.stringify({
git: info,
name: pkg.name,
description: pkg.description,
source: pkg.repository.url,
config: buildFile,
environment: {
versions: process.versions,
env: process.env,
arch: process.arch,
platform: process.platform,
release: process.release,
version: process.version,
features: process.features,
config: process.config
},
pipeline: results
}, null, 4));
}

Compile({
config: {
git: info,
name: pkg.name,
description: pkg.description,
source: pkg.repository.url,
config: buildFile,
environment: {
versions: process.versions,
env: process.env,
arch: process.arch,
platform: process.platform,
release: process.release,
version: process.version,
features: process.features,
config: process.config
},
pipeline: results
},
output: path.resolve(output) || process.cwd() + '/build'
}, (error) => {
if(error) {
return console.log(`Compile has failed with the following error:\n${error}`); // eslint-disable-line
}
const reportLocation = path.resolve((path.resolve(output) || process.cwd() + '/build'), 'index.html');
const end = process.hrtime(start);

console.log(`Report compiled [${ms(((end[0] * 1e9) + end[1]) / 1e6)}]\nLocated at ${reportLocation}`); // eslint-disable-line
const { config, debug, output, browser } = program;

open(reportLocation, { wait: false });
});
})
.catch((error) => {
console.log(`Failed trying to get git information ${error}`); // eslint-disable-line
})
});
const buildFile = fs.readFileSync(config, 'utf8');
const doc = yaml.safeLoad(buildFile);

} catch (error) {
console.log(`Something went really wrong ${error}`); // eslint-disable-line
}
(async function() {
await execute(Object.assign({ runOnly, debug, output, browser }, doc));
}())
Loading

0 comments on commit cc530a0

Please sign in to comment.