Skip to content

Commit a3d9934

Browse files
authored
Merge pull request #5 from vltansky/master
Adds tests, reorganizes the code and adds a readme file
2 parents 0373c5b + 06218e8 commit a3d9934

File tree

8 files changed

+4206
-50
lines changed

8 files changed

+4206
-50
lines changed

.github/workflows/coveralls.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node
2+
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions
3+
4+
name: Node.js CI
5+
6+
on:
7+
push:
8+
branches: [ master ]
9+
pull_request:
10+
branches: [ master ]
11+
12+
jobs:
13+
build:
14+
15+
runs-on: ubuntu-latest
16+
17+
strategy:
18+
matrix:
19+
node-version: [12.x]
20+
21+
steps:
22+
- uses: actions/checkout@v2
23+
- name: Use Node.js ${{ matrix.node-version }}
24+
uses: actions/setup-node@v1
25+
with:
26+
node-version: ${{ matrix.node-version }}
27+
- run: npm ci
28+
- run: npm run coverage
29+
30+
- name: Coveralls
31+
uses: coverallsapp/github-action@master
32+
with:
33+
github-token: ${{ secrets.GITHUB_TOKEN }}

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
node_modules
2-
out
2+
out
3+
coverage

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# create-html5-boilerplate
2+
npx for html5-boilerplate
3+
4+
[![Coverage Status](https://coveralls.io/repos/github/h5bp/create-html5-boilerplate/badge.svg?branch=master)](https://coveralls.io/github/h5bp/create-html5-boilerplate?branch=master)

cli.js

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#!/usr/bin/env node
2+
'use strict'
3+
const yargs_parser = require('yargs-parser')
4+
const path = require("path");
5+
const chalk = require('chalk');
6+
const ora = require("ora");
7+
const { extract } = require('pacote');
8+
const fs = require("fs-extra");
9+
const os = require('os');
10+
const packageName = 'html5-boilerplate';
11+
const tempDir = os.tmpdir()+`/${packageName}-staging`;
12+
const elapsed = require("elapsed-time-logger");
13+
14+
module.exports = async () => {
15+
const argv = yargs_parser(process.argv.slice(2), {alias:{release: ['r']}});
16+
const timer = elapsed.start();
17+
const version = argv['release'] || 'latest';
18+
const targetDir = path.resolve(argv['_'][0] || './');
19+
const spinner = ora(`Downloading ${packageName} version '${version}' to ${targetDir}`).start();
20+
await fs.ensureDir(tempDir);
21+
try{
22+
const { from: nameWithVersion } = await extract(packageName + '@' + version, tempDir, {});
23+
spinner.text = `${nameWithVersion} copied to ${targetDir} in ${timer.get()}. Have fun!`;
24+
}catch(err){
25+
await fs.remove(tempDir);
26+
if(err.code === 'ETARGET'){
27+
spinner.fail(chalk.red(`version '${err.wanted}' not found in npm registry\navailable versions:`));
28+
console.log(err.versions.reverse().join(' | '));
29+
process.exit(1);
30+
}/* istanbul ignore next */else{
31+
spinner.fail('Unexpected error');
32+
console.error(err);
33+
process.exit(-1);
34+
};
35+
return;
36+
}
37+
await fs.copy(tempDir+'/dist', targetDir);
38+
await fs.remove(tempDir);
39+
spinner.succeed();
40+
return;
41+
};

index.js

Lines changed: 1 addition & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1 @@
1-
#!/usr/bin/env node
2-
'use strict'
3-
const argv = require('yargs-parser')(process.argv.slice(2), {alias:{release: ['r']}})
4-
const path = require("path");
5-
const chalk = require('chalk');
6-
const ora = require("ora");
7-
const { extract } = require('pacote');
8-
const fs = require("fs-extra");
9-
const os = require('os');
10-
const packageName = 'html5-boilerplate';
11-
const elapsed = require("elapsed-time-logger");
12-
13-
(async () => {
14-
const timer = elapsed.start();
15-
const version = argv['release'] || 'latest';
16-
const targetDir = path.resolve(argv['_'][0] || './');
17-
const spinner = ora(`Downloading ${packageName} version '${version}' to ${targetDir}`).start();
18-
const tempDir = os.tmpdir()+`/${packageName}-staging`;
19-
await fs.ensureDir(tempDir);
20-
try{
21-
const { from: nameWithVersion } = await extract(packageName + '@' + version, tempDir, {});
22-
spinner.text = `${nameWithVersion} copied to ${targetDir} in ${timer.get()}. Have fun!`;
23-
}catch(err){
24-
await fs.remove(tempDir);
25-
if(err.code === 'ETARGET'){
26-
spinner.fail(chalk.red(`version '${err.wanted}' not found in npm registry\navailable versions:`));
27-
console.log(err.versions.reverse().join(' | '));
28-
}else{
29-
spinner.fail('Unexpected error');
30-
console.error(err);
31-
}
32-
process.exit(0);
33-
}
34-
await fs.copy(tempDir+'/dist', targetDir);
35-
await fs.remove(tempDir);
36-
spinner.succeed();
37-
return;
38-
})();
1+
require('./cli')();

0 commit comments

Comments
 (0)