@platformatic/runtime 3.0.0-alpha.4 → 3.0.0-alpha.6

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/lib/generator.js CHANGED
@@ -1,27 +1,22 @@
1
- 'use strict'
2
-
3
- const createError = require('@fastify/error')
4
- const { BaseGenerator } = require('@platformatic/generators')
5
- const { existsSync } = require('node:fs')
6
- const { join, basename } = require('node:path')
7
- const { envObjectToString } = require('@platformatic/generators/lib/utils')
8
- const { readFile, readdir, stat } = require('node:fs/promises')
9
- const { transform } = require('./config')
10
- const { getServiceTemplateFromSchemaUrl } = require('@platformatic/generators/lib/utils')
11
- const { DotEnvTool } = require('dotenv-tool')
12
- const { getArrayDifference } = require('./utils')
13
- const { schema } = require('./schema')
14
- const { pathToFileURL } = require('node:url')
15
- const {
16
- safeRemove,
17
- generateDashedName,
1
+ import createError from '@fastify/error'
2
+ import {
3
+ defaultPackageManager,
18
4
  findConfigurationFile,
5
+ generateDashedName,
6
+ kMetadata,
19
7
  loadConfiguration,
20
8
  loadConfigurationFile,
21
- kMetadata,
22
- defaultPackageManager
23
- } = require('@platformatic/foundation')
24
- const { createRequire } = require('node:module')
9
+ safeRemove
10
+ } from '@platformatic/foundation'
11
+ import { BaseGenerator, envObjectToString, getApplicationTemplateFromSchemaUrl } from '@platformatic/generators'
12
+ import { existsSync } from 'node:fs'
13
+ import { readFile, readdir, stat } from 'node:fs/promises'
14
+ import { createRequire } from 'node:module'
15
+ import { basename, join } from 'node:path'
16
+ import { pathToFileURL } from 'node:url'
17
+ import { transform } from './config.js'
18
+ import { schema } from './schema.js'
19
+ import { getArrayDifference } from './utils.js'
25
20
 
26
21
  const wrappableProperties = {
27
22
  logger: {
@@ -38,11 +33,11 @@ const engines = {
38
33
  node: '>=22.18.0'
39
34
  }
40
35
 
41
- const ERROR_PREFIX = 'PLT_RUNTIME_GEN'
36
+ export const ERROR_PREFIX = 'PLT_RUNTIME_GEN'
42
37
 
43
- const NoServiceNamedError = createError(
44
- `${ERROR_PREFIX}_NO_SERVICE_FOUND`,
45
- "No service named '%s' has been added to this runtime."
38
+ const NoApplicationNamedError = createError(
39
+ `${ERROR_PREFIX}_NO_APPLICATION_FOUND`,
40
+ "No application named '%s' has been added to this runtime."
46
41
  )
47
42
  const NoEntryPointError = createError(`${ERROR_PREFIX}_NO_ENTRYPOINT`, 'No entrypoint had been defined.')
48
43
 
@@ -55,46 +50,53 @@ function getRuntimeBaseEnvVars (config) {
55
50
  }
56
51
  }
57
52
 
58
- class RuntimeGenerator extends BaseGenerator {
53
+ // This is needed as dotenv-tool is not loading with ESM currently
54
+ export function createDotenvTool (...args) {
55
+ const { DotEnvTool } = createRequire(import.meta.url)('dotenv-tool')
56
+ return new DotEnvTool(...args)
57
+ }
58
+
59
+ export class RuntimeGenerator extends BaseGenerator {
59
60
  constructor (opts) {
60
61
  super({
61
62
  ...opts,
62
63
  module: '@platformatic/runtime'
63
64
  })
64
65
  this.runtimeName = opts.name
65
- this.servicesFolder = opts.servicesFolder ?? 'services'
66
- this.services = []
67
- this.existingServices = []
66
+ this.applicationsFolder = opts.applicationsFolder ?? 'applications'
67
+ this.applications = []
68
+ this.existingApplications = []
68
69
  this.entryPoint = null
69
70
  this.packageManager = opts.packageManager ?? defaultPackageManager
70
71
  }
71
72
 
72
- async addService (service, name) {
73
- // ensure service config is correct
74
- const originalConfig = service.config
75
- const serviceName = name || generateDashedName()
73
+ async addApplication (application, name) {
74
+ // ensure application config is correct
75
+ const originalConfig = application.config
76
+ const applicationName = name || generateDashedName()
76
77
  const newConfig = {
77
78
  ...originalConfig,
78
79
  isRuntimeContext: true,
79
- serviceName
80
+ applicationName
80
81
  }
81
- // reset all files previously generated by the service
82
- service.reset()
83
- service.setConfig(newConfig)
84
- this.services.push({
85
- name: serviceName,
86
- service
82
+ // reset all files previously generated by the application
83
+ application.reset()
84
+ application.setConfig(newConfig)
85
+ this.applications.push({
86
+ name: applicationName,
87
+ application
87
88
  })
88
89
 
89
- service.setRuntime(this)
90
+ application.setRuntime(this)
90
91
  }
91
92
 
92
93
  setEntryPoint (entryPoint) {
93
- const service = this.existingServices.includes(entryPoint) || this.services.find(svc => svc.name === entryPoint)
94
- if (!service) {
95
- throw new NoServiceNamedError(entryPoint)
94
+ const application =
95
+ this.existingApplications.includes(entryPoint) || this.applications.find(svc => svc.name === entryPoint)
96
+ if (!application) {
97
+ throw new NoApplicationNamedError(entryPoint)
96
98
  }
97
- this.entryPoint = service
99
+ this.entryPoint = application
98
100
  }
99
101
 
100
102
  async generatePackageJson () {
@@ -106,8 +108,7 @@ class RuntimeGenerator extends BaseGenerator {
106
108
  start: this.config.startCommand ?? 'platformatic start'
107
109
  },
108
110
  devDependencies: {
109
- fastify: `^${this.fastifyVersion}`,
110
- borp: `${this.pkgData.devDependencies.borp}`
111
+ fastify: `^${this.fastifyVersion}`
111
112
  },
112
113
  dependencies: {
113
114
  '@platformatic/runtime': `^${this.platformaticVersion}`,
@@ -119,24 +120,24 @@ class RuntimeGenerator extends BaseGenerator {
119
120
  }
120
121
 
121
122
  if (this.packageManager === 'npm' || this.packageManager === 'yarn') {
122
- template.workspaces = [this.servicesFolder + '/*']
123
+ template.workspaces = [this.applicationsFolder + '/*']
123
124
  }
124
125
 
125
126
  return template
126
127
  }
127
128
 
128
129
  async _beforePrepare () {
129
- this.setServicesDirectory()
130
- this.setServicesConfigValues()
131
- this.addServicesDependencies()
130
+ this.setApplicationsDirectory()
131
+ this.setApplicationsConfigValues()
132
+ this.addApplicationsDependencies()
132
133
 
133
134
  this.addEnvVars(getRuntimeBaseEnvVars(this.config), { overwrite: false, default: true })
134
135
  }
135
136
 
136
- addServicesDependencies () {
137
- this.services.forEach(({ service }) => {
138
- if (service.config.dependencies) {
139
- Object.entries(service.config.dependencies).forEach(kv => {
137
+ addApplicationsDependencies () {
138
+ this.applications.forEach(({ application }) => {
139
+ if (application.config.dependencies) {
140
+ Object.entries(application.config.dependencies).forEach(kv => {
140
141
  this.config.dependencies[kv[0]] = kv[1]
141
142
  })
142
143
  }
@@ -159,8 +160,8 @@ class RuntimeGenerator extends BaseGenerator {
159
160
  const { PLT_ROOT, ...existingEnvironment } = this.existingConfig[kMetadata].env
160
161
  this.config.env = existingEnvironment
161
162
  this.config.port = this.config.env.PORT
162
- this.entryPoint = this.existingConfig.services.find(svc => svc.entrypoint)
163
- this.existingServices = this.existingConfig.services.map(s => s.id)
163
+ this.entryPoint = this.existingConfig.applications.find(svc => svc.entrypoint)
164
+ this.existingApplications = this.existingConfig.applications.map(s => s.id)
164
165
 
165
166
  this.updateRuntimeConfig(this.existingConfigRaw)
166
167
  this.updateRuntimeEnv(await readFile(join(this.targetDirectory, '.env'), 'utf-8'))
@@ -170,8 +171,8 @@ class RuntimeGenerator extends BaseGenerator {
170
171
  async prepare () {
171
172
  await this.populateFromExistingConfig()
172
173
  if (this.existingConfig) {
173
- this.setServicesDirectory()
174
- this.setServicesConfigValues()
174
+ this.setApplicationsDirectory()
175
+ this.setApplicationsConfigValues()
175
176
  await this._afterPrepare()
176
177
  return {
177
178
  env: this.config.env,
@@ -182,11 +183,11 @@ class RuntimeGenerator extends BaseGenerator {
182
183
  }
183
184
  }
184
185
 
185
- setServicesConfigValues () {
186
- this.services.forEach(({ service }) => {
187
- if (!service.config) {
186
+ setApplicationsConfigValues () {
187
+ this.applications.forEach(({ application }) => {
188
+ if (!application.config) {
188
189
  // set default config
189
- service.setConfig()
190
+ application.setConfig()
190
191
  }
191
192
  })
192
193
  }
@@ -197,7 +198,7 @@ class RuntimeGenerator extends BaseGenerator {
197
198
  entrypoint: this.entryPoint.name,
198
199
  watch: true,
199
200
  autoload: {
200
- path: this.config.autoload || this.servicesFolder,
201
+ path: this.config.autoload || this.applicationsFolder,
201
202
  exclude: ['docs']
202
203
  },
203
204
  ...wrappableProperties
@@ -210,11 +211,11 @@ class RuntimeGenerator extends BaseGenerator {
210
211
  if (!this.entryPoint) {
211
212
  throw new NoEntryPointError()
212
213
  }
213
- const servicesEnv = await this.prepareServiceFiles()
214
+ const applicationsEnv = await this.prepareApplicationFiles()
214
215
  this.addEnvVars({
215
216
  ...this.config.env,
216
217
  ...this.getRuntimeEnv(),
217
- ...servicesEnv
218
+ ...applicationsEnv
218
219
  })
219
220
 
220
221
  this.updateRuntimeEnv(envObjectToString(this.config.env))
@@ -227,25 +228,25 @@ class RuntimeGenerator extends BaseGenerator {
227
228
 
228
229
  return {
229
230
  targetDirectory: this.targetDirectory,
230
- env: servicesEnv
231
+ env: applicationsEnv
231
232
  }
232
233
  }
233
234
 
234
235
  async writeFiles () {
235
- for (const { service } of this.services) {
236
- await service._beforeWriteFiles?.(this)
236
+ for (const { application } of this.applications) {
237
+ await application._beforeWriteFiles?.(this)
237
238
  }
238
239
 
239
240
  await super.writeFiles()
240
241
 
241
242
  if (!this.config.isUpdating) {
242
- for (const { service } of this.services) {
243
- await service.writeFiles()
243
+ for (const { application } of this.applications) {
244
+ await application.writeFiles()
244
245
  }
245
246
  }
246
247
 
247
- for (const { service } of this.services) {
248
- await service._afterWriteFiles?.(this)
248
+ for (const { application } of this.applications) {
249
+ await application._afterWriteFiles?.(this)
249
250
  }
250
251
  }
251
252
 
@@ -265,43 +266,43 @@ class RuntimeGenerator extends BaseGenerator {
265
266
  })
266
267
  }
267
268
 
268
- setServicesDirectory () {
269
- this.services.forEach(({ service }) => {
270
- if (!service.config) {
269
+ setApplicationsDirectory () {
270
+ this.applications.forEach(({ application }) => {
271
+ if (!application.config) {
271
272
  // set default config
272
- service.setConfig()
273
+ application.setConfig()
273
274
  }
274
275
  let basePath
275
276
  if (this.existingConfig) {
276
277
  basePath = this.existingConfig.autoload.path
277
278
  } else {
278
- basePath = join(this.targetDirectory, this.config.autoload || this.servicesFolder)
279
+ basePath = join(this.targetDirectory, this.config.autoload || this.applicationsFolder)
279
280
  }
280
- this.servicesBasePath = basePath
281
- service.setTargetDirectory(join(basePath, service.config.serviceName))
281
+ this.applicationsBasePath = basePath
282
+ application.setTargetDirectory(join(basePath, application.config.applicationName))
282
283
  })
283
284
  }
284
285
 
285
- setServicesConfig (configToOverride) {
286
- this.services.forEach(service => {
287
- const originalConfig = service.config
288
- service.setConfig({
286
+ setApplicationsConfig (configToOverride) {
287
+ this.applications.forEach(application => {
288
+ const originalConfig = application.config
289
+ application.setConfig({
289
290
  ...originalConfig,
290
291
  ...configToOverride
291
292
  })
292
293
  })
293
294
  }
294
295
 
295
- async prepareServiceFiles () {
296
- let servicesEnv = {}
297
- for (const svc of this.services) {
298
- const svcEnv = await svc.service.prepare()
299
- servicesEnv = {
300
- ...servicesEnv,
296
+ async prepareApplicationFiles () {
297
+ let applicationsEnv = {}
298
+ for (const svc of this.applications) {
299
+ const svcEnv = await svc.application.prepare()
300
+ applicationsEnv = {
301
+ ...applicationsEnv,
301
302
  ...svcEnv.env
302
303
  }
303
304
  }
304
- return servicesEnv
305
+ return applicationsEnv
305
306
  }
306
307
 
307
308
  getConfigFieldsDefinitions () {
@@ -319,8 +320,8 @@ class RuntimeGenerator extends BaseGenerator {
319
320
  }
320
321
 
321
322
  async postInstallActions () {
322
- for (const { service } of this.services) {
323
- await service.postInstallActions()
323
+ for (const { application } of this.applications) {
324
+ await application.postInstallActions()
324
325
  }
325
326
  }
326
327
 
@@ -332,122 +333,122 @@ class RuntimeGenerator extends BaseGenerator {
332
333
 
333
334
  async loadFromDir () {
334
335
  const output = {
335
- services: []
336
+ applications: []
336
337
  }
337
338
  const runtimePkgConfigFileData = JSON.parse(await readFile(join(this.targetDirectory, this.runtimeConfig), 'utf-8'))
338
- const servicesPath = join(this.targetDirectory, runtimePkgConfigFileData.autoload.path)
339
+ const applicationsPath = join(this.targetDirectory, runtimePkgConfigFileData.autoload.path)
339
340
 
340
- // load all services
341
- const allServices = await readdir(servicesPath)
342
- for (const s of allServices) {
341
+ // load all applications
342
+ const allApplications = await readdir(applicationsPath)
343
+ for (const s of allApplications) {
343
344
  // check is a directory
344
- const currentServicePath = join(servicesPath, s)
345
- const dirStat = await stat(currentServicePath)
345
+ const currentApplicationPath = join(applicationsPath, s)
346
+ const dirStat = await stat(currentApplicationPath)
346
347
  if (dirStat.isDirectory()) {
347
- // load the service config
348
- const configFile = await findConfigurationFile(currentServicePath)
349
- const servicePltJson = JSON.parse(await readFile(join(currentServicePath, configFile), 'utf-8'))
348
+ // load the application config
349
+ const configFile = await findConfigurationFile(currentApplicationPath)
350
+ const applicationPltJson = JSON.parse(await readFile(join(currentApplicationPath, configFile), 'utf-8'))
350
351
  // get module to load
351
- const template = servicePltJson.module || getServiceTemplateFromSchemaUrl(servicePltJson.$schema)
352
- const Generator = await this._getGeneratorForTemplate(currentServicePath, template)
352
+ const template = applicationPltJson.module || getApplicationTemplateFromSchemaUrl(applicationPltJson.$schema)
353
+ const Generator = await this._getGeneratorForTemplate(currentApplicationPath, template)
353
354
  const instance = new Generator({
354
355
  logger: this.logger
355
356
  })
356
- this.addService(instance, s)
357
- output.services.push(await instance.loadFromDir(s, this.targetDirectory))
357
+ this.addApplication(instance, s)
358
+ output.applications.push(await instance.loadFromDir(s, this.targetDirectory))
358
359
  }
359
360
  }
360
361
  return output
361
362
  }
362
363
 
363
364
  async update (newConfig) {
364
- let allServicesDependencies = {}
365
+ let allApplicationsDependencies = {}
365
366
  const runtimeAddedEnvKeys = []
366
367
 
367
368
  this.config.isUpdating = true
368
369
  const currrentPackageJson = JSON.parse(await readFile(join(this.targetDirectory, 'package.json'), 'utf-8'))
369
370
  const currentRuntimeDependencies = currrentPackageJson.dependencies
370
- // check all services are present with the same template
371
- const allCurrentServicesNames = this.services.map(s => s.name)
372
- const allNewServicesNames = newConfig.services.map(s => s.name)
371
+ // check all applications are present with the same template
372
+ const allCurrentApplicationsNames = this.applications.map(s => s.name)
373
+ const allNewApplicationsNames = newConfig.applications.map(s => s.name)
373
374
  // load dotenv tool
374
- const envTool = new DotEnvTool({
375
+ const envTool = createDotenvTool({
375
376
  path: join(this.targetDirectory, '.env')
376
377
  })
377
378
 
378
379
  await envTool.load()
379
380
 
380
- const removedServices = getArrayDifference(allCurrentServicesNames, allNewServicesNames)
381
- if (removedServices.length > 0) {
382
- for (const removedService of removedServices) {
383
- // handle service delete
381
+ const removedApplications = getArrayDifference(allCurrentApplicationsNames, allNewApplicationsNames)
382
+ if (removedApplications.length > 0) {
383
+ for (const removedApplication of removedApplications) {
384
+ // handle application delete
384
385
 
385
386
  // delete env variables
386
- const s = this.services.find(f => f.name === removedService)
387
+ const s = this.applications.find(f => f.name === removedApplication)
387
388
  const allKeys = envTool.getKeys()
388
389
  allKeys.forEach(k => {
389
- if (k.startsWith(`PLT_${s.service.config.envPrefix}`)) {
390
+ if (k.startsWith(`PLT_${s.application.config.envPrefix}`)) {
390
391
  envTool.deleteKey(k)
391
392
  }
392
393
  })
393
394
 
394
395
  // delete dependencies
395
- const servicePath = join(this.targetDirectory, this.servicesFolder, s.name)
396
- const configFile = await findConfigurationFile(servicePath)
397
- const servicePackageJson = JSON.parse(await readFile(join(servicePath, configFile), 'utf-8'))
398
- if (servicePackageJson.plugins && servicePackageJson.plugins.packages) {
399
- servicePackageJson.plugins.packages.forEach(p => {
396
+ const applicationPath = join(this.targetDirectory, this.applicationsFolder, s.name)
397
+ const configFile = await findConfigurationFile(applicationPath)
398
+ const applicationPackageJson = JSON.parse(await readFile(join(applicationPath, configFile), 'utf-8'))
399
+ if (applicationPackageJson.plugins && applicationPackageJson.plugins.packages) {
400
+ applicationPackageJson.plugins.packages.forEach(p => {
400
401
  delete currrentPackageJson.dependencies[p.name]
401
402
  })
402
403
  }
403
404
  // delete directory
404
- await safeRemove(join(this.targetDirectory, this.servicesFolder, s.name))
405
+ await safeRemove(join(this.targetDirectory, this.applicationsFolder, s.name))
405
406
  }
406
- // throw new CannotRemoveServiceOnUpdateError(removedServices.join(', '))
407
+ // throw new CannotRemoveApplicationOnUpdateError(removedApplications.join(', '))
407
408
  }
408
409
 
409
- // handle new services
410
- for (const newService of newConfig.services) {
411
- // create generator for the service
412
- const ServiceGenerator = await this._getGeneratorForTemplate(
410
+ // handle new applications
411
+ for (const newApplication of newConfig.applications) {
412
+ // create generator for the application
413
+ const ApplicationGenerator = await this._getGeneratorForTemplate(
413
414
  join(this.targetDirectory, 'package.json'),
414
- newService.template
415
+ newApplication.template
415
416
  )
416
- const serviceInstance = new ServiceGenerator({
417
+ const applicationInstance = new ApplicationGenerator({
417
418
  logger: this.logger
418
419
  })
419
420
  const baseConfig = {
420
421
  isRuntimeContext: true,
421
- targetDirectory: join(this.targetDirectory, this.servicesFolder, newService.name),
422
- serviceName: newService.name,
422
+ targetDirectory: join(this.targetDirectory, this.applicationsFolder, newApplication.name),
423
+ applicationName: newApplication.name,
423
424
  plugin: true
424
425
  }
425
- if (allCurrentServicesNames.includes(newService.name)) {
426
- // update existing services env values
427
- // otherwise, is a new service
426
+ if (allCurrentApplicationsNames.includes(newApplication.name)) {
427
+ // update existing applications env values
428
+ // otherwise, is a new application
428
429
  baseConfig.isUpdating = true
429
430
 
430
- // handle service's plugin differences
431
- const oldServiceMetadata = await serviceInstance.loadFromDir(newService.name, this.targetDirectory)
432
- const oldServicePackages = oldServiceMetadata.plugins.map(meta => meta.name)
433
- const newServicePackages = newService.plugins.map(meta => meta.name)
434
- const pluginsToRemove = getArrayDifference(oldServicePackages, newServicePackages)
431
+ // handle application's plugin differences
432
+ const oldApplicationMetadata = await applicationInstance.loadFromDir(newApplication.name, this.targetDirectory)
433
+ const oldApplicationPackages = oldApplicationMetadata.plugins.map(meta => meta.name)
434
+ const newApplicationPackages = newApplication.plugins.map(meta => meta.name)
435
+ const pluginsToRemove = getArrayDifference(oldApplicationPackages, newApplicationPackages)
435
436
  pluginsToRemove.forEach(p => delete currentRuntimeDependencies[p])
436
437
  } else {
437
- // add service to the generator
438
- this.services.push({
439
- name: newService.name,
440
- service: serviceInstance
438
+ // add application to the generator
439
+ this.applications.push({
440
+ name: newApplication.name,
441
+ application: applicationInstance
441
442
  })
442
443
  }
443
- serviceInstance.setConfig(baseConfig)
444
- serviceInstance.setConfigFields(newService.fields)
444
+ applicationInstance.setConfig(baseConfig)
445
+ applicationInstance.setConfigFields(newApplication.fields)
445
446
 
446
- const serviceEnvPrefix = `PLT_${serviceInstance.config.envPrefix}`
447
- for (const plug of newService.plugins) {
448
- await serviceInstance.addPackage(plug)
447
+ const applicationEnvPrefix = `PLT_${applicationInstance.config.envPrefix}`
448
+ for (const plug of newApplication.plugins) {
449
+ await applicationInstance.addPackage(plug)
449
450
  for (const opt of plug.options) {
450
- const key = `${serviceEnvPrefix}_${opt.name}`
451
+ const key = `${applicationEnvPrefix}_${opt.name}`
451
452
  runtimeAddedEnvKeys.push(key)
452
453
  const value = opt.value
453
454
  if (envTool.hasKey(key)) {
@@ -457,18 +458,18 @@ class RuntimeGenerator extends BaseGenerator {
457
458
  }
458
459
  }
459
460
  }
460
- allServicesDependencies = { ...allServicesDependencies, ...serviceInstance.config.dependencies }
461
- const afterPrepareMetadata = await serviceInstance.prepare()
462
- await serviceInstance.writeFiles()
463
- // cleanup runtime env removing keys not present anymore in service plugins
461
+ allApplicationsDependencies = { ...allApplicationsDependencies, ...applicationInstance.config.dependencies }
462
+ const afterPrepareMetadata = await applicationInstance.prepare()
463
+ await applicationInstance.writeFiles()
464
+ // cleanup runtime env removing keys not present anymore in application plugins
464
465
  const allKeys = envTool.getKeys()
465
466
  allKeys.forEach(k => {
466
- if (k.startsWith(`${serviceEnvPrefix}_FST_PLUGIN`) && !runtimeAddedEnvKeys.includes(k)) {
467
+ if (k.startsWith(`${applicationEnvPrefix}_FST_PLUGIN`) && !runtimeAddedEnvKeys.includes(k)) {
467
468
  envTool.deleteKey(k)
468
469
  }
469
470
  })
470
471
 
471
- // add service env variables to runtime env
472
+ // add application env variables to runtime env
472
473
  Object.entries(afterPrepareMetadata.env).forEach(([key, value]) => {
473
474
  envTool.addKey(key, value)
474
475
  })
@@ -476,7 +477,7 @@ class RuntimeGenerator extends BaseGenerator {
476
477
  // update runtime package.json dependencies
477
478
  currrentPackageJson.dependencies = {
478
479
  ...currrentPackageJson.dependencies,
479
- ...allServicesDependencies
480
+ ...allApplicationsDependencies
480
481
  }
481
482
  this.addFile({
482
483
  path: '',
@@ -549,7 +550,7 @@ class RuntimeGenerator extends BaseGenerator {
549
550
  }
550
551
  }
551
552
 
552
- class WrappedGenerator extends BaseGenerator {
553
+ export class WrappedGenerator extends BaseGenerator {
553
554
  async prepare () {
554
555
  await this.getPlatformaticVersion()
555
556
  await this.#updateEnvironment()
@@ -637,8 +638,3 @@ class WrappedGenerator extends BaseGenerator {
637
638
  return contents + suffix
638
639
  }
639
640
  }
640
-
641
- module.exports = {
642
- RuntimeGenerator,
643
- WrappedGenerator
644
- }
package/lib/logger.js CHANGED
@@ -1,9 +1,9 @@
1
- 'use strict'
1
+ import { buildPinoFormatters, buildPinoTimestamp } from '@platformatic/foundation'
2
+ import { isatty } from 'node:tty'
3
+ import pino from 'pino'
4
+ import pretty from 'pino-pretty'
2
5
 
3
- const { isatty } = require('node:tty')
4
- const pino = require('pino')
5
- const pretty = require('pino-pretty')
6
- const { abstractLogger, buildPinoFormatters, buildPinoTimestamp } = require('@platformatic/foundation')
6
+ export { abstractLogger } from '@platformatic/foundation'
7
7
 
8
8
  const customPrettifiers = {
9
9
  name (name, _, obj) {
@@ -17,7 +17,7 @@ const customPrettifiers = {
17
17
  }
18
18
 
19
19
  // Create the runtime logger
20
- async function createLogger (config) {
20
+ export async function createLogger (config) {
21
21
  const loggerConfig = { ...config.logger, transport: undefined }
22
22
  if (config.logger.base === null) {
23
23
  loggerConfig.base = undefined
@@ -55,5 +55,3 @@ async function createLogger (config) {
55
55
 
56
56
  return [pino(loggerConfig, multiStream), multiStream]
57
57
  }
58
-
59
- module.exports = { abstractLogger, createLogger }