getrelay 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/LICENSE +21 -0
- package/README.md +40 -0
- package/bin/relay.js +362 -0
- package/design-md/airbnb/DESIGN.md +545 -0
- package/design-md/airbnb/README.md +5 -0
- package/design-md/airtable/DESIGN.md +554 -0
- package/design-md/airtable/README.md +5 -0
- package/design-md/apple/DESIGN.md +562 -0
- package/design-md/apple/README.md +5 -0
- package/design-md/binance/DESIGN.md +634 -0
- package/design-md/binance/README.md +5 -0
- package/design-md/bmw/DESIGN.md +544 -0
- package/design-md/bmw/README.md +5 -0
- package/design-md/bmw-m/DESIGN.md +503 -0
- package/design-md/bmw-m/README.md +5 -0
- package/design-md/bugatti/DESIGN.md +454 -0
- package/design-md/bugatti/README.md +5 -0
- package/design-md/cal/DESIGN.md +542 -0
- package/design-md/cal/README.md +5 -0
- package/design-md/claude/DESIGN.md +589 -0
- package/design-md/claude/README.md +5 -0
- package/design-md/clay/DESIGN.md +541 -0
- package/design-md/clay/README.md +5 -0
- package/design-md/clickhouse/DESIGN.md +544 -0
- package/design-md/clickhouse/README.md +5 -0
- package/design-md/cohere/DESIGN.md +451 -0
- package/design-md/cohere/README.md +5 -0
- package/design-md/coinbase/DESIGN.md +570 -0
- package/design-md/coinbase/README.md +5 -0
- package/design-md/composio/DESIGN.md +506 -0
- package/design-md/composio/README.md +5 -0
- package/design-md/cursor/DESIGN.md +537 -0
- package/design-md/cursor/README.md +5 -0
- package/design-md/elevenlabs/DESIGN.md +504 -0
- package/design-md/elevenlabs/README.md +5 -0
- package/design-md/expo/DESIGN.md +526 -0
- package/design-md/expo/README.md +5 -0
- package/design-md/ferrari/DESIGN.md +531 -0
- package/design-md/ferrari/README.md +5 -0
- package/design-md/figma/DESIGN.md +578 -0
- package/design-md/figma/README.md +5 -0
- package/design-md/framer/DESIGN.md +544 -0
- package/design-md/framer/README.md +5 -0
- package/design-md/hashicorp/DESIGN.md +575 -0
- package/design-md/hashicorp/README.md +5 -0
- package/design-md/ibm/DESIGN.md +550 -0
- package/design-md/ibm/README.md +5 -0
- package/design-md/intercom/DESIGN.md +546 -0
- package/design-md/intercom/README.md +5 -0
- package/design-md/kraken/DESIGN.md +125 -0
- package/design-md/kraken/README.md +5 -0
- package/design-md/lamborghini/DESIGN.md +288 -0
- package/design-md/lamborghini/README.md +5 -0
- package/design-md/linear.app/DESIGN.md +548 -0
- package/design-md/linear.app/README.md +5 -0
- package/design-md/lovable/DESIGN.md +298 -0
- package/design-md/lovable/README.md +5 -0
- package/design-md/mastercard/DESIGN.md +365 -0
- package/design-md/mastercard/README.md +5 -0
- package/design-md/meta/DESIGN.md +683 -0
- package/design-md/meta/README.md +5 -0
- package/design-md/minimax/DESIGN.md +746 -0
- package/design-md/minimax/README.md +5 -0
- package/design-md/mintlify/DESIGN.md +852 -0
- package/design-md/mintlify/README.md +5 -0
- package/design-md/miro/DESIGN.md +825 -0
- package/design-md/miro/README.md +5 -0
- package/design-md/mistral.ai/DESIGN.md +773 -0
- package/design-md/mistral.ai/README.md +5 -0
- package/design-md/mongodb/DESIGN.md +767 -0
- package/design-md/mongodb/README.md +5 -0
- package/design-md/nike/DESIGN.md +575 -0
- package/design-md/nike/README.md +5 -0
- package/design-md/notion/DESIGN.md +821 -0
- package/design-md/notion/README.md +5 -0
- package/design-md/nvidia/DESIGN.md +640 -0
- package/design-md/nvidia/README.md +5 -0
- package/design-md/ollama/DESIGN.md +539 -0
- package/design-md/ollama/README.md +5 -0
- package/design-md/opencode.ai/DESIGN.md +521 -0
- package/design-md/opencode.ai/README.md +5 -0
- package/design-md/pinterest/DESIGN.md +597 -0
- package/design-md/pinterest/README.md +5 -0
- package/design-md/playstation/DESIGN.md +661 -0
- package/design-md/playstation/README.md +5 -0
- package/design-md/posthog/DESIGN.md +690 -0
- package/design-md/posthog/README.md +5 -0
- package/design-md/raycast/DESIGN.md +669 -0
- package/design-md/raycast/README.md +5 -0
- package/design-md/renault/DESIGN.md +589 -0
- package/design-md/renault/README.md +5 -0
- package/design-md/replicate/DESIGN.md +616 -0
- package/design-md/replicate/README.md +5 -0
- package/design-md/resend/DESIGN.md +585 -0
- package/design-md/resend/README.md +5 -0
- package/design-md/revolut/DESIGN.md +636 -0
- package/design-md/revolut/README.md +5 -0
- package/design-md/runwayml/DESIGN.md +244 -0
- package/design-md/runwayml/README.md +5 -0
- package/design-md/sanity/DESIGN.md +357 -0
- package/design-md/sanity/README.md +5 -0
- package/design-md/sentry/DESIGN.md +551 -0
- package/design-md/sentry/README.md +5 -0
- package/design-md/shopify/DESIGN.md +516 -0
- package/design-md/shopify/README.md +5 -0
- package/design-md/slack/DESIGN.md +482 -0
- package/design-md/spacex/DESIGN.md +363 -0
- package/design-md/spacex/README.md +5 -0
- package/design-md/spotify/DESIGN.md +246 -0
- package/design-md/spotify/README.md +5 -0
- package/design-md/starbucks/DESIGN.md +580 -0
- package/design-md/starbucks/README.md +5 -0
- package/design-md/stripe/DESIGN.md +487 -0
- package/design-md/stripe/README.md +5 -0
- package/design-md/supabase/DESIGN.md +462 -0
- package/design-md/supabase/README.md +5 -0
- package/design-md/superhuman/DESIGN.md +448 -0
- package/design-md/superhuman/README.md +5 -0
- package/design-md/tesla/DESIGN.md +286 -0
- package/design-md/tesla/README.md +5 -0
- package/design-md/theverge/DESIGN.md +339 -0
- package/design-md/theverge/README.md +5 -0
- package/design-md/together.ai/DESIGN.md +633 -0
- package/design-md/together.ai/README.md +5 -0
- package/design-md/uber/DESIGN.md +636 -0
- package/design-md/uber/README.md +5 -0
- package/design-md/vercel/DESIGN.md +736 -0
- package/design-md/vercel/README.md +5 -0
- package/design-md/vodafone/DESIGN.md +538 -0
- package/design-md/vodafone/README.md +5 -0
- package/design-md/voltagent/DESIGN.md +521 -0
- package/design-md/voltagent/README.md +5 -0
- package/design-md/warp/DESIGN.md +526 -0
- package/design-md/warp/README.md +5 -0
- package/design-md/webflow/DESIGN.md +588 -0
- package/design-md/webflow/README.md +5 -0
- package/design-md/wired/DESIGN.md +497 -0
- package/design-md/wired/README.md +5 -0
- package/design-md/wise/DESIGN.md +544 -0
- package/design-md/wise/README.md +5 -0
- package/design-md/x.ai/DESIGN.md +465 -0
- package/design-md/x.ai/README.md +5 -0
- package/design-md/zapier/DESIGN.md +537 -0
- package/design-md/zapier/README.md +5 -0
- package/package.json +31 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 VoltAgent
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# RelayDesgins
|
|
2
|
+
|
|
3
|
+
RelayDesgins runs through `npx getrelay@latest`.
|
|
4
|
+
|
|
5
|
+
It lets users pick a website style from the bundled collection and creates `Relay.md` in the project where the command runs.
|
|
6
|
+
|
|
7
|
+
## Use
|
|
8
|
+
|
|
9
|
+
Local checkout:
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
node .\RelayDesgins\bin\relay.js
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
Public command:
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
npx getrelay@latest
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
Relay displays the website list, lets you choose one, and creates:
|
|
22
|
+
|
|
23
|
+
```text
|
|
24
|
+
Relay.md
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
Then tell your AI coding agent:
|
|
28
|
+
|
|
29
|
+
```text
|
|
30
|
+
Use Relay.md as the design source for this page.
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## Commands
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
npx getrelay@latest
|
|
37
|
+
npx getrelay@latest list
|
|
38
|
+
npx getrelay@latest vercel
|
|
39
|
+
npx getrelay@latest apple --out docs/Relay.md
|
|
40
|
+
```
|
package/bin/relay.js
ADDED
|
@@ -0,0 +1,362 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
"use strict";
|
|
4
|
+
|
|
5
|
+
const fs = require("node:fs/promises");
|
|
6
|
+
const fsSync = require("node:fs");
|
|
7
|
+
const path = require("node:path");
|
|
8
|
+
const process = require("node:process");
|
|
9
|
+
const readline = require("node:readline/promises");
|
|
10
|
+
const readlineSync = require("node:readline");
|
|
11
|
+
|
|
12
|
+
const PACKAGE_ROOT = path.resolve(__dirname, "..");
|
|
13
|
+
const DESIGN_ROOT = path.join(PACKAGE_ROOT, "design-md");
|
|
14
|
+
const DEFAULT_OUTPUT_FILE = "Relay.md";
|
|
15
|
+
const MENU_SIZE = 16;
|
|
16
|
+
const color = {
|
|
17
|
+
reset: "\x1b[0m",
|
|
18
|
+
cyan: "\x1b[36m",
|
|
19
|
+
green: "\x1b[32m",
|
|
20
|
+
gray: "\x1b[90m",
|
|
21
|
+
inverse: "\x1b[7m",
|
|
22
|
+
bold: "\x1b[1m",
|
|
23
|
+
clearLine: "\x1b[2K",
|
|
24
|
+
cursorUp: (count) => `\x1b[${count}A`,
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
const helpText = `Relay
|
|
28
|
+
|
|
29
|
+
Copy a website-inspired design file into the current project as Relay.md.
|
|
30
|
+
|
|
31
|
+
Usage:
|
|
32
|
+
npx getrelay@latest Choose a layout interactively
|
|
33
|
+
npx getrelay@latest <layout> Create Relay.md from a layout slug
|
|
34
|
+
npx getrelay@latest list Show available layouts
|
|
35
|
+
|
|
36
|
+
Options:
|
|
37
|
+
-o, --out <file> Output file path. Default: Relay.md
|
|
38
|
+
-f, --force Overwrite the output file if it already exists
|
|
39
|
+
-h, --help Show help
|
|
40
|
+
|
|
41
|
+
Examples:
|
|
42
|
+
npx getrelay@latest
|
|
43
|
+
npx getrelay@latest vercel
|
|
44
|
+
npx getrelay@latest apple --out docs/Relay.md
|
|
45
|
+
npx getrelay@latest list
|
|
46
|
+
`;
|
|
47
|
+
|
|
48
|
+
function parseArgs(argv) {
|
|
49
|
+
const options = {
|
|
50
|
+
command: null,
|
|
51
|
+
outFile: DEFAULT_OUTPUT_FILE,
|
|
52
|
+
force: false,
|
|
53
|
+
help: false,
|
|
54
|
+
list: false,
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
for (let index = 0; index < argv.length; index += 1) {
|
|
58
|
+
const arg = argv[index];
|
|
59
|
+
|
|
60
|
+
if (arg === "-h" || arg === "--help") {
|
|
61
|
+
options.help = true;
|
|
62
|
+
continue;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
if (arg === "-f" || arg === "--force") {
|
|
66
|
+
options.force = true;
|
|
67
|
+
continue;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
if (arg === "-o" || arg === "--out") {
|
|
71
|
+
const value = argv[index + 1];
|
|
72
|
+
if (!value || value.startsWith("-")) {
|
|
73
|
+
throw new Error("Missing value for --out.");
|
|
74
|
+
}
|
|
75
|
+
options.outFile = value;
|
|
76
|
+
index += 1;
|
|
77
|
+
continue;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
if (arg.startsWith("--out=")) {
|
|
81
|
+
const value = arg.slice("--out=".length);
|
|
82
|
+
if (!value) {
|
|
83
|
+
throw new Error("Missing value for --out.");
|
|
84
|
+
}
|
|
85
|
+
options.outFile = value;
|
|
86
|
+
continue;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
if (arg.startsWith("-")) {
|
|
90
|
+
throw new Error(`Unknown option: ${arg}`);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
if (options.command) {
|
|
94
|
+
throw new Error(`Unexpected argument: ${arg}`);
|
|
95
|
+
}
|
|
96
|
+
options.command = arg;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
if (options.command === "help") {
|
|
100
|
+
options.help = true;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
if (options.command === "list" || options.command === "layouts") {
|
|
104
|
+
options.list = true;
|
|
105
|
+
options.command = null;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
if (options.outFile.trim() === "") {
|
|
109
|
+
throw new Error("Output file path cannot be empty.");
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
return options;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
async function loadLayouts() {
|
|
116
|
+
const entries = await fs.readdir(DESIGN_ROOT, { withFileTypes: true });
|
|
117
|
+
const layouts = [];
|
|
118
|
+
|
|
119
|
+
for (const entry of entries) {
|
|
120
|
+
if (!entry.isDirectory()) {
|
|
121
|
+
continue;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
const slug = entry.name;
|
|
125
|
+
const designPath = path.join(DESIGN_ROOT, slug, "DESIGN.md");
|
|
126
|
+
|
|
127
|
+
if (!fsSync.existsSync(designPath)) {
|
|
128
|
+
continue;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
const content = await fs.readFile(designPath, "utf8");
|
|
132
|
+
layouts.push({
|
|
133
|
+
slug,
|
|
134
|
+
name: extractFrontmatterValue(content, "name") || toTitle(slug),
|
|
135
|
+
description: extractFrontmatterValue(content, "description") || "",
|
|
136
|
+
designPath,
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
return layouts.sort((left, right) => left.name.localeCompare(right.name));
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
function extractFrontmatterValue(content, key) {
|
|
144
|
+
const frontmatterEnd = content.indexOf("\n---", 3);
|
|
145
|
+
const frontmatter = frontmatterEnd === -1 ? content : content.slice(0, frontmatterEnd);
|
|
146
|
+
const pattern = new RegExp(`^${escapeRegExp(key)}:\\s*(.+)$`, "im");
|
|
147
|
+
const match = frontmatter.match(pattern);
|
|
148
|
+
|
|
149
|
+
if (!match) {
|
|
150
|
+
return "";
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
return match[1].trim().replace(/^["']|["']$/g, "");
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
function escapeRegExp(value) {
|
|
157
|
+
return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
function toTitle(slug) {
|
|
161
|
+
return slug
|
|
162
|
+
.split(/[-.]/g)
|
|
163
|
+
.filter(Boolean)
|
|
164
|
+
.map((part) => part.charAt(0).toUpperCase() + part.slice(1))
|
|
165
|
+
.join(" ");
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
function printLayouts(layouts) {
|
|
169
|
+
for (const layout of layouts) {
|
|
170
|
+
console.log(`${color.gray}${layout.slug.padEnd(16)}${color.reset} ${color.cyan}${layout.name}${color.reset}`);
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
async function chooseLayout(layouts) {
|
|
175
|
+
if (!process.stdin.isTTY) {
|
|
176
|
+
throw new Error("No layout was provided. Run `npx getrelay@latest list`, then pass a layout slug like `npx getrelay@latest vercel`.");
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
return chooseLayoutWithKeyboard(layouts);
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
function findLayout(layouts, value) {
|
|
183
|
+
const normalized = value.trim().toLowerCase();
|
|
184
|
+
|
|
185
|
+
if (!normalized) {
|
|
186
|
+
return null;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
const number = Number.parseInt(normalized, 10);
|
|
190
|
+
if (String(number) === normalized && number >= 1 && number <= layouts.length) {
|
|
191
|
+
return layouts[number - 1];
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
return layouts.find((layout) => {
|
|
195
|
+
return layout.slug.toLowerCase() === normalized || layout.name.toLowerCase() === normalized;
|
|
196
|
+
});
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
async function confirmOverwrite(targetPath) {
|
|
200
|
+
if (!process.stdin.isTTY) {
|
|
201
|
+
return false;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
const rl = readline.createInterface({
|
|
205
|
+
input: process.stdin,
|
|
206
|
+
output: process.stdout,
|
|
207
|
+
});
|
|
208
|
+
|
|
209
|
+
try {
|
|
210
|
+
const answer = await rl.question(`${targetPath} already exists. Overwrite it? [y/N] `);
|
|
211
|
+
return answer.trim().toLowerCase() === "y" || answer.trim().toLowerCase() === "yes";
|
|
212
|
+
} finally {
|
|
213
|
+
rl.close();
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
async function copyLayout(layout, targetPath, force) {
|
|
218
|
+
const outputRoot = process.env.RELAY_OUTPUT_CWD || process.cwd();
|
|
219
|
+
const resolvedTarget = path.resolve(outputRoot, targetPath);
|
|
220
|
+
|
|
221
|
+
if (fsSync.existsSync(resolvedTarget) && !force) {
|
|
222
|
+
const overwrite = await confirmOverwrite(resolvedTarget);
|
|
223
|
+
if (!overwrite) {
|
|
224
|
+
return {
|
|
225
|
+
path: resolvedTarget,
|
|
226
|
+
skipped: true,
|
|
227
|
+
};
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
await fs.mkdir(path.dirname(resolvedTarget), { recursive: true });
|
|
232
|
+
await fs.copyFile(layout.designPath, resolvedTarget);
|
|
233
|
+
|
|
234
|
+
return {
|
|
235
|
+
path: resolvedTarget,
|
|
236
|
+
skipped: false,
|
|
237
|
+
};
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
function chooseLayoutWithKeyboard(layouts) {
|
|
241
|
+
return new Promise((resolve, reject) => {
|
|
242
|
+
let selectedIndex = 0;
|
|
243
|
+
let renderedLines = 0;
|
|
244
|
+
|
|
245
|
+
const render = () => {
|
|
246
|
+
if (renderedLines > 0) {
|
|
247
|
+
process.stdout.write(color.cursorUp(renderedLines));
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
const halfWindow = Math.floor(MENU_SIZE / 2);
|
|
251
|
+
const maxStart = Math.max(layouts.length - MENU_SIZE, 0);
|
|
252
|
+
const start = Math.min(Math.max(selectedIndex - halfWindow, 0), maxStart);
|
|
253
|
+
const visible = layouts.slice(start, start + MENU_SIZE);
|
|
254
|
+
const lines = [];
|
|
255
|
+
|
|
256
|
+
lines.push(`${color.bold}Choose the website layout to copy into Relay.md${color.reset}`);
|
|
257
|
+
lines.push(`${color.gray}Use Up/Down, Enter to select, Ctrl+C to quit.${color.reset}`);
|
|
258
|
+
lines.push("");
|
|
259
|
+
|
|
260
|
+
for (let offset = 0; offset < visible.length; offset += 1) {
|
|
261
|
+
const layout = visible[offset];
|
|
262
|
+
const index = start + offset;
|
|
263
|
+
const marker = index === selectedIndex ? ">" : " ";
|
|
264
|
+
const plainRow = `${marker} ${layout.name.padEnd(18)} ${layout.slug}`;
|
|
265
|
+
const colorRow = `${marker} ${color.cyan}${layout.name.padEnd(18)}${color.reset} ${color.gray}${layout.slug}${color.reset}`;
|
|
266
|
+
lines.push(index === selectedIndex ? `${color.inverse}${plainRow}${color.reset}` : colorRow);
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
lines.push("");
|
|
270
|
+
lines.push(`${color.gray}Enter selects the highlighted website.${color.reset}`);
|
|
271
|
+
|
|
272
|
+
for (const line of lines) {
|
|
273
|
+
process.stdout.write(`${color.clearLine}${line}\n`);
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
renderedLines = lines.length;
|
|
277
|
+
};
|
|
278
|
+
|
|
279
|
+
const cleanup = () => {
|
|
280
|
+
process.stdin.off("keypress", onKeypress);
|
|
281
|
+
if (process.stdin.isRaw) {
|
|
282
|
+
process.stdin.setRawMode(false);
|
|
283
|
+
}
|
|
284
|
+
process.stdin.pause();
|
|
285
|
+
};
|
|
286
|
+
|
|
287
|
+
const onKeypress = (_text, key) => {
|
|
288
|
+
if (key.name === "c" && key.ctrl) {
|
|
289
|
+
cleanup();
|
|
290
|
+
process.stdout.write("\n");
|
|
291
|
+
reject(new Error("Aborted."));
|
|
292
|
+
return;
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
if (key.name === "up") {
|
|
296
|
+
selectedIndex = selectedIndex === 0 ? layouts.length - 1 : selectedIndex - 1;
|
|
297
|
+
render();
|
|
298
|
+
return;
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
if (key.name === "down") {
|
|
302
|
+
selectedIndex = selectedIndex === layouts.length - 1 ? 0 : selectedIndex + 1;
|
|
303
|
+
render();
|
|
304
|
+
return;
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
if (key.name === "return" || key.name === "enter") {
|
|
308
|
+
const layout = layouts[selectedIndex];
|
|
309
|
+
cleanup();
|
|
310
|
+
process.stdout.write("\n");
|
|
311
|
+
resolve(layout);
|
|
312
|
+
}
|
|
313
|
+
};
|
|
314
|
+
|
|
315
|
+
readlineSync.emitKeypressEvents(process.stdin);
|
|
316
|
+
process.stdin.setRawMode(true);
|
|
317
|
+
process.stdin.resume();
|
|
318
|
+
process.stdin.on("keypress", onKeypress);
|
|
319
|
+
render();
|
|
320
|
+
});
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
async function main() {
|
|
324
|
+
const options = parseArgs(process.argv.slice(2));
|
|
325
|
+
|
|
326
|
+
if (options.help) {
|
|
327
|
+
console.log(helpText);
|
|
328
|
+
return;
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
const layouts = await loadLayouts();
|
|
332
|
+
if (layouts.length === 0) {
|
|
333
|
+
throw new Error(`No layouts were found in ${DESIGN_ROOT}.`);
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
if (options.list) {
|
|
337
|
+
printLayouts(layouts);
|
|
338
|
+
return;
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
const layout = options.command ? findLayout(layouts, options.command) : await chooseLayout(layouts);
|
|
342
|
+
if (!layout) {
|
|
343
|
+
throw new Error(`Unknown layout: ${options.command}. Run \`relay list\` to see available layouts.`);
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
const result = await copyLayout(layout, options.outFile, options.force);
|
|
347
|
+
const relativeTargetPath = path.relative(process.cwd(), result.path);
|
|
348
|
+
|
|
349
|
+
if (result.skipped) {
|
|
350
|
+
console.log(`Skipped ${relativeTargetPath}. Existing file was left unchanged.`);
|
|
351
|
+
console.log("Run `npx getrelay@latest --force` to overwrite it, or use `npx getrelay@latest --out <file>` to write somewhere else.");
|
|
352
|
+
return;
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
console.log(`Created ${relativeTargetPath} from ${layout.name}.`);
|
|
356
|
+
console.log("Tell your AI coding agent to use Relay.md as the design source for your page.");
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
main().catch((error) => {
|
|
360
|
+
console.error(`Relay error: ${error.message}`);
|
|
361
|
+
process.exitCode = 1;
|
|
362
|
+
});
|