pinokiod 8.3.22 → 8.3.26
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/windows_console.js +16 -55
- package/package.json +1 -1
- package/server/index.js +14 -9
- package/server/lib/app_run_tabs.js +51 -0
- package/server/public/agent-bar.js +1 -1
- package/server/public/app-run-tabs.js +30 -0
- package/server/public/files-app/open-folder.js +77 -0
- package/server/public/files-app/toolbar.css +28 -0
- package/server/public/git-page.css +521 -0
- package/server/public/git-page.js +625 -0
- package/server/public/universal-launcher.js +4 -4
- package/server/public/urldropdown.js +0 -1
- package/server/routes/git_page.js +30 -0
- package/server/views/app.ejs +24 -29
- package/server/views/file_browser.ejs +17 -31
- package/server/views/git_page.ejs +21 -0
- package/server/views/index.ejs +2 -2
- package/server/views/partials/home_action_modal.ejs +0 -7
- package/test/launch-settings-ui.test.js +1 -1
- package/test/url-split-modal.test.js +1 -1
- package/test/windows-console.test.js +27 -112
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
// The app's Git page: every repository in the app's folder, with its changes,
|
|
2
|
+
// history, fork and publish, all on one page. Opened as a tab on the app page.
|
|
3
|
+
//
|
|
4
|
+
// GET /pinokio/git/:name ?publish=1 opens on the Publish section
|
|
5
|
+
const fs = require("fs")
|
|
6
|
+
|
|
7
|
+
module.exports = function registerGitPageRoutes(app, options = {}) {
|
|
8
|
+
const kernel = options.kernel
|
|
9
|
+
const getPageContext = options.getPageContext || (() => ({}))
|
|
10
|
+
|
|
11
|
+
app.get("/pinokio/git/:name", async (req, res) => {
|
|
12
|
+
const name = req.params.name
|
|
13
|
+
const cwd = kernel.path("api", name)
|
|
14
|
+
try {
|
|
15
|
+
const stat = await fs.promises.stat(cwd)
|
|
16
|
+
if (!stat.isDirectory()) {
|
|
17
|
+
throw new Error("not a folder")
|
|
18
|
+
}
|
|
19
|
+
} catch (_) {
|
|
20
|
+
res.status(404).send("App not found")
|
|
21
|
+
return
|
|
22
|
+
}
|
|
23
|
+
res.render("git_page", {
|
|
24
|
+
...getPageContext(req),
|
|
25
|
+
name,
|
|
26
|
+
cwd,
|
|
27
|
+
publish: req.query && req.query.publish === "1",
|
|
28
|
+
})
|
|
29
|
+
})
|
|
30
|
+
}
|
package/server/views/app.ejs
CHANGED
|
@@ -8441,6 +8441,9 @@ body.dark .pinokio-custom-terminal-header {
|
|
|
8441
8441
|
<div class="app-header-info-popover-title"><%=config.title || name%></div>
|
|
8442
8442
|
<div class="app-header-info-popover-description"><%=config.description || 'No description provided.'%></div>
|
|
8443
8443
|
</div>
|
|
8444
|
+
<button type="button" id="edit" class="app-header-info-popover-row-action" style="flex: 0 0 auto" title="Edit metadata" aria-label="Edit metadata" data-app-info-reveal-path>
|
|
8445
|
+
<i class="fa-solid fa-pen-to-square" aria-hidden="true"></i>
|
|
8446
|
+
</button>
|
|
8444
8447
|
</div>
|
|
8445
8448
|
<div class="app-header-info-popover-meta">
|
|
8446
8449
|
<% if (appInfoFolderPath) { %>
|
|
@@ -8567,16 +8570,6 @@ body.dark .pinokio-custom-terminal-header {
|
|
|
8567
8570
|
<aside id='app-sidebar' class='active'>
|
|
8568
8571
|
<div class='menu-container'>
|
|
8569
8572
|
<div class='menu-scroller'>
|
|
8570
|
-
<div class='workspace-mode-switch' role="tablist" aria-label="Workspace mode">
|
|
8571
|
-
<a class="workspace-mode-link <%=type === 'run' ? 'selected' : ''%>" href="<%=run_tab%>" role="tab" aria-selected="<%=type === 'run' ? 'true' : 'false'%>">
|
|
8572
|
-
<i class="fa-solid fa-circle-play"></i>
|
|
8573
|
-
<span>Run</span>
|
|
8574
|
-
</a>
|
|
8575
|
-
<a class="workspace-mode-link <%=type === 'browse' || type === 'files' ? 'selected' : ''%>" href="<%=dev_tab%>" role="tab" aria-selected="<%=type === 'browse' || type === 'files' ? 'true' : 'false'%>">
|
|
8576
|
-
<i class="fa-solid fa-terminal"></i>
|
|
8577
|
-
<span>Dev</span>
|
|
8578
|
-
</a>
|
|
8579
|
-
</div>
|
|
8580
8573
|
<%if (type==='browse') { %>
|
|
8581
8574
|
<div class='m n system' data-type="n">
|
|
8582
8575
|
<a id='devtab' data-mode="refresh" target="<%=dev_link%>" href="<%=dev_link%>" class="btn frame-link <%=dev_initial_tab === 'files' ? '' : 'selected'%>" data-index="10">
|
|
@@ -8696,13 +8689,22 @@ body.dark .pinokio-custom-terminal-header {
|
|
|
8696
8689
|
<span class='logs-new-badge hidden' id='logs-new-badge'>New</span>
|
|
8697
8690
|
</div>
|
|
8698
8691
|
</button>
|
|
8699
|
-
|
|
8692
|
+
<% if (type === 'run') { %>
|
|
8693
|
+
<a id='files-tab' target="pinokio-files" href="<%=editor_tab%>" class="btn header-item frame-link" data-index="files" data-static="retain">
|
|
8700
8694
|
<div class='tab'>
|
|
8701
|
-
<i class="fa-solid fa-
|
|
8702
|
-
<div class='display'>
|
|
8695
|
+
<i class="fa-solid fa-file-lines menu-action-leading-icon"></i>
|
|
8696
|
+
<div class='display'>Files</div>
|
|
8703
8697
|
<div class='flexible'></div>
|
|
8704
8698
|
</div>
|
|
8705
|
-
</
|
|
8699
|
+
</a>
|
|
8700
|
+
<a id='git-tab' target="app-git" href="/pinokio/git/<%=encodeURIComponent(name)%><%=typeof git_initial_publish !== 'undefined' && git_initial_publish ? '?publish=1' : ''%>" class="btn header-item frame-link" data-index="git" data-static="retain">
|
|
8701
|
+
<div class='tab'>
|
|
8702
|
+
<i class="fa-brands fa-git-alt menu-action-leading-icon"></i>
|
|
8703
|
+
<div class='display'>Git</div>
|
|
8704
|
+
<div class='flexible'></div>
|
|
8705
|
+
</div>
|
|
8706
|
+
</a>
|
|
8707
|
+
<% } %>
|
|
8706
8708
|
<% if (typeof vault_enabled !== 'undefined' && vault_enabled) { %>
|
|
8707
8709
|
<% const vaultAutomaticMode = typeof vault_automatic_mode === 'string' && vault_automatic_mode === 'manual' ? 'manual' : 'automatic' %>
|
|
8708
8710
|
<% const vaultGlobalScanReady = typeof vault_global_scan_ready !== 'undefined' && vault_global_scan_ready === true %>
|
|
@@ -9057,6 +9059,9 @@ body.dark .pinokio-custom-terminal-header {
|
|
|
9057
9059
|
<div class="app-header-info-popover-title"><%=config.title || name%></div>
|
|
9058
9060
|
<div class="app-header-info-popover-description"><%=config.description || 'No description provided.'%></div>
|
|
9059
9061
|
</div>
|
|
9062
|
+
<button type="button" class="app-header-info-popover-row-action" style="flex: 0 0 auto" title="Edit metadata" aria-label="Edit metadata" data-app-info-reveal-path onclick="document.getElementById('edit').click()">
|
|
9063
|
+
<i class="fa-solid fa-pen-to-square" aria-hidden="true"></i>
|
|
9064
|
+
</button>
|
|
9060
9065
|
</div>
|
|
9061
9066
|
<div class="app-header-info-popover-meta">
|
|
9062
9067
|
<% if (appInfoFolderPath) { %>
|
|
@@ -9136,16 +9141,6 @@ body.dark .pinokio-custom-terminal-header {
|
|
|
9136
9141
|
<div>Pinokio</div>
|
|
9137
9142
|
</div>
|
|
9138
9143
|
<div class='mobile-menu-fallback__body'>
|
|
9139
|
-
<div class='workspace-mode-switch' role="tablist" aria-label="Workspace mode">
|
|
9140
|
-
<a class="workspace-mode-link <%=type === 'run' ? 'selected' : ''%>" href="<%=run_tab%>" role="tab" aria-selected="<%=type === 'run' ? 'true' : 'false'%>">
|
|
9141
|
-
<i class="fa-solid fa-circle-play"></i>
|
|
9142
|
-
<span>Run</span>
|
|
9143
|
-
</a>
|
|
9144
|
-
<a class="workspace-mode-link <%=type === 'browse' || type === 'files' ? 'selected' : ''%>" href="<%=dev_tab%>" role="tab" aria-selected="<%=type === 'browse' || type === 'files' ? 'true' : 'false'%>">
|
|
9145
|
-
<i class="fa-solid fa-terminal"></i>
|
|
9146
|
-
<span>Dev</span>
|
|
9147
|
-
</a>
|
|
9148
|
-
</div>
|
|
9149
9144
|
<div class='mobile-drawer-actions' aria-label="App actions">
|
|
9150
9145
|
<button type='button' class='btn header-item mobile-nav-logs' data-mobile-proxy="#fs-status .fs-logs .fs-status-btn" data-mobile-panel="logs" data-mobile-close-menu="true" aria-pressed="false" aria-label="Logs">
|
|
9151
9146
|
<div class='tab'>
|
|
@@ -17313,11 +17308,8 @@ document.addEventListener("DOMContentLoaded", () => {
|
|
|
17313
17308
|
focusConfirm: false,
|
|
17314
17309
|
}).then((result) => {
|
|
17315
17310
|
if (result && result.isConfirmed) {
|
|
17316
|
-
|
|
17317
|
-
|
|
17318
|
-
const qs = params.toString()
|
|
17319
|
-
const url = `/p/${encodeURIComponent(workspace)}/dev${qs ? `?${qs}` : ""}`
|
|
17320
|
-
window.location.href = url
|
|
17311
|
+
// the app page, not launching the app, on its Git tab's Publish section
|
|
17312
|
+
window.location.href = `/v/${encodeURIComponent(workspace)}?git_publish=1`
|
|
17321
17313
|
}
|
|
17322
17314
|
})
|
|
17323
17315
|
return
|
|
@@ -20039,5 +20031,8 @@ document.addEventListener("DOMContentLoaded", () => {
|
|
|
20039
20031
|
}
|
|
20040
20032
|
})()
|
|
20041
20033
|
</script>
|
|
20034
|
+
<% if (type === 'run') { %>
|
|
20035
|
+
<script src="/app-run-tabs.js" data-tab="<%=typeof run_initial_tab === 'string' ? run_initial_tab : ''%>"></script>
|
|
20036
|
+
<% } %>
|
|
20042
20037
|
</body>
|
|
20043
20038
|
</html>
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
<link href="/css/brands.min.css" rel="stylesheet">
|
|
11
11
|
<link href="/style.css" rel="stylesheet">
|
|
12
12
|
<link href="/files-app/app.css" rel="stylesheet">
|
|
13
|
+
<link href="/files-app/toolbar.css" rel="stylesheet">
|
|
13
14
|
<link href="/filepond.min.css" rel="stylesheet" />
|
|
14
15
|
<link href="/filepond-plugin-image-preview.min.css" rel="stylesheet" />
|
|
15
16
|
<link href="/filepond-plugin-image-edit.min.css" rel="stylesheet" />
|
|
@@ -20,36 +21,6 @@
|
|
|
20
21
|
</head>
|
|
21
22
|
<body class="<%=theme%>" data-agent="<%=agent%>">
|
|
22
23
|
<div class="files-app" data-theme="<%=theme%>">
|
|
23
|
-
<header class="files-app__header">
|
|
24
|
-
<button class="files-app__mobile-back" id="files-app-mobile-back" type="button" aria-label="Back to files">
|
|
25
|
-
<i class="fa-solid fa-chevron-left" aria-hidden="true"></i>
|
|
26
|
-
<span>Files</span>
|
|
27
|
-
</button>
|
|
28
|
-
<div class="files-app__header-title">
|
|
29
|
-
<% if (workspaceMeta && workspaceMeta.icon) { %>
|
|
30
|
-
<img class="files-app__header-icon" src="<%= workspaceMeta.icon %>" onerror="this.onerror=null; this.src='/pinokio-black.png'" alt="Project icon" />
|
|
31
|
-
<% } else { %>
|
|
32
|
-
<i class="fa-regular fa-folder-open"></i>
|
|
33
|
-
<% } %>
|
|
34
|
-
<div class="files-app__header-text">
|
|
35
|
-
<div class="files-app__header-primary"><%= (workspaceMeta && workspaceMeta.title) ? workspaceMeta.title : workspaceLabel %></div>
|
|
36
|
-
<% if (workspaceMeta && workspaceMeta.description) { %>
|
|
37
|
-
<div class="files-app__header-desc"><%= workspaceMeta.description %></div>
|
|
38
|
-
<% } %>
|
|
39
|
-
<div class="files-app__header-sub"><%=workspaceRoot%></div>
|
|
40
|
-
</div>
|
|
41
|
-
</div>
|
|
42
|
-
<div class="files-app__header-actions">
|
|
43
|
-
<button class="files-app__meta" type="button" id="files-app-edit-metadata">
|
|
44
|
-
<i class="fa-solid fa-pen-to-square"></i>
|
|
45
|
-
<span>Edit metadata</span>
|
|
46
|
-
</button>
|
|
47
|
-
<button class="files-app__save" id="files-app-save" disabled>
|
|
48
|
-
<i class="fa-solid fa-floppy-disk"></i>
|
|
49
|
-
<span>Save</span>
|
|
50
|
-
</button>
|
|
51
|
-
</div>
|
|
52
|
-
</header>
|
|
53
24
|
<section class="files-app__body">
|
|
54
25
|
<aside class="files-app__sidebar" aria-label="Project files">
|
|
55
26
|
<div class="files-app__sidebar-scroll" id="files-app-tree">
|
|
@@ -60,7 +31,21 @@
|
|
|
60
31
|
<span class="sr-only">Hide files</span>
|
|
61
32
|
<i class="fa-solid fa-chevron-left" aria-hidden="true"></i>
|
|
62
33
|
</button>
|
|
63
|
-
<div class="files-
|
|
34
|
+
<div class="files-app__tabbar">
|
|
35
|
+
<button class="files-app__mobile-back" id="files-app-mobile-back" type="button" aria-label="Back to files">
|
|
36
|
+
<i class="fa-solid fa-chevron-left" aria-hidden="true"></i>
|
|
37
|
+
<span>Files</span>
|
|
38
|
+
</button>
|
|
39
|
+
<div class="files-app__tabs" id="files-app-tabs" role="tablist" aria-label="Open files"></div>
|
|
40
|
+
<button class="files-app__meta" type="button" id="files-app-open-explorer" data-root="<%=workspaceRoot%>">
|
|
41
|
+
<i class="fa-solid fa-folder-open"></i>
|
|
42
|
+
<span>File Explorer</span>
|
|
43
|
+
</button>
|
|
44
|
+
<button class="files-app__save" id="files-app-save" title="Save" aria-label="Save" disabled>
|
|
45
|
+
<i class="fa-solid fa-floppy-disk"></i>
|
|
46
|
+
<span>Save</span>
|
|
47
|
+
</button>
|
|
48
|
+
</div>
|
|
64
49
|
<div class="files-app__editor" id="files-app-editor" role="presentation"></div>
|
|
65
50
|
<div class="files-app__status" id="files-app-status" role="status" aria-live="polite"></div>
|
|
66
51
|
</main>
|
|
@@ -79,6 +64,7 @@
|
|
|
79
64
|
<script src="/ace/ace.js"></script>
|
|
80
65
|
<script src="/ace/ext-modelist.js"></script>
|
|
81
66
|
<script src="/files-app/app.js"></script>
|
|
67
|
+
<script src="/files-app/open-folder.js"></script>
|
|
82
68
|
<script>
|
|
83
69
|
window.FilesApp.init({
|
|
84
70
|
workspace: <%- JSON.stringify(workspaceSlug) %>,
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
<html>
|
|
2
|
+
<head>
|
|
3
|
+
<title>Git</title>
|
|
4
|
+
<meta charset="UTF-8">
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1" />
|
|
6
|
+
<link href="/css/fontawesome.min.css" rel="stylesheet">
|
|
7
|
+
<link href="/css/solid.min.css" rel="stylesheet">
|
|
8
|
+
<link href="/css/regular.min.css" rel="stylesheet">
|
|
9
|
+
<link href="/css/brands.min.css" rel="stylesheet">
|
|
10
|
+
<link href="/style.css" rel="stylesheet"/>
|
|
11
|
+
<% if (agent === "electron") { %>
|
|
12
|
+
<link href="/electron.css" rel="stylesheet"/>
|
|
13
|
+
<% } %>
|
|
14
|
+
<link href="/git-page.css" rel="stylesheet"/>
|
|
15
|
+
<script src="/timeago.min.js"></script>
|
|
16
|
+
</head>
|
|
17
|
+
<body class='<%=theme%> git-page' data-agent="<%=agent%>">
|
|
18
|
+
<div class='git-page-root' id='git-page' data-name="<%=name%>" data-cwd="<%=cwd%>" data-publish="<%= publish ? '1' : '' %>"></div>
|
|
19
|
+
<script src="/git-page.js"></script>
|
|
20
|
+
</body>
|
|
21
|
+
</html>
|
package/server/views/index.ejs
CHANGED
|
@@ -1866,7 +1866,7 @@ body.dark aside .current.selected {
|
|
|
1866
1866
|
<% const runningTerminalOnlineCount = Number(item.terminal_online_count || 0) %>
|
|
1867
1867
|
<% const runningTerminalLabel = runningTerminalOnlineCount > 0 ? `${runningTerminalOnlineCount} terminal${runningTerminalOnlineCount === 1 ? "" : "s"} online` : "Terminals" %>
|
|
1868
1868
|
<% if (runningTerminalOnlineCount > 0) { %>
|
|
1869
|
-
<button class='btn browse terminals-link is-online' type='button' data-src="<%=item.
|
|
1869
|
+
<button class='btn browse terminals-link is-online' type='button' data-src="<%=item.view_url%>" title="<%=runningTerminalLabel%>">
|
|
1870
1870
|
<i class="fa-solid fa-terminal" aria-hidden="true"></i>
|
|
1871
1871
|
<span><%=runningTerminalLabel%></span>
|
|
1872
1872
|
<i class="fa-solid fa-circle-notch fa-spin terminals-link-indicator" aria-hidden="true"></i>
|
|
@@ -1956,7 +1956,7 @@ body.dark aside .current.selected {
|
|
|
1956
1956
|
</button>
|
|
1957
1957
|
<% if (notRunningTerminalOnlineCount > 0) { %>
|
|
1958
1958
|
<% const notRunningTerminalLabel = notRunningTerminalOnlineCount > 0 ? `${notRunningTerminalOnlineCount} terminal${notRunningTerminalOnlineCount === 1 ? "" : "s"} online` : "Terminals" %>
|
|
1959
|
-
<button class='btn browse terminals-link is-online' type='button' data-src="<%=item.
|
|
1959
|
+
<button class='btn browse terminals-link is-online' type='button' data-src="<%=item.view_url%>" title="<%=notRunningTerminalLabel%>">
|
|
1960
1960
|
<i class="fa-solid fa-terminal" aria-hidden="true"></i>
|
|
1961
1961
|
<span><%=notRunningTerminalLabel%></span>
|
|
1962
1962
|
<i class="fa-solid fa-circle-notch fa-spin terminals-link-indicator" aria-hidden="true"></i>
|
|
@@ -76,13 +76,6 @@ const homeActionsShareExternalReadyUrls = item && Array.isArray(item.external_re
|
|
|
76
76
|
<i class='fa-regular fa-eye' aria-hidden='true'></i>
|
|
77
77
|
<span>Open without launching</span>
|
|
78
78
|
</button>
|
|
79
|
-
<button type='button' class='home-mode-command home-browse' data-src='<%= item.dev_url %>'>
|
|
80
|
-
<i class='fa-solid fa-code' aria-hidden='true'></i>
|
|
81
|
-
<span>Open dev mode</span>
|
|
82
|
-
<% if (item.terminal_online_count > 0) { %>
|
|
83
|
-
<span class='home-actions-count'><%= item.terminal_online_count %> online</span>
|
|
84
|
-
<% } %>
|
|
85
|
-
</button>
|
|
86
79
|
<% if (homeActionsSettingsHref) { %>
|
|
87
80
|
<a class='home-mode-command' href='<%= homeActionsSettingsHref %>'>
|
|
88
81
|
<i class='fa-solid fa-gear' aria-hidden='true'></i>
|
|
@@ -372,7 +372,7 @@ test("static guard: open without launching is not wired to launch requirement st
|
|
|
372
372
|
|
|
373
373
|
assert.match(homeActionModal, /Open without launching/)
|
|
374
374
|
assert.match(homeActionModal, /class='home-mode-command home-browse' data-src='<%= item\.view_url %>'/)
|
|
375
|
-
assert.
|
|
375
|
+
assert.doesNotMatch(homeActionModal, /Open dev mode/)
|
|
376
376
|
assert.match(homeActionModal, /const homeActionsAppId = item && \(item\.uri \|\| item\.path \|\| item\.name\)/)
|
|
377
377
|
assert.match(homeActionModal, /pinokio_home_select: JSON\.stringify/)
|
|
378
378
|
assert.match(homeActionModal, /target: "env-settings"/)
|
|
@@ -94,7 +94,7 @@ test("split URL modal uses inline submit and omits Files actions", async () => {
|
|
|
94
94
|
assert.equal(content.classList.contains("split-mode"), true)
|
|
95
95
|
assert.equal(inlineSubmit.textContent, "Open in pane")
|
|
96
96
|
assert.ok(actions)
|
|
97
|
-
assert.deepEqual([...new Set(modeLabels)].sort(), ["
|
|
97
|
+
assert.deepEqual([...new Set(modeLabels)].sort(), ["Run"])
|
|
98
98
|
assert.doesNotMatch(content.textContent, /\bFiles\b/)
|
|
99
99
|
|
|
100
100
|
const input = document.querySelector(".url-modal-input")
|
|
@@ -1,26 +1,14 @@
|
|
|
1
|
-
//
|
|
2
|
-
// the
|
|
3
|
-
//
|
|
4
|
-
// the bundled console layer itself: that exists only on Windows.
|
|
1
|
+
// Which Windows console layer a shell starts on (kernel/windows_console.js):
|
|
2
|
+
// the option it hands the pty library. No shell is started here, and none of
|
|
3
|
+
// it runs the shipped console layer itself: that exists only on Windows.
|
|
5
4
|
const assert = require('node:assert/strict')
|
|
6
5
|
const fs = require('node:fs')
|
|
7
6
|
const os = require('node:os')
|
|
8
7
|
const path = require('node:path')
|
|
9
8
|
const test = require('node:test')
|
|
10
|
-
const ejs = require('ejs')
|
|
11
9
|
|
|
12
10
|
const WindowsConsole = require('../kernel/windows_console')
|
|
13
11
|
|
|
14
|
-
const store = (initial = {}) => {
|
|
15
|
-
const data = { ...initial }
|
|
16
|
-
return {
|
|
17
|
-
get: (key) => (key in data ? data[key] : null),
|
|
18
|
-
set: (key, val) => { data[key] = val },
|
|
19
|
-
delete: (key) => { delete data[key] },
|
|
20
|
-
data,
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
const kernel = (platform, initial) => ({ platform, store: store(initial) })
|
|
24
12
|
const present = () => true
|
|
25
13
|
const missing = () => false
|
|
26
14
|
// os.release() on each
|
|
@@ -28,93 +16,34 @@ const WIN10 = '10.0.19045'
|
|
|
28
16
|
const WIN11 = '10.0.22000'
|
|
29
17
|
const WIN11_25H2 = '10.0.26200'
|
|
30
18
|
|
|
31
|
-
test('Windows 10
|
|
32
|
-
assert.equal(WindowsConsole.
|
|
33
|
-
assert.equal(WindowsConsole.
|
|
34
|
-
assert.equal(WindowsConsole.
|
|
35
|
-
assert.equal(WindowsConsole.
|
|
36
|
-
assert.equal(WindowsConsole.
|
|
37
|
-
assert.equal(WindowsConsole.
|
|
19
|
+
test('Windows 10 is every build before the first Windows 11 one', () => {
|
|
20
|
+
assert.equal(WindowsConsole.isWindows10('10.0.18363'), true)
|
|
21
|
+
assert.equal(WindowsConsole.isWindows10(WIN10), true)
|
|
22
|
+
assert.equal(WindowsConsole.isWindows10('10.0.21999'), true)
|
|
23
|
+
assert.equal(WindowsConsole.isWindows10(WIN11), false)
|
|
24
|
+
assert.equal(WindowsConsole.isWindows10('10.0.22631'), false)
|
|
25
|
+
assert.equal(WindowsConsole.isWindows10(WIN11_25H2), false)
|
|
38
26
|
// a version that cannot be read stays on what Windows has
|
|
39
|
-
assert.equal(WindowsConsole.
|
|
40
|
-
assert.equal(WindowsConsole.
|
|
41
|
-
// and on the machine running this, whatever it is, it
|
|
42
|
-
assert.
|
|
27
|
+
assert.equal(WindowsConsole.isWindows10(''), false)
|
|
28
|
+
assert.equal(WindowsConsole.isWindows10('nonsense'), false)
|
|
29
|
+
// and on the machine running this, whatever it is, it has an answer
|
|
30
|
+
assert.equal(typeof WindowsConsole.isWindows10(), 'boolean')
|
|
43
31
|
})
|
|
44
32
|
|
|
45
|
-
test('the
|
|
46
|
-
assert.deepEqual(WindowsConsole.settings(kernel('darwin'), WIN10), [])
|
|
47
|
-
assert.deepEqual(WindowsConsole.settings(kernel('linux'), WIN10), [])
|
|
48
|
-
|
|
49
|
-
const [row, ...rest] = WindowsConsole.settings(kernel('win32'), WIN10)
|
|
50
|
-
assert.equal(rest.length, 0)
|
|
51
|
-
assert.equal(row.key, 'terminal_engine')
|
|
52
|
-
assert.deepEqual(row.options, ['system', 'pinokio'])
|
|
53
|
-
// nothing chosen: what the Windows version gets
|
|
54
|
-
assert.equal(row.val, 'pinokio')
|
|
55
|
-
assert.equal(WindowsConsole.settings(kernel('win32'), WIN11)[0].val, 'system')
|
|
56
|
-
|
|
57
|
-
// a choice wins over the Windows version, either way
|
|
58
|
-
assert.equal(WindowsConsole.settings(kernel('win32', { terminal_engine: 'system' }), WIN10)[0].val, 'system')
|
|
59
|
-
assert.equal(WindowsConsole.settings(kernel('win32', { terminal_engine: 'pinokio' }), WIN11)[0].val, 'pinokio')
|
|
60
|
-
// a value that is not one of the two reads as nothing chosen
|
|
61
|
-
assert.equal(WindowsConsole.settings(kernel('win32', { terminal_engine: 'nonsense' }), WIN10)[0].val, 'pinokio')
|
|
62
|
-
assert.equal(WindowsConsole.settings(kernel('win32', { terminal_engine: 'default' }), WIN11)[0].val, 'system')
|
|
63
|
-
})
|
|
64
|
-
|
|
65
|
-
test('saving keeps only a choice that differs from the Windows version\'s own', () => {
|
|
66
|
-
const s = store()
|
|
67
|
-
WindowsConsole.save(s, { theme: 'dark' }, WIN10) // the row is absent off Windows
|
|
68
|
-
assert.deepEqual(s.data, {})
|
|
69
|
-
WindowsConsole.save(s, { terminal_engine: 'nonsense' }, WIN10)
|
|
70
|
-
assert.deepEqual(s.data, {})
|
|
71
|
-
|
|
72
|
-
// the page posts the row with every save: an untouched row stores nothing
|
|
73
|
-
WindowsConsole.save(s, { terminal_engine: 'pinokio' }, WIN10)
|
|
74
|
-
assert.deepEqual(s.data, {})
|
|
75
|
-
WindowsConsole.save(s, { terminal_engine: 'system' }, WIN11)
|
|
76
|
-
assert.deepEqual(s.data, {})
|
|
77
|
-
|
|
78
|
-
// the other one is kept
|
|
79
|
-
WindowsConsole.save(s, { terminal_engine: 'system' }, WIN10)
|
|
80
|
-
assert.deepEqual(s.data, { terminal_engine: 'system' })
|
|
81
|
-
// and going back to the Windows version's own clears it
|
|
82
|
-
WindowsConsole.save(s, { terminal_engine: 'pinokio' }, WIN10)
|
|
83
|
-
assert.deepEqual(s.data, {})
|
|
84
|
-
|
|
85
|
-
WindowsConsole.save(s, { terminal_engine: 'pinokio' }, WIN11)
|
|
86
|
-
assert.deepEqual(s.data, { terminal_engine: 'pinokio' })
|
|
87
|
-
WindowsConsole.save(s, { terminal_engine: 'system' }, WIN11)
|
|
88
|
-
assert.deepEqual(s.data, {})
|
|
89
|
-
})
|
|
90
|
-
|
|
91
|
-
test('a shell gets the bundled layer only on Windows, only when it is the one in use, only when its files are there', () => {
|
|
33
|
+
test('a shell gets the shipped layer only on Windows 10, and only when its files are there', () => {
|
|
92
34
|
const on = { useConptyDll: true }
|
|
93
|
-
|
|
94
|
-
assert.deepEqual(WindowsConsole.ptyOptions(
|
|
95
|
-
assert.deepEqual(WindowsConsole.ptyOptions(
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
assert.deepEqual(WindowsConsole.ptyOptions(
|
|
99
|
-
assert.deepEqual(WindowsConsole.ptyOptions(
|
|
100
|
-
//
|
|
101
|
-
assert.deepEqual(WindowsConsole.ptyOptions(
|
|
102
|
-
assert.deepEqual(WindowsConsole.ptyOptions(kernel('linux', { terminal_engine: 'pinokio' }), present, WIN10), {})
|
|
103
|
-
// in use, but the install has no copy: the shell starts on the system one
|
|
104
|
-
assert.deepEqual(WindowsConsole.ptyOptions(kernel('win32'), missing, WIN10), {})
|
|
105
|
-
assert.deepEqual(WindowsConsole.ptyOptions(kernel('win32', { terminal_engine: 'pinokio' }), missing, WIN11), {})
|
|
106
|
-
})
|
|
107
|
-
|
|
108
|
-
test('the choice is read each time a shell starts', () => {
|
|
109
|
-
const k = kernel('win32')
|
|
110
|
-
assert.deepEqual(WindowsConsole.ptyOptions(k, present, WIN11), {})
|
|
111
|
-
WindowsConsole.save(k.store, { terminal_engine: 'pinokio' }, WIN11)
|
|
112
|
-
assert.deepEqual(WindowsConsole.ptyOptions(k, present, WIN11), { useConptyDll: true })
|
|
113
|
-
WindowsConsole.save(k.store, { terminal_engine: 'system' }, WIN11)
|
|
114
|
-
assert.deepEqual(WindowsConsole.ptyOptions(k, present, WIN11), {})
|
|
35
|
+
assert.deepEqual(WindowsConsole.ptyOptions({ platform: 'win32' }, present, WIN10), on)
|
|
36
|
+
assert.deepEqual(WindowsConsole.ptyOptions({ platform: 'win32' }, present, WIN11), {})
|
|
37
|
+
assert.deepEqual(WindowsConsole.ptyOptions({ platform: 'win32' }, present, WIN11_25H2), {})
|
|
38
|
+
// never off Windows, whatever the version string looks like
|
|
39
|
+
assert.deepEqual(WindowsConsole.ptyOptions({ platform: 'darwin' }, present, WIN10), {})
|
|
40
|
+
assert.deepEqual(WindowsConsole.ptyOptions({ platform: 'linux' }, present, WIN10), {})
|
|
41
|
+
assert.deepEqual(WindowsConsole.ptyOptions(null, present, WIN10), {})
|
|
42
|
+
// the install has no copy: the shell starts on the one built into Windows
|
|
43
|
+
assert.deepEqual(WindowsConsole.ptyOptions({ platform: 'win32' }, missing, WIN10), {})
|
|
115
44
|
})
|
|
116
45
|
|
|
117
|
-
test('the
|
|
46
|
+
test('the shipped layer counts as there only when both of its files are', (t) => {
|
|
118
47
|
const dir = fs.mkdtempSync(path.join(os.tmpdir(), 'pinokio-conpty-'))
|
|
119
48
|
t.after(() => fs.rmSync(dir, { recursive: true, force: true }))
|
|
120
49
|
const files = ['conpty.dll', 'OpenConsole.exe'].map((name) => path.join(dir, name))
|
|
@@ -124,7 +53,7 @@ test('the bundled layer counts as there only when both of its files are', (t) =>
|
|
|
124
53
|
fs.writeFileSync(files[1], '')
|
|
125
54
|
assert.equal(WindowsConsole.bundledAvailable(files), true)
|
|
126
55
|
|
|
127
|
-
// looked for where the pty library
|
|
56
|
+
// looked for where the pty library loads them from
|
|
128
57
|
const expected = WindowsConsole.bundledFiles().map((file) => file.split(path.sep).slice(-4).join('/'))
|
|
129
58
|
assert.deepEqual(expected, ['build/Release/conpty/conpty.dll', 'build/Release/conpty/OpenConsole.exe'])
|
|
130
59
|
})
|
|
@@ -144,22 +73,8 @@ test('inside the desktop app the files are looked for beside the app archive', (
|
|
|
144
73
|
|
|
145
74
|
test('the pty library still takes the option this hands it', () => {
|
|
146
75
|
// The option is passed straight to the library. If an upgrade renames or
|
|
147
|
-
// drops it,
|
|
76
|
+
// drops it, Windows 10 would silently stay on the copy built into Windows.
|
|
148
77
|
const root = path.dirname(require.resolve('@homebridge/node-pty-prebuilt-multiarch/package.json'))
|
|
149
78
|
const source = fs.readFileSync(path.join(root, 'lib', 'windowsTerminal.js'), 'utf8')
|
|
150
79
|
assert.match(source, /opt\.useConptyDll/)
|
|
151
80
|
})
|
|
152
|
-
|
|
153
|
-
test('the Settings page draws the row as a dropdown with its explanation', async () => {
|
|
154
|
-
const view = fs.readFileSync(path.resolve(__dirname, '../server/views/settings.ejs'), 'utf8')
|
|
155
|
-
// the General form's loop over the rows, as the page has it
|
|
156
|
-
const start = view.indexOf('<% config.forEach((c) => { %>')
|
|
157
|
-
const end = view.indexOf('<% }) %>', view.indexOf("<div class='explanation'><%=c.description%></div>")) + '<% }) %>'.length
|
|
158
|
-
assert.ok(start > 0 && end > start)
|
|
159
|
-
const html = ejs.render(view.slice(start, end), { config: WindowsConsole.settings(kernel('win32'), WIN10) })
|
|
160
|
-
|
|
161
|
-
assert.match(html, /<select name="terminal_engine">/)
|
|
162
|
-
assert.match(html, /<option value="system">system<\/option>/)
|
|
163
|
-
assert.match(html, /<option value="pinokio" selected>pinokio<\/option>/)
|
|
164
|
-
assert.equal((html.match(/class='explanation'/g) || []).length, 2)
|
|
165
|
-
})
|