@toa.io/operations 1.0.0-alpha.136 → 1.0.0-alpha.141

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@toa.io/operations",
3
- "version": "1.0.0-alpha.136",
3
+ "version": "1.0.0-alpha.141",
4
4
  "description": "Toa Deployment",
5
5
  "homepage": "https://toa.io",
6
6
  "author": {
@@ -29,10 +29,10 @@
29
29
  "dependencies": {
30
30
  "@toa.io/filesystem": "1.0.0-alpha.93",
31
31
  "@toa.io/generic": "1.0.0-alpha.93",
32
- "@toa.io/norm": "1.0.0-alpha.136",
32
+ "@toa.io/norm": "1.0.0-alpha.141",
33
33
  "@toa.io/yaml": "1.0.0-alpha.93",
34
34
  "execa": "5.1.1",
35
35
  "fs-extra": "11.1.1"
36
36
  },
37
- "gitHead": "73722f06d137283915ca8710ae09e5e53307e1f9"
37
+ "gitHead": "c249cafe7249cb5ab4e9c4624ff3175dad654955"
38
38
  }
@@ -5,6 +5,7 @@ const fs = require('fs-extra')
5
5
  const { createHash } = require('node:crypto')
6
6
 
7
7
  const { Image } = require('./image')
8
+ const { undef } = require('@toa.io/concise/source/expressions/undefined')
8
9
 
9
10
  class Composition extends Image {
10
11
  dockerfile = join(__dirname, 'composition.Dockerfile')
@@ -37,11 +38,7 @@ class Composition extends Image {
37
38
  }
38
39
 
39
40
  get base () {
40
- if (this.#image !== undefined) {
41
- return this.#image
42
- }
43
-
44
- let image = null
41
+ let image = this.#image
45
42
 
46
43
  for (const component of this.#components) {
47
44
  const value = component.build?.image
@@ -53,7 +50,20 @@ class Composition extends Image {
53
50
  image = value
54
51
  }
55
52
 
56
- return image ?? undefined
53
+ return image
54
+ }
55
+
56
+ get run () {
57
+ const commands = []
58
+
59
+ for (const component of this.#components) {
60
+ const run = component.build?.run
61
+
62
+ if (run !== undefined)
63
+ commands.push(run)
64
+ }
65
+
66
+ return commands.join('\n')
57
67
  }
58
68
 
59
69
  async prepare (root) {
@@ -27,7 +27,7 @@ class Image {
27
27
  #runtime
28
28
  #values = {
29
29
  build: {
30
- image: 'node:20.9.0-alpine3.18'
30
+ image: 'node:22.14.0-alpine3.21'
31
31
  }
32
32
  }
33
33
 
@@ -54,6 +54,8 @@ class Image {
54
54
 
55
55
  get base () {}
56
56
 
57
+ get run () {}
58
+
57
59
  async prepare (root) {
58
60
  if (this.dockerfile === undefined) throw new Error('Dockerfile isn\'t specified')
59
61
 
@@ -81,9 +83,13 @@ class Image {
81
83
 
82
84
  const image = this.base
83
85
 
84
- if (image !== undefined) {
86
+ if (image !== undefined)
85
87
  this.#values.build.image = image
86
- }
88
+
89
+ const run = this.run
90
+
91
+ if (run !== undefined)
92
+ this.#values.build.run = (this.#values.build.run === undefined ? '' : this.#values.build.run + '\n') + run
87
93
 
88
94
  if (this.#values.build.arguments !== undefined) this.#values.build.arguments = createArguments(this.#values.build.arguments)
89
95
  if (this.#values.build.run !== undefined) this.#values.build.run = createRunCommands(this.#values.build.run)
@@ -1,4 +1,4 @@
1
- FROM node:20.9.0-alpine3.18
1
+ FROM {{build.image}}
2
2
 
3
3
  ENV NODE_ENV=production
4
4
  RUN if [ "{{runtime.registry}}" != "" ]; then npm set registry {{runtime.registry}}; fi