{"id":18483341,"url":"https://github.com/cloudcmd/console-io","last_synced_at":"2025-04-06T09:08:21.565Z","repository":{"id":18917074,"uuid":"22135962","full_name":"cloudcmd/console-io","owner":"cloudcmd","description":"Web console","archived":false,"fork":false,"pushed_at":"2023-10-12T07:42:41.000Z","size":1298,"stargazers_count":56,"open_issues_count":0,"forks_count":8,"subscribers_count":10,"default_branch":"master","last_synced_at":"2025-03-30T07:11:26.215Z","etag":null,"topics":["cloudcmd","console","expressjs","middleware","nodejs"],"latest_commit_sha":null,"homepage":"http://cloudcmd.io","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"psycopg/ZPsycopgDA","license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cloudcmd.png","metadata":{"files":{"readme":"README.md","changelog":"ChangeLog","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2014-07-23T07:18:33.000Z","updated_at":"2024-09-15T20:02:27.000Z","dependencies_parsed_at":"2023-10-12T17:26:54.576Z","dependency_job_id":null,"html_url":"https://github.com/cloudcmd/console-io","commit_stats":{"total_commits":670,"total_committers":3,"mean_commits":"223.33333333333334","dds":0.3940298507462686,"last_synced_commit":"46655228f210ca2d9187f79eb694b76efdde6ca3"},"previous_names":[],"tags_count":216,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cloudcmd%2Fconsole-io","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cloudcmd%2Fconsole-io/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cloudcmd%2Fconsole-io/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cloudcmd%2Fconsole-io/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cloudcmd","download_url":"https://codeload.github.com/cloudcmd/console-io/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247457801,"owners_count":20941906,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cloudcmd","console","expressjs","middleware","nodejs"],"created_at":"2024-11-06T12:35:23.598Z","updated_at":"2025-04-06T09:08:21.549Z","avatar_url":"https://github.com/cloudcmd.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Console [![License][LicenseIMGURL]][LicenseURL] [![NPM version][NPMIMGURL]][NPMURL]\n\n[NPMIMGURL]: https://img.shields.io/npm/v/console-io.svg?style=flat\n[LicenseIMGURL]: https://img.shields.io/badge/license-MIT-317BF9.svg?style=flat\n[NPM_INFO_IMG]: https://nodei.co/npm/console-io.png\n[NPMURL]: https://npmjs.org/package/console-io \"npm\"\n[LicenseURL]: https://tldrlegal.com/license/mit-license \"MIT License\"\n\nWeb console used in [Cloud Commander](http://cloudcmd.io).\n\n![Console](https://raw.githubusercontent.com/cloudcmd/console/master/img/console.png \"Console\")\n\n## Install\n\n`npm i console-io -g`\n\n## Use as standalone\n\nStart `console`, go to url `http://localhost:1337`\n\n## Hot keys\n\n|Key                    |Operation\n|:----------------------|:--------------------------------------------\n| `Ctrl + Z`            | cancel input\n| `Ctrl + L`            | clear screen\n| `Ctrl + C`            | kill running task\n\nFor more details see [Jq-console keyboard shortcuts](https://github.com/replit/jq-console#default-key-config).\n\n## API\n\n### Client API\n\n#### Console(element [, options])\n\n- element   - html element, or selector\n- options   - (optional) {cwd}\n\nWhen prefix set in server and client, you should use same prefix in html.\nFor example, if you use prefix \"any_prefix\" you should connect\nconsole script in this way:\n\n`\u003cscript src=\"/any_prefix/console.js\"\u003e\u003c/script\u003e`\n\n#### addShortCuts(shortCuts)\n\n- shortCuts - object contain big letter and function.\n\nExample: show alert on `Ctrl + A`:\n\n```js\nasync () =\u003e {\n    const konsole = await Console();\n    \n    konsole.addShortCuts({\n        A() {\n            alert('hello');\n        },\n    });\n};\n```\n\n#### getPromptText()\n\nGet text of prompt.\n\n#### setPromptText(text)\n\n- text - string of new text\n\nSet new text of prompt.\n\n#### focus()\n\nSet focus on Console.\n\n### Server API\n\n#### Console(options)\n\nCould be used as middleware, or for init `Console`.\n\n```js\nConsole.listen(socket, {\n    server, // when no socket\n    online: true, // default\n    prefix: '/console', // default\n    prefixSocket: '/console', // default\n    auth: (accept, reject) =\u003e (username, password) =\u003e {\n        accept();\n    },\n});\n```\n\n#### Console.middle(options)\n\nMiddleware function if there is a need of init `socket` in another place.\n\n```js\nConsole({\n    prefix: '/console', // default\n    online: true, // default\n});\n```\n\n## Use as middleware\n\nTo use `Console` in your programs you should make local install:\n\n`npm i console-io express`\n\nAnd use it in your program\n\n```js\n// server.js\nconst webconsole = require('console-io');\nconst http = require('http');\nconst express = require('express');\n\nconst app = express();\nconst server = http.createServer(app);\n\nconst port = 1337;\nconst ip = '0.0.0.0';\n\nconst online = true;\napp\n    .use(webconsole({\n        server,\n        online, // load jquery and socket.io from cdn\n    }))\n    .use(express.static(__dirname));\n\nwebconsole.listen({\n    server,\n});\n\nserver.listen(port, ip);\n```\n\n```html\n\u003c!-- index.html --\u003e\n\n\u003cdiv class=\"console\"\u003e\u003c/div\u003e\n\u003cscript src=\"/console/console.js\"\u003e\u003c/script\u003e\n\u003cscript\u003e\n    document.addEventListener('load', async () =\u003e {\n        const konsole = await Console('.console', {\n            prefix: 'console',\n            env: {\n                CURRENT_FILE: getCurrentFile(),\n                CURRENT_APP: 'console-io'\n            }\n        });\n        \n        console.log('console ready')\n        konsole.focus();\n        \n        function getCurrentFile() {\n            return 'filename.txt';\n        }\n    });\n\u003c/script\u003e\n```\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcloudcmd%2Fconsole-io","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcloudcmd%2Fconsole-io","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcloudcmd%2Fconsole-io/lists"}