guito 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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2023 danisss9
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,45 @@
1
+ # Guito
2
+
3
+ **G**u**IT**o ([**GUI**to](https://dicionario.priberam.org/guito)) is a free and simple git client.
4
+
5
+ ## Table of Contents
6
+
7
+ - [Guito](#guito)
8
+ - [Table of Contents](#table-of-contents)
9
+ - [Install](#install)
10
+ - [Use](#use)
11
+ - [Arguments](#arguments)
12
+ - [Changelog](#changelog)
13
+ - [FAQs](#faqs)
14
+
15
+ ## Install
16
+
17
+ ```cmd
18
+ npm install -g guito
19
+ ```
20
+
21
+ ## Use
22
+
23
+ Run the following command on the folder where you git repository is:
24
+
25
+ ```cmd
26
+ npx guito
27
+ ```
28
+
29
+ ## Arguments
30
+
31
+ No arguments for now.
32
+
33
+ ## Changelog
34
+
35
+ **Version 0.2:**
36
+
37
+ - added header and table components
38
+
39
+ **Version 0.1:**
40
+
41
+ - published library
42
+
43
+ ## FAQs
44
+
45
+ No FAQs for now. (⌐■_■)
package/bin/index.js ADDED
@@ -0,0 +1,50 @@
1
+ #! /usr/bin/env node
2
+ import { dirname, join } from 'node:path';
3
+ import { fileURLToPath } from 'node:url';
4
+ import fastify from 'fastify';
5
+ import fastifyStatic from '@fastify/static';
6
+ import fastifyCors from '@fastify/cors';
7
+ import open from 'open';
8
+ import simpleGit from 'simple-git';
9
+ void (async function main() {
10
+ // Calculate dirname
11
+ const __dirname = dirname(fileURLToPath(import.meta.url));
12
+ // Get port number
13
+ const portArgIndex = process.argv.findIndex((a) => a.toLowerCase() === '--port');
14
+ const port = portArgIndex !== -1 ? +process.argv[portArgIndex + 1] : 8080;
15
+ // Get if should not open browser
16
+ const shouldOpenBrowser = process.argv.findIndex((a) => a.toLowerCase() === '--no-open') === -1;
17
+ // Initialize server
18
+ const app = fastify({
19
+ logger: false,
20
+ });
21
+ // Register cors
22
+ await app.register(fastifyCors);
23
+ // Register static file provider
24
+ app.register(fastifyStatic, {
25
+ root: join(__dirname, 'ui'),
26
+ });
27
+ // Serve UI
28
+ app.get('/', (_req, resp) => resp.sendFile('index.html'));
29
+ // Initialize git lib
30
+ const git = simpleGit(process.cwd());
31
+ // Git Api
32
+ app.get('/api/commits', (_req, resp) => {
33
+ git.log({}, (err, data) => {
34
+ resp.type('application/json').send(data.all);
35
+ });
36
+ });
37
+ app.get('/api/fetch', (_req, resp) => {
38
+ git.fetch({}, (err, data) => {
39
+ resp.type('application/json').send();
40
+ });
41
+ });
42
+ // Run the server
43
+ app.listen({ port }, (err, address) => {
44
+ if (err)
45
+ throw err;
46
+ console.log(`Visit "${address}" to see git explorer.`);
47
+ if (shouldOpenBrowser)
48
+ open(address);
49
+ });
50
+ })();