fscr 6.2.3 → 6.2.6
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/dist/index.js +2 -1
- package/dist/lib/git/pub.js +0 -14
- package/dist/lib/release/bump.js +9 -6
- package/dist/lib/taskList.js +69 -61
- package/dist/lib/test-files/consoleSample.js +13 -0
- package/dist/lib/test-files/inputSample.js +17 -0
- package/dist/lib/test-files/testConsole.js +1 -0
- package/dist/lib/test-files/testInput.js +2 -0
- package/package.json +12 -6
- package/dist/lib/codemod/arrow.js +0 -13
- package/dist/lib/codemod/arrow2.js +0 -67
- package/dist/lib/codemod/funcs.js +0 -25
- package/dist/lib/codemod/removeConsole.js +0 -12
- package/dist/lib/codemod/test.js +0 -8
- package/dist/lib/components/App.js +0 -64
- package/dist/lib/components/Selector.js +0 -133
- package/dist/lib/components/TabChanger.js +0 -113
- package/dist/lib/components/Table.js +0 -177
- package/dist/lib/components/Tabs.js +0 -221
- package/dist/lib/generateFScripts.js +0 -25
- package/dist/lib/generateToc.js +0 -30
- package/dist/lib/helpers.js +0 -191
- package/dist/lib/parseScriptsMd.js +0 -85
- package/dist/lib/parseScriptsPackage.js +0 -9
- package/dist/lib/release/index.js +0 -4
- package/dist/lib/run/lib.js +0 -454
- package/dist/lib/run/main-p.js +0 -59
- package/dist/lib/run/main-s.js +0 -56
- package/dist/lib/run/parse-cli-args.js +0 -222
- package/dist/lib/run/run-p.js +0 -30
- package/dist/lib/run/run-s.js +0 -57
- package/dist/lib/runCLICommand.js +0 -30
- package/dist/lib/runParallel.js +0 -20
- package/dist/lib/runSequence.js +0 -38
- package/dist/lib/taskListAutoComplete.js +0 -15
package/dist/index.js
CHANGED
|
@@ -150,7 +150,8 @@ const runCmd = async (app, argsList = []) => {
|
|
|
150
150
|
* bump --
|
|
151
151
|
*/.command("bump", "Bump package.json and beautify it!", () => {}, async function (argv) {
|
|
152
152
|
let type = argv.type;
|
|
153
|
-
|
|
153
|
+
let skipGit = argv.skipGit;
|
|
154
|
+
await bump(type, skipGit === "true");
|
|
154
155
|
}).example(`${taskName("$0 bump")}`, `${textDescription("BUMPED AND PRETTY!")}`)
|
|
155
156
|
|
|
156
157
|
/**
|
package/dist/lib/git/pub.js
CHANGED
|
@@ -1,25 +1,11 @@
|
|
|
1
1
|
import inquirer from "inquirer";
|
|
2
2
|
import chalk from "chalk";
|
|
3
|
-
import boxen from "boxen";
|
|
4
3
|
import path from "path";
|
|
5
4
|
import { fileURLToPath } from "url";
|
|
6
5
|
const __filename = fileURLToPath(import.meta.url);
|
|
7
6
|
const __dirname = path.dirname(__filename);
|
|
8
|
-
import runTask from "./taskRunner.js";
|
|
9
7
|
import { readJson } from "../utils/helpers.js";
|
|
10
8
|
import simple from "simple-git";
|
|
11
|
-
// pub();
|
|
12
|
-
const newBranch = async name => {
|
|
13
|
-
await simple().checkoutLocalBranch(name);
|
|
14
|
-
};
|
|
15
|
-
async function pub() {
|
|
16
|
-
// runTask("sh " + path.join(__dirname, "publish.sh") + " --")
|
|
17
|
-
// .then(async () => {
|
|
18
|
-
// })
|
|
19
|
-
// .catch(e => {
|
|
20
|
-
// console.warn("-- Console ERR", e);
|
|
21
|
-
// });
|
|
22
|
-
}
|
|
23
9
|
import validateNotInDev from "./validateNotDev.js";
|
|
24
10
|
(async () => {
|
|
25
11
|
await validateNotInDev();
|
package/dist/lib/release/bump.js
CHANGED
|
@@ -11,7 +11,7 @@ if (!fs.existsSync(packagePath)) {
|
|
|
11
11
|
console.error("Cannot find package.json file in the current directory");
|
|
12
12
|
process.exit(1);
|
|
13
13
|
}
|
|
14
|
-
const bump = async (typeParam = null) => {
|
|
14
|
+
const bump = async (typeParam = null, skipGit = false) => {
|
|
15
15
|
let type = "patch";
|
|
16
16
|
if (!typeParam) {
|
|
17
17
|
type = await prompt({
|
|
@@ -22,11 +22,14 @@ const bump = async (typeParam = null) => {
|
|
|
22
22
|
} else {
|
|
23
23
|
type = typeParam;
|
|
24
24
|
}
|
|
25
|
-
let gitTag =
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
25
|
+
let gitTag = false;
|
|
26
|
+
if (!skipGit) {
|
|
27
|
+
gitTag = await prompt({
|
|
28
|
+
type: "confirm",
|
|
29
|
+
message: chalk.green.bold.underline("Add git tag?"),
|
|
30
|
+
default: false
|
|
31
|
+
});
|
|
32
|
+
}
|
|
30
33
|
await runAsync(`yarn version --${type} ${gitTag ? "--no-git-tag-version" : ""} --no-commit-hooks`);
|
|
31
34
|
const packageJson = await fs.readFileSync(packagePath);
|
|
32
35
|
const {
|
package/dist/lib/taskList.js
CHANGED
|
@@ -2,6 +2,7 @@ import inquirer from "inquirer";
|
|
|
2
2
|
const separator = " ~ ";
|
|
3
3
|
import termSize from "term-size";
|
|
4
4
|
import chalk from "chalk";
|
|
5
|
+
import { clear } from "./utils/index.js";
|
|
5
6
|
const convertBold = e => {
|
|
6
7
|
let reg = /(\*\*|^\*\*)(?=\S)([\s\S]*?\S)\*\*(?![\*\*\S])/g;
|
|
7
8
|
let boldMatches = e.match(reg);
|
|
@@ -26,68 +27,75 @@ const convertBoldArray = arr => {
|
|
|
26
27
|
};
|
|
27
28
|
const taskList = async (FcScripts, recentTasks) => {
|
|
28
29
|
return new Promise(resolve => {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
let catObj = FcScripts.categories.findIndex(e => e.name === category.name);
|
|
72
|
-
catObj = FcScripts.categories[catObj];
|
|
73
|
-
let taskNames = Object.keys(catObj.tasks).map(taskName => {
|
|
74
|
-
let task = catObj.tasks[taskName];
|
|
75
|
-
return `${taskName} ${task.description ? separator + task.description.replace(/\n/g, " ").trim() : ""}`;
|
|
76
|
-
});
|
|
77
|
-
taskNames = convertBoldArray(taskNames);
|
|
78
|
-
inquirer.prompt([{
|
|
79
|
-
type: "list",
|
|
80
|
-
name: "taskToRun",
|
|
81
|
-
message: "Which task do you want to run",
|
|
82
|
-
choices: taskNames
|
|
83
|
-
}]).then(({
|
|
84
|
-
taskToRun
|
|
85
|
-
}) => {
|
|
86
|
-
taskToRun = taskToRun.split(separator)[0].trim();
|
|
30
|
+
const promptUser = () => {
|
|
31
|
+
let choiceCategories = [...recentTasks.map(cat => {
|
|
32
|
+
return {
|
|
33
|
+
name: `${chalk.bold.underline.green(cat)}`,
|
|
34
|
+
value: {
|
|
35
|
+
type: "task",
|
|
36
|
+
name: cat
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
}), {
|
|
40
|
+
name: "-------------",
|
|
41
|
+
value: null
|
|
42
|
+
}, ...FcScripts.categories.map(cat => {
|
|
43
|
+
return {
|
|
44
|
+
name: `${chalk.bold.underline.green(cat.name)} ${separator} ${convertBold(cat.description)}`,
|
|
45
|
+
value: {
|
|
46
|
+
type: "category",
|
|
47
|
+
name: cat.name
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
})];
|
|
51
|
+
const {
|
|
52
|
+
rows
|
|
53
|
+
} = termSize();
|
|
54
|
+
//=> {columns: 143, rows: 24}
|
|
55
|
+
inquirer.prompt([{
|
|
56
|
+
type: "list",
|
|
57
|
+
name: "category",
|
|
58
|
+
message: "What category do you want to run?",
|
|
59
|
+
pageSize: rows - 1,
|
|
60
|
+
choices: choiceCategories
|
|
61
|
+
}]).then(({
|
|
62
|
+
category
|
|
63
|
+
}) => {
|
|
64
|
+
let sepInd = choiceCategories.indexOf("-------------");
|
|
65
|
+
let chosenInd = choiceCategories.indexOf(category);
|
|
66
|
+
if (category === null) {
|
|
67
|
+
// Ignore divider selection and prompt again
|
|
68
|
+
clear();
|
|
69
|
+
promptUser();
|
|
70
|
+
} else if (category.type === "task") {
|
|
71
|
+
let taskToRun = category.name.split(separator)[0].trim();
|
|
87
72
|
resolve(taskToRun);
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
|
|
73
|
+
} else {
|
|
74
|
+
let categoryName = category.name.split(separator)[0];
|
|
75
|
+
let catObj = FcScripts.categories.findIndex(e => e.name === category.name);
|
|
76
|
+
catObj = FcScripts.categories[catObj];
|
|
77
|
+
let taskNames = Object.keys(catObj.tasks).map(taskName => {
|
|
78
|
+
let task = catObj.tasks[taskName];
|
|
79
|
+
return `${taskName} ${task.description ? separator + task.description.replace(/\n/g, " ").trim() : ""}`;
|
|
80
|
+
});
|
|
81
|
+
taskNames = convertBoldArray(taskNames);
|
|
82
|
+
inquirer.prompt([{
|
|
83
|
+
type: "list",
|
|
84
|
+
name: "taskToRun",
|
|
85
|
+
message: "Which task do you want to run",
|
|
86
|
+
choices: taskNames
|
|
87
|
+
}]).then(({
|
|
88
|
+
taskToRun
|
|
89
|
+
}) => {
|
|
90
|
+
taskToRun = taskToRun.split(separator)[0].trim();
|
|
91
|
+
resolve(taskToRun);
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
// Start the prompt
|
|
98
|
+
promptUser();
|
|
91
99
|
});
|
|
92
100
|
};
|
|
93
101
|
export default taskList;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import chalk from "chalk";
|
|
2
|
+
import yargs from "yargs";
|
|
3
|
+
const argv = yargs(process.argv.slice(2)).argv;
|
|
4
|
+
(async function () {
|
|
5
|
+
console.log(`${chalk.green("PRE --- TEST 52")} ${process.argv.slice(2)} ${JSON.stringify(argv)}`);
|
|
6
|
+
await new Promise(resolve => {
|
|
7
|
+
setTimeout(() => {
|
|
8
|
+
console.log(`${chalk.green("ATTT --- TEST 52")}`);
|
|
9
|
+
resolve();
|
|
10
|
+
}, 3500);
|
|
11
|
+
});
|
|
12
|
+
console.log(`${chalk.green("POST --- TEST 52")}`);
|
|
13
|
+
})();
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import chalk from "chalk";
|
|
2
|
+
import inquirer from "inquirer";
|
|
3
|
+
(async function () {
|
|
4
|
+
console.log(`${chalk.green("PRE INPUT")}\n`);
|
|
5
|
+
inquirer.prompt([{
|
|
6
|
+
type: "list",
|
|
7
|
+
name: "category",
|
|
8
|
+
message: "What category do you want to run?",
|
|
9
|
+
choices: [1, 2, 3, 4, 5]
|
|
10
|
+
}]).then(({
|
|
11
|
+
category
|
|
12
|
+
}) => {
|
|
13
|
+
console.log(`${chalk.green("CHOSEN ", category)}`);
|
|
14
|
+
});
|
|
15
|
+
console.log(`${chalk.green("POST INPUT")}`);
|
|
16
|
+
console.log("NODEENV", process.env.INPUT);
|
|
17
|
+
})();
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
console.log("TEST CONSOLE OUTPUT");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fscr",
|
|
3
|
-
"version": "6.2.
|
|
3
|
+
"version": "6.2.6",
|
|
4
4
|
"description": "Runs the fscripts.md file",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -10,7 +10,8 @@
|
|
|
10
10
|
"build:index": "babel index.js --ignore 'node_modules' --out-file dist/index.js",
|
|
11
11
|
"build:lib": "babel lib --ignore 'node_modules' --out-dir dist/lib --copy-files",
|
|
12
12
|
"fsr": "node dist/index.js",
|
|
13
|
-
"release": "run-s release:bump release:clean release:build",
|
|
13
|
+
"release": "run-s release:test release:bump release:clean release:build",
|
|
14
|
+
"release:test": "vitest run",
|
|
14
15
|
"release:build": "run-p build:index build:lib",
|
|
15
16
|
"release:bump": "yarn fsr bump",
|
|
16
17
|
"release:clean": "rimraf dist",
|
|
@@ -21,6 +22,9 @@
|
|
|
21
22
|
"start:build": "babel-node index.js --ignore 'node_modules'",
|
|
22
23
|
"start:run": "node dist/index.js",
|
|
23
24
|
"start:watch": "nodemon --watch lib --watch index.js --ext js --exec babel-node index.js --ignore 'node_modules' -I",
|
|
25
|
+
"test": "vitest run",
|
|
26
|
+
"test:watch": "vitest",
|
|
27
|
+
"test:ui": "vitest --ui",
|
|
24
28
|
"docs": "npx cli-docs-generator --cli=./bin",
|
|
25
29
|
"test1": "echo 'yolo' && sleep 2 && echo 1",
|
|
26
30
|
"test2": "echo '2yolo' && sleep 2 && echo 22"
|
|
@@ -64,9 +68,8 @@
|
|
|
64
68
|
"git-release-notes": "^5.0.0",
|
|
65
69
|
"git-state": "^4.1.0",
|
|
66
70
|
"github-basic": "^6.0.0",
|
|
67
|
-
"ink": "^
|
|
68
|
-
"ink-
|
|
69
|
-
"ink-select-input": "^6.2.0",
|
|
71
|
+
"ink": "^5.2.1",
|
|
72
|
+
"ink-select-input": "^4.2.2",
|
|
70
73
|
"inquirer": "^12.9.6",
|
|
71
74
|
"is-builtin-module": "^5.0.0",
|
|
72
75
|
"json-colorz": "^0.2.7",
|
|
@@ -77,7 +80,7 @@
|
|
|
77
80
|
"moment-mini": "^2.24.0",
|
|
78
81
|
"open": "^10.2.0",
|
|
79
82
|
"pretty-ms": "^9.3.0",
|
|
80
|
-
"react": "^
|
|
83
|
+
"react": "^18.3.1",
|
|
81
84
|
"require-from-string": "^2.0.2",
|
|
82
85
|
"server-destroy": "^1.0.1",
|
|
83
86
|
"set-value": "^4.1.0",
|
|
@@ -98,6 +101,7 @@
|
|
|
98
101
|
"@babel/preset-env": "^7.9.0",
|
|
99
102
|
"@babel/preset-react": "^7.9.1",
|
|
100
103
|
"babel-plugin-module-resolver": "^5.0.2",
|
|
104
|
+
"execa": "8.0.1",
|
|
101
105
|
"fancy-log": "^2.0.0",
|
|
102
106
|
"fkill-cli": "^8.0.0",
|
|
103
107
|
"ink-tab": "^5.2.0",
|
|
@@ -114,8 +118,10 @@
|
|
|
114
118
|
"remarkable": "^2.0.0",
|
|
115
119
|
"rexrex": "^1.3.0",
|
|
116
120
|
"rimraf": "^6.0.1",
|
|
121
|
+
"strip-ansi": "^7.1.2",
|
|
117
122
|
"terminal-tree": "^0.0.3",
|
|
118
123
|
"underscore.string": "^3.3.5",
|
|
124
|
+
"vitest": "^3.2.4",
|
|
119
125
|
"yargs": "^18.0.0"
|
|
120
126
|
},
|
|
121
127
|
"peerDependencies": {
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
let bbt = $("<div id='btt'>DOWNLOAD LINKS</div>");
|
|
2
|
-
$("body").append(`<style>#btt { position:fixed; z-index:8999999; bottom:0;left:0; background:rgba(0,0,0,0.6); padding:10px; color:white;}</style>`);
|
|
3
|
-
bbt.on("click", function () {
|
|
4
|
-
let linkszz = $(".c-dl-links a");
|
|
5
|
-
let dwlinks = [];
|
|
6
|
-
linkszz.each(function () {
|
|
7
|
-
if ($(this).attr("href").startsWith("https://rapidga")) {
|
|
8
|
-
dwlinks.push($(this).attr("href"));
|
|
9
|
-
}
|
|
10
|
-
});
|
|
11
|
-
window.navigator.clipboard.writeText(JSON.stringify(dwlinks));
|
|
12
|
-
});
|
|
13
|
-
$("body").append(bbt);
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
module.exports = (file, api, options) => {
|
|
2
|
-
const j = api.jscodeshift;
|
|
3
|
-
const printOptions = options.printOptions || {
|
|
4
|
-
quote: 'single'
|
|
5
|
-
};
|
|
6
|
-
const root = j(file.source);
|
|
7
|
-
const ARGUMENTS = 'arguments';
|
|
8
|
-
const ARGS = 'args';
|
|
9
|
-
const createArrowFunctionExpression = (fn, args) => j.arrowFunctionExpression((fn.params || []).concat(j.restElement(args)), fn.body, fn.generator);
|
|
10
|
-
const filterMemberExpressions = path => path.parent.value.type !== "MemberExpression";
|
|
11
|
-
const filterArrowFunctions = path => {
|
|
12
|
-
while (path.parent) {
|
|
13
|
-
switch (path.value.type) {
|
|
14
|
-
case 'ArrowFunctionExpression':
|
|
15
|
-
if (j(path).find(j.Identifier, {
|
|
16
|
-
name: ARGS
|
|
17
|
-
}).size()) {
|
|
18
|
-
console.error(file.path + ': arrow function uses "' + ARGS + '" already. ' + 'Please rename this identifier first.');
|
|
19
|
-
return false;
|
|
20
|
-
}
|
|
21
|
-
return true;
|
|
22
|
-
case 'FunctionExpression':
|
|
23
|
-
case 'MethodDeclaration':
|
|
24
|
-
case 'Function':
|
|
25
|
-
case 'FunctionDeclaration':
|
|
26
|
-
return false;
|
|
27
|
-
default:
|
|
28
|
-
break;
|
|
29
|
-
}
|
|
30
|
-
path = path.parent;
|
|
31
|
-
}
|
|
32
|
-
return false;
|
|
33
|
-
};
|
|
34
|
-
const updateArgumentsCalls = path => {
|
|
35
|
-
var afPath = path;
|
|
36
|
-
while (afPath.parent) {
|
|
37
|
-
if (afPath.value.type == 'ArrowFunctionExpression') {
|
|
38
|
-
break;
|
|
39
|
-
}
|
|
40
|
-
afPath = afPath.parent;
|
|
41
|
-
}
|
|
42
|
-
const {
|
|
43
|
-
value: fn
|
|
44
|
-
} = afPath;
|
|
45
|
-
const {
|
|
46
|
-
params
|
|
47
|
-
} = fn;
|
|
48
|
-
const param = params[params.length - 1];
|
|
49
|
-
var args;
|
|
50
|
-
if (param && param.type == 'RestElement') {
|
|
51
|
-
params.pop();
|
|
52
|
-
args = param.argument;
|
|
53
|
-
} else {
|
|
54
|
-
args = j.identifier(ARGS);
|
|
55
|
-
}
|
|
56
|
-
j(afPath).replaceWith(createArrowFunctionExpression(fn, args));
|
|
57
|
-
if (params.length) {
|
|
58
|
-
j(path).replaceWith(j.arrayExpression(params.concat(j.spreadElement(args))));
|
|
59
|
-
} else {
|
|
60
|
-
j(path).replaceWith(args);
|
|
61
|
-
}
|
|
62
|
-
};
|
|
63
|
-
const didTransform = root.find(j.Identifier, {
|
|
64
|
-
name: ARGUMENTS
|
|
65
|
-
}).filter(filterMemberExpressions).filter(filterArrowFunctions).forEach(updateArgumentsCalls).size() > 0;
|
|
66
|
-
return didTransform ? root.toSource(printOptions) : null;
|
|
67
|
-
};
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
export default (fileInfo, api) => {
|
|
2
|
-
const j = api.jscodeshift;
|
|
3
|
-
return j(fileInfo.source).find(j.FunctionExpression).forEach(path => {
|
|
4
|
-
console.warn("-- Console oa", path.value);
|
|
5
|
-
}).toSource();
|
|
6
|
-
// return j(fileInfo.source)
|
|
7
|
-
// .find(j.CallExpression, {
|
|
8
|
-
// callee: {
|
|
9
|
-
// type: "MemberExpression",
|
|
10
|
-
// object: { type: "Identifier", name: "function" }
|
|
11
|
-
// }
|
|
12
|
-
// })
|
|
13
|
-
// .remove()
|
|
14
|
-
// .toSource();
|
|
15
|
-
// return api
|
|
16
|
-
// .jscodeshift(fileInfo.source)
|
|
17
|
-
// .find(j.CallExpression, {
|
|
18
|
-
// callee: {
|
|
19
|
-
// type: "MemberExpression",
|
|
20
|
-
// object: { type: "Identifier", name: "function" }
|
|
21
|
-
// }
|
|
22
|
-
// })
|
|
23
|
-
// .renameTo("zebra")
|
|
24
|
-
// .toSource();
|
|
25
|
-
};
|
package/dist/lib/codemod/test.js
DELETED
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import React, { Component } from "react";
|
|
2
|
-
import { render, Color, Box } from "ink";
|
|
3
|
-
import Selector from "./Selector.js";
|
|
4
|
-
import SelectInput from "ink-select-input";
|
|
5
|
-
import chalk from "chalk";
|
|
6
|
-
import { Tabs, Tab } from "./TabChanger.js";
|
|
7
|
-
// import { Tabs, Tab } from "ink-tab";
|
|
8
|
-
|
|
9
|
-
class App extends Component {
|
|
10
|
-
constructor() {
|
|
11
|
-
super();
|
|
12
|
-
this.state = {
|
|
13
|
-
activeTab: "foo",
|
|
14
|
-
i: 0,
|
|
15
|
-
active: [0, 0]
|
|
16
|
-
};
|
|
17
|
-
}
|
|
18
|
-
handleTabChange = name => {
|
|
19
|
-
this.setState({
|
|
20
|
-
activeTab: name
|
|
21
|
-
});
|
|
22
|
-
};
|
|
23
|
-
render() {
|
|
24
|
-
return /*#__PURE__*/React.createElement(Box, null, /*#__PURE__*/React.createElement(Tabs, {
|
|
25
|
-
activeTab: this.state.activeTab,
|
|
26
|
-
onChange: this.handleTabChange
|
|
27
|
-
}, /*#__PURE__*/React.createElement(Tab, {
|
|
28
|
-
name: "foo"
|
|
29
|
-
// renderName={() => (
|
|
30
|
-
// <Box flexDirection={"column"}>
|
|
31
|
-
// <Box>
|
|
32
|
-
// <Color bold>TITLE</Color>
|
|
33
|
-
// </Box>
|
|
34
|
-
// <Box>Under</Box>
|
|
35
|
-
// </Box>
|
|
36
|
-
// )}
|
|
37
|
-
}, /*#__PURE__*/React.createElement(Box, null, "Test 52")), /*#__PURE__*/React.createElement(Tab, {
|
|
38
|
-
name: "baaar"
|
|
39
|
-
}, /*#__PURE__*/React.createElement(Box, {
|
|
40
|
-
padding: 2
|
|
41
|
-
}, /*#__PURE__*/React.createElement(Color, {
|
|
42
|
-
red: true,
|
|
43
|
-
bold: true
|
|
44
|
-
}, "HI"))), /*#__PURE__*/React.createElement(Tab, {
|
|
45
|
-
name: "baz"
|
|
46
|
-
}, "Baz")));
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
render(/*#__PURE__*/React.createElement(App, null));
|
|
50
|
-
/**
|
|
51
|
-
<Selector />
|
|
52
|
-
|
|
53
|
-
<SelectInput
|
|
54
|
-
items={[
|
|
55
|
-
{
|
|
56
|
-
label: `${chalk.bold.green("Test")}
|
|
57
|
-
two four fibe`,
|
|
58
|
-
value: "test"
|
|
59
|
-
},
|
|
60
|
-
{ label: "Test2", value: "test2" }
|
|
61
|
-
]}
|
|
62
|
-
onSelect={this.handleSelect}
|
|
63
|
-
/>
|
|
64
|
-
*/
|
|
@@ -1,133 +0,0 @@
|
|
|
1
|
-
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
-
import React, { PureComponent, Component } from "react";
|
|
3
|
-
import { Color, Box, StdinContext } from "ink";
|
|
4
|
-
import Table from "./Table.js";
|
|
5
|
-
const data = [["Sosa Saunders", "male", 17, "sosa.saunders@mail.com"], ["Sass6osa Saunders", "male", 17, "sosa.saunders@mail.com"], ["Sosa 62626Saunders", "male", 17, "sosa.saunders@mail.com"]];
|
|
6
|
-
const columCount = data[0].length - 1;
|
|
7
|
-
const rowCount = data.length - 1;
|
|
8
|
-
const ARROW_UP = "\u001B[A";
|
|
9
|
-
const ARROW_DOWN = "\u001B[B";
|
|
10
|
-
const ARROW_LEFT = "\u001B[D";
|
|
11
|
-
const ARROW_RIGHT = "\u001B[C";
|
|
12
|
-
const ENTER = "\r";
|
|
13
|
-
class Counter extends Component {
|
|
14
|
-
constructor() {
|
|
15
|
-
super();
|
|
16
|
-
console.clear();
|
|
17
|
-
this.state = {
|
|
18
|
-
i: 0,
|
|
19
|
-
active: [0, 0]
|
|
20
|
-
};
|
|
21
|
-
}
|
|
22
|
-
handleInput = data => {
|
|
23
|
-
const s = String(data);
|
|
24
|
-
let [rowA, columnA] = this.state.active;
|
|
25
|
-
if (s === ARROW_DOWN) {
|
|
26
|
-
if (rowA < rowCount) {
|
|
27
|
-
rowA++;
|
|
28
|
-
} else {
|
|
29
|
-
rowA = 0;
|
|
30
|
-
}
|
|
31
|
-
this.setState({
|
|
32
|
-
active: [rowA, columnA]
|
|
33
|
-
});
|
|
34
|
-
}
|
|
35
|
-
if (s === ARROW_UP) {
|
|
36
|
-
if (rowA !== 0) {
|
|
37
|
-
rowA--;
|
|
38
|
-
} else {
|
|
39
|
-
rowA = rowCount;
|
|
40
|
-
}
|
|
41
|
-
this.setState({
|
|
42
|
-
active: [rowA, columnA]
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
|
-
if (s === ARROW_LEFT) {
|
|
46
|
-
if (columnA !== 0) {
|
|
47
|
-
columnA--;
|
|
48
|
-
} else {
|
|
49
|
-
columnA = columCount;
|
|
50
|
-
}
|
|
51
|
-
this.setState({
|
|
52
|
-
active: [rowA, columnA]
|
|
53
|
-
});
|
|
54
|
-
}
|
|
55
|
-
if (s === ARROW_RIGHT) {
|
|
56
|
-
if (columnA < columCount) {
|
|
57
|
-
columnA++;
|
|
58
|
-
} else {
|
|
59
|
-
columnA = 0;
|
|
60
|
-
}
|
|
61
|
-
this.setState({
|
|
62
|
-
active: [rowA, columnA]
|
|
63
|
-
});
|
|
64
|
-
}
|
|
65
|
-
if (s === ENTER) {
|
|
66
|
-
console.info("ENTER)");
|
|
67
|
-
}
|
|
68
|
-
};
|
|
69
|
-
handleSelect = item => {
|
|
70
|
-
console.log(item);
|
|
71
|
-
};
|
|
72
|
-
componentDidMount() {
|
|
73
|
-
const {
|
|
74
|
-
stdin,
|
|
75
|
-
setRawMode
|
|
76
|
-
} = this.props;
|
|
77
|
-
setRawMode(true);
|
|
78
|
-
stdin.on("data", this.handleInput);
|
|
79
|
-
}
|
|
80
|
-
render() {
|
|
81
|
-
return /*#__PURE__*/React.createElement(Box, {
|
|
82
|
-
flexDirection: "column"
|
|
83
|
-
}, /*#__PURE__*/React.createElement(Table, {
|
|
84
|
-
cell: ({
|
|
85
|
-
children,
|
|
86
|
-
cellData
|
|
87
|
-
}) => {
|
|
88
|
-
const {
|
|
89
|
-
row,
|
|
90
|
-
column
|
|
91
|
-
} = cellData;
|
|
92
|
-
// console.info("Console --- cellData.i", row, column);
|
|
93
|
-
const [rowA, columnA] = this.state.active;
|
|
94
|
-
let isActive = row + "_" + column === rowA + "_" + columnA;
|
|
95
|
-
return /*#__PURE__*/React.createElement(Box, {
|
|
96
|
-
paddingRight: 1
|
|
97
|
-
}, /*#__PURE__*/React.createElement(Color, {
|
|
98
|
-
hex: isActive ? "#1cff9a" : "#FFF",
|
|
99
|
-
bgHex: isActive ? "#0087ff" : "#000"
|
|
100
|
-
}, children[1]));
|
|
101
|
-
},
|
|
102
|
-
data: data
|
|
103
|
-
}), /*#__PURE__*/React.createElement(Box, {
|
|
104
|
-
width: 32,
|
|
105
|
-
margin: 1
|
|
106
|
-
}, /*#__PURE__*/React.createElement(Box, {
|
|
107
|
-
width: 5,
|
|
108
|
-
height: 5,
|
|
109
|
-
marginRight: 5
|
|
110
|
-
}, /*#__PURE__*/React.createElement(Color, {
|
|
111
|
-
bgHex: "#f00"
|
|
112
|
-
}, "Hey theasdre")), /*#__PURE__*/React.createElement(Box, {
|
|
113
|
-
width: 5,
|
|
114
|
-
marginLeft: 5
|
|
115
|
-
}, /*#__PURE__*/React.createElement(Color, {
|
|
116
|
-
hex: "#000000",
|
|
117
|
-
bgHex: "#FFFFFF"
|
|
118
|
-
}, "Hey theasdre"))));
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
export default class Keyselect extends PureComponent {
|
|
122
|
-
render() {
|
|
123
|
-
return /*#__PURE__*/React.createElement(StdinContext.Consumer, null, ({
|
|
124
|
-
stdin,
|
|
125
|
-
setRawMode
|
|
126
|
-
}) => /*#__PURE__*/React.createElement(Counter, _extends({}, this.props, {
|
|
127
|
-
stdin: stdin,
|
|
128
|
-
setRawMode: setRawMode
|
|
129
|
-
})));
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
// render(<Keyselect />);
|