pinokiod 3.343.0 → 5.0.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/server/index.js CHANGED
@@ -27,6 +27,7 @@ const crypto = require('crypto')
27
27
  const system = require('systeminformation')
28
28
  const serveIndex = require('./serveIndex')
29
29
  const registerFileRoutes = require('./routes/files')
30
+ const Git = require("../kernel/git")
30
31
  const TerminalApi = require('../kernel/api/terminal')
31
32
 
32
33
  const git = require('isomorphic-git')
@@ -180,68 +181,10 @@ class Server {
180
181
  }
181
182
 
182
183
  async ensureGitconfigDefaults(home) {
183
- const gitconfigPath = path.resolve(home, "gitconfig")
184
- const templatePath = path.resolve(__dirname, "..", "kernel", "gitconfig_template")
185
- const defaultName = "pinokio"
186
- const defaultEmail = "pinokio@localhost"
187
- const hasEmailShape = (value) => typeof value === "string" && value.includes("@")
188
- const required = [
189
- { section: "init", key: "defaultBranch", value: "main" },
190
- { section: "push", key: "autoSetupRemote", value: true },
191
- ]
192
-
193
- const exists = await this.kernel.exists(gitconfigPath)
194
- if (!exists) {
195
- await fs.promises.copyFile(templatePath, gitconfigPath)
196
- return
197
- }
198
-
199
- let config
200
- let dirty = false
201
- try {
202
- const content = await fs.promises.readFile(gitconfigPath, "utf8")
203
- config = ini.parse(content)
204
- } catch (e) {
205
- config = {}
206
- dirty = true
207
- }
208
-
209
- for (const { section, key, value } of required) {
210
- if (!config[section]) {
211
- config[section] = {}
212
- }
213
- const current = config[section][key]
214
- if (String(current) !== String(value)) {
215
- config[section][key] = value
216
- dirty = true
217
- }
218
- }
219
-
220
- if (!config.user) {
221
- config.user = {}
222
- }
223
- const name = (typeof config.user.name === "string") ? config.user.name : ""
224
- if (!name.trim()) {
225
- config.user.name = defaultName
226
- dirty = true
227
- }
228
- const email = (typeof config.user.email === "string") ? config.user.email.trim() : ""
229
- if (!hasEmailShape(email)) {
230
- config.user.email = defaultEmail
231
- dirty = true
232
- } else if (email !== config.user.email) {
233
- config.user.email = email
234
- dirty = true
235
- }
236
-
237
- if (config['credential "helperselector"']) {
238
- delete config['credential "helperselector"']
239
- dirty = true
240
- }
241
-
242
- if (dirty) {
243
- await fs.promises.writeFile(gitconfigPath, ini.stringify(config))
184
+ if (!this.kernel.git) {
185
+ this.kernel.git = new Git(this.kernel)
244
186
  }
187
+ await this.kernel.git.ensureDefaults(home)
245
188
  }
246
189
  async handleFatalError(error, origin) {
247
190
  if (this.handlingFatalError) {
@@ -272,6 +272,18 @@
272
272
  if (Array.isArray(payload.actions)) {
273
273
  this.renderActions(payload.actions)
274
274
  }
275
+ if (Object.prototype.hasOwnProperty.call(payload, 'actionsAlign')) {
276
+ const align = payload.actionsAlign
277
+ if (align === 'end') {
278
+ this.actions.style.justifyContent = 'flex-end'
279
+ } else if (align === 'center') {
280
+ this.actions.style.justifyContent = 'center'
281
+ } else {
282
+ this.actions.style.justifyContent = 'flex-start'
283
+ }
284
+ } else {
285
+ this.actions.style.justifyContent = 'flex-start'
286
+ }
275
287
  if (Object.prototype.hasOwnProperty.call(payload, 'dismissible')) {
276
288
  this.current.dismissible = Boolean(payload.dismissible)
277
289
  this.closeBtn.style.display = this.current.dismissible ? 'inline-flex' : 'none'