@kud/cli-shot 0.3.1 → 0.3.2
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/dist/{chunk-J6GAXRMG.js → chunk-FLZX3UOL.js} +115 -28
- package/dist/cli.js +1 -1
- package/dist/index.js +1 -1
- package/package.json +1 -1
|
@@ -1,34 +1,39 @@
|
|
|
1
|
-
import { mkdirSync, readFileSync, writeFileSync, mkdtempSync, rmSync, copyFileSync, readdirSync, existsSync, accessSync, constants } from 'fs';
|
|
1
|
+
import { mkdirSync, readFileSync, writeFileSync, mkdtempSync, rmSync, copyFileSync, readdirSync, chmodSync, existsSync, accessSync, constants } from 'fs';
|
|
2
2
|
import { tmpdir, cpus } from 'os';
|
|
3
3
|
import { dirname, join, relative, sep, extname, basename } from 'path';
|
|
4
|
-
import { createRequire } from 'module';
|
|
5
4
|
import { spawn } from 'node-pty';
|
|
6
5
|
import headless from '@xterm/headless';
|
|
7
6
|
import { SerializeAddon } from '@xterm/addon-serialize';
|
|
7
|
+
import { createRequire } from 'module';
|
|
8
8
|
import { execFileSync, spawnSync } from 'child_process';
|
|
9
9
|
import { fileURLToPath } from 'url';
|
|
10
10
|
|
|
11
11
|
// src/index.ts
|
|
12
|
-
var
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
`Could not open a pty for ${command}: ${message}
|
|
21
|
-
` + (notExecutable ? ` node-pty's helper is not executable. Fix with:
|
|
22
|
-
chmod +x ${helper}
|
|
23
|
-
It ships without the mode bit when install scripts are blocked;
|
|
24
|
-
npm approve-scripts node-pty makes it survive a reinstall.` : ` Check that the command exists and is executable.`),
|
|
25
|
-
{ cause: error }
|
|
26
|
-
);
|
|
12
|
+
var nodePtyDir = () => {
|
|
13
|
+
try {
|
|
14
|
+
return dirname(
|
|
15
|
+
createRequire(import.meta.url).resolve("node-pty/package.json")
|
|
16
|
+
);
|
|
17
|
+
} catch {
|
|
18
|
+
return void 0;
|
|
19
|
+
}
|
|
27
20
|
};
|
|
28
|
-
var
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
21
|
+
var currentContext = () => ({
|
|
22
|
+
platform: process.platform,
|
|
23
|
+
arch: process.arch,
|
|
24
|
+
packageDir: nodePtyDir()
|
|
25
|
+
});
|
|
26
|
+
var helperPath = ({
|
|
27
|
+
platform,
|
|
28
|
+
arch,
|
|
29
|
+
packageDir
|
|
30
|
+
}) => {
|
|
31
|
+
if (!packageDir) return void 0;
|
|
32
|
+
const candidate = join(
|
|
33
|
+
packageDir,
|
|
34
|
+
"prebuilds",
|
|
35
|
+
`${platform}-${arch}`,
|
|
36
|
+
"spawn-helper"
|
|
32
37
|
);
|
|
33
38
|
return existsSync(candidate) ? candidate : void 0;
|
|
34
39
|
};
|
|
@@ -40,6 +45,84 @@ var isExecutable = (path) => {
|
|
|
40
45
|
return false;
|
|
41
46
|
}
|
|
42
47
|
};
|
|
48
|
+
var isHelperFailure = (message) => message.includes("posix_spawnp");
|
|
49
|
+
var repairHelper = (message, context) => {
|
|
50
|
+
if (context.platform !== "darwin" || !isHelperFailure(message)) {
|
|
51
|
+
return { kind: "not-applicable" };
|
|
52
|
+
}
|
|
53
|
+
const helper = helperPath(context);
|
|
54
|
+
if (helper === void 0 || isExecutable(helper)) {
|
|
55
|
+
return { kind: "not-applicable" };
|
|
56
|
+
}
|
|
57
|
+
try {
|
|
58
|
+
(context.chmod ?? chmodSync)(helper, 493);
|
|
59
|
+
} catch (error) {
|
|
60
|
+
return {
|
|
61
|
+
kind: "unfixable",
|
|
62
|
+
helper,
|
|
63
|
+
reason: error instanceof Error ? error.message : String(error)
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
return { kind: "repaired", helper };
|
|
67
|
+
};
|
|
68
|
+
var spawnWithRepair = (spawn2, context = currentContext()) => {
|
|
69
|
+
try {
|
|
70
|
+
return spawn2();
|
|
71
|
+
} catch (error) {
|
|
72
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
73
|
+
const repair = repairHelper(message, context);
|
|
74
|
+
if (repair.kind !== "repaired") throw new HelperError(error, repair);
|
|
75
|
+
try {
|
|
76
|
+
return spawn2();
|
|
77
|
+
} catch (retryError) {
|
|
78
|
+
throw new HelperError(retryError, repair);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
var HelperError = class extends Error {
|
|
83
|
+
constructor(original, repair) {
|
|
84
|
+
super(
|
|
85
|
+
original instanceof Error ? original.message : String(original),
|
|
86
|
+
{ cause: original }
|
|
87
|
+
);
|
|
88
|
+
this.original = original;
|
|
89
|
+
this.repair = repair;
|
|
90
|
+
}
|
|
91
|
+
original;
|
|
92
|
+
repair;
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
// src/capture.ts
|
|
96
|
+
var { Terminal } = headless;
|
|
97
|
+
var TICK_MS = 60;
|
|
98
|
+
var HELPER_FAILURE = /execvp\(\d\) failed|posix_spawnp failed/;
|
|
99
|
+
var explainSpawnFailure = (error, command, repair = { kind: "not-applicable" }, context = currentContext()) => {
|
|
100
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
101
|
+
const fix = (helper) => ` chmod +x ${helper}
|
|
102
|
+
`;
|
|
103
|
+
let advice;
|
|
104
|
+
if (repair.kind === "unfixable") {
|
|
105
|
+
advice = ` node-pty's helper is not executable and could not be fixed (${repair.reason}):
|
|
106
|
+
${repair.helper}
|
|
107
|
+
Fix with:
|
|
108
|
+
` + fix(repair.helper);
|
|
109
|
+
} else if (repair.kind === "repaired") {
|
|
110
|
+
advice = ` node-pty's helper was made executable but the spawn still failed:
|
|
111
|
+
${repair.helper}
|
|
112
|
+
If it lost the bit again, fix with:
|
|
113
|
+
` + fix(repair.helper);
|
|
114
|
+
} else {
|
|
115
|
+
const helper = helperPath(context);
|
|
116
|
+
advice = isHelperFailure(message) && helper !== void 0 && !isExecutable(helper) ? ` node-pty's helper is not executable. Fix with:
|
|
117
|
+
` + fix(helper) + ` It ships without the mode bit when install scripts are blocked;
|
|
118
|
+
npm approve-scripts node-pty makes it survive a reinstall.` : ` Check that the command exists and is executable.`;
|
|
119
|
+
}
|
|
120
|
+
return new Error(
|
|
121
|
+
`Could not open a pty for ${command}: ${message}
|
|
122
|
+
${advice.trimEnd()}`,
|
|
123
|
+
{ cause: error }
|
|
124
|
+
);
|
|
125
|
+
};
|
|
43
126
|
var CI_MARKERS = ["CI", "CONTINUOUS_INTEGRATION"];
|
|
44
127
|
var childEnv = (base, extra = {}) => {
|
|
45
128
|
const merged = { ...base };
|
|
@@ -66,14 +149,18 @@ var capture = (command, args = [], {
|
|
|
66
149
|
term.loadAddon(serializer);
|
|
67
150
|
let pty;
|
|
68
151
|
try {
|
|
69
|
-
pty =
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
152
|
+
pty = spawnWithRepair(
|
|
153
|
+
() => spawn(command, [...args], {
|
|
154
|
+
name: "xterm-256color",
|
|
155
|
+
cols,
|
|
156
|
+
rows,
|
|
157
|
+
env: childEnv(process.env, env)
|
|
158
|
+
})
|
|
159
|
+
);
|
|
75
160
|
} catch (error) {
|
|
76
|
-
reject(
|
|
161
|
+
reject(
|
|
162
|
+
error instanceof HelperError ? explainSpawnFailure(error.original, command, error.repair) : explainSpawnFailure(error, command)
|
|
163
|
+
);
|
|
77
164
|
return;
|
|
78
165
|
}
|
|
79
166
|
let raw = 0;
|
package/dist/cli.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { FORMATS, DEFAULT_FONT, listScreens, shootScreens, shootAll } from './chunk-
|
|
2
|
+
import { FORMATS, DEFAULT_FONT, listScreens, shootScreens, shootAll } from './chunk-FLZX3UOL.js';
|
|
3
3
|
import { Command } from 'commander';
|
|
4
4
|
|
|
5
5
|
// src/flags.ts
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { DEFAULT_FONT, DEFAULT_FPS, DEFAULT_HOLD, FORMATS, MOVIE_FORMATS, VERCEL_CONFIG, buildPlayer, capture, castEvent, castHeader, drivenScreen, hasFfmpeg, launchBrowser, listScreens, movieFrames, parseCast, shootAll, shootFormats, shootScreen, shootScreens, toCast, toImage, toMovie } from './chunk-
|
|
1
|
+
export { DEFAULT_FONT, DEFAULT_FPS, DEFAULT_HOLD, FORMATS, MOVIE_FORMATS, VERCEL_CONFIG, buildPlayer, capture, castEvent, castHeader, drivenScreen, hasFfmpeg, launchBrowser, listScreens, movieFrames, parseCast, shootAll, shootFormats, shootScreen, shootScreens, toCast, toImage, toMovie } from './chunk-FLZX3UOL.js';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kud/cli-shot",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Automatic screenshots and recordings of interactive CLIs — pty capture, terminal emulation, PNG, asciicast, a web player, GIF or MP4 out",
|
|
6
6
|
"license": "MIT",
|