pepr 0.38.0-rc → 0.38.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/dist/cli.js +13 -13
- package/dist/controller.js +1 -1
- package/dist/fixtures/loader.d.ts +1 -1
- package/dist/fixtures/loader.d.ts.map +1 -1
- package/dist/lib/controller/index.d.ts +2 -1
- package/dist/lib/controller/index.d.ts.map +1 -1
- package/dist/lib/k8s.d.ts +1 -77
- package/dist/lib/k8s.d.ts.map +1 -1
- package/dist/lib.js.map +2 -2
- package/package.json +8 -6
- package/src/fixtures/loader.ts +1 -1
- package/src/lib/assets/pods.ts +6 -6
- package/src/lib/assets/yaml.ts +6 -6
- package/src/lib/controller/index.ts +2 -2
- package/src/lib/k8s.ts +1 -102
- package/dist/cli/init/utils.test.d.ts +0 -2
- package/dist/cli/init/utils.test.d.ts.map +0 -1
- package/dist/cli/init/walkthrough.test.d.ts +0 -2
- package/dist/cli/init/walkthrough.test.d.ts.map +0 -1
- package/dist/lib/adjudicators.test.d.ts +0 -2
- package/dist/lib/adjudicators.test.d.ts.map +0 -1
- package/dist/lib/assets/helm.test.d.ts +0 -2
- package/dist/lib/assets/helm.test.d.ts.map +0 -1
- package/dist/lib/assets/pods.test.d.ts +0 -2
- package/dist/lib/assets/pods.test.d.ts.map +0 -1
- package/dist/lib/capability.test.d.ts +0 -2
- package/dist/lib/capability.test.d.ts.map +0 -1
- package/dist/lib/controller/store.test.d.ts +0 -2
- package/dist/lib/controller/store.test.d.ts.map +0 -1
- package/dist/lib/errors.test.d.ts +0 -2
- package/dist/lib/errors.test.d.ts.map +0 -1
- package/dist/lib/filter.test.d.ts +0 -3
- package/dist/lib/filter.test.d.ts.map +0 -1
- package/dist/lib/finalizer.test.d.ts +0 -2
- package/dist/lib/finalizer.test.d.ts.map +0 -1
- package/dist/lib/helpers.test.d.ts +0 -2
- package/dist/lib/helpers.test.d.ts.map +0 -1
- package/dist/lib/included-files.test.d.ts +0 -2
- package/dist/lib/included-files.test.d.ts.map +0 -1
- package/dist/lib/logger.test.d.ts +0 -2
- package/dist/lib/logger.test.d.ts.map +0 -1
- package/dist/lib/metrics.test.d.ts +0 -2
- package/dist/lib/metrics.test.d.ts.map +0 -1
- package/dist/lib/module.test.d.ts +0 -2
- package/dist/lib/module.test.d.ts.map +0 -1
- package/dist/lib/mutate-request.test.d.ts +0 -2
- package/dist/lib/mutate-request.test.d.ts.map +0 -1
- package/dist/lib/queue.test.d.ts +0 -2
- package/dist/lib/queue.test.d.ts.map +0 -1
- package/dist/lib/schedule.test.d.ts +0 -15
- package/dist/lib/schedule.test.d.ts.map +0 -1
- package/dist/lib/storage.test.d.ts +0 -2
- package/dist/lib/storage.test.d.ts.map +0 -1
- package/dist/lib/tls.test.d.ts +0 -2
- package/dist/lib/tls.test.d.ts.map +0 -1
- package/dist/lib/utils.test.d.ts +0 -2
- package/dist/lib/utils.test.d.ts.map +0 -1
- package/dist/lib/validate-request.test.d.ts +0 -2
- package/dist/lib/validate-request.test.d.ts.map +0 -1
- package/dist/lib/watch-processor.test.d.ts +0 -2
- package/dist/lib/watch-processor.test.d.ts.map +0 -1
- package/dist/sdk/sdk.test.d.ts +0 -2
- package/dist/sdk/sdk.test.d.ts.map +0 -1
- package/src/cli/init/utils.test.ts +0 -19
- package/src/cli/init/walkthrough.test.ts +0 -102
- package/src/lib/adjudicators.test.ts +0 -1236
- package/src/lib/assets/helm.test.ts +0 -64
- package/src/lib/assets/pods.test.ts +0 -553
- package/src/lib/capability.test.ts +0 -655
- package/src/lib/controller/store.test.ts +0 -131
- package/src/lib/errors.test.ts +0 -85
- package/src/lib/filter.test.ts +0 -691
- package/src/lib/finalizer.test.ts +0 -236
- package/src/lib/helpers.test.ts +0 -1486
- package/src/lib/included-files.test.ts +0 -22
- package/src/lib/logger.test.ts +0 -18
- package/src/lib/metrics.test.ts +0 -132
- package/src/lib/module.test.ts +0 -126
- package/src/lib/mutate-request.test.ts +0 -187
- package/src/lib/queue.test.ts +0 -152
- package/src/lib/schedule.test.ts +0 -217
- package/src/lib/storage.test.ts +0 -216
- package/src/lib/tls.test.ts +0 -18
- package/src/lib/utils.test.ts +0 -69
- package/src/lib/validate-request.test.ts +0 -121
- package/src/lib/watch-processor.test.ts +0 -418
- package/src/sdk/sdk.test.ts +0 -276
package/package.json
CHANGED
|
@@ -11,9 +11,11 @@
|
|
|
11
11
|
},
|
|
12
12
|
"files": [
|
|
13
13
|
"/dist",
|
|
14
|
-
"/src"
|
|
14
|
+
"/src",
|
|
15
|
+
"!src/**/*.test.ts",
|
|
16
|
+
"!dist/**/*.test.d.ts*"
|
|
15
17
|
],
|
|
16
|
-
"version": "0.38.
|
|
18
|
+
"version": "0.38.1",
|
|
17
19
|
"main": "dist/lib.js",
|
|
18
20
|
"types": "dist/lib.d.ts",
|
|
19
21
|
"scripts": {
|
|
@@ -39,12 +41,12 @@
|
|
|
39
41
|
},
|
|
40
42
|
"dependencies": {
|
|
41
43
|
"@types/ramda": "0.30.2",
|
|
42
|
-
"express": "4.21.
|
|
44
|
+
"express": "4.21.1",
|
|
43
45
|
"fast-json-patch": "3.1.1",
|
|
44
46
|
"json-pointer": "^0.6.2",
|
|
45
|
-
"kubernetes-fluent-client": "
|
|
46
|
-
"pino": "9.
|
|
47
|
-
"pino-pretty": "11.
|
|
47
|
+
"kubernetes-fluent-client": "3.1.2",
|
|
48
|
+
"pino": "9.5.0",
|
|
49
|
+
"pino-pretty": "11.3.0",
|
|
48
50
|
"prom-client": "15.1.3",
|
|
49
51
|
"ramda": "0.30.1"
|
|
50
52
|
},
|
package/src/fixtures/loader.ts
CHANGED
package/src/lib/assets/pods.ts
CHANGED
|
@@ -128,11 +128,11 @@ export function watcher(assets: Assets, hash: string, buildTimestamp: string, im
|
|
|
128
128
|
],
|
|
129
129
|
resources: {
|
|
130
130
|
requests: {
|
|
131
|
-
memory: "
|
|
132
|
-
cpu: "
|
|
131
|
+
memory: "256Mi",
|
|
132
|
+
cpu: "200m",
|
|
133
133
|
},
|
|
134
134
|
limits: {
|
|
135
|
-
memory: "
|
|
135
|
+
memory: "512Mi",
|
|
136
136
|
cpu: "500m",
|
|
137
137
|
},
|
|
138
138
|
},
|
|
@@ -267,11 +267,11 @@ export function deployment(
|
|
|
267
267
|
],
|
|
268
268
|
resources: {
|
|
269
269
|
requests: {
|
|
270
|
-
memory: "
|
|
271
|
-
cpu: "
|
|
270
|
+
memory: "256Mi",
|
|
271
|
+
cpu: "200m",
|
|
272
272
|
},
|
|
273
273
|
limits: {
|
|
274
|
-
memory: "
|
|
274
|
+
memory: "512Mi",
|
|
275
275
|
cpu: "500m",
|
|
276
276
|
},
|
|
277
277
|
},
|
package/src/lib/assets/yaml.ts
CHANGED
|
@@ -63,11 +63,11 @@ export async function overridesFile({ hash, name, image, config, apiToken }: Ass
|
|
|
63
63
|
},
|
|
64
64
|
resources: {
|
|
65
65
|
requests: {
|
|
66
|
-
memory: "
|
|
67
|
-
cpu: "
|
|
66
|
+
memory: "256Mi",
|
|
67
|
+
cpu: "200m",
|
|
68
68
|
},
|
|
69
69
|
limits: {
|
|
70
|
-
memory: "
|
|
70
|
+
memory: "512Mi",
|
|
71
71
|
cpu: "500m",
|
|
72
72
|
},
|
|
73
73
|
},
|
|
@@ -129,11 +129,11 @@ export async function overridesFile({ hash, name, image, config, apiToken }: Ass
|
|
|
129
129
|
},
|
|
130
130
|
resources: {
|
|
131
131
|
requests: {
|
|
132
|
-
memory: "
|
|
133
|
-
cpu: "
|
|
132
|
+
memory: "256Mi",
|
|
133
|
+
cpu: "200m",
|
|
134
134
|
},
|
|
135
135
|
limits: {
|
|
136
|
-
memory: "
|
|
136
|
+
memory: "512Mi",
|
|
137
137
|
cpu: "500m",
|
|
138
138
|
},
|
|
139
139
|
},
|
|
@@ -6,14 +6,14 @@ import fs from "fs";
|
|
|
6
6
|
import https from "https";
|
|
7
7
|
|
|
8
8
|
import { Capability } from "../capability";
|
|
9
|
-
import { MutateResponse,
|
|
9
|
+
import { MutateResponse, ValidateResponse } from "../k8s";
|
|
10
10
|
import Log from "../logger";
|
|
11
11
|
import { metricsCollector, MetricsCollector } from "../metrics";
|
|
12
12
|
import { ModuleConfig, isWatchMode } from "../module";
|
|
13
13
|
import { mutateProcessor } from "../mutate-processor";
|
|
14
14
|
import { validateProcessor } from "../validate-processor";
|
|
15
15
|
import { PeprControllerStore } from "./store";
|
|
16
|
-
import { ResponseItem } from "../types";
|
|
16
|
+
import { ResponseItem, AdmissionRequest } from "../types";
|
|
17
17
|
|
|
18
18
|
if (!process.env.PEPR_NODE_WARNINGS) {
|
|
19
19
|
process.removeAllListeners("warning");
|
package/src/lib/k8s.ts
CHANGED
|
@@ -1,15 +1,7 @@
|
|
|
1
1
|
// SPDX-License-Identifier: Apache-2.0
|
|
2
2
|
// SPDX-FileCopyrightText: 2023-Present The Pepr Authors
|
|
3
3
|
|
|
4
|
-
import { GenericKind,
|
|
5
|
-
|
|
6
|
-
// DEPRECATED: Use Operation in types.ts instead
|
|
7
|
-
export enum Operation {
|
|
8
|
-
CREATE = "CREATE",
|
|
9
|
-
UPDATE = "UPDATE",
|
|
10
|
-
DELETE = "DELETE",
|
|
11
|
-
CONNECT = "CONNECT",
|
|
12
|
-
}
|
|
4
|
+
import { GenericKind, RegisterKind } from "kubernetes-fluent-client";
|
|
13
5
|
|
|
14
6
|
/**
|
|
15
7
|
* PeprStore for internal use by Pepr. This is used to store arbitrary data in the cluster.
|
|
@@ -28,99 +20,6 @@ export const peprStoreGVK = {
|
|
|
28
20
|
|
|
29
21
|
RegisterKind(PeprStore, peprStoreGVK);
|
|
30
22
|
|
|
31
|
-
// DEPRECATED: Use Operation in types.ts instead
|
|
32
|
-
/**
|
|
33
|
-
* GroupVersionResource unambiguously identifies a resource. It doesn't anonymously include GroupVersion
|
|
34
|
-
* to avoid automatic coercion. It doesn't use a GroupVersion to avoid custom marshalling
|
|
35
|
-
*/
|
|
36
|
-
export interface GroupVersionResource {
|
|
37
|
-
readonly group: string;
|
|
38
|
-
readonly version: string;
|
|
39
|
-
readonly resource: string;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
// DEPRECATED: Use Operation in types.ts instead
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* A Kubernetes admission request to be processed by a capability.
|
|
46
|
-
*/
|
|
47
|
-
export interface AdmissionRequest<T = KubernetesObject> {
|
|
48
|
-
/** UID is an identifier for the individual request/response. */
|
|
49
|
-
readonly uid: string;
|
|
50
|
-
|
|
51
|
-
/** Kind is the fully-qualified type of object being submitted (for example, v1.Pod or autoscaling.v1.Scale) */
|
|
52
|
-
readonly kind: GroupVersionKind;
|
|
53
|
-
|
|
54
|
-
/** Resource is the fully-qualified resource being requested (for example, v1.pods) */
|
|
55
|
-
readonly resource: GroupVersionResource;
|
|
56
|
-
|
|
57
|
-
/** SubResource is the sub-resource being requested, if any (for example, "status" or "scale") */
|
|
58
|
-
readonly subResource?: string;
|
|
59
|
-
|
|
60
|
-
/** RequestKind is the fully-qualified type of the original API request (for example, v1.Pod or autoscaling.v1.Scale). */
|
|
61
|
-
readonly requestKind?: GroupVersionKind;
|
|
62
|
-
|
|
63
|
-
/** RequestResource is the fully-qualified resource of the original API request (for example, v1.pods). */
|
|
64
|
-
readonly requestResource?: GroupVersionResource;
|
|
65
|
-
|
|
66
|
-
/** RequestSubResource is the sub-resource of the original API request, if any (for example, "status" or "scale"). */
|
|
67
|
-
readonly requestSubResource?: string;
|
|
68
|
-
|
|
69
|
-
/**
|
|
70
|
-
* Name is the name of the object as presented in the request. On a CREATE operation, the client may omit name and
|
|
71
|
-
* rely on the server to generate the name. If that is the case, this method will return the empty string.
|
|
72
|
-
*/
|
|
73
|
-
readonly name: string;
|
|
74
|
-
|
|
75
|
-
/** Namespace is the namespace associated with the request (if any). */
|
|
76
|
-
readonly namespace?: string;
|
|
77
|
-
|
|
78
|
-
/**
|
|
79
|
-
* Operation is the operation being performed. This may be different than the operation
|
|
80
|
-
* requested. e.g. a patch can result in either a CREATE or UPDATE Operation.
|
|
81
|
-
*/
|
|
82
|
-
readonly operation: Operation;
|
|
83
|
-
|
|
84
|
-
/** UserInfo is information about the requesting user */
|
|
85
|
-
readonly userInfo: {
|
|
86
|
-
/** The name that uniquely identifies this user among all active users. */
|
|
87
|
-
username?: string;
|
|
88
|
-
|
|
89
|
-
/**
|
|
90
|
-
* A unique value that identifies this user across time. If this user is deleted
|
|
91
|
-
* and another user by the same name is added, they will have different UIDs.
|
|
92
|
-
*/
|
|
93
|
-
uid?: string;
|
|
94
|
-
|
|
95
|
-
/** The names of groups this user is a part of. */
|
|
96
|
-
groups?: string[];
|
|
97
|
-
|
|
98
|
-
/** Any additional information provided by the authenticator. */
|
|
99
|
-
extra?: {
|
|
100
|
-
[key: string]: string[];
|
|
101
|
-
};
|
|
102
|
-
};
|
|
103
|
-
|
|
104
|
-
/** Object is the object from the incoming request prior to default values being applied */
|
|
105
|
-
readonly object: T;
|
|
106
|
-
|
|
107
|
-
/** OldObject is the existing object. Only populated for UPDATE or DELETE requests. */
|
|
108
|
-
readonly oldObject?: T;
|
|
109
|
-
|
|
110
|
-
/** DryRun indicates that modifications will definitely not be persisted for this request. Defaults to false. */
|
|
111
|
-
readonly dryRun?: boolean;
|
|
112
|
-
|
|
113
|
-
/**
|
|
114
|
-
* Options contains the options for the operation being performed.
|
|
115
|
-
* e.g. `meta.k8s.io/v1.DeleteOptions` or `meta.k8s.io/v1.CreateOptions`. This may be
|
|
116
|
-
* different than the options the caller provided. e.g. for a patch request the performed
|
|
117
|
-
* Operation might be a CREATE, in which case the Options will a
|
|
118
|
-
* `meta.k8s.io/v1.CreateOptions` even though the caller provided `meta.k8s.io/v1.PatchOptions`.
|
|
119
|
-
*/
|
|
120
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
121
|
-
readonly options?: any;
|
|
122
|
-
}
|
|
123
|
-
|
|
124
23
|
export interface MutateResponse {
|
|
125
24
|
/** UID is an identifier for the individual request/response. This must be copied over from the corresponding AdmissionRequest. */
|
|
126
25
|
uid: string;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"utils.test.d.ts","sourceRoot":"","sources":["../../../src/cli/init/utils.test.ts"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"walkthrough.test.d.ts","sourceRoot":"","sources":["../../../src/cli/init/walkthrough.test.ts"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"adjudicators.test.d.ts","sourceRoot":"","sources":["../../src/lib/adjudicators.test.ts"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"helm.test.d.ts","sourceRoot":"","sources":["../../../src/lib/assets/helm.test.ts"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"pods.test.d.ts","sourceRoot":"","sources":["../../../src/lib/assets/pods.test.ts"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"capability.test.d.ts","sourceRoot":"","sources":["../../src/lib/capability.test.ts"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"store.test.d.ts","sourceRoot":"","sources":["../../../src/lib/controller/store.test.ts"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"errors.test.d.ts","sourceRoot":"","sources":["../../src/lib/errors.test.ts"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"filter.test.d.ts","sourceRoot":"","sources":["../../src/lib/filter.test.ts"],"names":[],"mappings":"AAUA,eAAO,MAAM,QAAQ,iBAAkB,CAAC;AAExC,eAAO,MAAM,OAAO,qDAAyC,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"finalizer.test.d.ts","sourceRoot":"","sources":["../../src/lib/finalizer.test.ts"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.test.d.ts","sourceRoot":"","sources":["../../src/lib/helpers.test.ts"],"names":[],"mappings":"AAkCA,eAAO,MAAM,QAAQ,iBAAkB,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"included-files.test.d.ts","sourceRoot":"","sources":["../../src/lib/included-files.test.ts"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"logger.test.d.ts","sourceRoot":"","sources":["../../src/lib/logger.test.ts"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"metrics.test.d.ts","sourceRoot":"","sources":["../../src/lib/metrics.test.ts"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"module.test.d.ts","sourceRoot":"","sources":["../../src/lib/module.test.ts"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"mutate-request.test.d.ts","sourceRoot":"","sources":["../../src/lib/mutate-request.test.ts"],"names":[],"mappings":""}
|
package/dist/lib/queue.test.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"queue.test.d.ts","sourceRoot":"","sources":["../../src/lib/queue.test.ts"],"names":[],"mappings":""}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { Unsubscribe } from "./storage";
|
|
2
|
-
export declare class MockStorage {
|
|
3
|
-
private storage;
|
|
4
|
-
subscription: string;
|
|
5
|
-
constructor();
|
|
6
|
-
getItem(key: string): string | null;
|
|
7
|
-
setItem(key: string, value: string): void;
|
|
8
|
-
setItemAndWait(key: string, value: string): Promise<void>;
|
|
9
|
-
removeItem(key: string): void;
|
|
10
|
-
removeItemAndWait(key: string): Promise<void>;
|
|
11
|
-
clear(): void;
|
|
12
|
-
subscribe(): Unsubscribe;
|
|
13
|
-
onReady(): void;
|
|
14
|
-
}
|
|
15
|
-
//# sourceMappingURL=schedule.test.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"schedule.test.d.ts","sourceRoot":"","sources":["../../src/lib/schedule.test.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAExC,qBAAa,WAAW;IACtB,OAAO,CAAC,OAAO,CAA8B;IAC7C,YAAY,EAAE,MAAM,CAAC;;IAKrB,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI;IAInC,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI;IAIzC,cAAc,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAOzD,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI;IAI7B,iBAAiB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAO7C,KAAK,IAAI,IAAI;IAIb,SAAS,IAAI,WAAW;IAMxB,OAAO,IAAI,IAAI;CAKhB"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"storage.test.d.ts","sourceRoot":"","sources":["../../src/lib/storage.test.ts"],"names":[],"mappings":""}
|
package/dist/lib/tls.test.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"tls.test.d.ts","sourceRoot":"","sources":["../../src/lib/tls.test.ts"],"names":[],"mappings":""}
|
package/dist/lib/utils.test.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"utils.test.d.ts","sourceRoot":"","sources":["../../src/lib/utils.test.ts"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"validate-request.test.d.ts","sourceRoot":"","sources":["../../src/lib/validate-request.test.ts"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"watch-processor.test.d.ts","sourceRoot":"","sources":["../../src/lib/watch-processor.test.ts"],"names":[],"mappings":""}
|
package/dist/sdk/sdk.test.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"sdk.test.d.ts","sourceRoot":"","sources":["../../src/sdk/sdk.test.ts"],"names":[],"mappings":""}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
-
// SPDX-FileCopyrightText: 2023-Present The Pepr Authors
|
|
3
|
-
|
|
4
|
-
import { expect, it } from "@jest/globals";
|
|
5
|
-
|
|
6
|
-
import { sanitizeName } from "./utils";
|
|
7
|
-
|
|
8
|
-
it.each([
|
|
9
|
-
//Test sanitizeName() with ["$BAD_INPUT", "$SANITIZED_INPUT"]
|
|
10
|
-
["My Test Module", "my-test-module"],
|
|
11
|
-
["!! 123 @@ Module", "123-module"],
|
|
12
|
-
["---Test-Module---", "test-module"],
|
|
13
|
-
])("sanitizeName() sanitizes '%s' correctly", (input: string, expected: string) => {
|
|
14
|
-
expect(sanitizeName(input)).toBe(expected);
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
it("sanitizeName() should throw TypeError when given a non-string", () => {
|
|
18
|
-
expect(() => sanitizeName({ input: 0 } as unknown as string)).toThrow(TypeError);
|
|
19
|
-
});
|
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
-
// SPDX-FileCopyrightText: 2023-Present The Pepr Authors
|
|
3
|
-
|
|
4
|
-
import { describe, expect, it } from "@jest/globals";
|
|
5
|
-
import prompts from "prompts";
|
|
6
|
-
import {
|
|
7
|
-
walkthrough,
|
|
8
|
-
confirm,
|
|
9
|
-
PromptOptions,
|
|
10
|
-
PartialPromptOptions,
|
|
11
|
-
setName,
|
|
12
|
-
setErrorBehavior,
|
|
13
|
-
} from "./walkthrough";
|
|
14
|
-
|
|
15
|
-
describe("when processing input", () => {
|
|
16
|
-
describe("walkthough() returns expected results", () => {
|
|
17
|
-
it.each([
|
|
18
|
-
//Test flag combinations with [["$FLAG", ...]]
|
|
19
|
-
[["description", "errorBehavior"]],
|
|
20
|
-
[["description"]],
|
|
21
|
-
[["errorBehavior"]],
|
|
22
|
-
[["name", "description", "errorBehavior"]],
|
|
23
|
-
[["name", "description"]],
|
|
24
|
-
[["name", "errorBehavior"]],
|
|
25
|
-
[["name"]],
|
|
26
|
-
[undefined],
|
|
27
|
-
])(`when the set flags are: %s`, async (flagInput: string[] | undefined) => {
|
|
28
|
-
const expected: PromptOptions = {
|
|
29
|
-
name: "My Test Module",
|
|
30
|
-
description: "A test module for Pepr",
|
|
31
|
-
errorBehavior: "reject",
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
// Set values for the flag(s) under test by making a subset of (expected)
|
|
35
|
-
type SupportedFlagNames = keyof typeof expected;
|
|
36
|
-
type PartialTestInput = { [key in SupportedFlagNames]?: string };
|
|
37
|
-
const setFlags =
|
|
38
|
-
flagInput?.reduce((acc: PartialTestInput, key: string) => {
|
|
39
|
-
if (key in expected) {
|
|
40
|
-
acc[key as SupportedFlagNames] = expected[key as SupportedFlagNames];
|
|
41
|
-
}
|
|
42
|
-
return acc;
|
|
43
|
-
}, {} as PartialTestInput) || {};
|
|
44
|
-
|
|
45
|
-
// Simulate user-input for unset flags by making a subset of (expected - setFlags)
|
|
46
|
-
const promptInput = flagInput
|
|
47
|
-
? Object.entries(expected)
|
|
48
|
-
.filter(([key]) => !flagInput.includes(key))
|
|
49
|
-
.map(([, value]) => value)
|
|
50
|
-
: Object.values(expected);
|
|
51
|
-
prompts.inject(Object.values(promptInput));
|
|
52
|
-
|
|
53
|
-
const result = await walkthrough(setFlags as PartialPromptOptions);
|
|
54
|
-
|
|
55
|
-
expect(result).toEqual(expected);
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
it("should prompt for input when given invalid input", async () => {
|
|
59
|
-
const expected = { name: "aaa" };
|
|
60
|
-
prompts.inject(["aaa"]);
|
|
61
|
-
const result = await setName("aa");
|
|
62
|
-
expect(result).toStrictEqual(expected);
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
it("should prompt for errorBehavior when given invalid input", async () => {
|
|
66
|
-
const expected = { errorBehavior: "audit" };
|
|
67
|
-
prompts.inject(["audit"]);
|
|
68
|
-
const result = await setErrorBehavior("not-valid" as "reject"); // Type-Coercion forces invalid input
|
|
69
|
-
expect(result).toStrictEqual(expected);
|
|
70
|
-
});
|
|
71
|
-
});
|
|
72
|
-
|
|
73
|
-
describe("confirm() handles input", () => {
|
|
74
|
-
it.each([
|
|
75
|
-
["n", false],
|
|
76
|
-
["no", false],
|
|
77
|
-
["y", true],
|
|
78
|
-
["yes", true],
|
|
79
|
-
])("when prompt input is '%s'", async (userInput: string, expected: boolean) => {
|
|
80
|
-
prompts.inject([userInput]);
|
|
81
|
-
const result = await confirm(
|
|
82
|
-
"some string",
|
|
83
|
-
{ path: "some path", print: "some print" },
|
|
84
|
-
"some Pepr TS path",
|
|
85
|
-
);
|
|
86
|
-
expect(result).toBe(expected);
|
|
87
|
-
});
|
|
88
|
-
|
|
89
|
-
it.each([[true], [false]])(
|
|
90
|
-
"when flag '--confirm' is %s",
|
|
91
|
-
async (confirmFlag: boolean | undefined) => {
|
|
92
|
-
const result = await confirm(
|
|
93
|
-
"some string",
|
|
94
|
-
{ path: "some path", print: "some print" },
|
|
95
|
-
"some Pepr TS path",
|
|
96
|
-
confirmFlag,
|
|
97
|
-
);
|
|
98
|
-
expect(result).toBe(confirmFlag);
|
|
99
|
-
},
|
|
100
|
-
);
|
|
101
|
-
});
|
|
102
|
-
});
|