From da39e698327df0f506b4ef6684dfe581ab2f0d60 Mon Sep 17 00:00:00 2001
From: jdepriest
Date: Tue, 23 Jul 2019 20:50:23 -0400
Subject: [PATCH] adding git commands to the game
---
assets/cmds/README.md | 4 +
assets/cmds/git.js | 194 ++++++++++++++++++++++++++++++++++++++++++
index.html | 2 +-
src/app.js | 18 +++-
src/cmds.js | 11 ++-
src/main.js | 6 +-
6 files changed, 230 insertions(+), 5 deletions(-)
create mode 100644 assets/cmds/git.js
diff --git a/assets/cmds/README.md b/assets/cmds/README.md
index bb541ed..aba453f 100644
--- a/assets/cmds/README.md
+++ b/assets/cmds/README.md
@@ -27,3 +27,7 @@ A few types of JS code are accepted.
- additional [built-in properties of the global object](https://tc39.github.io/ecma262/#sec-additional-properties-of-the-global-object)
- `async` should be added. it won't appear in the above lists because it is not a proper keyword (it's only a keyword in certain contexts but can still be used as a variable name, etc).
- `window`, `document`, `navigator` I can't find in any spec but should be included
+
+## Git
+
+Get all core git commands from `/usr/lib/git-core/`.
diff --git a/assets/cmds/git.js b/assets/cmds/git.js
new file mode 100644
index 0000000..3c0d0b8
--- /dev/null
+++ b/assets/cmds/git.js
@@ -0,0 +1,194 @@
+/**
+ * This is a list of git commands
+ *
+ * See the README in this directory for more on how this list is assembled.
+ *
+ * There are duplicates, and that's okay. But if you are removing items, be sure to look for multiple entries!
+ */
+export default {
+ name: "Git",
+ commonCmds: [
+ "clone",
+ "init",
+ "add",
+ "mv",
+ "reset",
+ "rm",
+ "bisect",
+ "grep",
+ "log",
+ "show",
+ "status",
+ "branch",
+ "checkout",
+ "commit",
+ "diff",
+ "merge",
+ "rebase",
+ "tag",
+ "fetch",
+ "pull",
+ "push"
+ ],
+ cmds: [
+ // keywords
+ "add",
+ "add--interactive",
+ "am",
+ "annotate",
+ "apply",
+ "archive",
+ "bisect",
+ "bisect--helper",
+ "blame",
+ "branch",
+ "bundle",
+ "cat-file",
+ "check-attr",
+ "check-ignore",
+ "check-mailmap",
+ "checkout",
+ "checkout-index",
+ "check-ref-format",
+ "cherry",
+ "cherry-pick",
+ "clean",
+ "clone",
+ "column",
+ "commit",
+ "commit-tree",
+ "config",
+ "count-objects",
+ "credential",
+ "credential-cache",
+ "credential-cache--daemon",
+ "credential-store",
+ "daemon",
+ "describe",
+ "diff",
+ "diff-files",
+ "diff-index",
+ "difftool",
+ "difftool--helper",
+ "diff-tree",
+ "fast-export",
+ "fast-import",
+ "fetch",
+ "fetch-pack",
+ "filter-branch",
+ "fmt-merge-msg",
+ "for-each-ref",
+ "format-patch",
+ "fsck",
+ "fsck-objects",
+ "c",
+ "et-tar-commit-id",
+ "rep",
+ "hash-object",
+ "help",
+ "http-backend",
+ "http-fetch",
+ "http-push",
+ "map-send",
+ "ndex-pack",
+ "nit",
+ "nit-db",
+ "nstaweb",
+ "nterpret-trailers",
+ "log",
+ "ls-files",
+ "ls-remote",
+ "ls-tree",
+ "mailinfo",
+ "mailsplit",
+ "merge",
+ "merge-base",
+ "merge-file",
+ "merge-index",
+ "merge-octopus",
+ "merge-one-file",
+ "merge-ours",
+ "merge-recursive",
+ "merge-resolve",
+ "merge-subtree",
+ "mergetool",
+ "mergetool--lib",
+ "merge-tree",
+ "mktag",
+ "mktree",
+ "mv",
+ "name-rev",
+ "notes",
+ "pack-objects",
+ "pack-redundant",
+ "pack-refs",
+ "parse-remote",
+ "patch-id",
+ "prune",
+ "prune-packed",
+ "pull",
+ "push",
+ "quiltimport",
+ "read-tree",
+ "rebase",
+ "rebase--am",
+ "rebase--helper",
+ "rebase--interactive",
+ "rebase--merge",
+ "receive-pack",
+ "reflog",
+ "remote",
+ "remote-ext",
+ "remote-fd",
+ "remote-ftp",
+ "remote-ftps",
+ "remote-http",
+ "remote-https",
+ "remote-testsvn",
+ "repack",
+ "replace",
+ "request-pull",
+ "rerere",
+ "reset",
+ "revert",
+ "rev-list",
+ "rev-parse",
+ "rm",
+ "send-pack",
+ "shell",
+ "sh-i18n",
+ "sh-i18n--envsubst",
+ "shortlog",
+ "show",
+ "show-branch",
+ "show-index",
+ "show-ref",
+ "sh-prompt",
+ "sh-setup",
+ "stage",
+ "stash",
+ "status",
+ "stripspace",
+ "submodule",
+ "submodule--helper",
+ "subtree",
+ "symbolic-ref",
+ "ag",
+ "unpack-file",
+ "unpack-objects",
+ "update-index",
+ "update-ref",
+ "update-server-info",
+ "upload-archive",
+ "upload-pack",
+ "var",
+ "verify-commit",
+ "verify-pack",
+ "verify-tag",
+ "web--browse",
+ "whatchanged",
+ "worktree",
+ "write-tree",
+ "mergetools"
+ ]
+};
diff --git a/index.html b/index.html
index dd5b26a..95797f9 100644
--- a/index.html
+++ b/index.html
@@ -34,7 +34,7 @@
You have {{parseInt(gameDuration/1000)}} seconds to type commands from:
- BASH · JAVASCRIPT · PYTHON · HTML5
+ BASH · JAVASCRIPT · PYTHON · HTML5 · GIT
Set the terminal on fire. Type PLAY to begin.
diff --git a/src/app.js b/src/app.js
index 21cf659..dcfbb6a 100644
--- a/src/app.js
+++ b/src/app.js
@@ -71,6 +71,7 @@ const app = new Vue({
bash: 0,
html: 0,
py: 0,
+ git: 0,
recentValidCharacters: 0,
totalValidCharacters: 0,
totalValidCommands: 0
@@ -216,6 +217,8 @@ const app = new Vue({
let pyCommon = cmds.cmdsByLang.py.commonCmds;
let htmlAll = filterCmds(cmds.cmdsByLang.html.cmds);
let htmlCommon = filterCmds(cmds.cmdsByLang.html.commonCmds);
+ let gitAll = filterCmds(cmds.cmdsByLang.git.cmds);
+ let gitCommon = filterCmds(cmds.cmdsByLang.git.commonCmds);
let cn = config.GOLDEN_CMDS_COMMON_PER_LANG;
let rn = config.GOLDEN_CMDS_RANDOM_PER_LANG;
@@ -232,12 +235,16 @@ const app = new Vue({
),
html: _.sampleSize(htmlCommon, cn).concat(
_.sampleSize(_.xor(htmlCommon, htmlAll), rn)
+ ),
+ git: _.sampleSize(gitCommon, cn).concat(
+ _.sampleSize(_.xor(gitCommon, gitAll), rn)
)
};
goldenCommands.all = goldenCommands.bash.concat(
goldenCommands.js,
goldenCommands.py,
- goldenCommands.html
+ goldenCommands.html,
+ goldenCommands.git
);
return goldenCommands;
@@ -284,6 +291,14 @@ const app = new Vue({
.map(cs => cs.join(""))
.join("");
+ out += "\n";
+
+ // title of fifth language
+ out += cmds.git().name +"\n"
+
+ // commands for fifth language
+ out += goldCmds.git.map(c => ` - ${c}\n`).join("")
+
return out;
},
printHighScores: function(leaders) {
@@ -378,6 +393,7 @@ const app = new Vue({
this.count.bash = 0;
this.count.html = 0;
this.count.py = 0;
+ this.count.git = 0;
this.count.recentValidCharacters = 0;
this.count.totalValidCharacters = 0;
this.count.totalValidCommands = 0;
diff --git a/src/cmds.js b/src/cmds.js
index 4b4e2b9..2b509df 100644
--- a/src/cmds.js
+++ b/src/cmds.js
@@ -4,19 +4,22 @@ import bashCmds from "../assets/cmds/bash.js";
import jsCmds from "../assets/cmds/js.js";
import pyCmds from "../assets/cmds/python.js";
import htmlCmds from "../assets/cmds/html.js";
+import gitCmds from "../assets/cmds/git.js";
const allCmds = _.union(
bash().cmds,
js().cmds,
py().cmds,
- html().cmds /* and other langs as needed */
+ html().cmds,
+ git().cmds /* and other langs as needed */
);
export const cmdsByLang = {
bash: bash(),
js: js(),
py: py(),
- html: html()
+ html: html(),
+ git: git()
};
export function all() {
@@ -39,6 +42,10 @@ export function html() {
return htmlCmds;
}
+export function git() {
+ return gitCmds;
+}
+
export function longest() {
return allCmds.reduce(function(a, b) {
return a.length > b.length ? a : b;
diff --git a/src/main.js b/src/main.js
index ad96535..ce6cf85 100644
--- a/src/main.js
+++ b/src/main.js
@@ -171,6 +171,7 @@ of the following:
- JavaScript keywords, objects, functions
- Python keywords, objects, functions
- HTML5 tags
+- Git commands
Press Enter to continue.`;
@@ -380,6 +381,8 @@ Press Enter to continue.`;
app.cmd += `PYTHON ${app.count.py}\n`;
app.cmd += `JAVASCRIPT ${app.count.js}\n`;
app.cmd += `HTML5 ${app.count.html}\n`;
+ app.cmd += `GIT ${app.count.git}\n`;
+
app.cmd += `\nPress Enter to continue.`;
@@ -751,7 +754,8 @@ function deriveTribe() {
{ tribe: "bash", count: app.count.bash },
{ tribe: "Python", count: app.count.py },
{ tribe: "JavaScript", count: app.count.js },
- { tribe: "HTML", count: app.count.html }
+ { tribe: "HTML", count: app.count.html },
+ { tribe: "GIT", count: app.count.git }
];
const tribesSorted = _.reverse(_.sortBy(cmdCounts, "count"));