pepr 0.49.0-nightly.9 → 0.50.0-nightly.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/format/format.helpers.d.ts.map +1 -0
- package/dist/cli/{format.d.ts → format/index.d.ts} +2 -2
- package/dist/cli/format/index.d.ts.map +1 -0
- package/dist/cli/init/templates.d.ts +1 -18
- package/dist/cli/init/templates.d.ts.map +1 -1
- package/dist/cli/update/index.d.ts +3 -0
- package/dist/cli/update/index.d.ts.map +1 -0
- package/dist/cli.js +193 -184
- package/dist/controller.js +1 -1
- package/package.json +6 -6
- package/src/cli/{format.ts → format/index.ts} +1 -1
- package/src/cli/init/templates.ts +17 -3
- package/src/cli/{update.ts → update/index.ts} +30 -3
- package/src/templates/capabilities/hello-pepr.ts +1 -1
- package/src/templates/eslint.config.mjs +45 -0
- package/dist/cli/format.d.ts.map +0 -1
- package/dist/cli/format.helpers.d.ts.map +0 -1
- package/dist/cli/update.d.ts +0 -3
- package/dist/cli/update.d.ts.map +0 -1
- package/src/templates/.eslintrc.json +0 -6
- package/src/templates/.eslintrc.template.json +0 -18
- /package/dist/cli/{format.helpers.d.ts → format/format.helpers.d.ts} +0 -0
- /package/src/cli/{format.helpers.ts → format/format.helpers.ts} +0 -0
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,
|
|
107
|
-
const ctrl = callVisitor(key, node, visitor,
|
|
106
|
+
function visit_(key, node, visitor, path4) {
|
|
107
|
+
const ctrl = callVisitor(key, node, visitor, path4);
|
|
108
108
|
if (identity.isNode(ctrl) || identity.isPair(ctrl)) {
|
|
109
|
-
replaceNode(key,
|
|
110
|
-
return visit_(key, ctrl, visitor,
|
|
109
|
+
replaceNode(key, path4, ctrl);
|
|
110
|
+
return visit_(key, ctrl, visitor, path4);
|
|
111
111
|
}
|
|
112
112
|
if (typeof ctrl !== "symbol") {
|
|
113
113
|
if (identity.isCollection(node)) {
|
|
114
|
-
|
|
114
|
+
path4 = Object.freeze(path4.concat(node));
|
|
115
115
|
for (let i = 0; i < node.items.length; ++i) {
|
|
116
|
-
const ci = visit_(i, node.items[i], visitor,
|
|
116
|
+
const ci = visit_(i, node.items[i], visitor, path4);
|
|
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
|
-
|
|
128
|
-
const ck = visit_("key", node.key, visitor,
|
|
127
|
+
path4 = Object.freeze(path4.concat(node));
|
|
128
|
+
const ck = visit_("key", node.key, visitor, path4);
|
|
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,
|
|
133
|
+
const cv = visit_("value", node.value, visitor, path4);
|
|
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,
|
|
155
|
-
const ctrl = await callVisitor(key, node, visitor,
|
|
154
|
+
async function visitAsync_(key, node, visitor, path4) {
|
|
155
|
+
const ctrl = await callVisitor(key, node, visitor, path4);
|
|
156
156
|
if (identity.isNode(ctrl) || identity.isPair(ctrl)) {
|
|
157
|
-
replaceNode(key,
|
|
158
|
-
return visitAsync_(key, ctrl, visitor,
|
|
157
|
+
replaceNode(key, path4, ctrl);
|
|
158
|
+
return visitAsync_(key, ctrl, visitor, path4);
|
|
159
159
|
}
|
|
160
160
|
if (typeof ctrl !== "symbol") {
|
|
161
161
|
if (identity.isCollection(node)) {
|
|
162
|
-
|
|
162
|
+
path4 = Object.freeze(path4.concat(node));
|
|
163
163
|
for (let i = 0; i < node.items.length; ++i) {
|
|
164
|
-
const ci = await visitAsync_(i, node.items[i], visitor,
|
|
164
|
+
const ci = await visitAsync_(i, node.items[i], visitor, path4);
|
|
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
|
-
|
|
176
|
-
const ck = await visitAsync_("key", node.key, visitor,
|
|
175
|
+
path4 = Object.freeze(path4.concat(node));
|
|
176
|
+
const ck = await visitAsync_("key", node.key, visitor, path4);
|
|
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,
|
|
181
|
+
const cv = await visitAsync_("value", node.value, visitor, path4);
|
|
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,
|
|
208
|
+
function callVisitor(key, node, visitor, path4) {
|
|
209
209
|
if (typeof visitor === "function")
|
|
210
|
-
return visitor(key, node,
|
|
210
|
+
return visitor(key, node, path4);
|
|
211
211
|
if (identity.isMap(node))
|
|
212
|
-
return visitor.Map?.(key, node,
|
|
212
|
+
return visitor.Map?.(key, node, path4);
|
|
213
213
|
if (identity.isSeq(node))
|
|
214
|
-
return visitor.Seq?.(key, node,
|
|
214
|
+
return visitor.Seq?.(key, node, path4);
|
|
215
215
|
if (identity.isPair(node))
|
|
216
|
-
return visitor.Pair?.(key, node,
|
|
216
|
+
return visitor.Pair?.(key, node, path4);
|
|
217
217
|
if (identity.isScalar(node))
|
|
218
|
-
return visitor.Scalar?.(key, node,
|
|
218
|
+
return visitor.Scalar?.(key, node, path4);
|
|
219
219
|
if (identity.isAlias(node))
|
|
220
|
-
return visitor.Alias?.(key, node,
|
|
220
|
+
return visitor.Alias?.(key, node, path4);
|
|
221
221
|
return void 0;
|
|
222
222
|
}
|
|
223
|
-
function replaceNode(key,
|
|
224
|
-
const parent =
|
|
223
|
+
function replaceNode(key, path4, node) {
|
|
224
|
+
const parent = path4[path4.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,
|
|
822
|
+
function collectionFromPath(schema, path4, value) {
|
|
823
823
|
let v = value;
|
|
824
|
-
for (let i =
|
|
825
|
-
const k =
|
|
824
|
+
for (let i = path4.length - 1; i >= 0; --i) {
|
|
825
|
+
const k = path4[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 = (
|
|
844
|
+
var isEmptyPath = (path4) => path4 == null || typeof path4 === "object" && !!path4[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(
|
|
875
|
-
if (isEmptyPath(
|
|
874
|
+
addIn(path4, value) {
|
|
875
|
+
if (isEmptyPath(path4))
|
|
876
876
|
this.add(value);
|
|
877
877
|
else {
|
|
878
|
-
const [key, ...rest] =
|
|
878
|
+
const [key, ...rest] = path4;
|
|
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(
|
|
893
|
-
const [key, ...rest] =
|
|
892
|
+
deleteIn(path4) {
|
|
893
|
+
const [key, ...rest] = path4;
|
|
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(
|
|
908
|
-
const [key, ...rest] =
|
|
907
|
+
getIn(path4, keepScalar) {
|
|
908
|
+
const [key, ...rest] = path4;
|
|
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(
|
|
927
|
-
const [key, ...rest] =
|
|
926
|
+
hasIn(path4) {
|
|
927
|
+
const [key, ...rest] = path4;
|
|
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(
|
|
938
|
-
const [key, ...rest] =
|
|
937
|
+
setIn(path4, value) {
|
|
938
|
+
const [key, ...rest] = path4;
|
|
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(
|
|
3444
|
+
addIn(path4, value) {
|
|
3445
3445
|
if (assertCollection(this.contents))
|
|
3446
|
-
this.contents.addIn(
|
|
3446
|
+
this.contents.addIn(path4, 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(
|
|
3522
|
-
if (Collection.isEmptyPath(
|
|
3521
|
+
deleteIn(path4) {
|
|
3522
|
+
if (Collection.isEmptyPath(path4)) {
|
|
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(
|
|
3528
|
+
return assertCollection(this.contents) ? this.contents.deleteIn(path4) : 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(
|
|
3544
|
-
if (Collection.isEmptyPath(
|
|
3543
|
+
getIn(path4, keepScalar) {
|
|
3544
|
+
if (Collection.isEmptyPath(path4))
|
|
3545
3545
|
return !keepScalar && identity.isScalar(this.contents) ? this.contents.value : this.contents;
|
|
3546
|
-
return identity.isCollection(this.contents) ? this.contents.getIn(
|
|
3546
|
+
return identity.isCollection(this.contents) ? this.contents.getIn(path4, 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(
|
|
3558
|
-
if (Collection.isEmptyPath(
|
|
3557
|
+
hasIn(path4) {
|
|
3558
|
+
if (Collection.isEmptyPath(path4))
|
|
3559
3559
|
return this.contents !== void 0;
|
|
3560
|
-
return identity.isCollection(this.contents) ? this.contents.hasIn(
|
|
3560
|
+
return identity.isCollection(this.contents) ? this.contents.hasIn(path4) : 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(
|
|
3578
|
-
if (Collection.isEmptyPath(
|
|
3577
|
+
setIn(path4, value) {
|
|
3578
|
+
if (Collection.isEmptyPath(path4)) {
|
|
3579
3579
|
this.contents = value;
|
|
3580
3580
|
} else if (this.contents == null) {
|
|
3581
|
-
this.contents = Collection.collectionFromPath(this.schema, Array.from(
|
|
3581
|
+
this.contents = Collection.collectionFromPath(this.schema, Array.from(path4), value);
|
|
3582
3582
|
} else if (assertCollection(this.contents)) {
|
|
3583
|
-
this.contents.setIn(
|
|
3583
|
+
this.contents.setIn(path4, 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,
|
|
5538
|
+
visit.itemAtPath = (cst, path4) => {
|
|
5539
5539
|
let item = cst;
|
|
5540
|
-
for (const [field, index] of
|
|
5540
|
+
for (const [field, index] of path4) {
|
|
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,
|
|
5550
|
-
const parent = visit.itemAtPath(cst,
|
|
5551
|
-
const field =
|
|
5549
|
+
visit.parentCollection = (cst, path4) => {
|
|
5550
|
+
const parent = visit.itemAtPath(cst, path4.slice(0, -1));
|
|
5551
|
+
const field = path4[path4.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(
|
|
5558
|
-
let ctrl = visitor(item,
|
|
5557
|
+
function _visit(path4, item, visitor) {
|
|
5558
|
+
let ctrl = visitor(item, path4);
|
|
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(
|
|
5565
|
+
const ci = _visit(Object.freeze(path4.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,
|
|
5576
|
+
ctrl = ctrl(item, path4);
|
|
5577
5577
|
}
|
|
5578
5578
|
}
|
|
5579
|
-
return typeof ctrl === "function" ? ctrl(item,
|
|
5579
|
+
return typeof ctrl === "function" ? ctrl(item, path4) : 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
|
|
7379
|
-
var
|
|
7378
|
+
var import_fs10 = require("fs");
|
|
7379
|
+
var import_path4 = 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(
|
|
7739
|
+
async function createDirectoryIfNotExists(path4) {
|
|
7740
7740
|
try {
|
|
7741
|
-
await import_fs.promises.access(
|
|
7741
|
+
await import_fs.promises.access(path4);
|
|
7742
7742
|
} catch (error) {
|
|
7743
7743
|
if (error.code === "ENOENT") {
|
|
7744
|
-
await import_fs.promises.mkdir(
|
|
7744
|
+
await import_fs.promises.mkdir(path4, { 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 },
|
|
8089
|
+
async function overridesFile({ hash, name: name2, image, config, apiPath, capabilities }, path4, 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(
|
|
8244
|
+
await import_fs2.promises.writeFile(path4, (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(
|
|
8329
|
+
function loadCapabilities(path4) {
|
|
8330
8330
|
return new Promise((resolve6, reject) => {
|
|
8331
|
-
const program2 = (0, import_child_process.fork)(
|
|
8331
|
+
const program2 = (0, import_child_process.fork)(path4, {
|
|
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,
|
|
8449
|
+
constructor(config, path4, 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 =
|
|
8454
|
+
this.path = path4;
|
|
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,
|
|
8467
|
-
zarfYamlChart = (zarfYamlGenerator,
|
|
8466
|
+
zarfYaml = (zarfYamlGenerator, path4) => zarfYamlGenerator(this, path4, "manifests");
|
|
8467
|
+
zarfYamlChart = (zarfYamlGenerator, path4) => zarfYamlGenerator(this, path4, "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,26 +8594,8 @@ 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
|
-
|
|
8598
|
-
|
|
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
|
-
};
|
|
8597
|
+
var import_fs5 = require("fs");
|
|
8598
|
+
var import_path2 = __toESM(require("path"));
|
|
8617
8599
|
|
|
8618
8600
|
// src/templates/pepr.code-snippets.json
|
|
8619
8601
|
var pepr_code_snippets_default = {
|
|
@@ -8853,8 +8835,8 @@ var tsconfig_module_default = {
|
|
|
8853
8835
|
var gitIgnore = "# Ignore node_modules and Pepr build artifacts\nnode_modules\ndist\ninsecure*\n";
|
|
8854
8836
|
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';
|
|
8855
8837
|
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';
|
|
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.
|
|
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.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 --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.23.0", "@typescript-eslint/parser": "8.23.0", commander: "13.1.0", esbuild: "0.25.0", eslint: "^9.26.0", "node-forge": "1.3.1", prettier: "3.4.2", prompts: "2.4.2", typescript: "5.7.3", uuid: "11.0.5" } };
|
|
8858
8840
|
|
|
8859
8841
|
// src/cli/init/utils.ts
|
|
8860
8842
|
var import_fs4 = require("fs");
|
|
@@ -8880,11 +8862,11 @@ async function createDir(dir) {
|
|
|
8880
8862
|
}
|
|
8881
8863
|
}
|
|
8882
8864
|
}
|
|
8883
|
-
function write(
|
|
8865
|
+
function write(path4, data) {
|
|
8884
8866
|
if (typeof data !== "string") {
|
|
8885
8867
|
data = JSON.stringify(data, null, 2);
|
|
8886
8868
|
}
|
|
8887
|
-
return import_fs4.promises.writeFile(
|
|
8869
|
+
return import_fs4.promises.writeFile(path4, data);
|
|
8888
8870
|
}
|
|
8889
8871
|
|
|
8890
8872
|
// src/cli/init/templates.ts
|
|
@@ -8984,36 +8966,47 @@ var prettier = {
|
|
|
8984
8966
|
data: prettierrc_default
|
|
8985
8967
|
};
|
|
8986
8968
|
var eslint = {
|
|
8987
|
-
path: ".
|
|
8988
|
-
data:
|
|
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
|
+
)
|
|
8989
8982
|
};
|
|
8990
8983
|
|
|
8991
8984
|
// src/cli/build.ts
|
|
8992
8985
|
var import_commander = require("commander");
|
|
8993
8986
|
|
|
8994
|
-
// src/cli/format.ts
|
|
8987
|
+
// src/cli/format/index.ts
|
|
8995
8988
|
var import_eslint = require("eslint");
|
|
8996
8989
|
|
|
8997
|
-
// src/cli/format.helpers.ts
|
|
8998
|
-
var
|
|
8990
|
+
// src/cli/format/format.helpers.ts
|
|
8991
|
+
var import_fs6 = require("fs");
|
|
8999
8992
|
var import_prettier = require("prettier");
|
|
9000
8993
|
async function formatWithPrettier(results, validateOnly) {
|
|
9001
8994
|
let hasFailure = false;
|
|
9002
8995
|
for (const { filePath } of results) {
|
|
9003
|
-
const content = await
|
|
8996
|
+
const content = await import_fs6.promises.readFile(filePath, "utf8");
|
|
9004
8997
|
const cfg = await (0, import_prettier.resolveConfig)(filePath);
|
|
9005
8998
|
const formatted = await (0, import_prettier.format)(content, { filepath: filePath, ...cfg });
|
|
9006
8999
|
if (validateOnly && formatted !== content) {
|
|
9007
9000
|
hasFailure = true;
|
|
9008
9001
|
console.error(`File ${filePath} is not formatted correctly`);
|
|
9009
9002
|
} else {
|
|
9010
|
-
await
|
|
9003
|
+
await import_fs6.promises.writeFile(filePath, formatted);
|
|
9011
9004
|
}
|
|
9012
9005
|
}
|
|
9013
9006
|
return hasFailure;
|
|
9014
9007
|
}
|
|
9015
9008
|
|
|
9016
|
-
// src/cli/format.ts
|
|
9009
|
+
// src/cli/format/index.ts
|
|
9017
9010
|
function format_default(program2) {
|
|
9018
9011
|
program2.command("format").description("Lint and format this Pepr module").option("-v, --validate-only", "Do not modify files, only validate formatting.").action(async (opts) => {
|
|
9019
9012
|
const success = await peprFormat(opts.validateOnly);
|
|
@@ -9054,7 +9047,7 @@ async function peprFormat(validateOnly) {
|
|
|
9054
9047
|
}
|
|
9055
9048
|
|
|
9056
9049
|
// src/lib/included-files.ts
|
|
9057
|
-
var
|
|
9050
|
+
var import_fs7 = require("fs");
|
|
9058
9051
|
async function createDockerfile(version3, description, includedFiles) {
|
|
9059
9052
|
const file = `
|
|
9060
9053
|
# Use an official Node.js runtime as the base image
|
|
@@ -9066,14 +9059,14 @@ async function createDockerfile(version3, description, includedFiles) {
|
|
|
9066
9059
|
${includedFiles.map((f) => `ADD ${f} ${f}`).join("\n")}
|
|
9067
9060
|
|
|
9068
9061
|
`;
|
|
9069
|
-
await
|
|
9062
|
+
await import_fs7.promises.writeFile("Dockerfile.controller", file, { encoding: "utf-8" });
|
|
9070
9063
|
}
|
|
9071
9064
|
|
|
9072
9065
|
// src/cli/build.helpers.ts
|
|
9073
9066
|
var import_child_process2 = require("child_process");
|
|
9074
9067
|
var import_esbuild = require("esbuild");
|
|
9075
|
-
var
|
|
9076
|
-
var
|
|
9068
|
+
var import_path3 = require("path");
|
|
9069
|
+
var import_fs9 = require("fs");
|
|
9077
9070
|
|
|
9078
9071
|
// src/lib/assets/yaml/generateAllYaml.ts
|
|
9079
9072
|
var import_crypto2 = __toESM(require("crypto"));
|
|
@@ -9388,7 +9381,7 @@ function getDeployment(assets, hash, buildTimestamp, imagePullSecret) {
|
|
|
9388
9381
|
}
|
|
9389
9382
|
function getModuleSecret(name2, data, hash) {
|
|
9390
9383
|
const compressed = (0, import_zlib.gzipSync)(data);
|
|
9391
|
-
const
|
|
9384
|
+
const path4 = `module-${hash}.js.gz`;
|
|
9392
9385
|
const compressedData = compressed.toString("base64");
|
|
9393
9386
|
if (secretOverLimit(compressedData)) {
|
|
9394
9387
|
const error = new Error(`Module secret for ${name2} is over the 1MB limit`);
|
|
@@ -9403,14 +9396,14 @@ function getModuleSecret(name2, data, hash) {
|
|
|
9403
9396
|
},
|
|
9404
9397
|
type: "Opaque",
|
|
9405
9398
|
data: {
|
|
9406
|
-
[
|
|
9399
|
+
[path4]: compressed.toString("base64")
|
|
9407
9400
|
}
|
|
9408
9401
|
};
|
|
9409
9402
|
}
|
|
9410
9403
|
}
|
|
9411
9404
|
|
|
9412
9405
|
// src/lib/assets/yaml/generateAllYaml.ts
|
|
9413
|
-
var
|
|
9406
|
+
var import_fs8 = require("fs");
|
|
9414
9407
|
|
|
9415
9408
|
// src/lib/assets/webhooks.ts
|
|
9416
9409
|
var import_ramda = require("ramda");
|
|
@@ -9497,8 +9490,8 @@ async function webhookConfigGenerator(assets, mutateOrValidate, timeoutSeconds =
|
|
|
9497
9490
|
|
|
9498
9491
|
// src/lib/assets/yaml/generateAllYaml.ts
|
|
9499
9492
|
async function generateAllYaml(assets, deployments) {
|
|
9500
|
-
const { name: name2, tls, apiPath, path:
|
|
9501
|
-
const code = await
|
|
9493
|
+
const { name: name2, tls, apiPath, path: path4, config } = assets;
|
|
9494
|
+
const code = await import_fs8.promises.readFile(path4);
|
|
9502
9495
|
const hash = import_crypto2.default.createHash("sha256").update(code).digest("hex");
|
|
9503
9496
|
const resources = [
|
|
9504
9497
|
getNamespace(assets.config.customLabels?.namespace),
|
|
@@ -9531,18 +9524,18 @@ async function generateAllYaml(assets, deployments) {
|
|
|
9531
9524
|
|
|
9532
9525
|
// src/lib/assets/yaml/generateZarfYaml.ts
|
|
9533
9526
|
var import_client_node5 = require("@kubernetes/client-node");
|
|
9534
|
-
function generateZarfYamlGeneric(assets,
|
|
9527
|
+
function generateZarfYamlGeneric(assets, path4, type) {
|
|
9535
9528
|
const zarfComponentName = process.env.PEPR_CUSTOM_BUILD_NAME ?? "module";
|
|
9536
9529
|
const manifestSettings = {
|
|
9537
9530
|
name: zarfComponentName,
|
|
9538
9531
|
namespace: "pepr-system",
|
|
9539
|
-
files: [
|
|
9532
|
+
files: [path4]
|
|
9540
9533
|
};
|
|
9541
9534
|
const chartSettings = {
|
|
9542
9535
|
name: zarfComponentName,
|
|
9543
9536
|
namespace: "pepr-system",
|
|
9544
9537
|
version: `${assets.config.appVersion || "0.0.1"}`,
|
|
9545
|
-
localPath:
|
|
9538
|
+
localPath: path4
|
|
9546
9539
|
};
|
|
9547
9540
|
const component = {
|
|
9548
9541
|
name: zarfComponentName,
|
|
@@ -9642,18 +9635,18 @@ async function generateYamlAndWriteToDisk(obj) {
|
|
|
9642
9635
|
const { uuid, imagePullSecret, outputDir: outputDir2, assets, zarf } = obj;
|
|
9643
9636
|
const yamlFile = `pepr-module-${uuid}.yaml`;
|
|
9644
9637
|
const chartPath = `${uuid}-chart`;
|
|
9645
|
-
const yamlPath = (0,
|
|
9638
|
+
const yamlPath = (0, import_path3.resolve)(outputDir2, yamlFile);
|
|
9646
9639
|
try {
|
|
9647
9640
|
const yaml = await assets.allYaml(generateAllYaml, getDeployment, getWatcher, imagePullSecret);
|
|
9648
|
-
const zarfPath = (0,
|
|
9641
|
+
const zarfPath = (0, import_path3.resolve)(outputDir2, "zarf.yaml");
|
|
9649
9642
|
let localZarf = "";
|
|
9650
9643
|
if (zarf === "chart") {
|
|
9651
9644
|
localZarf = assets.zarfYamlChart(generateZarfYamlGeneric, chartPath);
|
|
9652
9645
|
} else {
|
|
9653
9646
|
localZarf = assets.zarfYaml(generateZarfYamlGeneric, yamlFile);
|
|
9654
9647
|
}
|
|
9655
|
-
await
|
|
9656
|
-
await
|
|
9648
|
+
await import_fs9.promises.writeFile(yamlPath, yaml);
|
|
9649
|
+
await import_fs9.promises.writeFile(zarfPath, localZarf);
|
|
9657
9650
|
await assets.generateHelmChart(webhookConfigGenerator, getWatcher, getModuleSecret, outputDir2);
|
|
9658
9651
|
console.info(`\u2705 K8s resource for the module saved to ${yamlPath}`);
|
|
9659
9652
|
} catch (error) {
|
|
@@ -9709,7 +9702,7 @@ function build_default(program2) {
|
|
|
9709
9702
|
).action(async (opts) => {
|
|
9710
9703
|
outputDir = await handleCustomOutputDir(opts.outputDir);
|
|
9711
9704
|
const buildModuleResult = await buildModule(void 0, opts.entryPoint, opts.embed);
|
|
9712
|
-
const { cfg, path:
|
|
9705
|
+
const { cfg, path: path4 } = buildModuleResult;
|
|
9713
9706
|
if (opts.customName) {
|
|
9714
9707
|
process.env.PEPR_CUSTOM_BUILD_NAME = opts.customName;
|
|
9715
9708
|
}
|
|
@@ -9732,7 +9725,7 @@ function build_default(program2) {
|
|
|
9732
9725
|
);
|
|
9733
9726
|
}
|
|
9734
9727
|
if (!opts.embed) {
|
|
9735
|
-
console.info(`\u2705 Module built successfully at ${
|
|
9728
|
+
console.info(`\u2705 Module built successfully at ${path4}`);
|
|
9736
9729
|
return;
|
|
9737
9730
|
}
|
|
9738
9731
|
const assets = new Assets(
|
|
@@ -9746,7 +9739,7 @@ function build_default(program2) {
|
|
|
9746
9739
|
// Can override the rbacMode with the CLI option
|
|
9747
9740
|
rbacMode: determineRbacMode(opts, cfg)
|
|
9748
9741
|
},
|
|
9749
|
-
|
|
9742
|
+
path4,
|
|
9750
9743
|
opts.withPullSecret === "" ? [] : [opts.withPullSecret]
|
|
9751
9744
|
);
|
|
9752
9745
|
if (image !== "") assets.image = image;
|
|
@@ -9765,19 +9758,19 @@ var externalLibs = Object.keys(dependencies);
|
|
|
9765
9758
|
externalLibs.push("pepr");
|
|
9766
9759
|
externalLibs.push("@kubernetes/client-node");
|
|
9767
9760
|
async function loadModule(entryPoint = peprTS2) {
|
|
9768
|
-
const entryPointPath = (0,
|
|
9769
|
-
const modulePath = (0,
|
|
9770
|
-
const cfgPath = (0,
|
|
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");
|
|
9771
9764
|
try {
|
|
9772
|
-
await
|
|
9773
|
-
await
|
|
9765
|
+
await import_fs10.promises.access(cfgPath);
|
|
9766
|
+
await import_fs10.promises.access(entryPointPath);
|
|
9774
9767
|
} catch {
|
|
9775
9768
|
console.error(
|
|
9776
9769
|
`Could not find ${cfgPath} or ${entryPointPath} in the current directory. Please run this command from the root of your module's directory.`
|
|
9777
9770
|
);
|
|
9778
9771
|
process.exit(1);
|
|
9779
9772
|
}
|
|
9780
|
-
const moduleText = await
|
|
9773
|
+
const moduleText = await import_fs10.promises.readFile(cfgPath, { encoding: "utf-8" });
|
|
9781
9774
|
const cfg = JSON.parse(moduleText);
|
|
9782
9775
|
const { uuid } = cfg.pepr;
|
|
9783
9776
|
const name2 = `pepr-${uuid}.js`;
|
|
@@ -9790,13 +9783,13 @@ async function loadModule(entryPoint = peprTS2) {
|
|
|
9790
9783
|
entryPointPath,
|
|
9791
9784
|
modulePath,
|
|
9792
9785
|
name: name2,
|
|
9793
|
-
path: (0,
|
|
9786
|
+
path: (0, import_path4.resolve)(outputDir, name2),
|
|
9794
9787
|
uuid
|
|
9795
9788
|
};
|
|
9796
9789
|
}
|
|
9797
9790
|
async function buildModule(reloader, entryPoint = peprTS2, embed = true) {
|
|
9798
9791
|
try {
|
|
9799
|
-
const { cfg, modulePath, path:
|
|
9792
|
+
const { cfg, modulePath, path: path4, uuid } = await loadModule(entryPoint);
|
|
9800
9793
|
await checkFormat();
|
|
9801
9794
|
const npmRoot = (0, import_child_process3.execFileSync)("npm", ["root"]).toString().trim();
|
|
9802
9795
|
const args = ["--project", `${modulePath}/tsconfig.json`, "--outdir", outputDir];
|
|
@@ -9810,7 +9803,7 @@ async function buildModule(reloader, entryPoint = peprTS2, embed = true) {
|
|
|
9810
9803
|
legalComments: "external",
|
|
9811
9804
|
metafile: true,
|
|
9812
9805
|
minify: true,
|
|
9813
|
-
outfile:
|
|
9806
|
+
outfile: path4,
|
|
9814
9807
|
plugins: [
|
|
9815
9808
|
{
|
|
9816
9809
|
name: "reload-server",
|
|
@@ -9835,12 +9828,12 @@ async function buildModule(reloader, entryPoint = peprTS2, embed = true) {
|
|
|
9835
9828
|
}
|
|
9836
9829
|
if (!embed) {
|
|
9837
9830
|
ctxCfg.minify = false;
|
|
9838
|
-
ctxCfg.outfile = (0,
|
|
9831
|
+
ctxCfg.outfile = (0, import_path4.resolve)(outputDir, (0, import_path4.basename)(entryPoint, (0, import_path4.extname)(entryPoint))) + ".js";
|
|
9839
9832
|
ctxCfg.packages = "external";
|
|
9840
9833
|
ctxCfg.treeShaking = false;
|
|
9841
9834
|
}
|
|
9842
9835
|
const ctx = await watchForChanges(ctxCfg, reloader);
|
|
9843
|
-
return { ctx, path:
|
|
9836
|
+
return { ctx, path: path4, cfg, uuid };
|
|
9844
9837
|
} catch (e) {
|
|
9845
9838
|
handleModuleBuildError(e);
|
|
9846
9839
|
}
|
|
@@ -9889,7 +9882,7 @@ var import_prompts = __toESM(require("prompts"));
|
|
|
9889
9882
|
|
|
9890
9883
|
// src/lib/assets/deploy.ts
|
|
9891
9884
|
var import_crypto3 = __toESM(require("crypto"));
|
|
9892
|
-
var
|
|
9885
|
+
var import_fs11 = require("fs");
|
|
9893
9886
|
var import_kubernetes_fluent_client3 = require("kubernetes-fluent-client");
|
|
9894
9887
|
|
|
9895
9888
|
// src/lib/k8s.ts
|
|
@@ -9998,7 +9991,7 @@ async function deployWebhook(assets, force, webhookTimeout) {
|
|
|
9998
9991
|
logger_default.info("Applying the Pepr Store CRD if it doesn't exist");
|
|
9999
9992
|
await (0, import_kubernetes_fluent_client3.K8s)(import_kubernetes_fluent_client3.kind.CustomResourceDefinition).Apply(peprStoreCRD, { force });
|
|
10000
9993
|
if (assets.host) return;
|
|
10001
|
-
const code = await
|
|
9994
|
+
const code = await import_fs11.promises.readFile(assets.path);
|
|
10002
9995
|
if (!code.length) throw new Error("No code provided");
|
|
10003
9996
|
const hash = import_crypto3.default.createHash("sha256").update(code).digest("hex");
|
|
10004
9997
|
await setupRBAC(assets.name, assets.capabilities, force, assets.config);
|
|
@@ -10200,7 +10193,7 @@ function deploy_default(program2) {
|
|
|
10200
10193
|
var import_prompts2 = __toESM(require("prompts"));
|
|
10201
10194
|
var import_child_process4 = require("child_process");
|
|
10202
10195
|
var import_kubernetes_fluent_client5 = require("kubernetes-fluent-client");
|
|
10203
|
-
var
|
|
10196
|
+
var import_fs12 = require("fs");
|
|
10204
10197
|
function dev_default(program2) {
|
|
10205
10198
|
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) => {
|
|
10206
10199
|
if (!opts.confirm) {
|
|
@@ -10213,25 +10206,25 @@ function dev_default(program2) {
|
|
|
10213
10206
|
process.exit(0);
|
|
10214
10207
|
}
|
|
10215
10208
|
}
|
|
10216
|
-
const { cfg, path:
|
|
10209
|
+
const { cfg, path: path4 } = await loadModule();
|
|
10217
10210
|
const webhook = new Assets(
|
|
10218
10211
|
{
|
|
10219
10212
|
...cfg.pepr,
|
|
10220
10213
|
description: cfg.description
|
|
10221
10214
|
},
|
|
10222
|
-
|
|
10215
|
+
path4,
|
|
10223
10216
|
[],
|
|
10224
10217
|
opts.host
|
|
10225
10218
|
);
|
|
10226
|
-
await
|
|
10227
|
-
await
|
|
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);
|
|
10228
10221
|
try {
|
|
10229
10222
|
let program3;
|
|
10230
10223
|
const name2 = `pepr-${cfg.pepr.uuid}`;
|
|
10231
10224
|
const scheduleStore = `pepr-${cfg.pepr.uuid}-schedule`;
|
|
10232
10225
|
const store = `pepr-${cfg.pepr.uuid}-store`;
|
|
10233
10226
|
const runFork = async () => {
|
|
10234
|
-
console.info(`Running module ${
|
|
10227
|
+
console.info(`Running module ${path4}`);
|
|
10235
10228
|
await webhook.deploy(deployWebhook, false, 30);
|
|
10236
10229
|
try {
|
|
10237
10230
|
validateCapabilityNames(webhook.capabilities);
|
|
@@ -10239,7 +10232,7 @@ function dev_default(program2) {
|
|
|
10239
10232
|
console.error(`Error validating capability names:`, e);
|
|
10240
10233
|
process.exit(1);
|
|
10241
10234
|
}
|
|
10242
|
-
program3 = (0, import_child_process4.fork)(
|
|
10235
|
+
program3 = (0, import_child_process4.fork)(path4, {
|
|
10243
10236
|
env: {
|
|
10244
10237
|
...process.env,
|
|
10245
10238
|
LOG_LEVEL: process.env.LOG_LEVEL ?? "debug",
|
|
@@ -10373,11 +10366,11 @@ ${filteredFailures.length > 0 ? "\u274C" : "\u2705"} VALIDATE ${name2} (${uid
|
|
|
10373
10366
|
|
|
10374
10367
|
// src/cli/init/index.ts
|
|
10375
10368
|
var import_child_process5 = require("child_process");
|
|
10376
|
-
var
|
|
10369
|
+
var import_path5 = require("path");
|
|
10377
10370
|
var import_prompts4 = __toESM(require("prompts"));
|
|
10378
10371
|
|
|
10379
10372
|
// src/cli/init/walkthrough.ts
|
|
10380
|
-
var
|
|
10373
|
+
var import_fs13 = require("fs");
|
|
10381
10374
|
var import_prompts3 = __toESM(require("prompts"));
|
|
10382
10375
|
|
|
10383
10376
|
// src/cli/init/enums.ts
|
|
@@ -10424,7 +10417,7 @@ async function setName(name2) {
|
|
|
10424
10417
|
validate: async (val) => {
|
|
10425
10418
|
try {
|
|
10426
10419
|
const name3 = sanitizeName(val);
|
|
10427
|
-
await
|
|
10420
|
+
await import_fs13.promises.access(name3, import_fs13.promises.constants.F_OK);
|
|
10428
10421
|
return "A directory with this name already exists";
|
|
10429
10422
|
} catch {
|
|
10430
10423
|
return val.length > 2 || "The name must be at least 3 characters long";
|
|
@@ -10569,8 +10562,8 @@ function init_default(program2) {
|
|
|
10569
10562
|
}
|
|
10570
10563
|
async function setupProjectStructure(dirName) {
|
|
10571
10564
|
await createDir(dirName);
|
|
10572
|
-
await createDir((0,
|
|
10573
|
-
await createDir((0,
|
|
10565
|
+
await createDir((0, import_path5.resolve)(dirName, ".vscode"));
|
|
10566
|
+
await createDir((0, import_path5.resolve)(dirName, "capabilities"));
|
|
10574
10567
|
}
|
|
10575
10568
|
async function createProjectFiles(dirName, packageJSON2) {
|
|
10576
10569
|
const files = [
|
|
@@ -10589,10 +10582,10 @@ async function createProjectFiles(dirName, packageJSON2) {
|
|
|
10589
10582
|
{ dir: "capabilities", path: helloPepr.path, data: helloPepr.data }
|
|
10590
10583
|
];
|
|
10591
10584
|
for (const file of files) {
|
|
10592
|
-
await write((0,
|
|
10585
|
+
await write((0, import_path5.resolve)(dirName, file.path), file.data);
|
|
10593
10586
|
}
|
|
10594
10587
|
for (const file of nestedFiles) {
|
|
10595
|
-
await write((0,
|
|
10588
|
+
await write((0, import_path5.resolve)(dirName, file.dir, file.path), file.data);
|
|
10596
10589
|
}
|
|
10597
10590
|
}
|
|
10598
10591
|
var doPostInitActions = (dirName) => {
|
|
@@ -10648,10 +10641,10 @@ var RootCmd = class extends import_commander2.Command {
|
|
|
10648
10641
|
}
|
|
10649
10642
|
};
|
|
10650
10643
|
|
|
10651
|
-
// src/cli/update.ts
|
|
10644
|
+
// src/cli/update/index.ts
|
|
10652
10645
|
var import_child_process6 = require("child_process");
|
|
10653
|
-
var
|
|
10654
|
-
var
|
|
10646
|
+
var import_fs14 = __toESM(require("fs"));
|
|
10647
|
+
var import_path6 = require("path");
|
|
10655
10648
|
var import_prompts5 = __toESM(require("prompts"));
|
|
10656
10649
|
function update_default(program2) {
|
|
10657
10650
|
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) => {
|
|
@@ -10667,6 +10660,22 @@ function update_default(program2) {
|
|
|
10667
10660
|
}
|
|
10668
10661
|
console.log("Updating the Pepr module...");
|
|
10669
10662
|
try {
|
|
10663
|
+
let packageLockContent = "";
|
|
10664
|
+
let foundPackageLock = false;
|
|
10665
|
+
try {
|
|
10666
|
+
if (import_fs14.default.existsSync("./package-lock.json")) {
|
|
10667
|
+
packageLockContent = import_fs14.default.readFileSync("./package-lock.json", "utf-8");
|
|
10668
|
+
foundPackageLock = true;
|
|
10669
|
+
}
|
|
10670
|
+
} catch {
|
|
10671
|
+
}
|
|
10672
|
+
if (foundPackageLock && packageLockContent) {
|
|
10673
|
+
if (packageLockContent.indexOf('"eslint":') >= 0 && packageLockContent.match(/"eslint":\s*"[~^]?8\.[0-9]+\.[0-9]+"/)) {
|
|
10674
|
+
console.warn(
|
|
10675
|
+
"\nWarning: This Pepr module uses ESLint v8. Pepr will be upgraded to use v9 in a future release.\nSee eslint@9.0.0 release notes for more details: https://eslint.org/blog/2024/04/eslint-v9.0.0-released/"
|
|
10676
|
+
);
|
|
10677
|
+
}
|
|
10678
|
+
}
|
|
10670
10679
|
(0, import_child_process6.execSync)("npm install pepr@latest", {
|
|
10671
10680
|
stdio: "inherit"
|
|
10672
10681
|
});
|
|
@@ -10685,17 +10694,17 @@ function update_default(program2) {
|
|
|
10685
10694
|
console.log("Updating Pepr config and template tiles...");
|
|
10686
10695
|
try {
|
|
10687
10696
|
if (!opts.skipTemplateUpdate) {
|
|
10688
|
-
await write((0,
|
|
10689
|
-
await write((0,
|
|
10690
|
-
await write((0,
|
|
10691
|
-
await write((0,
|
|
10692
|
-
const samplePath = (0,
|
|
10693
|
-
if (
|
|
10694
|
-
|
|
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);
|
|
10695
10704
|
await write(samplePath, samplesYaml.data);
|
|
10696
10705
|
}
|
|
10697
|
-
const tsPath = (0,
|
|
10698
|
-
if (
|
|
10706
|
+
const tsPath = (0, import_path6.resolve)("capabilities", helloPepr.path);
|
|
10707
|
+
if (import_fs14.default.existsSync(tsPath)) {
|
|
10699
10708
|
await write(tsPath, helloPepr.data);
|
|
10700
10709
|
}
|
|
10701
10710
|
}
|
|
@@ -10736,8 +10745,8 @@ function kfc_default(program2) {
|
|
|
10736
10745
|
|
|
10737
10746
|
// src/cli/crd/create.ts
|
|
10738
10747
|
var import_commander3 = require("commander");
|
|
10739
|
-
var
|
|
10740
|
-
var
|
|
10748
|
+
var import_fs15 = require("fs");
|
|
10749
|
+
var import_path7 = __toESM(require("path"));
|
|
10741
10750
|
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(
|
|
10742
10751
|
"--scope <Namespaced | Cluster>",
|
|
10743
10752
|
"Whether the resulting custom resource is cluster- or namespace-scoped",
|
|
@@ -10745,9 +10754,9 @@ var create = new import_commander3.Command("create").description("Create a new C
|
|
|
10745
10754
|
"Namespaced"
|
|
10746
10755
|
).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 }) => {
|
|
10747
10756
|
console.log("This feature is currently in alpha.\n");
|
|
10748
|
-
const outputDir2 =
|
|
10757
|
+
const outputDir2 = import_path7.default.resolve(`./api/${version3}`);
|
|
10749
10758
|
await createDirectoryIfNotExists(outputDir2);
|
|
10750
|
-
await
|
|
10759
|
+
await import_fs15.promises.writeFile(
|
|
10751
10760
|
`./api/${version3}/${kind8.toLowerCase()}_types.ts`,
|
|
10752
10761
|
generateCRDScaffold(group2, version3, kind8, { domain, scope, plural: plural2, shortName })
|
|
10753
10762
|
);
|
|
@@ -10842,8 +10851,8 @@ function validateScope(value) {
|
|
|
10842
10851
|
|
|
10843
10852
|
// src/cli/crd/generate.ts
|
|
10844
10853
|
var import_commander4 = require("commander");
|
|
10845
|
-
var
|
|
10846
|
-
var
|
|
10854
|
+
var import_fs16 = __toESM(require("fs"));
|
|
10855
|
+
var import_path8 = __toESM(require("path"));
|
|
10847
10856
|
var import_yaml = __toESM(require_dist());
|
|
10848
10857
|
var import_ts_morph = require("ts-morph");
|
|
10849
10858
|
|
|
@@ -10873,24 +10882,24 @@ function extractCRDDetails(content, sourceFile) {
|
|
|
10873
10882
|
}
|
|
10874
10883
|
async function generateCRDs(options) {
|
|
10875
10884
|
console.log("This feature is currently in alpha.\n");
|
|
10876
|
-
const outputDir2 =
|
|
10885
|
+
const outputDir2 = import_path8.default.resolve(options.output);
|
|
10877
10886
|
await createDirectoryIfNotExists(outputDir2);
|
|
10878
10887
|
const project = new import_ts_morph.Project();
|
|
10879
|
-
const apiRoot =
|
|
10888
|
+
const apiRoot = import_path8.default.resolve("api");
|
|
10880
10889
|
const versions = getAPIVersions(apiRoot);
|
|
10881
10890
|
for (const version3 of versions) {
|
|
10882
|
-
const sourceFiles = loadVersionFiles(project,
|
|
10891
|
+
const sourceFiles = loadVersionFiles(project, import_path8.default.join(apiRoot, version3));
|
|
10883
10892
|
for (const sourceFile of sourceFiles) {
|
|
10884
10893
|
processSourceFile(sourceFile, version3, outputDir2);
|
|
10885
10894
|
}
|
|
10886
10895
|
}
|
|
10887
10896
|
}
|
|
10888
10897
|
function getAPIVersions(apiRoot) {
|
|
10889
|
-
return
|
|
10898
|
+
return import_fs16.default.readdirSync(apiRoot).filter((v) => import_fs16.default.statSync(import_path8.default.join(apiRoot, v)).isDirectory());
|
|
10890
10899
|
}
|
|
10891
10900
|
function loadVersionFiles(project, versionDir) {
|
|
10892
|
-
const files =
|
|
10893
|
-
const filePaths = files.map((f) =>
|
|
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));
|
|
10894
10903
|
return project.addSourceFilesAtPaths(filePaths);
|
|
10895
10904
|
}
|
|
10896
10905
|
function processSourceFile(sourceFile, version3, outputDir2) {
|
|
@@ -10918,8 +10927,8 @@ function processSourceFile(sourceFile, version3, outputDir2) {
|
|
|
10918
10927
|
specSchema,
|
|
10919
10928
|
conditionSchema
|
|
10920
10929
|
});
|
|
10921
|
-
const outPath =
|
|
10922
|
-
|
|
10930
|
+
const outPath = import_path8.default.join(outputDir2, `${kind8.toLowerCase()}.yaml`);
|
|
10931
|
+
import_fs16.default.writeFileSync(outPath, (0, import_yaml.stringify)(crd), "utf8");
|
|
10923
10932
|
console.log(`\u2714 Created ${outPath}`);
|
|
10924
10933
|
}
|
|
10925
10934
|
function extractSingleLineComment(content, label) {
|