pinokiod 3.237.0 → 3.239.0
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/kernel/bin/git.js +3 -88
- package/kernel/git.js +28 -0
- package/kernel/index.js +8 -4
- package/package.json +1 -1
- package/server/public/style.css +3 -0
- package/server/views/env_editor.ejs +57 -0
package/kernel/bin/git.js
CHANGED
|
@@ -21,99 +21,14 @@ class Git {
|
|
|
21
21
|
`conda install -y -c conda-forge ${this.cmd()}`
|
|
22
22
|
]
|
|
23
23
|
}, ondata)
|
|
24
|
-
await fs.promises.mkdir(this.kernel.path("config/gh"), { recursive: true }).catch((e) => { })
|
|
25
|
-
|
|
26
|
-
let gitconfig_path = path.resolve(this.kernel.homedir, "gitconfig")
|
|
27
|
-
// check if gitconfig exists
|
|
28
|
-
let exists = await this.kernel.api.exists(gitconfig_path)
|
|
29
|
-
// if not, create one
|
|
30
|
-
if (!exists) {
|
|
31
|
-
await fs.promises.copyFile(
|
|
32
|
-
path.resolve(__dirname, "..", "gitconfig_template"),
|
|
33
|
-
gitconfig_path
|
|
34
|
-
)
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
await fs.promises.mkdir(this.kernel.path("scripts/git"), { recursive: true }).catch((e) => { })
|
|
38
|
-
|
|
39
|
-
let gitfork_path = path.resolve(this.kernel.homedir, "scripts/git/fork.json")
|
|
40
|
-
await fs.promises.copyFile(
|
|
41
|
-
path.resolve(__dirname, "..", "scripts/git/fork"),
|
|
42
|
-
gitfork_path
|
|
43
|
-
)
|
|
44
|
-
|
|
45
|
-
let gitpush_path = path.resolve(this.kernel.homedir, "scripts/git/push.json")
|
|
46
|
-
await fs.promises.copyFile(
|
|
47
|
-
path.resolve(__dirname, "..", "scripts/git/push"),
|
|
48
|
-
gitpush_path
|
|
49
|
-
)
|
|
50
|
-
|
|
51
|
-
let gitcreate_path = path.resolve(this.kernel.homedir, "scripts/git/create.json")
|
|
52
|
-
await fs.promises.copyFile(
|
|
53
|
-
path.resolve(__dirname, "..", "scripts/git/create"),
|
|
54
|
-
gitcreate_path
|
|
55
|
-
)
|
|
56
|
-
|
|
57
|
-
let gitcommit_path = path.resolve(this.kernel.homedir, "scripts/git/commit.json")
|
|
58
|
-
await fs.promises.copyFile(
|
|
59
|
-
path.resolve(__dirname, "..", "scripts/git/commit"),
|
|
60
|
-
gitcommit_path
|
|
61
|
-
)
|
|
62
|
-
|
|
63
|
-
let gitcheckout_path = path.resolve(this.kernel.homedir, "scripts/git/checkout.json")
|
|
64
|
-
await fs.promises.copyFile(
|
|
65
|
-
path.resolve(__dirname, "..", "scripts/git/checkout"),
|
|
66
|
-
gitcheckout_path
|
|
67
|
-
)
|
|
68
|
-
|
|
69
|
-
let gitreset_commit_path = path.resolve(this.kernel.homedir, "scripts/git/reset_commit.json")
|
|
70
|
-
await fs.promises.copyFile(
|
|
71
|
-
path.resolve(__dirname, "..", "scripts/git/reset_commit"),
|
|
72
|
-
gitreset_commit_path
|
|
73
|
-
)
|
|
74
|
-
|
|
75
|
-
let gitreset_file_path = path.resolve(this.kernel.homedir, "scripts/git/reset_file.json")
|
|
76
|
-
await fs.promises.copyFile(
|
|
77
|
-
path.resolve(__dirname, "..", "scripts/git/reset_file"),
|
|
78
|
-
gitreset_file_path
|
|
79
|
-
)
|
|
80
24
|
}
|
|
81
25
|
async installed() {
|
|
82
|
-
let gitconfig_path = path.resolve(this.kernel.homedir, "gitconfig")
|
|
83
|
-
let exists = await this.kernel.api.exists(gitconfig_path)
|
|
84
|
-
if (!exists) {
|
|
85
|
-
return false;
|
|
86
|
-
}
|
|
87
|
-
let gitpush_path = path.resolve(this.kernel.homedir, "scripts/git/push.json")
|
|
88
|
-
let exists2 = await this.kernel.api.exists(gitpush_path)
|
|
89
|
-
if (!exists2) {
|
|
90
|
-
return false;
|
|
91
|
-
}
|
|
92
|
-
let gitcreate_path = path.resolve(this.kernel.homedir, "scripts/git/create.json")
|
|
93
|
-
let exists3 = await this.kernel.api.exists(gitcreate_path)
|
|
94
|
-
if (!exists3) {
|
|
95
|
-
return false;
|
|
96
|
-
}
|
|
97
|
-
let gitcommit_path = path.resolve(this.kernel.homedir, "scripts/git/commit.json")
|
|
98
|
-
let exists4 = await this.kernel.api.exists(gitcommit_path)
|
|
99
|
-
if (!exists4) {
|
|
100
|
-
return false;
|
|
101
|
-
}
|
|
102
|
-
let gitfork_path = path.resolve(this.kernel.homedir, "scripts/git/fork.json")
|
|
103
|
-
let exists5 = await this.kernel.api.exists(gitfork_path)
|
|
104
|
-
if (!exists5) {
|
|
105
|
-
return false;
|
|
106
|
-
}
|
|
107
|
-
|
|
108
26
|
if (this.kernel.platform === "darwin") {
|
|
109
|
-
|
|
110
|
-
return this.kernel.bin.installed.conda && this.kernel.bin.installed.conda.has("git") && this.kernel.bin.installed.conda.has("gh") && gh_config_exists
|
|
27
|
+
return this.kernel.bin.installed.conda && this.kernel.bin.installed.conda.has("git") && this.kernel.bin.installed.conda.has("gh")
|
|
111
28
|
} else if (this.kernel.platform === "win32") {
|
|
112
|
-
|
|
113
|
-
return this.kernel.bin.installed.conda && this.kernel.bin.installed.conda.has("git") && this.kernel.bin.installed.conda.has("gh") && gh_config_exists && this.kernel.bin.installed.conda.has("git-bash")
|
|
29
|
+
return this.kernel.bin.installed.conda && this.kernel.bin.installed.conda.has("git") && this.kernel.bin.installed.conda.has("gh") && this.kernel.bin.installed.conda.has("git-bash")
|
|
114
30
|
} else {
|
|
115
|
-
|
|
116
|
-
return this.kernel.bin.installed.conda && this.kernel.bin.installed.conda.has("git") && this.kernel.bin.installed.conda.has("gh") && gh_config_exists
|
|
31
|
+
return this.kernel.bin.installed.conda && this.kernel.bin.installed.conda.has("git") && this.kernel.bin.installed.conda.has("gh")
|
|
117
32
|
}
|
|
118
33
|
}
|
|
119
34
|
async uninstall(req, ondata) {
|
package/kernel/git.js
CHANGED
|
@@ -11,6 +11,34 @@ class Git {
|
|
|
11
11
|
this.dirs = new Set()
|
|
12
12
|
this.mapping = {}
|
|
13
13
|
}
|
|
14
|
+
async init() {
|
|
15
|
+
const ensureDir = (target) => fs.promises.mkdir(target, { recursive: true }).catch(() => { })
|
|
16
|
+
await Promise.all([
|
|
17
|
+
ensureDir(this.kernel.path("config/gh")),
|
|
18
|
+
ensureDir(this.kernel.path("scripts/git"))
|
|
19
|
+
])
|
|
20
|
+
|
|
21
|
+
const gitconfig_path = path.resolve(this.kernel.homedir, "gitconfig")
|
|
22
|
+
const gitconfigTemplate = path.resolve(__dirname, "gitconfig_template")
|
|
23
|
+
if (!(await this.kernel.api.exists(gitconfig_path))) {
|
|
24
|
+
await fs.promises.copyFile(gitconfigTemplate, gitconfig_path)
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const scripts = [
|
|
28
|
+
"fork",
|
|
29
|
+
"push",
|
|
30
|
+
"create",
|
|
31
|
+
"commit",
|
|
32
|
+
"checkout",
|
|
33
|
+
"reset_commit",
|
|
34
|
+
"reset_file"
|
|
35
|
+
]
|
|
36
|
+
await Promise.all(scripts.map((name) => {
|
|
37
|
+
const src = path.resolve(__dirname, `scripts/git/${name}`)
|
|
38
|
+
const dest = path.resolve(this.kernel.homedir, `scripts/git/${name}.json`)
|
|
39
|
+
return fs.promises.copyFile(src, dest)
|
|
40
|
+
}))
|
|
41
|
+
}
|
|
14
42
|
async findGitDirs(dir, results = []) {
|
|
15
43
|
const entries = await fs.promises.readdir(dir, { withFileTypes: true });
|
|
16
44
|
for (const entry of entries) {
|
package/kernel/index.js
CHANGED
|
@@ -947,8 +947,10 @@ class Kernel {
|
|
|
947
947
|
let ts = Date.now()
|
|
948
948
|
this.bin.init().then(() => {
|
|
949
949
|
if (this.homedir) {
|
|
950
|
-
this.git.
|
|
951
|
-
|
|
950
|
+
this.git.init().then(() => {
|
|
951
|
+
this.git.index(this).then(() => {
|
|
952
|
+
//console.log(this.git.mapping)
|
|
953
|
+
})
|
|
952
954
|
})
|
|
953
955
|
this.shell.init().then(async () => {
|
|
954
956
|
this.bin.check({
|
|
@@ -977,8 +979,10 @@ class Kernel {
|
|
|
977
979
|
}
|
|
978
980
|
})
|
|
979
981
|
if (this.bin.installed.conda.has("git")) {
|
|
980
|
-
await
|
|
981
|
-
|
|
982
|
+
await Promise.all([
|
|
983
|
+
this.proto.init(),
|
|
984
|
+
this.plugin.init(),
|
|
985
|
+
])
|
|
982
986
|
}
|
|
983
987
|
|
|
984
988
|
this.sys = new Sysinfo()
|
package/package.json
CHANGED
package/server/public/style.css
CHANGED
|
@@ -145,6 +145,13 @@ body.dark .comment {
|
|
|
145
145
|
#save {
|
|
146
146
|
background: rgba(127, 91, 243, 0.9);
|
|
147
147
|
}
|
|
148
|
+
#delete-project {
|
|
149
|
+
color: firebrick;
|
|
150
|
+
background: none;
|
|
151
|
+
}
|
|
152
|
+
#delete-project:hover {
|
|
153
|
+
border: 1px solid firebrick;
|
|
154
|
+
}
|
|
148
155
|
a#customize {
|
|
149
156
|
text-decoration: underline;
|
|
150
157
|
cursor: pointer;
|
|
@@ -270,8 +277,53 @@ document.addEventListener("DOMContentLoaded", async () => {
|
|
|
270
277
|
e.preventDefault()
|
|
271
278
|
e.stopPropagation()
|
|
272
279
|
document.querySelector("#editor").classList.toggle("hidden")
|
|
280
|
+
document.body.classList.toggle("center")
|
|
273
281
|
})
|
|
274
282
|
<% } %>
|
|
283
|
+
<% if (!init && name) { %>
|
|
284
|
+
const deleteBtn = document.querySelector("#delete-project")
|
|
285
|
+
if (deleteBtn) {
|
|
286
|
+
const projectName = <%- JSON.stringify(name) %>
|
|
287
|
+
deleteBtn.addEventListener("click", async (e) => {
|
|
288
|
+
e.preventDefault()
|
|
289
|
+
e.stopPropagation()
|
|
290
|
+
const confirmed = confirm("Are you sure you wish to delete?")
|
|
291
|
+
if (!confirmed) {
|
|
292
|
+
return
|
|
293
|
+
}
|
|
294
|
+
Swal.fire({
|
|
295
|
+
html: '<i class="fa-solid fa-circle-notch fa-spin"></i> Deleting',
|
|
296
|
+
customClass: {
|
|
297
|
+
container: "loader-container",
|
|
298
|
+
popup: "loader-popup",
|
|
299
|
+
htmlContainer: "loader-dialog",
|
|
300
|
+
footer: "hidden",
|
|
301
|
+
actions: "hidden"
|
|
302
|
+
}
|
|
303
|
+
})
|
|
304
|
+
try {
|
|
305
|
+
const res = await fetch("/pinokio/delete", {
|
|
306
|
+
method: "post",
|
|
307
|
+
headers: {
|
|
308
|
+
"Content-Type": "application/json"
|
|
309
|
+
},
|
|
310
|
+
body: JSON.stringify({ name: projectName })
|
|
311
|
+
}).then((response) => response.json())
|
|
312
|
+
Swal.close()
|
|
313
|
+
if (res && res.success) {
|
|
314
|
+
location.href = "/"
|
|
315
|
+
} else if (res && res.error) {
|
|
316
|
+
alert(res.error)
|
|
317
|
+
} else {
|
|
318
|
+
alert("Failed to delete project")
|
|
319
|
+
}
|
|
320
|
+
} catch (err) {
|
|
321
|
+
Swal.close()
|
|
322
|
+
alert(err.message || "Failed to delete project")
|
|
323
|
+
}
|
|
324
|
+
})
|
|
325
|
+
}
|
|
326
|
+
<% } %>
|
|
275
327
|
})
|
|
276
328
|
</script>
|
|
277
329
|
</head>
|
|
@@ -309,6 +361,11 @@ document.addEventListener("DOMContentLoaded", async () => {
|
|
|
309
361
|
<% if (home) { %>
|
|
310
362
|
<a class='home-button home' href="/"><i class='fa-solid fa-home'></i></a>
|
|
311
363
|
<% } %>
|
|
364
|
+
<% if (name) { %>
|
|
365
|
+
<button class='btn' id='delete-project'>
|
|
366
|
+
<i class="fa-solid fa-trash"></i> Delete Project
|
|
367
|
+
</button>
|
|
368
|
+
<% } %>
|
|
312
369
|
<div class='flexible'></div>
|
|
313
370
|
<div class='nav-btns'>
|
|
314
371
|
<a class='btn' href="<%=editorpath%>"><i class="fa-solid fa-pen-to-square"></i> Edit file</a>
|