pepr 0.50.0-nightly.1 → 0.50.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/cli.js CHANGED
@@ -103,17 +103,17 @@ var require_visit = __commonJS({
103
103
  visit.BREAK = BREAK;
104
104
  visit.SKIP = SKIP;
105
105
  visit.REMOVE = REMOVE;
106
- function visit_(key, node, visitor, path4) {
107
- const ctrl = callVisitor(key, node, visitor, path4);
106
+ function visit_(key, node, visitor, path3) {
107
+ const ctrl = callVisitor(key, node, visitor, path3);
108
108
  if (identity.isNode(ctrl) || identity.isPair(ctrl)) {
109
- replaceNode(key, path4, ctrl);
110
- return visit_(key, ctrl, visitor, path4);
109
+ replaceNode(key, path3, ctrl);
110
+ return visit_(key, ctrl, visitor, path3);
111
111
  }
112
112
  if (typeof ctrl !== "symbol") {
113
113
  if (identity.isCollection(node)) {
114
- path4 = Object.freeze(path4.concat(node));
114
+ path3 = Object.freeze(path3.concat(node));
115
115
  for (let i = 0; i < node.items.length; ++i) {
116
- const ci = visit_(i, node.items[i], visitor, path4);
116
+ const ci = visit_(i, node.items[i], visitor, path3);
117
117
  if (typeof ci === "number")
118
118
  i = ci - 1;
119
119
  else if (ci === BREAK)
@@ -124,13 +124,13 @@ var require_visit = __commonJS({
124
124
  }
125
125
  }
126
126
  } else if (identity.isPair(node)) {
127
- path4 = Object.freeze(path4.concat(node));
128
- const ck = visit_("key", node.key, visitor, path4);
127
+ path3 = Object.freeze(path3.concat(node));
128
+ const ck = visit_("key", node.key, visitor, path3);
129
129
  if (ck === BREAK)
130
130
  return BREAK;
131
131
  else if (ck === REMOVE)
132
132
  node.key = null;
133
- const cv = visit_("value", node.value, visitor, path4);
133
+ const cv = visit_("value", node.value, visitor, path3);
134
134
  if (cv === BREAK)
135
135
  return BREAK;
136
136
  else if (cv === REMOVE)
@@ -151,17 +151,17 @@ var require_visit = __commonJS({
151
151
  visitAsync.BREAK = BREAK;
152
152
  visitAsync.SKIP = SKIP;
153
153
  visitAsync.REMOVE = REMOVE;
154
- async function visitAsync_(key, node, visitor, path4) {
155
- const ctrl = await callVisitor(key, node, visitor, path4);
154
+ async function visitAsync_(key, node, visitor, path3) {
155
+ const ctrl = await callVisitor(key, node, visitor, path3);
156
156
  if (identity.isNode(ctrl) || identity.isPair(ctrl)) {
157
- replaceNode(key, path4, ctrl);
158
- return visitAsync_(key, ctrl, visitor, path4);
157
+ replaceNode(key, path3, ctrl);
158
+ return visitAsync_(key, ctrl, visitor, path3);
159
159
  }
160
160
  if (typeof ctrl !== "symbol") {
161
161
  if (identity.isCollection(node)) {
162
- path4 = Object.freeze(path4.concat(node));
162
+ path3 = Object.freeze(path3.concat(node));
163
163
  for (let i = 0; i < node.items.length; ++i) {
164
- const ci = await visitAsync_(i, node.items[i], visitor, path4);
164
+ const ci = await visitAsync_(i, node.items[i], visitor, path3);
165
165
  if (typeof ci === "number")
166
166
  i = ci - 1;
167
167
  else if (ci === BREAK)
@@ -172,13 +172,13 @@ var require_visit = __commonJS({
172
172
  }
173
173
  }
174
174
  } else if (identity.isPair(node)) {
175
- path4 = Object.freeze(path4.concat(node));
176
- const ck = await visitAsync_("key", node.key, visitor, path4);
175
+ path3 = Object.freeze(path3.concat(node));
176
+ const ck = await visitAsync_("key", node.key, visitor, path3);
177
177
  if (ck === BREAK)
178
178
  return BREAK;
179
179
  else if (ck === REMOVE)
180
180
  node.key = null;
181
- const cv = await visitAsync_("value", node.value, visitor, path4);
181
+ const cv = await visitAsync_("value", node.value, visitor, path3);
182
182
  if (cv === BREAK)
183
183
  return BREAK;
184
184
  else if (cv === REMOVE)
@@ -205,23 +205,23 @@ var require_visit = __commonJS({
205
205
  }
206
206
  return visitor;
207
207
  }
208
- function callVisitor(key, node, visitor, path4) {
208
+ function callVisitor(key, node, visitor, path3) {
209
209
  if (typeof visitor === "function")
210
- return visitor(key, node, path4);
210
+ return visitor(key, node, path3);
211
211
  if (identity.isMap(node))
212
- return visitor.Map?.(key, node, path4);
212
+ return visitor.Map?.(key, node, path3);
213
213
  if (identity.isSeq(node))
214
- return visitor.Seq?.(key, node, path4);
214
+ return visitor.Seq?.(key, node, path3);
215
215
  if (identity.isPair(node))
216
- return visitor.Pair?.(key, node, path4);
216
+ return visitor.Pair?.(key, node, path3);
217
217
  if (identity.isScalar(node))
218
- return visitor.Scalar?.(key, node, path4);
218
+ return visitor.Scalar?.(key, node, path3);
219
219
  if (identity.isAlias(node))
220
- return visitor.Alias?.(key, node, path4);
220
+ return visitor.Alias?.(key, node, path3);
221
221
  return void 0;
222
222
  }
223
- function replaceNode(key, path4, node) {
224
- const parent = path4[path4.length - 1];
223
+ function replaceNode(key, path3, node) {
224
+ const parent = path3[path3.length - 1];
225
225
  if (identity.isCollection(parent)) {
226
226
  parent.items[key] = node;
227
227
  } else if (identity.isPair(parent)) {
@@ -819,10 +819,10 @@ var require_Collection = __commonJS({
819
819
  var createNode = require_createNode();
820
820
  var identity = require_identity();
821
821
  var Node2 = require_Node();
822
- function collectionFromPath(schema, path4, value) {
822
+ function collectionFromPath(schema, path3, value) {
823
823
  let v = value;
824
- for (let i = path4.length - 1; i >= 0; --i) {
825
- const k = path4[i];
824
+ for (let i = path3.length - 1; i >= 0; --i) {
825
+ const k = path3[i];
826
826
  if (typeof k === "number" && Number.isInteger(k) && k >= 0) {
827
827
  const a = [];
828
828
  a[k] = v;
@@ -841,7 +841,7 @@ var require_Collection = __commonJS({
841
841
  sourceObjects: /* @__PURE__ */ new Map()
842
842
  });
843
843
  }
844
- var isEmptyPath = (path4) => path4 == null || typeof path4 === "object" && !!path4[Symbol.iterator]().next().done;
844
+ var isEmptyPath = (path3) => path3 == null || typeof path3 === "object" && !!path3[Symbol.iterator]().next().done;
845
845
  var Collection = class extends Node2.NodeBase {
846
846
  constructor(type, schema) {
847
847
  super(type);
@@ -871,11 +871,11 @@ var require_Collection = __commonJS({
871
871
  * be a Pair instance or a `{ key, value }` object, which may not have a key
872
872
  * that already exists in the map.
873
873
  */
874
- addIn(path4, value) {
875
- if (isEmptyPath(path4))
874
+ addIn(path3, value) {
875
+ if (isEmptyPath(path3))
876
876
  this.add(value);
877
877
  else {
878
- const [key, ...rest] = path4;
878
+ const [key, ...rest] = path3;
879
879
  const node = this.get(key, true);
880
880
  if (identity.isCollection(node))
881
881
  node.addIn(rest, value);
@@ -889,8 +889,8 @@ var require_Collection = __commonJS({
889
889
  * Removes a value from the collection.
890
890
  * @returns `true` if the item was found and removed.
891
891
  */
892
- deleteIn(path4) {
893
- const [key, ...rest] = path4;
892
+ deleteIn(path3) {
893
+ const [key, ...rest] = path3;
894
894
  if (rest.length === 0)
895
895
  return this.delete(key);
896
896
  const node = this.get(key, true);
@@ -904,8 +904,8 @@ var require_Collection = __commonJS({
904
904
  * scalar values from their surrounding node; to disable set `keepScalar` to
905
905
  * `true` (collections are always returned intact).
906
906
  */
907
- getIn(path4, keepScalar) {
908
- const [key, ...rest] = path4;
907
+ getIn(path3, keepScalar) {
908
+ const [key, ...rest] = path3;
909
909
  const node = this.get(key, true);
910
910
  if (rest.length === 0)
911
911
  return !keepScalar && identity.isScalar(node) ? node.value : node;
@@ -923,8 +923,8 @@ var require_Collection = __commonJS({
923
923
  /**
924
924
  * Checks if the collection includes a value with the key `key`.
925
925
  */
926
- hasIn(path4) {
927
- const [key, ...rest] = path4;
926
+ hasIn(path3) {
927
+ const [key, ...rest] = path3;
928
928
  if (rest.length === 0)
929
929
  return this.has(key);
930
930
  const node = this.get(key, true);
@@ -934,8 +934,8 @@ var require_Collection = __commonJS({
934
934
  * Sets a value in this collection. For `!!set`, `value` needs to be a
935
935
  * boolean to add/remove the item from the set.
936
936
  */
937
- setIn(path4, value) {
938
- const [key, ...rest] = path4;
937
+ setIn(path3, value) {
938
+ const [key, ...rest] = path3;
939
939
  if (rest.length === 0) {
940
940
  this.set(key, value);
941
941
  } else {
@@ -3441,9 +3441,9 @@ var require_Document = __commonJS({
3441
3441
  this.contents.add(value);
3442
3442
  }
3443
3443
  /** Adds a value to the document. */
3444
- addIn(path4, value) {
3444
+ addIn(path3, value) {
3445
3445
  if (assertCollection(this.contents))
3446
- this.contents.addIn(path4, value);
3446
+ this.contents.addIn(path3, value);
3447
3447
  }
3448
3448
  /**
3449
3449
  * Create a new `Alias` node, ensuring that the target `node` has the required anchor.
@@ -3518,14 +3518,14 @@ var require_Document = __commonJS({
3518
3518
  * Removes a value from the document.
3519
3519
  * @returns `true` if the item was found and removed.
3520
3520
  */
3521
- deleteIn(path4) {
3522
- if (Collection.isEmptyPath(path4)) {
3521
+ deleteIn(path3) {
3522
+ if (Collection.isEmptyPath(path3)) {
3523
3523
  if (this.contents == null)
3524
3524
  return false;
3525
3525
  this.contents = null;
3526
3526
  return true;
3527
3527
  }
3528
- return assertCollection(this.contents) ? this.contents.deleteIn(path4) : false;
3528
+ return assertCollection(this.contents) ? this.contents.deleteIn(path3) : false;
3529
3529
  }
3530
3530
  /**
3531
3531
  * Returns item at `key`, or `undefined` if not found. By default unwraps
@@ -3540,10 +3540,10 @@ var require_Document = __commonJS({
3540
3540
  * scalar values from their surrounding node; to disable set `keepScalar` to
3541
3541
  * `true` (collections are always returned intact).
3542
3542
  */
3543
- getIn(path4, keepScalar) {
3544
- if (Collection.isEmptyPath(path4))
3543
+ getIn(path3, keepScalar) {
3544
+ if (Collection.isEmptyPath(path3))
3545
3545
  return !keepScalar && identity.isScalar(this.contents) ? this.contents.value : this.contents;
3546
- return identity.isCollection(this.contents) ? this.contents.getIn(path4, keepScalar) : void 0;
3546
+ return identity.isCollection(this.contents) ? this.contents.getIn(path3, keepScalar) : void 0;
3547
3547
  }
3548
3548
  /**
3549
3549
  * Checks if the document includes a value with the key `key`.
@@ -3554,10 +3554,10 @@ var require_Document = __commonJS({
3554
3554
  /**
3555
3555
  * Checks if the document includes a value at `path`.
3556
3556
  */
3557
- hasIn(path4) {
3558
- if (Collection.isEmptyPath(path4))
3557
+ hasIn(path3) {
3558
+ if (Collection.isEmptyPath(path3))
3559
3559
  return this.contents !== void 0;
3560
- return identity.isCollection(this.contents) ? this.contents.hasIn(path4) : false;
3560
+ return identity.isCollection(this.contents) ? this.contents.hasIn(path3) : false;
3561
3561
  }
3562
3562
  /**
3563
3563
  * Sets a value in this document. For `!!set`, `value` needs to be a
@@ -3574,13 +3574,13 @@ var require_Document = __commonJS({
3574
3574
  * Sets a value in this document. For `!!set`, `value` needs to be a
3575
3575
  * boolean to add/remove the item from the set.
3576
3576
  */
3577
- setIn(path4, value) {
3578
- if (Collection.isEmptyPath(path4)) {
3577
+ setIn(path3, value) {
3578
+ if (Collection.isEmptyPath(path3)) {
3579
3579
  this.contents = value;
3580
3580
  } else if (this.contents == null) {
3581
- this.contents = Collection.collectionFromPath(this.schema, Array.from(path4), value);
3581
+ this.contents = Collection.collectionFromPath(this.schema, Array.from(path3), value);
3582
3582
  } else if (assertCollection(this.contents)) {
3583
- this.contents.setIn(path4, value);
3583
+ this.contents.setIn(path3, value);
3584
3584
  }
3585
3585
  }
3586
3586
  /**
@@ -5535,9 +5535,9 @@ var require_cst_visit = __commonJS({
5535
5535
  visit.BREAK = BREAK;
5536
5536
  visit.SKIP = SKIP;
5537
5537
  visit.REMOVE = REMOVE;
5538
- visit.itemAtPath = (cst, path4) => {
5538
+ visit.itemAtPath = (cst, path3) => {
5539
5539
  let item = cst;
5540
- for (const [field, index] of path4) {
5540
+ for (const [field, index] of path3) {
5541
5541
  const tok = item?.[field];
5542
5542
  if (tok && "items" in tok) {
5543
5543
  item = tok.items[index];
@@ -5546,23 +5546,23 @@ var require_cst_visit = __commonJS({
5546
5546
  }
5547
5547
  return item;
5548
5548
  };
5549
- visit.parentCollection = (cst, path4) => {
5550
- const parent = visit.itemAtPath(cst, path4.slice(0, -1));
5551
- const field = path4[path4.length - 1][0];
5549
+ visit.parentCollection = (cst, path3) => {
5550
+ const parent = visit.itemAtPath(cst, path3.slice(0, -1));
5551
+ const field = path3[path3.length - 1][0];
5552
5552
  const coll = parent?.[field];
5553
5553
  if (coll && "items" in coll)
5554
5554
  return coll;
5555
5555
  throw new Error("Parent collection not found");
5556
5556
  };
5557
- function _visit(path4, item, visitor) {
5558
- let ctrl = visitor(item, path4);
5557
+ function _visit(path3, item, visitor) {
5558
+ let ctrl = visitor(item, path3);
5559
5559
  if (typeof ctrl === "symbol")
5560
5560
  return ctrl;
5561
5561
  for (const field of ["key", "value"]) {
5562
5562
  const token = item[field];
5563
5563
  if (token && "items" in token) {
5564
5564
  for (let i = 0; i < token.items.length; ++i) {
5565
- const ci = _visit(Object.freeze(path4.concat([[field, i]])), token.items[i], visitor);
5565
+ const ci = _visit(Object.freeze(path3.concat([[field, i]])), token.items[i], visitor);
5566
5566
  if (typeof ci === "number")
5567
5567
  i = ci - 1;
5568
5568
  else if (ci === BREAK)
@@ -5573,10 +5573,10 @@ var require_cst_visit = __commonJS({
5573
5573
  }
5574
5574
  }
5575
5575
  if (typeof ctrl === "function" && field === "key")
5576
- ctrl = ctrl(item, path4);
5576
+ ctrl = ctrl(item, path3);
5577
5577
  }
5578
5578
  }
5579
- return typeof ctrl === "function" ? ctrl(item, path4) : ctrl;
5579
+ return typeof ctrl === "function" ? ctrl(item, path3) : ctrl;
5580
5580
  }
5581
5581
  exports2.visit = visit;
5582
5582
  }
@@ -7375,8 +7375,8 @@ var banner = `\x1B[107;40m\x1B[38;5;m \x1B[38;5;m \x1B[38;5;m \x1B[38;5;m \x1B[3
7375
7375
  // src/cli/build.ts
7376
7376
  var import_child_process3 = require("child_process");
7377
7377
  var import_esbuild2 = require("esbuild");
7378
- var import_fs10 = require("fs");
7379
- var import_path4 = require("path");
7378
+ var import_fs9 = require("fs");
7379
+ var import_path3 = require("path");
7380
7380
 
7381
7381
  // src/lib/assets/assets.ts
7382
7382
  var import_crypto = __toESM(require("crypto"));
@@ -7736,12 +7736,12 @@ function serviceMonitorTemplate(name2, type) {
7736
7736
 
7737
7737
  // src/lib/filesystemService.ts
7738
7738
  var import_fs = require("fs");
7739
- async function createDirectoryIfNotExists(path4) {
7739
+ async function createDirectoryIfNotExists(path3) {
7740
7740
  try {
7741
- await import_fs.promises.access(path4);
7741
+ await import_fs.promises.access(path3);
7742
7742
  } catch (error) {
7743
7743
  if (error.code === "ENOENT") {
7744
- await import_fs.promises.mkdir(path4, { recursive: true });
7744
+ await import_fs.promises.mkdir(path3, { recursive: true });
7745
7745
  } else {
7746
7746
  throw error;
7747
7747
  }
@@ -8086,7 +8086,7 @@ function resolveIgnoreNamespaces(ignoredNSConfig = []) {
8086
8086
  }
8087
8087
 
8088
8088
  // src/lib/assets/yaml/overridesFile.ts
8089
- async function overridesFile({ hash, name: name2, image, config, apiPath, capabilities }, path4, imagePullSecrets) {
8089
+ async function overridesFile({ hash, name: name2, image, config, apiPath, capabilities }, path3, imagePullSecrets) {
8090
8090
  const rbacOverrides = clusterRole(name2, capabilities, config.rbacMode, config.rbac).rules;
8091
8091
  const overrides = {
8092
8092
  imagePullSecrets,
@@ -8241,7 +8241,7 @@ async function overridesFile({ hash, name: name2, image, config, apiPath, capabi
8241
8241
  }
8242
8242
  }
8243
8243
  };
8244
- await import_fs2.promises.writeFile(path4, (0, import_client_node.dumpYaml)(overrides, { noRefs: true, forceQuotes: true }));
8244
+ await import_fs2.promises.writeFile(path3, (0, import_client_node.dumpYaml)(overrides, { noRefs: true, forceQuotes: true }));
8245
8245
  }
8246
8246
 
8247
8247
  // src/lib/assets/index.ts
@@ -8326,9 +8326,9 @@ function helmLayout(basePath, unique) {
8326
8326
 
8327
8327
  // src/lib/assets/loader.ts
8328
8328
  var import_child_process = require("child_process");
8329
- function loadCapabilities(path4) {
8329
+ function loadCapabilities(path3) {
8330
8330
  return new Promise((resolve6, reject) => {
8331
- const program2 = (0, import_child_process.fork)(path4, {
8331
+ const program2 = (0, import_child_process.fork)(path3, {
8332
8332
  env: {
8333
8333
  ...process.env,
8334
8334
  LOG_LEVEL: "warn",
@@ -8446,12 +8446,12 @@ var Assets = class {
8446
8446
  image;
8447
8447
  buildTimestamp;
8448
8448
  host;
8449
- constructor(config, path4, imagePullSecrets, host) {
8449
+ constructor(config, path3, imagePullSecrets, host) {
8450
8450
  this.name = `pepr-${config.uuid}`;
8451
8451
  this.imagePullSecrets = imagePullSecrets;
8452
8452
  this.buildTimestamp = `${Date.now()}`;
8453
8453
  this.config = config;
8454
- this.path = path4;
8454
+ this.path = path3;
8455
8455
  this.host = host;
8456
8456
  this.alwaysIgnore = config.alwaysIgnore;
8457
8457
  this.image = `ghcr.io/defenseunicorns/pepr/controller:v${config.peprVersion}`;
@@ -8463,8 +8463,8 @@ var Assets = class {
8463
8463
  const timeout = typeof webhookTimeout === "number" ? webhookTimeout : 10;
8464
8464
  await deployFunction(this, force, timeout);
8465
8465
  }
8466
- zarfYaml = (zarfYamlGenerator, path4) => zarfYamlGenerator(this, path4, "manifests");
8467
- zarfYamlChart = (zarfYamlGenerator, path4) => zarfYamlGenerator(this, path4, "charts");
8466
+ zarfYaml = (zarfYamlGenerator, path3) => zarfYamlGenerator(this, path3, "manifests");
8467
+ zarfYamlChart = (zarfYamlGenerator, path3) => zarfYamlGenerator(this, path3, "charts");
8468
8468
  allYaml = async (yamlGenerationFunction, getDeploymentFunction, getWatcherFunction, imagePullSecret) => {
8469
8469
  this.capabilities = await loadCapabilities(this.path);
8470
8470
  for (const capability of this.capabilities) {
@@ -8594,8 +8594,26 @@ var Assets = class {
8594
8594
  var import_client_node3 = require("@kubernetes/client-node");
8595
8595
  var import_util = require("util");
8596
8596
  var import_uuid = require("uuid");
8597
- var import_fs5 = require("fs");
8598
- var import_path2 = __toESM(require("path"));
8597
+
8598
+ // src/templates/.eslintrc.template.json
8599
+ var eslintrc_template_default = {
8600
+ env: {
8601
+ browser: false,
8602
+ es2021: true
8603
+ },
8604
+ extends: ["eslint:recommended", "plugin:@typescript-eslint/recommended"],
8605
+ parser: "@typescript-eslint/parser",
8606
+ parserOptions: {
8607
+ project: ["./tsconfig.json"],
8608
+ ecmaVersion: 2022
8609
+ },
8610
+ plugins: ["@typescript-eslint"],
8611
+ ignorePatterns: ["node_modules", "dist"],
8612
+ root: true,
8613
+ rules: {
8614
+ "@typescript-eslint/no-floating-promises": ["error"]
8615
+ }
8616
+ };
8599
8617
 
8600
8618
  // src/templates/pepr.code-snippets.json
8601
8619
  var pepr_code_snippets_default = {
@@ -8835,8 +8853,8 @@ var tsconfig_module_default = {
8835
8853
  var gitIgnore = "# Ignore node_modules and Pepr build artifacts\nnode_modules\ndist\ninsecure*\n";
8836
8854
  var readmeMd = '# Pepr Module\n\nThis is a Pepr Module. [Pepr](https://github.com/defenseunicorns/pepr) is a type-safe Kubernetes middleware system.\n\nThe `capabilities` directory contains all the capabilities for this module. By default,\na capability is a single typescript file in the format of `capability-name.ts` that is\nimported in the root `pepr.ts` file as `import { HelloPepr } from "./capabilities/hello-pepr";`.\nBecause this is typescript, you can organize this however you choose, e.g. creating a sub-folder\nper-capability or common logic in shared files or folders.\n\nExample Structure:\n\n```\nModule Root\n\u251C\u2500\u2500 package.json\n\u251C\u2500\u2500 pepr.ts\n\u2514\u2500\u2500 capabilities\n \u251C\u2500\u2500 example-one.ts\n \u251C\u2500\u2500 example-three.ts\n \u2514\u2500\u2500 example-two.ts\n```\n';
8837
8855
  var peprTS = 'import { PeprModule } from "pepr";\n// cfg loads your pepr configuration from package.json\nimport cfg from "./package.json";\n\n// HelloPepr is a demo capability that is included with Pepr. Comment or delete the line below to remove it.\nimport { HelloPepr } from "./capabilities/hello-pepr";\n\n/**\n * This is the main entrypoint for this Pepr module. It is run when the module is started.\n * This is where you register your Pepr configurations and capabilities.\n */\nnew PeprModule(cfg, [\n // "HelloPepr" is a demo capability that is included with Pepr. Comment or delete the line below to remove it.\n HelloPepr,\n\n // Your additional capabilities go here\n]);\n';
8838
- var helloPeprTS = 'import {\n Capability,\n K8s,\n Log,\n PeprMutateRequest,\n RegisterKind,\n a,\n fetch,\n fetchStatus,\n kind,\n} from "pepr";\nimport { MockAgent, setGlobalDispatcher } from "undici";\n\n/**\n * The HelloPepr Capability is an example capability to demonstrate some general concepts of Pepr.\n * To test this capability you run `pepr dev`and then run the following command:\n * `kubectl apply -f capabilities/hello-pepr.samples.yaml`\n */\nexport const HelloPepr = new Capability({\n name: "hello-pepr",\n description: "A simple example capability to show how things work.",\n namespaces: ["pepr-demo", "pepr-demo-2"],\n});\n\n// Use the \'When\' function to create a new action, use \'Store\' to persist data\nconst { When, Store } = HelloPepr;\n\n/**\n * ---------------------------------------------------------------------------------------------------\n * Mutate Action (Namespace) *\n * ---------------------------------------------------------------------------------------------------\n *\n * This action removes the label `remove-me` when a Namespace is created.\n * Note we don\'t need to specify the namespace here, because we\'ve already specified\n * it in the Capability definition above.\n */\nWhen(a.Namespace)\n .IsCreated()\n .Mutate(ns => ns.RemoveLabel("remove-me"));\n\n/**\n * ---------------------------------------------------------------------------------------------------\n * Watch Action with K8s SSA (Namespace) *\n * ---------------------------------------------------------------------------------------------------\n *\n * This action watches for the `pepr-demo-2` namespace to be created, then creates a ConfigMap with\n * the name `pepr-ssa-demo` and adds the namespace UID to the ConfigMap data. Because Pepr uses\n * server-side apply for this operation, the ConfigMap will be created or updated if it already exists.\n */\nWhen(a.Namespace)\n .IsCreated()\n .WithName("pepr-demo-2")\n .Watch(async ns => {\n Log.info("Namespace pepr-demo-2 was created.");\n\n try {\n // Apply the ConfigMap using K8s server-side apply\n await K8s(kind.ConfigMap).Apply({\n metadata: {\n name: "pepr-ssa-demo",\n namespace: "pepr-demo-2",\n },\n data: {\n "ns-uid": ns.metadata.uid,\n },\n });\n } catch (error) {\n // You can use the Log object to log messages to the Pepr controller pod\n Log.error(error, "Failed to apply ConfigMap using server-side apply.");\n }\n\n // You can share data between actions using the Store, including between different types of actions\n Store.setItem("watch-data", "This data was stored by a Watch Action.");\n });\n\n/**\n * ---------------------------------------------------------------------------------------------------\n * Mutate Action (CM Example 1) *\n * ---------------------------------------------------------------------------------------------------\n *\n * This is a single action. They can be in the same file or put imported from other files.\n * In this example, when a ConfigMap is created with the name `example-1`, then add a label and annotation.\n *\n * Equivalent to manually running:\n * `kubectl label configmap example-1 pepr=was-here`\n * `kubectl annotate configmap example-1 pepr.dev=annotations-work-too`\n */\nWhen(a.ConfigMap)\n .IsCreated()\n .WithName("example-1")\n .Mutate(request => {\n request.SetLabel("pepr", "was-here").SetAnnotation("pepr.dev", "annotations-work-too");\n\n // Use the Store to persist data between requests and Pepr controller pods\n Store.setItem("example-1", "was-here");\n\n // This data is written asynchronously and can be read back via `Store.getItem()` or `Store.subscribe()`\n Store.setItem("example-1-data", JSON.stringify(request.Raw.data));\n });\n\n/**\n * ---------------------------------------------------------------------------------------------------\n * Mutate & Validate Actions (CM Example 2) *\n * ---------------------------------------------------------------------------------------------------\n *\n * This combines 3 different types of actions: \'Mutate\', \'Validate\', and \'Watch\'. The order\n * of the actions is required, but each action is optional. In this example, when a ConfigMap is created\n * with the name `example-2`, then add a label and annotation, validate that the ConfigMap has the label\n * `pepr`, and log the request.\n */\nWhen(a.ConfigMap)\n .IsCreated()\n .WithName("example-2")\n .Mutate(request => {\n // This Mutate Action will mutate the request before it is persisted to the cluster\n\n // Use `request.Merge()` to merge the new data with the existing data\n request.Merge({\n metadata: {\n labels: {\n pepr: "was-here",\n },\n annotations: {\n "pepr.dev": "annotations-work-too",\n },\n },\n });\n })\n .Validate(request => {\n // This Validate Action will validate the request before it is persisted to the cluster\n\n // Approve the request if the ConfigMap has the label \'pepr\'\n if (request.HasLabel("pepr")) {\n return request.Approve();\n }\n\n // Otherwise, deny the request with an error message (optional)\n return request.Deny("ConfigMap must have label \'pepr\'");\n })\n .Watch((cm, phase) => {\n // This Watch Action will watch the ConfigMap after it has been persisted to the cluster\n Log.info(cm, `ConfigMap was ${phase} with the name example-2`);\n });\n\n/**\n * ---------------------------------------------------------------------------------------------------\n * Mutate Action (CM Example 2a) *\n * ---------------------------------------------------------------------------------------------------\n *\n * This action shows a simple validation that will deny any ConfigMap that has the\n * annotation `evil`. Note that the `Deny()` function takes an optional second parameter that is a\n * user-defined status code to return.\n */\nWhen(a.ConfigMap)\n .IsCreated()\n .Validate(request => {\n if (request.HasAnnotation("evil")) {\n return request.Deny("No evil CM annotations allowed.", 400);\n }\n\n return request.Approve();\n });\n\n/**\n * ---------------------------------------------------------------------------------------------------\n * Mutate Action (CM Example 3) *\n * ---------------------------------------------------------------------------------------------------\n *\n * This action combines different styles. Unlike the previous actions, this one will look\n * for any ConfigMap in the `pepr-demo` namespace that has the label `change=by-label` during either\n * CREATE or UPDATE. Note that all conditions added such as `WithName()`, `WithLabel()`, `InNamespace()`,\n * are ANDs so all conditions must be true for the request to be processed.\n */\nWhen(a.ConfigMap)\n .IsCreatedOrUpdated()\n .WithLabel("change", "by-label")\n .Mutate(request => {\n // The K8s object e are going to mutate\n const cm = request.Raw;\n\n // Get the username and uid of the K8s request\n const { username, uid } = request.Request.userInfo;\n\n // Store some data about the request in the configmap\n cm.data["username"] = username;\n cm.data["uid"] = uid;\n\n // You can still mix other ways of making changes too\n request.SetAnnotation("pepr.dev", "making-waves");\n });\n\n// This action validates the label `change=by-label` is deleted\nWhen(a.ConfigMap)\n .IsDeleted()\n .WithLabel("change", "by-label")\n .Validate(request => {\n // Log and then always approve the request\n Log.info("CM with label \'change=by-label\' was deleted.");\n return request.Approve();\n });\n\n/**\n * ---------------------------------------------------------------------------------------------------\n * Mutate Action (CM Example 4) *\n * ---------------------------------------------------------------------------------------------------\n *\n * This action show how you can use the `Mutate()` function without an inline function.\n * This is useful if you want to keep your actions small and focused on a single task,\n * or if you want to reuse the same function in multiple actions.\n */\nWhen(a.ConfigMap).IsCreated().WithName("example-4").Mutate(example4Cb);\n\n// This function uses the complete type definition, but is not required.\nfunction example4Cb(cm: PeprMutateRequest<a.ConfigMap>): void {\n cm.SetLabel("pepr.dev/first", "true");\n cm.SetLabel("pepr.dev/second", "true");\n cm.SetLabel("pepr.dev/third", "true");\n}\n\n/**\n * ---------------------------------------------------------------------------------------------------\n * Mutate Action (CM Example 4a) *\n * ---------------------------------------------------------------------------------------------------\n *\n * This is the same as Example 4, except this only operates on a CM in the `pepr-demo-2` namespace.\n * Note because the Capability defines namespaces, the namespace specified here must be one of those.\n * Alternatively, you can remove the namespace from the Capability definition and specify it here.\n */\nWhen(a.ConfigMap).IsCreated().InNamespace("pepr-demo-2").WithName("example-4a").Mutate(example4Cb);\n\n/**\n * ---------------------------------------------------------------------------------------------------\n * Mutate Action (CM Example 5) *\n * ---------------------------------------------------------------------------------------------------\n *\n * This action is a bit more complex. It will look for any ConfigMap in the `pepr-demo`\n * namespace that has the label `chuck-norris` during CREATE. When it finds one, it will fetch a\n * random Chuck Norris joke from the API and add it to the ConfigMap. This is a great example of how\n * you can use Pepr to make changes to your K8s objects based on external data.\n *\n * Note the use of the `async` keyword. This is required for any action that uses `await` or `fetch()`.\n *\n * Also note we are passing a type to the `fetch()` function. This is optional, but it will help you\n * avoid mistakes when working with the data returned from the API. You can also use the `as` keyword to\n * cast the data returned from the API.\n *\n * These are equivalent:\n * ```ts\n * const joke = await fetch<TheChuckNorrisJoke>("https://icanhazdadjoke.com/");\n * const joke = await fetch("https://icanhazdadjoke.com/") as TheChuckNorrisJoke;\n * ```\n *\n * Alternatively, you can drop the type completely:\n *\n * ```ts\n * fetch("https://icanhazdadjoke.com")\n * ```\n */\ninterface TheChuckNorrisJoke {\n id: string;\n joke: string;\n status: number;\n}\n\nWhen(a.ConfigMap)\n .IsCreatedOrUpdated()\n .WithLabel("chuck-norris")\n .Mutate(cm => cm.SetLabel("got-jokes", "true"))\n .Watch(async cm => {\n const jokeURL = "https://icanhazdadjoke.com";\n\n const mockAgent: MockAgent = new MockAgent();\n setGlobalDispatcher(mockAgent);\n const mockClient = mockAgent.get(jokeURL);\n mockClient.intercept({ path: "/", method: "GET" }).reply(\n 200,\n {\n id: "R7UfaahVfFd",\n joke: "Funny joke goes here.",\n status: 200,\n },\n {\n headers: {\n "Content-Type": "application/json; charset=utf-8",\n },\n },\n );\n\n // Try/catch is not needed as a response object will always be returned\n const response = await fetch<TheChuckNorrisJoke>(jokeURL, {\n headers: {\n Accept: "application/json",\n },\n });\n\n // Instead, check the `response.ok` field\n if (response.ok) {\n const { joke } = response.data;\n // Add Joke to the Store\n await Store.setItemAndWait(jokeURL, joke);\n // Add the Chuck Norris joke to the configmap\n try {\n await K8s(kind.ConfigMap).Apply({\n metadata: {\n name: cm.metadata.name,\n namespace: cm.metadata.namespace,\n },\n data: {\n "chuck-says": Store.getItem(jokeURL),\n },\n });\n } catch (error) {\n Log.error(error, "Failed to apply ConfigMap using server-side apply.", {\n cm,\n });\n }\n }\n\n // You can also assert on different HTTP response codes\n if (response.status === fetchStatus.NOT_FOUND) {\n // Do something else\n return;\n }\n });\n\n/**\n * ---------------------------------------------------------------------------------------------------\n * Mutate Action (Secret Base64 Handling) *\n * ---------------------------------------------------------------------------------------------------\n *\n * The K8s JS client provides incomplete support for base64 encoding/decoding handling for secrets,\n * unlike the GO client. To make this less painful, Pepr automatically handles base64 encoding/decoding\n * secret data before and after the action is executed.\n */\nWhen(a.Secret)\n .IsCreated()\n .WithName("secret-1")\n .Mutate(request => {\n const secret = request.Raw;\n\n // This will be encoded at the end of all processing back to base64: "Y2hhbmdlLXdpdGhvdXQtZW5jb2Rpbmc="\n secret.data.magic = "change-without-encoding";\n\n // You can modify the data directly, and it will be encoded at the end of all processing\n secret.data.example += " - modified by Pepr";\n });\n\n/**\n * ---------------------------------------------------------------------------------------------------\n * Mutate Action (Untyped Custom Resource) *\n * ---------------------------------------------------------------------------------------------------\n *\n * Out of the box, Pepr supports all the standard Kubernetes objects. However, you can also create\n * your own types. This is useful if you are working with an Operator that creates custom resources.\n * There are two ways to do this, the first is to use the `When()` function with a `GenericKind`,\n * the second is to create a new class that extends `GenericKind` and use the `RegisterKind()` function.\n *\n * This example shows how to use the `When()` function with a `GenericKind`. Note that you\n * must specify the `group`, `version`, and `kind` of the object (if applicable). This is how Pepr knows\n * if the action should be triggered or not. Since we are using a `GenericKind`,\n * Pepr will not be able to provide any intellisense for the object, so you will need to refer to the\n * Kubernetes API documentation for the object you are working with.\n *\n * You will need to wait for the CRD in `hello-pepr.samples.yaml` to be created, then you can apply\n *\n * ```yaml\n * apiVersion: pepr.dev/v1\n * kind: Unicorn\n * metadata:\n * name: example-1\n * namespace: pepr-demo\n * spec:\n * message: replace-me\n * counter: 0\n * ```\n */\nWhen(a.GenericKind, {\n group: "pepr.dev",\n version: "v1",\n kind: "Unicorn",\n})\n .IsCreated()\n .WithName("example-1")\n .Mutate(request => {\n request.Merge({\n spec: {\n message: "Hello Pepr without type data!",\n counter: Math.random(),\n },\n });\n });\n\n/**\n * ---------------------------------------------------------------------------------------------------\n * Mutate Action (Typed Custom Resource) *\n * ---------------------------------------------------------------------------------------------------\n *\n * This example shows how to use the `RegisterKind()` function to create a new type. This is useful\n * if you are working with an Operator that creates custom resources and you want to have intellisense\n * for the object. Note that you must specify the `group`, `version`, and `kind` of the object (if applicable)\n * as this is how Pepr knows if the action should be triggered or not.\n *\n * Once you register a new Kind with Pepr, you can use the `When()` function with the new Kind. Ideally,\n * you should register custom Kinds at the top of your Capability file or Pepr Module so they are available\n * to all actions, but we are putting it here for demonstration purposes.\n *\n * You will need to wait for the CRD in `hello-pepr.samples.yaml` to be created, then you can apply\n *\n * ```yaml\n * apiVersion: pepr.dev/v1\n * kind: Unicorn\n * metadata:\n * name: example-2\n * namespace: pepr-demo\n * spec:\n * message: replace-me\n * counter: 0\n * ```*\n */\nclass UnicornKind extends a.GenericKind {\n spec: {\n /**\n * JSDoc comments can be added to explain more details about the field.\n *\n * @example\n * ```ts\n * request.Raw.spec.message = "Hello Pepr!";\n * ```\n * */\n message: string;\n counter: number;\n };\n}\n\nRegisterKind(UnicornKind, {\n group: "pepr.dev",\n version: "v1",\n kind: "Unicorn",\n});\n\nWhen(UnicornKind)\n .IsCreated()\n .WithName("example-2")\n .Mutate(request => {\n request.Merge({\n spec: {\n message: "Hello Pepr with type data!",\n counter: Math.random(),\n },\n });\n });\n\n/**\n * A callback function that is called once the Pepr Store is fully loaded.\n */\nStore.onReady(data => {\n Log.info(data, "Pepr Store Ready");\n});\n';
8839
- var packageJSON = { name: "pepr", description: "Kubernetes application engine", author: "Defense Unicorns", homepage: "https://github.com/defenseunicorns/pepr", license: "Apache-2.0", bin: "dist/cli.js", repository: "defenseunicorns/pepr", engines: { node: ">=18.0.0" }, files: ["/dist", "/src", "!src/**/*.test.ts", "!src/fixtures/**", "!dist/**/*.test.d.ts*", "!src/cli/docs/**"], version: "0.50.0-nightly.1", main: "dist/lib.js", types: "dist/lib.d.ts", scripts: { ci: "npm ci", "gen-data-json": "node hack/build-template-data.js", prebuild: "rm -fr dist/* && npm run gen-data-json", build: "tsc && node build.mjs && npm pack", "build:image": "npm run build && docker buildx build --output type=docker --tag pepr:dev .", "build:image:unicorn": "npm run build && docker buildx build --output type=docker --tag pepr:dev $(node scripts/read-unicorn-build-args.mjs) .", "set:version": "node scripts/set-version.js", test: "npm run test:unit && npm run test:journey && npm run test:journey-wasm", "test:artifacts": "npm run build && jest src/build-artifact.test.ts", "test:docs": "jest --verbose src/cli/docs/*.test.ts", "test:integration": "npm run test:integration:prep && npm run test:integration:run", "test:integration:prep": "./integration/prep.sh", "test:integration:run": "jest --maxWorkers=4 integration", "test:journey": "npm run test:journey:k3d && npm run build && npm run test:journey:image && npm run test:journey:run", "test:journey-wasm": "npm run test:journey:k3d && npm run build && npm run test:journey:image && npm run test:journey:run-wasm", "test:journey-wasm:unicorn": "npm run test:journey:k3d && npm run build && npm run test:journey:image:unicorn && npm run test:journey:run-wasm", "test:journey:image": "docker buildx build --output type=docker --tag pepr:dev . && k3d image import pepr:dev -c pepr-dev", "test:journey:image:unicorn": "npm run build && docker buildx build --output type=docker --tag pepr:dev $(node scripts/read-unicorn-build-args.mjs) . && k3d image import pepr:dev -c pepr-dev", "test:journey:k3d": "k3d cluster delete pepr-dev && k3d cluster create pepr-dev --k3s-arg '--debug@server:0' --wait && kubectl rollout status deployment -n kube-system", "test:journey:run": "jest --detectOpenHandles journey/entrypoint.test.ts && npm run test:journey:upgrade", "test:journey:run-wasm": "jest --detectOpenHandles journey/entrypoint-wasm.test.ts", "test:journey:unicorn": "npm run test:journey:k3d && npm run test:journey:image:unicorn && npm run test:journey:run", "test:journey:upgrade": "npm run test:journey:k3d && npm run test:journey:image && jest --detectOpenHandles journey/pepr-upgrade.test.ts", "test:unit": 'npm run gen-data-json && jest src --coverage --detectOpenHandles --coverageDirectory=./coverage --testPathIgnorePatterns="build-artifact.test.ts|src/cli/docs/.*\\.test\\.ts"', "format:check": "eslint --ignore-pattern src/templates/eslint.config.mjs src && prettier --config .prettierrc src --check", "format:fix": "eslint --fix --ignore-pattern src/templates/eslint.config.mjs src && prettier --config .prettierrc src --write", prepare: `if [ "$NODE_ENV" != 'production' ]; then husky; fi` }, dependencies: { "@types/ramda": "0.30.2", express: "5.1.0", "fast-json-patch": "3.1.1", heredoc: "^1.3.1", "http-status-codes": "^2.3.0", "json-pointer": "^0.6.2", "kubernetes-fluent-client": "3.5.3", pino: "9.6.0", "pino-pretty": "13.0.0", "prom-client": "15.1.3", ramda: "0.30.1", sigstore: "3.1.0", "ts-morph": "^25.0.1" }, devDependencies: { "@commitlint/cli": "19.8.1", "@commitlint/config-conventional": "19.8.1", "@fast-check/jest": "^2.0.1", "@jest/globals": "29.7.0", "@types/eslint": "9.6.1", "@types/express": "5.0.1", "@types/json-pointer": "^1.0.34", "@types/node": "22.x.x", "@types/node-forge": "1.3.11", "@types/uuid": "10.0.0", "fast-check": "^4.0.0", globals: "^16.0.0", husky: "^9.1.6", jest: "29.7.0", "js-yaml": "^4.1.0", shellcheck: "^3.0.0", "ts-jest": "29.3.2", undici: "^7.0.1" }, overrides: { glob: "^9.0.0" }, peerDependencies: { "@types/prompts": "2.4.9", "@typescript-eslint/eslint-plugin": "8.32.1", "@typescript-eslint/parser": "8.32.1", commander: "13.1.0", esbuild: "0.25.0", eslint: "^9.26.0", "node-forge": "1.3.1", prettier: "3.5.3", prompts: "2.4.2", typescript: "5.8.3", uuid: "11.1.0" } };
8856
+ var helloPeprTS = 'import {\n Capability,\n K8s,\n Log,\n PeprMutateRequest,\n RegisterKind,\n a,\n fetch,\n fetchStatus,\n kind,\n} from "pepr";\nimport { MockAgent, setGlobalDispatcher } from "undici";\n\n/**\n * The HelloPepr Capability is an example capability to demonstrate some general concepts of Pepr.\n * To test this capability you run `pepr dev`and then run the following command:\n * `kubectl apply -f capabilities/hello-pepr.samples.yaml`\n */\nexport const HelloPepr = new Capability({\n name: "hello-pepr",\n description: "A simple example capability to show how things work.",\n namespaces: ["pepr-demo", "pepr-demo-2"],\n});\n\n// Use the \'When\' function to create a new action, use \'Store\' to persist data\nconst { When, Store } = HelloPepr;\n\n/**\n * ---------------------------------------------------------------------------------------------------\n * Mutate Action (Namespace) *\n * ---------------------------------------------------------------------------------------------------\n *\n * This action removes the label `remove-me` when a Namespace is created.\n * Note we don\'t need to specify the namespace here, because we\'ve already specified\n * it in the Capability definition above.\n */\nWhen(a.Namespace)\n .IsCreated()\n .Mutate(ns => ns.RemoveLabel("remove-me"));\n\n/**\n * ---------------------------------------------------------------------------------------------------\n * Watch Action with K8s SSA (Namespace) *\n * ---------------------------------------------------------------------------------------------------\n *\n * This action watches for the `pepr-demo-2` namespace to be created, then creates a ConfigMap with\n * the name `pepr-ssa-demo` and adds the namespace UID to the ConfigMap data. Because Pepr uses\n * server-side apply for this operation, the ConfigMap will be created or updated if it already exists.\n */\nWhen(a.Namespace)\n .IsCreated()\n .WithName("pepr-demo-2")\n .Watch(async ns => {\n Log.info("Namespace pepr-demo-2 was created.");\n\n try {\n // Apply the ConfigMap using K8s server-side apply\n await K8s(kind.ConfigMap).Apply({\n metadata: {\n name: "pepr-ssa-demo",\n namespace: "pepr-demo-2",\n },\n data: {\n "ns-uid": ns.metadata.uid,\n },\n });\n } catch (error) {\n // You can use the Log object to log messages to the Pepr controller pod\n Log.error(error, "Failed to apply ConfigMap using server-side apply.");\n }\n\n // You can share data between actions using the Store, including between different types of actions\n Store.setItem("watch-data", "This data was stored by a Watch Action.");\n });\n\n/**\n * ---------------------------------------------------------------------------------------------------\n * Mutate Action (CM Example 1) *\n * ---------------------------------------------------------------------------------------------------\n *\n * This is a single action. They can be in the same file or put imported from other files.\n * In this example, when a ConfigMap is created with the name `example-1`, then add a label and annotation.\n *\n * Equivalent to manually running:\n * `kubectl label configmap example-1 pepr=was-here`\n * `kubectl annotate configmap example-1 pepr.dev=annotations-work-too`\n */\nWhen(a.ConfigMap)\n .IsCreated()\n .WithName("example-1")\n .Mutate(request => {\n request.SetLabel("pepr", "was-here").SetAnnotation("pepr.dev", "annotations-work-too");\n\n // Use the Store to persist data between requests and Pepr controller pods\n Store.setItem("example-1", "was-here");\n\n // This data is written asynchronously and can be read back via `Store.getItem()` or `Store.subscribe()`\n Store.setItem("example-1-data", JSON.stringify(request.Raw.data));\n });\n\n/**\n * ---------------------------------------------------------------------------------------------------\n * Mutate & Validate Actions (CM Example 2) *\n * ---------------------------------------------------------------------------------------------------\n *\n * This combines 3 different types of actions: \'Mutate\', \'Validate\', and \'Watch\'. The order\n * of the actions is required, but each action is optional. In this example, when a ConfigMap is created\n * with the name `example-2`, then add a label and annotation, validate that the ConfigMap has the label\n * `pepr`, and log the request.\n */\nWhen(a.ConfigMap)\n .IsCreated()\n .WithName("example-2")\n .Mutate(request => {\n // This Mutate Action will mutate the request before it is persisted to the cluster\n\n // Use `request.Merge()` to merge the new data with the existing data\n request.Merge({\n metadata: {\n labels: {\n pepr: "was-here",\n },\n annotations: {\n "pepr.dev": "annotations-work-too",\n },\n },\n });\n })\n .Validate(request => {\n // This Validate Action will validate the request before it is persisted to the cluster\n\n // Approve the request if the ConfigMap has the label \'pepr\'\n if (request.HasLabel("pepr")) {\n return request.Approve();\n }\n\n // Otherwise, deny the request with an error message (optional)\n return request.Deny("ConfigMap must have label \'pepr\'");\n })\n .Watch((cm, phase) => {\n // This Watch Action will watch the ConfigMap after it has been persisted to the cluster\n Log.info(cm, `ConfigMap was ${phase} with the name example-2`);\n });\n\n/**\n * ---------------------------------------------------------------------------------------------------\n * Mutate Action (CM Example 2a) *\n * ---------------------------------------------------------------------------------------------------\n *\n * This action shows a simple validation that will deny any ConfigMap that has the\n * annotation `evil`. Note that the `Deny()` function takes an optional second parameter that is a\n * user-defined status code to return.\n */\nWhen(a.ConfigMap)\n .IsCreated()\n .Validate(request => {\n if (request.HasAnnotation("evil")) {\n return request.Deny("No evil CM annotations allowed.", 400);\n }\n\n return request.Approve();\n });\n\n/**\n * ---------------------------------------------------------------------------------------------------\n * Mutate Action (CM Example 3) *\n * ---------------------------------------------------------------------------------------------------\n *\n * This action combines different styles. Unlike the previous actions, this one will look\n * for any ConfigMap in the `pepr-demo` namespace that has the label `change=by-label` during either\n * CREATE or UPDATE. Note that all conditions added such as `WithName()`, `WithLabel()`, `InNamespace()`,\n * are ANDs so all conditions must be true for the request to be processed.\n */\nWhen(a.ConfigMap)\n .IsCreatedOrUpdated()\n .WithLabel("change", "by-label")\n .Mutate(request => {\n // The K8s object e are going to mutate\n const cm = request.Raw;\n\n // Get the username and uid of the K8s request\n const { username, uid } = request.Request.userInfo;\n\n // Store some data about the request in the configmap\n cm.data["username"] = username;\n cm.data["uid"] = uid;\n\n // You can still mix other ways of making changes too\n request.SetAnnotation("pepr.dev", "making-waves");\n });\n\n// This action validates the label `change=by-label` is deleted\nWhen(a.ConfigMap)\n .IsDeleted()\n .WithLabel("change", "by-label")\n .Validate(request => {\n // Log and then always approve the request\n Log.info("CM with label \'change=by-label\' was deleted.");\n return request.Approve();\n });\n\n/**\n * ---------------------------------------------------------------------------------------------------\n * Mutate Action (CM Example 4) *\n * ---------------------------------------------------------------------------------------------------\n *\n * This action show how you can use the `Mutate()` function without an inline function.\n * This is useful if you want to keep your actions small and focused on a single task,\n * or if you want to reuse the same function in multiple actions.\n */\nWhen(a.ConfigMap).IsCreated().WithName("example-4").Mutate(example4Cb);\n\n// This function uses the complete type definition, but is not required.\nfunction example4Cb(cm: PeprMutateRequest<a.ConfigMap>) {\n cm.SetLabel("pepr.dev/first", "true");\n cm.SetLabel("pepr.dev/second", "true");\n cm.SetLabel("pepr.dev/third", "true");\n}\n\n/**\n * ---------------------------------------------------------------------------------------------------\n * Mutate Action (CM Example 4a) *\n * ---------------------------------------------------------------------------------------------------\n *\n * This is the same as Example 4, except this only operates on a CM in the `pepr-demo-2` namespace.\n * Note because the Capability defines namespaces, the namespace specified here must be one of those.\n * Alternatively, you can remove the namespace from the Capability definition and specify it here.\n */\nWhen(a.ConfigMap).IsCreated().InNamespace("pepr-demo-2").WithName("example-4a").Mutate(example4Cb);\n\n/**\n * ---------------------------------------------------------------------------------------------------\n * Mutate Action (CM Example 5) *\n * ---------------------------------------------------------------------------------------------------\n *\n * This action is a bit more complex. It will look for any ConfigMap in the `pepr-demo`\n * namespace that has the label `chuck-norris` during CREATE. When it finds one, it will fetch a\n * random Chuck Norris joke from the API and add it to the ConfigMap. This is a great example of how\n * you can use Pepr to make changes to your K8s objects based on external data.\n *\n * Note the use of the `async` keyword. This is required for any action that uses `await` or `fetch()`.\n *\n * Also note we are passing a type to the `fetch()` function. This is optional, but it will help you\n * avoid mistakes when working with the data returned from the API. You can also use the `as` keyword to\n * cast the data returned from the API.\n *\n * These are equivalent:\n * ```ts\n * const joke = await fetch<TheChuckNorrisJoke>("https://icanhazdadjoke.com/");\n * const joke = await fetch("https://icanhazdadjoke.com/") as TheChuckNorrisJoke;\n * ```\n *\n * Alternatively, you can drop the type completely:\n *\n * ```ts\n * fetch("https://icanhazdadjoke.com")\n * ```\n */\ninterface TheChuckNorrisJoke {\n id: string;\n joke: string;\n status: number;\n}\n\nWhen(a.ConfigMap)\n .IsCreatedOrUpdated()\n .WithLabel("chuck-norris")\n .Mutate(cm => cm.SetLabel("got-jokes", "true"))\n .Watch(async cm => {\n const jokeURL = "https://icanhazdadjoke.com";\n\n const mockAgent: MockAgent = new MockAgent();\n setGlobalDispatcher(mockAgent);\n const mockClient = mockAgent.get(jokeURL);\n mockClient.intercept({ path: "/", method: "GET" }).reply(\n 200,\n {\n id: "R7UfaahVfFd",\n joke: "Funny joke goes here.",\n status: 200,\n },\n {\n headers: {\n "Content-Type": "application/json; charset=utf-8",\n },\n },\n );\n\n // Try/catch is not needed as a response object will always be returned\n const response = await fetch<TheChuckNorrisJoke>(jokeURL, {\n headers: {\n Accept: "application/json",\n },\n });\n\n // Instead, check the `response.ok` field\n if (response.ok) {\n const { joke } = response.data;\n // Add Joke to the Store\n await Store.setItemAndWait(jokeURL, joke);\n // Add the Chuck Norris joke to the configmap\n try {\n await K8s(kind.ConfigMap).Apply({\n metadata: {\n name: cm.metadata.name,\n namespace: cm.metadata.namespace,\n },\n data: {\n "chuck-says": Store.getItem(jokeURL),\n },\n });\n } catch (error) {\n Log.error(error, "Failed to apply ConfigMap using server-side apply.", {\n cm,\n });\n }\n }\n\n // You can also assert on different HTTP response codes\n if (response.status === fetchStatus.NOT_FOUND) {\n // Do something else\n return;\n }\n });\n\n/**\n * ---------------------------------------------------------------------------------------------------\n * Mutate Action (Secret Base64 Handling) *\n * ---------------------------------------------------------------------------------------------------\n *\n * The K8s JS client provides incomplete support for base64 encoding/decoding handling for secrets,\n * unlike the GO client. To make this less painful, Pepr automatically handles base64 encoding/decoding\n * secret data before and after the action is executed.\n */\nWhen(a.Secret)\n .IsCreated()\n .WithName("secret-1")\n .Mutate(request => {\n const secret = request.Raw;\n\n // This will be encoded at the end of all processing back to base64: "Y2hhbmdlLXdpdGhvdXQtZW5jb2Rpbmc="\n secret.data.magic = "change-without-encoding";\n\n // You can modify the data directly, and it will be encoded at the end of all processing\n secret.data.example += " - modified by Pepr";\n });\n\n/**\n * ---------------------------------------------------------------------------------------------------\n * Mutate Action (Untyped Custom Resource) *\n * ---------------------------------------------------------------------------------------------------\n *\n * Out of the box, Pepr supports all the standard Kubernetes objects. However, you can also create\n * your own types. This is useful if you are working with an Operator that creates custom resources.\n * There are two ways to do this, the first is to use the `When()` function with a `GenericKind`,\n * the second is to create a new class that extends `GenericKind` and use the `RegisterKind()` function.\n *\n * This example shows how to use the `When()` function with a `GenericKind`. Note that you\n * must specify the `group`, `version`, and `kind` of the object (if applicable). This is how Pepr knows\n * if the action should be triggered or not. Since we are using a `GenericKind`,\n * Pepr will not be able to provide any intellisense for the object, so you will need to refer to the\n * Kubernetes API documentation for the object you are working with.\n *\n * You will need to wait for the CRD in `hello-pepr.samples.yaml` to be created, then you can apply\n *\n * ```yaml\n * apiVersion: pepr.dev/v1\n * kind: Unicorn\n * metadata:\n * name: example-1\n * namespace: pepr-demo\n * spec:\n * message: replace-me\n * counter: 0\n * ```\n */\nWhen(a.GenericKind, {\n group: "pepr.dev",\n version: "v1",\n kind: "Unicorn",\n})\n .IsCreated()\n .WithName("example-1")\n .Mutate(request => {\n request.Merge({\n spec: {\n message: "Hello Pepr without type data!",\n counter: Math.random(),\n },\n });\n });\n\n/**\n * ---------------------------------------------------------------------------------------------------\n * Mutate Action (Typed Custom Resource) *\n * ---------------------------------------------------------------------------------------------------\n *\n * This example shows how to use the `RegisterKind()` function to create a new type. This is useful\n * if you are working with an Operator that creates custom resources and you want to have intellisense\n * for the object. Note that you must specify the `group`, `version`, and `kind` of the object (if applicable)\n * as this is how Pepr knows if the action should be triggered or not.\n *\n * Once you register a new Kind with Pepr, you can use the `When()` function with the new Kind. Ideally,\n * you should register custom Kinds at the top of your Capability file or Pepr Module so they are available\n * to all actions, but we are putting it here for demonstration purposes.\n *\n * You will need to wait for the CRD in `hello-pepr.samples.yaml` to be created, then you can apply\n *\n * ```yaml\n * apiVersion: pepr.dev/v1\n * kind: Unicorn\n * metadata:\n * name: example-2\n * namespace: pepr-demo\n * spec:\n * message: replace-me\n * counter: 0\n * ```*\n */\nclass UnicornKind extends a.GenericKind {\n spec: {\n /**\n * JSDoc comments can be added to explain more details about the field.\n *\n * @example\n * ```ts\n * request.Raw.spec.message = "Hello Pepr!";\n * ```\n * */\n message: string;\n counter: number;\n };\n}\n\nRegisterKind(UnicornKind, {\n group: "pepr.dev",\n version: "v1",\n kind: "Unicorn",\n});\n\nWhen(UnicornKind)\n .IsCreated()\n .WithName("example-2")\n .Mutate(request => {\n request.Merge({\n spec: {\n message: "Hello Pepr with type data!",\n counter: Math.random(),\n },\n });\n });\n\n/**\n * A callback function that is called once the Pepr Store is fully loaded.\n */\nStore.onReady(data => {\n Log.info(data, "Pepr Store Ready");\n});\n';
8857
+ var packageJSON = { name: "pepr", description: "Kubernetes application engine", author: "Defense Unicorns", homepage: "https://github.com/defenseunicorns/pepr", license: "Apache-2.0", bin: "dist/cli.js", repository: "defenseunicorns/pepr", engines: { node: ">=18.0.0" }, files: ["/dist", "/src", "!src/**/*.test.ts", "!src/fixtures/**", "!dist/**/*.test.d.ts*", "!src/cli/docs/**"], version: "0.50.0", main: "dist/lib.js", types: "dist/lib.d.ts", scripts: { ci: "npm ci", "gen-data-json": "node hack/build-template-data.js", prebuild: "rm -fr dist/* && npm run gen-data-json", build: "tsc && node build.mjs && npm pack", "build:image": "npm run build && docker buildx build --output type=docker --tag pepr:dev .", "build:image:unicorn": "npm run build && docker buildx build --output type=docker --tag pepr:dev $(node scripts/read-unicorn-build-args.mjs) .", "set:version": "node scripts/set-version.js", test: "npm run test:unit && npm run test:journey && npm run test:journey-wasm", "test:artifacts": "npm run build && jest src/build-artifact.test.ts", "test:docs": "jest --verbose src/cli/docs/*.test.ts", "test:integration": "npm run test:integration:prep && npm run test:integration:run", "test:integration:prep": "./integration/prep.sh", "test:integration:run": "jest --maxWorkers=4 integration", "test:journey": "npm run test:journey:k3d && npm run build && npm run test:journey:image && npm run test:journey:run", "test:journey-wasm": "npm run test:journey:k3d && npm run build && npm run test:journey:image && npm run test:journey:run-wasm", "test:journey-wasm:unicorn": "npm run test:journey:k3d && npm run build && npm run test:journey:image:unicorn && npm run test:journey:run-wasm", "test:journey:image": "docker buildx build --output type=docker --tag pepr:dev . && k3d image import pepr:dev -c pepr-dev", "test:journey:image:unicorn": "npm run build && docker buildx build --output type=docker --tag pepr:dev $(node scripts/read-unicorn-build-args.mjs) . && k3d image import pepr:dev -c pepr-dev", "test:journey:k3d": "k3d cluster delete pepr-dev && k3d cluster create pepr-dev --k3s-arg '--debug@server:0' --wait && kubectl rollout status deployment -n kube-system", "test:journey:run": "jest --detectOpenHandles journey/entrypoint.test.ts && npm run test:journey:upgrade", "test:journey:run-wasm": "jest --detectOpenHandles journey/entrypoint-wasm.test.ts", "test:journey:unicorn": "npm run test:journey:k3d && npm run test:journey:image:unicorn && npm run test:journey:run", "test:journey:upgrade": "npm run test:journey:k3d && npm run test:journey:image && jest --detectOpenHandles journey/pepr-upgrade.test.ts", "test:unit": 'npm run gen-data-json && jest src --coverage --detectOpenHandles --coverageDirectory=./coverage --testPathIgnorePatterns="build-artifact.test.ts|src/cli/docs/.*\\.test\\.ts"', "format:check": "eslint src && prettier --config .prettierrc src --check", "format:fix": "eslint src --fix && prettier --config .prettierrc src --write", prepare: `if [ "$NODE_ENV" != 'production' ]; then husky; fi` }, dependencies: { "@types/ramda": "0.30.2", express: "5.1.0", "fast-json-patch": "3.1.1", heredoc: "^1.3.1", "http-status-codes": "^2.3.0", "json-pointer": "^0.6.2", "kubernetes-fluent-client": "3.5.3", pino: "9.6.0", "pino-pretty": "13.0.0", "prom-client": "15.1.3", ramda: "0.30.1", sigstore: "3.1.0", "ts-morph": "^25.0.1" }, devDependencies: { "@commitlint/cli": "19.8.1", "@commitlint/config-conventional": "19.8.1", "@fast-check/jest": "^2.0.1", "@jest/globals": "29.7.0", "@types/eslint": "9.6.1", "@types/express": "5.0.1", "@types/json-pointer": "^1.0.34", "@types/node": "22.x.x", "@types/node-forge": "1.3.11", "@types/uuid": "10.0.0", "fast-check": "^4.0.0", globals: "^16.0.0", husky: "^9.1.6", jest: "29.7.0", "js-yaml": "^4.1.0", shellcheck: "^3.0.0", "ts-jest": "29.3.2", undici: "^7.0.1" }, overrides: { glob: "^9.0.0" }, peerDependencies: { "@types/prompts": "2.4.9", "@typescript-eslint/eslint-plugin": "8.23.0", "@typescript-eslint/parser": "8.23.0", commander: "13.1.0", esbuild: "0.25.0", eslint: "8.57.0", "node-forge": "1.3.1", prettier: "3.4.2", prompts: "2.4.2", typescript: "5.7.3", uuid: "11.0.5" } };
8840
8858
 
8841
8859
  // src/cli/init/utils.ts
8842
8860
  var import_fs4 = require("fs");
@@ -8862,11 +8880,11 @@ async function createDir(dir) {
8862
8880
  }
8863
8881
  }
8864
8882
  }
8865
- function write(path4, data) {
8883
+ function write(path3, data) {
8866
8884
  if (typeof data !== "string") {
8867
8885
  data = JSON.stringify(data, null, 2);
8868
8886
  }
8869
- return import_fs4.promises.writeFile(path4, data);
8887
+ return import_fs4.promises.writeFile(path3, data);
8870
8888
  }
8871
8889
 
8872
8890
  // src/cli/init/templates.ts
@@ -8966,19 +8984,8 @@ var prettier = {
8966
8984
  data: prettierrc_default
8967
8985
  };
8968
8986
  var eslint = {
8969
- path: "eslint.config.mjs",
8970
- data: (0, import_fs5.readFileSync)(
8971
- import_path2.default.resolve(
8972
- (() => {
8973
- const fullPath = __dirname;
8974
- const lengthOfSuffix = "pepr/".length;
8975
- const lastPeprIndex = fullPath.lastIndexOf("pepr/");
8976
- return fullPath.substring(0, lastPeprIndex + lengthOfSuffix);
8977
- })(),
8978
- "src/templates/eslint.config.mjs"
8979
- ),
8980
- "utf-8"
8981
- )
8987
+ path: ".eslintrc.json",
8988
+ data: eslintrc_template_default
8982
8989
  };
8983
8990
 
8984
8991
  // src/cli/build.ts
@@ -8988,19 +8995,19 @@ var import_commander = require("commander");
8988
8995
  var import_eslint = require("eslint");
8989
8996
 
8990
8997
  // src/cli/format/format.helpers.ts
8991
- var import_fs6 = require("fs");
8998
+ var import_fs5 = require("fs");
8992
8999
  var import_prettier = require("prettier");
8993
9000
  async function formatWithPrettier(results, validateOnly) {
8994
9001
  let hasFailure = false;
8995
9002
  for (const { filePath } of results) {
8996
- const content = await import_fs6.promises.readFile(filePath, "utf8");
9003
+ const content = await import_fs5.promises.readFile(filePath, "utf8");
8997
9004
  const cfg = await (0, import_prettier.resolveConfig)(filePath);
8998
9005
  const formatted = await (0, import_prettier.format)(content, { filepath: filePath, ...cfg });
8999
9006
  if (validateOnly && formatted !== content) {
9000
9007
  hasFailure = true;
9001
9008
  console.error(`File ${filePath} is not formatted correctly`);
9002
9009
  } else {
9003
- await import_fs6.promises.writeFile(filePath, formatted);
9010
+ await import_fs5.promises.writeFile(filePath, formatted);
9004
9011
  }
9005
9012
  }
9006
9013
  return hasFailure;
@@ -9047,7 +9054,7 @@ async function peprFormat(validateOnly) {
9047
9054
  }
9048
9055
 
9049
9056
  // src/lib/included-files.ts
9050
- var import_fs7 = require("fs");
9057
+ var import_fs6 = require("fs");
9051
9058
  async function createDockerfile(version3, description, includedFiles) {
9052
9059
  const file = `
9053
9060
  # Use an official Node.js runtime as the base image
@@ -9059,14 +9066,14 @@ async function createDockerfile(version3, description, includedFiles) {
9059
9066
  ${includedFiles.map((f) => `ADD ${f} ${f}`).join("\n")}
9060
9067
 
9061
9068
  `;
9062
- await import_fs7.promises.writeFile("Dockerfile.controller", file, { encoding: "utf-8" });
9069
+ await import_fs6.promises.writeFile("Dockerfile.controller", file, { encoding: "utf-8" });
9063
9070
  }
9064
9071
 
9065
9072
  // src/cli/build.helpers.ts
9066
9073
  var import_child_process2 = require("child_process");
9067
9074
  var import_esbuild = require("esbuild");
9068
- var import_path3 = require("path");
9069
- var import_fs9 = require("fs");
9075
+ var import_path2 = require("path");
9076
+ var import_fs8 = require("fs");
9070
9077
 
9071
9078
  // src/lib/assets/yaml/generateAllYaml.ts
9072
9079
  var import_crypto2 = __toESM(require("crypto"));
@@ -9381,7 +9388,7 @@ function getDeployment(assets, hash, buildTimestamp, imagePullSecret) {
9381
9388
  }
9382
9389
  function getModuleSecret(name2, data, hash) {
9383
9390
  const compressed = (0, import_zlib.gzipSync)(data);
9384
- const path4 = `module-${hash}.js.gz`;
9391
+ const path3 = `module-${hash}.js.gz`;
9385
9392
  const compressedData = compressed.toString("base64");
9386
9393
  if (secretOverLimit(compressedData)) {
9387
9394
  const error = new Error(`Module secret for ${name2} is over the 1MB limit`);
@@ -9396,14 +9403,14 @@ function getModuleSecret(name2, data, hash) {
9396
9403
  },
9397
9404
  type: "Opaque",
9398
9405
  data: {
9399
- [path4]: compressed.toString("base64")
9406
+ [path3]: compressed.toString("base64")
9400
9407
  }
9401
9408
  };
9402
9409
  }
9403
9410
  }
9404
9411
 
9405
9412
  // src/lib/assets/yaml/generateAllYaml.ts
9406
- var import_fs8 = require("fs");
9413
+ var import_fs7 = require("fs");
9407
9414
 
9408
9415
  // src/lib/assets/webhooks.ts
9409
9416
  var import_ramda = require("ramda");
@@ -9490,8 +9497,8 @@ async function webhookConfigGenerator(assets, mutateOrValidate, timeoutSeconds =
9490
9497
 
9491
9498
  // src/lib/assets/yaml/generateAllYaml.ts
9492
9499
  async function generateAllYaml(assets, deployments) {
9493
- const { name: name2, tls, apiPath, path: path4, config } = assets;
9494
- const code = await import_fs8.promises.readFile(path4);
9500
+ const { name: name2, tls, apiPath, path: path3, config } = assets;
9501
+ const code = await import_fs7.promises.readFile(path3);
9495
9502
  const hash = import_crypto2.default.createHash("sha256").update(code).digest("hex");
9496
9503
  const resources = [
9497
9504
  getNamespace(assets.config.customLabels?.namespace),
@@ -9524,18 +9531,18 @@ async function generateAllYaml(assets, deployments) {
9524
9531
 
9525
9532
  // src/lib/assets/yaml/generateZarfYaml.ts
9526
9533
  var import_client_node5 = require("@kubernetes/client-node");
9527
- function generateZarfYamlGeneric(assets, path4, type) {
9534
+ function generateZarfYamlGeneric(assets, path3, type) {
9528
9535
  const zarfComponentName = process.env.PEPR_CUSTOM_BUILD_NAME ?? "module";
9529
9536
  const manifestSettings = {
9530
9537
  name: zarfComponentName,
9531
9538
  namespace: "pepr-system",
9532
- files: [path4]
9539
+ files: [path3]
9533
9540
  };
9534
9541
  const chartSettings = {
9535
9542
  name: zarfComponentName,
9536
9543
  namespace: "pepr-system",
9537
9544
  version: `${assets.config.appVersion || "0.0.1"}`,
9538
- localPath: path4
9545
+ localPath: path3
9539
9546
  };
9540
9547
  const component = {
9541
9548
  name: zarfComponentName,
@@ -9635,18 +9642,18 @@ async function generateYamlAndWriteToDisk(obj) {
9635
9642
  const { uuid, imagePullSecret, outputDir: outputDir2, assets, zarf } = obj;
9636
9643
  const yamlFile = `pepr-module-${uuid}.yaml`;
9637
9644
  const chartPath = `${uuid}-chart`;
9638
- const yamlPath = (0, import_path3.resolve)(outputDir2, yamlFile);
9645
+ const yamlPath = (0, import_path2.resolve)(outputDir2, yamlFile);
9639
9646
  try {
9640
9647
  const yaml = await assets.allYaml(generateAllYaml, getDeployment, getWatcher, imagePullSecret);
9641
- const zarfPath = (0, import_path3.resolve)(outputDir2, "zarf.yaml");
9648
+ const zarfPath = (0, import_path2.resolve)(outputDir2, "zarf.yaml");
9642
9649
  let localZarf = "";
9643
9650
  if (zarf === "chart") {
9644
9651
  localZarf = assets.zarfYamlChart(generateZarfYamlGeneric, chartPath);
9645
9652
  } else {
9646
9653
  localZarf = assets.zarfYaml(generateZarfYamlGeneric, yamlFile);
9647
9654
  }
9648
- await import_fs9.promises.writeFile(yamlPath, yaml);
9649
- await import_fs9.promises.writeFile(zarfPath, localZarf);
9655
+ await import_fs8.promises.writeFile(yamlPath, yaml);
9656
+ await import_fs8.promises.writeFile(zarfPath, localZarf);
9650
9657
  await assets.generateHelmChart(webhookConfigGenerator, getWatcher, getModuleSecret, outputDir2);
9651
9658
  console.info(`\u2705 K8s resource for the module saved to ${yamlPath}`);
9652
9659
  } catch (error) {
@@ -9702,7 +9709,7 @@ function build_default(program2) {
9702
9709
  ).action(async (opts) => {
9703
9710
  outputDir = await handleCustomOutputDir(opts.outputDir);
9704
9711
  const buildModuleResult = await buildModule(void 0, opts.entryPoint, opts.embed);
9705
- const { cfg, path: path4 } = buildModuleResult;
9712
+ const { cfg, path: path3 } = buildModuleResult;
9706
9713
  if (opts.customName) {
9707
9714
  process.env.PEPR_CUSTOM_BUILD_NAME = opts.customName;
9708
9715
  }
@@ -9725,7 +9732,7 @@ function build_default(program2) {
9725
9732
  );
9726
9733
  }
9727
9734
  if (!opts.embed) {
9728
- console.info(`\u2705 Module built successfully at ${path4}`);
9735
+ console.info(`\u2705 Module built successfully at ${path3}`);
9729
9736
  return;
9730
9737
  }
9731
9738
  const assets = new Assets(
@@ -9739,7 +9746,7 @@ function build_default(program2) {
9739
9746
  // Can override the rbacMode with the CLI option
9740
9747
  rbacMode: determineRbacMode(opts, cfg)
9741
9748
  },
9742
- path4,
9749
+ path3,
9743
9750
  opts.withPullSecret === "" ? [] : [opts.withPullSecret]
9744
9751
  );
9745
9752
  if (image !== "") assets.image = image;
@@ -9758,19 +9765,19 @@ var externalLibs = Object.keys(dependencies);
9758
9765
  externalLibs.push("pepr");
9759
9766
  externalLibs.push("@kubernetes/client-node");
9760
9767
  async function loadModule(entryPoint = peprTS2) {
9761
- const entryPointPath = (0, import_path4.resolve)(".", entryPoint);
9762
- const modulePath = (0, import_path4.dirname)(entryPointPath);
9763
- const cfgPath = (0, import_path4.resolve)(modulePath, "package.json");
9768
+ const entryPointPath = (0, import_path3.resolve)(".", entryPoint);
9769
+ const modulePath = (0, import_path3.dirname)(entryPointPath);
9770
+ const cfgPath = (0, import_path3.resolve)(modulePath, "package.json");
9764
9771
  try {
9765
- await import_fs10.promises.access(cfgPath);
9766
- await import_fs10.promises.access(entryPointPath);
9772
+ await import_fs9.promises.access(cfgPath);
9773
+ await import_fs9.promises.access(entryPointPath);
9767
9774
  } catch {
9768
9775
  console.error(
9769
9776
  `Could not find ${cfgPath} or ${entryPointPath} in the current directory. Please run this command from the root of your module's directory.`
9770
9777
  );
9771
9778
  process.exit(1);
9772
9779
  }
9773
- const moduleText = await import_fs10.promises.readFile(cfgPath, { encoding: "utf-8" });
9780
+ const moduleText = await import_fs9.promises.readFile(cfgPath, { encoding: "utf-8" });
9774
9781
  const cfg = JSON.parse(moduleText);
9775
9782
  const { uuid } = cfg.pepr;
9776
9783
  const name2 = `pepr-${uuid}.js`;
@@ -9783,13 +9790,13 @@ async function loadModule(entryPoint = peprTS2) {
9783
9790
  entryPointPath,
9784
9791
  modulePath,
9785
9792
  name: name2,
9786
- path: (0, import_path4.resolve)(outputDir, name2),
9793
+ path: (0, import_path3.resolve)(outputDir, name2),
9787
9794
  uuid
9788
9795
  };
9789
9796
  }
9790
9797
  async function buildModule(reloader, entryPoint = peprTS2, embed = true) {
9791
9798
  try {
9792
- const { cfg, modulePath, path: path4, uuid } = await loadModule(entryPoint);
9799
+ const { cfg, modulePath, path: path3, uuid } = await loadModule(entryPoint);
9793
9800
  await checkFormat();
9794
9801
  const npmRoot = (0, import_child_process3.execFileSync)("npm", ["root"]).toString().trim();
9795
9802
  const args = ["--project", `${modulePath}/tsconfig.json`, "--outdir", outputDir];
@@ -9803,7 +9810,7 @@ async function buildModule(reloader, entryPoint = peprTS2, embed = true) {
9803
9810
  legalComments: "external",
9804
9811
  metafile: true,
9805
9812
  minify: true,
9806
- outfile: path4,
9813
+ outfile: path3,
9807
9814
  plugins: [
9808
9815
  {
9809
9816
  name: "reload-server",
@@ -9828,12 +9835,12 @@ async function buildModule(reloader, entryPoint = peprTS2, embed = true) {
9828
9835
  }
9829
9836
  if (!embed) {
9830
9837
  ctxCfg.minify = false;
9831
- ctxCfg.outfile = (0, import_path4.resolve)(outputDir, (0, import_path4.basename)(entryPoint, (0, import_path4.extname)(entryPoint))) + ".js";
9838
+ ctxCfg.outfile = (0, import_path3.resolve)(outputDir, (0, import_path3.basename)(entryPoint, (0, import_path3.extname)(entryPoint))) + ".js";
9832
9839
  ctxCfg.packages = "external";
9833
9840
  ctxCfg.treeShaking = false;
9834
9841
  }
9835
9842
  const ctx = await watchForChanges(ctxCfg, reloader);
9836
- return { ctx, path: path4, cfg, uuid };
9843
+ return { ctx, path: path3, cfg, uuid };
9837
9844
  } catch (e) {
9838
9845
  handleModuleBuildError(e);
9839
9846
  }
@@ -9882,7 +9889,7 @@ var import_prompts = __toESM(require("prompts"));
9882
9889
 
9883
9890
  // src/lib/assets/deploy.ts
9884
9891
  var import_crypto3 = __toESM(require("crypto"));
9885
- var import_fs11 = require("fs");
9892
+ var import_fs10 = require("fs");
9886
9893
  var import_kubernetes_fluent_client3 = require("kubernetes-fluent-client");
9887
9894
 
9888
9895
  // src/lib/k8s.ts
@@ -9991,7 +9998,7 @@ async function deployWebhook(assets, force, webhookTimeout) {
9991
9998
  logger_default.info("Applying the Pepr Store CRD if it doesn't exist");
9992
9999
  await (0, import_kubernetes_fluent_client3.K8s)(import_kubernetes_fluent_client3.kind.CustomResourceDefinition).Apply(peprStoreCRD, { force });
9993
10000
  if (assets.host) return;
9994
- const code = await import_fs11.promises.readFile(assets.path);
10001
+ const code = await import_fs10.promises.readFile(assets.path);
9995
10002
  if (!code.length) throw new Error("No code provided");
9996
10003
  const hash = import_crypto3.default.createHash("sha256").update(code).digest("hex");
9997
10004
  await setupRBAC(assets.name, assets.capabilities, force, assets.config);
@@ -10193,7 +10200,7 @@ function deploy_default(program2) {
10193
10200
  var import_prompts2 = __toESM(require("prompts"));
10194
10201
  var import_child_process4 = require("child_process");
10195
10202
  var import_kubernetes_fluent_client5 = require("kubernetes-fluent-client");
10196
- var import_fs12 = require("fs");
10203
+ var import_fs11 = require("fs");
10197
10204
  function dev_default(program2) {
10198
10205
  program2.command("dev").description("Setup a local webhook development environment").option("-h, --host [host]", "Host to listen on", "host.k3d.internal").option("--confirm", "Skip confirmation prompt").action(async (opts) => {
10199
10206
  if (!opts.confirm) {
@@ -10206,25 +10213,25 @@ function dev_default(program2) {
10206
10213
  process.exit(0);
10207
10214
  }
10208
10215
  }
10209
- const { cfg, path: path4 } = await loadModule();
10216
+ const { cfg, path: path3 } = await loadModule();
10210
10217
  const webhook = new Assets(
10211
10218
  {
10212
10219
  ...cfg.pepr,
10213
10220
  description: cfg.description
10214
10221
  },
10215
- path4,
10222
+ path3,
10216
10223
  [],
10217
10224
  opts.host
10218
10225
  );
10219
- await import_fs12.promises.writeFile("insecure-tls.crt", webhook.tls.pem.crt);
10220
- await import_fs12.promises.writeFile("insecure-tls.key", webhook.tls.pem.key);
10226
+ await import_fs11.promises.writeFile("insecure-tls.crt", webhook.tls.pem.crt);
10227
+ await import_fs11.promises.writeFile("insecure-tls.key", webhook.tls.pem.key);
10221
10228
  try {
10222
10229
  let program3;
10223
10230
  const name2 = `pepr-${cfg.pepr.uuid}`;
10224
10231
  const scheduleStore = `pepr-${cfg.pepr.uuid}-schedule`;
10225
10232
  const store = `pepr-${cfg.pepr.uuid}-store`;
10226
10233
  const runFork = async () => {
10227
- console.info(`Running module ${path4}`);
10234
+ console.info(`Running module ${path3}`);
10228
10235
  await webhook.deploy(deployWebhook, false, 30);
10229
10236
  try {
10230
10237
  validateCapabilityNames(webhook.capabilities);
@@ -10232,7 +10239,7 @@ function dev_default(program2) {
10232
10239
  console.error(`Error validating capability names:`, e);
10233
10240
  process.exit(1);
10234
10241
  }
10235
- program3 = (0, import_child_process4.fork)(path4, {
10242
+ program3 = (0, import_child_process4.fork)(path3, {
10236
10243
  env: {
10237
10244
  ...process.env,
10238
10245
  LOG_LEVEL: process.env.LOG_LEVEL ?? "debug",
@@ -10366,11 +10373,11 @@ ${filteredFailures.length > 0 ? "\u274C" : "\u2705"} VALIDATE ${name2} (${uid
10366
10373
 
10367
10374
  // src/cli/init/index.ts
10368
10375
  var import_child_process5 = require("child_process");
10369
- var import_path5 = require("path");
10376
+ var import_path4 = require("path");
10370
10377
  var import_prompts4 = __toESM(require("prompts"));
10371
10378
 
10372
10379
  // src/cli/init/walkthrough.ts
10373
- var import_fs13 = require("fs");
10380
+ var import_fs12 = require("fs");
10374
10381
  var import_prompts3 = __toESM(require("prompts"));
10375
10382
 
10376
10383
  // src/cli/init/enums.ts
@@ -10417,7 +10424,7 @@ async function setName(name2) {
10417
10424
  validate: async (val) => {
10418
10425
  try {
10419
10426
  const name3 = sanitizeName(val);
10420
- await import_fs13.promises.access(name3, import_fs13.promises.constants.F_OK);
10427
+ await import_fs12.promises.access(name3, import_fs12.promises.constants.F_OK);
10421
10428
  return "A directory with this name already exists";
10422
10429
  } catch {
10423
10430
  return val.length > 2 || "The name must be at least 3 characters long";
@@ -10562,8 +10569,8 @@ function init_default(program2) {
10562
10569
  }
10563
10570
  async function setupProjectStructure(dirName) {
10564
10571
  await createDir(dirName);
10565
- await createDir((0, import_path5.resolve)(dirName, ".vscode"));
10566
- await createDir((0, import_path5.resolve)(dirName, "capabilities"));
10572
+ await createDir((0, import_path4.resolve)(dirName, ".vscode"));
10573
+ await createDir((0, import_path4.resolve)(dirName, "capabilities"));
10567
10574
  }
10568
10575
  async function createProjectFiles(dirName, packageJSON2) {
10569
10576
  const files = [
@@ -10582,10 +10589,10 @@ async function createProjectFiles(dirName, packageJSON2) {
10582
10589
  { dir: "capabilities", path: helloPepr.path, data: helloPepr.data }
10583
10590
  ];
10584
10591
  for (const file of files) {
10585
- await write((0, import_path5.resolve)(dirName, file.path), file.data);
10592
+ await write((0, import_path4.resolve)(dirName, file.path), file.data);
10586
10593
  }
10587
10594
  for (const file of nestedFiles) {
10588
- await write((0, import_path5.resolve)(dirName, file.dir, file.path), file.data);
10595
+ await write((0, import_path4.resolve)(dirName, file.dir, file.path), file.data);
10589
10596
  }
10590
10597
  }
10591
10598
  var doPostInitActions = (dirName) => {
@@ -10643,8 +10650,8 @@ var RootCmd = class extends import_commander2.Command {
10643
10650
 
10644
10651
  // src/cli/update/index.ts
10645
10652
  var import_child_process6 = require("child_process");
10646
- var import_fs14 = __toESM(require("fs"));
10647
- var import_path6 = require("path");
10653
+ var import_fs13 = __toESM(require("fs"));
10654
+ var import_path5 = require("path");
10648
10655
  var import_prompts5 = __toESM(require("prompts"));
10649
10656
  function update_default(program2) {
10650
10657
  program2.command("update").description("Update this Pepr module. Not recommended for prod as it may change files.").option("--skip-template-update", "Skip updating the template files").action(async (opts) => {
@@ -10663,8 +10670,8 @@ function update_default(program2) {
10663
10670
  let packageLockContent = "";
10664
10671
  let foundPackageLock = false;
10665
10672
  try {
10666
- if (import_fs14.default.existsSync("./package-lock.json")) {
10667
- packageLockContent = import_fs14.default.readFileSync("./package-lock.json", "utf-8");
10673
+ if (import_fs13.default.existsSync("./package-lock.json")) {
10674
+ packageLockContent = import_fs13.default.readFileSync("./package-lock.json", "utf-8");
10668
10675
  foundPackageLock = true;
10669
10676
  }
10670
10677
  } catch {
@@ -10694,17 +10701,17 @@ function update_default(program2) {
10694
10701
  console.log("Updating Pepr config and template tiles...");
10695
10702
  try {
10696
10703
  if (!opts.skipTemplateUpdate) {
10697
- await write((0, import_path6.resolve)(prettier.path), prettier.data);
10698
- await write((0, import_path6.resolve)(tsConfig.path), tsConfig.data);
10699
- await write((0, import_path6.resolve)(".vscode", snippet.path), snippet.data);
10700
- await write((0, import_path6.resolve)(".vscode", codeSettings.path), codeSettings.data);
10701
- const samplePath = (0, import_path6.resolve)("capabilities", samplesYaml.path);
10702
- if (import_fs14.default.existsSync(samplePath)) {
10703
- import_fs14.default.unlinkSync(samplePath);
10704
+ await write((0, import_path5.resolve)(prettier.path), prettier.data);
10705
+ await write((0, import_path5.resolve)(tsConfig.path), tsConfig.data);
10706
+ await write((0, import_path5.resolve)(".vscode", snippet.path), snippet.data);
10707
+ await write((0, import_path5.resolve)(".vscode", codeSettings.path), codeSettings.data);
10708
+ const samplePath = (0, import_path5.resolve)("capabilities", samplesYaml.path);
10709
+ if (import_fs13.default.existsSync(samplePath)) {
10710
+ import_fs13.default.unlinkSync(samplePath);
10704
10711
  await write(samplePath, samplesYaml.data);
10705
10712
  }
10706
- const tsPath = (0, import_path6.resolve)("capabilities", helloPepr.path);
10707
- if (import_fs14.default.existsSync(tsPath)) {
10713
+ const tsPath = (0, import_path5.resolve)("capabilities", helloPepr.path);
10714
+ if (import_fs13.default.existsSync(tsPath)) {
10708
10715
  await write(tsPath, helloPepr.data);
10709
10716
  }
10710
10717
  }
@@ -10745,8 +10752,8 @@ function kfc_default(program2) {
10745
10752
 
10746
10753
  // src/cli/crd/create.ts
10747
10754
  var import_commander3 = require("commander");
10748
- var import_fs15 = require("fs");
10749
- var import_path7 = __toESM(require("path"));
10755
+ var import_fs14 = require("fs");
10756
+ var import_path6 = __toESM(require("path"));
10750
10757
  var create = new import_commander3.Command("create").description("Create a new CRD TypeScript definition").requiredOption("--group <group>", "API group (e.g. cache)").requiredOption("--version <version>", "API version (e.g. v1alpha1)").requiredOption("--kind <kind>", "Kind name (e.g. Memcached)").option("--domain <domain>", "Optional domain (e.g. pepr.dev)", "pepr.dev").option(
10751
10758
  "--scope <Namespaced | Cluster>",
10752
10759
  "Whether the resulting custom resource is cluster- or namespace-scoped",
@@ -10754,9 +10761,9 @@ var create = new import_commander3.Command("create").description("Create a new C
10754
10761
  "Namespaced"
10755
10762
  ).option("--plural <plural>", "Plural name (e.g. memcacheds)", "").option("--shortName <shortName>", "Short name (e.g. mc)", "").action(async ({ group: group2, version: version3, kind: kind8, domain, scope, plural: plural2, shortName }) => {
10756
10763
  console.log("This feature is currently in alpha.\n");
10757
- const outputDir2 = import_path7.default.resolve(`./api/${version3}`);
10764
+ const outputDir2 = import_path6.default.resolve(`./api/${version3}`);
10758
10765
  await createDirectoryIfNotExists(outputDir2);
10759
- await import_fs15.promises.writeFile(
10766
+ await import_fs14.promises.writeFile(
10760
10767
  `./api/${version3}/${kind8.toLowerCase()}_types.ts`,
10761
10768
  generateCRDScaffold(group2, version3, kind8, { domain, scope, plural: plural2, shortName })
10762
10769
  );
@@ -10851,8 +10858,8 @@ function validateScope(value) {
10851
10858
 
10852
10859
  // src/cli/crd/generate.ts
10853
10860
  var import_commander4 = require("commander");
10854
- var import_fs16 = __toESM(require("fs"));
10855
- var import_path8 = __toESM(require("path"));
10861
+ var import_fs15 = __toESM(require("fs"));
10862
+ var import_path7 = __toESM(require("path"));
10856
10863
  var import_yaml = __toESM(require_dist());
10857
10864
  var import_ts_morph = require("ts-morph");
10858
10865
 
@@ -10882,24 +10889,24 @@ function extractCRDDetails(content, sourceFile) {
10882
10889
  }
10883
10890
  async function generateCRDs(options) {
10884
10891
  console.log("This feature is currently in alpha.\n");
10885
- const outputDir2 = import_path8.default.resolve(options.output);
10892
+ const outputDir2 = import_path7.default.resolve(options.output);
10886
10893
  await createDirectoryIfNotExists(outputDir2);
10887
10894
  const project = new import_ts_morph.Project();
10888
- const apiRoot = import_path8.default.resolve("api");
10895
+ const apiRoot = import_path7.default.resolve("api");
10889
10896
  const versions = getAPIVersions(apiRoot);
10890
10897
  for (const version3 of versions) {
10891
- const sourceFiles = loadVersionFiles(project, import_path8.default.join(apiRoot, version3));
10898
+ const sourceFiles = loadVersionFiles(project, import_path7.default.join(apiRoot, version3));
10892
10899
  for (const sourceFile of sourceFiles) {
10893
10900
  processSourceFile(sourceFile, version3, outputDir2);
10894
10901
  }
10895
10902
  }
10896
10903
  }
10897
10904
  function getAPIVersions(apiRoot) {
10898
- return import_fs16.default.readdirSync(apiRoot).filter((v) => import_fs16.default.statSync(import_path8.default.join(apiRoot, v)).isDirectory());
10905
+ return import_fs15.default.readdirSync(apiRoot).filter((v) => import_fs15.default.statSync(import_path7.default.join(apiRoot, v)).isDirectory());
10899
10906
  }
10900
10907
  function loadVersionFiles(project, versionDir) {
10901
- const files = import_fs16.default.readdirSync(versionDir).filter((f) => f.endsWith(".ts"));
10902
- const filePaths = files.map((f) => import_path8.default.join(versionDir, f));
10908
+ const files = import_fs15.default.readdirSync(versionDir).filter((f) => f.endsWith(".ts"));
10909
+ const filePaths = files.map((f) => import_path7.default.join(versionDir, f));
10903
10910
  return project.addSourceFilesAtPaths(filePaths);
10904
10911
  }
10905
10912
  function processSourceFile(sourceFile, version3, outputDir2) {
@@ -10927,8 +10934,8 @@ function processSourceFile(sourceFile, version3, outputDir2) {
10927
10934
  specSchema,
10928
10935
  conditionSchema
10929
10936
  });
10930
- const outPath = import_path8.default.join(outputDir2, `${kind8.toLowerCase()}.yaml`);
10931
- import_fs16.default.writeFileSync(outPath, (0, import_yaml.stringify)(crd), "utf8");
10937
+ const outPath = import_path7.default.join(outputDir2, `${kind8.toLowerCase()}.yaml`);
10938
+ import_fs15.default.writeFileSync(outPath, (0, import_yaml.stringify)(crd), "utf8");
10932
10939
  console.log(`\u2714 Created ${outPath}`);
10933
10940
  }
10934
10941
  function extractSingleLineComment(content, label) {