Compare commits

...

9 Commits

Author SHA1 Message Date
8fa6ad0735 Ensure MDNS service definitions are included in standalone binaries 2017-12-14 13:29:44 +01:00
db32d89f1f Add standalone install instructions to the readme 2017-12-14 13:26:07 +01:00
bb2365b3fd Use proper strict settings for automation TS 2017-12-14 13:26:07 +01:00
a9db392580 Fix docs generation when building on windows
Change-Type: patch
2017-12-14 13:26:07 +01:00
d86fcfcda4 Autodeploy built standalone binaries for all platforms to github
Change-Type: minor
2017-12-14 13:26:07 +01:00
7fb03b8511 Add manual script to deploy built CLI binaries to GitHub 2017-12-14 13:26:07 +01:00
3b52f7ba4e Set up a script to automate builds, and support native extensions 2017-12-14 13:26:07 +01:00
69396904c6 Package the CLI into a standalone runnable binary
This has no native modules yet, which means it works on Linux,
but ignoring any ext4 image data. Drivelist will fail for
some windows operations, but most other things should work.

This is only building a folder with a runnable binary, this needs
packaging before it can be distributable.

Change-Type: minor
2017-12-14 13:26:07 +01:00
71e8448fbf Move from open to opn
Change-Type: patch
2017-12-14 13:26:05 +01:00
10 changed files with 249 additions and 21 deletions

2
.gitignore vendored
View File

@ -35,3 +35,5 @@ resinrc.yml
/tmp
build/
build-bin/
resin-cli-*.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

@ -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;
}

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

@ -0,0 +1,53 @@
import * as Promise from 'bluebird';
import * as path from 'path';
import * as os from 'os';
import * as fs from 'fs-extra';
import * as publishRelease from 'publish-release';
import * as archiver from 'archiver';
const publishReleaseAsync = Promise.promisify(publishRelease);
const { GITHUB_TOKEN } = process.env;
const ROOT = path.join(__dirname, '..');
const version = 'v' + require('../package.json').version;
const outputFile = path.join(ROOT, `resin-cli-${version}-${os.platform()}-${os.arch()}.zip`);
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: 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

@ -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": "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,12 @@
"node": ">=6.0"
},
"devDependencies": {
"@types/archiver": "^2.0.1",
"@types/fs-extra": "^5.0.0",
"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 +66,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 +101,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",
@ -119,4 +142,4 @@
"optionalDependencies": {
"removedrive": "^1.0.0"
}
}
}