Skip to content

Commit

Permalink
Auto-merge for PR #753 via VersionBot
Browse files Browse the repository at this point in the history
Add prettier
  • Loading branch information
resin-io-versionbot[bot] committed Jan 10, 2018
2 parents 29145df + c94f7b1 commit 7df277c
Show file tree
Hide file tree
Showing 25 changed files with 453 additions and 340 deletions.
5 changes: 5 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"single-quote": true,
"trailing-comma": "all",
"use-tabs": true
}
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file
automatically by Versionist. DO NOT EDIT THIS FILE MANUALLY!
This project adheres to [Semantic Versioning](http://semver.org/).

## v6.12.4 - 2018-01-10

* Start using Prettier #753 [Tim Perry]

## v6.12.3 - 2018-01-09

* Lint TypeScript and CoffeeScript with resin-lint #743 [Tim Perry]
Expand Down
48 changes: 25 additions & 23 deletions automation/build-bin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,28 +7,30 @@ const ROOT = path.join(__dirname, '..');

console.log('Building package...\n');

execPkg([
'--target', 'host',
'--output', 'build-bin/resin',
'package.json'
]).then(() => fs.copy(
path.join(ROOT, 'node_modules', 'opn', 'xdg-open'),
path.join(ROOT, 'build-bin', 'xdg-open')
)).then(() => {
return filehound.create()
.paths(path.join(ROOT, 'node_modules'))
.ext(['node', 'dll'])
.find();
}).then((nativeExtensions) => {
console.log(`\nCopying to build-bin:\n${nativeExtensions.join('\n')}`);
execPkg(['--target', 'host', '--output', 'build-bin/resin', 'package.json'])
.then(() =>
fs.copy(
path.join(ROOT, 'node_modules', 'opn', 'xdg-open'),
path.join(ROOT, 'build-bin', 'xdg-open'),
),
)
.then(() => {
return filehound
.create()
.paths(path.join(ROOT, 'node_modules'))
.ext(['node', 'dll'])
.find();
})
.then(nativeExtensions => {
console.log(`\nCopying to build-bin:\n${nativeExtensions.join('\n')}`);

return nativeExtensions.map((extPath) => {
return fs.copy(
extPath,
extPath.replace(
path.join(ROOT, 'node_modules'),
path.join(ROOT, 'build-bin')
)
);
return nativeExtensions.map(extPath => {
return fs.copy(
extPath,
extPath.replace(
path.join(ROOT, 'node_modules'),
path.join(ROOT, 'build-bin'),
),
);
});
});
});
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ import * as path from 'path';
import * as markdown from './markdown';
import { Document, Category } from './doc-types';

const result = <Document> {};
const result = <Document>{};
result.title = capitanodoc.title;
result.introduction = capitanodoc.introduction;
result.categories = [];

for (let commandCategory of capitanodoc.categories) {
const category = <Category> {};
const category = <Category>{};
category.title = commandCategory.title;
category.commands = [];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ export function renderCommand(command: Command) {
result += '\n### Options';

for (let option of command.options!) {
result += `\n\n#### ${utils.parseSignature(option)}\n\n${option.description}`;
result += `\n\n#### ${utils.parseSignature(option)}\n\n${
option.description
}`;
}

result += '\n';
Expand All @@ -30,35 +32,41 @@ export function renderCategory(category: Category) {
}

function getAnchor(command: Command) {
return '#' + command.signature
.replace(/\s/g,'-')
.replace(/</g, '60-')
.replace(/>/g, '-62-')
.replace(/\[/g, '')
.replace(/\]/g, '-')
.replace(/--/g, '-')
.replace(/\.\.\./g, '')
.replace(/\|/g, '')
.toLowerCase();
return (
'#' +
command.signature
.replace(/\s/g, '-')
.replace(/</g, '60-')
.replace(/>/g, '-62-')
.replace(/\[/g, '')
.replace(/\]/g, '-')
.replace(/--/g, '-')
.replace(/\.\.\./g, '')
.replace(/\|/g, '')
.toLowerCase()
);
}

export function renderToc(categories: Category[]) {
let result = `# Table of contents\n`;

for (let category of categories) {

result += `\n- ${category.title}\n\n`;

for (let command of category.commands) {
result += `\t- [${ent.encode(command.signature)}](${getAnchor(command)})\n`;
result += `\t- [${ent.encode(command.signature)}](${getAnchor(
command,
)})\n`;
}
}

return result;
}

export function render(doc: Document) {
let result = `# ${doc.title}\n\n${doc.introduction}\n\n${renderToc(doc.categories)}`;
let result = `# ${doc.title}\n\n${doc.introduction}\n\n${renderToc(
doc.categories,
)}`;

for (let category of doc.categories) {
result += `\n${renderCategory(category)}`;
Expand Down
File renamed without changes.
5 changes: 4 additions & 1 deletion automation/custom-types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@ declare module 'publish-release' {
html_url: string;
}

let publishRelease: (args: PublishOptions, callback: (e: Error, release: Release) => void) => void;
let publishRelease: (
args: PublishOptions,
callback: (e: Error, release: Release) => void,
) => void;

export = publishRelease;
}
85 changes: 48 additions & 37 deletions automation/deploy-bin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,43 +14,54 @@ const { GITHUB_TOKEN } = process.env;
const ROOT = path.join(__dirname, '..');

const version = 'v' + packageJSON.version;
const outputFile = path.join(ROOT, 'build-zip', `resin-cli-${version}-${os.platform()}-${os.arch()}.zip`);
const outputFile = path.join(
ROOT,
'build-zip',
`resin-cli-${version}-${os.platform()}-${os.arch()}.zip`,
);

mkdirpAsync(path.dirname(outputFile)).then(() => new Promise((resolve, reject) => {
console.log('Zipping build...');
mkdirpAsync(path.dirname(outputFile))
.then(
() =>
new Promise((resolve, reject) => {
console.log('Zipping build...');

let archive = archiver('zip', {
zlib: { level: 7 },
});
archive.directory(path.join(ROOT, 'build-bin'), 'resin-cli');

let outputStream = fs.createWriteStream(outputFile);

outputStream.on('close', resolve);
outputStream.on('error', reject);

archive.on('error', reject);
archive.on('warning', console.warn);

archive.pipe(outputStream);
archive.finalize();
})).then(() => {
console.log('Build zipped');
console.log('Publishing build...');

return publishReleaseAsync({
token: <string> GITHUB_TOKEN,
owner: 'resin-io',
repo: 'resin-cli',
tag: version,
name: `Resin-CLI ${version}`,
reuseRelease: true,
assets: [outputFile],
let archive = archiver('zip', {
zlib: { level: 7 },
});
archive.directory(path.join(ROOT, 'build-bin'), 'resin-cli');

let outputStream = fs.createWriteStream(outputFile);

outputStream.on('close', resolve);
outputStream.on('error', reject);

archive.on('error', reject);
archive.on('warning', console.warn);

archive.pipe(outputStream);
archive.finalize();
}),
)
.then(() => {
console.log('Build zipped');
console.log('Publishing build...');

return publishReleaseAsync({
token: <string>GITHUB_TOKEN,
owner: 'resin-io',
repo: 'resin-cli',
tag: version,
name: `Resin-CLI ${version}`,
reuseRelease: true,
assets: [outputFile],
});
})
.then(release => {
console.log(`Release ${version} successful: ${release.html_url}`);
})
.catch(err => {
console.error('Release failed');
console.error(err);
process.exit(1);
});
}).then((release) => {
console.log(`Release ${version} successful: ${release.html_url}`);
}).catch((err) => {
console.error('Release failed');
console.error(err);
process.exit(1);
});
17 changes: 0 additions & 17 deletions extras/tsconfig.json

This file was deleted.

3 changes: 2 additions & 1 deletion lib/actions/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ Examples:
const resin = (await import('resin-sdk')).fromSharedOptions();
const prettyjson = await import('prettyjson');

return resin.settings.getAll()
return resin.settings
.getAll()
.then(prettyjson.render)
.then(console.log)
.nodeify(done);
Expand Down
3 changes: 2 additions & 1 deletion lib/config.ts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export const sentryDsn = 'https://56d2a46124614b01b0f4086897e96110:6e175465accc41b595a96947155f61fb@sentry.io/149239';
export const sentryDsn =
'https://56d2a46124614b01b0f4086897e96110:6e175465accc41b595a96947155f61fb@sentry.io/149239';
18 changes: 12 additions & 6 deletions lib/errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,16 @@ import patterns = require('./utils/patterns');
import Raven = require('raven');
import Promise = require('bluebird');

const captureException = Promise.promisify<string, Error>(Raven.captureException, { context: Raven });
const captureException = Promise.promisify<string, Error>(
Raven.captureException,
{ context: Raven },
);

exports.handle = function(error: any) {
let message = errors.interpret(error);
if ((message == null)) { return; }
if (message == null) {
return;
}

if (process.env.DEBUG) {
message = error.stack;
Expand All @@ -32,8 +37,9 @@ exports.handle = function(error: any) {
patterns.printErrorMessage(message);

return captureException(error)
.timeout(1000)
.catch(function() {
// Ignore any errors (from error logging, or timeouts)
}).finally(() => process.exit(error.exitCode || 1));
.timeout(1000)
.catch(function() {
// Ignore any errors (from error logging, or timeouts)
})
.finally(() => process.exit(error.exitCode || 1));
};
50 changes: 28 additions & 22 deletions lib/events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,34 +9,40 @@ import packageJSON = require('../package.json');

const resin = ResinSdk.fromSharedOptions();
const getMatchCommandAsync = Promise.promisify(Capitano.state.getMatchCommand);
const getMixpanel = _.memoize<any>(() => resin.models.config.getAll().get('mixpanelToken').then(Mixpanel.init));
const getMixpanel = _.memoize<any>(() =>
resin.models.config
.getAll()
.get('mixpanelToken')
.then(Mixpanel.init),
);

export function trackCommand(capitanoCli: Capitano.Cli) {
return Promise.props({
resinUrl: resin.settings.get('resinUrl'),
username: resin.auth.whoami().catchReturn(undefined),
mixpanel: getMixpanel(),
}).then(({ username, resinUrl, mixpanel }) => {
return getMatchCommandAsync(capitanoCli.command).then((command) => {
Raven.mergeContext({
user: {
id: username,
username,
},
});
})
.then(({ username, resinUrl, mixpanel }) => {
return getMatchCommandAsync(capitanoCli.command).then(command => {
Raven.mergeContext({
user: {
id: username,
username,
},
});

return mixpanel.track(`[CLI] ${command.signature.toString()}`, {
distinct_id: username,
argv: process.argv.join(' '),
version: packageJSON.version,
node: process.version,
arch: process.arch,
resinUrl,
platform: process.platform,
command: capitanoCli,
return mixpanel.track(`[CLI] ${command.signature.toString()}`, {
distinct_id: username,
argv: process.argv.join(' '),
version: packageJSON.version,
node: process.version,
arch: process.arch,
resinUrl,
platform: process.platform,
command: capitanoCli,
});
});
});
})
.timeout(100)
.catchReturn(undefined);
})
.timeout(100)
.catchReturn(undefined);
}

0 comments on commit 7df277c

Please sign in to comment.