pepr 0.51.6-nightly.5 → 0.51.6-nightly.7
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/crd/create.d.ts +0 -1
- package/dist/cli/crd/create.d.ts.map +1 -1
- package/dist/cli/init/index.d.ts.map +1 -1
- package/dist/cli/init/walkthrough.d.ts.map +1 -1
- package/dist/cli.js +28 -31
- package/dist/controller.js +1 -1
- package/package.json +2 -2
- package/src/cli/crd/create.ts +14 -19
- package/src/cli/crd/generate.ts +1 -1
- package/src/cli/dev.ts +6 -6
- package/src/cli/format/index.ts +1 -1
- package/src/cli/init/index.ts +10 -7
- package/src/cli/init/walkthrough.ts +2 -4
- package/src/cli/update/index.ts +1 -1
package/dist/cli/crd/create.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create.d.ts","sourceRoot":"","sources":["../../../src/cli/crd/create.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,OAAO,
|
|
1
|
+
{"version":3,"file":"create.d.ts","sourceRoot":"","sources":["../../../src/cli/crd/create.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,OAAO,EAAU,MAAM,WAAW,CAAC;AAM5C,QAAA,MAAM,MAAM,SA2BR,CAAC;AAEL,eAAe,MAAM,CAAC;AAEtB,eAAO,MAAM,mBAAmB,GAC9B,OAAO,MAAM,EACb,SAAS,MAAM,EACf,MAAM,MAAM,EACZ,MAAM;IACJ,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;CACnB,KACA,MA8EF,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/cli/init/index.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/cli/init/index.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAqBlC,MAAM,CAAC,OAAO,WAAW,OAAO,EAAE,OAAO,GAAG,IAAI,CAoE/C"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"walkthrough.d.ts","sourceRoot":"","sources":["../../../src/cli/init/walkthrough.ts"],"names":[],"mappings":"AAIA,OAAe,EAAE,OAAO,EAAgB,MAAM,SAAS,CAAC;AAIxD,OAAO,EAAE,OAAO,EAAqB,MAAM,SAAS,CAAC;AAGrD,MAAM,MAAM,aAAa,GAAG;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,aAAa,EAAE,OAAO,CAAC;IACvB,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC;AAE1D,wBAAsB,WAAW,CAAC,IAAI,CAAC,EAAE,oBAAoB,GAAG,OAAO,CAAC,aAAa,CAAC,CAQrF;AAoBD,wBAAsB,OAAO,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CA6BrE;AAgBD,wBAAsB,gBAAgB,CAAC,aAAa,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAoCxF;AAED,wBAAsB,OAAO,CAC3B,OAAO,EAAE,MAAM,EACf,WAAW,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,EAC5C,UAAU,EAAE,MAAM,EAClB,UAAU,CAAC,EAAE,OAAO,GACnB,OAAO,CAAC,OAAO,CAAC,
|
|
1
|
+
{"version":3,"file":"walkthrough.d.ts","sourceRoot":"","sources":["../../../src/cli/init/walkthrough.ts"],"names":[],"mappings":"AAIA,OAAe,EAAE,OAAO,EAAgB,MAAM,SAAS,CAAC;AAIxD,OAAO,EAAE,OAAO,EAAqB,MAAM,SAAS,CAAC;AAGrD,MAAM,MAAM,aAAa,GAAG;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,aAAa,EAAE,OAAO,CAAC;IACvB,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC;AAE1D,wBAAsB,WAAW,CAAC,IAAI,CAAC,EAAE,oBAAoB,GAAG,OAAO,CAAC,aAAa,CAAC,CAQrF;AAoBD,wBAAsB,OAAO,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CA6BrE;AAgBD,wBAAsB,gBAAgB,CAAC,aAAa,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAoCxF;AAED,wBAAsB,OAAO,CAC3B,OAAO,EAAE,MAAM,EACf,WAAW,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,EAC5C,UAAU,EAAE,MAAM,EAClB,UAAU,CAAC,EAAE,OAAO,GACnB,OAAO,CAAC,OAAO,CAAC,CA+BlB"}
|
package/dist/cli.js
CHANGED
|
@@ -8867,7 +8867,7 @@ var gitIgnore = "# Ignore node_modules and Pepr build artifacts\nnode_modules\nd
|
|
|
8867
8867
|
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```text\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';
|
|
8868
8868
|
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';
|
|
8869
8869
|
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';
|
|
8870
|
-
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*"], version: "0.51.6-nightly.
|
|
8870
|
+
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*"], version: "0.51.6-nightly.7", 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 -p config/tsconfig.root.json && 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/private: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 && vitest run src/build-artifact.test.ts", "test:docs": "vitest run --config=config/vitest.integration.config.ts integration/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": "vitest run --config=config/vitest.integration.config.ts 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/private:dev $(node scripts/read-unicorn-build-args.mjs) . && k3d image import pepr/private: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": "vitest run --config=config/vitest.journey.config.ts journey/entrypoint.test.ts && npm run test:journey:upgrade", "test:journey:run-wasm": "vitest run --config=config/vitest.journey.config.ts journey/entrypoint-wasm.test.ts", "test:journey:unicorn": "npm run test:journey:k3d && npm run test:journey:image:unicorn && npm run test:journey:run", "format:check": "npm run format:src && npm run format:tests && npm run format:markdown && npm run format:integration && npm run format:prettier -- --check", "format:fix": "npm run format:src -- --fix && npm run format:markdown -- --fix && npm run format:integration -- --fix && npm run format:prettier -- --write", "format:integration": "eslint --config config/eslint.integration.config.mjs integration/cli integration/helpers", "format:markdown": 'npx -y markdownlint-cli --config config/.markdownlint.json --ignore adr --ignore integration/testroot --ignore pepr-test-module --ignore pepr-upgrade-test --ignore node_modules "**/*.md"', "format:prettier": "prettier --config config/.prettierrc src integration/cli/**/*.ts integration/helpers/**/*.ts", "format:src": "eslint --config config/eslint.root.config.mjs 'src/**/*.ts' --ignore-pattern '**/*.test.ts' --ignore-pattern 'src/templates/**'", "format:tests": "eslint --config config/eslint.test.config.mjs 'src/**/*.test.ts'", "test:journey:upgrade": "npm run test:journey:k3d && npm run test:journey:image && vitest run --config=config/vitest.journey.config.ts journey/pepr-upgrade.test.ts", "test:unit": "npm run gen-data-json && NODE_OPTIONS=--no-deprecation vitest --config config/vitest.root.config.ts run --coverage", prepare: `if [ "$NODE_ENV" != 'production' ]; then husky; fi` }, dependencies: { "@types/ramda": "0.30.2", commander: "14.0.0", 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.8.0", pino: "9.7.0", "pino-pretty": "13.0.0", "prom-client": "15.1.3", ramda: "0.31.3", sigstore: "3.1.0", "ts-morph": "^26.0.0" }, devDependencies: { "@commitlint/cli": "19.8.1", "@commitlint/config-conventional": "19.8.1", "@fast-check/vitest": "^0.2.1", "@types/eslint": "9.6.1", "@types/express": "5.0.3", "@types/json-pointer": "^1.0.34", "@types/node": "24.x.x", "@types/node-forge": "1.3.13", "@types/uuid": "10.0.0", "@types/ws": "^8.18.1", "@vitest/coverage-v8": "^3.2.3", "fast-check": "^4.0.0", globals: "^16.0.0", husky: "^9.1.6", "js-yaml": "^4.1.0", shellcheck: "^3.0.0", tsx: "^4.20.3", undici: "^7.0.1", vitest: "^3.2.3" }, overrides: { glob: "^9.0.0", "brace-expansion": "1.1.11" }, peerDependencies: { "@types/prompts": "2.4.9", "@typescript-eslint/eslint-plugin": "8.33.0", "@typescript-eslint/parser": "8.33.0", esbuild: "0.25.5", 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" } };
|
|
8871
8871
|
|
|
8872
8872
|
// src/cli/init/utils.ts
|
|
8873
8873
|
var import_fs4 = require("fs");
|
|
@@ -9071,7 +9071,7 @@ async function peprFormat(validateOnly) {
|
|
|
9071
9071
|
if (!validateOnly) {
|
|
9072
9072
|
await import_eslint.ESLint.outputFixes(results);
|
|
9073
9073
|
}
|
|
9074
|
-
hasFailure = await formatWithPrettier(results, validateOnly);
|
|
9074
|
+
hasFailure = hasFailure || await formatWithPrettier(results, validateOnly);
|
|
9075
9075
|
return !hasFailure;
|
|
9076
9076
|
} catch (e) {
|
|
9077
9077
|
console.error(`Error formatting module:`, e);
|
|
@@ -10301,14 +10301,14 @@ var import_child_process4 = require("child_process");
|
|
|
10301
10301
|
var import_kubernetes_fluent_client5 = require("kubernetes-fluent-client");
|
|
10302
10302
|
var import_fs12 = require("fs");
|
|
10303
10303
|
function dev_default(program2) {
|
|
10304
|
-
program2.command("dev").description("Setup a local webhook development environment").option("-
|
|
10305
|
-
if (!opts.
|
|
10304
|
+
program2.command("dev").description("Setup a local webhook development environment").option("-H, --host <host>", "Host to listen on", "host.k3d.internal").option("-y, --yes", "Skip confirmation prompt").action(async (opts) => {
|
|
10305
|
+
if (!opts.yes) {
|
|
10306
10306
|
const confirm2 = await (0, import_prompts2.default)({
|
|
10307
10307
|
type: "confirm",
|
|
10308
|
-
name: "
|
|
10308
|
+
name: "yes",
|
|
10309
10309
|
message: "This will remove and redeploy the module. Continue?"
|
|
10310
10310
|
});
|
|
10311
|
-
if (!confirm2.
|
|
10311
|
+
if (!confirm2.yes) {
|
|
10312
10312
|
process.exitCode = 0;
|
|
10313
10313
|
return;
|
|
10314
10314
|
}
|
|
@@ -10591,7 +10591,7 @@ async function setErrorBehavior(errorBehavior) {
|
|
|
10591
10591
|
async function confirm(dirName, packageJSON2, peprTSPath, skipPrompt) {
|
|
10592
10592
|
const confirmationPrompt = {
|
|
10593
10593
|
type: "confirm",
|
|
10594
|
-
name: "
|
|
10594
|
+
name: "yes",
|
|
10595
10595
|
message: "Create the new Pepr module?"
|
|
10596
10596
|
};
|
|
10597
10597
|
const confirmationMessage = `To be generated:
|
|
@@ -10614,17 +10614,20 @@ ${packageJSON2.print.replace(/^/gm, " \u2502 ")}
|
|
|
10614
10614
|
} else {
|
|
10615
10615
|
console.log(confirmationMessage);
|
|
10616
10616
|
const confirm2 = await (0, import_prompts3.default)([confirmationPrompt]);
|
|
10617
|
-
const shouldCreateModule = confirm2.
|
|
10617
|
+
const shouldCreateModule = confirm2.yes === "y" || confirm2.yes === "yes" || confirm2.yes === true ? true : false;
|
|
10618
10618
|
return shouldCreateModule;
|
|
10619
10619
|
}
|
|
10620
10620
|
}
|
|
10621
10621
|
|
|
10622
10622
|
// src/cli/init/index.ts
|
|
10623
|
+
var import_commander2 = require("commander");
|
|
10623
10624
|
function init_default(program2) {
|
|
10624
10625
|
let response = {};
|
|
10625
10626
|
let pkgOverride = "";
|
|
10626
|
-
program2.command("init").description("Initialize a new Pepr Module").option("
|
|
10627
|
-
"--
|
|
10627
|
+
program2.command("init").description("Initialize a new Pepr Module").option("-d, --description <string>", "Explain the purpose of the new module.").addOption(
|
|
10628
|
+
new import_commander2.Option("-e, --error-behavior <behavior>", "Set an error behavior.").choices(ErrorList)
|
|
10629
|
+
).option("-n, --name <string>", "Set the name of the new module.").option("-s, --skip-post-init", "Skip npm install, git init, and VSCode launch.").option(
|
|
10630
|
+
"-u, --uuid <string>",
|
|
10628
10631
|
"Unique identifier for your module with a max length of 36 characters.",
|
|
10629
10632
|
(uuid) => {
|
|
10630
10633
|
if (uuid.length > UUID_LENGTH_LIMIT) {
|
|
@@ -10632,7 +10635,7 @@ function init_default(program2) {
|
|
|
10632
10635
|
}
|
|
10633
10636
|
return uuid.toLocaleLowerCase();
|
|
10634
10637
|
}
|
|
10635
|
-
).hook("preAction", async (thisCommand) => {
|
|
10638
|
+
).option("-y, --yes", "Skip verification prompt when creating a new module.").hook("preAction", async (thisCommand) => {
|
|
10636
10639
|
if (process.env.TEST_MODE === "true") {
|
|
10637
10640
|
import_prompts4.default.inject([
|
|
10638
10641
|
"pepr-test-module",
|
|
@@ -10650,7 +10653,7 @@ function init_default(program2) {
|
|
|
10650
10653
|
}).action(async (opts) => {
|
|
10651
10654
|
const dirName = sanitizeName(response.name);
|
|
10652
10655
|
const packageJSON2 = genPkgJSON(response, pkgOverride);
|
|
10653
|
-
const confirmed = await confirm(dirName, packageJSON2, peprTSTemplate.path, opts.
|
|
10656
|
+
const confirmed = await confirm(dirName, packageJSON2, peprTSTemplate.path, opts.yes);
|
|
10654
10657
|
if (confirmed) {
|
|
10655
10658
|
console.log("Creating new Pepr module...");
|
|
10656
10659
|
try {
|
|
@@ -10742,11 +10745,11 @@ function uuid_default(program2) {
|
|
|
10742
10745
|
}
|
|
10743
10746
|
|
|
10744
10747
|
// src/cli/root.ts
|
|
10745
|
-
var
|
|
10746
|
-
var RootCmd = class extends
|
|
10748
|
+
var import_commander3 = require("commander");
|
|
10749
|
+
var RootCmd = class extends import_commander3.Command {
|
|
10747
10750
|
// eslint-disable-next-line class-methods-use-this
|
|
10748
10751
|
createCommand(name2) {
|
|
10749
|
-
const cmd = new
|
|
10752
|
+
const cmd = new import_commander3.Command(name2);
|
|
10750
10753
|
return cmd;
|
|
10751
10754
|
}
|
|
10752
10755
|
};
|
|
@@ -10757,7 +10760,7 @@ var import_fs14 = __toESM(require("fs"));
|
|
|
10757
10760
|
var import_path6 = require("path");
|
|
10758
10761
|
var import_prompts5 = __toESM(require("prompts"));
|
|
10759
10762
|
function update_default(program2) {
|
|
10760
|
-
program2.command("update").description("Update this Pepr module. Not recommended for prod as it may change files.").option("--skip-template-update", "
|
|
10763
|
+
program2.command("update").description("Update this Pepr module. Not recommended for prod as it may change files.").option("-s, --skip-template-update", "Do not update template files").action(async (opts) => {
|
|
10761
10764
|
if (!opts.skipTemplateUpdate) {
|
|
10762
10765
|
const { confirm: confirm2 } = await (0, import_prompts5.default)({
|
|
10763
10766
|
type: "confirm",
|
|
@@ -10839,15 +10842,15 @@ function kfc_default(program2) {
|
|
|
10839
10842
|
}
|
|
10840
10843
|
|
|
10841
10844
|
// src/cli/crd/create.ts
|
|
10842
|
-
var
|
|
10845
|
+
var import_commander4 = require("commander");
|
|
10843
10846
|
var import_fs15 = require("fs");
|
|
10844
10847
|
var import_path7 = __toESM(require("path"));
|
|
10845
|
-
var create = new
|
|
10846
|
-
|
|
10847
|
-
|
|
10848
|
-
|
|
10849
|
-
"Namespaced"
|
|
10850
|
-
).option("--
|
|
10848
|
+
var create = new import_commander4.Command("create").description("Create a new CRD TypeScript definition").addOption(
|
|
10849
|
+
new import_commander4.Option(
|
|
10850
|
+
"-S, --scope <scope>",
|
|
10851
|
+
"Whether the resulting custom resource is cluster- or namespace-scoped"
|
|
10852
|
+
).choices(["Namespaced", "Cluster"]).default("Namespaced")
|
|
10853
|
+
).option("-d, --domain <domain>", "Optional domain for CRD (e.g. pepr.dev)", "pepr.dev").requiredOption("-g, --group <group>", "API group (e.g. cache)").requiredOption("-k, --kind <kind>", "Kind name (e.g. memcached)").option("-p, --plural <plural>", "Plural name for CRD (e.g. memcacheds)").option("-s, --short-name <name>", "Short name for CRD (e.g. mc)", "").requiredOption("-v, --version <version>", "API version (e.g. v1alpha1)").action(async ({ group: group2, version: version3, kind: kind8, domain, scope, plural: plural2, shortName }) => {
|
|
10851
10854
|
console.log("This feature is currently in alpha.\n");
|
|
10852
10855
|
const outputDir2 = import_path7.default.resolve(`./api/${version3}`);
|
|
10853
10856
|
await createDirectoryIfNotExists(outputDir2);
|
|
@@ -10937,15 +10940,9 @@ type ${kind8}StatusCondition = {
|
|
|
10937
10940
|
|
|
10938
10941
|
`;
|
|
10939
10942
|
};
|
|
10940
|
-
function validateScope(value) {
|
|
10941
|
-
if (value !== "Cluster" && value !== "Namespaced") {
|
|
10942
|
-
throw new Error("Scope must be either 'Cluster' or 'Namespaced'");
|
|
10943
|
-
}
|
|
10944
|
-
return value;
|
|
10945
|
-
}
|
|
10946
10943
|
|
|
10947
10944
|
// src/cli/crd/generate.ts
|
|
10948
|
-
var
|
|
10945
|
+
var import_commander5 = require("commander");
|
|
10949
10946
|
var import_fs16 = __toESM(require("fs"));
|
|
10950
10947
|
var import_path8 = __toESM(require("path"));
|
|
10951
10948
|
var import_yaml = __toESM(require_dist());
|
|
@@ -10964,7 +10961,7 @@ var WarningMessages = {
|
|
|
10964
10961
|
};
|
|
10965
10962
|
|
|
10966
10963
|
// src/cli/crd/generate.ts
|
|
10967
|
-
var generate_default = new
|
|
10964
|
+
var generate_default = new import_commander5.Command("generate").description("Generate CRD manifests from TypeScript definitions").option("-o, --output <directory>", "Output directory for generated CRDs", "./crds").action(generateCRDs);
|
|
10968
10965
|
function extractCRDDetails(content, sourceFile) {
|
|
10969
10966
|
const kind8 = extractSingleLineComment(content, "Kind");
|
|
10970
10967
|
const group2 = extractSingleLineComment(content, "Group") ?? "example";
|
package/dist/controller.js
CHANGED
|
@@ -50,7 +50,7 @@ if (process.env.LOG_LEVEL) {
|
|
|
50
50
|
var logger_default = Log;
|
|
51
51
|
|
|
52
52
|
// src/templates/data.json
|
|
53
|
-
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*"], version: "0.51.6-nightly.
|
|
53
|
+
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*"], version: "0.51.6-nightly.7", 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 -p config/tsconfig.root.json && 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/private: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 && vitest run src/build-artifact.test.ts", "test:docs": "vitest run --config=config/vitest.integration.config.ts integration/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": "vitest run --config=config/vitest.integration.config.ts 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/private:dev $(node scripts/read-unicorn-build-args.mjs) . && k3d image import pepr/private: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": "vitest run --config=config/vitest.journey.config.ts journey/entrypoint.test.ts && npm run test:journey:upgrade", "test:journey:run-wasm": "vitest run --config=config/vitest.journey.config.ts journey/entrypoint-wasm.test.ts", "test:journey:unicorn": "npm run test:journey:k3d && npm run test:journey:image:unicorn && npm run test:journey:run", "format:check": "npm run format:src && npm run format:tests && npm run format:markdown && npm run format:integration && npm run format:prettier -- --check", "format:fix": "npm run format:src -- --fix && npm run format:markdown -- --fix && npm run format:integration -- --fix && npm run format:prettier -- --write", "format:integration": "eslint --config config/eslint.integration.config.mjs integration/cli integration/helpers", "format:markdown": 'npx -y markdownlint-cli --config config/.markdownlint.json --ignore adr --ignore integration/testroot --ignore pepr-test-module --ignore pepr-upgrade-test --ignore node_modules "**/*.md"', "format:prettier": "prettier --config config/.prettierrc src integration/cli/**/*.ts integration/helpers/**/*.ts", "format:src": "eslint --config config/eslint.root.config.mjs 'src/**/*.ts' --ignore-pattern '**/*.test.ts' --ignore-pattern 'src/templates/**'", "format:tests": "eslint --config config/eslint.test.config.mjs 'src/**/*.test.ts'", "test:journey:upgrade": "npm run test:journey:k3d && npm run test:journey:image && vitest run --config=config/vitest.journey.config.ts journey/pepr-upgrade.test.ts", "test:unit": "npm run gen-data-json && NODE_OPTIONS=--no-deprecation vitest --config config/vitest.root.config.ts run --coverage", prepare: `if [ "$NODE_ENV" != 'production' ]; then husky; fi` }, dependencies: { "@types/ramda": "0.30.2", commander: "14.0.0", 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.8.0", pino: "9.7.0", "pino-pretty": "13.0.0", "prom-client": "15.1.3", ramda: "0.31.3", sigstore: "3.1.0", "ts-morph": "^26.0.0" }, devDependencies: { "@commitlint/cli": "19.8.1", "@commitlint/config-conventional": "19.8.1", "@fast-check/vitest": "^0.2.1", "@types/eslint": "9.6.1", "@types/express": "5.0.3", "@types/json-pointer": "^1.0.34", "@types/node": "24.x.x", "@types/node-forge": "1.3.13", "@types/uuid": "10.0.0", "@types/ws": "^8.18.1", "@vitest/coverage-v8": "^3.2.3", "fast-check": "^4.0.0", globals: "^16.0.0", husky: "^9.1.6", "js-yaml": "^4.1.0", shellcheck: "^3.0.0", tsx: "^4.20.3", undici: "^7.0.1", vitest: "^3.2.3" }, overrides: { glob: "^9.0.0", "brace-expansion": "1.1.11" }, peerDependencies: { "@types/prompts": "2.4.9", "@typescript-eslint/eslint-plugin": "8.33.0", "@typescript-eslint/parser": "8.33.0", esbuild: "0.25.5", 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" } };
|
|
54
54
|
|
|
55
55
|
// src/lib/k8s.ts
|
|
56
56
|
var import_kubernetes_fluent_client = require("kubernetes-fluent-client");
|
package/package.json
CHANGED
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"!src/fixtures/**",
|
|
17
17
|
"!dist/**/*.test.d.ts*"
|
|
18
18
|
],
|
|
19
|
-
"version": "0.51.6-nightly.
|
|
19
|
+
"version": "0.51.6-nightly.7",
|
|
20
20
|
"main": "dist/lib.js",
|
|
21
21
|
"types": "dist/lib.d.ts",
|
|
22
22
|
"scripts": {
|
|
@@ -77,7 +77,7 @@
|
|
|
77
77
|
"@types/express": "5.0.3",
|
|
78
78
|
"@types/json-pointer": "^1.0.34",
|
|
79
79
|
"@types/node": "24.x.x",
|
|
80
|
-
"@types/node-forge": "1.3.
|
|
80
|
+
"@types/node-forge": "1.3.13",
|
|
81
81
|
"@types/uuid": "10.0.0",
|
|
82
82
|
"@types/ws": "^8.18.1",
|
|
83
83
|
"@vitest/coverage-v8": "^3.2.3",
|
package/src/cli/crd/create.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// SPDX-License-Identifier: Apache-2.0
|
|
2
2
|
// SPDX-FileCopyrightText: 2023-Present The Pepr Authors
|
|
3
3
|
|
|
4
|
-
import { Command } from "commander";
|
|
4
|
+
import { Command, Option } from "commander";
|
|
5
5
|
import { createDirectoryIfNotExists } from "../../lib/filesystemService";
|
|
6
6
|
import { promises as fs } from "fs";
|
|
7
7
|
import path from "path";
|
|
@@ -9,18 +9,20 @@ import path from "path";
|
|
|
9
9
|
// Scaffolds a new CRD TypeScript definition
|
|
10
10
|
const create = new Command("create")
|
|
11
11
|
.description("Create a new CRD TypeScript definition")
|
|
12
|
-
.
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
validateScope,
|
|
20
|
-
"Namespaced",
|
|
12
|
+
.addOption(
|
|
13
|
+
new Option(
|
|
14
|
+
"-S, --scope <scope>",
|
|
15
|
+
"Whether the resulting custom resource is cluster- or namespace-scoped",
|
|
16
|
+
)
|
|
17
|
+
.choices(["Namespaced", "Cluster"])
|
|
18
|
+
.default("Namespaced"),
|
|
21
19
|
)
|
|
22
|
-
.option("--
|
|
23
|
-
.
|
|
20
|
+
.option("-d, --domain <domain>", "Optional domain for CRD (e.g. pepr.dev)", "pepr.dev")
|
|
21
|
+
.requiredOption("-g, --group <group>", "API group (e.g. cache)")
|
|
22
|
+
.requiredOption("-k, --kind <kind>", "Kind name (e.g. memcached)")
|
|
23
|
+
.option("-p, --plural <plural>", "Plural name for CRD (e.g. memcacheds)")
|
|
24
|
+
.option("-s, --short-name <name>", "Short name for CRD (e.g. mc)", "")
|
|
25
|
+
.requiredOption("-v, --version <version>", "API version (e.g. v1alpha1)")
|
|
24
26
|
.action(async ({ group, version, kind, domain, scope, plural, shortName }) => {
|
|
25
27
|
console.log("This feature is currently in alpha.\n");
|
|
26
28
|
const outputDir = path.resolve(`./api/${version}`);
|
|
@@ -125,10 +127,3 @@ type ${kind}StatusCondition = {
|
|
|
125
127
|
|
|
126
128
|
`;
|
|
127
129
|
};
|
|
128
|
-
|
|
129
|
-
export function validateScope(value: string): "Cluster" | "Namespaced" {
|
|
130
|
-
if (value !== "Cluster" && value !== "Namespaced") {
|
|
131
|
-
throw new Error("Scope must be either 'Cluster' or 'Namespaced'");
|
|
132
|
-
}
|
|
133
|
-
return value;
|
|
134
|
-
}
|
package/src/cli/crd/generate.ts
CHANGED
|
@@ -21,7 +21,7 @@ import { WarningMessages, ErrorMessages } from "./messages";
|
|
|
21
21
|
|
|
22
22
|
export default new Command("generate")
|
|
23
23
|
.description("Generate CRD manifests from TypeScript definitions")
|
|
24
|
-
.option("--output <
|
|
24
|
+
.option("-o, --output <directory>", "Output directory for generated CRDs", "./crds")
|
|
25
25
|
.action(generateCRDs);
|
|
26
26
|
|
|
27
27
|
export function extractCRDDetails(
|
package/src/cli/dev.ts
CHANGED
|
@@ -16,19 +16,19 @@ export default function (program: RootCmd): void {
|
|
|
16
16
|
program
|
|
17
17
|
.command("dev")
|
|
18
18
|
.description("Setup a local webhook development environment")
|
|
19
|
-
.option("-
|
|
20
|
-
.option("--
|
|
19
|
+
.option("-H, --host <host>", "Host to listen on", "host.k3d.internal")
|
|
20
|
+
.option("-y, --yes", "Skip confirmation prompt")
|
|
21
21
|
.action(async opts => {
|
|
22
|
-
// Prompt the user to confirm if they didn't pass the --
|
|
23
|
-
if (!opts.
|
|
22
|
+
// Prompt the user to confirm if they didn't pass the --yes flag
|
|
23
|
+
if (!opts.yes) {
|
|
24
24
|
const confirm = await prompt({
|
|
25
25
|
type: "confirm",
|
|
26
|
-
name: "
|
|
26
|
+
name: "yes",
|
|
27
27
|
message: "This will remove and redeploy the module. Continue?",
|
|
28
28
|
});
|
|
29
29
|
|
|
30
30
|
// Exit if the user doesn't confirm
|
|
31
|
-
if (!confirm.
|
|
31
|
+
if (!confirm.yes) {
|
|
32
32
|
process.exitCode = 0;
|
|
33
33
|
return;
|
|
34
34
|
}
|
package/src/cli/format/index.ts
CHANGED
|
@@ -55,7 +55,7 @@ export async function peprFormat(validateOnly: boolean): Promise<boolean> {
|
|
|
55
55
|
await ESLint.outputFixes(results);
|
|
56
56
|
}
|
|
57
57
|
|
|
58
|
-
hasFailure = await formatWithPrettier(results, validateOnly);
|
|
58
|
+
hasFailure = hasFailure || (await formatWithPrettier(results, validateOnly));
|
|
59
59
|
|
|
60
60
|
return !hasFailure;
|
|
61
61
|
} catch (e) {
|
package/src/cli/init/index.ts
CHANGED
|
@@ -24,6 +24,7 @@ import { createDir, sanitizeName, write } from "./utils";
|
|
|
24
24
|
import { confirm, PromptOptions, walkthrough } from "./walkthrough";
|
|
25
25
|
import { ErrorList } from "../../lib/errors";
|
|
26
26
|
import { UUID_LENGTH_LIMIT } from "./enums";
|
|
27
|
+
import { Option } from "commander";
|
|
27
28
|
|
|
28
29
|
export default function (program: RootCmd): void {
|
|
29
30
|
let response = {} as PromptOptions;
|
|
@@ -31,13 +32,14 @@ export default function (program: RootCmd): void {
|
|
|
31
32
|
program
|
|
32
33
|
.command("init")
|
|
33
34
|
.description("Initialize a new Pepr Module")
|
|
34
|
-
.option("--
|
|
35
|
-
.
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
.option(
|
|
35
|
+
.option("-d, --description <string>", "Explain the purpose of the new module.")
|
|
36
|
+
.addOption(
|
|
37
|
+
new Option("-e, --error-behavior <behavior>", "Set an error behavior.").choices(ErrorList),
|
|
38
|
+
)
|
|
39
|
+
.option("-n, --name <string>", "Set the name of the new module.")
|
|
40
|
+
.option("-s, --skip-post-init", "Skip npm install, git init, and VSCode launch.")
|
|
39
41
|
.option(
|
|
40
|
-
"--uuid
|
|
42
|
+
"-u, --uuid <string>",
|
|
41
43
|
"Unique identifier for your module with a max length of 36 characters.",
|
|
42
44
|
(uuid: string): string => {
|
|
43
45
|
if (uuid.length > UUID_LENGTH_LIMIT) {
|
|
@@ -46,6 +48,7 @@ export default function (program: RootCmd): void {
|
|
|
46
48
|
return uuid.toLocaleLowerCase();
|
|
47
49
|
},
|
|
48
50
|
)
|
|
51
|
+
.option("-y, --yes", "Skip verification prompt when creating a new module.")
|
|
49
52
|
.hook("preAction", async thisCommand => {
|
|
50
53
|
// TODO: Overrides for testing. Don't be so gross with Node CLI testing
|
|
51
54
|
// TODO: See pepr/#1140
|
|
@@ -68,7 +71,7 @@ export default function (program: RootCmd): void {
|
|
|
68
71
|
const dirName = sanitizeName(response.name);
|
|
69
72
|
const packageJSON = genPkgJSON(response, pkgOverride);
|
|
70
73
|
|
|
71
|
-
const confirmed = await confirm(dirName, packageJSON, peprTSTemplate.path, opts.
|
|
74
|
+
const confirmed = await confirm(dirName, packageJSON, peprTSTemplate.path, opts.yes);
|
|
72
75
|
|
|
73
76
|
if (confirmed) {
|
|
74
77
|
console.log("Creating new Pepr module...");
|
|
@@ -137,7 +137,7 @@ export async function confirm(
|
|
|
137
137
|
): Promise<boolean> {
|
|
138
138
|
const confirmationPrompt: PromptObject = {
|
|
139
139
|
type: "confirm",
|
|
140
|
-
name: "
|
|
140
|
+
name: "yes",
|
|
141
141
|
message: "Create the new Pepr module?",
|
|
142
142
|
};
|
|
143
143
|
const confirmationMessage = `To be generated:
|
|
@@ -162,9 +162,7 @@ ${packageJSON.print.replace(/^/gm, " │ ")}
|
|
|
162
162
|
console.log(confirmationMessage);
|
|
163
163
|
const confirm = await prompt([confirmationPrompt]);
|
|
164
164
|
const shouldCreateModule =
|
|
165
|
-
confirm.
|
|
166
|
-
? true
|
|
167
|
-
: false;
|
|
165
|
+
confirm.yes === "y" || confirm.yes === "yes" || confirm.yes === true ? true : false;
|
|
168
166
|
return shouldCreateModule;
|
|
169
167
|
}
|
|
170
168
|
}
|
package/src/cli/update/index.ts
CHANGED
|
@@ -21,7 +21,7 @@ export default function (program: RootCmd): void {
|
|
|
21
21
|
program
|
|
22
22
|
.command("update")
|
|
23
23
|
.description("Update this Pepr module. Not recommended for prod as it may change files.")
|
|
24
|
-
.option("--skip-template-update", "
|
|
24
|
+
.option("-s, --skip-template-update", "Do not update template files")
|
|
25
25
|
.action(async opts => {
|
|
26
26
|
if (!opts.skipTemplateUpdate) {
|
|
27
27
|
const { confirm } = await prompt({
|