From f41d7e8d64a39cded547bb64fb3afe72940d58ee Mon Sep 17 00:00:00 2001 From: CHaBou Date: Mon, 9 Oct 2017 19:05:24 +0200 Subject: [PATCH 01/30] Symlink Hyper CLI on macOS --- app/config/paths.js | 4 ++- app/index.js | 8 +++++ app/package.json | 1 + app/utils/cli-install.js | 50 +++++++++++++++++++++++++++ app/yarn.lock | 75 ++++++++++++++++++++++++++++++++++++++++ bin/cli.js | 1 + build/linux/hyper | 34 ++++++++++++++++++ build/mac/hyper | 9 +++++ build/win/hyper | 21 +++++++++++ build/win/hyper.cmd | 5 +++ package.json | 61 ++++++++++++++++++++++---------- yarn.lock | 16 ++++++++- 12 files changed, 264 insertions(+), 21 deletions(-) create mode 100644 app/utils/cli-install.js create mode 100644 bin/cli.js create mode 100755 build/linux/hyper create mode 100755 build/mac/hyper create mode 100755 build/win/hyper create mode 100755 build/win/hyper.cmd diff --git a/app/config/paths.js b/app/config/paths.js index 7987b4ab28f0..d302791aae97 100644 --- a/app/config/paths.js +++ b/app/config/paths.js @@ -35,6 +35,7 @@ const plugs = { cache: resolve(plugins, 'cache') }; const yarn = resolve(__dirname, '../../bin/yarn-standalone.js'); +const cliScriptPath = resolve(__dirname, '../../bin/hyper'); const icon = resolve(__dirname, '../static/icon96x96.png'); @@ -64,5 +65,6 @@ module.exports = { icon, defaultPlatformKeyPath, plugs, - yarn + yarn, + cliScriptPath }; diff --git a/app/index.js b/app/index.js index 141cc0398e8f..fb62a1976999 100644 --- a/app/index.js +++ b/app/index.js @@ -63,6 +63,7 @@ const config = require('./config'); config.setup(); const plugins = require('./plugins'); +const {addSymlink, addBinToUserPath} = require('./utils/cli-install'); const Window = require('./ui/window'); @@ -97,6 +98,13 @@ if (isDev) { } else { //eslint-disable-next-line no-console console.log('running in prod mode'); + if (process.platform === 'win32') { + //eslint-disable-next-line no-console + addBinToUserPath().catch(err => console.error('Failed to add Hyper CLI path to user PATH', err)); + } else { + //eslint-disable-next-line no-console + addSymlink().catch(err => console.error('Failed to symlink Hyper CLI', err)); + } } const url = 'file://' + resolve(isDev ? __dirname : app.getAppPath(), 'index.html'); diff --git a/app/package.json b/app/package.json index 52c56f3cc088..9cc479aa77c6 100644 --- a/app/package.json +++ b/app/package.json @@ -27,6 +27,7 @@ "queue": "4.4.0", "semver": "5.4.1", "shell-env": "0.3.0", + "util.promisify": "false1.0.0", "uuid": "3.1.0", "winreg": "1.2.4" } diff --git a/app/utils/cli-install.js b/app/utils/cli-install.js new file mode 100644 index 000000000000..128b48ad01ce --- /dev/null +++ b/app/utils/cli-install.js @@ -0,0 +1,50 @@ +const {cliScriptPath} = require('../config/paths'); + +const promisify = require('util.promisify'); +const fs = require('fs'); + +const lstat = promisify(fs.lstat); +const readlink = promisify(fs.readlink); +const unlink = promisify(fs.unlink); +const symlink = promisify(fs.symlink); + +const target = process.platform === 'darwin' ? '/usr/local/bin/hyper' : '/usr/bin/hyper'; +const source = cliScriptPath; + +const checkInstall = () => { + return lstat(target) + .then(stat => stat.isSymbolicLink()) + .then(() => readlink(target)) + .then(link => link === source) + .catch(err => { + if (err.code === 'ENOENT') { + return false; + } + throw err; + }); +}; + +const createSymlink = () => { + return unlink(target) + .catch(err => { + if (err.code === 'ENOENT') { + return; + } + throw err; + }) + .then(() => symlink(source, target)); +}; + +exports.addSymlink = () => { + return checkInstall().then(isInstalled => { + if (isInstalled) { + return Promise.resolve(); + } + return createSymlink(); + }); +}; + +exports.addBinToUserPath = () => { + // TODO + return Promise.resolve(); +}; diff --git a/app/yarn.lock b/app/yarn.lock index 4196cc1065d6..e0473062bc57 100644 --- a/app/yarn.lock +++ b/app/yarn.lock @@ -78,6 +78,13 @@ default-shell@1.0.1, default-shell@^1.0.0: version "1.0.1" resolved "https://registry.yarnpkg.com/default-shell/-/default-shell-1.0.1.tgz#752304bddc6174f49eb29cb988feea0b8813c8bc" +define-properties@^1.1.2: + version "1.1.2" + resolved "https://registry.yarnpkg.com/define-properties/-/define-properties-1.1.2.tgz#83a73f2fea569898fb737193c8f873caf6d45c94" + dependencies: + foreach "^2.0.5" + object-keys "^1.0.8" + dot-prop@^4.1.0: version "4.2.0" resolved "https://registry.yarnpkg.com/dot-prop/-/dot-prop-4.2.0.tgz#1f19e0c2e1aa0e32797c49799f2837ac6af69c57" @@ -110,6 +117,24 @@ env-paths@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/env-paths/-/env-paths-1.0.0.tgz#4168133b42bb05c38a35b1ae4397c8298ab369e0" +es-abstract@^1.5.1: + version "1.9.0" + resolved "https://registry.yarnpkg.com/es-abstract/-/es-abstract-1.9.0.tgz#690829a07cae36b222e7fd9b75c0d0573eb25227" + dependencies: + es-to-primitive "^1.1.1" + function-bind "^1.1.1" + has "^1.0.1" + is-callable "^1.1.3" + is-regex "^1.0.4" + +es-to-primitive@^1.1.1: + version "1.1.1" + resolved "https://registry.yarnpkg.com/es-to-primitive/-/es-to-primitive-1.1.1.tgz#45355248a88979034b6792e19bb81f2b7975dd0d" + dependencies: + is-callable "^1.1.1" + is-date-object "^1.0.1" + is-symbol "^1.0.1" + execa@^0.5.0: version "0.5.1" resolved "https://registry.yarnpkg.com/execa/-/execa-0.5.1.tgz#de3fb85cb8d6e91c85bcbceb164581785cb57b36" @@ -132,6 +157,14 @@ find-up@^2.1.0: dependencies: locate-path "^2.0.0" +foreach@^2.0.5: + version "2.0.5" + resolved "https://registry.yarnpkg.com/foreach/-/foreach-2.0.5.tgz#0bee005018aeb260d0a3af3ae658dd0136ec1b99" + +function-bind@^1.0.2, function-bind@^1.1.1: + version "1.1.1" + resolved "https://registry.yarnpkg.com/function-bind/-/function-bind-1.1.1.tgz#a56899d3ea3c9bab874bb9773b7c5ede92f4895d" + get-stream@^2.2.0: version "2.3.1" resolved "https://registry.yarnpkg.com/get-stream/-/get-stream-2.3.1.tgz#5f38f93f346009666ee0150a054167f91bdd95de" @@ -151,6 +184,12 @@ graceful-fs@^4.1.11: version "4.1.11" resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.1.11.tgz#0e8bdfe4d1ddb8854d64e04ea7c00e2a026e5658" +has@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/has/-/has-1.0.1.tgz#8461733f538b0837c9361e39a9ab9e9704dc2f28" + dependencies: + function-bind "^1.0.2" + iconv-lite@~0.4.13: version "0.4.19" resolved "https://registry.yarnpkg.com/iconv-lite/-/iconv-lite-0.4.19.tgz#f7468f60135f5e5dad3399c0a81be9a1603a082b" @@ -167,20 +206,38 @@ is-arrayish@^0.3.1: version "0.3.1" resolved "https://registry.yarnpkg.com/is-arrayish/-/is-arrayish-0.3.1.tgz#c2dfc386abaa0c3e33c48db3fe87059e69065efd" +is-callable@^1.1.1, is-callable@^1.1.3: + version "1.1.3" + resolved "https://registry.yarnpkg.com/is-callable/-/is-callable-1.1.3.tgz#86eb75392805ddc33af71c92a0eedf74ee7604b2" + is-css-color-name@^0.1.1: version "0.1.3" resolved "https://registry.yarnpkg.com/is-css-color-name/-/is-css-color-name-0.1.3.tgz#ea3b51bc901d8a243d32c9b7873d0680dbbef7f1" dependencies: css-color-names "0.0.2" +is-date-object@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/is-date-object/-/is-date-object-1.0.1.tgz#9aa20eb6aeebbff77fbd33e74ca01b33581d3a16" + is-obj@^1.0.0: version "1.0.1" resolved "https://registry.yarnpkg.com/is-obj/-/is-obj-1.0.1.tgz#3e4729ac1f5fde025cd7d83a896dab9f4f67db0f" +is-regex@^1.0.4: + version "1.0.4" + resolved "https://registry.yarnpkg.com/is-regex/-/is-regex-1.0.4.tgz#5517489b547091b0930e095654ced25ee97e9491" + dependencies: + has "^1.0.1" + is-stream@^1.0.1, is-stream@^1.1.0: version "1.1.0" resolved "https://registry.yarnpkg.com/is-stream/-/is-stream-1.1.0.tgz#12d4a3dd4e68e0b79ceb8dbc84173ae80d91ca44" +is-symbol@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/is-symbol/-/is-symbol-1.0.1.tgz#3cc59f00025194b6ab2e38dbae6689256b660572" + isexe@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/isexe/-/isexe-2.0.0.tgz#e8fbf374dc556ff8947a10dcb0572d633f2cfa10" @@ -250,6 +307,17 @@ object-assign@^4.0.1: version "4.1.1" resolved "https://registry.yarnpkg.com/object-assign/-/object-assign-4.1.1.tgz#2109adc7965887cfc05cbbd442cac8bfbb360863" +object-keys@^1.0.8: + version "1.0.11" + resolved "https://registry.yarnpkg.com/object-keys/-/object-keys-1.0.11.tgz#c54601778ad560f1142ce0e01bcca8b56d13426d" + +object.getownpropertydescriptors@^2.0.3: + version "2.0.3" + resolved "https://registry.yarnpkg.com/object.getownpropertydescriptors/-/object.getownpropertydescriptors-2.0.3.tgz#8758c846f5b407adab0f236e0986f14b051caa16" + dependencies: + define-properties "^1.1.2" + es-abstract "^1.5.1" + p-finally@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/p-finally/-/p-finally-1.0.0.tgz#3fbcfb15b899a44123b34b6dcc18b724336a2cae" @@ -338,6 +406,13 @@ strip-eof@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/strip-eof/-/strip-eof-1.0.0.tgz#bb43ff5598a6eb05d89b59fcd129c983313606bf" +util.promisify@false1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/util.promisify/-/util.promisify-1.0.0.tgz#440f7165a459c9a16dc145eb8e72f35687097030" + dependencies: + define-properties "^1.1.2" + object.getownpropertydescriptors "^2.0.3" + uuid@3.1.0: version "3.1.0" resolved "https://registry.yarnpkg.com/uuid/-/uuid-3.1.0.tgz#3dd3d3e790abc24d7b0d3a034ffababe28ebbc04" diff --git a/bin/cli.js b/bin/cli.js new file mode 100644 index 000000000000..829a81ee48d3 --- /dev/null +++ b/bin/cli.js @@ -0,0 +1 @@ +console.log('CLI-Tool', process.argv); diff --git a/build/linux/hyper b/build/linux/hyper new file mode 100755 index 000000000000..522408d7284e --- /dev/null +++ b/build/linux/hyper @@ -0,0 +1,34 @@ +#!/usr/bin/env bash +# Deeply inspired by https://github.com/Microsoft/vscode/blob/1.17.0/resources/linux/bin/code.sh + +# If root, ensure that --user-data-dir is specified +if [ "$(id -u)" = "0" ]; then + for i in $@ + do + if [[ $i == --user-data-dir=* ]]; then + DATA_DIR_SET=1 + fi + done + if [ -z $DATA_DIR_SET ]; then + echo "It is recommended to start hyper as a normal user. To run as root, you must specify an alternate user data directory with the --user-data-dir argument." 1>&2 + exit 1 + fi +fi + +if [ ! -L $0 ]; then + # if path is not a symlink, find relatively + HYPER_PATH="$(dirname $0)/.." +else + if which readlink >/dev/null; then + # if readlink exists, follow the symlink and find relatively + HYPER_PATH="$(dirname $(readlink -f $0))/.." + else + # else use the standard install location + HYPER_PATH="/usr/share/@@NAME@@" + fi +fi + +ELECTRON="$HYPER_PATH/@@NAME@@" +CLI="$HYPER_PATH/resources/bin/cli.js" +ELECTRON_RUN_AS_NODE=1 "$ELECTRON" "$CLI" "$@" +exit $? \ No newline at end of file diff --git a/build/mac/hyper b/build/mac/hyper new file mode 100755 index 000000000000..d5be61bf1b19 --- /dev/null +++ b/build/mac/hyper @@ -0,0 +1,9 @@ +#!/usr/bin/env bash +# Deeply inspired by https://github.com/Microsoft/vscode/blob/1.17.0/resources/darwin/bin/code.sh + +function realpath() { /usr/bin/python -c "import os,sys; print os.path.realpath(sys.argv[1])" "$0"; } +CONTENTS="$(dirname "$(dirname "$(dirname "$(realpath "$0")")")")" +ELECTRON="$CONTENTS/MacOS/Hyper" +CLI="$CONTENTS/Resources/bin/cli.js" +ELECTRON_RUN_AS_NODE=1 "$ELECTRON" "$CLI" "$@" +exit $? \ No newline at end of file diff --git a/build/win/hyper b/build/win/hyper new file mode 100755 index 000000000000..c255d4a93499 --- /dev/null +++ b/build/win/hyper @@ -0,0 +1,21 @@ +#!/usr/bin/env bash +# Deeply inspired by https://github.com/Microsoft/vscode/blob/1.17.0/resources/win/bin/code.sh + +NAME="@@NAME@@" +HYPER_PATH="$(dirname "$(dirname "$(realpath "$0")")")" +ELECTRON="$HYPER_PATH/$NAME.exe" +if grep -q Microsoft /proc/version; then + # If running under WSL don't pass cli.js to Electron as environment vars + # cannot be transferred from WSL to Windows + # See: https://github.com/Microsoft/BashOnWindows/issues/1363 + # https://github.com/Microsoft/BashOnWindows/issues/1494 + "$ELECTRON" "$@" + exit $? +fi +if [ "$(expr substr $(uname -s) 1 9)" == "CYGWIN_NT" ]; then + CLI=$(cygpath -m "$HYPER_PATH/resources/bin/cli.js") +else + CLI="$HYPER_PATH/resources/bin/cli.js" +fi +ELECTRON_RUN_AS_NODE=1 "$ELECTRON" "$CLI" "$@" +exit $? diff --git a/build/win/hyper.cmd b/build/win/hyper.cmd new file mode 100755 index 000000000000..66f5bd9f7ab5 --- /dev/null +++ b/build/win/hyper.cmd @@ -0,0 +1,5 @@ +@echo off +setlocal +set ELECTRON_RUN_AS_NODE=1 +call "%~dp0..\@@NAME@@.exe" "%~dp0..\resources\bin\cli.js" %* +endlocal \ No newline at end of file diff --git a/package.json b/package.json index cc8168ad7930..fbb6219f7972 100644 --- a/package.json +++ b/package.json @@ -1,8 +1,7 @@ { "repository": "zeit/hyper", "scripts": { - "start": - "echo 'please run `yarn run dev` in one tab and then `yarn run app` in another one'", + "start": "echo 'please run `yarn run dev` in one tab and then `yarn run app` in another one'", "app": "electron app", "dev": "webpack -w", "build": "cross-env NODE_ENV=production webpack", @@ -11,18 +10,21 @@ "test:unit": "ava test/unit", "test:unit:watch": "yarn run test:unit -- --watch", "prepush": "yarn test", - "postinstall": - "electron-builder install-app-deps && yarn run rebuild-node-pty", - "rebuild-node-pty": - "electron-rebuild -f -w app/node_modules/node-pty -m app", - "dist": - "yarn run build && cross-env BABEL_ENV=production babel --out-file app/renderer/bundle.js --no-comments --minified app/renderer/bundle.js && build", - "clean": - "node ./bin/rimraf-standalone.js node_modules && node ./bin/rimraf-standalone.js ./app/node_modules && node ./bin/rimraf-standalone.js ./app/renderer" + "postinstall": "electron-builder install-app-deps && yarn run rebuild-node-pty", + "rebuild-node-pty": "electron-rebuild -f -w app/node_modules/node-pty -m app", + "dist": "yarn run build && cross-env BABEL_ENV=production babel --out-file app/renderer/bundle.js --no-comments --minified app/renderer/bundle.js && build", + "clean": "node ./bin/rimraf-standalone.js node_modules && node ./bin/rimraf-standalone.js ./app/node_modules && node ./bin/rimraf-standalone.js ./app/renderer" }, "eslintConfig": { - "plugins": ["react", "prettier"], - "extends": ["eslint:recommended", "plugin:react/recommended", "prettier"], + "plugins": [ + "react", + "prettier" + ], + "extends": [ + "eslint:recommended", + "plugin:react/recommended", + "prettier" + ], "parserOptions": { "ecmaVersion": 8, "sourceType": "module", @@ -39,7 +41,10 @@ "node": true }, "rules": { - "func-names": ["error", "as-needed"], + "func-names": [ + "error", + "as-needed" + ], "no-shadow": "error", "no-extra-semi": 0, "react/prop-types": 0, @@ -64,7 +69,9 @@ } }, "babel": { - "presets": ["react"], + "presets": [ + "react" + ], "env": { "production": { "plugins": [ @@ -95,26 +102,41 @@ }, "build": { "appId": "co.zeit.hyper", - "extraResources": "./bin/yarn-standalone.js", + "extraResources": [ + "./bin/yarn-standalone.js", + "./bin/cli.js", + { + "from": "./build/${os}/", + "to": "./bin/" + } + ], "linux": { "category": "TerminalEmulator", "target": [ { "target": "deb", - "arch": ["x64"] + "arch": [ + "x64" + ] }, { "target": "AppImage", - "arch": ["x64"] + "arch": [ + "x64" + ] }, { "target": "rpm", - "arch": ["x64"] + "arch": [ + "x64" + ] } ] }, "win": { - "target": ["squirrel"] + "target": [ + "squirrel" + ] }, "mac": { "category": "public.app-category.developer-tools", @@ -143,6 +165,7 @@ "runes": "0.4.2", "seamless-immutable": "7.1.2", "semver": "5.4.1", + "util.promisify": "false1.0.0", "uuid": "3.1.0", "xterm": "2.9.2" }, diff --git a/yarn.lock b/yarn.lock index 2ade328a54d0..5b5e11fc87c8 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2303,7 +2303,7 @@ error-ex@^1.2.0: dependencies: is-arrayish "^0.2.1" -es-abstract@^1.7.0: +es-abstract@^1.5.1, es-abstract@^1.7.0: version "1.9.0" resolved "https://registry.yarnpkg.com/es-abstract/-/es-abstract-1.9.0.tgz#690829a07cae36b222e7fd9b75c0d0573eb25227" dependencies: @@ -4199,6 +4199,13 @@ object-keys@~0.4.0: version "0.4.0" resolved "https://registry.yarnpkg.com/object-keys/-/object-keys-0.4.0.tgz#28a6aae7428dd2c3a92f3d95f21335dd204e0336" +object.getownpropertydescriptors@^2.0.3: + version "2.0.3" + resolved "https://registry.yarnpkg.com/object.getownpropertydescriptors/-/object.getownpropertydescriptors-2.0.3.tgz#8758c846f5b407adab0f236e0986f14b051caa16" + dependencies: + define-properties "^1.1.2" + es-abstract "^1.5.1" + object.omit@^2.0.0: version "2.0.1" resolved "https://registry.yarnpkg.com/object.omit/-/object.omit-2.0.1.tgz#1a9c744829f39dbb858c76ca3579ae2a54ebd1fa" @@ -5955,6 +5962,13 @@ util-deprecate@~1.0.1: version "1.0.2" resolved "https://registry.yarnpkg.com/util-deprecate/-/util-deprecate-1.0.2.tgz#450d4dc9fa70de732762fbd2d4a28981419a0ccf" +util.promisify@false1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/util.promisify/-/util.promisify-1.0.0.tgz#440f7165a459c9a16dc145eb8e72f35687097030" + dependencies: + define-properties "^1.1.2" + object.getownpropertydescriptors "^2.0.3" + util@0.10.3, util@^0.10.3: version "0.10.3" resolved "https://registry.yarnpkg.com/util/-/util-0.10.3.tgz#7afb1afe50805246489e3db7fe0ed379336ac0f9" From 4916285c773eaae200b04293ced1fc16d3a35d1d Mon Sep 17 00:00:00 2001 From: CHaBou Date: Tue, 10 Oct 2017 09:05:06 +0200 Subject: [PATCH 02/30] Add cli building --- .gitignore | 1 + bin/cli.js | 1 - cli/index.js | 3 ++ webpack.config.js | 125 ++++++++++++++++++++++++++++++---------------- 4 files changed, 85 insertions(+), 45 deletions(-) delete mode 100644 bin/cli.js create mode 100644 cli/index.js diff --git a/.gitignore b/.gitignore index be68f684e6e2..e7a7992298e4 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ # build output dist app/renderer +bin/cli.js # dependencies node_modules diff --git a/bin/cli.js b/bin/cli.js deleted file mode 100644 index 829a81ee48d3..000000000000 --- a/bin/cli.js +++ /dev/null @@ -1 +0,0 @@ -console.log('CLI-Tool', process.argv); diff --git a/cli/index.js b/cli/index.js new file mode 100644 index 000000000000..2cf41cf4746b --- /dev/null +++ b/cli/index.js @@ -0,0 +1,3 @@ +// This is a CLI tool, using console is OK +/* eslint no-console: 0 */ +console.log('CLI-Tool', process.argv); diff --git a/webpack.config.js b/webpack.config.js index b9e7b50d30d6..9cacb6f31f55 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -6,48 +6,85 @@ const Copy = require('copy-webpack-plugin'); const nodeEnv = process.env.NODE_ENV || 'development'; const isProd = nodeEnv === 'production'; -module.exports = { - resolve: { - extensions: ['.js', '.jsx'] - }, - devtool: isProd ? 'hidden-source-map' : 'cheap-module-source-map', - entry: './lib/index.js', - output: { - path: path.join(__dirname, 'app', 'renderer'), - filename: 'bundle.js' - }, - module: { - rules: [ - { - test: /\.(js|jsx)$/, - exclude: /node_modules/, - loader: 'babel-loader' - }, - { - test: /\.json/, - loader: 'json-loader' - }, - // for xterm.js - { - test: /\.css$/, - loader: 'style-loader!css-loader' - } - ] - }, - plugins: [ - new webpack.IgnorePlugin(/.*\.js.map$/i), +module.exports = [ + { + name: 'hyper', + resolve: { + extensions: ['.js', '.jsx'] + }, + devtool: isProd ? 'hidden-source-map' : 'cheap-module-source-map', + entry: './lib/index.js', + output: { + path: path.join(__dirname, 'app', 'renderer'), + filename: 'bundle.js' + }, + module: { + rules: [ + { + test: /\.(js|jsx)$/, + exclude: /node_modules/, + loader: 'babel-loader' + }, + { + test: /\.json/, + loader: 'json-loader' + }, + // for xterm.js + { + test: /\.css$/, + loader: 'style-loader!css-loader' + } + ] + }, + plugins: [ + new webpack.IgnorePlugin(/.*\.js.map$/i), - new webpack.DefinePlugin({ - 'process.env': { - NODE_ENV: JSON.stringify(nodeEnv) - } - }), - new Copy([ - { - from: './assets', - to: './assets' - } - ]) - ], - target: 'electron' -}; + new webpack.DefinePlugin({ + 'process.env': { + NODE_ENV: JSON.stringify(nodeEnv) + } + }), + new Copy([ + { + from: './assets', + to: './assets' + } + ]) + ], + target: 'electron' + }, + { + name: 'hyper-cli', + resolve: { + extensions: ['.js', '.jsx'] + }, + devtool: isProd ? 'none' : 'cheap-module-source-map', + entry: './cli/index.js', + output: { + path: path.join(__dirname, 'bin'), + filename: 'cli.js' + }, + module: { + rules: [ + { + test: /\.(js|jsx)$/, + exclude: /node_modules/, + loader: 'babel-loader' + }, + { + test: /\.json/, + loader: 'json-loader' + } + ] + }, + plugins: [ + new webpack.IgnorePlugin(/.*\.js.map$/i), + new webpack.DefinePlugin({ + 'process.env': { + NODE_ENV: JSON.stringify(nodeEnv) + } + }) + ], + target: 'node' + } +]; From 3a38884c2910bd833ff0cbad93788dcc53601fde Mon Sep 17 00:00:00 2001 From: CHaBou Date: Tue, 10 Oct 2017 09:05:48 +0200 Subject: [PATCH 03/30] Replace util.promisify by pify --- app/utils/cli-install.js | 10 ++++---- package.json | 53 ++++++++++++++-------------------------- yarn.lock | 20 ++++----------- 3 files changed, 29 insertions(+), 54 deletions(-) diff --git a/app/utils/cli-install.js b/app/utils/cli-install.js index 128b48ad01ce..5591f50517ec 100644 --- a/app/utils/cli-install.js +++ b/app/utils/cli-install.js @@ -1,12 +1,12 @@ const {cliScriptPath} = require('../config/paths'); -const promisify = require('util.promisify'); +const pify = require('pify'); const fs = require('fs'); -const lstat = promisify(fs.lstat); -const readlink = promisify(fs.readlink); -const unlink = promisify(fs.unlink); -const symlink = promisify(fs.symlink); +const lstat = pify(fs.lstat); +const readlink = pify(fs.readlink); +const unlink = pify(fs.unlink); +const symlink = pify(fs.symlink); const target = process.platform === 'darwin' ? '/usr/local/bin/hyper' : '/usr/bin/hyper'; const source = cliScriptPath; diff --git a/package.json b/package.json index fbb6219f7972..11fecf3964b6 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,8 @@ { "repository": "zeit/hyper", "scripts": { - "start": "echo 'please run `yarn run dev` in one tab and then `yarn run app` in another one'", + "start": + "echo 'please run `yarn run dev` in one tab and then `yarn run app` in another one'", "app": "electron app", "dev": "webpack -w", "build": "cross-env NODE_ENV=production webpack", @@ -10,21 +11,18 @@ "test:unit": "ava test/unit", "test:unit:watch": "yarn run test:unit -- --watch", "prepush": "yarn test", - "postinstall": "electron-builder install-app-deps && yarn run rebuild-node-pty", - "rebuild-node-pty": "electron-rebuild -f -w app/node_modules/node-pty -m app", - "dist": "yarn run build && cross-env BABEL_ENV=production babel --out-file app/renderer/bundle.js --no-comments --minified app/renderer/bundle.js && build", - "clean": "node ./bin/rimraf-standalone.js node_modules && node ./bin/rimraf-standalone.js ./app/node_modules && node ./bin/rimraf-standalone.js ./app/renderer" + "postinstall": + "electron-builder install-app-deps && yarn run rebuild-node-pty", + "rebuild-node-pty": + "electron-rebuild -f -w app/node_modules/node-pty -m app", + "dist": + "yarn run build && cross-env BABEL_ENV=production babel --out-file app/renderer/bundle.js --no-comments --minified app/renderer/bundle.js && build", + "clean": + "node ./bin/rimraf-standalone.js node_modules && node ./bin/rimraf-standalone.js ./app/node_modules && node ./bin/rimraf-standalone.js ./app/renderer" }, "eslintConfig": { - "plugins": [ - "react", - "prettier" - ], - "extends": [ - "eslint:recommended", - "plugin:react/recommended", - "prettier" - ], + "plugins": ["react", "prettier"], + "extends": ["eslint:recommended", "plugin:react/recommended", "prettier"], "parserOptions": { "ecmaVersion": 8, "sourceType": "module", @@ -41,10 +39,7 @@ "node": true }, "rules": { - "func-names": [ - "error", - "as-needed" - ], + "func-names": ["error", "as-needed"], "no-shadow": "error", "no-extra-semi": 0, "react/prop-types": 0, @@ -69,9 +64,7 @@ } }, "babel": { - "presets": [ - "react" - ], + "presets": ["react"], "env": { "production": { "plugins": [ @@ -115,28 +108,20 @@ "target": [ { "target": "deb", - "arch": [ - "x64" - ] + "arch": ["x64"] }, { "target": "AppImage", - "arch": [ - "x64" - ] + "arch": ["x64"] }, { "target": "rpm", - "arch": [ - "x64" - ] + "arch": ["x64"] } ] }, "win": { - "target": [ - "squirrel" - ] + "target": ["squirrel"] }, "mac": { "category": "public.app-category.developer-tools", @@ -155,6 +140,7 @@ "json-loader": "0.5.7", "ms": "2.0.0", "php-escape-shell": "1.0.0", + "pify": "false3.0.0", "react": "16.0.0", "react-deep-force-update": "2.0.1", "react-dom": "16.0.0", @@ -165,7 +151,6 @@ "runes": "0.4.2", "seamless-immutable": "7.1.2", "semver": "5.4.1", - "util.promisify": "false1.0.0", "uuid": "3.1.0", "xterm": "2.9.2" }, diff --git a/yarn.lock b/yarn.lock index 5b5e11fc87c8..4e6d4fb93621 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2303,7 +2303,7 @@ error-ex@^1.2.0: dependencies: is-arrayish "^0.2.1" -es-abstract@^1.5.1, es-abstract@^1.7.0: +es-abstract@^1.7.0: version "1.9.0" resolved "https://registry.yarnpkg.com/es-abstract/-/es-abstract-1.9.0.tgz#690829a07cae36b222e7fd9b75c0d0573eb25227" dependencies: @@ -4199,13 +4199,6 @@ object-keys@~0.4.0: version "0.4.0" resolved "https://registry.yarnpkg.com/object-keys/-/object-keys-0.4.0.tgz#28a6aae7428dd2c3a92f3d95f21335dd204e0336" -object.getownpropertydescriptors@^2.0.3: - version "2.0.3" - resolved "https://registry.yarnpkg.com/object.getownpropertydescriptors/-/object.getownpropertydescriptors-2.0.3.tgz#8758c846f5b407adab0f236e0986f14b051caa16" - dependencies: - define-properties "^1.1.2" - es-abstract "^1.5.1" - object.omit@^2.0.0: version "2.0.1" resolved "https://registry.yarnpkg.com/object.omit/-/object.omit-2.0.1.tgz#1a9c744829f39dbb858c76ca3579ae2a54ebd1fa" @@ -4455,6 +4448,10 @@ pify@^2.0.0, pify@^2.3.0: version "2.3.0" resolved "https://registry.yarnpkg.com/pify/-/pify-2.3.0.tgz#ed141a6ac043a849ea588498e7dca8b15330e90c" +pify@false3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/pify/-/pify-3.0.0.tgz#e5a4acd2c101fdf3d9a4d07f0dbc4db49dd28176" + pinkie-promise@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/pinkie-promise/-/pinkie-promise-1.0.0.tgz#d1da67f5482563bb7cf57f286ae2822ecfbf3670" @@ -5962,13 +5959,6 @@ util-deprecate@~1.0.1: version "1.0.2" resolved "https://registry.yarnpkg.com/util-deprecate/-/util-deprecate-1.0.2.tgz#450d4dc9fa70de732762fbd2d4a28981419a0ccf" -util.promisify@false1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/util.promisify/-/util.promisify-1.0.0.tgz#440f7165a459c9a16dc145eb8e72f35687097030" - dependencies: - define-properties "^1.1.2" - object.getownpropertydescriptors "^2.0.3" - util@0.10.3, util@^0.10.3: version "0.10.3" resolved "https://registry.yarnpkg.com/util/-/util-0.10.3.tgz#7afb1afe50805246489e3db7fe0ed379336ac0f9" From a441d62dfd5fdfa7fffc7f5b25fc4eba48d3412a Mon Sep 17 00:00:00 2001 From: CHaBou Date: Tue, 10 Oct 2017 13:27:09 +0200 Subject: [PATCH 04/30] Remove util.promisify from app dep --- app/package.json | 1 - app/yarn.lock | 75 ------------------------------------------------ yarn.lock | 43 +++------------------------ 3 files changed, 4 insertions(+), 115 deletions(-) diff --git a/app/package.json b/app/package.json index 9cc479aa77c6..52c56f3cc088 100644 --- a/app/package.json +++ b/app/package.json @@ -27,7 +27,6 @@ "queue": "4.4.0", "semver": "5.4.1", "shell-env": "0.3.0", - "util.promisify": "false1.0.0", "uuid": "3.1.0", "winreg": "1.2.4" } diff --git a/app/yarn.lock b/app/yarn.lock index e0473062bc57..4196cc1065d6 100644 --- a/app/yarn.lock +++ b/app/yarn.lock @@ -78,13 +78,6 @@ default-shell@1.0.1, default-shell@^1.0.0: version "1.0.1" resolved "https://registry.yarnpkg.com/default-shell/-/default-shell-1.0.1.tgz#752304bddc6174f49eb29cb988feea0b8813c8bc" -define-properties@^1.1.2: - version "1.1.2" - resolved "https://registry.yarnpkg.com/define-properties/-/define-properties-1.1.2.tgz#83a73f2fea569898fb737193c8f873caf6d45c94" - dependencies: - foreach "^2.0.5" - object-keys "^1.0.8" - dot-prop@^4.1.0: version "4.2.0" resolved "https://registry.yarnpkg.com/dot-prop/-/dot-prop-4.2.0.tgz#1f19e0c2e1aa0e32797c49799f2837ac6af69c57" @@ -117,24 +110,6 @@ env-paths@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/env-paths/-/env-paths-1.0.0.tgz#4168133b42bb05c38a35b1ae4397c8298ab369e0" -es-abstract@^1.5.1: - version "1.9.0" - resolved "https://registry.yarnpkg.com/es-abstract/-/es-abstract-1.9.0.tgz#690829a07cae36b222e7fd9b75c0d0573eb25227" - dependencies: - es-to-primitive "^1.1.1" - function-bind "^1.1.1" - has "^1.0.1" - is-callable "^1.1.3" - is-regex "^1.0.4" - -es-to-primitive@^1.1.1: - version "1.1.1" - resolved "https://registry.yarnpkg.com/es-to-primitive/-/es-to-primitive-1.1.1.tgz#45355248a88979034b6792e19bb81f2b7975dd0d" - dependencies: - is-callable "^1.1.1" - is-date-object "^1.0.1" - is-symbol "^1.0.1" - execa@^0.5.0: version "0.5.1" resolved "https://registry.yarnpkg.com/execa/-/execa-0.5.1.tgz#de3fb85cb8d6e91c85bcbceb164581785cb57b36" @@ -157,14 +132,6 @@ find-up@^2.1.0: dependencies: locate-path "^2.0.0" -foreach@^2.0.5: - version "2.0.5" - resolved "https://registry.yarnpkg.com/foreach/-/foreach-2.0.5.tgz#0bee005018aeb260d0a3af3ae658dd0136ec1b99" - -function-bind@^1.0.2, function-bind@^1.1.1: - version "1.1.1" - resolved "https://registry.yarnpkg.com/function-bind/-/function-bind-1.1.1.tgz#a56899d3ea3c9bab874bb9773b7c5ede92f4895d" - get-stream@^2.2.0: version "2.3.1" resolved "https://registry.yarnpkg.com/get-stream/-/get-stream-2.3.1.tgz#5f38f93f346009666ee0150a054167f91bdd95de" @@ -184,12 +151,6 @@ graceful-fs@^4.1.11: version "4.1.11" resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.1.11.tgz#0e8bdfe4d1ddb8854d64e04ea7c00e2a026e5658" -has@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/has/-/has-1.0.1.tgz#8461733f538b0837c9361e39a9ab9e9704dc2f28" - dependencies: - function-bind "^1.0.2" - iconv-lite@~0.4.13: version "0.4.19" resolved "https://registry.yarnpkg.com/iconv-lite/-/iconv-lite-0.4.19.tgz#f7468f60135f5e5dad3399c0a81be9a1603a082b" @@ -206,38 +167,20 @@ is-arrayish@^0.3.1: version "0.3.1" resolved "https://registry.yarnpkg.com/is-arrayish/-/is-arrayish-0.3.1.tgz#c2dfc386abaa0c3e33c48db3fe87059e69065efd" -is-callable@^1.1.1, is-callable@^1.1.3: - version "1.1.3" - resolved "https://registry.yarnpkg.com/is-callable/-/is-callable-1.1.3.tgz#86eb75392805ddc33af71c92a0eedf74ee7604b2" - is-css-color-name@^0.1.1: version "0.1.3" resolved "https://registry.yarnpkg.com/is-css-color-name/-/is-css-color-name-0.1.3.tgz#ea3b51bc901d8a243d32c9b7873d0680dbbef7f1" dependencies: css-color-names "0.0.2" -is-date-object@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/is-date-object/-/is-date-object-1.0.1.tgz#9aa20eb6aeebbff77fbd33e74ca01b33581d3a16" - is-obj@^1.0.0: version "1.0.1" resolved "https://registry.yarnpkg.com/is-obj/-/is-obj-1.0.1.tgz#3e4729ac1f5fde025cd7d83a896dab9f4f67db0f" -is-regex@^1.0.4: - version "1.0.4" - resolved "https://registry.yarnpkg.com/is-regex/-/is-regex-1.0.4.tgz#5517489b547091b0930e095654ced25ee97e9491" - dependencies: - has "^1.0.1" - is-stream@^1.0.1, is-stream@^1.1.0: version "1.1.0" resolved "https://registry.yarnpkg.com/is-stream/-/is-stream-1.1.0.tgz#12d4a3dd4e68e0b79ceb8dbc84173ae80d91ca44" -is-symbol@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/is-symbol/-/is-symbol-1.0.1.tgz#3cc59f00025194b6ab2e38dbae6689256b660572" - isexe@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/isexe/-/isexe-2.0.0.tgz#e8fbf374dc556ff8947a10dcb0572d633f2cfa10" @@ -307,17 +250,6 @@ object-assign@^4.0.1: version "4.1.1" resolved "https://registry.yarnpkg.com/object-assign/-/object-assign-4.1.1.tgz#2109adc7965887cfc05cbbd442cac8bfbb360863" -object-keys@^1.0.8: - version "1.0.11" - resolved "https://registry.yarnpkg.com/object-keys/-/object-keys-1.0.11.tgz#c54601778ad560f1142ce0e01bcca8b56d13426d" - -object.getownpropertydescriptors@^2.0.3: - version "2.0.3" - resolved "https://registry.yarnpkg.com/object.getownpropertydescriptors/-/object.getownpropertydescriptors-2.0.3.tgz#8758c846f5b407adab0f236e0986f14b051caa16" - dependencies: - define-properties "^1.1.2" - es-abstract "^1.5.1" - p-finally@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/p-finally/-/p-finally-1.0.0.tgz#3fbcfb15b899a44123b34b6dcc18b724336a2cae" @@ -406,13 +338,6 @@ strip-eof@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/strip-eof/-/strip-eof-1.0.0.tgz#bb43ff5598a6eb05d89b59fcd129c983313606bf" -util.promisify@false1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/util.promisify/-/util.promisify-1.0.0.tgz#440f7165a459c9a16dc145eb8e72f35687097030" - dependencies: - define-properties "^1.1.2" - object.getownpropertydescriptors "^2.0.3" - uuid@3.1.0: version "3.1.0" resolved "https://registry.yarnpkg.com/uuid/-/uuid-3.1.0.tgz#3dd3d3e790abc24d7b0d3a034ffababe28ebbc04" diff --git a/yarn.lock b/yarn.lock index 4e6d4fb93621..35b8ba139dff 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1061,14 +1061,10 @@ balanced-match@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.0.tgz#89b4d199ab2bee49de164ea02b89ce462d71b767" -base64-js@1.2.0: +base64-js@1.2.0, base64-js@^1.0.2: version "1.2.0" resolved "https://registry.yarnpkg.com/base64-js/-/base64-js-1.2.0.tgz#a39992d723584811982be5e290bb6a53d86700f1" -base64-js@^1.0.2: - version "1.2.1" - resolved "https://registry.yarnpkg.com/base64-js/-/base64-js-1.2.1.tgz#a91947da1f4a516ea38e5b4ec0ec3773675e0886" - bcrypt-pbkdf@^1.0.0: version "1.0.1" resolved "https://registry.yarnpkg.com/bcrypt-pbkdf/-/bcrypt-pbkdf-1.0.1.tgz#63bc5dcb61331b92bc05fd528953c33462a06f8d" @@ -1253,7 +1249,7 @@ builder-util-runtime@1.0.6, builder-util-runtime@^1.0.5, builder-util-runtime@^1 debug "^3.1.0" fs-extra-p "^4.4.2" -builder-util@2.0.6: +builder-util@2.0.6, builder-util@^2.0.2, builder-util@^2.0.5, builder-util@^2.0.6: version "2.0.6" resolved "https://registry.yarnpkg.com/builder-util/-/builder-util-2.0.6.tgz#2a3eec93c77709e45f879c2eccdcbe5f29a70271" dependencies: @@ -1274,27 +1270,6 @@ builder-util@2.0.6: temp-file "^2.0.3" tunnel-agent "^0.6.0" -builder-util@^2.0.2, builder-util@^2.0.5, builder-util@^2.0.6: - version "2.0.7" - resolved "https://registry.yarnpkg.com/builder-util/-/builder-util-2.0.7.tgz#f6172303561d7fbf8944d5989bce806ffc76480f" - dependencies: - "7zip-bin" "^2.2.4" - bluebird-lst "^1.0.3" - builder-util-runtime "^1.0.6" - chalk "^2.1.0" - debug "^3.1.0" - fs-extra-p "^4.4.2" - ini "^1.3.4" - is-ci "^1.0.10" - js-yaml "^3.10.0" - lazy-val "^1.0.2" - node-emoji "^1.8.1" - semver "^5.4.1" - source-map-support "^0.5.0" - stat-mode "^0.2.2" - temp-file "^2.0.3" - tunnel-agent "^0.6.0" - builtin-modules@^1.0.0: version "1.1.1" resolved "https://registry.yarnpkg.com/builtin-modules/-/builtin-modules-1.1.1.tgz#270f076c5a72c02f5b65a47df94c5fe3a278892f" @@ -3962,7 +3937,7 @@ minimalistic-crypto-utils@^1.0.0, minimalistic-crypto-utils@^1.0.1: dependencies: brace-expansion "^1.1.7" -minimist@0.0.8: +minimist@0.0.8, minimist@~0.0.1: version "0.0.8" resolved "https://registry.yarnpkg.com/minimist/-/minimist-0.0.8.tgz#857fcabfc3397d2625b8228262e86aa7a011b05d" @@ -3970,10 +3945,6 @@ minimist@^1.1.0, minimist@^1.1.3, minimist@^1.2.0: version "1.2.0" resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.0.tgz#a35008b20f41383eec1fb914f4cd5df79a264284" -minimist@~0.0.1: - version "0.0.10" - resolved "https://registry.yarnpkg.com/minimist/-/minimist-0.0.10.tgz#de3f98543dbf96082be48ad1a0c7cda836301dcf" - mkdirp@0.5.0: version "0.5.0" resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-0.5.0.tgz#1d73076a6df986cd9344e15e71fcc05a4c9abf12" @@ -5425,12 +5396,6 @@ source-map-support@^0.4.0, source-map-support@^0.4.15, source-map-support@^0.4.1 dependencies: source-map "^0.5.6" -source-map-support@^0.5.0: - version "0.5.0" - resolved "https://registry.yarnpkg.com/source-map-support/-/source-map-support-0.5.0.tgz#2018a7ad2bdf8faf2691e5fddab26bed5a2bacab" - dependencies: - source-map "^0.6.0" - source-map-url@~0.3.0: version "0.3.0" resolved "https://registry.yarnpkg.com/source-map-url/-/source-map-url-0.3.0.tgz#7ecaf13b57bcd09da8a40c5d269db33799d4aaf9" @@ -5445,7 +5410,7 @@ source-map@^0.5.0, source-map@^0.5.3, source-map@^0.5.6, source-map@~0.5.1, sour version "0.5.7" resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.5.7.tgz#8a039d2d1021d22d1ea14c80d8ea468ba2ef3fcc" -source-map@^0.6.0, source-map@^0.6.1: +source-map@^0.6.1: version "0.6.1" resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.6.1.tgz#74722af32e9614e9c287a8d0bbde48b5e2f1a263" From 618a8cb58ec819a3baf1d0f6a447707809182e7e Mon Sep 17 00:00:00 2001 From: CHaBou Date: Tue, 10 Oct 2017 13:27:48 +0200 Subject: [PATCH 05/30] Use implicit return in promise chains --- app/utils/cli-install.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/utils/cli-install.js b/app/utils/cli-install.js index 5591f50517ec..90d6b03d1617 100644 --- a/app/utils/cli-install.js +++ b/app/utils/cli-install.js @@ -12,7 +12,7 @@ const target = process.platform === 'darwin' ? '/usr/local/bin/hyper' : '/usr/bi const source = cliScriptPath; const checkInstall = () => { - return lstat(target) + lstat(target) .then(stat => stat.isSymbolicLink()) .then(() => readlink(target)) .then(link => link === source) @@ -25,7 +25,7 @@ const checkInstall = () => { }; const createSymlink = () => { - return unlink(target) + unlink(target) .catch(err => { if (err.code === 'ENOENT') { return; @@ -36,7 +36,7 @@ const createSymlink = () => { }; exports.addSymlink = () => { - return checkInstall().then(isInstalled => { + checkInstall().then(isInstalled => { if (isInstalled) { return Promise.resolve(); } From 1f670c892301aa9c8633044a9b082eee079113dd Mon Sep 17 00:00:00 2001 From: CHaBou Date: Tue, 10 Oct 2017 14:39:07 +0200 Subject: [PATCH 06/30] Explicit returns in promise chaining --- app/utils/cli-install.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/utils/cli-install.js b/app/utils/cli-install.js index 90d6b03d1617..5591f50517ec 100644 --- a/app/utils/cli-install.js +++ b/app/utils/cli-install.js @@ -12,7 +12,7 @@ const target = process.platform === 'darwin' ? '/usr/local/bin/hyper' : '/usr/bi const source = cliScriptPath; const checkInstall = () => { - lstat(target) + return lstat(target) .then(stat => stat.isSymbolicLink()) .then(() => readlink(target)) .then(link => link === source) @@ -25,7 +25,7 @@ const checkInstall = () => { }; const createSymlink = () => { - unlink(target) + return unlink(target) .catch(err => { if (err.code === 'ENOENT') { return; @@ -36,7 +36,7 @@ const createSymlink = () => { }; exports.addSymlink = () => { - checkInstall().then(isInstalled => { + return checkInstall().then(isInstalled => { if (isInstalled) { return Promise.resolve(); } From 5ac8dfd5c7a6ab97fba4e4e6c124e8328f29ef6b Mon Sep 17 00:00:00 2001 From: CHaBou Date: Mon, 16 Oct 2017 21:54:49 +0200 Subject: [PATCH 07/30] Fix path for linux --- app/utils/cli-install.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/utils/cli-install.js b/app/utils/cli-install.js index 5591f50517ec..5951448567de 100644 --- a/app/utils/cli-install.js +++ b/app/utils/cli-install.js @@ -8,7 +8,7 @@ const readlink = pify(fs.readlink); const unlink = pify(fs.unlink); const symlink = pify(fs.symlink); -const target = process.platform === 'darwin' ? '/usr/local/bin/hyper' : '/usr/bin/hyper'; +const target = '/usr/local/bin/hyper'; const source = cliScriptPath; const checkInstall = () => { From 02df9d42ffc38b4ef2508f1a1f89b3ef1e562058 Mon Sep 17 00:00:00 2001 From: CHaBou Date: Wed, 11 Oct 2017 00:41:26 +0200 Subject: [PATCH 08/30] Working cli on macOS --- .gitignore | 2 +- cli/api.js | 112 ++++++++++++++++++++++++++ cli/index.js | 180 +++++++++++++++++++++++++++++++++++++++++- package.json | 62 ++++++++++----- webpack.config.js | 14 ++-- yarn.lock | 195 ++++++++++++++++++++++++++++++++++++++++------ 6 files changed, 513 insertions(+), 52 deletions(-) create mode 100644 cli/api.js diff --git a/.gitignore b/.gitignore index e7a7992298e4..b2887952d29c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,7 @@ # build output dist app/renderer -bin/cli.js +bin/cli.* # dependencies node_modules diff --git a/cli/api.js b/cli/api.js new file mode 100644 index 000000000000..41f3a7c09b4a --- /dev/null +++ b/cli/api.js @@ -0,0 +1,112 @@ +const fs = require('fs'); +const os = require('os'); +const npmName = () => Promise.resolve(); //require('npm-name'); +const pify = require('pify'); +const recast = require('recast'); + +const fileName = `${os.homedir()}/.hyper.js`; + +let fileContents; +let parsedFile; +let plugins; +let localPlugins; + +try { + fileContents = fs.readFileSync(fileName, 'utf8'); + + parsedFile = recast.parse(fileContents); + + const properties = parsedFile.program.body[0].expression.right.properties; + plugins = properties.find(property => { + return property.key.name === 'plugins'; + }).value.elements; + + localPlugins = properties.find(property => { + return property.key.name === 'localPlugins'; + }).value.elements; +} catch (err) { + if (err.code !== 'ENOENT') { + // ENOENT === !exists() + throw err; + } +} + +function exists() { + return fileContents !== undefined; +} + +function isInstalled(plugin, locally) { + const array = locally ? localPlugins : plugins; + if (array && Array.isArray(array)) { + return array.find(entry => entry.value === plugin) !== undefined; + } + return false; +} + +function save() { + return pify(fs.writeFile)(fileName, recast.print(parsedFile).code, 'utf8'); +} + +function existsOnNpm(plugin) { + plugin = plugin.split('#')[0].split('@')[0]; + return npmName(plugin).then(unavailable => { + if (unavailable) { + const err = new Error(`${plugin} not found on npm`); + err.code = 'NOT_FOUND_ON_NPM'; + throw err; + } + }); +} + +function install(plugin, locally) { + const array = locally ? localPlugins : plugins; + return new Promise((resolve, reject) => { + existsOnNpm(plugin) + .then(() => { + if (isInstalled(plugin, locally)) { + return reject(`${plugin} is already installed`); + } + + array.push(recast.types.builders.literal(plugin)); + save() + .then(resolve) + .catch(err => reject(err)); + }) + .catch(err => { + if (err.code === 'NOT_FOUND_ON_NPM') { + reject(err.message); + } else { + reject(err); + } + }); + }); +} + +function uninstall(plugin) { + return new Promise((resolve, reject) => { + if (!isInstalled(plugin)) { + return reject(`${plugin} is not installed`); + } + + const index = plugins.findIndex(entry => entry.value === plugin); + plugins.splice(index, 1); + save() + .then(resolve) + .catch(err => reject(err)); + }); +} + +function list() { + if (Array.isArray(plugins)) { + return plugins.map(plugin => plugin.value).join('\n'); + } + return false; +} + +module.exports.configPath = fileName; +module.exports.exists = exists; +module.exports.existsOnNpm = existsOnNpm; +module.exports.isInstalled = isInstalled; +module.exports.install = install; +module.exports.uninstall = uninstall; +module.exports.list = list; diff --git a/cli/index.js b/cli/index.js index 2cf41cf4746b..b4c4e978edf8 100644 --- a/cli/index.js +++ b/cli/index.js @@ -1,3 +1,181 @@ // This is a CLI tool, using console is OK /* eslint no-console: 0 */ -console.log('CLI-Tool', process.argv); +const {spawn} = require('child_process'); +const args = require('args'); +const chalk = require('chalk'); +const columnify = require('columnify'); +const got = require('got'); +const opn = require('opn'); +const ora = require('ora'); +const api = require('./api'); + +let commandUsed = false; + +if (!api.exists()) { + let msg = chalk.red(`Error! Config file not found: ${api.configPath}\n`); + msg += 'Please launch Hyper and retry.'; + console.error(msg); + process.exit(1); +} + +args.command(['i', 'install'], 'Install a plugin', (name, args_) => { + commandUsed = true; + const plugin = args_[0]; + return api + .install(plugin) + .then(() => console.log(chalk.green(`${plugin} installed successfully!`))) + .catch(err => console.error(chalk.red(err))); +}); + +args.command(['u', 'uninstall', 'rm', 'remove'], 'Uninstall a plugin', (name, args_) => { + commandUsed = true; + const plugin = args_[0]; + return api + .uninstall(plugin) + .then(() => console.log(chalk.green(`${plugin} uninstalled successfully!`))) + .catch(err => console.log(chalk.red(err))); +}); + +args.command(['ls', 'list'], 'List installed plugins', () => { + commandUsed = true; + let plugins = api.list(); + + if (plugins) { + console.log(plugins); + } else { + console.log(chalk.red(`No plugins installed yet.`)); + } + process.exit(1); +}); + +const lsRemote = () => { + // note that no errors are catched by this function + const URL = + 'http://registry.npmjs.org/-/_view/byKeyword?startkey=[%22hyperterm%22,%22hyper%22]&endkey=[%22hyperterm%22,{}]&group_level=4'; + return got(URL) + .then(response => JSON.parse(response.body).rows) + .then(entries => entries.map(entry => entry.key)) + .then(entries => + entries.map(entry => { + return {name: entry[1], description: entry[2]}; + }) + ) + .then(entries => + entries.map(entry => { + entry.name = chalk.green(entry.name); + return entry; + }) + ); +}; + +args.command(['s', 'search'], 'Search for plugins on npm', (name, args_) => { + commandUsed = true; + const spinner = ora('Searching').start(); + const query = args_[0] ? args_[0].toLowerCase() : ''; + + return lsRemote() + .then(entries => { + return entries.filter(entry => { + return entry.name.indexOf(query) !== -1 || entry.description.toLowerCase().indexOf(query) !== -1; + }); + }) + .then(entries => { + if (entries.length === 0) { + spinner.fail(); + console.error(chalk.red(`Your search '${query}' did not match any plugins`)); + console.error(`${chalk.red('Try')} ${chalk.green('hpm ls-remote')}`); + process.exit(1); + } else { + let msg = columnify(entries); + spinner.succeed(); + msg = msg.substring(msg.indexOf('\n') + 1); // remove header + console.log(msg); + } + }) + .catch(err => { + spinner.fail(); + console.error(chalk.red(err)); // TODO + }); +}); + +args.command(['lsr', 'list-remote', 'ls-remote'], 'List plugins available on npm', () => { + commandUsed = true; + const spinner = ora('Searching').start(); + + return lsRemote() + .then(entries => { + let msg = columnify(entries); + + spinner.succeed(); + msg = msg.substring(msg.indexOf('\n') + 1); // remove header + console.log(msg); + }) + .catch(err => { + spinner.fail(); + console.error(chalk.red(err)); // TODO + }); +}); + +args.command(['d', 'docs', 'h', 'home'], 'Open the npm page of a plugin', (name, args_) => { + commandUsed = true; + return opn(`http://ghub.io/${args_[0]}`, {wait: false}); +}); + +args.option(['v', 'verbose'], 'Verbose mode', false); + +const main = argv => { + const flags = args.parse(argv, { + version: false + }); + + if (commandUsed) { + return Promise.resolve(); + } + + console.log('flags', flags); + + const env = Object.assign({}, process.env, { + // this will signal Hyper that it was spawned from this module + HYPER_CLI: '1', + ELECTRON_NO_ATTACH_CONSOLE: '1' + }); + + delete env['ELECTRON_RUN_AS_NODE']; + + if (flags.verbose) { + env['ELECTRON_ENABLE_LOGGING'] = '1'; + } + + const options = { + detached: true, + env + }; + + if (!flags.verbose) { + options['stdio'] = 'ignore'; + } + + const args_ = args.sub; + const child = spawn(process.execPath, args_, options); + + if (flags.verbose) { + child.stdout.on('data', data => console.log(data.toString('utf8'))); + child.stderr.on('data', data => console.error(data.toString('utf8'))); + } + if (flags.verbose) { + return new Promise(c => child.once('exit', () => c(null))); + } + child.unref(); + return Promise.resolve(); +}; + +function eventuallyExit(code) { + setTimeout(() => process.exit(code), 100); +} + +main(process.argv) + .then(() => eventuallyExit(0)) + .catch(err => { + console.error(err.stack ? err.stack : err); + eventuallyExit(1); + }); diff --git a/package.json b/package.json index 11fecf3964b6..d5ad1d4083ff 100644 --- a/package.json +++ b/package.json @@ -1,8 +1,7 @@ { "repository": "zeit/hyper", "scripts": { - "start": - "echo 'please run `yarn run dev` in one tab and then `yarn run app` in another one'", + "start": "echo 'please run `yarn run dev` in one tab and then `yarn run app` in another one'", "app": "electron app", "dev": "webpack -w", "build": "cross-env NODE_ENV=production webpack", @@ -11,18 +10,21 @@ "test:unit": "ava test/unit", "test:unit:watch": "yarn run test:unit -- --watch", "prepush": "yarn test", - "postinstall": - "electron-builder install-app-deps && yarn run rebuild-node-pty", - "rebuild-node-pty": - "electron-rebuild -f -w app/node_modules/node-pty -m app", - "dist": - "yarn run build && cross-env BABEL_ENV=production babel --out-file app/renderer/bundle.js --no-comments --minified app/renderer/bundle.js && build", - "clean": - "node ./bin/rimraf-standalone.js node_modules && node ./bin/rimraf-standalone.js ./app/node_modules && node ./bin/rimraf-standalone.js ./app/renderer" + "postinstall": "electron-builder install-app-deps && yarn run rebuild-node-pty", + "rebuild-node-pty": "electron-rebuild -f -w app/node_modules/node-pty -m app", + "dist": "yarn run build && cross-env BABEL_ENV=production babel --out-file app/renderer/bundle.js --no-comments --minified app/renderer/bundle.js && build", + "clean": "node ./bin/rimraf-standalone.js node_modules && node ./bin/rimraf-standalone.js ./app/node_modules && node ./bin/rimraf-standalone.js ./app/renderer" }, "eslintConfig": { - "plugins": ["react", "prettier"], - "extends": ["eslint:recommended", "plugin:react/recommended", "prettier"], + "plugins": [ + "react", + "prettier" + ], + "extends": [ + "eslint:recommended", + "plugin:react/recommended", + "prettier" + ], "parserOptions": { "ecmaVersion": 8, "sourceType": "module", @@ -39,7 +41,10 @@ "node": true }, "rules": { - "func-names": ["error", "as-needed"], + "func-names": [ + "error", + "as-needed" + ], "no-shadow": "error", "no-extra-semi": 0, "react/prop-types": 0, @@ -64,7 +69,9 @@ } }, "babel": { - "presets": ["react"], + "presets": [ + "react" + ], "env": { "production": { "plugins": [ @@ -108,20 +115,28 @@ "target": [ { "target": "deb", - "arch": ["x64"] + "arch": [ + "x64" + ] }, { "target": "AppImage", - "arch": ["x64"] + "arch": [ + "x64" + ] }, { "target": "rpm", - "arch": ["x64"] + "arch": [ + "x64" + ] } ] }, "win": { - "target": ["squirrel"] + "target": [ + "squirrel" + ] }, "mac": { "category": "public.app-category.developer-tools", @@ -135,22 +150,31 @@ }, "dependencies": { "aphrodite-simple": "0.4.1", + "args": "3.0.6", + "chalk": "2.1.0", "color": "2.0.0", + "columnify": "1.5.4", "css-loader": "0.28.4", + "got": "7.1.0", "json-loader": "0.5.7", "ms": "2.0.0", + "npm-name": "3.1.0", + "opn": "5.1.0", + "ora": "1.3.0", "php-escape-shell": "1.0.0", - "pify": "false3.0.0", + "pify": "3.0.0", "react": "16.0.0", "react-deep-force-update": "2.0.1", "react-dom": "16.0.0", "react-redux": "5.0.6", + "recast": "0.12.6", "redux": "3.7.2", "redux-thunk": "2.2.0", "reselect": "3.0.1", "runes": "0.4.2", "seamless-immutable": "7.1.2", "semver": "5.4.1", + "shebang-loader": "false0.0.1", "uuid": "3.1.0", "xterm": "2.9.2" }, diff --git a/webpack.config.js b/webpack.config.js index 9cacb6f31f55..c0d88ffefa52 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -56,7 +56,7 @@ module.exports = [ { name: 'hyper-cli', resolve: { - extensions: ['.js', '.jsx'] + extensions: ['.js', '.jsx', '.json'] }, devtool: isProd ? 'none' : 'cheap-module-source-map', entry: './cli/index.js', @@ -72,17 +72,17 @@ module.exports = [ loader: 'babel-loader' }, { - test: /\.json/, - loader: 'json-loader' + test: /index.js/, + loader: 'shebang-loader', + include: [/node_modules\/rc/] } ] }, plugins: [ - new webpack.IgnorePlugin(/.*\.js.map$/i), + // spawn-sync is required by execa if node <= 0.10 + new webpack.IgnorePlugin(/(.*\.js.map|spawn-sync)$/i), new webpack.DefinePlugin({ - 'process.env': { - NODE_ENV: JSON.stringify(nodeEnv) - } + 'process.env.NODE_ENV': JSON.stringify(nodeEnv) }) ], target: 'node' diff --git a/yarn.lock b/yarn.lock index 35b8ba139dff..75d8878206f6 100644 --- a/yarn.lock +++ b/yarn.lock @@ -257,6 +257,16 @@ argparse@^1.0.7: dependencies: sprintf-js "~1.0.2" +args@3.0.6: + version "3.0.6" + resolved "https://registry.yarnpkg.com/args/-/args-3.0.6.tgz#2c323409dd84ffeac97979bb70c7836bb8aafd4a" + dependencies: + camelcase "4.1.0" + chalk "2.1.0" + mri "1.1.0" + pkginfo "0.4.1" + string-similarity "1.2.0" + arr-diff@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/arr-diff/-/arr-diff-2.0.0.tgz#8f3b827f955a8bd669697e4a4256ac3ceae356cf" @@ -341,6 +351,10 @@ assert@^1.1.1: dependencies: util "0.10.3" +ast-types@0.9.11: + version "0.9.11" + resolved "https://registry.yarnpkg.com/ast-types/-/ast-types-0.9.11.tgz#371177bb59232ff5ceaa1d09ee5cad705b1a5aa9" + async-each@^1.0.0: version "1.0.1" resolved "https://registry.yarnpkg.com/async-each/-/async-each-1.0.1.tgz#19d386a1d9edc6e7c1c85d388aedbcc56d33602d" @@ -1316,6 +1330,10 @@ camelcase-keys@^2.0.0: camelcase "^2.0.0" map-obj "^1.0.0" +camelcase@4.1.0, camelcase@^4.0.0, camelcase@^4.1.0: + version "4.1.0" + resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-4.1.0.tgz#d545635be1e33c542649c69173e5de6acfae34dd" + camelcase@^1.0.2: version "1.2.1" resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-1.2.1.tgz#9bb5304d2e0b56698b2c758b08a3eaa9daa58a39" @@ -1328,10 +1346,6 @@ camelcase@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-3.0.0.tgz#32fc4b9fcdaf845fcdf7e73bb97cac2261f0ab0a" -camelcase@^4.0.0, camelcase@^4.1.0: - version "4.1.0" - resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-4.1.0.tgz#d545635be1e33c542649c69173e5de6acfae34dd" - caniuse-api@^1.5.2: version "1.6.1" resolved "https://registry.yarnpkg.com/caniuse-api/-/caniuse-api-1.6.1.tgz#b534e7c734c4f81ec5fbe8aca2ad24354b962c6c" @@ -1360,6 +1374,14 @@ center-align@^0.1.1: align-text "^0.1.3" lazy-cache "^1.0.3" +chalk@2.1.0, chalk@^2.0.0, chalk@^2.0.1, chalk@^2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/chalk/-/chalk-2.1.0.tgz#ac5becf14fa21b99c6c92ca7a7d7cfd5b17e743e" + dependencies: + ansi-styles "^3.1.0" + escape-string-regexp "^1.0.5" + supports-color "^4.0.0" + chalk@^0.4.0: version "0.4.0" resolved "https://registry.yarnpkg.com/chalk/-/chalk-0.4.0.tgz#5199a3ddcd0c1efe23bc08c1b027b06176e0c64f" @@ -1378,14 +1400,6 @@ chalk@^1.0.0, chalk@^1.1.1, chalk@^1.1.3: strip-ansi "^3.0.0" supports-color "^2.0.0" -chalk@^2.0.0, chalk@^2.0.1, chalk@^2.1.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/chalk/-/chalk-2.1.0.tgz#ac5becf14fa21b99c6c92ca7a7d7cfd5b17e743e" - dependencies: - ansi-styles "^3.1.0" - escape-string-regexp "^1.0.5" - supports-color "^4.0.0" - chokidar@^1.4.2, chokidar@^1.6.1, chokidar@^1.7.0: version "1.7.0" resolved "https://registry.yarnpkg.com/chokidar/-/chokidar-1.7.0.tgz#798e689778151c8076b4b360e5edd28cda2bb468" @@ -1559,6 +1573,13 @@ colors@^1.1.2, colors@~1.1.2: version "1.1.2" resolved "https://registry.yarnpkg.com/colors/-/colors-1.1.2.tgz#168a4701756b6a7f51a12ce0c97bfa28c084ed63" +columnify@1.5.4: + version "1.5.4" + resolved "https://registry.yarnpkg.com/columnify/-/columnify-1.5.4.tgz#4737ddf1c7b69a8a7c340570782e947eec8e78bb" + dependencies: + strip-ansi "^3.0.0" + wcwidth "^1.0.0" + combined-stream@^1.0.5, combined-stream@~1.0.5: version "1.0.5" resolved "https://registry.yarnpkg.com/combined-stream/-/combined-stream-1.0.5.tgz#938370a57b4a51dea2c77c15d5c5fdf895164009" @@ -1675,7 +1696,7 @@ core-js@^1.0.0: version "1.2.7" resolved "https://registry.yarnpkg.com/core-js/-/core-js-1.2.7.tgz#652294c14651db28fa93bd2d5ff2983a4f08c636" -core-js@^2.0.0, core-js@^2.4.0, core-js@^2.5.0: +core-js@^2.0.0, core-js@^2.4.0, core-js@^2.4.1, core-js@^2.5.0: version "2.5.1" resolved "https://registry.yarnpkg.com/core-js/-/core-js-2.5.1.tgz#ae6874dc66937789b80754ff5428df66819ca50b" @@ -1933,6 +1954,12 @@ decamelize@^1.0.0, decamelize@^1.1.1, decamelize@^1.1.2: version "1.2.0" resolved "https://registry.yarnpkg.com/decamelize/-/decamelize-1.2.0.tgz#f6534d15148269b20352e7bee26f501f9a191290" +decompress-response@^3.2.0: + version "3.3.0" + resolved "https://registry.yarnpkg.com/decompress-response/-/decompress-response-3.3.0.tgz#80a4dd323748384bfa248083622aedec982adff3" + dependencies: + mimic-response "^1.0.0" + deep-equal@^1.0.0: version "1.0.1" resolved "https://registry.yarnpkg.com/deep-equal/-/deep-equal-1.0.1.tgz#f5d260292b660e084eff4cdbc9f08ad3247448b5" @@ -1949,6 +1976,12 @@ deepmerge@~1.3.2: version "1.3.2" resolved "https://registry.yarnpkg.com/deepmerge/-/deepmerge-1.3.2.tgz#1663691629d4dbfe364fa12a2a4f0aa86aa3a050" +defaults@^1.0.3: + version "1.0.3" + resolved "https://registry.yarnpkg.com/defaults/-/defaults-1.0.3.tgz#c656051e9817d9ff08ed881477f3fe4019f3ef7d" + dependencies: + clone "^1.0.2" + define-properties@^1.1.2: version "1.1.2" resolved "https://registry.yarnpkg.com/define-properties/-/define-properties-1.1.2.tgz#83a73f2fea569898fb737193c8f873caf6d45c94" @@ -2460,7 +2493,7 @@ esprima@^2.6.0: version "2.7.3" resolved "https://registry.yarnpkg.com/esprima/-/esprima-2.7.3.tgz#96e3b70d5779f6ad49cd032673d1c312767ba581" -esprima@^4.0.0: +esprima@^4.0.0, esprima@~4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/esprima/-/esprima-4.0.0.tgz#4499eddcd1110e0b218bacf2fa7f7f59f55ca804" @@ -2903,6 +2936,25 @@ globule@^1.0.0: lodash "~4.17.4" minimatch "~3.0.2" +got@7.1.0, got@^7.0.0: + version "7.1.0" + resolved "https://registry.yarnpkg.com/got/-/got-7.1.0.tgz#05450fd84094e6bbea56f451a43a9c289166385a" + dependencies: + decompress-response "^3.2.0" + duplexer3 "^0.1.4" + get-stream "^3.0.0" + is-plain-obj "^1.1.0" + is-retry-allowed "^1.0.0" + is-stream "^1.0.0" + isurl "^1.0.0-alpha5" + lowercase-keys "^1.0.0" + p-cancelable "^0.3.0" + p-timeout "^1.1.1" + safe-buffer "^5.0.1" + timed-out "^4.0.0" + url-parse-lax "^1.0.0" + url-to-options "^1.0.1" + got@^6.7.1: version "6.7.1" resolved "https://registry.yarnpkg.com/got/-/got-6.7.1.tgz#240cd05785a9a18e561dc1b44b41c763ef1e8db0" @@ -2963,6 +3015,16 @@ has-flag@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/has-flag/-/has-flag-2.0.0.tgz#e8207af1cc7b30d446cc70b734b5e8be18f88d51" +has-symbol-support-x@^1.4.1: + version "1.4.1" + resolved "https://registry.yarnpkg.com/has-symbol-support-x/-/has-symbol-support-x-1.4.1.tgz#66ec2e377e0c7d7ccedb07a3a84d77510ff1bc4c" + +has-to-string-tag-x@^1.2.0: + version "1.4.1" + resolved "https://registry.yarnpkg.com/has-to-string-tag-x/-/has-to-string-tag-x-1.4.1.tgz#a045ab383d7b4b2012a00148ab0aa5f290044d4d" + dependencies: + has-symbol-support-x "^1.4.1" + has-unicode@^2.0.0: version "2.0.1" resolved "https://registry.yarnpkg.com/has-unicode/-/has-unicode-2.0.1.tgz#e0e6fe6a28cf51138855e086d1691e771de2a8b9" @@ -3369,6 +3431,10 @@ is-obj@^1.0.0: version "1.0.1" resolved "https://registry.yarnpkg.com/is-obj/-/is-obj-1.0.1.tgz#3e4729ac1f5fde025cd7d83a896dab9f4f67db0f" +is-object@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/is-object/-/is-object-1.0.1.tgz#8952688c5ec2ffd6b03ecc85e769e02903083470" + is-observable@^0.2.0: version "0.2.0" resolved "https://registry.yarnpkg.com/is-observable/-/is-observable-0.2.0.tgz#b361311d83c6e5d726cabf5e250b0237106f5ae2" @@ -3391,7 +3457,7 @@ is-path-inside@^1.0.0: dependencies: path-is-inside "^1.0.1" -is-plain-obj@^1.0.0: +is-plain-obj@^1.0.0, is-plain-obj@^1.1.0: version "1.1.0" resolved "https://registry.yarnpkg.com/is-plain-obj/-/is-plain-obj-1.1.0.tgz#71a50c8429dfca773c92a390a4a03b39fcd51d3e" @@ -3457,6 +3523,10 @@ is-windows@^1.0.0: version "1.0.1" resolved "https://registry.yarnpkg.com/is-windows/-/is-windows-1.0.1.tgz#310db70f742d259a16a369202b51af84233310d9" +is-wsl@^1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/is-wsl/-/is-wsl-1.1.0.tgz#1f16e4aa22b04d1336b66188a66af3c600c3a66d" + isarray@0.0.1: version "0.0.1" resolved "https://registry.yarnpkg.com/isarray/-/isarray-0.0.1.tgz#8a18acfca9a8f4177e09abfc6038939b05d1eedf" @@ -3490,6 +3560,13 @@ isstream@~0.1.2: version "0.1.2" resolved "https://registry.yarnpkg.com/isstream/-/isstream-0.1.2.tgz#47e63f7af55afa6f92e1500e690eb8b8529c099a" +isurl@^1.0.0-alpha5: + version "1.0.0" + resolved "https://registry.yarnpkg.com/isurl/-/isurl-1.0.0.tgz#b27f4f49f3cdaa3ea44a0a5b7f3462e6edc39d67" + dependencies: + has-to-string-tag-x "^1.2.0" + is-object "^1.0.1" + jest-docblock@^21.0.0: version "21.2.0" resolved "https://registry.yarnpkg.com/jest-docblock/-/jest-docblock-21.2.0.tgz#51529c3b30d5fd159da60c27ceedc195faf8d414" @@ -3767,7 +3844,11 @@ lodash.uniq@^4.5.0: version "4.5.0" resolved "https://registry.yarnpkg.com/lodash.uniq/-/lodash.uniq-4.5.0.tgz#d0225373aeb652adc1bc82e4945339a842754773" -lodash@^4.14.0, lodash@^4.17.4, lodash@^4.2.0, lodash@^4.2.1, lodash@^4.3.0, lodash@^4.8.0, lodash@~4.17.4: +lodash.zip@^4.0.0: + version "4.2.0" + resolved "https://registry.yarnpkg.com/lodash.zip/-/lodash.zip-4.2.0.tgz#ec6662e4896408ed4ab6c542a3990b72cc080020" + +lodash@^4.13.1, lodash@^4.14.0, lodash@^4.17.4, lodash@^4.2.0, lodash@^4.2.1, lodash@^4.3.0, lodash@^4.8.0, lodash@~4.17.4: version "4.17.4" resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.4.tgz#78203a4d1c328ae1d86dca6460e369b57f4055ae" @@ -3923,6 +4004,10 @@ mimic-fn@^1.0.0: version "1.1.0" resolved "https://registry.yarnpkg.com/mimic-fn/-/mimic-fn-1.1.0.tgz#e667783d92e89dbd342818b5230b9d62a672ad18" +mimic-response@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/mimic-response/-/mimic-response-1.0.0.tgz#df3d3652a73fded6b9b0b24146e6fd052353458e" + minimalistic-assert@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/minimalistic-assert/-/minimalistic-assert-1.0.0.tgz#702be2dda6b37f4836bcb3f5db56641b64a1d3d3" @@ -3957,6 +4042,10 @@ mkdirp@0.5.0: dependencies: minimist "0.0.8" +mri@1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/mri/-/mri-1.1.0.tgz#5c0a3f29c8ccffbbb1ec941dcec09d71fa32f36a" + ms@0.7.1: version "0.7.1" resolved "https://registry.yarnpkg.com/ms/-/ms-0.7.1.tgz#9cd13c03adbff25b65effde7ce864ee952017098" @@ -4119,6 +4208,14 @@ npm-install-package@~2.1.0: version "2.1.0" resolved "https://registry.yarnpkg.com/npm-install-package/-/npm-install-package-2.1.0.tgz#d7efe3cfcd7ab00614b896ea53119dc9ab259125" +npm-name@3.1.0: + version "3.1.0" + resolved "https://registry.yarnpkg.com/npm-name/-/npm-name-3.1.0.tgz#79789afac52ae335dc3a5aa7f41f59d1b77c756f" + dependencies: + got "^7.0.0" + lodash.zip "^4.0.0" + registry-url "^3.0.0" + npm-run-path@^2.0.0: version "2.0.2" resolved "https://registry.yarnpkg.com/npm-run-path/-/npm-run-path-2.0.2.tgz#35a9232dfa35d7067b4cb2ddf2357b1871536c5f" @@ -4196,6 +4293,12 @@ onetime@^2.0.0: dependencies: mimic-fn "^1.0.0" +opn@5.1.0: + version "5.1.0" + resolved "https://registry.yarnpkg.com/opn/-/opn-5.1.0.tgz#72ce2306a17dbea58ff1041853352b4a8fc77519" + dependencies: + is-wsl "^1.1.0" + optimist@~0.6.1: version "0.6.1" resolved "https://registry.yarnpkg.com/optimist/-/optimist-0.6.1.tgz#da3ea74686fa21a19a111c326e90eb15a0196686" @@ -4218,7 +4321,7 @@ optionator@^0.8.2: type-check "~0.3.2" wordwrap "~1.0.0" -ora@^1.2.0: +ora@1.3.0, ora@^1.2.0: version "1.3.0" resolved "https://registry.yarnpkg.com/ora/-/ora-1.3.0.tgz#80078dd2b92a934af66a3ad72a5b910694ede51a" dependencies: @@ -4268,6 +4371,10 @@ output-file-sync@^1.1.2: mkdirp "^0.5.1" object-assign "^4.1.0" +p-cancelable@^0.3.0: + version "0.3.0" + resolved "https://registry.yarnpkg.com/p-cancelable/-/p-cancelable-0.3.0.tgz#b9e123800bcebb7ac13a479be195b507b98d30fa" + p-finally@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/p-finally/-/p-finally-1.0.0.tgz#3fbcfb15b899a44123b34b6dcc18b724336a2cae" @@ -4282,6 +4389,12 @@ p-locate@^2.0.0: dependencies: p-limit "^1.1.0" +p-timeout@^1.1.1: + version "1.2.0" + resolved "https://registry.yarnpkg.com/p-timeout/-/p-timeout-1.2.0.tgz#9820f99434c5817868b4f34809ee5291660d5b6c" + dependencies: + p-finally "^1.0.0" + package-hash@^1.2.0: version "1.2.0" resolved "https://registry.yarnpkg.com/package-hash/-/package-hash-1.2.0.tgz#003e56cd57b736a6ed6114cc2b81542672770e44" @@ -4415,14 +4528,14 @@ php-escape-shell@1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/php-escape-shell/-/php-escape-shell-1.0.0.tgz#7d589611f91c2ff6f3fe6591c91478c05c610879" +pify@3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/pify/-/pify-3.0.0.tgz#e5a4acd2c101fdf3d9a4d07f0dbc4db49dd28176" + pify@^2.0.0, pify@^2.3.0: version "2.3.0" resolved "https://registry.yarnpkg.com/pify/-/pify-2.3.0.tgz#ed141a6ac043a849ea588498e7dca8b15330e90c" -pify@false3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/pify/-/pify-3.0.0.tgz#e5a4acd2c101fdf3d9a4d07f0dbc4db49dd28176" - pinkie-promise@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/pinkie-promise/-/pinkie-promise-1.0.0.tgz#d1da67f5482563bb7cf57f286ae2822ecfbf3670" @@ -4456,6 +4569,10 @@ pkg-dir@^2.0.0: dependencies: find-up "^2.1.0" +pkginfo@0.4.1: + version "0.4.1" + resolved "https://registry.yarnpkg.com/pkginfo/-/pkginfo-0.4.1.tgz#b5418ef0439de5425fc4995042dced14fb2a84ff" + plist@^2.1.0: version "2.1.0" resolved "https://registry.yarnpkg.com/plist/-/plist-2.1.0.tgz#57ccdb7a0821df21831217a3cad54e3e146a1025" @@ -4761,7 +4878,7 @@ pretty-ms@^2.0.0: parse-ms "^1.0.0" plur "^1.0.0" -private@^0.1.7: +private@^0.1.7, private@~0.1.5: version "0.1.7" resolved "https://registry.yarnpkg.com/private/-/private-0.1.7.tgz#68ce5e8a1ef0a23bb570cc28537b5332aba63ef1" @@ -4978,6 +5095,16 @@ readdirp@^2.0.0: readable-stream "^2.0.2" set-immediate-shim "^1.0.1" +recast@0.12.6: + version "0.12.6" + resolved "https://registry.yarnpkg.com/recast/-/recast-0.12.6.tgz#4b0fb82feb1d10b3bd62d34943426d9b3ed30d4c" + dependencies: + ast-types "0.9.11" + core-js "^2.4.1" + esprima "~4.0.0" + private "~0.1.5" + source-map "~0.5.0" + redent@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/redent/-/redent-1.0.0.tgz#cf916ab1fd5f1f16dfb20822dd6ec7f730c2afde" @@ -5053,7 +5180,7 @@ registry-auth-token@^3.0.1: rc "^1.1.6" safe-buffer "^5.0.1" -registry-url@^3.0.3: +registry-url@^3.0.0, registry-url@^3.0.3: version "3.1.0" resolved "https://registry.yarnpkg.com/registry-url/-/registry-url-3.1.0.tgz#3d4ef870f73dde1d77f0cf9a381432444e174942" dependencies: @@ -5315,6 +5442,10 @@ shebang-command@^1.2.0: dependencies: shebang-regex "^1.0.0" +shebang-loader@false0.0.1: + version "0.0.1" + resolved "https://registry.yarnpkg.com/shebang-loader/-/shebang-loader-0.0.1.tgz#a4000495d44cceefbec63435e7b1698569fa52ec" + shebang-regex@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/shebang-regex/-/shebang-regex-1.0.0.tgz#da42f49740c0b42db2ca9728571cb190c98efea3" @@ -5406,7 +5537,7 @@ source-map@^0.1.38: dependencies: amdefine ">=0.0.4" -source-map@^0.5.0, source-map@^0.5.3, source-map@^0.5.6, source-map@~0.5.1, source-map@~0.5.3: +source-map@^0.5.0, source-map@^0.5.3, source-map@^0.5.6, source-map@~0.5.0, source-map@~0.5.1, source-map@~0.5.3: version "0.5.7" resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.5.7.tgz#8a039d2d1021d22d1ea14c80d8ea468ba2ef3fcc" @@ -5503,6 +5634,12 @@ strict-uri-encode@^1.0.0: version "1.1.0" resolved "https://registry.yarnpkg.com/strict-uri-encode/-/strict-uri-encode-1.1.0.tgz#279b225df1d582b1f54e65addd4352e18faa0713" +string-similarity@1.2.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/string-similarity/-/string-similarity-1.2.0.tgz#d75153cb383846318b7a39a8d9292bb4db4e9c30" + dependencies: + lodash "^4.13.1" + string-width@^1.0.1, string-width@^1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/string-width/-/string-width-1.0.2.tgz#118bdf5b8cdc51a2a7e70d211e07e2b0b9b107d3" @@ -5905,6 +6042,10 @@ url-parse-lax@^1.0.0: dependencies: prepend-http "^1.0.1" +url-to-options@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/url-to-options/-/url-to-options-1.0.1.tgz#1505a03a289a48cbd7a434efbaeec5055f5633a9" + url@^0.11.0, url@~0.11.0: version "0.11.0" resolved "https://registry.yarnpkg.com/url/-/url-0.11.0.tgz#3838e97cfc60521eb73c525a8e55bfdd9e2e28f1" @@ -5981,6 +6122,12 @@ watchpack@^1.4.0: chokidar "^1.7.0" graceful-fs "^4.1.2" +wcwidth@^1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/wcwidth/-/wcwidth-1.0.1.tgz#f0b0dcf915bc5ff1528afadb2c0e17b532da2fe8" + dependencies: + defaults "^1.0.3" + wdio-dot-reporter@~0.0.8: version "0.0.9" resolved "https://registry.yarnpkg.com/wdio-dot-reporter/-/wdio-dot-reporter-0.0.9.tgz#929b2adafd49d6b0534fda068e87319b47e38fe5" From 6147109df4a29cf0fc9317e6c69cad1e9842adb2 Mon Sep 17 00:00:00 2001 From: CHaBou Date: Wed, 18 Oct 2017 18:40:45 +0200 Subject: [PATCH 09/30] Delay config reloading to ensure file consistency --- app/config.js | 11 +++++++---- cli/index.js | 2 -- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/app/config.js b/app/config.js index 58cb18d1d81b..6deda09daad3 100644 --- a/app/config.js +++ b/app/config.js @@ -15,10 +15,13 @@ const _watch = function() { } const onChange = () => { - cfg = _import(); - notify('Configuration updated', 'Hyper configuration reloaded!'); - watchers.forEach(fn => fn()); - checkDeprecatedConfig(); + // Need to wait 100ms to ensure that write is complete + setTimeout(() => { + cfg = _import(); + notify('Configuration updated', 'Hyper configuration reloaded!'); + watchers.forEach(fn => fn()); + checkDeprecatedConfig(); + }, 100); }; if (process.platform === 'win32') { diff --git a/cli/index.js b/cli/index.js index b4c4e978edf8..c34030e1bf6f 100644 --- a/cli/index.js +++ b/cli/index.js @@ -132,8 +132,6 @@ const main = argv => { return Promise.resolve(); } - console.log('flags', flags); - const env = Object.assign({}, process.env, { // this will signal Hyper that it was spawned from this module HYPER_CLI: '1', From eea9631b7e41f1d6d3e56eb24b2785b89d187a27 Mon Sep 17 00:00:00 2001 From: CHaBou Date: Wed, 18 Oct 2017 22:42:28 +0200 Subject: [PATCH 10/30] Disable lsr/search command and fix cli name in help --- cli/index.js | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/cli/index.js b/cli/index.js index c34030e1bf6f..1b3ce67c7297 100644 --- a/cli/index.js +++ b/cli/index.js @@ -3,10 +3,10 @@ const {spawn} = require('child_process'); const args = require('args'); const chalk = require('chalk'); -const columnify = require('columnify'); -const got = require('got'); +//const columnify = require('columnify'); +//const got = require('got'); const opn = require('opn'); -const ora = require('ora'); +//const ora = require('ora'); const api = require('./api'); let commandUsed = false; @@ -47,7 +47,7 @@ args.command(['ls', 'list'], 'List installed plugins', () => { } process.exit(1); }); - +/* const lsRemote = () => { // note that no errors are catched by this function const URL = @@ -114,17 +114,20 @@ args.command(['lsr', 'list-remote', 'ls-remote'], 'List plugins available on npm spinner.fail(); console.error(chalk.red(err)); // TODO }); -}); +});*/ args.command(['d', 'docs', 'h', 'home'], 'Open the npm page of a plugin', (name, args_) => { commandUsed = true; return opn(`http://ghub.io/${args_[0]}`, {wait: false}); }); +args.command([''], 'Launch Hyper'); + args.option(['v', 'verbose'], 'Verbose mode', false); const main = argv => { const flags = args.parse(argv, { + name: 'hyper', version: false }); From 1545d8e02eb0c3c18d4725d74a3755d25a06aef9 Mon Sep 17 00:00:00 2001 From: CHaBou Date: Thu, 19 Oct 2017 01:48:29 +0200 Subject: [PATCH 11/30] Add Windows compatibility --- app/utils/cli-install.js | 44 ++++++++++++++++++++++++++++++++++++---- build/win/hyper.cmd | 2 +- 2 files changed, 41 insertions(+), 5 deletions(-) diff --git a/app/utils/cli-install.js b/app/utils/cli-install.js index 5951448567de..b606bc3f8847 100644 --- a/app/utils/cli-install.js +++ b/app/utils/cli-install.js @@ -1,7 +1,9 @@ -const {cliScriptPath} = require('../config/paths'); - const pify = require('pify'); const fs = require('fs'); +const path = require('path'); +const Registry = require('winreg'); + +const {cliScriptPath} = require('../config/paths'); const lstat = pify(fs.lstat); const readlink = pify(fs.readlink); @@ -45,6 +47,40 @@ exports.addSymlink = () => { }; exports.addBinToUserPath = () => { - // TODO - return Promise.resolve(); + // Can't use pify because of param order of Registry.values callback + return new Promise((resolve, reject) => { + const envKey = new Registry({hive: 'HKCU', key: '\\Environment'}); + envKey.values((err, items) => { + if (err) { + reject(err); + return; + } + // C:\Users\\AppData\Local\hyper\app-2.0.4\resources\bin + const binPath = path.dirname(cliScriptPath); + // C:\Users\\AppData\Local\hyper + const basePath = path.resolve(binPath, '../../..'); + + const pathItem = items.find(item => item.name === 'Path'); + const pathParts = pathItem.value.split(';'); + const existingPath = pathParts.find(pathPart => pathPart === binPath); + if (existingPath) { + resolve(); + return; + } + + // Because version is in path we need to remove old path if present and add current path + const newPathValue = pathParts + .filter(pathPart => !pathPart.startsWith(basePath)) + .concat([binPath]) + .join(';'); + + envKey.set(pathItem.name, Registry.REG_SZ, newPathValue, error => { + if (error) { + reject(error); + return; + } + resolve(); + }); + }); + }); }; diff --git a/build/win/hyper.cmd b/build/win/hyper.cmd index 66f5bd9f7ab5..ce733d990ca3 100755 --- a/build/win/hyper.cmd +++ b/build/win/hyper.cmd @@ -1,5 +1,5 @@ @echo off setlocal set ELECTRON_RUN_AS_NODE=1 -call "%~dp0..\@@NAME@@.exe" "%~dp0..\resources\bin\cli.js" %* +call "%~dp0..\..\Hyper.exe" "%~dp0..\..\resources\bin\cli.js" %* endlocal \ No newline at end of file From 3913d3ae5c0b469d5806693e0da03f7b278f479c Mon Sep 17 00:00:00 2001 From: CHaBou Date: Thu, 19 Oct 2017 09:30:11 +0200 Subject: [PATCH 12/30] Fix WSL laucnh script --- build/win/hyper | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/build/win/hyper b/build/win/hyper index c255d4a93499..068073efdcbb 100755 --- a/build/win/hyper +++ b/build/win/hyper @@ -1,8 +1,8 @@ #!/usr/bin/env bash # Deeply inspired by https://github.com/Microsoft/vscode/blob/1.17.0/resources/win/bin/code.sh -NAME="@@NAME@@" -HYPER_PATH="$(dirname "$(dirname "$(realpath "$0")")")" +NAME="Hyper" +HYPER_PATH="$(dirname "$(dirname "$(dirname "$(dirname "$(realpath "$0")")")")")" ELECTRON="$HYPER_PATH/$NAME.exe" if grep -q Microsoft /proc/version; then # If running under WSL don't pass cli.js to Electron as environment vars @@ -19,3 +19,4 @@ else fi ELECTRON_RUN_AS_NODE=1 "$ELECTRON" "$CLI" "$@" exit $? + From 9baabe150afe87a06fc06a1d70ac1c72f96c6b99 Mon Sep 17 00:00:00 2001 From: CHaBou Date: Thu, 2 Nov 2017 22:19:04 +0100 Subject: [PATCH 13/30] Add postinstall scripts for Linux --- build/linux/after-install.tpl | 4 ++++ build/linux/hyper | 8 ++++---- package.json | 9 ++++++++- 3 files changed, 16 insertions(+), 5 deletions(-) create mode 100644 build/linux/after-install.tpl diff --git a/build/linux/after-install.tpl b/build/linux/after-install.tpl new file mode 100644 index 000000000000..7a39c2b8987e --- /dev/null +++ b/build/linux/after-install.tpl @@ -0,0 +1,4 @@ +#!/bin/bash + +# Link to the CLI bootstrap +ln -sf '/opt/${productFilename}/resources/bin/${executable}' '/usr/local/bin/${executable}' \ No newline at end of file diff --git a/build/linux/hyper b/build/linux/hyper index 522408d7284e..cf1efceacae5 100755 --- a/build/linux/hyper +++ b/build/linux/hyper @@ -17,18 +17,18 @@ fi if [ ! -L $0 ]; then # if path is not a symlink, find relatively - HYPER_PATH="$(dirname $0)/.." + HYPER_PATH="$(dirname $0)../.." else if which readlink >/dev/null; then # if readlink exists, follow the symlink and find relatively - HYPER_PATH="$(dirname $(readlink -f $0))/.." + HYPER_PATH="$(dirname $(readlink -f $0))/../.." else # else use the standard install location - HYPER_PATH="/usr/share/@@NAME@@" + HYPER_PATH="/opt/Hyper" fi fi -ELECTRON="$HYPER_PATH/@@NAME@@" +ELECTRON="$HYPER_PATH/hyper" CLI="$HYPER_PATH/resources/bin/cli.js" ELECTRON_RUN_AS_NODE=1 "$ELECTRON" "$CLI" "$@" exit $? \ No newline at end of file diff --git a/package.json b/package.json index eb5af9daf006..bb4abbf3a813 100644 --- a/package.json +++ b/package.json @@ -119,7 +119,8 @@ "./bin/cli.js", { "from": "./build/${os}/", - "to": "./bin/" + "to": "./bin/", + "filter": ["hyper*"] } ], "linux": { @@ -145,6 +146,12 @@ "mac": { "category": "public.app-category.developer-tools", "extendInfo": "build/Info.plist" + }, + "deb": { + "afterInstall": "./build/linux/after-install.tpl" + }, + "rpm": { + "afterInstall": "./build/linux/after-install.tpl" } }, "license": "MIT", From 430919603f6d7c503834614510e791888cac70d4 Mon Sep 17 00:00:00 2001 From: CHaBou Date: Fri, 3 Nov 2017 00:29:53 +0100 Subject: [PATCH 14/30] Prevent launching multiple Hyper process on macOS --- cli/index.js | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/cli/index.js b/cli/index.js index 1b3ce67c7297..0d776199649c 100644 --- a/cli/index.js +++ b/cli/index.js @@ -1,6 +1,7 @@ // This is a CLI tool, using console is OK /* eslint no-console: 0 */ -const {spawn} = require('child_process'); +const {spawn, exec} = require('child_process'); +const pify = require('pify'); const args = require('args'); const chalk = require('chalk'); //const columnify = require('columnify'); @@ -152,11 +153,20 @@ const main = argv => { env }; + const args_ = args.sub; + if (!flags.verbose) { options['stdio'] = 'ignore'; + if (process.platform === 'darwin') { + //Use `open` to prevent multiple Hyper process + const cmd = `open -b co.zeit.hyper ${args_}`; + const opts = { + env + }; + return pify(exec)(cmd, opts); + } } - const args_ = args.sub; const child = spawn(process.execPath, args_, options); if (flags.verbose) { From 87ccaa08cc0043d148d62cdb34665fb6c89c1807 Mon Sep 17 00:00:00 2001 From: CHaBou Date: Fri, 3 Nov 2017 13:22:34 +0100 Subject: [PATCH 15/30] Fix Hyper path from cli.js on GitBash --- build/win/hyper | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/win/hyper b/build/win/hyper index 068073efdcbb..f55bc46d7994 100755 --- a/build/win/hyper +++ b/build/win/hyper @@ -2,7 +2,7 @@ # Deeply inspired by https://github.com/Microsoft/vscode/blob/1.17.0/resources/win/bin/code.sh NAME="Hyper" -HYPER_PATH="$(dirname "$(dirname "$(dirname "$(dirname "$(realpath "$0")")")")")" +HYPER_PATH="$(dirname "$(dirname "$(dirname "$(realpath "$0")")")")" ELECTRON="$HYPER_PATH/$NAME.exe" if grep -q Microsoft /proc/version; then # If running under WSL don't pass cli.js to Electron as environment vars From 180f1691e0b1f8c96865b1689e42463cbde01798 Mon Sep 17 00:00:00 2001 From: CHaBou Date: Fri, 3 Nov 2017 13:32:34 +0100 Subject: [PATCH 16/30] Add warning for WSL --- build/win/hyper | 3 +++ 1 file changed, 3 insertions(+) diff --git a/build/win/hyper b/build/win/hyper index f55bc46d7994..8d7ebd7010ef 100755 --- a/build/win/hyper +++ b/build/win/hyper @@ -5,6 +5,9 @@ NAME="Hyper" HYPER_PATH="$(dirname "$(dirname "$(dirname "$(realpath "$0")")")")" ELECTRON="$HYPER_PATH/$NAME.exe" if grep -q Microsoft /proc/version; then + echo "Warning! Due to WSL limitations, you can use CLI commands here. Please use Hyper CLI on cmd, PowerShell or GitBash/CygWin." + echo "Please see: https://github.com/Microsoft/WSL/issues/1494" + echo "" # If running under WSL don't pass cli.js to Electron as environment vars # cannot be transferred from WSL to Windows # See: https://github.com/Microsoft/BashOnWindows/issues/1363 From e2943b9c2591c1ca1b6a26ad6ef30978ad8afdaa Mon Sep 17 00:00:00 2001 From: CHaBou Date: Fri, 3 Nov 2017 14:07:34 +0100 Subject: [PATCH 17/30] Convert relative path arguments to absolute paths --- cli/index.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/cli/index.js b/cli/index.js index 0d776199649c..ebb6ef718c3f 100644 --- a/cli/index.js +++ b/cli/index.js @@ -1,6 +1,7 @@ // This is a CLI tool, using console is OK /* eslint no-console: 0 */ const {spawn, exec} = require('child_process'); +const {isAbsolute, resolve} = require('path'); const pify = require('pify'); const args = require('args'); const chalk = require('chalk'); @@ -153,7 +154,11 @@ const main = argv => { env }; - const args_ = args.sub; + const args_ = args.sub.map(arg => { + return isAbsolute(arg) ? arg : resolve(process.cwd(), arg); + }); + + console.log(args_); if (!flags.verbose) { options['stdio'] = 'ignore'; From 28eb7feaccb57ed07a441c86cc7a207e39041e50 Mon Sep 17 00:00:00 2001 From: CHaBou Date: Fri, 3 Nov 2017 14:16:59 +0100 Subject: [PATCH 18/30] Update yarn.lock --- yarn.lock | 21 ++++----------------- 1 file changed, 4 insertions(+), 17 deletions(-) diff --git a/yarn.lock b/yarn.lock index b737fdc48936..1f36970df977 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1109,13 +1109,7 @@ block-stream@*: dependencies: inherits "~2.0.0" -bluebird-lst@^1.0.2, bluebird-lst@^1.0.3: - version "1.0.3" - resolved "https://registry.yarnpkg.com/bluebird-lst/-/bluebird-lst-1.0.3.tgz#cc56c18660eff0a0b86e2c33d1659618f7005158" - dependencies: - bluebird "^3.5.0" - -bluebird-lst@^1.0.4, bluebird-lst@^1.0.5: +bluebird-lst@^1.0.3, bluebird-lst@^1.0.4, bluebird-lst@^1.0.5: version "1.0.5" resolved "https://registry.yarnpkg.com/bluebird-lst/-/bluebird-lst-1.0.5.tgz#bebc83026b7e92a72871a3dc599e219cbfb002a9" dependencies: @@ -1385,7 +1379,7 @@ center-align@^0.1.1: align-text "^0.1.3" lazy-cache "^1.0.3" -chalk@2.1.0, chalk@^2.0.0, chalk@^2.0.1, chalk@^2.1.0: +chalk@2.1.0, chalk@^2.0.1: version "2.1.0" resolved "https://registry.yarnpkg.com/chalk/-/chalk-2.1.0.tgz#ac5becf14fa21b99c6c92ca7a7d7cfd5b17e743e" dependencies: @@ -1411,7 +1405,7 @@ chalk@^1.0.0, chalk@^1.1.1, chalk@^1.1.3: strip-ansi "^3.0.0" supports-color "^2.0.0" -chalk@^2.3.0: +chalk@^2.0.0, chalk@^2.1.0, chalk@^2.3.0: version "2.3.0" resolved "https://registry.yarnpkg.com/chalk/-/chalk-2.3.0.tgz#b5ea48efc9c1793dccc9b4767c93914d3f2d52ba" dependencies: @@ -2757,14 +2751,7 @@ form-data@~2.3.1: combined-stream "^1.0.5" mime-types "^2.1.12" -fs-extra-p@^4.4.0: - version "4.4.2" - resolved "https://registry.yarnpkg.com/fs-extra-p/-/fs-extra-p-4.4.2.tgz#b6abd882a9b89f41b977771d3da788ce38f085f3" - dependencies: - bluebird-lst "^1.0.2" - fs-extra "^4.0.2" - -fs-extra-p@^4.4.4: +fs-extra-p@^4.4.0, fs-extra-p@^4.4.4: version "4.4.4" resolved "https://registry.yarnpkg.com/fs-extra-p/-/fs-extra-p-4.4.4.tgz#396ad6f914eb2954e1700fd0e18288301ed45f04" dependencies: From 3225d4e32cb656a9d7fae78ee5a844d5e48f9107 Mon Sep 17 00:00:00 2001 From: CHaBou Date: Fri, 3 Nov 2017 14:20:49 +0100 Subject: [PATCH 19/30] Update yarn.lock --- yarn.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/yarn.lock b/yarn.lock index e1de2091fbd8..dafd736de8f9 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4083,7 +4083,7 @@ mkdirp@0.5.0: mousetrap@chabou/mousetrap#useCapture: version "1.6.1" resolved "https://codeload.github.com/chabou/mousetrap/tar.gz/c95eeeaafba1131dd8d35bc130d4a79b2ff9261a" - + mri@1.1.0: version "1.1.0" resolved "https://registry.yarnpkg.com/mri/-/mri-1.1.0.tgz#5c0a3f29c8ccffbbb1ec941dcec09d71fa32f36a" From 82db3a73f3f42af0b4c0d07bd4363a4e94038b17 Mon Sep 17 00:00:00 2001 From: CHaBou Date: Fri, 3 Nov 2017 15:26:08 +0100 Subject: [PATCH 20/30] Wake up AppVeyor From e9bbb3ed86fbb3eeccb02b656f4e976c9b11bc97 Mon Sep 17 00:00:00 2001 From: CHaBou Date: Fri, 3 Nov 2017 17:06:06 +0100 Subject: [PATCH 21/30] Remove logs --- cli/index.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/cli/index.js b/cli/index.js index ebb6ef718c3f..bb660cac0e2c 100644 --- a/cli/index.js +++ b/cli/index.js @@ -158,8 +158,6 @@ const main = argv => { return isAbsolute(arg) ? arg : resolve(process.cwd(), arg); }); - console.log(args_); - if (!flags.verbose) { options['stdio'] = 'ignore'; if (process.platform === 'darwin') { From 2d5fd3ea1f13f9b373d486422f4eaa97c6c3f662 Mon Sep 17 00:00:00 2001 From: CHaBou Date: Fri, 3 Nov 2017 23:34:17 +0100 Subject: [PATCH 22/30] Fix app path in Linux bootstrap --- build/linux/hyper | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/linux/hyper b/build/linux/hyper index cf1efceacae5..18824de3a3b1 100755 --- a/build/linux/hyper +++ b/build/linux/hyper @@ -17,7 +17,7 @@ fi if [ ! -L $0 ]; then # if path is not a symlink, find relatively - HYPER_PATH="$(dirname $0)../.." + HYPER_PATH="$(dirname $0)/../.." else if which readlink >/dev/null; then # if readlink exists, follow the symlink and find relatively From 6d00ce8bfa9288feed51eccda696c704ce3d3e30 Mon Sep 17 00:00:00 2001 From: CHaBou Date: Sat, 4 Nov 2017 14:04:05 +0100 Subject: [PATCH 23/30] Check if config exists only when needed --- cli/index.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/cli/index.js b/cli/index.js index bb660cac0e2c..41381e36e320 100644 --- a/cli/index.js +++ b/cli/index.js @@ -13,15 +13,19 @@ const api = require('./api'); let commandUsed = false; -if (!api.exists()) { +const checkConfig = () => { + if (api.exists()) { + return true; + } let msg = chalk.red(`Error! Config file not found: ${api.configPath}\n`); msg += 'Please launch Hyper and retry.'; console.error(msg); process.exit(1); -} +}; args.command(['i', 'install'], 'Install a plugin', (name, args_) => { commandUsed = true; + checkConfig(); const plugin = args_[0]; return api .install(plugin) @@ -31,6 +35,7 @@ args.command(['i', 'install'], 'Install a plugin', (name, args_) => { args.command(['u', 'uninstall', 'rm', 'remove'], 'Uninstall a plugin', (name, args_) => { commandUsed = true; + checkConfig(); const plugin = args_[0]; return api .uninstall(plugin) @@ -40,6 +45,7 @@ args.command(['u', 'uninstall', 'rm', 'remove'], 'Uninstall a plugin', (name, ar args.command(['ls', 'list'], 'List installed plugins', () => { commandUsed = true; + checkConfig(); let plugins = api.list(); if (plugins) { From c2212d863ee837f863b3aef6eb688ee90373d16b Mon Sep 17 00:00:00 2001 From: CHaBou Date: Sat, 4 Nov 2017 14:04:28 +0100 Subject: [PATCH 24/30] Fix verbose mode with path --- cli/index.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/cli/index.js b/cli/index.js index 41381e36e320..7fd4ad3e8859 100644 --- a/cli/index.js +++ b/cli/index.js @@ -136,7 +136,10 @@ args.option(['v', 'verbose'], 'Verbose mode', false); const main = argv => { const flags = args.parse(argv, { name: 'hyper', - version: false + version: false, + mri: { + boolean: ['v', 'verbose'] + } }); if (commandUsed) { From 6d153184371a233044258c97beee7b967e3c38a0 Mon Sep 17 00:00:00 2001 From: CHaBou Date: Sat, 4 Nov 2017 14:17:44 +0100 Subject: [PATCH 25/30] Check if directory/file argument exists --- cli/index.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/cli/index.js b/cli/index.js index 7fd4ad3e8859..1e6a3c74f89a 100644 --- a/cli/index.js +++ b/cli/index.js @@ -2,6 +2,7 @@ /* eslint no-console: 0 */ const {spawn, exec} = require('child_process'); const {isAbsolute, resolve} = require('path'); +const {existsSync} = require('fs'); const pify = require('pify'); const args = require('args'); const chalk = require('chalk'); @@ -164,7 +165,12 @@ const main = argv => { }; const args_ = args.sub.map(arg => { - return isAbsolute(arg) ? arg : resolve(process.cwd(), arg); + const cwd = isAbsolute(arg) ? arg : resolve(process.cwd(), arg); + if (!existsSync(cwd)) { + console.error(chalk.red(`Error! Directory or file does not exist: ${cwd}`)); + process.exit(1); + } + return cwd; }); if (!flags.verbose) { From 48228986083fb1e5624ae536b16d278e66d64ce0 Mon Sep 17 00:00:00 2001 From: CHaBou Date: Sun, 5 Nov 2017 17:56:08 +0100 Subject: [PATCH 26/30] Use commandPromise and wait for command termination --- cli/index.js | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-) diff --git a/cli/index.js b/cli/index.js index 1e6a3c74f89a..832fb30a7c39 100644 --- a/cli/index.js +++ b/cli/index.js @@ -6,13 +6,13 @@ const {existsSync} = require('fs'); const pify = require('pify'); const args = require('args'); const chalk = require('chalk'); -//const columnify = require('columnify'); -//const got = require('got'); const opn = require('opn'); -//const ora = require('ora'); +// const columnify = require('columnify'); +// const got = require('got'); +// const ora = require('ora'); const api = require('./api'); -let commandUsed = false; +let commandPromise; const checkConfig = () => { if (api.exists()) { @@ -25,27 +25,24 @@ const checkConfig = () => { }; args.command(['i', 'install'], 'Install a plugin', (name, args_) => { - commandUsed = true; checkConfig(); const plugin = args_[0]; - return api + commandPromise = api .install(plugin) .then(() => console.log(chalk.green(`${plugin} installed successfully!`))) .catch(err => console.error(chalk.red(err))); }); args.command(['u', 'uninstall', 'rm', 'remove'], 'Uninstall a plugin', (name, args_) => { - commandUsed = true; checkConfig(); const plugin = args_[0]; - return api + commandPromise = api .uninstall(plugin) .then(() => console.log(chalk.green(`${plugin} uninstalled successfully!`))) .catch(err => console.log(chalk.red(err))); }); args.command(['ls', 'list'], 'List installed plugins', () => { - commandUsed = true; checkConfig(); let plugins = api.list(); @@ -78,11 +75,10 @@ const lsRemote = () => { }; args.command(['s', 'search'], 'Search for plugins on npm', (name, args_) => { - commandUsed = true; const spinner = ora('Searching').start(); const query = args_[0] ? args_[0].toLowerCase() : ''; - return lsRemote() + commandPromise = lsRemote() .then(entries => { return entries.filter(entry => { return entry.name.indexOf(query) !== -1 || entry.description.toLowerCase().indexOf(query) !== -1; @@ -108,10 +104,9 @@ args.command(['s', 'search'], 'Search for plugins on npm', (name, args_) => { }); args.command(['lsr', 'list-remote', 'ls-remote'], 'List plugins available on npm', () => { - commandUsed = true; const spinner = ora('Searching').start(); - return lsRemote() + commandPromise = lsRemote() .then(entries => { let msg = columnify(entries); @@ -126,7 +121,6 @@ args.command(['lsr', 'list-remote', 'ls-remote'], 'List plugins available on npm });*/ args.command(['d', 'docs', 'h', 'home'], 'Open the npm page of a plugin', (name, args_) => { - commandUsed = true; return opn(`http://ghub.io/${args_[0]}`, {wait: false}); }); @@ -143,8 +137,8 @@ const main = argv => { } }); - if (commandUsed) { - return Promise.resolve(); + if (commandPromise) { + return commandPromise; } const env = Object.assign({}, process.env, { From fc45cb881cd74237fbeba7885576c51956c4c53b Mon Sep 17 00:00:00 2001 From: CHaBou Date: Tue, 9 Jan 2018 14:47:30 +0100 Subject: [PATCH 27/30] Enable package checking on npm --- cli/api.js | 2 +- package.json | 3 +++ yarn.lock | 6 +++--- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/cli/api.js b/cli/api.js index 41f3a7c09b4a..239aaf918d62 100644 --- a/cli/api.js +++ b/cli/api.js @@ -1,6 +1,6 @@ const fs = require('fs'); const os = require('os'); -const npmName = () => Promise.resolve(); //require('npm-name'); +const npmName = require('npm-name'); const pify = require('pify'); const recast = require('recast'); diff --git a/package.json b/package.json index e0ad57a5c0cf..432345051a12 100644 --- a/package.json +++ b/package.json @@ -231,5 +231,8 @@ "spectron": "3.7.2", "style-loader": "0.19.0", "webpack": "3.8.1" + }, + "resolutions": { + "rc": "1.2.3" } } diff --git a/yarn.lock b/yarn.lock index dafd736de8f9..647d88491263 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5056,9 +5056,9 @@ randombytes@^2.0.0, randombytes@^2.0.1: dependencies: safe-buffer "^5.1.0" -rc@^1.0.1, rc@^1.1.2, rc@^1.1.6, rc@^1.1.7, rc@^1.2.1: - version "1.2.1" - resolved "https://registry.yarnpkg.com/rc/-/rc-1.2.1.tgz#2e03e8e42ee450b8cb3dce65be1bf8974e1dfd95" +rc@1.2.3, rc@^1.0.1, rc@^1.1.2, rc@^1.1.6, rc@^1.1.7, rc@^1.2.1: + version "1.2.3" + resolved "https://registry.yarnpkg.com/rc/-/rc-1.2.3.tgz#51575a900f8dd68381c710b4712c2154c3e2035b" dependencies: deep-extend "~0.4.0" ini "~1.3.0" From 0fb085b82fa233266bec6472307b4a195ca7df73 Mon Sep 17 00:00:00 2001 From: CHaBou Date: Tue, 9 Jan 2018 14:48:36 +0100 Subject: [PATCH 28/30] Fix comment --- app/utils/cli-install.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/utils/cli-install.js b/app/utils/cli-install.js index b606bc3f8847..342099c6dc52 100644 --- a/app/utils/cli-install.js +++ b/app/utils/cli-install.js @@ -55,7 +55,7 @@ exports.addBinToUserPath = () => { reject(err); return; } - // C:\Users\\AppData\Local\hyper\app-2.0.4\resources\bin + // C:\Users\\AppData\Local\hyper\app-\resources\bin const binPath = path.dirname(cliScriptPath); // C:\Users\\AppData\Local\hyper const basePath = path.resolve(binPath, '../../..'); From 3e5bc0d59165150567183af44a358fa19f1c2b82 Mon Sep 17 00:00:00 2001 From: CHaBou Date: Tue, 9 Jan 2018 15:39:59 +0100 Subject: [PATCH 29/30] Add plugin list and search --- cli/index.js | 38 +++++++++++++++++--------------------- 1 file changed, 17 insertions(+), 21 deletions(-) diff --git a/cli/index.js b/cli/index.js index 832fb30a7c39..d4b146088b65 100644 --- a/cli/index.js +++ b/cli/index.js @@ -7,9 +7,9 @@ const pify = require('pify'); const args = require('args'); const chalk = require('chalk'); const opn = require('opn'); -// const columnify = require('columnify'); -// const got = require('got'); -// const ora = require('ora'); +const columnify = require('columnify'); +const got = require('got'); +const ora = require('ora'); const api = require('./api'); let commandPromise; @@ -51,19 +51,19 @@ args.command(['ls', 'list'], 'List installed plugins', () => { } else { console.log(chalk.red(`No plugins installed yet.`)); } - process.exit(1); + process.exit(0); }); -/* -const lsRemote = () => { + +const lsRemote = pattern => { // note that no errors are catched by this function - const URL = - 'http://registry.npmjs.org/-/_view/byKeyword?startkey=[%22hyperterm%22,%22hyper%22]&endkey=[%22hyperterm%22,{}]&group_level=4'; + const URL = `https://api.npms.io/v2/search?q=${(pattern && `${pattern}+`) || ''}keywords:hyper-plugin,hyper-theme`; return got(URL) - .then(response => JSON.parse(response.body).rows) - .then(entries => entries.map(entry => entry.key)) + .then(response => JSON.parse(response.body).results) + .then(entries => entries.map(entry => entry.package)) + .then(entries => entries.filter(entry => entry.name.indexOf('hyper-') === 0)) .then(entries => - entries.map(entry => { - return {name: entry[1], description: entry[2]}; + entries.map(({name, description}) => { + return {name, description}; }) ) .then(entries => @@ -78,17 +78,12 @@ args.command(['s', 'search'], 'Search for plugins on npm', (name, args_) => { const spinner = ora('Searching').start(); const query = args_[0] ? args_[0].toLowerCase() : ''; - commandPromise = lsRemote() - .then(entries => { - return entries.filter(entry => { - return entry.name.indexOf(query) !== -1 || entry.description.toLowerCase().indexOf(query) !== -1; - }); - }) + commandPromise = lsRemote(query) .then(entries => { if (entries.length === 0) { spinner.fail(); console.error(chalk.red(`Your search '${query}' did not match any plugins`)); - console.error(`${chalk.red('Try')} ${chalk.green('hpm ls-remote')}`); + console.error(`${chalk.red('Try')} ${chalk.green('hyper ls-remote')}`); process.exit(1); } else { let msg = columnify(entries); @@ -118,10 +113,11 @@ args.command(['lsr', 'list-remote', 'ls-remote'], 'List plugins available on npm spinner.fail(); console.error(chalk.red(err)); // TODO }); -});*/ +}); args.command(['d', 'docs', 'h', 'home'], 'Open the npm page of a plugin', (name, args_) => { - return opn(`http://ghub.io/${args_[0]}`, {wait: false}); + opn(`http://ghub.io/${args_[0]}`, {wait: false}); + process.exit(0); }); args.command([''], 'Launch Hyper'); From 2699d6e5f89afb2f3e2f032620cb443cdfae7eed Mon Sep 17 00:00:00 2001 From: CHaBou Date: Tue, 9 Jan 2018 15:46:27 +0100 Subject: [PATCH 30/30] Enforce hyper- prefix --- cli/index.js | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/cli/index.js b/cli/index.js index d4b146088b65..4f43da698910 100644 --- a/cli/index.js +++ b/cli/index.js @@ -12,8 +12,17 @@ const got = require('got'); const ora = require('ora'); const api = require('./api'); +const PLUGIN_PREFIX = 'hyper-'; + let commandPromise; +const getPluginName = arg => { + if (arg.indexOf(PLUGIN_PREFIX) !== 0) { + return `${PLUGIN_PREFIX}${arg}`; + } + return arg; +}; + const checkConfig = () => { if (api.exists()) { return true; @@ -26,7 +35,7 @@ const checkConfig = () => { args.command(['i', 'install'], 'Install a plugin', (name, args_) => { checkConfig(); - const plugin = args_[0]; + const plugin = getPluginName(args_[0]); commandPromise = api .install(plugin) .then(() => console.log(chalk.green(`${plugin} installed successfully!`))) @@ -35,7 +44,7 @@ args.command(['i', 'install'], 'Install a plugin', (name, args_) => { args.command(['u', 'uninstall', 'rm', 'remove'], 'Uninstall a plugin', (name, args_) => { checkConfig(); - const plugin = args_[0]; + const plugin = getPluginName(args_[0]); commandPromise = api .uninstall(plugin) .then(() => console.log(chalk.green(`${plugin} uninstalled successfully!`))) @@ -60,7 +69,7 @@ const lsRemote = pattern => { return got(URL) .then(response => JSON.parse(response.body).results) .then(entries => entries.map(entry => entry.package)) - .then(entries => entries.filter(entry => entry.name.indexOf('hyper-') === 0)) + .then(entries => entries.filter(entry => entry.name.indexOf(PLUGIN_PREFIX) === 0)) .then(entries => entries.map(({name, description}) => { return {name, description}; @@ -116,7 +125,8 @@ args.command(['lsr', 'list-remote', 'ls-remote'], 'List plugins available on npm }); args.command(['d', 'docs', 'h', 'home'], 'Open the npm page of a plugin', (name, args_) => { - opn(`http://ghub.io/${args_[0]}`, {wait: false}); + const plugin = getPluginName(args_[0]); + opn(`http://ghub.io/${plugin}`, {wait: false}); process.exit(0); });