Skip to content

Commit c495ccf

Browse files
authored
Merge pull request #408 from AtkinsSJ/git-client
Add a git client
2 parents 146ce65 + 10f715f commit c495ccf

37 files changed

+3434
-1189
lines changed

package-lock.json

+681-909
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/backend/src/SelfHostedModule.js

+13
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,15 @@ class SelfHostedModule extends AdvancedBase {
4040
PUTER_JS_URL: ({ global_config: config }) => config.origin + '/sdk/puter.dev.js',
4141
}
4242
},
43+
{
44+
name: 'git:rollup-watch',
45+
directory: 'packages/git',
46+
command: 'npx',
47+
args: ['rollup', '-c', 'rollup.config.js', '--watch'],
48+
env: {
49+
PUTER_JS_URL: ({ global_config: config }) => config.origin + '/sdk/puter.dev.js',
50+
}
51+
},
4352
],
4453
});
4554

@@ -58,6 +67,10 @@ class SelfHostedModule extends AdvancedBase {
5867
prefix: '/builtin/phoenix',
5968
path: path_.resolve(__dirname, '../../../packages/phoenix/dist'),
6069
},
70+
{
71+
prefix: '/builtin/git',
72+
path: path_.resolve(__dirname, '../../../packages/git/dist'),
73+
},
6174
],
6275
});
6376
}

packages/backend/src/services/database/SqliteDatabaseAccessService.js

+6-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ class SqliteDatabaseAccessService extends BaseDatabaseAccessService {
4242
this.db = new Database(this.config.path);
4343

4444
// Database upgrade logic
45-
const TARGET_VERSION = 7;
45+
const TARGET_VERSION = 8;
4646

4747
if ( do_setup ) {
4848
this.log.noticeme(`SETUP: creating database at ${this.config.path}`);
@@ -56,6 +56,7 @@ class SqliteDatabaseAccessService extends BaseDatabaseAccessService {
5656
'0007_sessions.sql',
5757
'0008_otp.sql',
5858
'0009_app-prefix-fix.sql',
59+
'0010_add-git-app.sql',
5960
].map(p => path_.join(__dirname, 'sqlite_setup', p));
6061
const fs = require('fs');
6162
for ( const filename of sql_files ) {
@@ -100,6 +101,10 @@ class SqliteDatabaseAccessService extends BaseDatabaseAccessService {
100101
upgrade_files.push('0009_app-prefix-fix.sql');
101102
}
102103

104+
if ( user_version <= 7 ) {
105+
upgrade_files.push('0010_add-git-app.sql');
106+
}
107+
103108
if ( upgrade_files.length > 0 ) {
104109
this.log.noticeme(`Database out of date: ${this.config.path}`);
105110
this.log.noticeme(`UPGRADING DATABASE: ${user_version} -> ${TARGET_VERSION}`);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
INSERT INTO `apps`
2+
(`uid`, `owner_user_id`, `icon`, `name`, `title`, `description`, `godmode`, `background`, `maximize_on_start`, `index_url`, `approved_for_listing`, `approved_for_opening_items`, `approved_for_incentive_program`, `timestamp`, `last_review`, `tags`, `app_owner`)
3+
VALUES
4+
('app-e3ac5486-da8c-42ad-8377-8728086e0980', 1, 'data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSI5MnB0IiBoZWlnaHQ9IjkycHQiIHZpZXdCb3g9IjAgMCA5MiA5MiI+PGRlZnM+PGNsaXBQYXRoIGlkPSJhIj48cGF0aCBkPSJNMCAuMTEzaDkxLjg4N1Y5MkgwWm0wIDAiLz48L2NsaXBQYXRoPjwvZGVmcz48ZyBjbGlwLXBhdGg9InVybCgjYSkiPjxwYXRoIHN0eWxlPSJzdHJva2U6bm9uZTtmaWxsLXJ1bGU6bm9uemVybztmaWxsOiNmMDNjMmU7ZmlsbC1vcGFjaXR5OjEiIGQ9Ik05MC4xNTYgNDEuOTY1IDUwLjAzNiAxLjg0OGE1LjkxOCA1LjkxOCAwIDAgMC04LjM3MiAwbC04LjMyOCA4LjMzMiAxMC41NjYgMTAuNTY2YTcuMDMgNy4wMyAwIDAgMSA3LjIzIDEuNjg0IDcuMDM0IDcuMDM0IDAgMCAxIDEuNjY5IDcuMjc3bDEwLjE4NyAxMC4xODRhNy4wMjggNy4wMjggMCAwIDEgNy4yNzggMS42NzIgNy4wNCA3LjA0IDAgMCAxIDAgOS45NTcgNy4wNSA3LjA1IDAgMCAxLTkuOTY1IDAgNy4wNDQgNy4wNDQgMCAwIDEtMS41MjgtNy42NmwtOS41LTkuNDk3VjU5LjM2YTcuMDQgNy4wNCAwIDAgMSAxLjg2IDExLjI5IDcuMDQgNy4wNCAwIDAgMS05Ljk1NyAwIDcuMDQgNy4wNCAwIDAgMSAwLTkuOTU4IDcuMDYgNy4wNiAwIDAgMSAyLjMwNC0xLjUzOVYzMy45MjZhNy4wNDkgNy4wNDkgMCAwIDEtMy44Mi05LjIzNEwyOS4yNDIgMTQuMjcyIDEuNzMgNDEuNzc3YTUuOTI1IDUuOTI1IDAgMCAwIDAgOC4zNzFMNDEuODUyIDkwLjI3YTUuOTI1IDUuOTI1IDAgMCAwIDguMzcgMGwzOS45MzQtMzkuOTM0YTUuOTI1IDUuOTI1IDAgMCAwIDAtOC4zNzEiLz48L2c+PC9zdmc+', 'git', 'Git', 'Puter Git client', 0, 1, 0, 'https://builtins.namespaces.puter.com/git', 1, 0, 0, '2024-05-15 10:33:00', NULL, 'productivity', NULL);

packages/git/.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
node_modules/
2+
dist/

packages/git/LICENSE

+661
Large diffs are not rendered by default.

packages/git/README.md

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Puter Git Client
2+
3+
This is a git client running on the Puter filesystem, using [isomorphic-git](https://isomorphic-git.org).

packages/git/assets/index.html

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<title>Git client</title>
6+
<script src="__SDK_URL__"></script>
7+
<script src="config.js"></script>
8+
<script src="bundle.js"></script>
9+
<script>
10+
document.addEventListener('DOMContentLoaded', async () => {
11+
main();
12+
});
13+
</script>
14+
</head>
15+
<body>
16+
This is a cli app so you shouldn't see this
17+
</body>
18+
</html>

packages/git/config/dev.js

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/*
2+
* Copyright (C) 2024 Puter Technologies Inc.
3+
*
4+
* This file is part of Phoenix Shell.
5+
*
6+
* Phoenix Shell is free software: you can redistribute it and/or modify
7+
* it under the terms of the GNU Affero General Public License as published
8+
* by the Free Software Foundation, either version 3 of the License, or
9+
* (at your option) any later version.
10+
*
11+
* This program is distributed in the hope that it will be useful,
12+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
* GNU Affero General Public License for more details.
15+
*
16+
* You should have received a copy of the GNU Affero General Public License
17+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
18+
*/
19+
globalThis.__CONFIG__ = {
20+
sdk_url: 'http://puter.localhost:4100/sdk/puter.js',
21+
};

packages/git/config/release.js

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/*
2+
* Copyright (C) 2024 Puter Technologies Inc.
3+
*
4+
* This file is part of Phoenix Shell.
5+
*
6+
* Phoenix Shell is free software: you can redistribute it and/or modify
7+
* it under the terms of the GNU Affero General Public License as published
8+
* by the Free Software Foundation, either version 3 of the License, or
9+
* (at your option) any later version.
10+
*
11+
* This program is distributed in the hope that it will be useful,
12+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
* GNU Affero General Public License for more details.
15+
*
16+
* You should have received a copy of the GNU Affero General Public License
17+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
18+
*/
19+
globalThis.__CONFIG__ = {
20+
sdk_url: 'https://puter.com/puter.js/v2',
21+
};

packages/git/package.json

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"name": "git",
3+
"version": "1.0.0",
4+
"description": "Git Client for Puter",
5+
"main": "index.js",
6+
"scripts": {
7+
"test": "echo \"Error: no test specified\" && exit 1"
8+
},
9+
"author": "Puter Technologies Inc.",
10+
"license": "AGPL-3.0-only",
11+
"type": "module",
12+
"devDependencies": {
13+
"@rollup/plugin-commonjs": "^24.1.0",
14+
"@rollup/plugin-node-resolve": "^15.0.2",
15+
"@rollup/plugin-replace": "^5.0.2",
16+
"mocha": "^10.2.0",
17+
"rollup": "^3.21.4",
18+
"rollup-plugin-copy": "^3.4.0"
19+
},
20+
"dependencies": {
21+
"@pkgjs/parseargs": "^0.11.0",
22+
"buffer": "^6.0.3",
23+
"isomorphic-git": "^1.25.10"
24+
}
25+
}

packages/git/rollup.config.js

+53
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
/*
2+
* Copyright (C) 2024 Puter Technologies Inc.
3+
*
4+
* This file is part of Phoenix Shell.
5+
*
6+
* Phoenix Shell is free software: you can redistribute it and/or modify
7+
* it under the terms of the GNU Affero General Public License as published
8+
* by the Free Software Foundation, either version 3 of the License, or
9+
* (at your option) any later version.
10+
*
11+
* This program is distributed in the hope that it will be useful,
12+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
* GNU Affero General Public License for more details.
15+
*
16+
* You should have received a copy of the GNU Affero General Public License
17+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
18+
*/
19+
import { nodeResolve } from '@rollup/plugin-node-resolve'
20+
import commonjs from '@rollup/plugin-commonjs';
21+
import copy from 'rollup-plugin-copy';
22+
import process from 'node:process';
23+
24+
const configFile = process.env.CONFIG_FILE ?? 'config/dev.js';
25+
await import(`./${configFile}`);
26+
27+
export default {
28+
input: "src/main.js",
29+
output: {
30+
file: "dist/bundle.js",
31+
format: "iife"
32+
},
33+
plugins: [
34+
nodeResolve({
35+
browser: true,
36+
preferBuiltins: false,
37+
}),
38+
commonjs(),
39+
copy({
40+
targets: [
41+
{
42+
src: 'assets/index.html',
43+
dest: 'dist',
44+
transform: (contents, name) => {
45+
return contents.toString().replace('__SDK_URL__',
46+
process.env.PUTER_JS_URL ?? globalThis.__CONFIG__.sdk_url);
47+
}
48+
},
49+
{ src: configFile, dest: 'dist', rename: 'config.js' }
50+
]
51+
}),
52+
]
53+
}

0 commit comments

Comments
 (0)