@datadog/datadog-ci-plugin-synthetics 5.17.0 → 5.19.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/dist/bundle.d.ts CHANGED
@@ -2388,17 +2388,30 @@ declare enum LogLevel {
2388
2388
  WARN = 3,
2389
2389
  ERROR = 4
2390
2390
  }
2391
+ interface LoggerOptions {
2392
+ shouldIncludeTimestamp?: boolean;
2393
+ /**
2394
+ * When `true`, every log call emits a single-line JSON object instead of
2395
+ * ANSI-coloured text. Useful when Datadog itself (or any other log
2396
+ * pipeline) ingests CLI output: each line parses cleanly and `level` is
2397
+ * preserved instead of every `error` showing up as `info`.
2398
+ */
2399
+ jsonOutput?: boolean;
2400
+ }
2391
2401
  declare class Logger {
2392
2402
  private loglevel;
2393
- private writeMessage;
2403
+ private rawWriteMessage;
2394
2404
  private shouldIncludeTimestamp;
2395
- constructor(writeMessage: (s: string) => void, loglevel: LogLevel, shouldIncludeTimestamp?: boolean);
2405
+ private jsonOutput;
2406
+ constructor(writeMessage: (s: string) => void, loglevel: LogLevel, shouldIncludeTimestampOrOptions?: boolean | LoggerOptions);
2396
2407
  setLogLevel(newLogLevel: LogLevel): void;
2397
2408
  setShouldIncludeTime(newShouldIncludeTimestamp: boolean): void;
2409
+ setJsonOutput(newJsonOutput: boolean): void;
2398
2410
  error(s: string): void;
2399
2411
  warn(s: string): void;
2400
2412
  info(s: string): void;
2401
2413
  debug(s: string): void;
2414
+ private emit;
2402
2415
  }
2403
2416
  //#endregion
2404
2417
  //#region src/commands/upload-application.d.ts
package/dist/bundle.js CHANGED
@@ -5761,11 +5761,12 @@ var require_glob = /* @__PURE__ */ __commonJSMin(((exports) => {
5761
5761
  var require_package$2 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
5762
5762
  module.exports = {
5763
5763
  "name": "@datadog/datadog-ci-base",
5764
- "version": "5.17.0",
5764
+ "version": "5.19.0",
5765
5765
  "description": "Base package for Datadog CI",
5766
5766
  "license": "Apache-2.0",
5767
5767
  "keywords": ["datadog", "datadog-ci"],
5768
5768
  "homepage": "https://github.com/DataDog/datadog-ci/tree/master/packages/base",
5769
+ "bugs": { "url": "https://github.com/DataDog/datadog-ci/issues" },
5769
5770
  "repository": {
5770
5771
  "type": "git",
5771
5772
  "url": "https://github.com/DataDog/datadog-ci.git",
@@ -65363,8 +65364,6 @@ var require_datadog_route = /* @__PURE__ */ __commonJSMin(((exports) => {
65363
65364
  exports.DATADOG_ROUTE_PATHS = [
65364
65365
  "/api/intake/ci/custom_spans",
65365
65366
  "/api/ui/support/serverless/flare",
65366
- "/api/unstable/deployments/gates/evaluation",
65367
- "/api/unstable/deployments/gates/evaluation/:evaluationId",
65368
65367
  "/api/v1/validate",
65369
65368
  "/api/v2/ci/deployments/correlate-image",
65370
65369
  "/api/v2/ci/deployments/correlate",
@@ -65374,6 +65373,8 @@ var require_datadog_route = /* @__PURE__ */ __commonJSMin(((exports) => {
65374
65373
  "/api/v2/cicovreprt",
65375
65374
  "/api/v2/ciiac",
65376
65375
  "/api/v2/cireport",
65376
+ "/api/v2/deployments/gates/evaluation",
65377
+ "/api/v2/deployments/gates/evaluation/:evaluationId",
65377
65378
  "/api/v2/dora/deployment",
65378
65379
  "/api/v2/git/repository/packfile",
65379
65380
  "/api/v2/git/repository/search_commits",
@@ -137482,6 +137483,7 @@ var require_is_standalone_binary = /* @__PURE__ */ __commonJSMin(((exports) => {
137482
137483
  const { isSea } = yield import("node:sea");
137483
137484
  return isSea();
137484
137485
  } catch (_a) {
137486
+ if (process.pkg !== void 0) return true;
137485
137487
  return false;
137486
137488
  }
137487
137489
  });
@@ -138376,7 +138378,7 @@ var require_plugin = /* @__PURE__ */ __commonJSMin(((exports) => {
138376
138378
  return mod && mod.__esModule ? mod : { "default": mod };
138377
138379
  };
138378
138380
  Object.defineProperty(exports, "__esModule", { value: true });
138379
- exports.getTempPath = exports.VERSION_OVERRIDE_REGEX = exports.scopeToPackageName = exports.importInstallPkg = exports.installPlugin = exports.checkPlugin = exports.listAllPlugins = exports.executePluginCommand = void 0;
138381
+ exports.getTempPath = exports.VERSION_OVERRIDE_REGEX = exports.scopeToPackageName = exports.importInstallPkg = exports.installPlugin = exports.checkPlugin = exports.listAllPlugins = exports.normalizePluginSubmodule = exports.executePluginCommand = void 0;
138380
138382
  const node_child_process_1 = require("node:child_process");
138381
138383
  const node_path_1 = __importDefault(require("node:path"));
138382
138384
  const node_url_1 = __importDefault(require("node:url"));
@@ -138417,6 +138419,15 @@ var require_plugin = /* @__PURE__ */ __commonJSMin(((exports) => {
138417
138419
  }
138418
138420
  });
138419
138421
  exports.executePluginCommand = executePluginCommand;
138422
+ const normalizePluginSubmodule = (submodule) => {
138423
+ if (isPluginSubmodule(submodule)) return submodule;
138424
+ if (typeof submodule === "object" && submodule && "default" in submodule) {
138425
+ const defaultExport = submodule.default;
138426
+ if (isPluginSubmodule(defaultExport)) return defaultExport;
138427
+ }
138428
+ return submodule;
138429
+ };
138430
+ exports.normalizePluginSubmodule = normalizePluginSubmodule;
138420
138431
  const listAllPlugins = () => {
138421
138432
  return Object.keys(package_json_1.peerDependencies);
138422
138433
  };
@@ -138579,6 +138590,21 @@ var require_plugin = /* @__PURE__ */ __commonJSMin(((exports) => {
138579
138590
  }
138580
138591
  patchModulePaths();
138581
138592
  yield handlePluginAutoInstall(scope);
138593
+ const submoduleName = `@datadog/datadog-ci-plugin-${scope}/commands/${command}`;
138594
+ debug("Resolving submodule:", submoduleName);
138595
+ let submoduleResolveError;
138596
+ let resolvedSubmodulePath;
138597
+ try {
138598
+ resolvedSubmodulePath = require.resolve(submoduleName);
138599
+ } catch (error) {
138600
+ debug(`Could not require.resolve() the ${submoduleName} submodule: ${error}`);
138601
+ submoduleResolveError = error;
138602
+ }
138603
+ if (resolvedSubmodulePath) {
138604
+ const submodulePath = node_url_1.default.pathToFileURL(resolvedSubmodulePath).href;
138605
+ debug("Importing submodule:", submodulePath);
138606
+ return (0, exports.normalizePluginSubmodule)(yield import(submodulePath));
138607
+ }
138582
138608
  const pluginPackage = `@datadog/datadog-ci-plugin-${scope}`;
138583
138609
  try {
138584
138610
  const submodule = (_b = require(pluginPackage).commands) === null || _b === void 0 ? void 0 : _b[command];
@@ -138587,19 +138613,9 @@ var require_plugin = /* @__PURE__ */ __commonJSMin(((exports) => {
138587
138613
  return submodule;
138588
138614
  }
138589
138615
  } catch (error) {
138590
- debug("Plugin bundle load failed, trying submodule path:", error);
138616
+ debug("Plugin bundle load failed:", error);
138591
138617
  }
138592
- const submoduleName = `@datadog/datadog-ci-plugin-${scope}/commands/${command}`;
138593
- debug("Resolving submodule:", submoduleName);
138594
- let submodulePath = submoduleName;
138595
- try {
138596
- const resolvedPath = require.resolve(submoduleName);
138597
- submodulePath = node_url_1.default.pathToFileURL(resolvedPath).href;
138598
- } catch (error) {
138599
- debug(`Could not require.resolve() the ${submoduleName} submodule: ${error}`);
138600
- }
138601
- debug("Importing submodule:", submodulePath);
138602
- return yield import(submodulePath);
138618
+ throw submoduleResolveError;
138603
138619
  });
138604
138620
  const scopeToPackageName = (scope) => {
138605
138621
  if (scope.match(/^@datadog\/datadog-ci-plugin-[a-z-]+$/)) return scope;
@@ -138619,6 +138635,9 @@ var require_plugin = /* @__PURE__ */ __commonJSMin(((exports) => {
138619
138635
  const isValidScope = (scope) => {
138620
138636
  return (0, exports.scopeToPackageName)(scope) in package_json_1.peerDependencies;
138621
138637
  };
138638
+ const isPluginSubmodule = (submodule) => {
138639
+ return typeof submodule === "object" && !!submodule && "PluginCommand" in submodule && typeof submodule.PluginCommand === "function";
138640
+ };
138622
138641
  /**
138623
138642
  * @example "1.2.3"
138624
138643
  * @example "file:./artifacts/@datadog-datadog-ci-base-20.tgz"
@@ -140105,12 +140124,19 @@ var require_logger = /* @__PURE__ */ __commonJSMin(((exports) => {
140105
140124
  LogLevel[LogLevel["WARN"] = 3] = "WARN";
140106
140125
  LogLevel[LogLevel["ERROR"] = 4] = "ERROR";
140107
140126
  })(LogLevel || (exports.LogLevel = LogLevel = {}));
140127
+ const LEVEL_NAMES = {
140128
+ [LogLevel.DEBUG]: "debug",
140129
+ [LogLevel.INFO]: "info",
140130
+ [LogLevel.WARN]: "warn",
140131
+ [LogLevel.ERROR]: "error"
140132
+ };
140108
140133
  var Logger = class {
140109
- constructor(writeMessage, loglevel, shouldIncludeTimestamp) {
140110
- this.shouldIncludeTimestamp = shouldIncludeTimestamp !== null && shouldIncludeTimestamp !== void 0 ? shouldIncludeTimestamp : false;
140111
- this.writeMessage = (s) => {
140112
- return writeMessage(this.shouldIncludeTimestamp ? `${(/* @__PURE__ */ new Date()).toISOString()}: ${s}` : s);
140113
- };
140134
+ constructor(writeMessage, loglevel, shouldIncludeTimestampOrOptions) {
140135
+ var _a, _b;
140136
+ const options = typeof shouldIncludeTimestampOrOptions === "boolean" ? { shouldIncludeTimestamp: shouldIncludeTimestampOrOptions } : shouldIncludeTimestampOrOptions !== null && shouldIncludeTimestampOrOptions !== void 0 ? shouldIncludeTimestampOrOptions : {};
140137
+ this.rawWriteMessage = writeMessage;
140138
+ this.shouldIncludeTimestamp = (_a = options.shouldIncludeTimestamp) !== null && _a !== void 0 ? _a : false;
140139
+ this.jsonOutput = (_b = options.jsonOutput) !== null && _b !== void 0 ? _b : false;
140114
140140
  this.loglevel = loglevel;
140115
140141
  }
140116
140142
  setLogLevel(newLogLevel) {
@@ -140119,17 +140145,34 @@ var require_logger = /* @__PURE__ */ __commonJSMin(((exports) => {
140119
140145
  setShouldIncludeTime(newShouldIncludeTimestamp) {
140120
140146
  this.shouldIncludeTimestamp = newShouldIncludeTimestamp;
140121
140147
  }
140148
+ setJsonOutput(newJsonOutput) {
140149
+ this.jsonOutput = newJsonOutput;
140150
+ }
140122
140151
  error(s) {
140123
- if (this.loglevel <= LogLevel.ERROR) this.writeMessage(chalk_1.default.red(s) + "\n");
140152
+ if (this.loglevel <= LogLevel.ERROR) this.emit(LogLevel.ERROR, s, chalk_1.default.red);
140124
140153
  }
140125
140154
  warn(s) {
140126
- if (this.loglevel <= LogLevel.WARN) this.writeMessage(chalk_1.default.yellow(s) + "\n");
140155
+ if (this.loglevel <= LogLevel.WARN) this.emit(LogLevel.WARN, s, chalk_1.default.yellow);
140127
140156
  }
140128
140157
  info(s) {
140129
- if (this.loglevel <= LogLevel.INFO) this.writeMessage(s + "\n");
140158
+ if (this.loglevel <= LogLevel.INFO) this.emit(LogLevel.INFO, s);
140130
140159
  }
140131
140160
  debug(s) {
140132
- if (this.loglevel <= LogLevel.DEBUG) this.writeMessage(s + "\n");
140161
+ if (this.loglevel <= LogLevel.DEBUG) this.emit(LogLevel.DEBUG, s);
140162
+ }
140163
+ emit(level, message, colorize) {
140164
+ if (this.jsonOutput) {
140165
+ const payload = {
140166
+ level: LEVEL_NAMES[level],
140167
+ message
140168
+ };
140169
+ if (this.shouldIncludeTimestamp) payload.timestamp = (/* @__PURE__ */ new Date()).toISOString();
140170
+ this.rawWriteMessage(JSON.stringify(payload) + "\n");
140171
+ return;
140172
+ }
140173
+ const prefix = this.shouldIncludeTimestamp ? `${(/* @__PURE__ */ new Date()).toISOString()}: ` : "";
140174
+ const body = colorize ? colorize(message) : message;
140175
+ this.rawWriteMessage(prefix + body + "\n");
140133
140176
  }
140134
140177
  };
140135
140178
  exports.Logger = Logger;