├── .gitignore ├── .gitattributes ├── node-nightly.gif ├── .travis.yml ├── .editorconfig ├── package.json ├── license ├── readme.md ├── cli.js ├── index.js └── History.md /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | node-nightly/ 3 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto 2 | *.js text eol=lf 3 | -------------------------------------------------------------------------------- /node-nightly.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hemanth/node-nightly/HEAD/node-nightly.gif -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | sudo: false 2 | language: node_js 3 | node_js: 4 | - '6' 5 | - '5' 6 | - '4' 7 | env: 8 | - CXX=g++-4.8 9 | addons: 10 | apt: 11 | sources: 12 | - ubuntu-toolchain-r-test 13 | packages: 14 | - g++-4.8 15 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | indent_style = tab 5 | end_of_line = lf 6 | charset = utf-8 7 | trim_trailing_whitespace = true 8 | insert_final_newline = true 9 | 10 | [{package.json,*.yml}] 11 | indent_style = space 12 | indent_size = 2 13 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "node-nightly", 3 | "version": "1.8.1", 4 | "description": "node-nightly at your finger tips!", 5 | "license": "MIT", 6 | "repository": "hemanth/node-nightly", 7 | "author": { 8 | "name": "Hemanth.HM", 9 | "email": "hemanth.hm@gmail.com", 10 | "url": "h3manth.com" 11 | }, 12 | "type": "module", 13 | "scripts": { 14 | "test": "node cli.js -v" 15 | }, 16 | "preferGlobal": true, 17 | "publishConfig": { 18 | "registry": "https://registry.npmjs.org" 19 | }, 20 | "bin": { 21 | "node-nightly": "./cli.js" 22 | }, 23 | "engines": { 24 | "node": ">=4" 25 | }, 26 | "files": [ 27 | "index.js", 28 | "cli.js" 29 | ], 30 | "keywords": [ 31 | "cli-app", 32 | "cli", 33 | "node", 34 | "nightly" 35 | ], 36 | "dependencies": { 37 | "configstore": "^6.0.0", 38 | "cross-spawn": "7.0.3", 39 | "download": "^8.0.0", 40 | "graceful-fs": "^4.2.9", 41 | "is-online": "^9.0.1", 42 | "node-nightly-version": "^1.0.6", 43 | "rimraf": "^3.0.2" 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /license: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) Hemanth.HM (h3manth.com) 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 | # node-nightly [![Build Status](https://travis-ci.org/hemanth/node-nightly.svg?branch=master)](https://travis-ci.org/hemanth/node-nightly) 2 | 3 | ## Install 4 | 5 | ``` 6 | $ npm install --global node-nightly 7 | ``` 8 | 9 | 10 | ## Usage 11 | 12 | __For the first time:__ 13 | 14 | ```sh 15 | $ node-nightly 16 | Downloading the nightly version, hang on... 17 | 18 | 19 | node-nightly is available on CLI! 20 | ``` 21 | 22 | __And then:__ 23 | 24 | ```sh 25 | $ node-nightly --inspect --debug-brk index.js 26 | Debugger listening on port 9229. 27 | To start debugging, open the following URL in Chrome: 28 | chrome-devtools://devtools/remote/serve_file/@521e5b7e2b7cc66b4006a8a54cb9c4e57494a5ef/inspector.html?experiments=true&v8only=true&ws=localhost:9229/node 29 | Debugger attached. 30 | Waiting for the debugger to disconnect... 31 | ``` 32 | 33 | ## Additional commands 34 | 35 | 1. `node-nightly --version {version}` Install a specific nightly. This is useful if the nightly is broken. 36 | 2. `node-nightly --upgrade` Install the latest nightly 37 | 38 | __GIF FTW!__ 39 | 40 | ![node-nightly](./node-nightly.gif) 41 | 42 | 43 | ## License 44 | 45 | MIT © [Hemanth.HM](https://h3manth.com) 46 | -------------------------------------------------------------------------------- /cli.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 'use strict'; 3 | import {spawn} from 'cross-spawn'; 4 | import nodeNightly from './index.js'; 5 | import gracefulFs from 'graceful-fs'; 6 | import isOnline from 'is-online'; 7 | import path from 'path'; 8 | import {fileURLToPath} from 'url'; 9 | 10 | const {existsSync} = gracefulFs; 11 | 12 | const os = process.platform === 'win32' ? 'win' : process.platform; 13 | let args = process.argv.slice(2); 14 | 15 | const __filename = fileURLToPath(import.meta.url); 16 | const __dirname = path.dirname(__filename); 17 | 18 | // Check for upgrade. 19 | let upgradeIndex = args.indexOf('--upgrade'), 20 | versionIndex = args.indexOf('--version'), 21 | version = versionIndex < 0 ? null : args[versionIndex + 1]; 22 | 23 | if (version) { 24 | nodeNightly.install(version).catch(console.error); 25 | } else if (!!~upgradeIndex) { 26 | reportIfOffline(); 27 | nodeNightly.update().then(res => { 28 | if (res !== 'Installed') { 29 | console.log(res); 30 | } 31 | process.exit(0); 32 | }).catch(console.error); 33 | } else if (!existsSync(`${__dirname}/node-nightly`)) { 34 | 35 | console.log('Downloading the nightly version, hang on...'); 36 | reportIfOffline(); 37 | //First install 38 | nodeNightly.install().catch(console.error); 39 | } else { 40 | 41 | nodeNightly.check().then(updatedVersion => { 42 | if (updatedVersion) { 43 | console.log('\x1b[36m', 'New nightly available. To upgrade: `node-nightly --upgrade`' ,'\x1b[0m'); 44 | } 45 | if (os === 'win') { 46 | spawn(`${__dirname}/node-nightly/node`, args, {stdio: 'inherit', env: process.env}); 47 | } else { 48 | spawn(`${__dirname}/node-nightly/bin/node`, args, {stdio: 'inherit', env: process.env}); 49 | } 50 | }).catch(console.error); 51 | } 52 | 53 | function reportIfOffline() { 54 | isOnline((err, online) => { 55 | if (!online) { 56 | //offline 57 | console.info('\x1b[31m', 'Please check your internet connectivity.','\x1b[0m'); 58 | process.exit(0); 59 | } 60 | }); 61 | } 62 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | import download from 'download'; 3 | import nodeNightlyVersion from 'node-nightly-version'; 4 | import Configstore from 'configstore'; 5 | import rm from 'rimraf'; 6 | import realFs from 'fs'; 7 | import gracefulFs from 'graceful-fs'; 8 | import path from 'path'; 9 | import {fileURLToPath} from 'url'; 10 | 11 | //import * as pkg from "./package.json" 12 | 13 | const pkg = {name: 'node-nightly'} 14 | 15 | 16 | gracefulFs.gracefulify(realFs); 17 | const mv = gracefulFs.renameSync; 18 | 19 | const extractDate = versionString => ~~versionString.split('nightly'[1].slice(0, 8)); 20 | const compVersion = (currentVersion, latestVersion) => extractDate(currentVersion) < extractDate(latestVersion); 21 | 22 | const __filename = fileURLToPath(import.meta.url); 23 | const __dirname = path.dirname(__filename); 24 | 25 | export default { 26 | 27 | install: (version) => { 28 | let osArchString, nodeNightlyVer; 29 | nodeNightlyVer = version !== undefined ? Promise.resolve(version) : nodeNightlyVersion(); 30 | 31 | return nodeNightlyVer.then(latest => { 32 | const os = process.platform === 'win32' ? 'win' : process.platform, 33 | extention = os === 'win' ? 'zip' : 'tar.gz', 34 | arch = process.arch === 'ia32' ? 'x86' : process.arch, 35 | type = 'nightly', 36 | osArchString = `${latest}-${os}-${arch}`, 37 | url = `https://nodejs.org/download/${type}/${latest}/node-${osArchString}.${extention}`, 38 | nightlyDir = `${__dirname}/node-nightly`; 39 | 40 | const extractedTo = `${__dirname}/node-${osArchString}`; 41 | 42 | if (gracefulFs.existsSync(extractedTo)) { 43 | rm.sync(extractedTo); 44 | } 45 | 46 | return download(url, __dirname, { 47 | extract: true 48 | }).then(_ => { 49 | if (gracefulFs.existsSync(nightlyDir)) { 50 | console.log('Deleting old version'); 51 | rm.sync(nightlyDir); 52 | console.log(`Deleted!\nInstalling newer version..`); 53 | } 54 | 55 | mv(extractedTo, nightlyDir); 56 | console.log(`node-nightly is available on your CLI!`); 57 | 58 | new Configstore(pkg.name).set('version', version); 59 | 60 | return 'Installed'; 61 | }); 62 | }); 63 | }, 64 | 65 | update: function() { 66 | console.log('Checking for update...'); 67 | return this.check().then(updatedVersion => { 68 | if (updatedVersion) { 69 | return this.install(updatedVersion); 70 | } 71 | return 'You are using latest version already.'; 72 | }); 73 | }, 74 | 75 | check: function() { 76 | return nodeNightlyVersion().then(latestVersion => { 77 | const currentVersion = new Configstore(pkg.name).get('version'); 78 | if (!currentVersion || compVersion(currentVersion, latestVersion)) { 79 | return latestVersion; 80 | } 81 | return false; 82 | }); 83 | } 84 | }; 85 | -------------------------------------------------------------------------------- /History.md: -------------------------------------------------------------------------------- 1 | v1.6.0 / 2016-08-22 2 | =================== 3 | 4 | * 1.6.0 5 | * updated node-nightly-version 6 | * Updated the deps 7 | 8 | v1.5.1 / 2016-08-18 9 | =================== 10 | 11 | * 1.5.1 12 | * updated node-nightly-version 13 | * node-nightly-version bump. 14 | * feat: Check for internet connectivity when upgrading/installing (#26) 15 | 16 | v1.5.0 / 2016-08-09 17 | =================== 18 | 19 | * 1.5.0 20 | * Add Windows Compability! (#24) 21 | * fix: Use graceful-fs everywhere to maintain consistency (#20) 22 | 23 | v1.4.2 / 2016-07-24 24 | =================== 25 | 26 | * 1.4.2 27 | * refactor: use graceful-fs (#18) 28 | 29 | v1.4.1 / 2016-07-15 30 | =================== 31 | 32 | * 1.4.1 33 | * Add `publishConfig` to package (#16) 34 | 35 | v1.4.0 / 2016-07-14 36 | =================== 37 | 38 | * 1.4.0 39 | * Update in how install and update works together (#15) 40 | * Rewrite phase-I 41 | * Promises anti-pattern removed (#9) 42 | 43 | v1.3.4 / 2016-07-06 44 | =================== 45 | 46 | * 1.3.4 47 | * Travis badge 48 | * Merge pull request #13 from cnpm/fix-extend 49 | * fix: file ext should be .tar.gz 50 | * Merge pull request #12 from tarungarg546/unused 51 | * Removed unused variable from cli.js 52 | * Merge pull request #11 from cnpm/download-from-mirror 53 | * feat: support download from mirror 54 | 55 | v1.3.3 / 2016-07-02 56 | =================== 57 | 58 | * 1.3.3 59 | * available typo :cactus: 60 | * Merge pull request #8 from paulirish/patch-2 61 | * fix spelling typo 62 | 63 | v1.3.2 / 2016-06-30 64 | =================== 65 | 66 | * 1.3.2 67 | * No more prompts. 68 | 69 | v1.3.1 / 2016-06-29 70 | =================== 71 | 72 | * 1.3.1 73 | * Merge pull request #6 from paulirish/patch-1 74 | * dirname duh duh :) 75 | 76 | v1.3.0 / 2016-06-28 77 | =================== 78 | 79 | * 1.3.0 80 | * __dirname duh 💩 81 | 82 | v1.2.1 / 2016-06-28 83 | =================== 84 | 85 | * 1.2.1 86 | * execvp logic shift 87 | 88 | v1.2.0 / 2016-06-28 89 | =================== 90 | 91 | * 1.2.0 92 | * --upgrade flag and less noise, as per @paulirish's suggestion 93 | 94 | v1.1.4 / 2016-06-28 95 | =================== 96 | 97 | * 1.1.4 98 | * yesno is not needed now. 99 | 100 | v1.1.3 / 2016-06-28 101 | =================== 102 | 103 | * 1.1.3 104 | * Clean up 105 | 106 | v1.1.2 / 2016-06-28 107 | =================== 108 | 109 | * 1.1.2 110 | * Fixes #1 111 | 112 | v1.1.1 / 2016-06-27 113 | =================== 114 | 115 | * 1.1.1 116 | * gif 🤓 117 | 118 | v1.1.0 / 2016-06-27 119 | =================== 120 | 121 | * 1.1.0 122 | * Notify and update on nightly + gif 🤓 123 | * using node-nightly-version module 124 | 125 | v1.0.1 / 2016-06-25 126 | =================== 127 | 128 | * 1.0.1 129 | * >=4 130 | * no tests for now 131 | 132 | v1.0.0 / 2016-06-25 133 | =================== 134 | 135 | * 1.0.0 136 | * 🐜 137 | --------------------------------------------------------------------------------