@zuplo/cli 6.59.45 → 6.59.48

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.
@@ -1 +1 @@
1
- {"version":3,"file":"worker-output.d.ts","sourceRoot":"","sources":["../../src/common/worker-output.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAiC,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAI1E,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,QA2JpE;AAED,wBAAgB,UAAU,CAAC,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,SAAI,QAEtE;AAKD,wBAAsB,eAAe,CACnC,KAAK,EAAE,QAAQ,EACf,IAAI,EAAE,MAAM,EACZ,SAAS,SAAI,iBAwDd"}
1
+ {"version":3,"file":"worker-output.d.ts","sourceRoot":"","sources":["../../src/common/worker-output.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAiC,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAO1E,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,QA2JpE;AAED,wBAAgB,UAAU,CAAC,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,SAAI,QAEtE;AAKD,wBAAsB,eAAe,CACnC,KAAK,EAAE,QAAQ,EACf,IAAI,EAAE,MAAM,EACZ,SAAS,SAAI,iBAwDd"}
@@ -1,5 +1,8 @@
1
1
  import { LogFormatter } from "@zuplo/core/cli";
2
- const logFormatter = new LogFormatter();
2
+ import { readFile } from "node:fs/promises";
3
+ const logFormatter = new LogFormatter(async (path) => {
4
+ return readFile(path, { encoding: "utf8" });
5
+ });
3
6
  export function handleRuntimeStdio(stdout, stderr) {
4
7
  const classifiers = {
5
8
  isBarf(chunk) {
@@ -1 +1 @@
1
- {"version":3,"file":"worker-output.js","sourceRoot":"","sources":["../../src/common/worker-output.ts"],"names":[],"mappings":"AAGA,OAAO,EAAmB,YAAY,EAAY,MAAM,iBAAiB,CAAC;AAE1E,MAAM,YAAY,GAAG,IAAI,YAAY,EAAE,CAAC;AAExC,MAAM,UAAU,kBAAkB,CAAC,MAAgB,EAAE,MAAgB;IAKnE,MAAM,WAAW,GAAG;QAElB,MAAM,CAAC,KAAa;YAClB,MAAM,6BAA6B,GAAG,KAAK,CAAC,QAAQ,CAClD,kEAAkE,CACnE,CAAC;YACF,MAAM,mCAAmC,GAAG,KAAK,CAAC,QAAQ,CACxD,6BAA6B,CAC9B,CAAC;YAIF,MAAM,gBAAgB,GAAG,8BAA8B,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;YAEpE,OAAO,CACL,6BAA6B;gBAC7B,mCAAmC;gBACnC,gBAAgB,CACjB,CAAC;QACJ,CAAC;QAED,cAAc,CAAC,KAAa;YAC1B,OAAO,KAAK,CAAC,QAAQ,CAAC,uCAAuC,CAAC,CAAC;QACjE,CAAC;QACD,SAAS,CAAC,KAAa;YACrB,OAAO,uBAAuB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAC7C,CAAC;QACD,kBAAkB,CAAC,KAAa;YAC9B,OAAO,mCAAmC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACzD,CAAC;QACD,iBAAiB,CAAC,KAAa;YAC7B,OAAO,KAAK,CAAC,QAAQ,CAAC,mBAAmB,CAAC,CAAC;QAC7C,CAAC;QACD,SAAS,CAAC,KAAa;YACrB,OAAO,KAAK,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC;QACrC,CAAC;KACF,CAAC;IAEF,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,KAAsB,EAAE,EAAE;QAC3C,KAAK,GAAG,KAAK,CAAC,QAAQ,EAAE,CAAC,IAAI,EAAE,CAA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OAAO;gBACT,CAAC;YACH,CAAC;YACD,MAAM,OAAO,CAAC,GAAG,CACf,QAAQ,CAAC,QAAQ,CAAC,GAAG,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE;gBAClC,MAAM,IAAI,GAAG,MAAM,YAAY,CAAC,gBAAgB,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC;gBAChE,OAAO,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,CAAC;YACvB,CAAC,CAAC,CACH,CAAC;QACJ,CAAC;aAAM,CAAC;YACN,OAAO,GAAG,MAAM,YAAY,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;YAEpD,MAAM,IAAI,GAAG,YAAY,CAAC,UAAU,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;YACrD,OAAO,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,CAAC;QACvB,CAAC;IACH,CAAC;IAAC,MAAM,CAAC;QACP,MAAM,IAAI,GAAG,YAAY,CAAC,UAAU,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;QAElD,OAAO,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,CAAC;IACvB,CAAC;AACH,CAAC","sourcesContent":["/* eslint-disable no-console */\n\nimport { Readable } from \"node:stream\";\nimport { ConsoleLogEntry, LogFormatter, LogLevel } from \"@zuplo/core/cli\";\n\nconst logFormatter = new LogFormatter();\n\nexport function handleRuntimeStdio(stdout: Readable, stderr: Readable) {\n // ASSUMPTION: each chunk is a whole message from workerd\n // This may not hold across OSes/architectures, but it seems to work on macOS M-line\n // I'm going with this simple approach to avoid complicating this too early\n // We can iterate on this heuristic in the future if it causes issues\n const classifiers = {\n // Is this chunk a big chonky barf from workerd that we want to hijack to cleanup/ignore?\n isBarf(chunk: string) {\n const containsLlvmSymbolizerWarning = chunk.includes(\n \"Not symbolizing stack traces because $LLVM_SYMBOLIZER is not set\"\n );\n const containsRecursiveIsolateLockWarning = chunk.includes(\n \"took recursive isolate lock\"\n );\n // Matches stack traces from workerd\n // - on unix: groups of 9 hex digits separated by spaces\n // - on windows: groups of 12 hex digits, or a single digit 0, separated by spaces\n const containsHexStack = /stack:( (0|[a-f\\d]{4,})){3,}/.test(chunk);\n\n return (\n containsLlvmSymbolizerWarning ||\n containsRecursiveIsolateLockWarning ||\n containsHexStack\n );\n },\n // Is this chunk an Address In Use error?\n isAddressInUse(chunk: string) {\n return chunk.includes(\"Address already in use; toString() = \");\n },\n isWarning(chunk: string) {\n return /\\.c\\+\\+:\\d+: warning:/.test(chunk);\n },\n isCodeMovedWarning(chunk: string) {\n return /CODE_MOVED for unknown code block/.test(chunk);\n },\n isAccessViolation(chunk: string) {\n return chunk.includes(\"access violation;\");\n },\n isZenoLog(chunk: string) {\n return chunk.startsWith(\"[ZENO]:\");\n },\n };\n\n stdout.on(\"data\", (chunk: Buffer | string) => {\n chunk = chunk.toString().trim();\n\n if (classifiers.isBarf(chunk)) {\n // this is a big chonky barf from workerd that we want to hijack to cleanup/ignore\n\n // CLEANABLE:\n // there are no known cases to cleanup yet\n // but, as they are identified, we will do that here\n\n // IGNORABLE:\n // anything else not handled above is considered ignorable\n // so send it to the debug logs which are discarded unless\n // the user explicitly sets a logLevel indicating they care\n logConsole(\"debug\", chunk);\n }\n\n // known case: warnings are not info, log them as such\n else if (classifiers.isWarning(chunk)) {\n logConsole(\"warn\", chunk);\n } else if (classifiers.isZenoLog(chunk)) {\n // Route to the specified logging level\n const levels = [\"debug\", \"info\", \"warn\", \"error\"];\n const level = levels.find((level) =>\n chunk.includes(`[${level.toUpperCase()}]`)\n );\n // Strip the prefixes for zeno and the zeno logging level\n chunk = chunk.substring(\"[ZENO]:\".length);\n chunk = chunk.substring(`[${level?.toUpperCase()}]`.length);\n if (level) {\n logConsole(level as LogLevel, chunk);\n } else {\n logConsole(\"info\", chunk);\n }\n }\n\n // anything not explicitly handled above should be logged as info (via stdout)\n else {\n logConsole(\"error\", chunk);\n }\n });\n\n stderr.on(\"data\", (chunk: Buffer | string) => {\n chunk = chunk.toString().trim();\n\n if (classifiers.isBarf(chunk)) {\n // this is a big chonky barf from workerd that we want to hijack to cleanup/ignore\n\n // CLEANABLE:\n // known case to cleanup: Address in use errors\n if (classifiers.isAddressInUse(chunk)) {\n const address = chunk.match(\n /Address already in use; toString\\(\\) = (.+)\\n/\n )?.[1];\n\n logConsole(\n \"error\",\n `Address already in use (${address}). Please check that you are not already running a server on this address or specify a different port with --port.`\n );\n\n // Log the original error to the debug logs.\n logConsole(\"debug\", chunk);\n }\n // In the past we have seen Access Violation errors on Windows, which may be caused by an outdated\n // version of the Windows OS or the Microsoft Visual C++ Redistributable.\n // See https://github.com/cloudflare/workers-sdk/issues/6170#issuecomment-2245209918\n else if (classifiers.isAccessViolation(chunk)) {\n let error = \"There was an access violation in the runtime.\";\n if (process.platform === \"win32\") {\n error +=\n \"\\nOn Windows, this may be caused by an outdated Microsoft Visual C++ Redistributable library.\\n\" +\n \"Check that you have the latest version installed.\\n\" +\n \"See https://learn.microsoft.com/en-us/cpp/windows/latest-supported-vc-redist.\";\n }\n logConsole(\"error\", error);\n\n // Log the original error to the debug logs.\n logConsole(\"debug\", chunk);\n }\n\n // IGNORABLE:\n // anything else not handled above is considered ignorable\n // so send it to the debug logs which are discarded unless\n // the user explicitly sets a logLevel indicating they care\n else {\n logConsole(\"debug\", chunk);\n }\n }\n\n // known case: warnings are not errors, log them as such\n else if (classifiers.isWarning(chunk)) {\n logConsole(\"warn\", chunk);\n }\n\n // known case: \"error: CODE_MOVED for unknown code block?\", warning for workerd devs, not application devs\n else if (classifiers.isCodeMovedWarning(chunk)) {\n // ignore entirely, don't even send it to the debug log file\n }\n\n // Handle Zeno error logs\n else if (classifiers.isZenoLog(chunk)) {\n // Strip the prefixes\n chunk = chunk.substring(\"[ZENO]:\".length);\n chunk = chunk.substring(\"[ERROR]\".length);\n logConsole(\"error\", chunk);\n }\n\n // anything not explicitly handled above should be logged as an error (via stderr)\n else {\n logConsole(\"error\", chunk);\n }\n });\n}\n\nexport function logConsole(level: LogLevel, data: string, callDepth = 0) {\n void logConsoleAsync(level, data, callDepth);\n}\n\n/**\n * This is what is logged when the runtime calls console.log, etc.\n */\nexport async function logConsoleAsync(\n level: LogLevel,\n data: string,\n callDepth = 0\n) {\n try {\n if (!data) {\n return;\n }\n\n // This shouldn't happen, but just in case\n if (typeof data !== \"string\") {\n console[level](data);\n return;\n }\n\n let message = data?.trim();\n if (!message || message?.length === 0) {\n return;\n }\n\n // Probably a JSON object\n if (message.startsWith(`{`) && message.endsWith(`}`)) {\n let logEntry: ConsoleLogEntry;\n try {\n logEntry = JSON.parse(message);\n } catch {\n // If we are at a depth of 1 it means we are trying to handle the case\n // where a chunk might be multiple JSON entries.\n if (callDepth === 1) {\n // We might have multiple log entries in a single chunk\n // so split them and log each one\n const lines = message.split(\"\\n\");\n await Promise.all(\n lines.map(async (line) => logConsole(level, line, callDepth++))\n );\n return;\n } else {\n console[level](data);\n return;\n }\n }\n await Promise.all(\n logEntry.messages.map(async (msg) => {\n const line = await logFormatter.formatStructured(logEntry, msg);\n console[level](line);\n })\n );\n } else {\n message = await logFormatter.formatMessage(message);\n\n const line = logFormatter.formatLine(level, message);\n console[level](line);\n }\n } catch {\n const line = logFormatter.formatLine(level, data);\n\n console[level](line);\n }\n}\n"]}
1
+ {"version":3,"file":"worker-output.js","sourceRoot":"","sources":["../../src/common/worker-output.ts"],"names":[],"mappings":"AAGA,OAAO,EAAmB,YAAY,EAAY,MAAM,iBAAiB,CAAC;AAC1E,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAE5C,MAAM,YAAY,GAAG,IAAI,YAAY,CAAC,KAAK,EAAE,IAAY,EAAE,EAAE;IAC3D,OAAO,QAAQ,CAAC,IAAI,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC,CAAC;AAC9C,CAAC,CAAC,CAAC;AAEH,MAAM,UAAU,kBAAkB,CAAC,MAAgB,EAAE,MAAgB;IAKnE,MAAM,WAAW,GAAG;QAElB,MAAM,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,CAAC;aAAM,CAAC;YACN,OAAO,GAAG,MAAM,YAAY,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;YAEpD,MAAM,IAAI,GAAG,YAAY,CAAC,UAAU,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;YACrD,OAAO,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,CAAC;QACvB,CAAC;IACH,CAAC;IAAC,MAAM,CAAC;QACP,MAAM,IAAI,GAAG,YAAY,CAAC,UAAU,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;QAElD,OAAO,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,CAAC;IACvB,CAAC;AACH,CAAC","sourcesContent":["/* eslint-disable no-console */\n\nimport { Readable } from \"node:stream\";\nimport { ConsoleLogEntry, LogFormatter, LogLevel } from \"@zuplo/core/cli\";\nimport { readFile } from \"node:fs/promises\";\n\nconst logFormatter = new LogFormatter(async (path: string) => {\n return readFile(path, { encoding: \"utf8\" });\n});\n\nexport function handleRuntimeStdio(stdout: Readable, stderr: Readable) {\n // ASSUMPTION: each chunk is a whole message from workerd\n // This may not hold across OSes/architectures, but it seems to work on macOS M-line\n // I'm going with this simple approach to avoid complicating this too early\n // We can iterate on this heuristic in the future if it causes issues\n const classifiers = {\n // Is this chunk a big chonky barf from workerd that we want to hijack to cleanup/ignore?\n isBarf(chunk: string) {\n const containsLlvmSymbolizerWarning = chunk.includes(\n \"Not symbolizing stack traces because $LLVM_SYMBOLIZER is not set\"\n );\n const containsRecursiveIsolateLockWarning = chunk.includes(\n \"took recursive isolate lock\"\n );\n // Matches stack traces from workerd\n // - on unix: groups of 9 hex digits separated by spaces\n // - on windows: groups of 12 hex digits, or a single digit 0, separated by spaces\n const containsHexStack = /stack:( (0|[a-f\\d]{4,})){3,}/.test(chunk);\n\n return (\n containsLlvmSymbolizerWarning ||\n containsRecursiveIsolateLockWarning ||\n containsHexStack\n );\n },\n // Is this chunk an Address In Use error?\n isAddressInUse(chunk: string) {\n return chunk.includes(\"Address already in use; toString() = \");\n },\n isWarning(chunk: string) {\n return /\\.c\\+\\+:\\d+: warning:/.test(chunk);\n },\n isCodeMovedWarning(chunk: string) {\n return /CODE_MOVED for unknown code block/.test(chunk);\n },\n isAccessViolation(chunk: string) {\n return chunk.includes(\"access violation;\");\n },\n isZenoLog(chunk: string) {\n return chunk.startsWith(\"[ZENO]:\");\n },\n };\n\n stdout.on(\"data\", (chunk: Buffer | string) => {\n chunk = chunk.toString().trim();\n\n if (classifiers.isBarf(chunk)) {\n // this is a big chonky barf from workerd that we want to hijack to cleanup/ignore\n\n // CLEANABLE:\n // there are no known cases to cleanup yet\n // but, as they are identified, we will do that here\n\n // IGNORABLE:\n // anything else not handled above is considered ignorable\n // so send it to the debug logs which are discarded unless\n // the user explicitly sets a logLevel indicating they care\n logConsole(\"debug\", chunk);\n }\n\n // known case: warnings are not info, log them as such\n else if (classifiers.isWarning(chunk)) {\n logConsole(\"warn\", chunk);\n } else if (classifiers.isZenoLog(chunk)) {\n // Route to the specified logging level\n const levels = [\"debug\", \"info\", \"warn\", \"error\"];\n const level = levels.find((level) =>\n chunk.includes(`[${level.toUpperCase()}]`)\n );\n // Strip the prefixes for zeno and the zeno logging level\n chunk = chunk.substring(\"[ZENO]:\".length);\n chunk = chunk.substring(`[${level?.toUpperCase()}]`.length);\n if (level) {\n logConsole(level as LogLevel, chunk);\n } else {\n logConsole(\"info\", chunk);\n }\n }\n\n // anything not explicitly handled above should be logged as info (via stdout)\n else {\n logConsole(\"error\", chunk);\n }\n });\n\n stderr.on(\"data\", (chunk: Buffer | string) => {\n chunk = chunk.toString().trim();\n\n if (classifiers.isBarf(chunk)) {\n // this is a big chonky barf from workerd that we want to hijack to cleanup/ignore\n\n // CLEANABLE:\n // known case to cleanup: Address in use errors\n if (classifiers.isAddressInUse(chunk)) {\n const address = chunk.match(\n /Address already in use; toString\\(\\) = (.+)\\n/\n )?.[1];\n\n logConsole(\n \"error\",\n `Address already in use (${address}). Please check that you are not already running a server on this address or specify a different port with --port.`\n );\n\n // Log the original error to the debug logs.\n logConsole(\"debug\", chunk);\n }\n // In the past we have seen Access Violation errors on Windows, which may be caused by an outdated\n // version of the Windows OS or the Microsoft Visual C++ Redistributable.\n // See https://github.com/cloudflare/workers-sdk/issues/6170#issuecomment-2245209918\n else if (classifiers.isAccessViolation(chunk)) {\n let error = \"There was an access violation in the runtime.\";\n if (process.platform === \"win32\") {\n error +=\n \"\\nOn Windows, this may be caused by an outdated Microsoft Visual C++ Redistributable library.\\n\" +\n \"Check that you have the latest version installed.\\n\" +\n \"See https://learn.microsoft.com/en-us/cpp/windows/latest-supported-vc-redist.\";\n }\n logConsole(\"error\", error);\n\n // Log the original error to the debug logs.\n logConsole(\"debug\", chunk);\n }\n\n // IGNORABLE:\n // anything else not handled above is considered ignorable\n // so send it to the debug logs which are discarded unless\n // the user explicitly sets a logLevel indicating they care\n else {\n logConsole(\"debug\", chunk);\n }\n }\n\n // known case: warnings are not errors, log them as such\n else if (classifiers.isWarning(chunk)) {\n logConsole(\"warn\", chunk);\n }\n\n // known case: \"error: CODE_MOVED for unknown code block?\", warning for workerd devs, not application devs\n else if (classifiers.isCodeMovedWarning(chunk)) {\n // ignore entirely, don't even send it to the debug log file\n }\n\n // Handle Zeno error logs\n else if (classifiers.isZenoLog(chunk)) {\n // Strip the prefixes\n chunk = chunk.substring(\"[ZENO]:\".length);\n chunk = chunk.substring(\"[ERROR]\".length);\n logConsole(\"error\", chunk);\n }\n\n // anything not explicitly handled above should be logged as an error (via stderr)\n else {\n logConsole(\"error\", chunk);\n }\n });\n}\n\nexport function logConsole(level: LogLevel, data: string, callDepth = 0) {\n void logConsoleAsync(level, data, callDepth);\n}\n\n/**\n * This is what is logged when the runtime calls console.log, etc.\n */\nexport async function logConsoleAsync(\n level: LogLevel,\n data: string,\n callDepth = 0\n) {\n try {\n if (!data) {\n return;\n }\n\n // This shouldn't happen, but just in case\n if (typeof data !== \"string\") {\n console[level](data);\n return;\n }\n\n let message = data?.trim();\n if (!message || message?.length === 0) {\n return;\n }\n\n // Probably a JSON object\n if (message.startsWith(`{`) && message.endsWith(`}`)) {\n let logEntry: ConsoleLogEntry;\n try {\n logEntry = JSON.parse(message);\n } catch {\n // If we are at a depth of 1 it means we are trying to handle the case\n // where a chunk might be multiple JSON entries.\n if (callDepth === 1) {\n // We might have multiple log entries in a single chunk\n // so split them and log each one\n const lines = message.split(\"\\n\");\n await Promise.all(\n lines.map(async (line) => logConsole(level, line, callDepth++))\n );\n return;\n } else {\n console[level](data);\n return;\n }\n }\n await Promise.all(\n logEntry.messages.map(async (msg) => {\n const line = await logFormatter.formatStructured(logEntry, msg);\n console[level](line);\n })\n );\n } else {\n message = await logFormatter.formatMessage(message);\n\n const line = logFormatter.formatLine(level, message);\n console[level](line);\n }\n } catch {\n const line = logFormatter.formatLine(level, data);\n\n console[level](line);\n }\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zuplo/cli",
3
- "version": "6.59.45",
3
+ "version": "6.59.48",
4
4
  "repository": "https://github.com/zuplo/zuplo",
5
5
  "author": "Zuplo, Inc.",
6
6
  "type": "module",
@@ -29,9 +29,9 @@
29
29
  "@opentelemetry/api": "1.9.0",
30
30
  "@sentry/node": "9.22.0",
31
31
  "@swc/core": "1.10.18",
32
- "@zuplo/core": "6.59.45",
33
- "@zuplo/openapi-tools": "6.59.45",
34
- "@zuplo/runtime": "6.59.45",
32
+ "@zuplo/core": "6.59.48",
33
+ "@zuplo/openapi-tools": "6.59.48",
34
+ "@zuplo/runtime": "6.59.48",
35
35
  "as-table": "1.0.55",
36
36
  "chalk": "5.4.1",
37
37
  "chokidar": "3.5.3",