pepr 0.1.28 → 0.1.30
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/cli.ts +3 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +4 -0
- package/dist/index.js +14 -5
- package/dist/package.json +2 -2
- package/dist/src/cli/banner.js +4 -1
- package/dist/src/cli/build.js +41 -34
- package/dist/src/cli/capability.js +4 -1
- package/dist/src/cli/deploy.js +18 -12
- package/dist/src/cli/dev.js +32 -26
- package/dist/src/cli/index.js +24 -19
- package/dist/src/cli/init/index.js +32 -26
- package/dist/src/cli/init/templates.js +23 -18
- package/dist/src/cli/init/utils.js +12 -6
- package/dist/src/cli/init/walkthrough.js +27 -19
- package/dist/src/cli/root.js +12 -5
- package/dist/src/cli/test.js +23 -17
- package/dist/src/lib/capability.js +26 -19
- package/dist/src/lib/controller.js +18 -11
- package/dist/src/lib/filter.js +12 -5
- package/dist/src/lib/k8s/index.js +35 -4
- package/dist/src/lib/k8s/kinds.js +7 -3
- package/dist/src/lib/k8s/tls.js +17 -10
- package/dist/src/lib/k8s/types.js +5 -2
- package/dist/src/lib/k8s/upstream.js +45 -1
- package/dist/src/lib/k8s/webhook.js +54 -47
- package/dist/src/lib/logger.js +8 -4
- package/dist/src/lib/module.js +12 -5
- package/dist/src/lib/processor.js +21 -14
- package/dist/src/lib/request.js +29 -2
- package/dist/src/lib/types.js +9 -6
- package/package.json +2 -2
package/cli.ts
ADDED
package/dist/cli.d.ts
ADDED
package/dist/cli.js
ADDED
package/dist/index.js
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.Log = exports.Capability = exports.PeprModule = exports.a = void 0;
|
|
7
|
+
const capability_1 = require("./src/lib/capability");
|
|
8
|
+
Object.defineProperty(exports, "Capability", { enumerable: true, get: function () { return capability_1.Capability; } });
|
|
9
|
+
const k8s_1 = require("./src/lib/k8s");
|
|
10
|
+
Object.defineProperty(exports, "a", { enumerable: true, get: function () { return k8s_1.a; } });
|
|
11
|
+
const logger_1 = __importDefault(require("./src/lib/logger"));
|
|
12
|
+
exports.Log = logger_1.default;
|
|
13
|
+
const module_1 = require("./src/lib/module");
|
|
14
|
+
Object.defineProperty(exports, "PeprModule", { enumerable: true, get: function () { return module_1.PeprModule; } });
|
package/dist/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pepr",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.30",
|
|
4
4
|
"description": "Kubernetes application engine",
|
|
5
5
|
"author": "Defense Unicorns",
|
|
6
6
|
"homepage": "https://github.com/defenseunicorns/pepr",
|
|
7
7
|
"license": "Apache-2.0",
|
|
8
|
-
"bin": "dist/
|
|
8
|
+
"bin": "dist/cli.js",
|
|
9
9
|
"repository": "defenseunicorns/pepr",
|
|
10
10
|
"engines": {
|
|
11
11
|
"node": ">=18.0.0"
|
package/dist/src/cli/banner.js
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
2
3
|
// SPDX-FileCopyrightText: 2023-Present The Pepr Authors
|
|
3
|
-
|
|
4
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
exports.banner = void 0;
|
|
6
|
+
exports.banner = `[107;40m[38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m
|
|
4
7
|
[38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m
|
|
5
8
|
[38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m
|
|
6
9
|
[38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m [38;5;016m
|
package/dist/src/cli/build.js
CHANGED
|
@@ -1,14 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
2
3
|
// SPDX-FileCopyrightText: 2023-Present The Pepr Authors
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
4
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
5
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
6
|
+
};
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.buildModule = void 0;
|
|
9
|
+
const plugin_json_1 = __importDefault(require("@rollup/plugin-json"));
|
|
10
|
+
const package_json_1 = require("../../package.json");
|
|
11
|
+
const plugin_node_resolve_1 = __importDefault(require("@rollup/plugin-node-resolve"));
|
|
12
|
+
const plugin_typescript_1 = __importDefault(require("@rollup/plugin-typescript"));
|
|
13
|
+
const fs_1 = require("fs");
|
|
14
|
+
const path_1 = require("path");
|
|
15
|
+
const rollup_1 = require("rollup");
|
|
16
|
+
const logger_1 = __importDefault(require("../lib/logger"));
|
|
17
|
+
const webhook_1 = require("../lib/k8s/webhook");
|
|
18
|
+
function default_1(program) {
|
|
12
19
|
program
|
|
13
20
|
.command("build")
|
|
14
21
|
.description("Build a Pepr Module for deployment")
|
|
@@ -17,36 +24,35 @@ export default function (program) {
|
|
|
17
24
|
// Build the module
|
|
18
25
|
const { cfg, path, uuid } = await buildModule(opts.dir);
|
|
19
26
|
// Read the compiled module code
|
|
20
|
-
const code = await
|
|
27
|
+
const code = await fs_1.promises.readFile(path, { encoding: "utf-8" });
|
|
21
28
|
// Generate a secret for the module
|
|
22
|
-
const webhook = new Webhook({
|
|
29
|
+
const webhook = new webhook_1.Webhook({
|
|
23
30
|
...cfg.pepr,
|
|
24
31
|
description: cfg.description,
|
|
25
32
|
});
|
|
26
33
|
const yamlFile = `pepr-module-${uuid}.yaml`;
|
|
27
|
-
const yamlPath = resolve("dist", yamlFile);
|
|
34
|
+
const yamlPath = (0, path_1.resolve)("dist", yamlFile);
|
|
28
35
|
const yaml = webhook.allYaml(code);
|
|
29
|
-
const zarfPath = resolve("dist", "zarf.yaml");
|
|
36
|
+
const zarfPath = (0, path_1.resolve)("dist", "zarf.yaml");
|
|
30
37
|
const zarf = webhook.zarfYaml(yamlFile);
|
|
31
|
-
await
|
|
32
|
-
await
|
|
33
|
-
|
|
34
|
-
|
|
38
|
+
await fs_1.promises.writeFile(yamlPath, yaml);
|
|
39
|
+
await fs_1.promises.writeFile(zarfPath, zarf);
|
|
40
|
+
logger_1.default.debug(`Module compiled successfully at ${path}`);
|
|
41
|
+
logger_1.default.info(`K8s resource for the module saved to ${yamlPath}`);
|
|
35
42
|
});
|
|
36
43
|
}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
export async function buildModule(moduleDir) {
|
|
44
|
+
exports.default = default_1;
|
|
45
|
+
// Create a list of external libraries to exclude from the bundle, these are already stored in the containe
|
|
46
|
+
const externalLibs = Object.keys(package_json_1.dependencies).map(dep => new RegExp(`^${dep}.*`));
|
|
47
|
+
// Add the pepr library to the list of external libraries
|
|
48
|
+
externalLibs.push("pepr");
|
|
49
|
+
async function buildModule(moduleDir) {
|
|
44
50
|
try {
|
|
45
51
|
// Resolve the path to the module's package.json file
|
|
46
|
-
const cfgPath = resolve(moduleDir, "package.json");
|
|
47
|
-
const input = resolve(moduleDir, "pepr.ts");
|
|
52
|
+
const cfgPath = (0, path_1.resolve)(moduleDir, "package.json");
|
|
53
|
+
const input = (0, path_1.resolve)(moduleDir, "pepr.ts");
|
|
48
54
|
// Read the module's UUID from the package.json filel
|
|
49
|
-
const moduleText = await
|
|
55
|
+
const moduleText = await fs_1.promises.readFile(cfgPath, { encoding: "utf-8" });
|
|
50
56
|
const cfg = JSON.parse(moduleText);
|
|
51
57
|
const { uuid } = cfg.pepr;
|
|
52
58
|
const name = `pepr-${uuid}.js`;
|
|
@@ -55,11 +61,11 @@ export async function buildModule(moduleDir) {
|
|
|
55
61
|
throw new Error("Could not load the uuid in package.json");
|
|
56
62
|
}
|
|
57
63
|
const plugins = [
|
|
58
|
-
|
|
64
|
+
(0, plugin_node_resolve_1.default)({
|
|
59
65
|
preferBuiltins: true,
|
|
60
66
|
}),
|
|
61
|
-
|
|
62
|
-
|
|
67
|
+
(0, plugin_json_1.default)(),
|
|
68
|
+
(0, plugin_typescript_1.default)({
|
|
63
69
|
tsconfig: "./tsconfig.json",
|
|
64
70
|
declaration: false,
|
|
65
71
|
removeComments: true,
|
|
@@ -68,7 +74,7 @@ export async function buildModule(moduleDir) {
|
|
|
68
74
|
}),
|
|
69
75
|
];
|
|
70
76
|
// Build the module using Rollup
|
|
71
|
-
const bundle = await rollup({
|
|
77
|
+
const bundle = await (0, rollup_1.rollup)({
|
|
72
78
|
plugins,
|
|
73
79
|
external: externalLibs,
|
|
74
80
|
treeshake: true,
|
|
@@ -81,15 +87,16 @@ export async function buildModule(moduleDir) {
|
|
|
81
87
|
entryFileNames: name,
|
|
82
88
|
});
|
|
83
89
|
return {
|
|
84
|
-
path: resolve("dist", name),
|
|
90
|
+
path: (0, path_1.resolve)("dist", name),
|
|
85
91
|
cfg,
|
|
86
92
|
uuid,
|
|
87
93
|
};
|
|
88
94
|
}
|
|
89
95
|
catch (e) {
|
|
90
96
|
// On any other error, exit with a non-zero exit code
|
|
91
|
-
|
|
92
|
-
|
|
97
|
+
logger_1.default.debug(e);
|
|
98
|
+
logger_1.default.error(e.message);
|
|
93
99
|
process.exit(1);
|
|
94
100
|
}
|
|
95
101
|
}
|
|
102
|
+
exports.buildModule = buildModule;
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
2
3
|
// SPDX-FileCopyrightText: 2023-Present The Pepr Authors
|
|
3
|
-
|
|
4
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
function default_1(program) {
|
|
4
6
|
program
|
|
5
7
|
.command("new")
|
|
6
8
|
.description("Create a new Pepr Capability")
|
|
@@ -10,3 +12,4 @@ export default function (program) {
|
|
|
10
12
|
console.log("new");
|
|
11
13
|
});
|
|
12
14
|
}
|
|
15
|
+
exports.default = default_1;
|
package/dist/src/cli/deploy.js
CHANGED
|
@@ -1,11 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
2
3
|
// SPDX-FileCopyrightText: 2023-Present The Pepr Authors
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
4
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
5
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
6
|
+
};
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
const fs_1 = require("fs");
|
|
9
|
+
const webhook_1 = require("../lib/k8s/webhook");
|
|
10
|
+
const logger_1 = __importDefault(require("../lib/logger"));
|
|
11
|
+
const build_1 = require("./build");
|
|
12
|
+
const prompts_1 = require("prompts");
|
|
13
|
+
function default_1(program) {
|
|
9
14
|
program
|
|
10
15
|
.command("deploy")
|
|
11
16
|
.description("Deploy a Pepr Module")
|
|
@@ -15,7 +20,7 @@ export default function (program) {
|
|
|
15
20
|
.action(async (opts) => {
|
|
16
21
|
if (!opts.force) {
|
|
17
22
|
// Prompt the user to confirm
|
|
18
|
-
const confirm = await prompt({
|
|
23
|
+
const confirm = await (0, prompts_1.prompt)({
|
|
19
24
|
type: "confirm",
|
|
20
25
|
name: "confirm",
|
|
21
26
|
message: "This will remove and redeploy the module. Continue?",
|
|
@@ -26,11 +31,11 @@ export default function (program) {
|
|
|
26
31
|
}
|
|
27
32
|
}
|
|
28
33
|
// Build the module
|
|
29
|
-
const { cfg, path } = await buildModule(opts.dir);
|
|
34
|
+
const { cfg, path } = await (0, build_1.buildModule)(opts.dir);
|
|
30
35
|
// Read the compiled module code
|
|
31
|
-
const code = await
|
|
36
|
+
const code = await fs_1.promises.readFile(path, { encoding: "utf-8" });
|
|
32
37
|
// Generate a secret for the module
|
|
33
|
-
const webhook = new Webhook({
|
|
38
|
+
const webhook = new webhook_1.Webhook({
|
|
34
39
|
...cfg.pepr,
|
|
35
40
|
description: cfg.description,
|
|
36
41
|
});
|
|
@@ -39,11 +44,12 @@ export default function (program) {
|
|
|
39
44
|
}
|
|
40
45
|
try {
|
|
41
46
|
await webhook.deploy(code);
|
|
42
|
-
|
|
47
|
+
logger_1.default.info(`Module deployed successfully`);
|
|
43
48
|
}
|
|
44
49
|
catch (e) {
|
|
45
|
-
|
|
50
|
+
logger_1.default.error(`Error deploying module: ${e}`);
|
|
46
51
|
process.exit(1);
|
|
47
52
|
}
|
|
48
53
|
});
|
|
49
54
|
}
|
|
55
|
+
exports.default = default_1;
|
package/dist/src/cli/dev.js
CHANGED
|
@@ -1,14 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
2
3
|
// SPDX-FileCopyrightText: 2023-Present The Pepr Authors
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
4
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
5
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
6
|
+
};
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
const child_process_1 = require("child_process");
|
|
9
|
+
const chokidar_1 = require("chokidar");
|
|
10
|
+
const fs_1 = require("fs");
|
|
11
|
+
const path_1 = require("path");
|
|
12
|
+
const prompts_1 = require("prompts");
|
|
13
|
+
const webhook_1 = require("../lib/k8s/webhook");
|
|
14
|
+
const logger_1 = __importDefault(require("../lib/logger"));
|
|
15
|
+
const build_1 = require("./build");
|
|
16
|
+
function default_1(program) {
|
|
12
17
|
program
|
|
13
18
|
.command("dev")
|
|
14
19
|
.description("Setup a local webhook development environment")
|
|
@@ -16,7 +21,7 @@ export default function (program) {
|
|
|
16
21
|
.option("-h, --host [host]", "Host to listen on", "host.docker.internal")
|
|
17
22
|
.action(async (opts) => {
|
|
18
23
|
// Prompt the user to confirm
|
|
19
|
-
const confirm = await prompt({
|
|
24
|
+
const confirm = await (0, prompts_1.prompt)({
|
|
20
25
|
type: "confirm",
|
|
21
26
|
name: "confirm",
|
|
22
27
|
message: "This will remove and redeploy the module. Continue?",
|
|
@@ -26,31 +31,31 @@ export default function (program) {
|
|
|
26
31
|
process.exit(0);
|
|
27
32
|
}
|
|
28
33
|
// Build the module
|
|
29
|
-
const { cfg, path } = await buildModule(opts.dir);
|
|
34
|
+
const { cfg, path } = await (0, build_1.buildModule)(opts.dir);
|
|
30
35
|
// Read the compiled module code
|
|
31
|
-
const code = await
|
|
36
|
+
const code = await fs_1.promises.readFile(path, { encoding: "utf-8" });
|
|
32
37
|
// Generate a secret for the module
|
|
33
|
-
const webhook = new Webhook({
|
|
38
|
+
const webhook = new webhook_1.Webhook({
|
|
34
39
|
...cfg.pepr,
|
|
35
40
|
description: cfg.description,
|
|
36
41
|
}, opts.host);
|
|
37
42
|
// Write the TLS cert and key to disk
|
|
38
|
-
await
|
|
39
|
-
await
|
|
43
|
+
await fs_1.promises.writeFile("insecure-tls.crt", webhook.tls.pem.crt);
|
|
44
|
+
await fs_1.promises.writeFile("insecure-tls.key", webhook.tls.pem.key);
|
|
40
45
|
try {
|
|
41
46
|
await webhook.deploy(code);
|
|
42
|
-
|
|
43
|
-
const moduleFiles = resolve(opts.dir, "**", "*.ts");
|
|
44
|
-
const watcher = watch(moduleFiles);
|
|
45
|
-
const peprTS = resolve(opts.dir, "pepr.ts");
|
|
47
|
+
logger_1.default.info(`Module deployed successfully`);
|
|
48
|
+
const moduleFiles = (0, path_1.resolve)(opts.dir, "**", "*.ts");
|
|
49
|
+
const watcher = (0, chokidar_1.watch)(moduleFiles);
|
|
50
|
+
const peprTS = (0, path_1.resolve)(opts.dir, "pepr.ts");
|
|
46
51
|
let program;
|
|
47
52
|
// Run the module once to start the server
|
|
48
53
|
runDev(peprTS);
|
|
49
54
|
// Watch for changes
|
|
50
55
|
watcher.on("ready", () => {
|
|
51
|
-
|
|
56
|
+
logger_1.default.info(`Watching for changes in ${moduleFiles}`);
|
|
52
57
|
watcher.on("all", async (event, path) => {
|
|
53
|
-
|
|
58
|
+
logger_1.default.debug({ event, path }, "File changed");
|
|
54
59
|
// Kill the running process
|
|
55
60
|
if (program) {
|
|
56
61
|
program.kill("SIGKILL");
|
|
@@ -61,14 +66,15 @@ export default function (program) {
|
|
|
61
66
|
});
|
|
62
67
|
}
|
|
63
68
|
catch (e) {
|
|
64
|
-
|
|
69
|
+
logger_1.default.error(`Error deploying module: ${e}`);
|
|
65
70
|
process.exit(1);
|
|
66
71
|
}
|
|
67
72
|
});
|
|
68
73
|
}
|
|
74
|
+
exports.default = default_1;
|
|
69
75
|
function runDev(path) {
|
|
70
76
|
try {
|
|
71
|
-
const program = spawn("./node_modules/.bin/ts-node", [path], {
|
|
77
|
+
const program = (0, child_process_1.spawn)("./node_modules/.bin/ts-node", [path], {
|
|
72
78
|
env: {
|
|
73
79
|
...process.env,
|
|
74
80
|
SSL_KEY_PATH: "insecure-tls.key",
|
|
@@ -78,13 +84,13 @@ function runDev(path) {
|
|
|
78
84
|
program.stdout.on("data", data => console.log(data.toString()));
|
|
79
85
|
program.stderr.on("data", data => console.error(data.toString()));
|
|
80
86
|
program.on("close", code => {
|
|
81
|
-
|
|
87
|
+
logger_1.default.info(`Process exited with code ${code}`);
|
|
82
88
|
});
|
|
83
89
|
return program;
|
|
84
90
|
}
|
|
85
91
|
catch (e) {
|
|
86
|
-
|
|
87
|
-
|
|
92
|
+
logger_1.default.debug(e);
|
|
93
|
+
logger_1.default.error(`Error running module: ${e}`);
|
|
88
94
|
process.exit(1);
|
|
89
95
|
}
|
|
90
96
|
}
|
package/dist/src/cli/index.js
CHANGED
|
@@ -1,28 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
2
3
|
// SPDX-FileCopyrightText: 2023-Present The Pepr Authors
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
const
|
|
4
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
5
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
6
|
+
};
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
const package_json_1 = require("../../package.json");
|
|
9
|
+
const banner_1 = require("./banner");
|
|
10
|
+
const build_1 = __importDefault(require("./build"));
|
|
11
|
+
const capability_1 = __importDefault(require("./capability"));
|
|
12
|
+
const deploy_1 = __importDefault(require("./deploy"));
|
|
13
|
+
const dev_1 = __importDefault(require("./dev"));
|
|
14
|
+
const init_1 = __importDefault(require("./init"));
|
|
15
|
+
const root_1 = require("./root");
|
|
16
|
+
const test_1 = __importDefault(require("./test"));
|
|
17
|
+
const program = new root_1.RootCmd();
|
|
13
18
|
program
|
|
14
|
-
.version(version)
|
|
15
|
-
.description(`Pepr Kubernetes Thingy (v${version})`)
|
|
19
|
+
.version(package_json_1.version)
|
|
20
|
+
.description(`Pepr Kubernetes Thingy (v${package_json_1.version})`)
|
|
16
21
|
.action(() => {
|
|
17
22
|
if (program.args.length < 1) {
|
|
18
|
-
console.log(banner);
|
|
23
|
+
console.log(banner_1.banner);
|
|
19
24
|
program.help();
|
|
20
25
|
}
|
|
21
26
|
});
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
27
|
+
(0, init_1.default)(program);
|
|
28
|
+
(0, build_1.default)(program);
|
|
29
|
+
(0, capability_1.default)(program);
|
|
30
|
+
(0, test_1.default)(program);
|
|
31
|
+
(0, deploy_1.default)(program);
|
|
32
|
+
(0, dev_1.default)(program);
|
|
28
33
|
program.parse();
|
|
@@ -1,48 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
2
3
|
// SPDX-FileCopyrightText: 2023-Present The Pepr Authors
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
4
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
5
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
6
|
+
};
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
const child_process_1 = require("child_process");
|
|
9
|
+
const path_1 = require("path");
|
|
10
|
+
const logger_1 = __importDefault(require("../../lib/logger"));
|
|
11
|
+
const templates_1 = require("./templates");
|
|
12
|
+
const utils_1 = require("./utils");
|
|
13
|
+
const walkthrough_1 = require("./walkthrough");
|
|
14
|
+
function default_1(program) {
|
|
10
15
|
program
|
|
11
16
|
.command("init")
|
|
12
17
|
.description("Initialize a new Pepr Module")
|
|
13
18
|
.action(async () => {
|
|
14
|
-
const response = await walkthrough();
|
|
15
|
-
const dirName = sanitizeName(response.name);
|
|
16
|
-
const packageJSON = genPkgJSON(response);
|
|
17
|
-
const peprTS = genPeprTS();
|
|
18
|
-
const confirmed = await confirm(dirName, packageJSON, peprTS.path);
|
|
19
|
+
const response = await (0, walkthrough_1.walkthrough)();
|
|
20
|
+
const dirName = (0, utils_1.sanitizeName)(response.name);
|
|
21
|
+
const packageJSON = (0, templates_1.genPkgJSON)(response);
|
|
22
|
+
const peprTS = (0, templates_1.genPeprTS)();
|
|
23
|
+
const confirmed = await (0, walkthrough_1.confirm)(dirName, packageJSON, peprTS.path);
|
|
19
24
|
if (confirmed) {
|
|
20
25
|
console.log("Creating new Pepr module...");
|
|
21
26
|
try {
|
|
22
|
-
await createDir(dirName);
|
|
23
|
-
await createDir(resolve(dirName, ".vscode"));
|
|
24
|
-
await createDir(resolve(dirName, "capabilities"));
|
|
25
|
-
await write(resolve(dirName, gitIgnore.path), gitIgnore.data);
|
|
26
|
-
await write(resolve(dirName, prettierRC.path), prettierRC.data);
|
|
27
|
-
await write(resolve(dirName, packageJSON.path), packageJSON.data);
|
|
28
|
-
await write(resolve(dirName, readme.path), readme.data);
|
|
29
|
-
await write(resolve(dirName, tsConfig.path), tsConfig.data);
|
|
30
|
-
await write(resolve(dirName, peprTS.path), peprTS.data);
|
|
31
|
-
await write(resolve(dirName, ".vscode", capabilitySnippet.path), capabilitySnippet.data);
|
|
32
|
-
await write(resolve(dirName, "capabilities", capabilityHelloPeprTS.path), capabilityHelloPeprTS.data);
|
|
27
|
+
await (0, utils_1.createDir)(dirName);
|
|
28
|
+
await (0, utils_1.createDir)((0, path_1.resolve)(dirName, ".vscode"));
|
|
29
|
+
await (0, utils_1.createDir)((0, path_1.resolve)(dirName, "capabilities"));
|
|
30
|
+
await (0, utils_1.write)((0, path_1.resolve)(dirName, templates_1.gitIgnore.path), templates_1.gitIgnore.data);
|
|
31
|
+
await (0, utils_1.write)((0, path_1.resolve)(dirName, templates_1.prettierRC.path), templates_1.prettierRC.data);
|
|
32
|
+
await (0, utils_1.write)((0, path_1.resolve)(dirName, packageJSON.path), packageJSON.data);
|
|
33
|
+
await (0, utils_1.write)((0, path_1.resolve)(dirName, templates_1.readme.path), templates_1.readme.data);
|
|
34
|
+
await (0, utils_1.write)((0, path_1.resolve)(dirName, templates_1.tsConfig.path), templates_1.tsConfig.data);
|
|
35
|
+
await (0, utils_1.write)((0, path_1.resolve)(dirName, peprTS.path), peprTS.data);
|
|
36
|
+
await (0, utils_1.write)((0, path_1.resolve)(dirName, ".vscode", templates_1.capabilitySnippet.path), templates_1.capabilitySnippet.data);
|
|
37
|
+
await (0, utils_1.write)((0, path_1.resolve)(dirName, "capabilities", templates_1.capabilityHelloPeprTS.path), templates_1.capabilityHelloPeprTS.data);
|
|
33
38
|
// run npm install from the new directory
|
|
34
39
|
process.chdir(dirName);
|
|
35
|
-
execSync("npm install", {
|
|
40
|
+
(0, child_process_1.execSync)("npm install", {
|
|
36
41
|
stdio: "inherit",
|
|
37
42
|
});
|
|
38
43
|
console.log(`New Pepr module created at ${dirName}`);
|
|
39
44
|
console.log(`Open VSCode or your editor of choice in ${dirName} to get started!`);
|
|
40
45
|
}
|
|
41
46
|
catch (e) {
|
|
42
|
-
|
|
43
|
-
|
|
47
|
+
logger_1.default.debug(e);
|
|
48
|
+
logger_1.default.error(e.message);
|
|
44
49
|
process.exit(1);
|
|
45
50
|
}
|
|
46
51
|
}
|
|
47
52
|
});
|
|
48
53
|
}
|
|
54
|
+
exports.default = default_1;
|