pepr 0.0.1

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/.eslintrc.json ADDED
@@ -0,0 +1,16 @@
1
+ {
2
+ "env": {
3
+ "browser": false,
4
+ "es2021": true
5
+ },
6
+ "extends": ["eslint:recommended", "plugin:@typescript-eslint/recommended"],
7
+ "overrides": [],
8
+ "parser": "@typescript-eslint/parser",
9
+ "parserOptions": {
10
+ "ecmaVersion": "latest",
11
+ "sourceType": "module"
12
+ },
13
+ "plugins": ["@typescript-eslint"],
14
+ "rules": {},
15
+ "ignorePatterns": ["node_modules", "dist"]
16
+ }
package/.prettierrc ADDED
@@ -0,0 +1,14 @@
1
+ {
2
+ "arrowParens": "avoid",
3
+ "bracketSameLine": false,
4
+ "bracketSpacing": true,
5
+ "embeddedLanguageFormatting": "auto",
6
+ "insertPragma": false,
7
+ "printWidth": 80,
8
+ "quoteProps": "as-needed",
9
+ "requirePragma": false,
10
+ "semi": true,
11
+ "useTabs": false,
12
+ "vueIndentScriptAndStyle": false,
13
+ "tabWidth": 2
14
+ }
package/LICENSE ADDED
File without changes
package/README.md ADDED
@@ -0,0 +1,159 @@
1
+ # Pepr
2
+
3
+ Pepr is an open-source project licensed under the Apache 2 license, designed to be a declarative Kubernetes configuration system that automates application reconfiguration. It allows users to interact with user-defined "capabilities" that react to Kubernetes mutating webhook events.
4
+
5
+ ## Features
6
+
7
+ - Define a set of Kubernetes transformations/actions as Pepr capabilities.
8
+ - Write capabilities in TypeScript and bundle them for in-cluster processing in [NodeJS](https://nodejs.org/).
9
+ - React to cluster resources by mutating them, creating new Kubernetes resources, or performing arbitrary exec/API operations.
10
+
11
+ ## Concepts
12
+
13
+ ### Module
14
+
15
+ A module is the top-level collection of capabilities. It is a single, complete TypeScript project that includes an entry point to load all the configuration and capabilities, along with their capability actions. During the Pepr build process, each module produces a unique Kubernetes MutatingWebhookConfiguration and ValidatingWebhookConfiguration, along with a secret containing the transpiled and compressed TypeScript code. The webhooks and secret are deployed into the Kubernetes cluster for processing by a common Pepr controller.
16
+
17
+ ### Capability
18
+
19
+ A capability is set of related CapabilityActions that work together to achieve a specific transformation or operation on Kubernetes resources. Capabilities are user-defined and can include one or more CapabilityActions. They are defined within a Pepr module and can be used in both MutatingWebhookConfigurations and ValidatingWebhookConfigurations. A Capability can have a specific scope, such as mutating or validating, and can be used in multiple Pepr modules if needed.
20
+
21
+ ### CapabilityAction
22
+
23
+ CapabilityAction is a discrete set of behaviors defined in a single function that acts on a given Kubernetes GroupVersionKind (GVK) passed in from Kubernetes. CapabilityActions are the atomic operations that are performed on Kubernetes resources by Pepr.
24
+
25
+ For example, a CapabilityAction could be responsible for adding a specific label to a Kubernetes resource, or for modifying a specific field in a resource's metadata. CapabilityActions can be grouped together within a Capability to provide a more comprehensive set of operations that can be performed on Kubernetes resources.
26
+
27
+ ## Example
28
+
29
+ Define a new capability:
30
+
31
+ ```
32
+ pepr new hello-world -d demo
33
+ ```
34
+
35
+ This will create a new directory tree called `demo/hello-world` with the following structure:
36
+
37
+ ### demo/hello-world/index.ts
38
+
39
+ ```typescript
40
+ import "./test-mutations";
41
+ ```
42
+
43
+ ### demo/hello-world/index.ts
44
+
45
+ ```typescript
46
+ import { a } from "@k8s";
47
+ import { Capability } from "@pepr";
48
+
49
+ const { When } = new Capability({
50
+ // The unique name of the capability
51
+ name: "hello-world",
52
+ // A short description of the capability
53
+ description: "Type a useful description here 🦄",
54
+ // Limit what namespaces the capability can be used in (optional)
55
+ namespaces: [],
56
+ });
57
+ ```
58
+
59
+ Next, we need to define some actions to perform when specific Kubernetes resources are created, updated or deleted in the cluster. Pepr provides a set of actions that can be used to react to Kubernetes resources, such as `a.Pod`, `a.Deployment`, `a.CronJob`, etc. These actions can be chained together to create complex conditions, such as `a.Pod.IsCreated().InNamespace("default")` or `a.Deployment.IsUpdated().WithLabel("changeme=true")`. Below is an example of a capability that reacts to the creation of a CronJob resource:
60
+
61
+ ```typescript
62
+ When(a.CronJob).IsCreated().Then(modifyCronJobSchedule);
63
+
64
+ function modifyCronJobSchedule(cronJob: Action<CronJob>) {
65
+ cronJob.Raw.spec.schedule = "*/5 * * * *";
66
+ }
67
+ ```
68
+
69
+ Here's a more complex example that reacts to the creation of a Deployment resource:
70
+
71
+ ```typescript
72
+ When(a.Deployment)
73
+ .IsCreatedOrUpdated()
74
+ .InNamespace("mutation-namespace")
75
+ .WithLabel("changeme", "true")
76
+ .Then(changeABunchOfDeploymentThings);
77
+
78
+ function changeABunchOfDeploymentThings(deployment: Action<Deployment>) {
79
+ deployment
80
+ .SetLabel("mutated", "true")
81
+ .SetLabel("test", "thing")
82
+ .SetAnnotation("test2", "thing")
83
+ .RemoveLabel("test3");
84
+
85
+ if (deployment.HasLabel("test")) {
86
+ deployment.SetLabel("test5", "thing");
87
+ }
88
+
89
+ let { spec } = deployment.Raw;
90
+ spec.strategy.type = "Recreate";
91
+ spec.minReadySeconds = 3;
92
+
93
+ if (deployment.PermitSideEffects) {
94
+ // Do side-effect inducing things
95
+ }
96
+ }
97
+ ```
98
+
99
+ Now you can build and bundle your capability:
100
+
101
+ ```
102
+ pepr build hello-world
103
+ ```
104
+
105
+ ## Logical Pepr Flow
106
+
107
+ ```mermaid
108
+ graph LR
109
+
110
+ subgraph "Module 3 (Validate Only)"
111
+ direction LR
112
+ Q[entrypoint 3] --> R[Validate Webhook];
113
+ R --> S[Capability a <br><i>- action 1<br>- action 2</i>];
114
+ S --> T[Capability b <br><i>- action 1<br>- action 2</i>];
115
+ end
116
+
117
+ subgraph "Module 2 (Mutate Only)"
118
+ direction LR
119
+ K[entrypoint 2] --> L[Mutate Webhook];
120
+ L --> M[Capability a <br><i>- action 1<br>- action 2</i>];
121
+ M --> N[Capability b <br><i>- action 1<br>- action 2<br>- action 3</i>];
122
+ N --> O[Capability c <br><i>- action 1</i>];
123
+ end
124
+
125
+ subgraph "Module 1 (Mutate & Validate)"
126
+ direction LR
127
+ A[entrypoint 1] --> B[Mutate Webhook];
128
+ A --> C[Validate Webhook];
129
+ B --> D[Capability a <br><i>- action 1</i>];
130
+ D --> E[Capability b <br><i>- action 1<br>- action 2</i>];
131
+ E --> F[Capability c <br><i>- action 1<br>- action 2</i>];
132
+ C --> G[Capability d <br><i>- action 1<br>- action 2</i>];
133
+ G --> H[Capability e <br><i>- action 1</i>];
134
+ H --> I[Capability f <br><i>- action 1<br>- action 2<br>- action 3</i>];
135
+ end
136
+
137
+
138
+
139
+ %% Defining node styles
140
+ classDef Validate fill:#66ff66,color:#000;
141
+ classDef Mutate fill:#5786ea,color:#000;
142
+
143
+
144
+ class L,M,N,O Mutate;
145
+ class B,D,E,F Mutate;
146
+
147
+ class R,S,T Validate;
148
+ class C,G,H,I Validate;
149
+ ```
150
+
151
+ ## TypeScript
152
+
153
+ [TypeScript](https://www.typescriptlang.org/) is a strongly typed, object-oriented programming language built on top of JavaScript. It provides optional static typing and a rich type system, allowing developers to write more robust code. TypeScript is transpiled to JavaScript, enabling it to run in any environment that supports JavaScript. Pepr allows you to use JavaScript or TypeScript to write capabilities, but TypeScript is recommended for its type safety and rich type system. You can learn more about TypeScript [here](https://www.typescriptlang.org/docs/handbook/typescript-from-scratch.html).
154
+
155
+ ## Kubernetes Mutating Webhooks
156
+
157
+ Kubernetes mutating webhooks are a powerful feature that allows users to intercept and modify Kubernetes API requests, such as resource creation or updates, before they are persisted to the cluster. They can be used to enforce security policies, default values, or perform custom transformations on resources.
158
+
159
+ Pepr uses Kubernetes mutating webhooks to react to cluster resource events and apply user-defined capabilities, which are sets of Kubernetes transformations/actions.
@@ -0,0 +1,276 @@
1
+ 'use strict';
2
+
3
+ var clientNode = require('@kubernetes/client-node');
4
+ var json = require('@rollup/plugin-json');
5
+ var nodeResolve = require('@rollup/plugin-node-resolve');
6
+ var typescript = require('@rollup/plugin-typescript');
7
+ var fs = require('fs');
8
+ var path = require('path');
9
+ var rollup = require('rollup');
10
+ require('@kubernetes/client-node/dist');
11
+ require('ramda');
12
+ require('fast-json-patch');
13
+ var zlib = require('zlib');
14
+ var commander = require('commander');
15
+ var child_process = require('child_process');
16
+ var chokidar = require('chokidar');
17
+ var util = require('util');
18
+
19
+ var version = "0.0.1";
20
+
21
+ var LogLevel;
22
+ (function (LogLevel) {
23
+ LogLevel[LogLevel["debug"] = 0] = "debug";
24
+ LogLevel[LogLevel["info"] = 1] = "info";
25
+ LogLevel[LogLevel["warn"] = 2] = "warn";
26
+ LogLevel[LogLevel["error"] = 3] = "error";
27
+ })(LogLevel || (LogLevel = {}));
28
+ var ConsoleColors;
29
+ (function (ConsoleColors) {
30
+ ConsoleColors["Reset"] = "\u001B[0m";
31
+ ConsoleColors["Bright"] = "\u001B[1m";
32
+ ConsoleColors["Dim"] = "\u001B[2m";
33
+ ConsoleColors["Underscore"] = "\u001B[4m";
34
+ ConsoleColors["Blink"] = "\u001B[5m";
35
+ ConsoleColors["Reverse"] = "\u001B[7m";
36
+ ConsoleColors["Hidden"] = "\u001B[8m";
37
+ ConsoleColors["FgBlack"] = "\u001B[30m";
38
+ ConsoleColors["FgRed"] = "\u001B[31m";
39
+ ConsoleColors["FgGreen"] = "\u001B[32m";
40
+ ConsoleColors["FgYellow"] = "\u001B[33m";
41
+ ConsoleColors["FgBlue"] = "\u001B[34m";
42
+ ConsoleColors["FgMagenta"] = "\u001B[35m";
43
+ ConsoleColors["FgCyan"] = "\u001B[36m";
44
+ ConsoleColors["FgWhite"] = "\u001B[37m";
45
+ ConsoleColors["BgBlack"] = "\u001B[40m";
46
+ ConsoleColors["BgRed"] = "\u001B[41m";
47
+ ConsoleColors["BgGreen"] = "\u001B[42m";
48
+ ConsoleColors["BgYellow"] = "\u001B[43m";
49
+ ConsoleColors["BgBlue"] = "\u001B[44m";
50
+ ConsoleColors["BgMagenta"] = "\u001B[45m";
51
+ ConsoleColors["BgCyan"] = "\u001B[46m";
52
+ ConsoleColors["BgWhite"] = "\u001B[47m";
53
+ })(ConsoleColors || (ConsoleColors = {}));
54
+ class Logger {
55
+ constructor(logLevel) {
56
+ this._logLevel = logLevel;
57
+ }
58
+ SetLogLevel(logLevel) {
59
+ this._logLevel = LogLevel[logLevel];
60
+ this.debug(`Log level set to ${logLevel}`);
61
+ }
62
+ debug(message, prefix) {
63
+ this.log(LogLevel.debug, message, prefix);
64
+ }
65
+ info(message, prefix) {
66
+ this.log(LogLevel.info, message, prefix);
67
+ }
68
+ warn(message, prefix) {
69
+ this.log(LogLevel.warn, message, prefix);
70
+ }
71
+ error(message, prefix) {
72
+ this.log(LogLevel.error, message, prefix);
73
+ }
74
+ log(logLevel, message, callerPrefix = "") {
75
+ const color = {
76
+ [LogLevel.debug]: ConsoleColors.FgBlack,
77
+ [LogLevel.info]: ConsoleColors.FgCyan,
78
+ [LogLevel.warn]: ConsoleColors.FgYellow,
79
+ [LogLevel.error]: ConsoleColors.FgRed,
80
+ };
81
+ if (logLevel >= this._logLevel) {
82
+ let prefix = "[" + LogLevel[logLevel] + "]\t" + callerPrefix;
83
+ prefix = this.colorize(prefix, color[logLevel]);
84
+ if (typeof message !== "string") {
85
+ console.log(prefix);
86
+ console.debug("%o", message);
87
+ }
88
+ else {
89
+ console.log(prefix + "\t" + message);
90
+ }
91
+ }
92
+ }
93
+ colorize(text, color) {
94
+ return color + text + ConsoleColors.Reset;
95
+ }
96
+ }
97
+ var Log = new Logger(LogLevel.info);
98
+
99
+ var Operation;
100
+ (function (Operation) {
101
+ Operation["CREATE"] = "CREATE";
102
+ Operation["UPDATE"] = "UPDATE";
103
+ Operation["DELETE"] = "DELETE";
104
+ Operation["CONNECT"] = "CONNECT";
105
+ })(Operation || (Operation = {}));
106
+
107
+ var HookPhase;
108
+ (function (HookPhase) {
109
+ HookPhase["mutate"] = "mutate";
110
+ HookPhase["valdiate"] = "validate";
111
+ })(HookPhase || (HookPhase = {}));
112
+ var Event;
113
+ (function (Event) {
114
+ Event["Create"] = "create";
115
+ Event["Update"] = "update";
116
+ Event["Delete"] = "delete";
117
+ Event["CreateOrUpdate"] = "createOrUpdate";
118
+ })(Event || (Event = {}));
119
+
120
+ function moduleSecret(uuid, data) {
121
+ const compressed = zlib.gzipSync(data);
122
+ return {
123
+ apiVersion: "v1",
124
+ kind: "Secret",
125
+ metadata: {
126
+ name: `module-${uuid}`,
127
+ namespace: "pepr-system",
128
+ },
129
+ type: "Opaque",
130
+ data: {
131
+ module: compressed.toString("base64"),
132
+ },
133
+ };
134
+ }
135
+
136
+ const externalLibs = [
137
+ /@kubernetes\/client-node(\/.*)?/,
138
+ "commander",
139
+ "express",
140
+ "fast-json-patch",
141
+ "ramda",
142
+ ];
143
+ const plugins = [
144
+ nodeResolve({
145
+ preferBuiltins: true,
146
+ }),
147
+ json(),
148
+ typescript({
149
+ tsconfig: "./tsconfig.json",
150
+ declaration: false,
151
+ removeComments: true,
152
+ sourceMap: false,
153
+ }),
154
+ ];
155
+ async function buildModule(moduleDir) {
156
+ try {
157
+ const modulePath = path.resolve(moduleDir, "index.ts");
158
+ const moduleText = await fs.promises.readFile(modulePath, { encoding: "utf-8" });
159
+ const match = moduleText.match(/peprModuleUUID:\s*"(.+?)"/);
160
+ const peprModuleUUID = match && match[1];
161
+ const name = `pepr-${peprModuleUUID}.js`;
162
+ if (!peprModuleUUID) {
163
+ throw new Error("Could not load the peprModuleUUID in index.ts");
164
+ }
165
+ const bundle = await rollup.rollup({
166
+ plugins,
167
+ external: externalLibs,
168
+ treeshake: true,
169
+ input: modulePath,
170
+ });
171
+ await bundle.write({
172
+ dir: "dist",
173
+ format: "cjs",
174
+ entryFileNames: name,
175
+ });
176
+ return {
177
+ path: path.resolve("dist", name),
178
+ uuid: peprModuleUUID,
179
+ };
180
+ }
181
+ catch (e) {
182
+ Log.error(e.message);
183
+ process.exit(1);
184
+ }
185
+ }
186
+ function build (program) {
187
+ program
188
+ .command("build")
189
+ .description("Build a Pepr Module for deployment")
190
+ .action(async (opts) => {
191
+ const { path: path$1, uuid } = await buildModule(opts.dir);
192
+ const code = await fs.promises.readFile(path$1, { encoding: "utf-8" });
193
+ const secret = moduleSecret(uuid, code);
194
+ const yaml = clientNode.dumpYaml(secret);
195
+ const yamlPath = path.resolve("dist", `pepr-module-${uuid}.yaml`);
196
+ await fs.promises.writeFile(yamlPath, yaml);
197
+ Log.debug(`Module compiled successfully at ${path$1}`);
198
+ Log.info(`K8s resource for the module saved to ${yamlPath}`);
199
+ });
200
+ }
201
+
202
+ function capability (program) {
203
+ program
204
+ .command("new")
205
+ .description("Create a new Pepr Capability")
206
+ .action(() => {
207
+ console.log("new");
208
+ });
209
+ }
210
+
211
+ function init (program) {
212
+ program
213
+ .command("init")
214
+ .description("Initialize a new Pepr Module")
215
+ .action(() => {
216
+ console.log("init");
217
+ });
218
+ }
219
+
220
+ class RootCmd extends commander.Command {
221
+ createCommand(name) {
222
+ const cmd = new commander.Command(name);
223
+ cmd.option("-l, --log-level [level]", "Log level: debug, info, warn, error", "info");
224
+ cmd.option("-d, --dir [directory]", "Pepr module directory", ".");
225
+ cmd.hook("preAction", run => {
226
+ Log.SetLogLevel(run.opts().logLevel);
227
+ });
228
+ return cmd;
229
+ }
230
+ }
231
+
232
+ const exec = util.promisify(child_process.exec);
233
+ function test (program) {
234
+ program
235
+ .command("test")
236
+ .description("Test a Pepr Module locally")
237
+ .option("-w, --watch", "Watch for changes and re-run the test")
238
+ .action(async (opts) => {
239
+ Log.info("Test Module");
240
+ await buildAndTest(opts.dir);
241
+ if (opts.watch) {
242
+ const moduleFiles = path.resolve(opts.dir, "**", "*.ts");
243
+ const watcher = chokidar.watch(moduleFiles);
244
+ watcher.on("ready", () => {
245
+ Log.info(`Watching for changes in ${moduleFiles}`);
246
+ watcher.on("all", async (event, path) => {
247
+ Log.debug({ event, path }, "File changed");
248
+ await buildAndTest(opts.dir);
249
+ });
250
+ });
251
+ }
252
+ });
253
+ }
254
+ async function buildAndTest(dir) {
255
+ const { path } = await buildModule(dir);
256
+ Log.info(`Module built successfully at ${path}`);
257
+ try {
258
+ const { stdout, stderr } = await exec(`node ${path}`);
259
+ console.log(stdout);
260
+ console.log(stderr);
261
+ }
262
+ catch (e) {
263
+ Log.debug(e);
264
+ Log.error(`Error running module: ${e}`);
265
+ process.exit(1);
266
+ }
267
+ }
268
+
269
+ const program = new RootCmd();
270
+ program.version(version);
271
+ init(program);
272
+ build(program);
273
+ capability(program);
274
+ test(program);
275
+ program.parse();
276
+ //# sourceMappingURL=pepr-cli.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pepr-cli.js","sources":["../src/lib/logger.ts","../src/lib/k8s/types.ts","../src/lib/types.ts","../src/lib/k8s/webhook.ts","../src/cli/build.ts","../src/cli/capability.ts","../src/cli/init.ts","../src/cli/root.ts","../src/cli/test.ts","../src/cli/index.ts"],"sourcesContent":[null,null,null,null,null,null,null,null,null,null],"names":["gzipSync","resolve","fs","rollup","path","dumpYaml","Command","promisify","execCallback","watch"],"mappings":";;;;;;;;;;;;;;;;;;;;AAMA,IAAY,QAKX,CAAA;AALD,CAAA,UAAY,QAAQ,EAAA;AAClB,IAAA,QAAA,CAAA,QAAA,CAAA,OAAA,CAAA,GAAA,CAAA,CAAA,GAAA,OAAS,CAAA;AACT,IAAA,QAAA,CAAA,QAAA,CAAA,MAAA,CAAA,GAAA,CAAA,CAAA,GAAA,MAAQ,CAAA;AACR,IAAA,QAAA,CAAA,QAAA,CAAA,MAAA,CAAA,GAAA,CAAA,CAAA,GAAA,MAAQ,CAAA;AACR,IAAA,QAAA,CAAA,QAAA,CAAA,OAAA,CAAA,GAAA,CAAA,CAAA,GAAA,OAAS,CAAA;AACX,CAAC,EALW,QAAQ,KAAR,QAAQ,GAKnB,EAAA,CAAA,CAAA,CAAA;AAED,IAAK,aA0BJ,CAAA;AA1BD,CAAA,UAAK,aAAa,EAAA;AAChB,IAAA,aAAA,CAAA,OAAA,CAAA,GAAA,WAAiB,CAAA;AACjB,IAAA,aAAA,CAAA,QAAA,CAAA,GAAA,WAAkB,CAAA;AAClB,IAAA,aAAA,CAAA,KAAA,CAAA,GAAA,WAAe,CAAA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description": "Kubernetes application engine",
5
+ "author": "Defense Unicorns",
6
+ "homepage": "https://github.com/defenseunicorns/pepr",
7
+ "license": "Apache-2.0",
8
+ "main": "dist/pepr-cli.js",
9
+ "repository": "defenseunicorns/pepr",
10
+ "engines": {
11
+ "node": ">=18.0.0"
12
+ },
13
+ "scripts": {
14
+ "webhook": "node dist/default.js",
15
+ "build": "rollup -c",
16
+ "start": "rollup -c -w --watch.onEnd 'sleep 1 && node dist/pepr-test.js'",
17
+ "test": "ava",
18
+ "lint": "npx eslint src",
19
+ "lint:fix": "npm run lint -- --fix",
20
+ "prettier": "npx prettier src --check",
21
+ "prettier:fix": "npm run prettier -- --write"
22
+ },
23
+ "dependencies": {
24
+ "@kubernetes/client-node": "^0.18.1",
25
+ "@types/ramda": "^0.28.23",
26
+ "chokidar": "^3.5.3",
27
+ "commander": "^10.0.0",
28
+ "express": "^4.18.2",
29
+ "fast-json-patch": "^3.1.1",
30
+ "ramda": "^0.28.0"
31
+ },
32
+ "devDependencies": {
33
+ "@rollup/plugin-commonjs": "^24.0.1",
34
+ "@rollup/plugin-json": "^6.0.0",
35
+ "@rollup/plugin-node-resolve": "^15.0.1",
36
+ "@rollup/plugin-terser": "^0.4.0",
37
+ "@rollup/plugin-typescript": "^11.0.0",
38
+ "@typescript-eslint/eslint-plugin": "^5.57.0",
39
+ "@typescript-eslint/parser": "^5.57.0",
40
+ "ava": "^5.2.0",
41
+ "eslint": "^8.37.0",
42
+ "prettier": "^2.8.7",
43
+ "rollup": "^3.20.2",
44
+ "rollup-plugin-visualizer": "^5.9.0",
45
+ "ts-node": "^10.9.1",
46
+ "tsconfig-paths": "^4.1.2",
47
+ "tslib": "^2.5.0",
48
+ "typescript": "^5.0.2"
49
+ },
50
+ "ava": {
51
+ "extensions": [
52
+ "ts"
53
+ ],
54
+ "require": [
55
+ "ts-node/register",
56
+ "tsconfig-paths/register"
57
+ ]
58
+ }
59
+ }
@@ -0,0 +1,26 @@
1
+ // rollup.config.js
2
+ import json from '@rollup/plugin-json';
3
+ import typescript from '@rollup/plugin-typescript';
4
+ import { visualizer } from 'rollup-plugin-visualizer';
5
+
6
+ export default {
7
+ input: {
8
+ cli: 'src/cli/index.ts',
9
+ controller: 'src/controller/index.ts',
10
+ },
11
+ output: {
12
+ dir: 'dist',
13
+ format: 'cjs',
14
+ sourcemap: true,
15
+ entryFileNames: 'pepr-[name].js'
16
+ },
17
+ plugins: [
18
+ json(),
19
+ typescript({
20
+ tsconfig: "./tsconfig.json",
21
+ sourceMap: true,
22
+ }),
23
+ visualizer(),
24
+ ],
25
+ treeshake: true,
26
+ };
package/tsconfig.json ADDED
@@ -0,0 +1,22 @@
1
+ {
2
+ "compilerOptions": {
3
+ "allowSyntheticDefaultImports": true,
4
+ "baseUrl": ".",
5
+ "lib": ["ES2020"],
6
+ "moduleResolution": "node",
7
+ "paths": {
8
+ "@fixtures/*": ["src/fixtures/*"],
9
+ "@pepr": ["src/lib"],
10
+ "@k8s": ["src/lib/k8s"]
11
+ },
12
+ "removeComments": true,
13
+ "resolveJsonModule": true,
14
+ "sourceMap": true,
15
+ "strict": false,
16
+ "target": "ES2020"
17
+ },
18
+ "include": ["src/**/*.ts"],
19
+ "watchOptions": {
20
+ "excludeDirectories": ["node_modules"]
21
+ }
22
+ }