@delance/builder 0.2.15 → 0.3.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/README.md CHANGED
@@ -12,7 +12,7 @@ A spear to the Python language server built with black magic.
12
12
  ## Usage
13
13
 
14
14
  - API
15
- ```typescript
15
+ ```javascript
16
16
  import run from '@delance/builder';
17
17
  ```
18
18
 
package/dist/cli.js CHANGED
@@ -1,41 +1,41 @@
1
1
  #!/usr/bin/env bun
2
- // @bun
3
2
  import {
4
- delance_builder_default
3
+ __require,
4
+ delance_builder_default
5
5
  } from "./index.js";
6
6
 
7
7
  // cli.ts
8
- import {spawnSync} from "child_process";
8
+ import { spawnSync } from "node:child_process";
9
9
  import debug from "debug";
10
10
 
11
11
  // utils/colors.ts
12
- import {isatty} from "tty";
12
+ import { isatty } from "node:tty";
13
13
  /*! modified from picocolors v1.0.0 | ISC License | github.com/alexeyraspopov/picocolors */
14
14
  var argv = process.argv || [];
15
15
  var { env } = process;
16
16
  var enabled = !(("NO_COLOR" in env) || argv.includes("--no-color")) && (("FORCE_COLOR" in env) || argv.includes("--color") || process.platform === "win32" || isatty(1) && env.TERM !== "dumb" || ("CI" in env));
17
- var formatter = (open, close, replace = open) => enabled ? (input) => {
18
- const string = String(input);
19
- const index = string.indexOf(close, open.length);
20
- return ~index ? open + replaceClose(string, close, replace, index) + close : open + string + close;
21
- } : String;
22
17
  var replaceClose = (string, close, replace, index) => {
23
18
  const start = string.slice(0, Math.max(0, index)) + replace;
24
19
  const end = string.slice(Math.max(0, index + close.length));
25
20
  const nextIndex = end.indexOf(close);
26
21
  return ~nextIndex ? start + replaceClose(end, close, replace, nextIndex) : start + end;
27
22
  };
28
- var bold = formatter("\x1B[1m", "\x1B[22m", "\x1B[22m\x1B[1m");
29
- var dim = formatter("\x1B[2m", "\x1B[22m", "\x1B[22m\x1B[2m");
30
- var underline = formatter("\x1B[4m", "\x1B[24m");
31
- var red = formatter("\x1B[31m", "\x1B[39m");
32
- var green = formatter("\x1B[32m", "\x1B[39m");
33
- var yellow = formatter("\x1B[33m", "\x1B[39m");
34
- var magenta = formatter("\x1B[35m", "\x1B[39m");
35
- var cyan = formatter("\x1B[36m", "\x1B[39m");
36
- var white = formatter("\x1B[37m", "\x1B[39m");
37
- var bgBlack = formatter("\x1B[40m", "\x1B[49m");
38
- var bgBlue = formatter("\x1B[44m", "\x1B[49m");
23
+ var formatter = (open, close, replace = open) => enabled ? (input) => {
24
+ const string = String(input);
25
+ const index = string.indexOf(close, open.length);
26
+ return ~index ? open + replaceClose(string, close, replace, index) + close : open + string + close;
27
+ } : String;
28
+ var bold = /* @__PURE__ */ formatter("\x1B[1m", "\x1B[22m", "\x1B[22m\x1B[1m");
29
+ var dim = /* @__PURE__ */ formatter("\x1B[2m", "\x1B[22m", "\x1B[22m\x1B[2m");
30
+ var underline = /* @__PURE__ */ formatter("\x1B[4m", "\x1B[24m");
31
+ var red = /* @__PURE__ */ formatter("\x1B[31m", "\x1B[39m");
32
+ var green = /* @__PURE__ */ formatter("\x1B[32m", "\x1B[39m");
33
+ var yellow = /* @__PURE__ */ formatter("\x1B[33m", "\x1B[39m");
34
+ var magenta = /* @__PURE__ */ formatter("\x1B[35m", "\x1B[39m");
35
+ var cyan = /* @__PURE__ */ formatter("\x1B[36m", "\x1B[39m");
36
+ var white = /* @__PURE__ */ formatter("\x1B[37m", "\x1B[39m");
37
+ var bgBlack = /* @__PURE__ */ formatter("\x1B[40m", "\x1B[49m");
38
+ var bgBlue = /* @__PURE__ */ formatter("\x1B[44m", "\x1B[49m");
39
39
 
40
40
  // cli.ts
41
41
  function hl(..._arguments) {
@@ -60,7 +60,7 @@ function hl(..._arguments) {
60
60
  return;
61
61
  }
62
62
  if (true) {
63
- if (argument.startsWith('"') && argument.endsWith('"') || argument.startsWith("\'") && argument.endsWith("\'")) {
63
+ if (argument.startsWith('"') && argument.endsWith('"') || argument.startsWith("'") && argument.endsWith("'")) {
64
64
  yield argument[0] + magenta(argument.slice(1, -1)) + argument[0];
65
65
  continue;
66
66
  }
@@ -69,6 +69,28 @@ function hl(..._arguments) {
69
69
  }
70
70
  }()].join(" ")} `);
71
71
  }
72
+ var errorMessage = `
73
+ ${red("Uh-oh")}. ${bold(yellow("@delance/builder"))} CLI requires Bun to run.
74
+ If you were trying to run the language server, use ${bold(magenta("npm i @delance/runtime"))}.
75
+
76
+ • To install Bun:
77
+ ${hl("npm", "i", "-d", "bun", "#", "locally")}
78
+ ${hl("curl", "-fsSL", "https://bun.sh/install", "|", "bash", "#", "globally")}
79
+ • More info: ${underline(cyan("https://bun.sh/docs/installation"))}
80
+
81
+ ${"─".repeat(80)}
82
+ `;
83
+ if (!process.isBun) {
84
+ const { status, error } = spawnSync("bun", ["run", ...process.argv.slice(1)], { stdio: "inherit" });
85
+ if (error) {
86
+ if (error.code === "ENOENT") {
87
+ console.error(errorMessage);
88
+ }
89
+ throw error;
90
+ } else {
91
+ process.exit(status);
92
+ }
93
+ }
72
94
  async function main(argv2) {
73
95
  debug.enable("*,-babel");
74
96
  const cwd = argv2.pop();
@@ -87,29 +109,7 @@ async function main(argv2) {
87
109
  console.groupEnd();
88
110
  }
89
111
  }
90
- var errorMessage = `
91
- ${red("Uh-oh")}. ${bold(yellow("@delance/builder"))} CLI requires Bun to run.
92
- If you were trying to run the language server, use ${bold(magenta("npm i @delance/runtime"))}.
93
-
94
- \u2022 To install Bun:
95
- ${hl("npm", "i", "-d", "bun", "#", "locally")}
96
- ${hl("curl", "-fsSL", "https://bun.sh/install", "|", "bash", "#", "globally")}
97
- \u2022 More info: ${underline(cyan("https://bun.sh/docs/installation"))}
98
-
99
- ${"\u2500".repeat(80)}
100
- `;
101
- if (!process.isBun) {
102
- const { status, error } = spawnSync("bun", ["run", ...process.argv.slice(1)], { stdio: "inherit" });
103
- if (status) {
104
- process.exit(status);
105
- } else {
106
- if (error && error.code === "ENOENT") {
107
- console.error(errorMessage);
108
- }
109
- throw error;
110
- }
111
- }
112
- if (import.meta.main) {
112
+ if (__require.main == __require.module) {
113
113
  await main(process.argv);
114
114
  }
115
115
  export {