wattpm 2.41.0 → 2.43.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.
package/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { bold } from 'colorette'
2
- import { buildCommand, installCommand } from './lib/commands/build.js'
2
+ import { buildCommand, installCommand, updateCommand } from './lib/commands/build.js'
3
3
  import { devCommand, reloadCommand, restartCommand, startCommand, stopCommand } from './lib/commands/execution.js'
4
4
  import { importCommand, resolveCommand } from './lib/commands/external.js'
5
5
  import { helpCommand } from './lib/commands/help.js'
@@ -102,6 +102,9 @@ export async function main () {
102
102
  case 'install':
103
103
  command = installCommand
104
104
  break
105
+ case 'update':
106
+ command = updateCommand
107
+ break
105
108
  case 'help':
106
109
  command = helpCommand
107
110
  break
@@ -3,8 +3,10 @@ import { bold } from 'colorette'
3
3
  import { parse } from 'dotenv'
4
4
  import { execa } from 'execa'
5
5
  import { existsSync } from 'node:fs'
6
- import { readFile } from 'node:fs/promises'
6
+ import { readFile, writeFile } from 'node:fs/promises'
7
7
  import { resolve } from 'node:path'
8
+ import { rsort, satisfies } from 'semver'
9
+ import { packages } from '../packages.js'
8
10
  import {
9
11
  buildRuntime,
10
12
  findConfigurationFile,
@@ -149,6 +151,84 @@ export async function installCommand (logger, args) {
149
151
  logger.done('All services have been resolved.')
150
152
  }
151
153
 
154
+ export async function updateCommand (logger, args) {
155
+ const { positionals } = parseArgs(args, {}, false)
156
+
157
+ /* c8 ignore next */
158
+ const root = getRoot(positionals)
159
+ const configurationFile = await findConfigurationFile(logger, root)
160
+ const { services } = await loadConfigurationFile(logger, configurationFile)
161
+
162
+ // First of all, get all version from NPM for the runtime
163
+ const selfInfoResponse = await fetch('https://registry.npmjs.org/@platformatic/runtime')
164
+
165
+ if (!selfInfoResponse.ok) {
166
+ logger.fatal(
167
+ { response: selfInfoResponse.status, body: await selfInfoResponse.text() },
168
+ 'Unable to fetch version information.'
169
+ )
170
+ }
171
+
172
+ const selfInfo = await selfInfoResponse.json()
173
+ const availableVersions = rsort(
174
+ Object.values(selfInfo.versions)
175
+ .filter(s => !s.deprecated)
176
+ .map(s => s.version)
177
+ )
178
+
179
+ // Now, for all the services in the configuration file, update the dependencies
180
+ for (const service of services) {
181
+ // Parse the configuration file, if any
182
+ const packageJsonPath = resolve(service.path, 'package.json')
183
+ if (!existsSync(packageJsonPath)) {
184
+ continue
185
+ }
186
+
187
+ let updated = false
188
+ const packageJson = JSON.parse(await readFile(packageJsonPath, 'utf-8'))
189
+
190
+ for (const section of ['dependencies', 'devDependencies', 'peerDependencies', 'optionalDependencies']) {
191
+ const sectionLabel = section === 'dependencies' ? '' : ` (${bold(section)})`
192
+ for (const [pkg, range] of Object.entries(packageJson[section] ?? {})) {
193
+ const specifier = range[0]
194
+
195
+ if (!packages.includes(pkg)) {
196
+ continue
197
+ }
198
+
199
+ if (specifier !== '^' && specifier !== '~') {
200
+ continue
201
+ }
202
+
203
+ // Search the first version that satisfies the range
204
+ let newRange = availableVersions.find(v => satisfies(v, range))
205
+
206
+ // Nothing new, move on
207
+ if (!newRange) {
208
+ continue
209
+ }
210
+
211
+ newRange = specifier + newRange
212
+
213
+ if (newRange && specifier + newRange !== range) {
214
+ updated = true
215
+ logger.info(
216
+ `Updating dependency ${bold(pkg)} of service ${bold(service.id)}${sectionLabel} from ${bold(range)} to ${bold(newRange)} ...`
217
+ )
218
+
219
+ packageJson[section][pkg] = newRange
220
+ }
221
+ }
222
+ }
223
+
224
+ if (updated) {
225
+ await writeFile(packageJsonPath, JSON.stringify(packageJson, null, 2))
226
+ }
227
+ }
228
+
229
+ logger.done('All dependencies have been updated.')
230
+ }
231
+
152
232
  export const help = {
153
233
  build: {
154
234
  usage: 'build [root]',
@@ -179,5 +259,15 @@ export const help = {
179
259
  description: 'Use an alternative package manager (the default is to autodetect it)'
180
260
  }
181
261
  ]
262
+ },
263
+ update: {
264
+ usage: 'update [root]',
265
+ description: 'Updates all the Platformatic packages to the latest available version.',
266
+ args: [
267
+ {
268
+ name: 'root',
269
+ description: 'The directory containing the application (the default is the current directory)'
270
+ }
271
+ ]
182
272
  }
183
273
  }
@@ -0,0 +1,39 @@
1
+ // This is auto generated from "npm run gen-packages" - DO NOT EDIT
2
+ export const packages = [
3
+ '@platformatic/astro',
4
+ '@platformatic/basic',
5
+ '@platformatic/client',
6
+ '@platformatic/client-cli',
7
+ '@platformatic/composer',
8
+ '@platformatic/config',
9
+ '@platformatic/control',
10
+ '@platformatic/db',
11
+ '@platformatic/db-authorization',
12
+ '@platformatic/db-core',
13
+ '@platformatic/frontend-template',
14
+ '@platformatic/generate-errors-doc',
15
+ '@platformatic/generators',
16
+ '@platformatic/globals',
17
+ '@platformatic/itc',
18
+ '@platformatic/metrics',
19
+ '@platformatic/next',
20
+ '@platformatic/node',
21
+ '@platformatic/remix',
22
+ '@platformatic/rpc',
23
+ '@platformatic/rpc-cli',
24
+ '@platformatic/runtime',
25
+ '@platformatic/scalar-theme',
26
+ '@platformatic/service',
27
+ '@platformatic/sql-events',
28
+ '@platformatic/sql-graphql',
29
+ '@platformatic/sql-json-schema-mapper',
30
+ '@platformatic/sql-mapper',
31
+ '@platformatic/sql-openapi',
32
+ '@platformatic/telemetry',
33
+ '@platformatic/ts-compiler',
34
+ '@platformatic/utils',
35
+ '@platformatic/vite',
36
+ 'create-platformatic',
37
+ 'platformatic',
38
+ 'wattpm'
39
+ ]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wattpm",
3
- "version": "2.41.0",
3
+ "version": "2.43.0",
4
4
  "description": "The Node.js Application Server",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -33,13 +33,14 @@
33
33
  "minimist": "^1.2.8",
34
34
  "pino": "^9.4.0",
35
35
  "pino-pretty": "^13.0.0",
36
+ "semver": "^7.7.0",
36
37
  "split2": "^4.2.0",
37
38
  "table": "^6.8.2",
38
- "@platformatic/basic": "2.41.0",
39
- "@platformatic/control": "2.41.0",
40
- "@platformatic/utils": "2.41.0",
41
- "@platformatic/runtime": "2.41.0",
42
- "@platformatic/config": "2.41.0"
39
+ "@platformatic/basic": "2.43.0",
40
+ "@platformatic/config": "2.43.0",
41
+ "@platformatic/control": "2.43.0",
42
+ "@platformatic/runtime": "2.43.0",
43
+ "@platformatic/utils": "2.43.0"
43
44
  },
44
45
  "devDependencies": {
45
46
  "borp": "^0.19.0",
@@ -49,14 +50,15 @@
49
50
  "neostandard": "^0.12.0",
50
51
  "typescript": "^5.5.4",
51
52
  "undici": "^7.0.0",
52
- "@platformatic/node": "2.41.0"
53
+ "@platformatic/node": "2.43.0"
53
54
  },
54
55
  "scripts": {
55
56
  "test": "npm run lint && borp --concurrency=1 --timeout=300000",
56
57
  "coverage": "npm run lint && borp -X test -C --concurrency=1 --timeout=300000",
58
+ "gen-packages": "node scripts/list-package.js > lib/packages.js",
57
59
  "gen-schema": "node lib/schema.js > schema.json",
58
60
  "gen-types": "json2ts > config.d.ts < schema.json",
59
- "build": "pnpm run gen-schema && pnpm run gen-types",
61
+ "build": "pnpm run gen-packages && pnpm run gen-schema && pnpm run gen-types",
60
62
  "lint": "eslint"
61
63
  }
62
64
  }
package/schema.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "$id": "https://schemas.platformatic.dev/wattpm/2.41.0.json",
2
+ "$id": "https://schemas.platformatic.dev/wattpm/2.43.0.json",
3
3
  "$schema": "http://json-schema.org/draft-07/schema#",
4
4
  "type": "object",
5
5
  "properties": {
@@ -113,7 +113,7 @@
113
113
  ]
114
114
  },
115
115
  "maxUnhealthyChecks": {
116
- "default": 3,
116
+ "default": 10,
117
117
  "anyOf": [
118
118
  {
119
119
  "type": "number",
@@ -125,7 +125,7 @@
125
125
  ]
126
126
  },
127
127
  "maxELU": {
128
- "default": 0.95,
128
+ "default": 0.99,
129
129
  "anyOf": [
130
130
  {
131
131
  "type": "number",
@@ -138,7 +138,7 @@
138
138
  ]
139
139
  },
140
140
  "maxHeapUsed": {
141
- "default": 0.95,
141
+ "default": 0.99,
142
142
  "anyOf": [
143
143
  {
144
144
  "type": "number",
@@ -284,7 +284,7 @@
284
284
  ]
285
285
  },
286
286
  "maxUnhealthyChecks": {
287
- "default": 3,
287
+ "default": 10,
288
288
  "anyOf": [
289
289
  {
290
290
  "type": "number",
@@ -296,7 +296,7 @@
296
296
  ]
297
297
  },
298
298
  "maxELU": {
299
- "default": 0.95,
299
+ "default": 0.99,
300
300
  "anyOf": [
301
301
  {
302
302
  "type": "number",
@@ -309,7 +309,7 @@
309
309
  ]
310
310
  },
311
311
  "maxHeapUsed": {
312
- "default": 0.95,
312
+ "default": 0.99,
313
313
  "anyOf": [
314
314
  {
315
315
  "type": "number",
@@ -520,7 +520,7 @@
520
520
  ]
521
521
  },
522
522
  "maxUnhealthyChecks": {
523
- "default": 3,
523
+ "default": 10,
524
524
  "anyOf": [
525
525
  {
526
526
  "type": "number",
@@ -532,7 +532,7 @@
532
532
  ]
533
533
  },
534
534
  "maxELU": {
535
- "default": 0.95,
535
+ "default": 0.99,
536
536
  "anyOf": [
537
537
  {
538
538
  "type": "number",
@@ -545,7 +545,7 @@
545
545
  ]
546
546
  },
547
547
  "maxHeapUsed": {
548
- "default": 0.95,
548
+ "default": 0.99,
549
549
  "anyOf": [
550
550
  {
551
551
  "type": "number",
@@ -870,7 +870,7 @@
870
870
  },
871
871
  {
872
872
  "type": "number",
873
- "minimum": 100
873
+ "minimum": 0
874
874
  }
875
875
  ]
876
876
  },
@@ -949,7 +949,7 @@
949
949
  ]
950
950
  },
951
951
  "maxUnhealthyChecks": {
952
- "default": 3,
952
+ "default": 10,
953
953
  "anyOf": [
954
954
  {
955
955
  "type": "number",
@@ -961,7 +961,7 @@
961
961
  ]
962
962
  },
963
963
  "maxELU": {
964
- "default": 0.95,
964
+ "default": 0.99,
965
965
  "anyOf": [
966
966
  {
967
967
  "type": "number",
@@ -974,7 +974,7 @@
974
974
  ]
975
975
  },
976
976
  "maxHeapUsed": {
977
- "default": 0.95,
977
+ "default": 0.99,
978
978
  "anyOf": [
979
979
  {
980
980
  "type": "number",