@sanity/runtime-cli 9.0.0 → 9.1.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/README.md +16 -16
- package/dist/server/static/components/app.css +29 -2
- package/dist/server/static/components/clear-button.d.ts +6 -0
- package/dist/server/static/components/clear-button.js +47 -0
- package/dist/server/static/components/console-panel.js +31 -5
- package/dist/server/static/components/response-panel.js +2 -2
- package/dist/server/static/components/toggle-switch.d.ts +10 -0
- package/dist/server/static/components/toggle-switch.js +80 -0
- package/dist/server/static/index.html +2 -0
- package/dist/utils/child-process-wrapper.js +60 -0
- package/oclif.manifest.json +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -20,7 +20,7 @@ $ npm install -g @sanity/runtime-cli
|
|
|
20
20
|
$ sanity-run COMMAND
|
|
21
21
|
running command...
|
|
22
22
|
$ sanity-run (--version)
|
|
23
|
-
@sanity/runtime-cli/9.
|
|
23
|
+
@sanity/runtime-cli/9.1.1 linux-x64 node-v22.16.0
|
|
24
24
|
$ sanity-run --help [COMMAND]
|
|
25
25
|
USAGE
|
|
26
26
|
$ sanity-run COMMAND
|
|
@@ -86,7 +86,7 @@ EXAMPLES
|
|
|
86
86
|
$ sanity-run blueprints add function --name my-function --fn-type document-publish --lang js
|
|
87
87
|
```
|
|
88
88
|
|
|
89
|
-
_See code: [src/commands/blueprints/add.ts](https://github.com/sanity-io/runtime-cli/blob/v9.
|
|
89
|
+
_See code: [src/commands/blueprints/add.ts](https://github.com/sanity-io/runtime-cli/blob/v9.1.1/src/commands/blueprints/add.ts)_
|
|
90
90
|
|
|
91
91
|
## `sanity-run blueprints config`
|
|
92
92
|
|
|
@@ -117,7 +117,7 @@ EXAMPLES
|
|
|
117
117
|
$ sanity-run blueprints config --edit --project-id <projectId> --stack-id <stackId>
|
|
118
118
|
```
|
|
119
119
|
|
|
120
|
-
_See code: [src/commands/blueprints/config.ts](https://github.com/sanity-io/runtime-cli/blob/v9.
|
|
120
|
+
_See code: [src/commands/blueprints/config.ts](https://github.com/sanity-io/runtime-cli/blob/v9.1.1/src/commands/blueprints/config.ts)_
|
|
121
121
|
|
|
122
122
|
## `sanity-run blueprints deploy`
|
|
123
123
|
|
|
@@ -139,7 +139,7 @@ EXAMPLES
|
|
|
139
139
|
$ sanity-run blueprints deploy --no-wait
|
|
140
140
|
```
|
|
141
141
|
|
|
142
|
-
_See code: [src/commands/blueprints/deploy.ts](https://github.com/sanity-io/runtime-cli/blob/v9.
|
|
142
|
+
_See code: [src/commands/blueprints/deploy.ts](https://github.com/sanity-io/runtime-cli/blob/v9.1.1/src/commands/blueprints/deploy.ts)_
|
|
143
143
|
|
|
144
144
|
## `sanity-run blueprints destroy`
|
|
145
145
|
|
|
@@ -164,7 +164,7 @@ EXAMPLES
|
|
|
164
164
|
$ sanity-run blueprints destroy --stack-id <stackId> --project-id <projectId> --force --no-wait
|
|
165
165
|
```
|
|
166
166
|
|
|
167
|
-
_See code: [src/commands/blueprints/destroy.ts](https://github.com/sanity-io/runtime-cli/blob/v9.
|
|
167
|
+
_See code: [src/commands/blueprints/destroy.ts](https://github.com/sanity-io/runtime-cli/blob/v9.1.1/src/commands/blueprints/destroy.ts)_
|
|
168
168
|
|
|
169
169
|
## `sanity-run blueprints info`
|
|
170
170
|
|
|
@@ -186,7 +186,7 @@ EXAMPLES
|
|
|
186
186
|
$ sanity-run blueprints info --stack-id <stackId>
|
|
187
187
|
```
|
|
188
188
|
|
|
189
|
-
_See code: [src/commands/blueprints/info.ts](https://github.com/sanity-io/runtime-cli/blob/v9.
|
|
189
|
+
_See code: [src/commands/blueprints/info.ts](https://github.com/sanity-io/runtime-cli/blob/v9.1.1/src/commands/blueprints/info.ts)_
|
|
190
190
|
|
|
191
191
|
## `sanity-run blueprints init [DIR]`
|
|
192
192
|
|
|
@@ -224,7 +224,7 @@ EXAMPLES
|
|
|
224
224
|
$ sanity-run blueprints init --blueprint-type <json|js|ts> --stack-name <stackName>
|
|
225
225
|
```
|
|
226
226
|
|
|
227
|
-
_See code: [src/commands/blueprints/init.ts](https://github.com/sanity-io/runtime-cli/blob/v9.
|
|
227
|
+
_See code: [src/commands/blueprints/init.ts](https://github.com/sanity-io/runtime-cli/blob/v9.1.1/src/commands/blueprints/init.ts)_
|
|
228
228
|
|
|
229
229
|
## `sanity-run blueprints logs`
|
|
230
230
|
|
|
@@ -246,7 +246,7 @@ EXAMPLES
|
|
|
246
246
|
$ sanity-run blueprints logs --watch
|
|
247
247
|
```
|
|
248
248
|
|
|
249
|
-
_See code: [src/commands/blueprints/logs.ts](https://github.com/sanity-io/runtime-cli/blob/v9.
|
|
249
|
+
_See code: [src/commands/blueprints/logs.ts](https://github.com/sanity-io/runtime-cli/blob/v9.1.1/src/commands/blueprints/logs.ts)_
|
|
250
250
|
|
|
251
251
|
## `sanity-run blueprints plan`
|
|
252
252
|
|
|
@@ -263,7 +263,7 @@ EXAMPLES
|
|
|
263
263
|
$ sanity-run blueprints plan
|
|
264
264
|
```
|
|
265
265
|
|
|
266
|
-
_See code: [src/commands/blueprints/plan.ts](https://github.com/sanity-io/runtime-cli/blob/v9.
|
|
266
|
+
_See code: [src/commands/blueprints/plan.ts](https://github.com/sanity-io/runtime-cli/blob/v9.1.1/src/commands/blueprints/plan.ts)_
|
|
267
267
|
|
|
268
268
|
## `sanity-run blueprints stacks`
|
|
269
269
|
|
|
@@ -285,7 +285,7 @@ EXAMPLES
|
|
|
285
285
|
$ sanity-run blueprints stacks --project-id <projectId>
|
|
286
286
|
```
|
|
287
287
|
|
|
288
|
-
_See code: [src/commands/blueprints/stacks.ts](https://github.com/sanity-io/runtime-cli/blob/v9.
|
|
288
|
+
_See code: [src/commands/blueprints/stacks.ts](https://github.com/sanity-io/runtime-cli/blob/v9.1.1/src/commands/blueprints/stacks.ts)_
|
|
289
289
|
|
|
290
290
|
## `sanity-run functions dev`
|
|
291
291
|
|
|
@@ -305,7 +305,7 @@ EXAMPLES
|
|
|
305
305
|
$ sanity-run functions dev --port 8974
|
|
306
306
|
```
|
|
307
307
|
|
|
308
|
-
_See code: [src/commands/functions/dev.ts](https://github.com/sanity-io/runtime-cli/blob/v9.
|
|
308
|
+
_See code: [src/commands/functions/dev.ts](https://github.com/sanity-io/runtime-cli/blob/v9.1.1/src/commands/functions/dev.ts)_
|
|
309
309
|
|
|
310
310
|
## `sanity-run functions env add NAME KEY VALUE`
|
|
311
311
|
|
|
@@ -327,7 +327,7 @@ EXAMPLES
|
|
|
327
327
|
$ sanity-run functions env add MyFunction API_URL https://api.example.com/
|
|
328
328
|
```
|
|
329
329
|
|
|
330
|
-
_See code: [src/commands/functions/env/add.ts](https://github.com/sanity-io/runtime-cli/blob/v9.
|
|
330
|
+
_See code: [src/commands/functions/env/add.ts](https://github.com/sanity-io/runtime-cli/blob/v9.1.1/src/commands/functions/env/add.ts)_
|
|
331
331
|
|
|
332
332
|
## `sanity-run functions env list NAME`
|
|
333
333
|
|
|
@@ -347,7 +347,7 @@ EXAMPLES
|
|
|
347
347
|
$ sanity-run functions env list MyFunction
|
|
348
348
|
```
|
|
349
349
|
|
|
350
|
-
_See code: [src/commands/functions/env/list.ts](https://github.com/sanity-io/runtime-cli/blob/v9.
|
|
350
|
+
_See code: [src/commands/functions/env/list.ts](https://github.com/sanity-io/runtime-cli/blob/v9.1.1/src/commands/functions/env/list.ts)_
|
|
351
351
|
|
|
352
352
|
## `sanity-run functions env remove NAME KEY`
|
|
353
353
|
|
|
@@ -368,7 +368,7 @@ EXAMPLES
|
|
|
368
368
|
$ sanity-run functions env remove MyFunction API_URL
|
|
369
369
|
```
|
|
370
370
|
|
|
371
|
-
_See code: [src/commands/functions/env/remove.ts](https://github.com/sanity-io/runtime-cli/blob/v9.
|
|
371
|
+
_See code: [src/commands/functions/env/remove.ts](https://github.com/sanity-io/runtime-cli/blob/v9.1.1/src/commands/functions/env/remove.ts)_
|
|
372
372
|
|
|
373
373
|
## `sanity-run functions logs NAME`
|
|
374
374
|
|
|
@@ -402,7 +402,7 @@ EXAMPLES
|
|
|
402
402
|
$ sanity-run functions logs <name> --delete
|
|
403
403
|
```
|
|
404
404
|
|
|
405
|
-
_See code: [src/commands/functions/logs.ts](https://github.com/sanity-io/runtime-cli/blob/v9.
|
|
405
|
+
_See code: [src/commands/functions/logs.ts](https://github.com/sanity-io/runtime-cli/blob/v9.1.1/src/commands/functions/logs.ts)_
|
|
406
406
|
|
|
407
407
|
## `sanity-run functions test NAME`
|
|
408
408
|
|
|
@@ -435,7 +435,7 @@ EXAMPLES
|
|
|
435
435
|
$ sanity-run functions test <name> --data '{ "id": 1 }' --timeout 60
|
|
436
436
|
```
|
|
437
437
|
|
|
438
|
-
_See code: [src/commands/functions/test.ts](https://github.com/sanity-io/runtime-cli/blob/v9.
|
|
438
|
+
_See code: [src/commands/functions/test.ts](https://github.com/sanity-io/runtime-cli/blob/v9.1.1/src/commands/functions/test.ts)_
|
|
439
439
|
|
|
440
440
|
## `sanity-run help [COMMAND]`
|
|
441
441
|
|
|
@@ -1109,12 +1109,16 @@ m-tabs {
|
|
|
1109
1109
|
background-color: light-dark(rgba(0, 0, 0, 0.025), rgba(255, 255, 255, 0.1)) !important;
|
|
1110
1110
|
}
|
|
1111
1111
|
|
|
1112
|
-
.slab-stat
|
|
1112
|
+
.slab-stat,
|
|
1113
|
+
.slab-text {
|
|
1113
1114
|
font-family: var(--font-family-mono);
|
|
1115
|
+
font-size: var(--font-size-text-2);
|
|
1116
|
+
}
|
|
1117
|
+
|
|
1118
|
+
.slab-stat {
|
|
1114
1119
|
display: flex;
|
|
1115
1120
|
align-items: center;
|
|
1116
1121
|
gap: 0 8px;
|
|
1117
|
-
font-size: var(--font-size-text-2);
|
|
1118
1122
|
margin: 0;
|
|
1119
1123
|
padding: var(--space-3);
|
|
1120
1124
|
}
|
|
@@ -1148,3 +1152,26 @@ payload-panel {
|
|
|
1148
1152
|
height: 100%;
|
|
1149
1153
|
overflow: hidden;
|
|
1150
1154
|
}
|
|
1155
|
+
|
|
1156
|
+
toggle-switch {
|
|
1157
|
+
display: inline-block;
|
|
1158
|
+
width: 2em;
|
|
1159
|
+
height: 1em;
|
|
1160
|
+
cursor: pointer;
|
|
1161
|
+
}
|
|
1162
|
+
|
|
1163
|
+
toggle-switch::part(track) {
|
|
1164
|
+
padding: 0.125em;
|
|
1165
|
+
border-radius: 1em;
|
|
1166
|
+
background-color: hsl(0, 0%, 67%);
|
|
1167
|
+
}
|
|
1168
|
+
|
|
1169
|
+
toggle-switch::part(slider) {
|
|
1170
|
+
border-radius: 1em;
|
|
1171
|
+
background-color: hsl(0, 0%, 100%);
|
|
1172
|
+
box-shadow: 0.0625em 0.0625em 0.125em hsla(0, 0%, 0%, 0.25);
|
|
1173
|
+
}
|
|
1174
|
+
|
|
1175
|
+
toggle-switch[checked]::part(track) {
|
|
1176
|
+
background-color: var(--color-interactive-primary-active-bg);
|
|
1177
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/* globals customElements document */
|
|
2
|
+
import {ApiBaseElement} from './api-base.js'
|
|
3
|
+
|
|
4
|
+
const template = document.createElement('template')
|
|
5
|
+
template.innerHTML = `
|
|
6
|
+
<style>
|
|
7
|
+
button {
|
|
8
|
+
background-color: transparent;
|
|
9
|
+
border-color: transparent;
|
|
10
|
+
margin-left: var(--space-1);
|
|
11
|
+
display: flex;
|
|
12
|
+
align-items: center;
|
|
13
|
+
}
|
|
14
|
+
button svg {
|
|
15
|
+
fill: var(--text-color);
|
|
16
|
+
}
|
|
17
|
+
</style>
|
|
18
|
+
<button title="Clear Log">
|
|
19
|
+
<svg width="16" height="16" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" d="M12 1C5.925 1 1 5.925 1 12s4.925 11 11 11 11-4.925 11-11S18.075 1 12 1zM2.5 12A9.5 9.5 0 0112 2.5c2.353 0 4.507.856 6.166 2.273L4.773 18.166A9.462 9.462 0 012.5 12zm3.334 7.227A9.462 9.462 0 0012 21.5a9.5 9.5 0 009.5-9.5 9.462 9.462 0 00-2.273-6.166L5.834 19.227z"/></svg>
|
|
20
|
+
</button>
|
|
21
|
+
`
|
|
22
|
+
|
|
23
|
+
export class ClearButton extends ApiBaseElement {
|
|
24
|
+
constructor() {
|
|
25
|
+
super()
|
|
26
|
+
this.attachShadow({mode: 'open'}).appendChild(template.content.cloneNode(true))
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
connectedCallback() {
|
|
30
|
+
this.addEventListener('click', this.clear)
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
disconnectedCallback() {
|
|
34
|
+
this.removeEventListener('click', this.clear)
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
clear = () => {
|
|
38
|
+
// this.api.store.result = {logs: '', timings: {bundle: 0, execute: 0}}
|
|
39
|
+
this.dispatchEvent(
|
|
40
|
+
new CustomEvent('clear-console', {
|
|
41
|
+
bubbles: true,
|
|
42
|
+
}),
|
|
43
|
+
)
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
customElements.define('clear-button', ClearButton)
|
|
@@ -3,10 +3,20 @@ import {ApiBaseElement} from './api-base.js'
|
|
|
3
3
|
|
|
4
4
|
// Template for the console panel
|
|
5
5
|
const template = `
|
|
6
|
-
<div id="console-container" style=
|
|
7
|
-
|
|
8
|
-
<
|
|
6
|
+
<div id="console-container" style="position: relative; background: var(--base-background-color); padding: var(--space-0) var(--space-3) var(--space-7) var(--space-4); overflow-y: scroll; border-top: 1px solid var(--card-border-color); height: 100%; max-height: 100%;">
|
|
7
|
+
<div style=" position: sticky; top: 0; left: 0; right: 0; margin-top: 0; margin-bottom: 0;">
|
|
8
|
+
<h3 class="config-label mar-t-0 mar-b-0" style="padding-top: var(--space-3); z-index: 32; background: var(--base-background-color);">
|
|
9
|
+
Console
|
|
10
|
+
</h3>
|
|
11
|
+
<div style="background: var(--base-background-color); display: flex; justify-content: flex-end; align-items: center; padding: var(--space-0); padding-block-end: var(--space-2)">
|
|
12
|
+
<toggle-switch></toggle-switch>
|
|
13
|
+
<span class="slab-text" style="margin-left: var(--space-2);">Preserve Log</span>
|
|
14
|
+
<clear-button></clear-button>
|
|
15
|
+
</div>
|
|
16
|
+
</div>
|
|
17
|
+
<pre id="console-output" style="padding: 0; margin: 0 0 var(--space-4) 0; white-space: pre-wrap; word-wrap: break-word;"></pre>
|
|
9
18
|
</div>
|
|
19
|
+
|
|
10
20
|
`
|
|
11
21
|
|
|
12
22
|
class ConsolePanel extends ApiBaseElement {
|
|
@@ -15,18 +25,33 @@ class ConsolePanel extends ApiBaseElement {
|
|
|
15
25
|
if (!this.consoleOutput || !result) return
|
|
16
26
|
|
|
17
27
|
const {error, logs} = result
|
|
28
|
+
let update = ''
|
|
18
29
|
if (error) {
|
|
19
30
|
// Display error details in the console
|
|
20
|
-
|
|
31
|
+
update = error?.details?.error ?? 'An error occurred.'
|
|
21
32
|
} else {
|
|
22
33
|
// Display regular logs
|
|
23
|
-
|
|
34
|
+
update = logs ?? '' // Handle case where logs might be null/undefined
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
if (this.api.store.preserveLog) {
|
|
38
|
+
this.consoleOutput.innerText = this.consoleOutput.innerText + update
|
|
39
|
+
} else {
|
|
40
|
+
this.consoleOutput.innerText = update
|
|
24
41
|
}
|
|
25
42
|
}
|
|
26
43
|
|
|
44
|
+
clear = () => {
|
|
45
|
+
const backUp = this.api.store.preserveLog
|
|
46
|
+
this.api.store.result = {logs: undefined, error: undefined}
|
|
47
|
+
this.querySelector('#console-output').innerText = ''
|
|
48
|
+
this.api.store.preserveLog = backUp
|
|
49
|
+
}
|
|
50
|
+
|
|
27
51
|
connectedCallback() {
|
|
28
52
|
this.innerHTML = template
|
|
29
53
|
this.consoleOutput = this.querySelector('#console-output')
|
|
54
|
+
this.addEventListener('clear-console', this.clear)
|
|
30
55
|
|
|
31
56
|
// Subscribe to changes in the result state to update the console
|
|
32
57
|
if (this.api) {
|
|
@@ -42,6 +67,7 @@ class ConsolePanel extends ApiBaseElement {
|
|
|
42
67
|
}
|
|
43
68
|
|
|
44
69
|
disconnectedCallback() {
|
|
70
|
+
this.removeEventListener('clear-console', this.clear)
|
|
45
71
|
// Unsubscribe when the element is removed from the DOM
|
|
46
72
|
if (this.api) {
|
|
47
73
|
this.api.unsubscribe(this.updateConsole)
|
|
@@ -58,8 +58,8 @@ class ResponsePanel extends ApiBaseElement {
|
|
|
58
58
|
this.time.innerText = prettyMilliseconds(timings.execute)
|
|
59
59
|
this.time.dateTime = `PT${timings.execute / 1000}S`
|
|
60
60
|
} else {
|
|
61
|
-
this.time.innerText =
|
|
62
|
-
this.time.dateTime =
|
|
61
|
+
this.time.innerText = ''
|
|
62
|
+
this.time.dateTime = ''
|
|
63
63
|
}
|
|
64
64
|
} else {
|
|
65
65
|
const transaction = this.api.store.response.state.update({
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export class ToggleSwitch extends ApiBaseElement {
|
|
2
|
+
static get observedAttributes(): string[];
|
|
3
|
+
connectedCallback(): void;
|
|
4
|
+
disconnectedCallback(): void;
|
|
5
|
+
attributeChangedCallback(name: any, oldValue: any, newValue: any): void;
|
|
6
|
+
set checked(value: boolean);
|
|
7
|
+
get checked(): boolean;
|
|
8
|
+
toggle: () => void;
|
|
9
|
+
}
|
|
10
|
+
import { ApiBaseElement } from './api-base.js';
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/* globals customElements document */
|
|
2
|
+
import {ApiBaseElement} from './api-base.js'
|
|
3
|
+
|
|
4
|
+
const template = document.createElement('template')
|
|
5
|
+
template.innerHTML = `
|
|
6
|
+
<style>
|
|
7
|
+
span {
|
|
8
|
+
box-sizing: border-box;
|
|
9
|
+
display: inline-block;
|
|
10
|
+
line-height: 1;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
[part="track"] {
|
|
14
|
+
width: 100%;
|
|
15
|
+
height: 100%;
|
|
16
|
+
background-color: #dddddd;
|
|
17
|
+
text-align: left;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
[part="slider"] {
|
|
21
|
+
width: 50%;
|
|
22
|
+
height: 100%;
|
|
23
|
+
background-color: #777777;
|
|
24
|
+
vertical-align: text-top;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
[part="track"], [part="slider"] {
|
|
28
|
+
transition: all 256ms;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
:host([checked]) [part="slider"] {
|
|
32
|
+
transform: translateX(100%);
|
|
33
|
+
}
|
|
34
|
+
</style>
|
|
35
|
+
|
|
36
|
+
<span part="track">
|
|
37
|
+
<span part="slider"></span>
|
|
38
|
+
</span>
|
|
39
|
+
`
|
|
40
|
+
|
|
41
|
+
export class ToggleSwitch extends ApiBaseElement {
|
|
42
|
+
static get observedAttributes() {
|
|
43
|
+
return ['checked']
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
constructor() {
|
|
47
|
+
super()
|
|
48
|
+
this.attachShadow({mode: 'open'}).appendChild(template.content.cloneNode(true))
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
connectedCallback() {
|
|
52
|
+
this.setAttribute('role', 'switch')
|
|
53
|
+
this.setAttribute('tabindex', '0')
|
|
54
|
+
this.addEventListener('click', this.toggle)
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
disconnectedCallback() {
|
|
58
|
+
this.removeEventListener('click', this.toggle)
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
attributeChangedCallback(name, oldValue, newValue) {
|
|
62
|
+
if (name === 'checked') {
|
|
63
|
+
this.setAttribute('aria-checked', this.checked.toString())
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
get checked() {
|
|
68
|
+
return this.hasAttribute('checked')
|
|
69
|
+
}
|
|
70
|
+
set checked(value) {
|
|
71
|
+
this.toggleAttribute('checked', value)
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
toggle = () => {
|
|
75
|
+
this.checked = !this.checked
|
|
76
|
+
this.api.store.preserveLog = this.checked
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
customElements.define('toggle-switch', ToggleSwitch)
|
|
@@ -55,6 +55,8 @@
|
|
|
55
55
|
<script src="./components/rule-panel.js" type="module"></script>
|
|
56
56
|
<script src="./components/console-panel.js" type="module"></script>
|
|
57
57
|
<script src="./components/run-panel.js" type="module"></script>
|
|
58
|
+
<script src="./components/toggle-switch.js" type="module"></script>
|
|
59
|
+
<script src="./components/clear-button.js" type="module"></script>
|
|
58
60
|
<script src="./hot-reload.js" type="module"></script>
|
|
59
61
|
</body>
|
|
60
62
|
</html>
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
import {table as renderTable} from 'node:console'
|
|
1
2
|
import {existsSync, statSync} from 'node:fs'
|
|
2
3
|
import {isAbsolute, join} from 'node:path'
|
|
3
4
|
import process from 'node:process'
|
|
5
|
+
import {inspect} from 'node:util'
|
|
4
6
|
|
|
5
7
|
export function getFunctionSource(src) {
|
|
6
8
|
const pathToCheck = isAbsolute(src) ? src : join(process.cwd(), src)
|
|
@@ -15,6 +17,64 @@ export function getFunctionSource(src) {
|
|
|
15
17
|
return `file://${pathToCheck}`
|
|
16
18
|
}
|
|
17
19
|
|
|
20
|
+
// Monkey patch console menthods to have logs match server log format
|
|
21
|
+
function logPrefix(level, ...args) {
|
|
22
|
+
const date = new Date()
|
|
23
|
+
const shouldUseColors = process.env.FORCE_COLOR === '1'
|
|
24
|
+
const message = args
|
|
25
|
+
.map((arg) =>
|
|
26
|
+
typeof arg === 'string' ? arg : inspect(arg, {depth: null, colors: shouldUseColors}),
|
|
27
|
+
)
|
|
28
|
+
.join(' ')
|
|
29
|
+
return `${date.toLocaleDateString()} ${date.toLocaleTimeString()} ${level.toUpperCase()} ${message}`
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
console.log = (...args) => {
|
|
33
|
+
process.stdout.write(`${logPrefix('info', ...args)}\n`)
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
console.info = (...args) => {
|
|
37
|
+
process.stdout.write(`${logPrefix('info', ...args)}\n`)
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
console.dir = (obj, options) => {
|
|
41
|
+
const shouldUseColors = process.env.FORCE_COLOR === '1'
|
|
42
|
+
const inspectOptions = {...options, colors: shouldUseColors}
|
|
43
|
+
process.stdout.write(`${logPrefix('info', inspect(obj, inspectOptions))}\n`)
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
console.table = (data, columns) => {
|
|
47
|
+
const prefix = logPrefix('info')
|
|
48
|
+
|
|
49
|
+
// Capture table output
|
|
50
|
+
const originalWrite = process.stdout.write.bind(process.stdout)
|
|
51
|
+
let buffer = ''
|
|
52
|
+
|
|
53
|
+
process.stdout.write = (chunk, encoding, callback) => {
|
|
54
|
+
buffer += chunk
|
|
55
|
+
if (typeof callback === 'function') callback()
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
renderTable(data, columns)
|
|
59
|
+
|
|
60
|
+
// Restore and print
|
|
61
|
+
process.stdout.write = originalWrite
|
|
62
|
+
for (const line of buffer.split('\n')) {
|
|
63
|
+
if (line.trim()) {
|
|
64
|
+
const message = `${!line.startsWith(prefix) ? `${prefix} ${line}` : line}`.trim()
|
|
65
|
+
process.stdout.write(`${message}\n`)
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
console.warn = (...args) => {
|
|
71
|
+
process.stdout.write(`${logPrefix('warn', ...args)}\n`)
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
console.error = (...args) => {
|
|
75
|
+
process.stdout.write(`${logPrefix('error', ...args)}\n`)
|
|
76
|
+
}
|
|
77
|
+
|
|
18
78
|
// Start when payload data arrives from parent process
|
|
19
79
|
process.on('message', async (data) => {
|
|
20
80
|
let jsonData = null
|
package/oclif.manifest.json
CHANGED