@grnsft/if 1.0.2 → 1.1.0-beta.0

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.
Files changed (107) hide show
  1. package/.dockerignore +10 -0
  2. package/CONTAINER.md +148 -0
  3. package/Dockerfile +73 -0
  4. package/HELM_CHART.md +96 -0
  5. package/README.md +56 -0
  6. package/bin/docker-entrypoint.sh +15 -0
  7. package/build/common/types/manifest.d.ts +1 -0
  8. package/build/common/types/manifest.js +1 -1
  9. package/build/common/util/debug-logger.js +4 -18
  10. package/build/common/util/storage.d.ts +9 -0
  11. package/build/common/util/storage.js +24 -0
  12. package/build/if-api/config/config.d.ts +9 -0
  13. package/build/if-api/config/config.js +58 -0
  14. package/build/if-api/config/index.d.ts +2 -0
  15. package/build/if-api/config/index.js +8 -0
  16. package/build/if-api/config/strings.d.ts +16 -0
  17. package/build/if-api/config/strings.js +20 -0
  18. package/build/if-api/index.d.ts +2 -0
  19. package/build/if-api/index.js +268 -0
  20. package/build/if-api/types/process-args.d.ts +18 -0
  21. package/build/if-api/types/process-args.js +3 -0
  22. package/build/if-api/util/args.d.ts +5 -0
  23. package/build/if-api/util/args.js +42 -0
  24. package/build/if-metadata-check/config/config.d.ts +5 -0
  25. package/build/if-metadata-check/config/config.js +26 -0
  26. package/build/if-metadata-check/config/strings.d.ts +5 -0
  27. package/build/if-metadata-check/config/strings.js +9 -0
  28. package/build/if-metadata-check/index.d.ts +2 -0
  29. package/build/if-metadata-check/index.js +30 -0
  30. package/build/if-metadata-check/types/plugin.d.ts +7 -0
  31. package/build/if-metadata-check/types/plugin.js +3 -0
  32. package/build/if-metadata-check/types/process-args.d.ts +5 -0
  33. package/build/if-metadata-check/types/process-args.js +3 -0
  34. package/build/if-metadata-check/util/args.d.ts +57 -0
  35. package/build/if-metadata-check/util/args.js +29 -0
  36. package/build/if-metadata-check/util/metadata-checker.d.ts +44 -0
  37. package/build/if-metadata-check/util/metadata-checker.js +99 -0
  38. package/build/if-run/index.js +1 -1
  39. package/build/if-run/lib/aggregate.d.ts +2 -2
  40. package/build/if-run/lib/aggregate.js +5 -19
  41. package/build/if-run/lib/compute.d.ts +1 -1
  42. package/build/if-run/lib/compute.js +10 -9
  43. package/build/if-run/lib/environment.d.ts +5 -1
  44. package/build/if-run/lib/environment.js +21 -16
  45. package/build/if-run/lib/initialize.d.ts +12 -0
  46. package/build/if-run/lib/initialize.js +37 -3
  47. package/build/if-run/lib/regroup.d.ts +3 -2
  48. package/build/if-run/lib/regroup.js +13 -9
  49. package/build/if-run/types/compute.d.ts +1 -1
  50. package/build/if-run/types/compute.js +1 -1
  51. package/helm-chart/.helmignore +23 -0
  52. package/helm-chart/Chart.yaml +24 -0
  53. package/helm-chart/templates/NOTES.txt +22 -0
  54. package/helm-chart/templates/_helpers.tpl +62 -0
  55. package/helm-chart/templates/additionalPlugins.yaml +13 -0
  56. package/helm-chart/templates/deployment.yaml +144 -0
  57. package/helm-chart/templates/disabledPlugins.yaml +11 -0
  58. package/helm-chart/templates/env-configmap.yaml +10 -0
  59. package/helm-chart/templates/env-secret.yaml +10 -0
  60. package/helm-chart/templates/hpa.yaml +32 -0
  61. package/helm-chart/templates/ingress.yaml +43 -0
  62. package/helm-chart/templates/npmrc.yaml +11 -0
  63. package/helm-chart/templates/service.yaml +24 -0
  64. package/helm-chart/templates/serviceaccount.yaml +13 -0
  65. package/helm-chart/templates/tests/test-connection.yaml +15 -0
  66. package/helm-chart/values.yaml +175 -0
  67. package/manifests/examples/bugs/aggregation-error-wrong-metric.yml +173 -0
  68. package/manifests/examples/bugs/input-error-missing-duration.yml +25 -0
  69. package/manifests/examples/bugs/mock-observations-failure-duration-is-zero.yml +33 -0
  70. package/manifests/examples/bugs/pipeline-error-naming-mismatch.yml +32 -0
  71. package/manifests/examples/bugs/pipeline-error-uninitialized-plugin.yml +33 -0
  72. package/manifests/examples/bugs/pipeline-ordering-error.yml +91 -0
  73. package/manifests/examples/builtins/divide/success-denominator-equal-zero.yml +36 -0
  74. package/manifests/examples/builtins/mock-observations/failure-invalid-config-cpu-range.yml +0 -1
  75. package/manifests/examples/builtins/mock-observations/failure-invalid-memory-utilization-range.yml +0 -1
  76. package/manifests/examples/builtins/mock-observations/failure-missing-timestamp-from-param.yml +0 -1
  77. package/manifests/examples/builtins/mock-observations/success.yml +0 -1
  78. package/manifests/examples/builtins/sci/failure-invalid-config-value.yml +0 -1
  79. package/manifests/examples/builtins/sci/failure-missing-input-param.yml +0 -1
  80. package/manifests/examples/builtins/sci/success.yml +0 -1
  81. package/manifests/examples/builtins/sci-embodied/failure-invalid-default-emission-value.yml +22 -0
  82. package/manifests/examples/builtins/time-sync/failure-missing-config.yml +0 -2
  83. package/manifests/examples/builtins/time-sync/success.yml +0 -2
  84. package/manifests/examples/features/aggregate-failure-invalid-metrics.yml +50 -0
  85. package/manifests/examples/features/aggregate-failure-missing-metric-in-inputs.yml +50 -0
  86. package/manifests/examples/features/aggregate-horizontal.yml +58 -0
  87. package/manifests/examples/features/aggregate-vertical.yml +58 -0
  88. package/manifests/examples/features/aggregate.yml +58 -0
  89. package/manifests/examples/pipelines/cloud-metadata-divide.yml +36 -0
  90. package/manifests/examples/pipelines/pipeline-with-mocks.yml +0 -1
  91. package/manifests/examples/pipelines/scenario-5.yml +0 -1
  92. package/manifests/outputs/bugs/mock-observations-failure-duration-is-zero.yaml +0 -1
  93. package/manifests/outputs/builtins/mock-observations/failure-invalid-config-cpu-range.yaml +0 -1
  94. package/manifests/outputs/builtins/mock-observations/failure-invalid-memory-utilization-range.yaml +0 -1
  95. package/manifests/outputs/builtins/mock-observations/failure-missing-timestamp-from-param.yaml +0 -1
  96. package/manifests/outputs/builtins/sci/failure-invalid-config-value.yaml +0 -1
  97. package/manifests/outputs/builtins/sci/failure-missing-input-param.yaml +0 -1
  98. package/manifests/outputs/builtins/time-sync/failure-missing-config.yaml +0 -2
  99. package/manifests/outputs/features/regroup/success.yaml +72 -0
  100. package/manifests/outputs/pipelines/pipeline-with-aggregate.yaml +1291 -0
  101. package/manifests/outputs/pipelines/scenario-3.yaml +126 -0
  102. package/openapi.yaml +424 -0
  103. package/package.json +8 -3
  104. package/with-plugins/Dockerfile +59 -0
  105. package/manifests/outputs/builtins/interpolation/interpolation.yaml +0 -81
  106. package/manifests/outputs/features/failure-invalid-regroup.yaml +0 -87
  107. package/manifests/outputs/features/failure-missing-cloud-instance-type.yaml +0 -86
@@ -0,0 +1,126 @@
1
+ name: groupby
2
+ description: successful path
3
+ initialize:
4
+ plugins:
5
+ sum:
6
+ path: builtin
7
+ method: Sum
8
+ config:
9
+ input-parameters:
10
+ - cpu/energy
11
+ - network/energy
12
+ output-parameter: energy
13
+ execution:
14
+ command: >-
15
+ /usr/bin/node /home/mitsuru/if/build/if-run -m
16
+ manifests/examples/pipelines/scenario-3.yml -o
17
+ manifests/outputs/pipelines/scenario-3.yaml
18
+ environment:
19
+ if-version: 1.0.2
20
+ os: Ubuntu
21
+ os-version: 24.04.2 LTS
22
+ node-version: 18.19.1
23
+ date-time: 2025-06-02T14:32:40.906Z (UTC)
24
+ dependencies:
25
+ - '@grnsft/if-core@0.0.30'
26
+ - axios@1.8.3
27
+ - csv-parse@5.5.6
28
+ - csv-stringify@6.4.6
29
+ - express@5.1.0
30
+ - js-yaml@4.1.0
31
+ - luxon@3.4.4
32
+ - ts-command-line-args@2.5.1
33
+ - typescript-cubic-spline@1.0.1
34
+ - winston@3.11.0
35
+ - zod@3.23.8
36
+ status: success
37
+ tree:
38
+ children:
39
+ my-app:
40
+ pipeline:
41
+ observe: null
42
+ regroup:
43
+ - cloud/instance-type
44
+ - cloud/region
45
+ compute: null
46
+ children:
47
+ uk-west:
48
+ children:
49
+ A1:
50
+ children:
51
+ uk-west:
52
+ inputs:
53
+ - timestamp: 2023-07-06T00:00
54
+ duration: 300
55
+ cloud/instance-type: A1
56
+ cloud/region: uk-west
57
+ cpu/utilization: 99
58
+ - timestamp: 2023-07-06T05:00
59
+ duration: 300
60
+ cloud/instance-type: A1
61
+ cloud/region: uk-west
62
+ cpu/utilization: 23
63
+ - timestamp: 2023-07-06T10:00
64
+ duration: 300
65
+ cloud/instance-type: A1
66
+ cloud/region: uk-west
67
+ cpu/utilization: 12
68
+ B1:
69
+ children:
70
+ uk-west:
71
+ inputs:
72
+ - timestamp: 2023-07-06T00:00
73
+ duration: 300
74
+ cloud/instance-type: B1
75
+ cloud/region: uk-west
76
+ cpu/utilization: 11
77
+ - timestamp: 2023-07-06T05:00
78
+ duration: 300
79
+ cloud/instance-type: B1
80
+ cloud/region: uk-west
81
+ cpu/utilization: 67
82
+ - timestamp: 2023-07-06T10:00
83
+ duration: 300
84
+ cloud/instance-type: B1
85
+ cloud/region: uk-west
86
+ cpu/utilization: 1
87
+ uk-east:
88
+ children:
89
+ A1:
90
+ children:
91
+ uk-east:
92
+ inputs:
93
+ - timestamp: 2023-07-06T00:00
94
+ duration: 300
95
+ cloud/instance-type: A1
96
+ cloud/region: uk-east
97
+ cpu/utilization: 9
98
+ - timestamp: 2023-07-06T05:00
99
+ duration: 300
100
+ cloud/instance-type: A1
101
+ cloud/region: uk-east
102
+ cpu/utilization: 23
103
+ - timestamp: 2023-07-06T10:00
104
+ duration: 300
105
+ cloud/instance-type: A1
106
+ cloud/region: uk-east
107
+ cpu/utilization: 12
108
+ B1:
109
+ children:
110
+ uk-east:
111
+ inputs:
112
+ - timestamp: 2023-07-06T00:00
113
+ duration: 300
114
+ cloud/instance-type: B1
115
+ cloud/region: uk-east
116
+ cpu/utilization: 11
117
+ - timestamp: 2023-07-06T05:00
118
+ duration: 300
119
+ cloud/instance-type: B1
120
+ cloud/region: uk-east
121
+ cpu/utilization: 67
122
+ - timestamp: 2023-07-06T10:00
123
+ duration: 300
124
+ cloud/instance-type: B1
125
+ cloud/region: uk-east
126
+ cpu/utilization: 1
package/openapi.yaml ADDED
@@ -0,0 +1,424 @@
1
+ openapi: 3.0.3
2
+ info:
3
+ title: Impact Framework Web API
4
+ description: |-
5
+ This API provides key feature of Impact Framework (IF) as a Web API.
6
+ license:
7
+ name: MIT license
8
+ url: https://github.com/Green-Software-Foundation/if/blob/main/LICENSE
9
+ version: 1.0.0
10
+ externalDocs:
11
+ description: Find out more about Impact Framework
12
+ url: https://if.greensoftware.foundation/
13
+ components:
14
+ schemas:
15
+ aggregation-method-type:
16
+ type: string
17
+ enum:
18
+ - sum
19
+ - avg
20
+ - none
21
+ - copy
22
+ aggregation-method:
23
+ type: object
24
+ properties:
25
+ time:
26
+ $ref: '#/components/schemas/aggregation-method-type'
27
+ component:
28
+ $ref: '#/components/schemas/aggregation-method-type'
29
+ required:
30
+ - time
31
+ - component
32
+ additionalProperties: false
33
+ aggregation-type:
34
+ type: string
35
+ enum:
36
+ - horizontal
37
+ - time
38
+ - vertical
39
+ - component
40
+ - both
41
+ metadata:
42
+ type: object
43
+ additionalProperties:
44
+ type: object
45
+ properties:
46
+ unit:
47
+ type: string
48
+ description:
49
+ type: string
50
+ aggregation-method:
51
+ $ref: '#/components/schemas/aggregation-method'
52
+ required:
53
+ - unit
54
+ - description
55
+ - aggregation-method
56
+ additionalProperties: false
57
+ nullable: true
58
+ parameter-metadata:
59
+ type: object
60
+ properties:
61
+ inputs:
62
+ $ref: '#/components/schemas/metadata'
63
+ outputs:
64
+ $ref: '#/components/schemas/metadata'
65
+ additionalProperties: false
66
+ manifest:
67
+ type: object
68
+ properties:
69
+ name:
70
+ type: string
71
+ description:
72
+ type: string
73
+ nullable: true
74
+ tags:
75
+ type: object
76
+ properties:
77
+ kind:
78
+ type: string
79
+ nullable: true
80
+ complexity:
81
+ type: string
82
+ nullable: true
83
+ category:
84
+ type: string
85
+ nullable: true
86
+ additionalProperties: false
87
+ nullable: true
88
+ explainer:
89
+ type: boolean
90
+ explain:
91
+ type: object
92
+ aggregation:
93
+ type: object
94
+ properties:
95
+ metrics:
96
+ type: array
97
+ items:
98
+ type: string
99
+ type:
100
+ $ref: '#/components/schemas/aggregation-type'
101
+ skip-components:
102
+ type: array
103
+ items:
104
+ type: string
105
+ required:
106
+ - metrics
107
+ - type
108
+ additionalProperties: false
109
+ nullable: true
110
+ initialize:
111
+ type: object
112
+ properties:
113
+ plugins:
114
+ type: object
115
+ additionalProperties:
116
+ type: object
117
+ properties:
118
+ path:
119
+ type: string
120
+ method:
121
+ type: string
122
+ mapping:
123
+ type: object
124
+ additionalProperties:
125
+ type: string
126
+ config:
127
+ type: object
128
+ parameter-metadata:
129
+ $ref: '#/components/schemas/parameter-metadata'
130
+ required:
131
+ - path
132
+ - method
133
+ additionalProperties: false
134
+ required:
135
+ - plugins
136
+ additionalProperties: false
137
+ execution:
138
+ type: object
139
+ properties:
140
+ command:
141
+ type: string
142
+ environment:
143
+ type: object
144
+ properties:
145
+ if-version:
146
+ type: string
147
+ os:
148
+ type: string
149
+ os-version:
150
+ type: string
151
+ node-version:
152
+ type: string
153
+ date-time:
154
+ type: string
155
+ dependencies:
156
+ type: array
157
+ items:
158
+ type: string
159
+ required:
160
+ - if-version
161
+ - os
162
+ - os-version
163
+ - node-version
164
+ - date-time
165
+ - dependencies
166
+ additionalProperties: false
167
+ status:
168
+ type: string
169
+ error:
170
+ type: string
171
+ required:
172
+ - status
173
+ additionalProperties: false
174
+ tree:
175
+ type: object
176
+ required:
177
+ - name
178
+ - initialize
179
+ - tree
180
+ additionalProperties: false
181
+ examples:
182
+ request-yaml:
183
+ summary: 'sample request YAML'
184
+ value:
185
+ name: demo
186
+ initialize:
187
+ plugins:
188
+ double-a-value:
189
+ path: 'builtin'
190
+ method: Coefficient
191
+ config:
192
+ input-parameter: "cpu/utilization"
193
+ coefficient: 2
194
+ output-parameter: "cpu-utilization-doubled"
195
+ tree:
196
+ children:
197
+ child-0:
198
+ pipeline:
199
+ compute:
200
+ - double-a-value
201
+ inputs:
202
+ - timestamp: 2023-07-06T00:00
203
+ duration: 1
204
+ cpu/utilization: 20
205
+ - timestamp: 2023-07-06T00:01
206
+ duration: 1
207
+ cpu/utilization: 80
208
+ request-json:
209
+ summary: 'sample request JSON'
210
+ value:
211
+ {
212
+ "name": "demo",
213
+ "initialize": {
214
+ "plugins": {
215
+ "double-a-value": {
216
+ "path": "builtin",
217
+ "method": "Coefficient",
218
+ "config": {
219
+ "input-parameter": "cpu/utilization",
220
+ "coefficient": 2,
221
+ "output-parameter": "cpu-utilization-doubled"
222
+ }
223
+ }
224
+ }
225
+ },
226
+ "tree": {
227
+ "children": {
228
+ "child-0": {
229
+ "pipeline": {
230
+ "compute": [
231
+ "double-a-value"
232
+ ]
233
+ },
234
+ "inputs": [
235
+ {
236
+ "timestamp": "2023-07-06T00:00",
237
+ "duration": 1,
238
+ "cpu/utilization": 20
239
+ },
240
+ {
241
+ "timestamp": "2023-07-06T00:01",
242
+ "duration": 1,
243
+ "cpu/utilization": 80
244
+ }
245
+ ]
246
+ }
247
+ }
248
+ }
249
+ }
250
+ response-yaml:
251
+ summary: 'sample response YAML'
252
+ value:
253
+ name: demo
254
+ initialize:
255
+ plugins:
256
+ double-a-value:
257
+ path: builtin
258
+ method: Coefficient
259
+ config:
260
+ input-parameter: cpu/utilization
261
+ coefficient: 2
262
+ output-parameter: cpu-utilization-doubled
263
+ execution:
264
+ command: /usr/bin/node /usr/local/bin/if-api
265
+ environment:
266
+ if-version: 1.0.1
267
+ os: Ubuntu
268
+ os-version: 24.04.2 LTS
269
+ node-version: 18.19.1
270
+ date-time: 2025-05-08T06:26:22.727Z (UTC)
271
+ dependencies: []
272
+ status: success
273
+ tree:
274
+ children:
275
+ child-0:
276
+ pipeline:
277
+ compute:
278
+ - double-a-value
279
+ inputs:
280
+ - timestamp: 2023-07-06T00:00
281
+ duration: 1
282
+ cpu/utilization: 20
283
+ - timestamp: 2023-07-06T00:01
284
+ duration: 1
285
+ cpu/utilization: 80
286
+ outputs:
287
+ - timestamp: 2023-07-06T00:00
288
+ duration: 1
289
+ cpu/utilization: 20
290
+ cpu-utilization-doubled: 40
291
+ - timestamp: 2023-07-06T00:01
292
+ duration: 1
293
+ cpu/utilization: 80
294
+ cpu-utilization-doubled: 160
295
+ response-json:
296
+ summary: 'sample response JSON'
297
+ value:
298
+ {
299
+ "name": "demo",
300
+ "initialize": {
301
+ "plugins": {
302
+ "double-a-value": {
303
+ "path": "builtin",
304
+ "method": "Coefficient",
305
+ "config": {
306
+ "input-parameter": "cpu/utilization",
307
+ "coefficient": 2,
308
+ "output-parameter": "cpu-utilization-doubled"
309
+ }
310
+ }
311
+ }
312
+ },
313
+ "execution": {
314
+ "command": "/usr/bin/node /usr/local/bin/if-api",
315
+ "environment": {
316
+ "if-version": "1.0.1",
317
+ "os": "Ubuntu",
318
+ "os-version": "24.04.2 LTS",
319
+ "node-version": "18.19.1",
320
+ "date-time": "2025-05-08T06:30:00.855Z (UTC)",
321
+ "dependencies": []
322
+ },
323
+ "status": "success"
324
+ },
325
+ "tree": {
326
+ "children": {
327
+ "child-0": {
328
+ "pipeline": {
329
+ "compute": [
330
+ "double-a-value"
331
+ ]
332
+ },
333
+ "inputs": [
334
+ {
335
+ "timestamp": "2023-07-06T00:00",
336
+ "duration": 1,
337
+ "cpu/utilization": 20
338
+ },
339
+ {
340
+ "timestamp": "2023-07-06T00:01",
341
+ "duration": 1,
342
+ "cpu/utilization": 80
343
+ }
344
+ ],
345
+ "outputs": [
346
+ {
347
+ "timestamp": "2023-07-06T00:00",
348
+ "duration": 1,
349
+ "cpu/utilization": 20,
350
+ "cpu-utilization-doubled": 40
351
+ },
352
+ {
353
+ "timestamp": "2023-07-06T00:01",
354
+ "duration": 1,
355
+ "cpu/utilization": 80,
356
+ "cpu-utilization-doubled": 160
357
+ }
358
+ ]
359
+ }
360
+ }
361
+ }
362
+ }
363
+ paths:
364
+ /v1/run:
365
+ post:
366
+ summary: Execute `if-run` with given manifest.
367
+ operationId: ifRun
368
+ parameters:
369
+ - in: query
370
+ name: observe
371
+ schema:
372
+ type: boolean
373
+ required: false
374
+ description: "executes only observe pipeline of the manifest"
375
+ - in: query
376
+ name: aggregate
377
+ schema:
378
+ type: boolean
379
+ required: false
380
+ description: "executes only regroup pipeline of the manifest"
381
+ - in: query
382
+ name: compute
383
+ schema:
384
+ type: boolean
385
+ required: false
386
+ description: "executes only compute pipeline of the manifest"
387
+ requestBody:
388
+ description: IF Manifest
389
+ content:
390
+ application/yaml:
391
+ schema:
392
+ $ref: '#/components/schemas/manifest'
393
+ examples:
394
+ sample:
395
+ $ref: '#/components/examples/request-yaml'
396
+ application/json:
397
+ schema:
398
+ $ref: '#/components/schemas/manifest'
399
+ examples:
400
+ sample:
401
+ $ref: '#/components/examples/request-json'
402
+ required: true
403
+ responses:
404
+ '200':
405
+ description: Successful operation.
406
+ content:
407
+ application/yaml:
408
+ schema:
409
+ $ref: '#/components/schemas/manifest'
410
+ examples:
411
+ success:
412
+ $ref: '#/components/examples/response-yaml'
413
+ application/json:
414
+ schema:
415
+ $ref: '#/components/schemas/manifest'
416
+ examples:
417
+ success:
418
+ $ref: '#/components/examples/response-json'
419
+ '400':
420
+ description: Validation Error
421
+ '415':
422
+ description: Invalid Content Type
423
+ '500':
424
+ description: Internal Server Error
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@grnsft/if",
3
3
  "description": "Impact Framework",
4
- "version": "1.0.2",
4
+ "version": "1.1.0-beta.0",
5
5
  "author": {
6
6
  "name": "Green Software Foundation",
7
7
  "email": "info@gsf.com"
@@ -12,7 +12,9 @@
12
12
  "if-env": "build/if-env/index.js",
13
13
  "if-check": "build/if-check/index.js",
14
14
  "if-csv": "build/if-csv/index.js",
15
- "if-merge": "build/if-merge/index.js"
15
+ "if-merge": "build/if-merge/index.js",
16
+ "if-api": "build/if-api/index.js",
17
+ "if-metadata-check": "build/if-metadata-check/index.js"
16
18
  },
17
19
  "bugs": {
18
20
  "url": "https://github.com/Green-Software-Foundation/if/issues/new?assignees=&labels=feedback&projects=&template=feedback.md&title=Feedback+-+"
@@ -22,6 +24,7 @@
22
24
  "axios": "^1.7.2",
23
25
  "csv-parse": "^5.5.6",
24
26
  "csv-stringify": "^6.4.6",
27
+ "express": "^5.1.0",
25
28
  "js-yaml": "^4.1.0",
26
29
  "luxon": "^3.4.4",
27
30
  "ts-command-line-args": "^2.5.1",
@@ -35,6 +38,7 @@
35
38
  "@commitlint/cli": "^18.6.0",
36
39
  "@commitlint/config-conventional": "^18.6.0",
37
40
  "@jest/globals": "^29.6.1",
41
+ "@types/express": "^5.0.1",
38
42
  "@types/jest": "^29.5.7",
39
43
  "@types/js-yaml": "^4.0.5",
40
44
  "@types/luxon": "^3.4.2",
@@ -46,7 +50,7 @@
46
50
  "husky": "^8.0.0",
47
51
  "jest": "^29.6.1",
48
52
  "lint-staged": "^15.2.2",
49
- "release-it": "^16.3.0",
53
+ "release-it": "^19.0.3",
50
54
  "rimraf": "^5.0.5",
51
55
  "ts-jest": "^29.1.1",
52
56
  "typescript": "^5.1.6"
@@ -79,6 +83,7 @@
79
83
  "coverage": "jest --verbose --coverage",
80
84
  "fix": "gts fix",
81
85
  "fix:package": "fixpack",
86
+ "if-api": "npx ts-node src/if-api/index.ts",
82
87
  "if-check": "cross-env CURRENT_DIR=$(node -p \"process.env.INIT_CWD\") npx ts-node src/if-check/index.ts",
83
88
  "if-csv": "cross-env CURRENT_DIR=$(node -p \"process.env.INIT_CWD\") npx ts-node src/if-csv/index.ts",
84
89
  "if-diff": "cross-env CURRENT_DIR=$(node -p \"process.env.INIT_CWD\") npx ts-node src/if-diff/index.ts",
@@ -0,0 +1,59 @@
1
+ ARG BUILDBASEIMAGE=ghcr.io/green-software-foundation/if
2
+ ARG BASEIMAGE=node:18-slim
3
+
4
+ FROM --platform=$BUILDPLATFORM $BUILDBASEIMAGE AS deps
5
+
6
+ USER 0
7
+
8
+ ARG PLUGINS=plugins.txt
9
+ ARG NPMRC=.npmrc
10
+
11
+ # Install additional plugins
12
+ RUN --mount=src=.,target=settings \
13
+ --mount=type=cache,target=/root/.npm,sharing=locked \
14
+ if [ -r settings/$NPMRC -a -s settings/$NPMRC ]; then \
15
+ cp settings/$NPMRC /root/.npmrc; \
16
+ fi; \
17
+ npm install --no-fund $(cat settings/$PLUGINS); \
18
+ rm -f /root/.npmrc
19
+
20
+ # Remove devDependencies
21
+ RUN --mount=type=cache,target=/root/.npm,sharing=locked \
22
+ npm prune --ignore-scripts --omit=dev
23
+
24
+ # Remove empty directory
25
+ RUN rmdir --ignore-fail-on-non-empty node_modules/*
26
+
27
+
28
+ FROM $BASEIMAGE
29
+
30
+ # Packages to be installed
31
+ ARG PACKAGES='git ca-certificates'
32
+
33
+ # Install lsb_release, git and ca-certificates
34
+ RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
35
+ --mount=type=cache,target=/var/lib/apt,sharing=locked \
36
+ apt-get update && \
37
+ apt-get --no-install-recommends install -y \
38
+ lsb-release $PACKAGES
39
+
40
+ # Copy entrypoint shell script
41
+ COPY --from=deps /usr/local/bin/docker-entrypoint.sh /usr/local/bin
42
+
43
+ # Set execution user
44
+ USER 1000
45
+
46
+ # Create application directory
47
+ WORKDIR /app
48
+
49
+ # Copy application and runtime dependencies
50
+ COPY --from=deps --chown=node:node /app .
51
+
52
+ # Set environment variables
53
+ ENV NODE_ENV=production NPM_CONFIG_UPDATE_NOTIFIER=false PATH=/app/node_modules/.bin:$PATH HOST=
54
+
55
+ # Expose port
56
+ EXPOSE 3000
57
+
58
+ # Run the application
59
+ CMD ["if-api"]