everything-dev 0.0.4 → 0.0.6

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "everything-dev",
3
- "version": "0.0.4",
3
+ "version": "0.0.6",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "bos": "./src/cli.ts"
@@ -23,6 +23,7 @@
23
23
  "degit": "^2.8.4",
24
24
  "effect": "^3.19.14",
25
25
  "every-plugin": "0.8.8",
26
+ "everything-dev": "^0.0.4",
26
27
  "execa": "^9.6.1",
27
28
  "gradient-string": "^3.0.0",
28
29
  "ink": "^5.2.1",
package/src/cli.ts CHANGED
@@ -1,43 +1,73 @@
1
1
  #!/usr/bin/env bun
2
2
  import { program } from "commander";
3
3
  import { createPluginRuntime } from "every-plugin";
4
- import { getConfigDir, getConfigPath, getPackages, getTitle, loadConfig } from "./config";
4
+ import { getConfigDir, getConfigPath, getPackages, getTitle, loadConfig, type BosConfig } from "./config";
5
5
  import BosPlugin from "./plugin";
6
6
  import { printBanner } from "./utils/banner";
7
7
  import { colors, frames, gradients, icons } from "./utils/theme";
8
8
 
9
- async function main() {
10
- let config: ReturnType<typeof loadConfig>;
9
+ function getHelpHeader(config: BosConfig | null, configPath: string): string {
10
+ const host = config?.app.host;
11
+ const lines: string[] = [];
12
+
13
+ lines.push("");
14
+ lines.push(colors.cyan(frames.top(52)));
15
+ lines.push(` ${icons.config} ${gradients.cyber("BOS CLI")} ${colors.dim("v1.0.0")}`);
16
+ lines.push(colors.cyan(frames.bottom(52)));
17
+ lines.push("");
18
+
19
+ if (config) {
20
+ lines.push(` ${colors.dim("Account")} ${colors.cyan(config.account)}`);
21
+ lines.push(` ${colors.dim("Gateway")} ${colors.white(config.gateway?.production ?? "not configured")}`);
22
+ lines.push(` ${colors.dim("Config ")} ${colors.dim(configPath)}`);
23
+ if (host?.description) {
24
+ lines.push(` ${colors.dim("About ")} ${colors.white(host.description)}`);
25
+ }
26
+ } else {
27
+ lines.push(` ${colors.dim("No project config found")}`);
28
+ lines.push(` ${colors.dim("Run")} ${colors.cyan("bos create project <name>")} ${colors.dim("to get started")}`);
29
+ }
30
+
31
+ lines.push("");
32
+ lines.push(colors.cyan(frames.top(52)));
33
+ lines.push("");
34
+
35
+ return lines.join("\n");
36
+ }
11
37
 
12
- try {
13
- config = loadConfig();
14
- } catch {
38
+ function requireConfig(config: BosConfig | null): asserts config is BosConfig {
39
+ if (!config) {
15
40
  console.error(colors.error(`${icons.err} Could not find bos.config.json`));
16
41
  console.log(colors.dim(" Run 'bos create project <name>' to create a new project"));
17
42
  process.exit(1);
18
43
  }
44
+ }
19
45
 
20
- const envPath = `${getConfigDir()}/.env.bos`;
21
- const envFile = Bun.file(envPath);
22
- if (await envFile.exists()) {
23
- const content = await envFile.text();
24
- for (const line of content.split("\n")) {
25
- const trimmed = line.trim();
26
- if (!trimmed || trimmed.startsWith("#")) continue;
27
- const eqIndex = trimmed.indexOf("=");
28
- if (eqIndex === -1) continue;
29
- const key = trimmed.slice(0, eqIndex).trim();
30
- const value = trimmed.slice(eqIndex + 1).trim();
31
- if (key && !process.env[key]) {
32
- process.env[key] = value;
46
+ async function main() {
47
+ const config = loadConfig();
48
+ const configPath = config ? getConfigPath() : process.cwd();
49
+ const packages = config ? getPackages() : [];
50
+ const title = config ? getTitle() : "BOS CLI";
51
+
52
+ if (config) {
53
+ const envPath = `${getConfigDir()}/.env.bos`;
54
+ const envFile = Bun.file(envPath);
55
+ if (await envFile.exists()) {
56
+ const content = await envFile.text();
57
+ for (const line of content.split("\n")) {
58
+ const trimmed = line.trim();
59
+ if (!trimmed || trimmed.startsWith("#")) continue;
60
+ const eqIndex = trimmed.indexOf("=");
61
+ if (eqIndex === -1) continue;
62
+ const key = trimmed.slice(0, eqIndex).trim();
63
+ const value = trimmed.slice(eqIndex + 1).trim();
64
+ if (key && !process.env[key]) {
65
+ process.env[key] = value;
66
+ }
33
67
  }
34
68
  }
35
69
  }
36
70
 
37
- const packages = getPackages();
38
- const title = getTitle();
39
- const configPath = getConfigPath();
40
-
41
71
  printBanner(title);
42
72
 
43
73
  const runtime = createPluginRuntime({
@@ -59,32 +89,10 @@ async function main() {
59
89
 
60
90
  const client = result.createClient();
61
91
 
62
- function getHelpHeader(): string {
63
- const host = config.app.host;
64
- const lines: string[] = [];
65
-
66
- lines.push("");
67
- lines.push(colors.cyan(frames.top(52)));
68
- lines.push(` ${icons.config} ${gradients.cyber("BOS CLI")} ${colors.dim("v1.0.0")}`);
69
- lines.push(colors.cyan(frames.bottom(52)));
70
- lines.push("");
71
- lines.push(` ${colors.dim("Account")} ${colors.cyan(config.account)}`);
72
- lines.push(` ${colors.dim("Gateway")} ${colors.white(config.gateway.production)}`);
73
- lines.push(` ${colors.dim("Config ")} ${colors.dim(configPath)}`);
74
- if (host.description) {
75
- lines.push(` ${colors.dim("About ")} ${colors.white(host.description)}`);
76
- }
77
- lines.push("");
78
- lines.push(colors.cyan(frames.top(52)));
79
- lines.push("");
80
-
81
- return lines.join("\n");
82
- }
83
-
84
92
  program
85
93
  .name("bos")
86
94
  .version("1.0.0")
87
- .addHelpText("before", getHelpHeader());
95
+ .addHelpText("before", getHelpHeader(config, configPath));
88
96
 
89
97
  program
90
98
  .command("info")
@@ -263,7 +271,7 @@ Zephyr Configuration:
263
271
  .action(async (options) => {
264
272
  console.log();
265
273
  console.log(` ${icons.pkg} Publishing to Near Social...`);
266
- console.log(colors.dim(` Account: ${config.account}`));
274
+ console.log(colors.dim(` Account: ${config?.account}`));
267
275
  console.log(colors.dim(` Network: ${options.network}`));
268
276
 
269
277
  if (options.dryRun) {
@@ -486,7 +494,7 @@ Zephyr Configuration:
486
494
  program
487
495
  .command("register")
488
496
  .description("Register a new tenant on the gateway")
489
- .argument("<name>", `Account name (will create <name>.${config.account})`)
497
+ .argument("<name>", `Account name (will create <name>.${config?.account})`)
490
498
  .option("--network <network>", "Network: mainnet | testnet", "mainnet")
491
499
  .action(async (name: string, options: { network: string }) => {
492
500
  console.log();
@@ -1,5 +1,6 @@
1
1
  import { Box, render, Text, useApp, useInput } from "ink";
2
2
  import { useEffect, useState } from "react";
3
+ import { linkify } from "../utils/linkify";
3
4
  import { colors, divider, gradients, icons, frames } from "../utils/theme";
4
5
 
5
6
  export type ProcessStatus = "pending" | "starting" | "ready" | "error";
@@ -81,7 +82,7 @@ function LogLine({ entry }: { entry: LogEntry }) {
81
82
  return (
82
83
  <Box>
83
84
  <Text color={color}>[{entry.source}]</Text>
84
- <Text color={entry.isError ? "#ff3366" : undefined}> {entry.line}</Text>
85
+ <Text color={entry.isError ? "#ff3366" : undefined}> {linkify(entry.line)}</Text>
85
86
  </Box>
86
87
  );
87
88
  }
@@ -1,3 +1,4 @@
1
+ import { linkify } from "../utils/linkify";
1
2
  import { colors, icons } from "../utils/theme";
2
3
  import type { ProcessState, ProcessStatus } from "./dev-view";
3
4
 
@@ -93,7 +94,7 @@ export function renderStreamingView(
93
94
  const addLog = (source: string, line: string, isError = false) => {
94
95
  const color = getServiceColor(source);
95
96
  const logColor = isError ? colors.error : colors.dim;
96
- write(`${colors.dim(`[${getTimestamp()}]`)} ${color(`[${source.toUpperCase()}]`)} ${colors.dim("│")} ${logColor(line)}`);
97
+ write(`${colors.dim(`[${getTimestamp()}]`)} ${color(`[${source.toUpperCase()}]`)} ${colors.dim("│")} ${logColor(linkify(line))}`);
97
98
  };
98
99
 
99
100
  const unmount = () => {
@@ -264,6 +264,12 @@ export const spawnRemoteHost = (
264
264
  return yield* Effect.fail(new Error("HOST_REMOTE_URL not provided for remote host"));
265
265
  }
266
266
 
267
+ if (config.env) {
268
+ for (const [key, value] of Object.entries(config.env)) {
269
+ process.env[key] = value;
270
+ }
271
+ }
272
+
267
273
  callbacks.onStatus(config.name, "starting");
268
274
 
269
275
  const configDir = getConfigDir();
package/src/plugin.ts CHANGED
@@ -454,6 +454,10 @@ export default createPlugin({
454
454
  if (input.type === "project" && input.name) {
455
455
  const newConfig = {
456
456
  account: `${input.name}.near`,
457
+ gateway: {
458
+ development: "http://localhost:8787",
459
+ production: `https://gateway.${input.name}.example.com`,
460
+ },
457
461
  create: DEFAULT_TEMPLATES,
458
462
  app: {
459
463
  host: {
@@ -0,0 +1,11 @@
1
+ const URL_REGEX = /https?:\/\/[^\s<>"{}|\\^`[\]]+/g;
2
+
3
+ const OSC_START = "\x1b]8;;";
4
+ const OSC_END = "\x07";
5
+ const OSC_RESET = "\x1b]8;;\x07";
6
+
7
+ export const linkify = (text: string): string => {
8
+ return text.replace(URL_REGEX, (url) => {
9
+ return `${OSC_START}${url}${OSC_END}${url}${OSC_RESET}`;
10
+ });
11
+ };