Auto-merge for PR #729 via VersionBot

Standalone binary for Resin-CLI
This commit is contained in:
resin-io-versionbot[bot] 2017-12-18 15:06:13 +00:00 committed by GitHub
commit fdd253f042
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 259 additions and 21 deletions

2
.gitignore vendored
View File

@ -35,3 +35,5 @@ resinrc.yml
/tmp
build/
build-bin/
build-zip/

View File

@ -1,22 +1,28 @@
language: node_js
matrix:
include:
- node_js:
- '6'
env:
- CAN_DEPLOY=true
os:
- linux
- osx
node_js:
- "6"
before_install:
- npm -g install npm@4
script: npm run ci
notifications:
email: false
deploy:
provider: npm
email: accounts@resin.io
api_key:
secure: phet6Du13hc1bzStbmpwy2ODNL5BFwjAmnpJ5wMcbWfI7fl0OtQ61s2+vW5hJAvm9fiRLOfiGAEiqOOtoupShZ1X8BNkC708d8+V+iZMoFh3+j6wAEz+N1sVq471PywlOuLAscOcqQNp92giCVt+4VPx2WQYh06nLsunvysGmUM=
skip_cleanup: true
on:
tags: true
condition: "$CAN_DEPLOY = 'true' && $TRAVIS_TAG =~ ^v?[[:digit:]]+\\.[[:digit:]]+\\.[[:digit:]]+"
repo: resin-io/resin-cli
- provider: script
script: npm run release
skip_cleanup: true
on:
tags: true
condition: "$TRAVIS_TAG =~ ^v?[[:digit:]]+\\.[[:digit:]]+\\.[[:digit:]]+"
repo: resin-io/resin-cli
- provider: npm
email: accounts@resin.io
api_key:
secure: phet6Du13hc1bzStbmpwy2ODNL5BFwjAmnpJ5wMcbWfI7fl0OtQ61s2+vW5hJAvm9fiRLOfiGAEiqOOtoupShZ1X8BNkC708d8+V+iZMoFh3+j6wAEz+N1sVq471PywlOuLAscOcqQNp92giCVt+4VPx2WQYh06nLsunvysGmUM=
skip_cleanup: true
on:
tags: true
condition: "$TRAVIS_TAG =~ ^v?[[:digit:]]+\\.[[:digit:]]+\\.[[:digit:]]+"
repo: resin-io/resin-cli

View File

@ -4,6 +4,13 @@ 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.11.0 - 2017-12-18
* Fix docs generation when building on windows #729 [Tim Perry]
* Autodeploy built standalone binaries for all platforms to github #729 [Tim Perry]
* Package the CLI into a standalone runnable binary #729 [Tim Perry]
* Move from open to opn #729 [Tim Perry]
## v6.10.3 - 2017-12-15
* Ensure logout works even with invalid credentials, or if not logged in #730 [Tim Perry]

View File

@ -10,6 +10,9 @@ Resin CLI
Requisites
----------
If you want to install the CLI directly through npm, you'll need the below. If this looks difficult,
we do now have an experimental standalone binary release available, see ['Standalone install'](#standalone-install) below.
- [NodeJS](https://nodejs.org) (>= v4)
- [Git](https://git-scm.com)
- The following executables should be correctly installed in your shell environment:
@ -34,7 +37,10 @@ If you still want to use `cmd.exe` you will have to use a package manager like M
Getting Started
---------------
### Install
### NPM install
If you've got all the requirements above, you should be able to install the CLI directly from npm. If not,
or if you have any trouble with this, please try the new standalone install steps just below.
This might require elevated privileges in some environments.
@ -42,6 +48,26 @@ This might require elevated privileges in some environments.
$ npm install --global --production resin-cli
```
### Standalone install
If you don't have node or a working pre-gyp environment, you can still install the CLI as a standalone
binary. **This is in experimental and may not work perfectly yet in all environments**, but it seems to work
well in initial cross-platform testing, so it may be useful, and we'd love your feedback if you hit any issues.
To install the CLI as a standalone binary:
* Download the latest zip for your OS from https://github.com/resin-io/resin-cli/releases.
* Extract the contents, putting the `resin-cli` folder somewhere appropriate for your system (e.g. `C:/resin-cli`, `/usr/local/lib/resin-cli`, etc).
* Add the `resin-cli` folder to your `PATH`. (
[Windows instructions](https://www.computerhope.com/issues/ch000549.htm),
[Linux instructions](https://stackoverflow.com/questions/14637979/how-to-permanently-set-path-on-linux-unix),
[OSX instructions](https://stackoverflow.com/questions/22465332/setting-path-environment-variable-in-osx-permanently))
* Running `resin` in a fresh command line should print the resin CLI help.
To update in future, simply download a new release and replace the extracted folder.
Have any problems, or see any unexpected behaviour? Please file an issue!
### Login
```sh

34
appveyor.yml Normal file
View File

@ -0,0 +1,34 @@
# appveyor file
# http://www.appveyor.com/docs/appveyor-yml
init:
- git config --global core.autocrlf input
cache:
- C:\Users\appveyor\.node-gyp
- '%AppData%\npm-cache'
matrix:
fast_finish: true
# what combinations to test
environment:
matrix:
- nodejs_version: 6
install:
- ps: Install-Product node $env:nodejs_version x64
- npm install -g npm@4
- set PATH=%APPDATA%\npm;%PATH%
- npm install
build: off
test_script:
- node --version
- npm --version
- cmd: npm test
deploy_script:
- IF "%APPVEYOR_REPO_TAG%" == "true" (npm run release)
- IF NOT "%APPVEYOR_REPO_TAG%" == "true" (echo 'Not tagged, skipping deploy')

34
automation/build-bin.ts Executable file
View File

@ -0,0 +1,34 @@
import * as path from 'path';
import * as fs from 'fs-extra';
import * as filehound from 'filehound';
import { exec as execPkg } from 'pkg';
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')}`);
return nativeExtensions.map((extPath) => {
return fs.copy(
extPath,
extPath.replace(
path.join(ROOT, 'node_modules'),
path.join(ROOT, 'build-bin')
)
);
});
});

35
automation/custom-types.d.ts vendored Normal file
View File

@ -0,0 +1,35 @@
declare module 'pkg' {
export function exec(args: string[]): Promise<void>;
}
declare module 'filehound' {
export function create(): FileHound;
export interface FileHound {
paths(paths: string[]): FileHound;
paths(...paths: string[]): FileHound;
ext(extensions: string[]): FileHound;
ext(...extensions: string[]): FileHound;
find(): Promise<string[]>;
}
}
declare module 'publish-release' {
interface PublishOptions {
token: string,
owner: string,
repo: string,
tag: string,
name: string,
reuseRelease?: boolean
assets: string[]
}
interface Release {
html_url: string;
}
let publishRelease: (args: PublishOptions, callback: (e: Error, release: Release) => void) => void;
export = publishRelease;
}

55
automation/deploy-bin.ts Normal file
View File

@ -0,0 +1,55 @@
import * as Promise from 'bluebird';
import * as path from 'path';
import * as os from 'os';
import * as fs from 'fs-extra';
import * as mkdirp from 'mkdirp';
import * as publishRelease from 'publish-release';
import * as archiver from 'archiver';
const publishReleaseAsync = Promise.promisify(publishRelease);
const mkdirpAsync = Promise.promisify<string | null, string>(mkdirp);
const { GITHUB_TOKEN } = process.env;
const ROOT = path.join(__dirname, '..');
const version = 'v' + require('../package.json').version;
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...');
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);
});

15
automation/tsconfig.json Normal file
View File

@ -0,0 +1,15 @@
{
"compilerOptions": {
"module": "commonjs",
"target": "es2015",
"strict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"preserveConstEnums": true,
"removeComments": true,
"sourceMap": true
},
"include": [
"./**/*.ts"
]
}

View File

@ -18,7 +18,7 @@ limitations under the License.
# @module auth
###
open = require('open')
open = require('opn')
resin = require('resin-sdk-preconfigured')
server = require('./server')
utils = require('./utils')

View File

@ -1,6 +1,6 @@
{
"name": "resin-cli",
"version": "6.10.3",
"version": "6.11.0",
"description": "The official resin.io CLI tool",
"main": "./build/actions/index.js",
"homepage": "https://github.com/resin-io/resin-cli",
@ -18,12 +18,26 @@
"bin": {
"resin": "./bin/resin"
},
"pkg": {
"scripts": [
"node_modules/resin-sync/build/capitano/*.js",
"node_modules/resin-sync/build/sync/*.js"
],
"assets": [
"build/auth/pages/*.ejs",
"node_modules/resin-discoverable-services/services/**/*"
]
},
"scripts": {
"build": "gulp build && tsc && npm run doc",
"prebuild": "rimraf build/ build-bin/ build-zip/",
"build": "npm run build:src && npm run build:bin",
"build:src": "gulp build && tsc && npm run doc",
"build:bin": "ts-node --type-check -P automation automation/build-bin.ts",
"release": "npm run build && ts-node --type-check -P automation automation/deploy-bin.ts",
"pretest": "npm run build",
"test": "gulp test",
"ci": "npm run test && catch-uncommitted",
"doc": "mkdir -p doc/ && coffee extras/capitanodoc/index.coffee > doc/cli.markdown",
"doc": "mkdirp doc/ && coffee extras/capitanodoc/index.coffee > doc/cli.markdown",
"watch": "gulp watch",
"lint": "gulp lint",
"prepublish": "require-npm4-to-publish",
@ -39,8 +53,13 @@
"node": ">=6.0"
},
"devDependencies": {
"@types/archiver": "^2.0.1",
"@types/fs-extra": "^5.0.0",
"@types/mkdirp": "^0.5.2",
"catch-uncommitted": "^1.0.0",
"ent": "^2.2.0",
"filehound": "^1.16.2",
"fs-extra": "^5.0.0",
"gulp": "^3.9.0",
"gulp-coffee": "^2.2.0",
"gulp-coffeelint": "^0.6.0",
@ -48,13 +67,17 @@
"gulp-mocha": "^2.0.0",
"gulp-shell": "^0.5.2",
"mochainon": "^2.0.0",
"pkg": "^4.3.0-beta.1",
"publish-release": "^1.3.3",
"require-npm4-to-publish": "^1.0.0",
"ts-node": "^4.0.1",
"typescript": "^2.6.1"
},
"dependencies": {
"@resin.io/valid-email": "^0.1.0",
"ansi-escapes": "^2.0.0",
"any-promise": "^1.3.0",
"archiver": "^2.1.0",
"bash": "0.0.1",
"bluebird": "^3.3.3",
"body-parser": "^1.14.1",
@ -79,11 +102,12 @@
"klaw": "^1.3.1",
"lodash": "^4.17.4",
"mixpanel": "^0.4.0",
"mkdirp": "^0.5.1",
"moment": "^2.12.0",
"mz": "^2.6.0",
"node-cleanup": "^2.1.2",
"nplugm": "^3.0.0",
"open": "0.0.5",
"opn": "^5.1.0",
"president": "^2.0.1",
"prettyjson": "^1.1.3",
"progress-stream": "^2.0.0",