@backstage-community/plugin-cicd-statistics 0.1.37
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/CHANGELOG.md +991 -0
- package/README.md +13 -0
- package/dist/esm/entity-page-CNIrdNBp.esm.js +1797 -0
- package/dist/esm/entity-page-CNIrdNBp.esm.js.map +1 -0
- package/dist/index.d.ts +263 -0
- package/dist/index.esm.js +45 -0
- package/dist/index.esm.js.map +1 -0
- package/package.json +74 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,263 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import * as _backstage_core_plugin_api from '@backstage/core-plugin-api';
|
|
3
|
+
import { Entity } from '@backstage/catalog-model';
|
|
4
|
+
|
|
5
|
+
/** @public */
|
|
6
|
+
declare function EntityPageCicdCharts(): JSX.Element;
|
|
7
|
+
|
|
8
|
+
/** @public */
|
|
9
|
+
declare const cicdStatisticsPlugin: _backstage_core_plugin_api.BackstagePlugin<{
|
|
10
|
+
entityContent: _backstage_core_plugin_api.RouteRef<undefined>;
|
|
11
|
+
}, {}, {}>;
|
|
12
|
+
/** @public */
|
|
13
|
+
declare const EntityCicdStatisticsContent: typeof EntityPageCicdCharts;
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* This is a generic enum of build statuses.
|
|
17
|
+
*
|
|
18
|
+
* If all of these aren't applicable to the underlying CI/CD, these can be
|
|
19
|
+
* configured to be hidden, using the `availableStatuses` in `CicdConfiguration`.
|
|
20
|
+
*
|
|
21
|
+
* @public
|
|
22
|
+
*/
|
|
23
|
+
type FilterStatusType = 'unknown' | 'enqueued' | 'scheduled' | 'running' | 'aborted' | 'succeeded' | 'failed' | 'stalled' | 'expired';
|
|
24
|
+
/**
|
|
25
|
+
* @public
|
|
26
|
+
*/
|
|
27
|
+
declare const statusTypes: Array<FilterStatusType>;
|
|
28
|
+
/**
|
|
29
|
+
* The branch enum of either 'master' or 'branch' (or possibly the meta 'all').
|
|
30
|
+
*
|
|
31
|
+
* The concept of what constitutes a master branch is generic. It might be called
|
|
32
|
+
* something like 'release' or 'main' or 'trunk' in the underlying CI/CD system,
|
|
33
|
+
* which is then up to the Api to map accordingly.
|
|
34
|
+
*
|
|
35
|
+
* @public
|
|
36
|
+
*/
|
|
37
|
+
type FilterBranchType = 'master' | 'branch';
|
|
38
|
+
/**
|
|
39
|
+
* @public
|
|
40
|
+
*/
|
|
41
|
+
type TriggerReason =
|
|
42
|
+
/** Triggered by source code management, e.g. a Github hook */
|
|
43
|
+
'scm'
|
|
44
|
+
/** Triggered manually */
|
|
45
|
+
| 'manual'
|
|
46
|
+
/** Triggered internally (non-scm, or perhaps after being delayed/enqueued) */
|
|
47
|
+
| 'internal'
|
|
48
|
+
/** Triggered for some other reason */
|
|
49
|
+
| 'other';
|
|
50
|
+
/**
|
|
51
|
+
* @public
|
|
52
|
+
*/
|
|
53
|
+
declare const triggerReasons: Array<TriggerReason>;
|
|
54
|
+
/**
|
|
55
|
+
* A Stage is a part of either a Build or a parent Stage.
|
|
56
|
+
*
|
|
57
|
+
* This may be called things like Stage or Step or Task in CI/CD systems, but is
|
|
58
|
+
* generic here. There's also no concept of parallelism which might exist within
|
|
59
|
+
* some stages.
|
|
60
|
+
*
|
|
61
|
+
* @public
|
|
62
|
+
*/
|
|
63
|
+
interface Stage {
|
|
64
|
+
name: string;
|
|
65
|
+
/** The status of the stage */
|
|
66
|
+
status: FilterStatusType;
|
|
67
|
+
/** Stage duration in milliseconds */
|
|
68
|
+
duration: number;
|
|
69
|
+
/** Sub stages within this stage */
|
|
70
|
+
stages?: Array<Stage>;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Generic Build type.
|
|
74
|
+
*
|
|
75
|
+
* A build has e.g. a build type (master/branch), a status and (possibly) sub stages.
|
|
76
|
+
*
|
|
77
|
+
* @public
|
|
78
|
+
*/
|
|
79
|
+
interface Build {
|
|
80
|
+
raw?: unknown;
|
|
81
|
+
/** Build id */
|
|
82
|
+
id: string;
|
|
83
|
+
/** The reason this build was started */
|
|
84
|
+
triggeredBy?: TriggerReason;
|
|
85
|
+
/** The status of the build */
|
|
86
|
+
status: FilterStatusType;
|
|
87
|
+
/** Branch type */
|
|
88
|
+
branchType: FilterBranchType;
|
|
89
|
+
/** Time when the build started */
|
|
90
|
+
requestedAt: Date;
|
|
91
|
+
/** The overall duration of the build */
|
|
92
|
+
duration: number;
|
|
93
|
+
/** Top-level build stages */
|
|
94
|
+
stages: Array<Stage>;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Helper type which is a Build with a certain typed 'raw' field.
|
|
98
|
+
*
|
|
99
|
+
* This can be useful in an Api to use while mapping internal data structures
|
|
100
|
+
* (raw) into generic builds.
|
|
101
|
+
*
|
|
102
|
+
* @public
|
|
103
|
+
*/
|
|
104
|
+
type BuildWithRaw<T = any> = Build & {
|
|
105
|
+
raw: T;
|
|
106
|
+
};
|
|
107
|
+
/**
|
|
108
|
+
* Chart type.
|
|
109
|
+
*
|
|
110
|
+
* Values are:
|
|
111
|
+
* * `duration`: shows an area chart of the duration over time
|
|
112
|
+
* * `count`: shows a bar chart of the number of build per day
|
|
113
|
+
*
|
|
114
|
+
* @public
|
|
115
|
+
*/
|
|
116
|
+
type ChartType = 'duration' | 'count';
|
|
117
|
+
/**
|
|
118
|
+
* Chart types.
|
|
119
|
+
*
|
|
120
|
+
* @public
|
|
121
|
+
*/
|
|
122
|
+
type ChartTypes = Array<ChartType>;
|
|
123
|
+
/**
|
|
124
|
+
* Default settings for the fetching options and view options.
|
|
125
|
+
*
|
|
126
|
+
* These are all optional, but can be overridden from the Api to whatever makes
|
|
127
|
+
* most sense for that implementation.
|
|
128
|
+
*
|
|
129
|
+
* @public
|
|
130
|
+
*/
|
|
131
|
+
interface CicdDefaults {
|
|
132
|
+
timeFrom: Date;
|
|
133
|
+
timeTo: Date;
|
|
134
|
+
filterStatus: Array<FilterStatusType>;
|
|
135
|
+
filterType: FilterBranchType | 'all';
|
|
136
|
+
/** Lower-case all stage names (to potentially merge stages with different cases) */
|
|
137
|
+
lowercaseNames: boolean;
|
|
138
|
+
/** Normalize the from-to date range in all charts */
|
|
139
|
+
normalizeTimeRange: boolean;
|
|
140
|
+
/** Default collapse the stages with a max-duration below this value */
|
|
141
|
+
collapsedLimit: number;
|
|
142
|
+
/** Default hide stages with a max-duration below this value */
|
|
143
|
+
hideLimit: number;
|
|
144
|
+
/** Chart types per status */
|
|
145
|
+
chartTypes: Record<FilterStatusType, ChartTypes>;
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* A configuration interface which the Api must implement.
|
|
149
|
+
*
|
|
150
|
+
* When the UI for the CI/CD Statistics is loaded, it begins with fetching the
|
|
151
|
+
* configuration before anything else.
|
|
152
|
+
*
|
|
153
|
+
* All of these fields are optional though, and will fallback to hard-coded defaults.
|
|
154
|
+
*
|
|
155
|
+
* @public
|
|
156
|
+
*/
|
|
157
|
+
interface CicdConfiguration {
|
|
158
|
+
/**
|
|
159
|
+
* This field can be used to override what statuses are available
|
|
160
|
+
*/
|
|
161
|
+
availableStatuses: ReadonlyArray<FilterStatusType>;
|
|
162
|
+
/**
|
|
163
|
+
* When transposing the list of builds into a tree of stages, the stage names
|
|
164
|
+
* will be transformed through this function.
|
|
165
|
+
*
|
|
166
|
+
* Override this for a custom implementation. The default will try to remove
|
|
167
|
+
* parent names off of child names, if they are prepended by them.
|
|
168
|
+
*
|
|
169
|
+
* For example; if a stage has the name 'Install' and a child stage has the
|
|
170
|
+
* name 'Install - Fetch dependencies', the child name will be replaced with
|
|
171
|
+
* 'Fetch dependencies'.
|
|
172
|
+
*/
|
|
173
|
+
formatStageName: (parentNames: Array<string>, stageName: string) => string;
|
|
174
|
+
/**
|
|
175
|
+
* Default options for the UI
|
|
176
|
+
*/
|
|
177
|
+
defaults: Partial<CicdDefaults>;
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* If the Api implements support for aborting the fetching of builds, throw an
|
|
181
|
+
* AbortError of this type (or any other error with name === 'AbortError').
|
|
182
|
+
*
|
|
183
|
+
* @public
|
|
184
|
+
*/
|
|
185
|
+
declare class AbortError extends Error {
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* The result type for `fetchBuilds`.
|
|
189
|
+
*
|
|
190
|
+
* @public
|
|
191
|
+
*/
|
|
192
|
+
interface CicdState {
|
|
193
|
+
builds: Array<Build>;
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* When fetching, if applicable, the Api can feedback progress back to the UI.
|
|
197
|
+
*
|
|
198
|
+
* Use the `updateProgress(completed, total, started?)` to signal that
|
|
199
|
+
* `completed` builds out of a `total` has finished. Optionally use the
|
|
200
|
+
* `started` to signal how many builds have been started in total (i.e. at least
|
|
201
|
+
* the amount of `completed`).
|
|
202
|
+
*
|
|
203
|
+
* This can be called at any rate. Rate limiting (debouncing) is implemented in
|
|
204
|
+
* the UI.
|
|
205
|
+
*
|
|
206
|
+
* Optionally this can signal multiple progresses in several steps
|
|
207
|
+
*
|
|
208
|
+
* @public
|
|
209
|
+
*/
|
|
210
|
+
interface UpdateProgress {
|
|
211
|
+
(completed: number, total: number, started?: number): void;
|
|
212
|
+
(steps: Array<{
|
|
213
|
+
title: string;
|
|
214
|
+
completed: number;
|
|
215
|
+
total: number;
|
|
216
|
+
started?: number;
|
|
217
|
+
}>): void;
|
|
218
|
+
}
|
|
219
|
+
/**
|
|
220
|
+
* When reading configuration, the Api can return a custom settings depending on
|
|
221
|
+
* the entity being viewed.
|
|
222
|
+
*
|
|
223
|
+
* @public
|
|
224
|
+
*/
|
|
225
|
+
interface GetConfigurationOptions {
|
|
226
|
+
entity: Entity;
|
|
227
|
+
}
|
|
228
|
+
/**
|
|
229
|
+
* When fetching, the Api should fetch build information about the `entity` and
|
|
230
|
+
* respect the `timeFrom`, `timeTo`, `filterStatus` and `filterType`.
|
|
231
|
+
*
|
|
232
|
+
* Optionally implement support for `updateProgress` and `abortSignal` if
|
|
233
|
+
* preferred.
|
|
234
|
+
*
|
|
235
|
+
* When the UI re-fetches, it will abort any previous fetching, so polling
|
|
236
|
+
* `abortSignal.aborted`, and possibly throwing an `AbortError`, can be useful.
|
|
237
|
+
*
|
|
238
|
+
* @public
|
|
239
|
+
*/
|
|
240
|
+
interface FetchBuildsOptions {
|
|
241
|
+
entity: Entity;
|
|
242
|
+
updateProgress: UpdateProgress;
|
|
243
|
+
abortSignal: AbortSignal;
|
|
244
|
+
timeFrom: Date;
|
|
245
|
+
timeTo: Date;
|
|
246
|
+
filterStatus: Array<FilterStatusType | 'all'>;
|
|
247
|
+
filterType: FilterBranchType | 'all';
|
|
248
|
+
}
|
|
249
|
+
/**
|
|
250
|
+
* The interface which is mapped to the `cicdStatisticsApiRef` which is used by
|
|
251
|
+
* the UI.
|
|
252
|
+
*
|
|
253
|
+
* @public
|
|
254
|
+
*/
|
|
255
|
+
interface CicdStatisticsApi {
|
|
256
|
+
getConfiguration(options: GetConfigurationOptions): Promise<Partial<CicdConfiguration>>;
|
|
257
|
+
fetchBuilds(options: FetchBuildsOptions): Promise<CicdState>;
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
/** @public */
|
|
261
|
+
declare const cicdStatisticsApiRef: _backstage_core_plugin_api.ApiRef<CicdStatisticsApi>;
|
|
262
|
+
|
|
263
|
+
export { AbortError, type Build, type BuildWithRaw, type ChartType, type ChartTypes, type CicdConfiguration, type CicdDefaults, type CicdState, type CicdStatisticsApi, EntityCicdStatisticsContent, EntityPageCicdCharts, type FetchBuildsOptions, type FilterBranchType, type FilterStatusType, type GetConfigurationOptions, type Stage, type TriggerReason, type UpdateProgress, cicdStatisticsApiRef, cicdStatisticsPlugin, statusTypes, triggerReasons };
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { createRouteRef, createPlugin, createRoutableExtension, createApiRef } from '@backstage/core-plugin-api';
|
|
2
|
+
|
|
3
|
+
const rootCatalogCicdStatsRouteRef = createRouteRef({
|
|
4
|
+
id: "cicd-statistics"
|
|
5
|
+
});
|
|
6
|
+
const cicdStatisticsPlugin = createPlugin({
|
|
7
|
+
id: "cicd-statistics",
|
|
8
|
+
routes: {
|
|
9
|
+
entityContent: rootCatalogCicdStatsRouteRef
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
const EntityCicdStatisticsContent = cicdStatisticsPlugin.provide(
|
|
13
|
+
createRoutableExtension({
|
|
14
|
+
component: () => import('./esm/entity-page-CNIrdNBp.esm.js').then((m) => m.EntityPageCicdCharts),
|
|
15
|
+
mountPoint: rootCatalogCicdStatsRouteRef,
|
|
16
|
+
name: "EntityCicdStatisticsContent"
|
|
17
|
+
})
|
|
18
|
+
);
|
|
19
|
+
|
|
20
|
+
const statusTypes = [
|
|
21
|
+
"succeeded",
|
|
22
|
+
"failed",
|
|
23
|
+
"enqueued",
|
|
24
|
+
"scheduled",
|
|
25
|
+
"running",
|
|
26
|
+
"aborted",
|
|
27
|
+
"stalled",
|
|
28
|
+
"expired",
|
|
29
|
+
"unknown"
|
|
30
|
+
];
|
|
31
|
+
const triggerReasons = [
|
|
32
|
+
"scm",
|
|
33
|
+
"manual",
|
|
34
|
+
"internal",
|
|
35
|
+
"other"
|
|
36
|
+
];
|
|
37
|
+
class AbortError extends Error {
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const cicdStatisticsApiRef = createApiRef({
|
|
41
|
+
id: "cicd-statistics-api"
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
export { AbortError, EntityCicdStatisticsContent, cicdStatisticsApiRef, cicdStatisticsPlugin, statusTypes, triggerReasons };
|
|
45
|
+
//# sourceMappingURL=index.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.esm.js","sources":["../src/plugin.ts","../src/apis/types.ts","../src/apis/cicd-statistics.ts"],"sourcesContent":["/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n createPlugin,\n createRoutableExtension,\n createRouteRef,\n} from '@backstage/core-plugin-api';\n\nexport type { EntityPageCicdCharts } from './entity-page';\n\nconst rootCatalogCicdStatsRouteRef = createRouteRef({\n id: 'cicd-statistics',\n});\n\n/** @public */\nexport const cicdStatisticsPlugin = createPlugin({\n id: 'cicd-statistics',\n routes: {\n entityContent: rootCatalogCicdStatsRouteRef,\n },\n});\n\n/** @public */\nexport const EntityCicdStatisticsContent = cicdStatisticsPlugin.provide(\n createRoutableExtension({\n component: () => import('./entity-page').then(m => m.EntityPageCicdCharts),\n mountPoint: rootCatalogCicdStatsRouteRef,\n name: 'EntityCicdStatisticsContent',\n }),\n);\n","/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { Entity } from '@backstage/catalog-model';\n\n/**\n * This is a generic enum of build statuses.\n *\n * If all of these aren't applicable to the underlying CI/CD, these can be\n * configured to be hidden, using the `availableStatuses` in `CicdConfiguration`.\n *\n * @public\n */\nexport type FilterStatusType =\n | 'unknown'\n | 'enqueued'\n | 'scheduled'\n | 'running'\n | 'aborted'\n | 'succeeded'\n | 'failed'\n | 'stalled'\n | 'expired';\n\n/**\n * @public\n */\nexport const statusTypes: Array<FilterStatusType> = [\n 'succeeded',\n 'failed',\n 'enqueued',\n 'scheduled',\n 'running',\n 'aborted',\n 'stalled',\n 'expired',\n 'unknown',\n];\n\n/**\n * The branch enum of either 'master' or 'branch' (or possibly the meta 'all').\n *\n * The concept of what constitutes a master branch is generic. It might be called\n * something like 'release' or 'main' or 'trunk' in the underlying CI/CD system,\n * which is then up to the Api to map accordingly.\n *\n * @public\n */\nexport type FilterBranchType = 'master' | 'branch';\n\n/**\n * @public\n */\nexport type TriggerReason =\n /** Triggered by source code management, e.g. a Github hook */\n | 'scm'\n /** Triggered manually */\n | 'manual'\n /** Triggered internally (non-scm, or perhaps after being delayed/enqueued) */\n | 'internal'\n /** Triggered for some other reason */\n | 'other';\n\n/**\n * @public\n */\nexport const triggerReasons: Array<TriggerReason> = [\n 'scm',\n 'manual',\n 'internal',\n 'other',\n];\n\n/**\n * A Stage is a part of either a Build or a parent Stage.\n *\n * This may be called things like Stage or Step or Task in CI/CD systems, but is\n * generic here. There's also no concept of parallelism which might exist within\n * some stages.\n *\n * @public\n */\nexport interface Stage {\n name: string;\n\n /** The status of the stage */\n status: FilterStatusType;\n\n /** Stage duration in milliseconds */\n duration: number;\n\n /** Sub stages within this stage */\n stages?: Array<Stage>;\n}\n\n/**\n * Generic Build type.\n *\n * A build has e.g. a build type (master/branch), a status and (possibly) sub stages.\n *\n * @public\n */\nexport interface Build {\n raw?: unknown;\n\n /** Build id */\n id: string;\n\n /** The reason this build was started */\n triggeredBy?: TriggerReason;\n\n /** The status of the build */\n status: FilterStatusType;\n\n /** Branch type */\n branchType: FilterBranchType;\n\n /** Time when the build started */\n requestedAt: Date;\n\n /** The overall duration of the build */\n duration: number;\n\n /** Top-level build stages */\n stages: Array<Stage>;\n}\n\n/**\n * Helper type which is a Build with a certain typed 'raw' field.\n *\n * This can be useful in an Api to use while mapping internal data structures\n * (raw) into generic builds.\n *\n * @public\n */\nexport type BuildWithRaw<T = any> = Build & {\n raw: T;\n};\n\n/**\n * Chart type.\n *\n * Values are:\n * * `duration`: shows an area chart of the duration over time\n * * `count`: shows a bar chart of the number of build per day\n *\n * @public\n */\nexport type ChartType = 'duration' | 'count';\n\n/**\n * Chart types.\n *\n * @public\n */\nexport type ChartTypes = Array<ChartType>;\n\n/**\n * Default settings for the fetching options and view options.\n *\n * These are all optional, but can be overridden from the Api to whatever makes\n * most sense for that implementation.\n *\n * @public\n */\nexport interface CicdDefaults {\n timeFrom: Date;\n timeTo: Date;\n filterStatus: Array<FilterStatusType>;\n filterType: FilterBranchType | 'all';\n\n /** Lower-case all stage names (to potentially merge stages with different cases) */\n lowercaseNames: boolean;\n /** Normalize the from-to date range in all charts */\n normalizeTimeRange: boolean;\n /** Default collapse the stages with a max-duration below this value */\n collapsedLimit: number;\n /** Default hide stages with a max-duration below this value */\n hideLimit: number;\n /** Chart types per status */\n chartTypes: Record<FilterStatusType, ChartTypes>;\n}\n\n/**\n * A configuration interface which the Api must implement.\n *\n * When the UI for the CI/CD Statistics is loaded, it begins with fetching the\n * configuration before anything else.\n *\n * All of these fields are optional though, and will fallback to hard-coded defaults.\n *\n * @public\n */\nexport interface CicdConfiguration {\n /**\n * This field can be used to override what statuses are available\n */\n availableStatuses: ReadonlyArray<FilterStatusType>;\n\n /**\n * When transposing the list of builds into a tree of stages, the stage names\n * will be transformed through this function.\n *\n * Override this for a custom implementation. The default will try to remove\n * parent names off of child names, if they are prepended by them.\n *\n * For example; if a stage has the name 'Install' and a child stage has the\n * name 'Install - Fetch dependencies', the child name will be replaced with\n * 'Fetch dependencies'.\n */\n formatStageName: (parentNames: Array<string>, stageName: string) => string;\n\n /**\n * Default options for the UI\n */\n defaults: Partial<CicdDefaults>;\n}\n\n/**\n * If the Api implements support for aborting the fetching of builds, throw an\n * AbortError of this type (or any other error with name === 'AbortError').\n *\n * @public\n */\nexport class AbortError extends Error {}\n\n/**\n * The result type for `fetchBuilds`.\n *\n * @public\n */\nexport interface CicdState {\n builds: Array<Build>;\n}\n\n/**\n * When fetching, if applicable, the Api can feedback progress back to the UI.\n *\n * Use the `updateProgress(completed, total, started?)` to signal that\n * `completed` builds out of a `total` has finished. Optionally use the\n * `started` to signal how many builds have been started in total (i.e. at least\n * the amount of `completed`).\n *\n * This can be called at any rate. Rate limiting (debouncing) is implemented in\n * the UI.\n *\n * Optionally this can signal multiple progresses in several steps\n *\n * @public\n */\nexport interface UpdateProgress {\n (completed: number, total: number, started?: number): void;\n (\n steps: Array<{\n title: string;\n completed: number;\n total: number;\n started?: number;\n }>,\n ): void;\n}\n\n/**\n * When reading configuration, the Api can return a custom settings depending on\n * the entity being viewed.\n *\n * @public\n */\nexport interface GetConfigurationOptions {\n entity: Entity;\n}\n\n/**\n * When fetching, the Api should fetch build information about the `entity` and\n * respect the `timeFrom`, `timeTo`, `filterStatus` and `filterType`.\n *\n * Optionally implement support for `updateProgress` and `abortSignal` if\n * preferred.\n *\n * When the UI re-fetches, it will abort any previous fetching, so polling\n * `abortSignal.aborted`, and possibly throwing an `AbortError`, can be useful.\n *\n * @public\n */\nexport interface FetchBuildsOptions {\n entity: Entity;\n updateProgress: UpdateProgress;\n abortSignal: AbortSignal;\n timeFrom: Date;\n timeTo: Date;\n filterStatus: Array<FilterStatusType | 'all'>;\n filterType: FilterBranchType | 'all';\n}\n\n/**\n * The interface which is mapped to the `cicdStatisticsApiRef` which is used by\n * the UI.\n *\n * @public\n */\nexport interface CicdStatisticsApi {\n getConfiguration(\n options: GetConfigurationOptions,\n ): Promise<Partial<CicdConfiguration>>;\n fetchBuilds(options: FetchBuildsOptions): Promise<CicdState>;\n}\n","/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { createApiRef } from '@backstage/core-plugin-api';\nimport { CicdStatisticsApi } from './types';\n\n/** @public */\nexport const cicdStatisticsApiRef = createApiRef<CicdStatisticsApi>({\n id: 'cicd-statistics-api',\n});\n"],"names":[],"mappings":";;AAwBA,MAAM,+BAA+B,cAAe,CAAA;AAAA,EAClD,EAAI,EAAA,iBAAA;AACN,CAAC,CAAA,CAAA;AAGM,MAAM,uBAAuB,YAAa,CAAA;AAAA,EAC/C,EAAI,EAAA,iBAAA;AAAA,EACJ,MAAQ,EAAA;AAAA,IACN,aAAe,EAAA,4BAAA;AAAA,GACjB;AACF,CAAC,EAAA;AAGM,MAAM,8BAA8B,oBAAqB,CAAA,OAAA;AAAA,EAC9D,uBAAwB,CAAA;AAAA,IACtB,SAAA,EAAW,MAAM,OAAO,mCAAe,EAAE,IAAK,CAAA,CAAA,CAAA,KAAK,EAAE,oBAAoB,CAAA;AAAA,IACzE,UAAY,EAAA,4BAAA;AAAA,IACZ,IAAM,EAAA,6BAAA;AAAA,GACP,CAAA;AACH;;ACHO,MAAM,WAAuC,GAAA;AAAA,EAClD,WAAA;AAAA,EACA,QAAA;AAAA,EACA,UAAA;AAAA,EACA,WAAA;AAAA,EACA,SAAA;AAAA,EACA,SAAA;AAAA,EACA,SAAA;AAAA,EACA,SAAA;AAAA,EACA,SAAA;AACF,EAAA;AA6BO,MAAM,cAAuC,GAAA;AAAA,EAClD,KAAA;AAAA,EACA,QAAA;AAAA,EACA,UAAA;AAAA,EACA,OAAA;AACF,EAAA;AAyJO,MAAM,mBAAmB,KAAM,CAAA;AAAC;;ACzNhC,MAAM,uBAAuB,YAAgC,CAAA;AAAA,EAClE,EAAI,EAAA,qBAAA;AACN,CAAC;;;;"}
|
package/package.json
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@backstage-community/plugin-cicd-statistics",
|
|
3
|
+
"version": "0.1.37",
|
|
4
|
+
"description": "A frontend plugin visualizing CI/CD pipeline statistics (build time)",
|
|
5
|
+
"backstage": {
|
|
6
|
+
"role": "frontend-plugin"
|
|
7
|
+
},
|
|
8
|
+
"publishConfig": {
|
|
9
|
+
"access": "public",
|
|
10
|
+
"main": "dist/index.esm.js",
|
|
11
|
+
"types": "dist/index.d.ts"
|
|
12
|
+
},
|
|
13
|
+
"keywords": [
|
|
14
|
+
"backstage"
|
|
15
|
+
],
|
|
16
|
+
"homepage": "https://backstage.io",
|
|
17
|
+
"repository": {
|
|
18
|
+
"type": "git",
|
|
19
|
+
"url": "https://github.com/backstage/community-plugins",
|
|
20
|
+
"directory": "workspaces/cicd-statistics/plugins/cicd-statistics"
|
|
21
|
+
},
|
|
22
|
+
"license": "Apache-2.0",
|
|
23
|
+
"sideEffects": false,
|
|
24
|
+
"main": "dist/index.esm.js",
|
|
25
|
+
"types": "dist/index.d.ts",
|
|
26
|
+
"files": [
|
|
27
|
+
"dist"
|
|
28
|
+
],
|
|
29
|
+
"scripts": {
|
|
30
|
+
"build": "backstage-cli package build",
|
|
31
|
+
"clean": "backstage-cli package clean",
|
|
32
|
+
"lint": "backstage-cli package lint",
|
|
33
|
+
"prepack": "backstage-cli package prepack",
|
|
34
|
+
"postpack": "backstage-cli package postpack",
|
|
35
|
+
"start": "backstage-cli package start",
|
|
36
|
+
"test": "backstage-cli package test"
|
|
37
|
+
},
|
|
38
|
+
"dependencies": {
|
|
39
|
+
"@backstage/catalog-model": "^1.4.5",
|
|
40
|
+
"@backstage/core-plugin-api": "^1.9.2",
|
|
41
|
+
"@backstage/plugin-catalog-react": "^1.11.3",
|
|
42
|
+
"@date-io/luxon": "^1.3.13",
|
|
43
|
+
"@material-ui/core": "^4.12.2",
|
|
44
|
+
"@material-ui/icons": "^4.9.1",
|
|
45
|
+
"@material-ui/lab": "4.0.0-alpha.61",
|
|
46
|
+
"@material-ui/pickers": "^3.3.10",
|
|
47
|
+
"already": "^3.2.0",
|
|
48
|
+
"humanize-duration": "^3.27.0",
|
|
49
|
+
"lodash": "^4.17.21",
|
|
50
|
+
"luxon": "^3.0.0",
|
|
51
|
+
"react-use": "^17.3.1",
|
|
52
|
+
"recharts": "^2.5.0"
|
|
53
|
+
},
|
|
54
|
+
"devDependencies": {
|
|
55
|
+
"@backstage/cli": "^0.26.3",
|
|
56
|
+
"@testing-library/dom": "^10.0.0",
|
|
57
|
+
"@testing-library/jest-dom": "^6.0.0",
|
|
58
|
+
"@testing-library/react": "^15.0.0",
|
|
59
|
+
"@types/humanize-duration": "^3.18.1",
|
|
60
|
+
"@types/lodash": "^4.14.151",
|
|
61
|
+
"@types/luxon": "^3.0.0",
|
|
62
|
+
"@types/react": "^16.13.1 || ^17.0.0",
|
|
63
|
+
"@types/react-dom": "^18.2.19",
|
|
64
|
+
"react": "^16.13.1 || ^17.0.0 || ^18.0.0",
|
|
65
|
+
"react-dom": "^16.13.1 || ^17.0.0 || ^18.0.0",
|
|
66
|
+
"react-router-dom": "6.0.0-beta.0 || ^6.3.0"
|
|
67
|
+
},
|
|
68
|
+
"peerDependencies": {
|
|
69
|
+
"react": "^16.13.1 || ^17.0.0 || ^18.0.0",
|
|
70
|
+
"react-dom": "^16.13.1 || ^17.0.0 || ^18.0.0",
|
|
71
|
+
"react-router-dom": "6.0.0-beta.0 || ^6.3.0"
|
|
72
|
+
},
|
|
73
|
+
"module": "./dist/index.esm.js"
|
|
74
|
+
}
|