Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: thebespokepixel/term-ng
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: eb805ba72ccc507f26716b5be79bbe5562e9a411
Choose a base ref
...
head repository: thebespokepixel/term-ng
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 8ce336f4c9e619803927d85cb069e3cede0281ce
Choose a head ref
Loading
Showing 341 changed files with 12,433 additions and 13,984 deletions.
42 changes: 19 additions & 23 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,39 +1,35 @@
---
branches:
only:
- master
- develop
- /^greenkeeper/.*$/
- master
- develop
- /^greenkeeper/.*$/
- /^feature/.*$/
language: node_js
node_js:
- stable
- 9
- 8
sudo: false
notifications:
webhooks:
urls:
- https://webhooks.gitter.im/e/d0418713e51ac049564a
on_success: always
on_failure: change
on_start: never
- 12
- 11
- 10
env:
global:
- CC_TEST_REPORTER_ID=027e05e388803c110e2bd2874962d470d838257ff0619faea6f28c495b646309
- secure: k+PXexJeDTne3XBzuDa59S3V7lvZ1hXoivoD3AkSM30WXRFVhqvreCkpcrKcwLWD6DTJA7DYy2eQE26V4Q2NVIPSHo4cMhVKX4v6a4JITN8UCWKqa9oaDE4OuHWymVXcuS1FRDUJQEy59oRb1zM37f+3bfOEoEupgg4IDBErxiaWyLZV3d8f5mVNkZC2nhvXdfla/KNeJxCIBk8bzR9yCPgra8frwzGb0ZQazZfyy31D3JkHYNeJfIp/4ncXLiracUxzLLAevW0sb4RI3oP3KX8UKs//uT0ipjQnSqPQFM1gewDUPelk6XvI/glw6G1+nttqcyxj+LO6mlpJGXtcyNP2qziU86n2UYsxaocEtvcK4U7lKyo5tnrJr/WunZZ1k0H8YHASkHdKsef5m+lhlrKvk9ebMZER96bE1+p7gNSo9ghGNS+JSelVqs9hqNMFAAdiT8Y3Q5li5Yg81BNbLOXTYwFlXt1OKPrC2Ie3kKw/kbcYIhn9bofmsCHI2naULquISoEW94cqycpZzPfRmoWXOVqXM+jyWdQ/w1tEFuthYIiYJG1YIoptuW2ZIR6kIt8bLe6ZKCotkIfUY8fnENIq/VuNhIZWzHt5rtnqeP0XiH2aPGFXmAVGylVbUZLifQa8mS6CQiR9CTD7bOy5/odFtKrqGD1IN/QxpaLoa1I=
- CC_TEST_REPORTER_ID=71353381ba1b658ffa6a6525569e63a14976d3de21d7dfa9bf4c109d19983243
before_install:
- '[[ $(node -v) =~ ^v10.*$ ]] || npm install -g npm@latest'
- npm i -g npm
- npm install -g greenkeeper-lockfile
install: npm install
install: npm ci --no-optional
before_script:
- greenkeeper-lockfile-update
- curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
- chmod +x ./cc-test-reporter
- ./cc-test-reporter before-build
- "./cc-test-reporter before-build"
after_script:
- greenkeeper-lockfile-upload
- "[ $TRAVIS_NODE_VERSION = stable ]
&& nyc report --reporter=lcov
&& ./cc-test-reporter after-build --debug -t lcov --exit-code $TRAVIS_TEST_RESULT
|| echo 'Coverage skipped'"

- "[ $TRAVIS_NODE_VERSION = stable ] && nyc report --reporter=lcov && ./cc-test-reporter
after-build --debug -t lcov --exit-code $TRAVIS_TEST_RESULT || echo 'Coverage skipped'"
notifications:
slack:
secure: k8prVQTufAadnHw3WL31uoidomdKCxLd3Xoe2pJveKSkCWHJfvrEknkSY3tB99OxLqKG7VfD8946m6FuTg171s6K7Yzv6sDCJZCkxWaBWZ6xlPjyapkz+xzVQJpFhmuE6dxIOH8BvOkM+EqHxjhcJE5iUjwXyV9YxEPAO3AqQFtjz08Bh+6d4HI77iNpb8MkPiqzplcrG4TXHceBxV5mvjmatPAaZAsq9Yi/toj2oOmHYYjDWXtHEdfkOQNuuWZzlcuDtkpxhJGEp9Xh06AQWJOlvivLCwvDqyZbVZ7bZsep6TD8Tu7HgP3UiIEUxfM4/tcjo80wolSmMa8f0rCdSxbYBBEoy4UmLn68QCgFA5twUEOsY914wx4NvKvy+ZQapskqsGt/UawL8TQmRVdPKoCAqtUbrdR53DsX731RApvMxvpi0inESzS96uJgY6ZsJL+zOUDizGVPJ1M/QdHtQU4Bw5ZOEZJEy6YupcmNIdyFxkTi2942H7z/YUpuEY3fYN2kenYTNFe/fhTpFWlI1kvJwZOHh4/Q7QhhmdqxXRzhDBsgl5UYA1JcPekOUhw844eRS8sG3cVCsts275cdYV7czNQw40PU1dN//QpcJ67KM0VRMX1ewxlglFFTeOrsG7ssOFmAEC7ebeaognt9bdfyXI32BZ16DNm4Vd97vkU=
cache:
directories:
- "$HOME/.npm"
254 changes: 185 additions & 69 deletions bin/termng
Original file line number Diff line number Diff line change
@@ -3,35 +3,205 @@

function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }

var path = require('path');
var trucolor = require('trucolor');
var truwrap = require('truwrap');
var yargs = _interopDefault(require('yargs'));
var meta = _interopDefault(require('@thebespokepixel/meta'));
var updateNotifier = _interopDefault(require('update-notifier'));
var readPkg = _interopDefault(require('read-pkg'));

/* ────────╮
│ Term-NG │ Next generation terminal detector
╰─────────┴─────────────────────────────────────────────────────────────────── */
const name = "term-ng";
const version = "1.0.5";
const description = "Terminal/$TERM feature snooping and whitelisting";
const main = "index.js";
const module$1 = "index.mjs";
const bin = {
termng: "./bin/termng"
};
const files = [
"index.js",
"index.mjs",
"bin"
];
const scripts = {
test: "xo && nyc ava",
"doc-serve": "documentation serve --watch --theme node_modules/documentation-theme-bespoke --github --config src/docs/documentation.yml --project-name $npm_package_name --project-version $npm_package_version src/index.js",
"doc-build": "documentation build --format html --output docs --theme node_modules/documentation-theme-bespoke --github --config src/docs/documentation.yml --project-name $npm_package_name --project-version $npm_package_version src/index.js",
readme: "compile-readme -u src/docs/example.md src/docs/readme.md > readme.md",
coverage: "nyc ava && nyc report --reporter=lcov --report-dir test/coverage; open test/coverage/lcov-report/index.html",
colors: "scripts/colortest.pl"
};
const repository = {
type: "git",
url: "https://github.com/thebespokepixel/term-ng.git"
};
const engines = {
node: ">=10.0"
};
const keywords = [
"24bit",
"color",
"ansi",
"truecolor",
"trucolor",
"sgr",
"cli",
"tty",
"iterm",
"xterm"
];
const author = "Mark Griffiths <mark@thebespokepixel.com> (http://thebespokepixel.com/)";
const copyright = {
year: "2020",
owner: "The Bespoke Pixel"
};
const license = "MIT";
const bugs = {
url: "https://github.com/thebespokepixel/term-ng/issues"
};
const homepage = "https://github.com/thebespokepixel/term-ng#readme";
const devDependencies = {
"@ava/babel": "^1.0.1",
"@babel/core": "^7.8.4",
"@babel/preset-env": "^7.8.4",
ava: "^3.3.0",
"babel-plugin-lodash": "^3.3.4",
"documentation-theme-bespoke": "^1.1.2",
gulp: "^4.0.2",
"gulp-better-rollup": "^4.0.1",
"gulp-chmod": "^3.0.0",
"gulp-rename": "^2.0.0",
"gulp-strip-comments": "^2.5.2",
nyc: "^15.0.0",
rollup: "^1.31.1",
"rollup-plugin-babel": "^4.3.3",
"rollup-plugin-commonjs": "^10.1.0",
"rollup-plugin-json": "^4.0.0",
"rollup-plugin-node-resolve": "^5.2.0",
xo: "^0.26.1"
};
const dependencies = {
"@thebespokepixel/meta": "^2.0.1",
"read-pkg": "^5.2.0",
trucolor: "^1.0.6",
truwrap: "^1.0.5",
"update-notifier": "^4.1.0",
yargs: "^15.1.0"
};
const xo = {
semicolon: false,
esnext: true,
ignores: [
"index.js",
"index.mjs",
"bin/*.js",
"docs/**",
"src/docs/example.js"
]
};
const ava = {
babel: true,
files: [
"test/*.js"
]
};
const badges = {
github: "thebespokepixel",
npm: "thebespokepixel",
codeclimate: "7ba2088efca500b3b4ff",
name: "term-ng",
providers: {
aux1: {
title: "github",
text: "source",
color: "4E73B6",
link: "https://github.com/thebespokepixel/term-ng"
}
},
readme: {
"Publishing Status": [
[
"npm",
"david"
],
[
"travis-com",
"rollup"
]
],
"Development Status": [
[
"greenkeeper",
"travis-com-dev"
],
[
"david-dev",
"david-devdeps-dev"
],
[
"snyk",
"code-climate",
"code-climate-coverage"
]
],
"Documentation/Help": [
"inch",
"twitter"
]
},
docs: [
[
"aux1",
"travis"
],
[
"code-climate",
"code-climate-coverage"
],
[
"snyk",
"david"
]
]
};
var pkg = {
name: name,
version: version,
description: description,
main: main,
module: module$1,
bin: bin,
files: files,
scripts: scripts,
repository: repository,
engines: engines,
keywords: keywords,
author: author,
copyright: copyright,
license: license,
bugs: bugs,
homepage: homepage,
devDependencies: devDependencies,
dependencies: dependencies,
xo: xo,
ava: ava,
badges: badges
};

/* eslint complexity:0 */
const itermSession = process.env.ITERM_SESSION_ID && process.env.ITERM_SESSION_ID.indexOf(':') > 0;
const termColor = process.env.TERM_COLOR && process.env.TERM_COLOR.indexOf('16m') >= 0;
const has16m = itermSession || termColor;
const colorTermTruecolor = process.env.COLORTERM && process.env.COLORTERM.includes('truecolor');
const termColor16m = process.env.TERM_COLOR && process.env.TERM_COLOR.includes('16m');
const has16m = itermSession || colorTermTruecolor || termColor16m;

if (has16m && !/-color/.test(process.argv.join(''))) {
process.argv.splice(2, 0, '--color=16m');
} // From https://github.com/sindresorhus/has-flag, under MIT license

}

const hasFlag = flag => {
const terminatorPos = process.argv.indexOf('--');
const prefix = /^-{1,2}/.test(flag) ? '' : '--';
const pos = process.argv.indexOf(prefix + flag);
return pos !== -1 && (terminatorPos === -1 ? true : pos < terminatorPos);
}; // From https://github.com/chalk/supports-color, under MIT license

};

const support = level => {
if (level === 0) {
@@ -99,81 +269,27 @@ if (supportLevel === 0 && 'FORCE_COLOR' in process.env) {
}

const supportsColor = process && support(supportLevel);
/**
* Terminal features.
* @namespace
*/

const termNG = {
/**
* Supported terminal color depth.
* @type {Object}
* @property {Number} level - 0 = None, 1 = Basic, 2 = 256 colors, 3 = 24 bit color
* @property {Boolean} basic - Is there basic color support?
* @property {Boolean} has256 - Terminal supports 256 colors
* @property {Boolean} has16m - Terminal supports 16 million (24 bit) color
*/
color: {
level: supportsColor.level || 0,
basic: supportsColor.hasBasic || false,
hasBasic: supportsColor.hasBasic || false,
has256: supportsColor.level >= 2,
has16m: supportsColor.level >= 3
},

/**
* Does the terminal support inline images?
* @type {Boolean}
* @example <caption>To set:</caption>
* env TERM_IMAGES=enabled
*/
images: process.env.TERM_IMAGES !== undefined && supportsColor.level >= 2,

/**
* Does the terminal support audio?
* @type {Boolean}
* @example <caption>To set:</caption>
* env TERM_AUDIO=enabled
*/
audio: process.env.TERM_AUDIO !== undefined,

/**
* Terminal font character set.
* @type {Object}
* @property {Boolean} basic - Font has basic box drawing symbols.
* @property {Boolean} enhanced - Font has 'full' Unicode character support
* @example <caption>To set:</caption>
* env TERM_FONT=[box|full]
*/
font: {
basic: process.env.TERM_FONT !== undefined,
enhanced: process.env.TERM_FONT === 'full'
},

/**
* Termcap support
* @type {Object}
* @property {Boolean} basic - Using the default termcap.
* @property {Boolean} enhanced - Using an enhanced/custom termcap.
* @example <caption>To set:</caption>
* env TERM_ENHANCED=enabled
*/
termcap: {
basic: process.env.TERM_ENHANCED !== undefined && process.env.TERM_ENHANCED === 'disabled',
enhanced: process.env.TERM_ENHANCED === 'enabled'
},

/**
* Name of running terminal software, i.e. 'iTerm.app'
* @type {String}
*/
software: process.env.TERM_PROGRAM || process.env.TERMKIT_HOST_APP || process.env.TERM || process.env.GULP
};

/* ────────╮
│ Term-NG │ Next Generation Terminal Feature Exposure/Whitelisting
╰─────────┴──────────────────────────────────────────────────────────────────── */
const pkg = readPkg.sync(path.resolve(__dirname, '..'));
const clr = trucolor.simple({
format: 'sgr'
});
@@ -212,7 +328,7 @@ If user-agent is used, the command will return the string on stdout and exit sta
${clr.title}Usage:${clr.title.out}
${clr.command}termng ${clr.option}[command]${clr.option.out}`;
const epilogue = `${clr.title}© 2016 The Bespoke Pixel. ${clr.grey}Released under the MIT License.${clr.grey.out}`;
const epilogue = `${clr.title}${metadata.copyright}. ${clr.grey}Released under the MIT License.${clr.grey.out}`;

if (!(process.env.USER === 'root' && process.env.SUDO_USER !== process.env.USER)) {
updateNotifier({
@@ -224,7 +340,7 @@ if (argv.help) {
renderer.write(usage);
renderer.break(2);
renderer.write(_yargs.getUsageInstance().help());
renderer.break();
renderer.break(2);
renderer.write(epilogue);
renderer.break(2);
process.exit(0);
@@ -235,7 +351,7 @@ if (argv.version) {
process.exit(0);
}

if (argv._.indexOf('user-agent') !== -1) {
if (argv._.includes('user-agent')) {
process.stdout.write(termNG.software);
process.exit(0);
}
Loading