jest-watch-typeahead 0.1.0-2 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +23 -3
- package/LICENSE +21 -0
- package/README.md +16 -0
- package/build/file_name_pattern_prompt.js +60 -102
- package/build/file_name_plugin/plugin.js +57 -0
- package/build/file_name_plugin/prompt.js +104 -0
- package/build/file_name_plugin.js +33 -54
- package/build/lib/pattern_mode_helpers.js +51 -0
- package/build/lib/scroll.js +34 -0
- package/build/lib/utils.js +70 -72
- package/build/shared/pattern_mode_helpers.js +11 -42
- package/build/shared/scroll.js +4 -7
- package/build/test_name_pattern_prompt.js +53 -93
- package/build/test_name_plugin/plugin.js +57 -0
- package/build/test_name_plugin/prompt.js +87 -0
- package/build/test_name_plugin.js +33 -54
- package/build/test_utils/pluginTester.js +53 -0
- package/filename.js +3 -0
- package/package.json +36 -20
- package/testname.js +1 -1
- package/build/filename_plugin.js +0 -74
- package/build/index.js +0 -74
- package/build/shared/Prompt.js +0 -110
- package/build/shared/constants.js +0 -39
- package/build/shared/pattern_prompt.js +0 -76
- package/build/test_path_pattern_prompt.js +0 -147
- package/build/test_path_plugin.js +0 -74
@@ -1,10 +1,6 @@
|
|
1
1
|
'use strict';
|
2
2
|
|
3
|
-
var
|
4
|
-
|
5
|
-
var _Prompt = require('./shared/Prompt');
|
6
|
-
|
7
|
-
var _Prompt2 = _interopRequireDefault(_Prompt);
|
3
|
+
var _jestWatcher = require('jest-watcher');
|
8
4
|
|
9
5
|
var _test_name_pattern_prompt = require('./test_name_pattern_prompt');
|
10
6
|
|
@@ -12,63 +8,46 @@ var _test_name_pattern_prompt2 = _interopRequireDefault(_test_name_pattern_promp
|
|
12
8
|
|
13
9
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
14
10
|
|
15
|
-
|
16
|
-
|
17
|
-
var TestNamePlugin = function () {
|
18
|
-
function TestNamePlugin(_ref) {
|
19
|
-
var stdin = _ref.stdin,
|
20
|
-
stdout = _ref.stdout;
|
21
|
-
|
22
|
-
_classCallCheck(this, TestNamePlugin);
|
11
|
+
class TestNamePlugin {
|
23
12
|
|
13
|
+
constructor({
|
14
|
+
stdin,
|
15
|
+
stdout
|
16
|
+
}) {
|
24
17
|
this._stdin = stdin;
|
25
18
|
this._stdout = stdout;
|
26
|
-
this._prompt = new
|
19
|
+
this._prompt = new _jestWatcher.Prompt();
|
27
20
|
this._testResults = [];
|
28
21
|
}
|
29
22
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
jestHooks.onTestRunComplete(function (_ref2) {
|
36
|
-
var testResults = _ref2.testResults;
|
37
|
-
|
38
|
-
_this._testResults = testResults;
|
39
|
-
});
|
40
|
-
}
|
41
|
-
}, {
|
42
|
-
key: 'onKey',
|
43
|
-
value: function onKey(key) {
|
44
|
-
this._prompt.put(key);
|
45
|
-
}
|
46
|
-
}, {
|
47
|
-
key: 'run',
|
48
|
-
value: function run(globalConfig, updateConfigAndRun) {
|
49
|
-
var p = new _test_name_pattern_prompt2.default(this._stdout, this._prompt);
|
50
|
-
p.updateCachedTestResults(this._testResults);
|
51
|
-
return new Promise(function (res, rej) {
|
52
|
-
p.run(function (value) {
|
53
|
-
updateConfigAndRun({ mode: 'watch', testNamePattern: value });
|
54
|
-
res();
|
55
|
-
}, rej);
|
56
|
-
});
|
57
|
-
}
|
23
|
+
apply(jestHooks) {
|
24
|
+
jestHooks.onTestRunComplete(({ testResults }) => {
|
25
|
+
this._testResults = testResults;
|
26
|
+
});
|
27
|
+
}
|
58
28
|
|
59
|
-
|
29
|
+
onKey(key) {
|
30
|
+
this._prompt.put(key);
|
31
|
+
}
|
60
32
|
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
33
|
+
run(globalConfig, updateConfigAndRun) {
|
34
|
+
const p = new _test_name_pattern_prompt2.default(this._stdout, this._prompt);
|
35
|
+
p.updateCachedTestResults(this._testResults);
|
36
|
+
return new Promise((res, rej) => {
|
37
|
+
p.run(value => {
|
38
|
+
updateConfigAndRun({ mode: 'watch', testNamePattern: value });
|
39
|
+
res();
|
40
|
+
}, rej);
|
41
|
+
});
|
42
|
+
}
|
70
43
|
|
71
|
-
|
72
|
-
|
44
|
+
// eslint-disable-next-line class-methods-use-this
|
45
|
+
getUsageInfo() {
|
46
|
+
return {
|
47
|
+
key: 't',
|
48
|
+
prompt: 'filter by a test name regex pattern'
|
49
|
+
};
|
50
|
+
}
|
51
|
+
}
|
73
52
|
|
74
53
|
module.exports = TestNamePlugin;
|
@@ -0,0 +1,53 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.default = void 0;
|
7
|
+
|
8
|
+
var _jestWatcher = require("jest-watcher");
|
9
|
+
|
10
|
+
var _stripAnsi = _interopRequireDefault(require("strip-ansi"));
|
11
|
+
|
12
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
13
|
+
|
14
|
+
expect.addSnapshotSerializer({
|
15
|
+
test: val => typeof val === 'string',
|
16
|
+
print: val => (0, _stripAnsi.default)(val)
|
17
|
+
});
|
18
|
+
jest.mock('ansi-escapes', () => ({
|
19
|
+
clearScreen: '[MOCK - clearScreen]',
|
20
|
+
cursorDown: (count = 1) => `[MOCK - cursorDown(${count})]`,
|
21
|
+
cursorLeft: '[MOCK - cursorLeft]',
|
22
|
+
cursorHide: '[MOCK - cursorHide]',
|
23
|
+
cursorRestorePosition: '[MOCK - cursorRestorePosition]',
|
24
|
+
cursorSavePosition: '[MOCK - cursorSavePosition]',
|
25
|
+
cursorShow: '[MOCK - cursorShow]',
|
26
|
+
cursorTo: (x, y) => `[MOCK - cursorTo(${x}, ${y})]`
|
27
|
+
}));
|
28
|
+
|
29
|
+
const pluginTester = (Plugin, config = {}) => {
|
30
|
+
const stdout = {
|
31
|
+
columns: 80,
|
32
|
+
write: jest.fn()
|
33
|
+
};
|
34
|
+
const jestHooks = new _jestWatcher.JestHook();
|
35
|
+
const plugin = new Plugin({
|
36
|
+
stdout,
|
37
|
+
config
|
38
|
+
});
|
39
|
+
plugin.apply(jestHooks.getSubscriber());
|
40
|
+
|
41
|
+
const type = (...keys) => keys.forEach(key => plugin.onKey(key));
|
42
|
+
|
43
|
+
return {
|
44
|
+
stdout,
|
45
|
+
hookEmitter: jestHooks.getEmitter(),
|
46
|
+
updateConfigAndRun: jest.fn(),
|
47
|
+
plugin,
|
48
|
+
type
|
49
|
+
};
|
50
|
+
};
|
51
|
+
|
52
|
+
var _default = pluginTester;
|
53
|
+
exports.default = _default;
|
package/filename.js
ADDED
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "jest-watch-typeahead",
|
3
|
-
"version": "0.1
|
3
|
+
"version": "0.2.1",
|
4
4
|
"main": "build/index.js",
|
5
5
|
"author": "Rogelio Guzman <rogelioguzmanh@gmail.com>",
|
6
6
|
"description": "Jest plugin for filtering by filename or test name",
|
@@ -12,7 +12,7 @@
|
|
12
12
|
"homepage": "https://github.com/jest-community/jest-watch-typeahead",
|
13
13
|
"files": [
|
14
14
|
"build/",
|
15
|
-
"
|
15
|
+
"filename.js",
|
16
16
|
"testname.js"
|
17
17
|
],
|
18
18
|
"scripts": {
|
@@ -25,26 +25,42 @@
|
|
25
25
|
},
|
26
26
|
"dependencies": {
|
27
27
|
"ansi-escapes": "^3.0.0",
|
28
|
-
"chalk": "^2.
|
29
|
-
"
|
30
|
-
"slash": "^
|
28
|
+
"chalk": "^2.4.1",
|
29
|
+
"jest-watcher": "^23.1.0",
|
30
|
+
"slash": "^2.0.0",
|
31
31
|
"string-length": "^2.0.0",
|
32
|
-
"strip-ansi": "^
|
32
|
+
"strip-ansi": "^5.0.0"
|
33
33
|
},
|
34
34
|
"devDependencies": {
|
35
|
-
"babel
|
36
|
-
"babel
|
37
|
-
"babel
|
38
|
-
"babel
|
39
|
-
"
|
40
|
-
"eslint
|
41
|
-
"
|
42
|
-
"eslint
|
43
|
-
"eslint-
|
44
|
-
"eslint-
|
45
|
-
"eslint-plugin-
|
46
|
-
"
|
47
|
-
"jest": "22.
|
48
|
-
"prettier": "
|
35
|
+
"@babel/cli": "^7.0.0",
|
36
|
+
"@babel/core": "^7.0.0",
|
37
|
+
"@babel/preset-env": "^7.0.0",
|
38
|
+
"@babel/preset-flow": "^7.0.0",
|
39
|
+
"babel-core": "^7.0.0-bridge.0",
|
40
|
+
"babel-eslint": "^10.0.1",
|
41
|
+
"babel-jest": "^23.4.2",
|
42
|
+
"eslint": "^5.12.1",
|
43
|
+
"eslint-config-airbnb-base": "^13.1.0",
|
44
|
+
"eslint-config-prettier": "^3.6.0",
|
45
|
+
"eslint-plugin-flowtype": "^3.2.1",
|
46
|
+
"eslint-plugin-import": "^2.9.0",
|
47
|
+
"eslint-plugin-jest": "^22.1.3",
|
48
|
+
"eslint-plugin-prettier": "^3.0.1",
|
49
|
+
"flow-bin": "^0.91.0",
|
50
|
+
"jest": "^23.2.0",
|
51
|
+
"prettier": "^1.13.7"
|
52
|
+
},
|
53
|
+
"jest": {
|
54
|
+
"watchPlugins": [
|
55
|
+
"<rootDir>/filename",
|
56
|
+
"<rootDir>/testname"
|
57
|
+
],
|
58
|
+
"snapshotSerializers": [
|
59
|
+
"<rootDir>/node_modules/pretty-format/build/plugins/convert_ansi"
|
60
|
+
],
|
61
|
+
"testPathIgnorePatterns": [
|
62
|
+
"<rootDir>/build/.*",
|
63
|
+
"<rootDir>/src/__tests__/pluginTester.js"
|
64
|
+
]
|
49
65
|
}
|
50
66
|
}
|
package/testname.js
CHANGED
package/build/filename_plugin.js
DELETED
@@ -1,74 +0,0 @@
|
|
1
|
-
'use strict';
|
2
|
-
|
3
|
-
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
|
4
|
-
|
5
|
-
var _Prompt = require('./shared/Prompt');
|
6
|
-
|
7
|
-
var _Prompt2 = _interopRequireDefault(_Prompt);
|
8
|
-
|
9
|
-
var _test_path_pattern_prompt = require('./test_path_pattern_prompt');
|
10
|
-
|
11
|
-
var _test_path_pattern_prompt2 = _interopRequireDefault(_test_path_pattern_prompt);
|
12
|
-
|
13
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
14
|
-
|
15
|
-
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
16
|
-
|
17
|
-
var TestPathPlugin = function () {
|
18
|
-
function TestPathPlugin(_ref) {
|
19
|
-
var stdin = _ref.stdin,
|
20
|
-
stdout = _ref.stdout;
|
21
|
-
|
22
|
-
_classCallCheck(this, TestPathPlugin);
|
23
|
-
|
24
|
-
this._stdin = stdin;
|
25
|
-
this._stdout = stdout;
|
26
|
-
this._prompt = new _Prompt2.default();
|
27
|
-
this._projects = [];
|
28
|
-
}
|
29
|
-
|
30
|
-
_createClass(TestPathPlugin, [{
|
31
|
-
key: 'apply',
|
32
|
-
value: function apply(jestHooks) {
|
33
|
-
var _this = this;
|
34
|
-
|
35
|
-
jestHooks.onFileChange(function (_ref2) {
|
36
|
-
var projects = _ref2.projects;
|
37
|
-
|
38
|
-
_this._projects = projects;
|
39
|
-
});
|
40
|
-
}
|
41
|
-
}, {
|
42
|
-
key: 'onKey',
|
43
|
-
value: function onKey(key) {
|
44
|
-
this._prompt.put(key);
|
45
|
-
}
|
46
|
-
}, {
|
47
|
-
key: 'run',
|
48
|
-
value: function run(globalConfig, updateConfigAndRun) {
|
49
|
-
var p = new _test_path_pattern_prompt2.default(this._stdout, this._prompt);
|
50
|
-
p.updateSearchSources(this._projects);
|
51
|
-
return new Promise(function (res, rej) {
|
52
|
-
p.run(function (value) {
|
53
|
-
updateConfigAndRun({ mode: 'watch', testPathPattern: value });
|
54
|
-
res();
|
55
|
-
}, rej);
|
56
|
-
});
|
57
|
-
}
|
58
|
-
|
59
|
-
// eslint-disable-next-line class-methods-use-this
|
60
|
-
|
61
|
-
}, {
|
62
|
-
key: 'getUsageInfo',
|
63
|
-
value: function getUsageInfo() {
|
64
|
-
return {
|
65
|
-
key: 'p',
|
66
|
-
prompt: 'filter by a filename regex pattern'
|
67
|
-
};
|
68
|
-
}
|
69
|
-
}]);
|
70
|
-
|
71
|
-
return TestPathPlugin;
|
72
|
-
}();
|
73
|
-
|
74
|
-
module.exports = TestPathPlugin;
|
package/build/index.js
DELETED
@@ -1,74 +0,0 @@
|
|
1
|
-
'use strict';
|
2
|
-
|
3
|
-
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
|
4
|
-
|
5
|
-
var _Prompt = require('./shared/Prompt');
|
6
|
-
|
7
|
-
var _Prompt2 = _interopRequireDefault(_Prompt);
|
8
|
-
|
9
|
-
var _test_path_pattern_prompt = require('./test_path_pattern_prompt');
|
10
|
-
|
11
|
-
var _test_path_pattern_prompt2 = _interopRequireDefault(_test_path_pattern_prompt);
|
12
|
-
|
13
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
14
|
-
|
15
|
-
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
16
|
-
|
17
|
-
var TestPathPlugin = function () {
|
18
|
-
function TestPathPlugin(_ref) {
|
19
|
-
var stdin = _ref.stdin,
|
20
|
-
stdout = _ref.stdout;
|
21
|
-
|
22
|
-
_classCallCheck(this, TestPathPlugin);
|
23
|
-
|
24
|
-
this._stdin = stdin;
|
25
|
-
this._stdout = stdout;
|
26
|
-
this._prompt = new _Prompt2.default();
|
27
|
-
this._projects = [];
|
28
|
-
}
|
29
|
-
|
30
|
-
_createClass(TestPathPlugin, [{
|
31
|
-
key: 'apply',
|
32
|
-
value: function apply(jestHooks) {
|
33
|
-
var _this = this;
|
34
|
-
|
35
|
-
jestHooks.onFileChange(function (_ref2) {
|
36
|
-
var projects = _ref2.projects;
|
37
|
-
|
38
|
-
_this._projects = projects;
|
39
|
-
});
|
40
|
-
}
|
41
|
-
}, {
|
42
|
-
key: 'onKey',
|
43
|
-
value: function onKey(key) {
|
44
|
-
this._prompt.put(key);
|
45
|
-
}
|
46
|
-
}, {
|
47
|
-
key: 'run',
|
48
|
-
value: function run(globalConfig, updateConfigAndRun) {
|
49
|
-
var p = new _test_path_pattern_prompt2.default(this._stdout, this._prompt);
|
50
|
-
p.updateSearchSources(this._projects);
|
51
|
-
return new Promise(function (res, rej) {
|
52
|
-
p.run(function (value) {
|
53
|
-
updateConfigAndRun({ mode: 'watch', testPathPattern: value });
|
54
|
-
res();
|
55
|
-
}, rej);
|
56
|
-
});
|
57
|
-
}
|
58
|
-
|
59
|
-
// eslint-disable-next-line class-methods-use-this
|
60
|
-
|
61
|
-
}, {
|
62
|
-
key: 'getUsageInfo',
|
63
|
-
value: function getUsageInfo() {
|
64
|
-
return {
|
65
|
-
key: 'p',
|
66
|
-
prompt: 'filter by a filename regex pattern'
|
67
|
-
};
|
68
|
-
}
|
69
|
-
}]);
|
70
|
-
|
71
|
-
return TestPathPlugin;
|
72
|
-
}();
|
73
|
-
|
74
|
-
module.exports = TestPathPlugin;
|
package/build/shared/Prompt.js
DELETED
@@ -1,110 +0,0 @@
|
|
1
|
-
'use strict';
|
2
|
-
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
4
|
-
value: true
|
5
|
-
});
|
6
|
-
|
7
|
-
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
|
8
|
-
|
9
|
-
var _constants = require('./constants');
|
10
|
-
|
11
|
-
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
12
|
-
|
13
|
-
var Prompt = function () {
|
14
|
-
function Prompt() {
|
15
|
-
_classCallCheck(this, Prompt);
|
16
|
-
|
17
|
-
this._onResize = this._onResize.bind(this);
|
18
|
-
}
|
19
|
-
|
20
|
-
_createClass(Prompt, [{
|
21
|
-
key: '_onResize',
|
22
|
-
value: function _onResize() {
|
23
|
-
this._onChange(this._value);
|
24
|
-
}
|
25
|
-
}, {
|
26
|
-
key: 'enter',
|
27
|
-
value: function enter(onChange, onSuccess, onCancel) {
|
28
|
-
var _this = this;
|
29
|
-
|
30
|
-
this._entering = true;
|
31
|
-
this._value = '';
|
32
|
-
this._onSuccess = onSuccess;
|
33
|
-
this._onCancel = onCancel;
|
34
|
-
this._typeaheadSelection = null;
|
35
|
-
this._typeaheadOffset = -1;
|
36
|
-
this._typeaheadLength = 0;
|
37
|
-
this._onChange = function () {
|
38
|
-
return onChange(_this._value, {
|
39
|
-
max: 10,
|
40
|
-
offset: _this._typeaheadOffset
|
41
|
-
});
|
42
|
-
};
|
43
|
-
|
44
|
-
this._onChange();
|
45
|
-
|
46
|
-
process.stdout.on('resize', this._onResize);
|
47
|
-
}
|
48
|
-
}, {
|
49
|
-
key: 'setTypeaheadLength',
|
50
|
-
value: function setTypeaheadLength(length) {
|
51
|
-
this._typeaheadLength = length;
|
52
|
-
}
|
53
|
-
}, {
|
54
|
-
key: 'setTypheadheadSelection',
|
55
|
-
value: function setTypheadheadSelection(selected) {
|
56
|
-
this._typeaheadSelection = selected;
|
57
|
-
}
|
58
|
-
}, {
|
59
|
-
key: 'put',
|
60
|
-
value: function put(key) {
|
61
|
-
switch (key) {
|
62
|
-
case _constants.KEYS.ENTER:
|
63
|
-
this._entering = false;
|
64
|
-
this._onSuccess(this._typeaheadSelection || this._value);
|
65
|
-
this.abort();
|
66
|
-
break;
|
67
|
-
case _constants.KEYS.ESCAPE:
|
68
|
-
this._entering = false;
|
69
|
-
this._onCancel(this._value);
|
70
|
-
this.abort();
|
71
|
-
break;
|
72
|
-
case _constants.KEYS.ARROW_DOWN:
|
73
|
-
this._typeaheadOffset = Math.min(this._typeaheadOffset + 1, this._typeaheadLength - 1);
|
74
|
-
this._onChange();
|
75
|
-
break;
|
76
|
-
case _constants.KEYS.ARROW_UP:
|
77
|
-
this._typeaheadOffset = Math.max(this._typeaheadOffset - 1, -1);
|
78
|
-
this._onChange();
|
79
|
-
break;
|
80
|
-
case _constants.KEYS.ARROW_LEFT:
|
81
|
-
case _constants.KEYS.ARROW_RIGHT:
|
82
|
-
break;
|
83
|
-
default:
|
84
|
-
{
|
85
|
-
this._value = key === _constants.KEYS.BACKSPACE ? this._value.slice(0, -1) : this._value + key;
|
86
|
-
this._typeaheadOffset = -1;
|
87
|
-
this._typeaheadSelection = null;
|
88
|
-
this._onChange();
|
89
|
-
break;
|
90
|
-
}
|
91
|
-
}
|
92
|
-
}
|
93
|
-
}, {
|
94
|
-
key: 'abort',
|
95
|
-
value: function abort() {
|
96
|
-
this._entering = false;
|
97
|
-
this._value = '';
|
98
|
-
process.stdout.removeListener('resize', this._onResize);
|
99
|
-
}
|
100
|
-
}, {
|
101
|
-
key: 'isEntering',
|
102
|
-
value: function isEntering() {
|
103
|
-
return this._entering;
|
104
|
-
}
|
105
|
-
}]);
|
106
|
-
|
107
|
-
return Prompt;
|
108
|
-
}();
|
109
|
-
|
110
|
-
exports.default = Prompt;
|
@@ -1,39 +0,0 @@
|
|
1
|
-
'use strict';
|
2
|
-
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
4
|
-
value: true
|
5
|
-
});
|
6
|
-
var isWindows = process.platform === 'win32';
|
7
|
-
|
8
|
-
var CLEAR = exports.CLEAR = isWindows ? '\x1Bc' : '\x1B[2J\x1B[3J\x1B[H';
|
9
|
-
|
10
|
-
var KEYS = exports.KEYS = {
|
11
|
-
A: 'a',
|
12
|
-
ARROW_DOWN: '\u001b[B',
|
13
|
-
ARROW_LEFT: '\u001b[D',
|
14
|
-
ARROW_RIGHT: '\u001b[C',
|
15
|
-
ARROW_UP: '\u001b[A',
|
16
|
-
BACKSPACE: isWindows ? Buffer.from('08', 'hex').toString() : Buffer.from('7f', 'hex').toString(),
|
17
|
-
C: 'c',
|
18
|
-
CONTROL_C: '\u0003',
|
19
|
-
CONTROL_D: '\u0004',
|
20
|
-
ENTER: '\r',
|
21
|
-
ESCAPE: '\u001b',
|
22
|
-
F: 'f',
|
23
|
-
I: 'i',
|
24
|
-
O: 'o',
|
25
|
-
P: 'p',
|
26
|
-
Q: 'q',
|
27
|
-
QUESTION_MARK: '?',
|
28
|
-
R: 'r',
|
29
|
-
S: 's',
|
30
|
-
T: 't',
|
31
|
-
U: 'u',
|
32
|
-
W: 'w'
|
33
|
-
};
|
34
|
-
|
35
|
-
var ICONS = exports.ICONS = {
|
36
|
-
failed: isWindows ? '\u00D7' : '\u2715',
|
37
|
-
pending: '\u25CB',
|
38
|
-
success: isWindows ? '\u221A' : '\u2713'
|
39
|
-
};
|
@@ -1,76 +0,0 @@
|
|
1
|
-
'use strict';
|
2
|
-
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
4
|
-
value: true
|
5
|
-
});
|
6
|
-
|
7
|
-
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
|
8
|
-
|
9
|
-
var _chalk = require('chalk');
|
10
|
-
|
11
|
-
var _chalk2 = _interopRequireDefault(_chalk);
|
12
|
-
|
13
|
-
var _ansiEscapes = require('ansi-escapes');
|
14
|
-
|
15
|
-
var _ansiEscapes2 = _interopRequireDefault(_ansiEscapes);
|
16
|
-
|
17
|
-
var _Prompt = require('./Prompt');
|
18
|
-
|
19
|
-
var _Prompt2 = _interopRequireDefault(_Prompt);
|
20
|
-
|
21
|
-
require('./scroll');
|
22
|
-
|
23
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
24
|
-
|
25
|
-
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
26
|
-
|
27
|
-
var usage = function usage(entity
|
28
|
-
// eslint-disable-nextline prefer-template
|
29
|
-
) {
|
30
|
-
return `\n${_chalk2.default.bold('Pattern Mode Usage')}\n` + ` ${_chalk2.default.dim('\u203A Press')} Esc ${_chalk2.default.dim('to exit pattern mode.')}\n` + ` ${_chalk2.default.dim('\u203A Press')} Enter ` + `${_chalk2.default.dim(`to apply pattern to all ${entity}.`)}\n` + `\n`;
|
31
|
-
};
|
32
|
-
|
33
|
-
var usageRows = usage('').split('\n').length;
|
34
|
-
|
35
|
-
var PatternPrompt = function () {
|
36
|
-
function PatternPrompt(pipe, prompt) {
|
37
|
-
_classCallCheck(this, PatternPrompt);
|
38
|
-
|
39
|
-
this._pipe = pipe;
|
40
|
-
this._prompt = prompt;
|
41
|
-
this._currentUsageRows = usageRows;
|
42
|
-
}
|
43
|
-
|
44
|
-
_createClass(PatternPrompt, [{
|
45
|
-
key: 'run',
|
46
|
-
value: function run(onSuccess, onCancel, options) {
|
47
|
-
this._pipe.write(_ansiEscapes2.default.cursorHide);
|
48
|
-
this._pipe.write(_ansiEscapes2.default.clearScreen);
|
49
|
-
|
50
|
-
if (options && options.header) {
|
51
|
-
this._pipe.write(`${options.header}\n`);
|
52
|
-
this._currentUsageRows = usageRows + options.header.split('\n').length;
|
53
|
-
} else {
|
54
|
-
this._currentUsageRows = usageRows;
|
55
|
-
}
|
56
|
-
|
57
|
-
this._pipe.write(usage(this._entityName));
|
58
|
-
this._pipe.write(_ansiEscapes2.default.cursorShow);
|
59
|
-
|
60
|
-
this._prompt.enter(this._onChange.bind(this), onSuccess, onCancel);
|
61
|
-
}
|
62
|
-
|
63
|
-
// eslint-disable-next-line no-unused-vars
|
64
|
-
|
65
|
-
}, {
|
66
|
-
key: '_onChange',
|
67
|
-
value: function _onChange(pattern, options) {
|
68
|
-
this._pipe.write(_ansiEscapes2.default.eraseLine);
|
69
|
-
this._pipe.write(_ansiEscapes2.default.cursorLeft);
|
70
|
-
}
|
71
|
-
}]);
|
72
|
-
|
73
|
-
return PatternPrompt;
|
74
|
-
}();
|
75
|
-
|
76
|
-
exports.default = PatternPrompt;
|