@rendshot/cli 0.1.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/dist/commands/auth.d.ts +4 -0
- package/dist/commands/auth.d.ts.map +1 -0
- package/dist/commands/auth.js +71 -0
- package/dist/commands/auth.js.map +1 -0
- package/dist/commands/generate.d.ts +3 -0
- package/dist/commands/generate.d.ts.map +1 -0
- package/dist/commands/generate.js +66 -0
- package/dist/commands/generate.js.map +1 -0
- package/dist/commands/screenshot.d.ts +3 -0
- package/dist/commands/screenshot.d.ts.map +1 -0
- package/dist/commands/screenshot.js +57 -0
- package/dist/commands/screenshot.js.map +1 -0
- package/dist/commands/usage.d.ts +3 -0
- package/dist/commands/usage.d.ts.map +1 -0
- package/dist/commands/usage.js +19 -0
- package/dist/commands/usage.js.map +1 -0
- package/dist/config.d.ts +13 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +36 -0
- package/dist/config.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +16 -0
- package/dist/index.js.map +1 -0
- package/package.json +37 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../src/commands/auth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAInC,wBAAgB,YAAY,IAAI,OAAO,CAAC,MAAM,CAAC,CAkB9C;AAED,eAAO,MAAM,WAAW,SACe,CAAA"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
import { createInterface } from 'readline';
|
|
3
|
+
import { saveCliConfig, loadCliConfig, deleteCliConfig } from '../config.js';
|
|
4
|
+
export function promptApiKey() {
|
|
5
|
+
return new Promise((resolve, reject) => {
|
|
6
|
+
const rl = createInterface({
|
|
7
|
+
input: process.stdin,
|
|
8
|
+
output: process.stderr,
|
|
9
|
+
terminal: process.stdin.isTTY ?? false,
|
|
10
|
+
});
|
|
11
|
+
rl.on('close', () => {
|
|
12
|
+
// Ctrl+C or stream closed before answer
|
|
13
|
+
reject(new Error('Prompt cancelled'));
|
|
14
|
+
});
|
|
15
|
+
rl.question('Enter your API Key (from rendshot.ai/dashboard/keys): ', (answer) => {
|
|
16
|
+
rl.close();
|
|
17
|
+
resolve(answer.trim());
|
|
18
|
+
});
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
export const authCommand = new Command('auth')
|
|
22
|
+
.description('Manage authentication');
|
|
23
|
+
authCommand
|
|
24
|
+
.command('login')
|
|
25
|
+
.description('Save API key (interactive prompt)')
|
|
26
|
+
.action(async () => {
|
|
27
|
+
let apiKey;
|
|
28
|
+
try {
|
|
29
|
+
apiKey = await promptApiKey();
|
|
30
|
+
}
|
|
31
|
+
catch {
|
|
32
|
+
console.log('\nLogin cancelled.');
|
|
33
|
+
process.exit(130);
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
if (!apiKey) {
|
|
37
|
+
console.error('Error: No API key entered.');
|
|
38
|
+
process.exit(1);
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
if (!apiKey.startsWith('rs_live_')) {
|
|
42
|
+
console.error('Error: Invalid API key format. Keys must start with "rs_live_"');
|
|
43
|
+
process.exit(1);
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
const config = loadCliConfig();
|
|
47
|
+
config.apiKey = apiKey;
|
|
48
|
+
saveCliConfig(config);
|
|
49
|
+
console.log('\u2713 API Key saved to ~/.rendshot/config.json');
|
|
50
|
+
});
|
|
51
|
+
authCommand
|
|
52
|
+
.command('status')
|
|
53
|
+
.description('Show current auth status')
|
|
54
|
+
.action(() => {
|
|
55
|
+
const config = loadCliConfig();
|
|
56
|
+
if (config.apiKey) {
|
|
57
|
+
console.log(`Authenticated: ${config.apiKey.slice(0, 12)}...`);
|
|
58
|
+
console.log(`API URL: ${config.apiUrl || 'https://api.rendshot.ai'}`);
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
console.log('Not authenticated. Run "rendshot auth login"');
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
authCommand
|
|
65
|
+
.command('logout')
|
|
66
|
+
.description('Remove saved credentials')
|
|
67
|
+
.action(() => {
|
|
68
|
+
deleteCliConfig();
|
|
69
|
+
console.log('Logged out. Config file removed.');
|
|
70
|
+
});
|
|
71
|
+
//# sourceMappingURL=auth.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.js","sourceRoot":"","sources":["../../src/commands/auth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACnC,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAA;AAC1C,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAE5E,MAAM,UAAU,YAAY;IAC1B,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACrC,MAAM,EAAE,GAAG,eAAe,CAAC;YACzB,KAAK,EAAE,OAAO,CAAC,KAAK;YACpB,MAAM,EAAE,OAAO,CAAC,MAAM;YACtB,QAAQ,EAAE,OAAO,CAAC,KAAK,CAAC,KAAK,IAAI,KAAK;SACvC,CAAC,CAAA;QAEF,EAAE,CAAC,EAAE,CAAC,OAAO,EAAE,GAAG,EAAE;YAClB,wCAAwC;YACxC,MAAM,CAAC,IAAI,KAAK,CAAC,kBAAkB,CAAC,CAAC,CAAA;QACvC,CAAC,CAAC,CAAA;QAEF,EAAE,CAAC,QAAQ,CAAC,wDAAwD,EAAE,CAAC,MAAM,EAAE,EAAE;YAC/E,EAAE,CAAC,KAAK,EAAE,CAAA;YACV,OAAO,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,CAAA;QACxB,CAAC,CAAC,CAAA;IACJ,CAAC,CAAC,CAAA;AACJ,CAAC;AAED,MAA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KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,KAAK,CAAC,CAAA;QAC9D,OAAO,CAAC,GAAG,CAAC,YAAY,MAAM,CAAC,MAAM,IAAI,yBAAyB,EAAE,CAAC,CAAA;IACvE,CAAC;SAAM,CAAC;QACN,OAAO,CAAC,GAAG,CAAC,8CAA8C,CAAC,CAAA;IAC7D,CAAC;AACH,CAAC,CAAC,CAAA;AAEJ,WAAW;KACR,OAAO,CAAC,QAAQ,CAAC;KACjB,WAAW,CAAC,0BAA0B,CAAC;KACvC,MAAM,CAAC,GAAG,EAAE;IACX,eAAe,EAAE,CAAA;IACjB,OAAO,CAAC,GAAG,CAAC,kCAAkC,CAAC,CAAA;AACjD,CAAC,CAAC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate.d.ts","sourceRoot":"","sources":["../../src/commands/generate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAOnC,eAAO,MAAM,eAAe,SAkDxB,CAAA"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
import { readFileSync, createWriteStream } from 'fs';
|
|
3
|
+
import { pipeline } from 'stream/promises';
|
|
4
|
+
import { Readable } from 'stream';
|
|
5
|
+
import { getApiKey, getApiUrl } from '../config.js';
|
|
6
|
+
import { RendshotClient } from '@rendshot/sdk';
|
|
7
|
+
export const generateCommand = new Command('generate')
|
|
8
|
+
.description('Render HTML/CSS to an image')
|
|
9
|
+
.option('--html <html>', 'HTML content to render')
|
|
10
|
+
.option('-f, --file <path>', 'Read HTML from file')
|
|
11
|
+
.option('--css <css>', 'CSS styles')
|
|
12
|
+
.option('-w, --width <n>', 'Width in pixels', parseInt)
|
|
13
|
+
.option('-h, --height <n>', 'Height in pixels', parseInt)
|
|
14
|
+
.option('--format <fmt>', 'Output format (png, jpg)')
|
|
15
|
+
.option('--quality <n>', 'Quality 1-100', parseInt)
|
|
16
|
+
.option('--device-scale <n>', 'Device scale (1, 2, 3)', parseInt)
|
|
17
|
+
.option('--timeout <ms>', 'Timeout in ms', parseInt)
|
|
18
|
+
.option('--json', 'Output full JSON response')
|
|
19
|
+
.option('--save <path>', 'Save image to local file')
|
|
20
|
+
.action(async (opts) => {
|
|
21
|
+
try {
|
|
22
|
+
let html = opts.html;
|
|
23
|
+
if (opts.file) {
|
|
24
|
+
html = readFileSync(opts.file, 'utf-8');
|
|
25
|
+
}
|
|
26
|
+
if (!html) {
|
|
27
|
+
console.error('Error: HTML content is required (--html or -f)');
|
|
28
|
+
process.exit(1);
|
|
29
|
+
}
|
|
30
|
+
const client = new RendshotClient({ apiKey: getApiKey(), baseUrl: getApiUrl() });
|
|
31
|
+
const params = { html };
|
|
32
|
+
if (opts.css)
|
|
33
|
+
params.css = opts.css;
|
|
34
|
+
if (opts.width)
|
|
35
|
+
params.width = opts.width;
|
|
36
|
+
if (opts.height)
|
|
37
|
+
params.height = opts.height;
|
|
38
|
+
if (opts.format)
|
|
39
|
+
params.format = opts.format;
|
|
40
|
+
if (opts.quality)
|
|
41
|
+
params.quality = opts.quality;
|
|
42
|
+
if (opts.deviceScale)
|
|
43
|
+
params.deviceScale = opts.deviceScale;
|
|
44
|
+
if (opts.timeout)
|
|
45
|
+
params.timeout = opts.timeout;
|
|
46
|
+
const result = await client.renderImage(params);
|
|
47
|
+
if (opts.save) {
|
|
48
|
+
const res = await fetch(result.url);
|
|
49
|
+
if (!res.ok || !res.body)
|
|
50
|
+
throw new Error('Failed to download image');
|
|
51
|
+
await pipeline(Readable.fromWeb(res.body), createWriteStream(opts.save));
|
|
52
|
+
console.log(`Saved to ${opts.save}`);
|
|
53
|
+
}
|
|
54
|
+
else if (opts.json) {
|
|
55
|
+
console.log(JSON.stringify(result));
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
console.log(result.url);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
catch (err) {
|
|
62
|
+
console.error(`Error: ${err.message}`);
|
|
63
|
+
process.exit(err.status >= 500 ? 2 : 1);
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
//# sourceMappingURL=generate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate.js","sourceRoot":"","sources":["../../src/commands/generate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACnC,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,IAAI,CAAA;AACpD,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAA;AAC1C,OAAO,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAA;AACjC,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AACnD,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAA;AAE9C,MAAM,CAAC,MAAM,eAAe,GAAG,IAAI,OAAO,CAAC,UAAU,CAAC;KACnD,WAAW,CAAC,6BAA6B,CAAC;KAC1C,MAAM,CAAC,eAAe,EAAE,wBAAwB,CAAC;KACjD,MAAM,CAAC,mBAAmB,EAAE,qBAAqB,CAAC;KAClD,MAAM,CAAC,aAAa,EAAE,YAAY,CAAC;KACnC,MAAM,CAAC,iBAAiB,EAAE,iBAAiB,EAAE,QAAQ,CAAC;KACtD,MAAM,CAAC,kBAAkB,EAAE,kBAAkB,EAAE,QAAQ,CAAC;KACxD,MAAM,CAAC,gBAAgB,EAAE,0BAA0B,CAAC;KACpD,MAAM,CAAC,eAAe,EAAE,eAAe,EAAE,QAAQ,CAAC;KAClD,MAAM,CAAC,oBAAoB,EAAE,wBAAwB,EAAE,QAAQ,CAAC;KAChE,MAAM,CAAC,gBAAgB,EAAE,eAAe,EAAE,QAAQ,CAAC;KACnD,MAAM,CAAC,QAAQ,EAAE,2BAA2B,CAAC;KAC7C,MAAM,CAAC,eAAe,EAAE,0BAA0B,CAAC;KACnD,MAAM,CAAC,KAAK,EA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AAC;YACd,MAAM,GAAG,GAAG,MAAM,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAA;YACnC,IAAI,CAAC,GAAG,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,IAAI;gBAAE,MAAM,IAAI,KAAK,CAAC,0BAA0B,CAAC,CAAA;YACrE,MAAM,QAAQ,CAAC,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,IAAW,CAAC,EAAE,iBAAiB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAA;YAC/E,OAAO,CAAC,GAAG,CAAC,YAAY,IAAI,CAAC,IAAI,EAAE,CAAC,CAAA;QACtC,CAAC;aAAM,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC;YACrB,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,CAAA;QACrC,CAAC;aAAM,CAAC;YACN,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAA;QACzB,CAAC;IACH,CAAC;IAAC,OAAO,GAAQ,EAAE,CAAC;QAClB,OAAO,CAAC,KAAK,CAAC,UAAU,GAAG,CAAC,OAAO,EAAE,CAAC,CAAA;QACtC,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,IAAI,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;IACzC,CAAC;AACH,CAAC,CAAC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"screenshot.d.ts","sourceRoot":"","sources":["../../src/commands/screenshot.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAOnC,eAAO,MAAM,iBAAiB,SAwC1B,CAAA"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
import { createWriteStream } from 'fs';
|
|
3
|
+
import { pipeline } from 'stream/promises';
|
|
4
|
+
import { Readable } from 'stream';
|
|
5
|
+
import { getApiKey, getApiUrl } from '../config.js';
|
|
6
|
+
import { RendshotClient } from '@rendshot/sdk';
|
|
7
|
+
export const screenshotCommand = new Command('screenshot')
|
|
8
|
+
.description('Take a screenshot of a URL')
|
|
9
|
+
.argument('<url>', 'URL to screenshot')
|
|
10
|
+
.option('-w, --width <n>', 'Width in pixels', parseInt)
|
|
11
|
+
.option('-h, --height <n>', 'Height in pixels', parseInt)
|
|
12
|
+
.option('--format <fmt>', 'Output format (png, jpg)')
|
|
13
|
+
.option('--quality <n>', 'Quality 1-100', parseInt)
|
|
14
|
+
.option('--full-page', 'Capture full page')
|
|
15
|
+
.option('--device-scale <n>', 'Device scale (1, 2, 3)', parseInt)
|
|
16
|
+
.option('--timeout <ms>', 'Timeout in ms', parseInt)
|
|
17
|
+
.option('--json', 'Output full JSON response')
|
|
18
|
+
.option('--save <path>', 'Save image to local file')
|
|
19
|
+
.action(async (url, opts) => {
|
|
20
|
+
try {
|
|
21
|
+
const client = new RendshotClient({ apiKey: getApiKey(), baseUrl: getApiUrl() });
|
|
22
|
+
const params = { url };
|
|
23
|
+
if (opts.width)
|
|
24
|
+
params.width = opts.width;
|
|
25
|
+
if (opts.height)
|
|
26
|
+
params.height = opts.height;
|
|
27
|
+
if (opts.format)
|
|
28
|
+
params.format = opts.format;
|
|
29
|
+
if (opts.quality)
|
|
30
|
+
params.quality = opts.quality;
|
|
31
|
+
if (opts.fullPage)
|
|
32
|
+
params.fullPage = true;
|
|
33
|
+
if (opts.deviceScale)
|
|
34
|
+
params.deviceScale = opts.deviceScale;
|
|
35
|
+
if (opts.timeout)
|
|
36
|
+
params.timeout = opts.timeout;
|
|
37
|
+
const result = await client.screenshotUrl(params);
|
|
38
|
+
if (opts.save) {
|
|
39
|
+
const res = await fetch(result.url);
|
|
40
|
+
if (!res.ok || !res.body)
|
|
41
|
+
throw new Error('Failed to download image');
|
|
42
|
+
await pipeline(Readable.fromWeb(res.body), createWriteStream(opts.save));
|
|
43
|
+
console.log(`Saved to ${opts.save}`);
|
|
44
|
+
}
|
|
45
|
+
else if (opts.json) {
|
|
46
|
+
console.log(JSON.stringify(result));
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
console.log(result.url);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
catch (err) {
|
|
53
|
+
console.error(`Error: ${err.message}`);
|
|
54
|
+
process.exit(err.status >= 500 ? 2 : 1);
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
//# sourceMappingURL=screenshot.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"screenshot.js","sourceRoot":"","sources":["../../src/commands/screenshot.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACnC,OAAO,EAAE,iBAAiB,EAAE,MAAM,IAAI,CAAA;AACtC,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAA;AAC1C,OAAO,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAA;AACjC,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AACnD,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAA;AAE9C,MAAM,CAAC,MAAM,iBAAiB,GAAG,IAAI,OAAO,CAAC,YAAY,CAAC;KACvD,WAAW,CAAC,4BAA4B,CAAC;KACzC,QAAQ,CAAC,OAAO,EAAE,mBAAmB,CAAC;KACtC,MAAM,CAAC,iBAAiB,EAAE,iBAAiB,EAAE,QAAQ,CAAC;KACtD,MAAM,CAAC,kBAAkB,EAAE,kBAAkB,EAAE,QAAQ,CAAC;KACxD,MAAM,CAAC,gBAAgB,EAAE,0BAA0B,CAAC;KACpD,MAAM,CAAC,eAAe,EAAE,eAAe,EAAE,QAAQ,CAAC;KAClD,MAAM,CAAC,aAAa,EAAE,mBAAmB,CAAC;KAC1C,MAAM,CAAC,oBAAoB,EAAE,wBAAwB,EAAE,QAAQ,CAAC;K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;gBAAE,MAAM,IAAI,KAAK,CAAC,0BAA0B,CAAC,CAAA;YACrE,MAAM,QAAQ,CAAC,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,IAAW,CAAC,EAAE,iBAAiB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAA;YAC/E,OAAO,CAAC,GAAG,CAAC,YAAY,IAAI,CAAC,IAAI,EAAE,CAAC,CAAA;QACtC,CAAC;aAAM,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC;YACrB,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,CAAA;QACrC,CAAC;aAAM,CAAC;YACN,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAA;QACzB,CAAC;IACH,CAAC;IAAC,OAAO,GAAQ,EAAE,CAAC;QAClB,OAAO,CAAC,KAAK,CAAC,UAAU,GAAG,CAAC,OAAO,EAAE,CAAC,CAAA;QACtC,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,IAAI,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;IACzC,CAAC;AACH,CAAC,CAAC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"usage.d.ts","sourceRoot":"","sources":["../../src/commands/usage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAInC,eAAO,MAAM,YAAY,SAarB,CAAA"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
import { getApiKey, getApiUrl } from '../config.js';
|
|
3
|
+
import { RendshotClient } from '@rendshot/sdk';
|
|
4
|
+
export const usageCommand = new Command('usage')
|
|
5
|
+
.description('Show current month usage')
|
|
6
|
+
.action(async () => {
|
|
7
|
+
try {
|
|
8
|
+
const client = new RendshotClient({ apiKey: getApiKey(), baseUrl: getApiUrl() });
|
|
9
|
+
const result = await client.getUsage();
|
|
10
|
+
console.log(`Plan: ${result.plan}`);
|
|
11
|
+
console.log(`Month: ${result.month}`);
|
|
12
|
+
console.log(`Usage: ${result.count} / ${result.limit}`);
|
|
13
|
+
}
|
|
14
|
+
catch (err) {
|
|
15
|
+
console.error(`Error: ${err.message}`);
|
|
16
|
+
process.exit(err.status >= 500 ? 2 : 1);
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
//# sourceMappingURL=usage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"usage.js","sourceRoot":"","sources":["../../src/commands/usage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACnC,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AACnD,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAA;AAE9C,MAAM,CAAC,MAAM,YAAY,GAAG,IAAI,OAAO,CAAC,OAAO,CAAC;KAC7C,WAAW,CAAC,0BAA0B,CAAC;KACvC,MAAM,CAAC,KAAK,IAAI,EAAE;IACjB,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,IAAI,cAAc,CAAC,EAAE,MAAM,EAAE,SAAS,EAAE,EAAE,OAAO,EAAE,SAAS,EAAE,EAAE,CAAC,CAAA;QAChF,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,QAAQ,EAAE,CAAA;QACtC,OAAO,CAAC,GAAG,CAAC,SAAS,MAAM,CAAC,IAAI,EAAE,CAAC,CAAA;QACnC,OAAO,CAAC,GAAG,CAAC,UAAU,MAAM,CAAC,KAAK,EAAE,CAAC,CAAA;QACrC,OAAO,CAAC,GAAG,CAAC,UAAU,MAAM,CAAC,KAAK,MAAM,MAAM,CAAC,KAAK,EAAE,CAAC,CAAA;IACzD,CAAC;IAAC,OAAO,GAAQ,EAAE,CAAC;QAClB,OAAO,CAAC,KAAK,CAAC,UAAU,GAAG,CAAC,OAAO,EAAE,CAAC,CAAA;QACtC,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,IAAI,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;IACzC,CAAC;AACH,CAAC,CAAC,CAAA"}
|
package/dist/config.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export interface CliConfig {
|
|
2
|
+
apiKey?: string;
|
|
3
|
+
apiUrl?: string;
|
|
4
|
+
defaultFormat?: string;
|
|
5
|
+
defaultWidth?: number;
|
|
6
|
+
defaultHeight?: number;
|
|
7
|
+
}
|
|
8
|
+
export declare function loadCliConfig(): CliConfig;
|
|
9
|
+
export declare function saveCliConfig(config: CliConfig): void;
|
|
10
|
+
export declare function deleteCliConfig(): void;
|
|
11
|
+
export declare function getApiKey(): string;
|
|
12
|
+
export declare function getApiUrl(): string;
|
|
13
|
+
//# sourceMappingURL=config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAOA,MAAM,WAAW,SAAS;IACxB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,aAAa,CAAC,EAAE,MAAM,CAAA;CACvB;AAED,wBAAgB,aAAa,IAAI,SAAS,CAMzC;AAED,wBAAgB,aAAa,CAAC,MAAM,EAAE,SAAS,GAAG,IAAI,CAIrD;AAED,wBAAgB,eAAe,IAAI,IAAI,CAItC;AAED,wBAAgB,SAAS,IAAI,MAAM,CAOlC;AAED,wBAAgB,SAAS,IAAI,MAAM,CAGlC"}
|
package/dist/config.js
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { readFileSync, writeFileSync, mkdirSync, existsSync, unlinkSync, chmodSync } from 'fs';
|
|
2
|
+
import { join } from 'path';
|
|
3
|
+
import { homedir } from 'os';
|
|
4
|
+
const CONFIG_DIR = join(homedir(), '.rendshot');
|
|
5
|
+
const CONFIG_FILE = join(CONFIG_DIR, 'config.json');
|
|
6
|
+
export function loadCliConfig() {
|
|
7
|
+
try {
|
|
8
|
+
return JSON.parse(readFileSync(CONFIG_FILE, 'utf-8'));
|
|
9
|
+
}
|
|
10
|
+
catch {
|
|
11
|
+
return {};
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
export function saveCliConfig(config) {
|
|
15
|
+
mkdirSync(CONFIG_DIR, { recursive: true, mode: 0o700 });
|
|
16
|
+
writeFileSync(CONFIG_FILE, JSON.stringify(config, null, 2));
|
|
17
|
+
chmodSync(CONFIG_FILE, 0o600);
|
|
18
|
+
}
|
|
19
|
+
export function deleteCliConfig() {
|
|
20
|
+
if (existsSync(CONFIG_FILE)) {
|
|
21
|
+
unlinkSync(CONFIG_FILE);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
export function getApiKey() {
|
|
25
|
+
const config = loadCliConfig();
|
|
26
|
+
if (!config.apiKey) {
|
|
27
|
+
console.error('Error: Not authenticated. Run "rendshot auth login" first.');
|
|
28
|
+
process.exit(1);
|
|
29
|
+
}
|
|
30
|
+
return config.apiKey;
|
|
31
|
+
}
|
|
32
|
+
export function getApiUrl() {
|
|
33
|
+
const config = loadCliConfig();
|
|
34
|
+
return config.apiUrl || 'https://api.rendshot.ai';
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,SAAS,EAAE,UAAU,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,IAAI,CAAA;AAC9F,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAA;AAC3B,OAAO,EAAE,OAAO,E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,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":""}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { Command } from 'commander';
|
|
3
|
+
import { authCommand } from './commands/auth.js';
|
|
4
|
+
import { generateCommand } from './commands/generate.js';
|
|
5
|
+
import { screenshotCommand } from './commands/screenshot.js';
|
|
6
|
+
import { usageCommand } from './commands/usage.js';
|
|
7
|
+
const program = new Command()
|
|
8
|
+
.name('rendshot')
|
|
9
|
+
.description('Rendshot CLI - AI-Native image generation')
|
|
10
|
+
.version('0.1.0');
|
|
11
|
+
program.addCommand(authCommand);
|
|
12
|
+
program.addCommand(generateCommand);
|
|
13
|
+
program.addCommand(screenshotCommand);
|
|
14
|
+
program.addCommand(usageCommand);
|
|
15
|
+
program.parse();
|
|
16
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACnC,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAA;AAChD,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAA;AACxD,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAA;AAC5D,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAA;AAElD,MAAM,OAAO,GAAG,IAAI,OAAO,EAAE;KAC1B,IAAI,CAAC,UAAU,CAAC;KAChB,WAAW,CAAC,2CAA2C,CAAC;KACxD,OAAO,CAAC,OAAO,CAAC,CAAA;AAEnB,OAAO,CAAC,UAAU,CAAC,WAAW,CAAC,CAAA;AAC/B,OAAO,CAAC,UAAU,CAAC,eAAe,CAAC,CAAA;AACnC,OAAO,CAAC,UAAU,CAAC,iBAAiB,CAAC,CAAA;AACrC,OAAO,CAAC,UAAU,CAAC,YAAY,CAAC,CAAA;AAEhC,OAAO,CAAC,KAAK,EAAE,CAAA"}
|
package/package.json
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@rendshot/cli",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"description": "CLI for RendShot — HTML-to-image rendering and URL screenshots",
|
|
6
|
+
"keywords": [
|
|
7
|
+
"rendshot",
|
|
8
|
+
"screenshot",
|
|
9
|
+
"html-to-image",
|
|
10
|
+
"rendering",
|
|
11
|
+
"cli"
|
|
12
|
+
],
|
|
13
|
+
"license": "MIT",
|
|
14
|
+
"engines": {
|
|
15
|
+
"node": ">=18"
|
|
16
|
+
},
|
|
17
|
+
"files": [
|
|
18
|
+
"dist"
|
|
19
|
+
],
|
|
20
|
+
"bin": {
|
|
21
|
+
"rendshot": "./dist/index.js"
|
|
22
|
+
},
|
|
23
|
+
"dependencies": {
|
|
24
|
+
"commander": "^13",
|
|
25
|
+
"@rendshot/sdk": "0.1.0"
|
|
26
|
+
},
|
|
27
|
+
"devDependencies": {
|
|
28
|
+
"tsx": "^4",
|
|
29
|
+
"vitest": "^3"
|
|
30
|
+
},
|
|
31
|
+
"scripts": {
|
|
32
|
+
"build": "tsc",
|
|
33
|
+
"dev": "tsx watch src/index.ts",
|
|
34
|
+
"test": "vitest run --passWithNoTests",
|
|
35
|
+
"clean": "rm -rf dist"
|
|
36
|
+
}
|
|
37
|
+
}
|