rewampui 0.1.0 → 0.1.1

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/bin/rewampui.js CHANGED
@@ -36,5 +36,17 @@ Examples:
36
36
 
37
37
  main().catch((err) => {
38
38
  console.error(`✖ ${err.message}`);
39
+ // Node's fetch() wraps the real reason (DNS failure, TLS interception,
40
+ // proxy refusal, etc.) in `.cause` and reports only the generic "fetch
41
+ // failed" as the top-level message — surface it so this is debuggable.
42
+ if (err.cause) {
43
+ console.error(` cause: ${err.cause.message || err.cause}`);
44
+ }
45
+ if (/fetch/i.test(err.message)) {
46
+ const proxyVars = ['HTTP_PROXY', 'HTTPS_PROXY', 'http_proxy', 'https_proxy', 'NO_PROXY', 'no_proxy', 'NODE_EXTRA_CA_CERTS'];
47
+ const setProxyVars = proxyVars.filter((k) => process.env[k]);
48
+ console.error(` node: ${process.version}`);
49
+ console.error(` proxy env vars set: ${setProxyVars.length ? setProxyVars.map((k) => `${k}=${process.env[k]}`).join(', ') : 'none'}`);
50
+ }
39
51
  process.exit(1);
40
52
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rewampui",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "CLI to add Rewamp UI components' source code directly into your project.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -24,7 +24,12 @@ export async function fetchRegistryItem(name, config) {
24
24
  }
25
25
 
26
26
  const url = `${config.registryUrl.replace(/\/$/, '')}/${name}.json`;
27
- const res = await fetch(url);
27
+ let res;
28
+ try {
29
+ res = await fetch(url);
30
+ } catch (err) {
31
+ throw new Error(`Network request failed fetching ${url}: ${err.message}`, { cause: err.cause || err });
32
+ }
28
33
  if (!res.ok) {
29
34
  throw new Error(`Component "${name}" not found in registry (${url})`);
30
35
  }
@@ -50,7 +55,12 @@ export async function readSourceFile(source, config) {
50
55
  // folder — fall back to fetching the file straight from the public GitHub repo.
51
56
  const base = config?.repoRawUrl || config?.registryUrl?.replace(/\/registry\/?$/, '');
52
57
  const url = base ? `${base.replace(/\/$/, '')}/${source}` : source;
53
- const res = await fetch(url);
58
+ let res;
59
+ try {
60
+ res = await fetch(url);
61
+ } catch (err) {
62
+ throw new Error(`Network request failed fetching ${url}: ${err.message}`, { cause: err.cause || err });
63
+ }
54
64
  if (!res.ok) throw new Error(`Could not fetch source file: ${url}`);
55
65
  return res.text();
56
66
  }