@platformatic/generators 1.27.0 → 1.28.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.
@@ -367,10 +367,11 @@ class BaseGenerator extends FileGenerator {
367
367
  name: `${this.config.serviceName}`,
368
368
  scripts: {
369
369
  start: 'platformatic start',
370
- test: 'node --test test/**'
370
+ test: 'borp'
371
371
  },
372
372
  devDependencies: {
373
373
  fastify: `^${this.fastifyVersion}`,
374
+ borp: `${this.pkgData.devDependencies.borp}`,
374
375
  ...this.config.devDependencies
375
376
  },
376
377
  dependencies: {
@@ -9,16 +9,17 @@ function getJsStackableIndexFile (stackableName) {
9
9
  const { platformaticService } = require('@platformatic/service')
10
10
  const { schema } = require('./lib/schema')
11
11
  const { Generator } = require('./lib/generator')
12
+ const { version } = require('./package.json')
12
13
 
13
14
  async function stackable (fastify, opts) {
14
15
  await fastify.register(platformaticService, opts)
15
16
  await fastify.register(require('./plugins/example'), opts)
16
17
  }
17
-
18
18
  stackable.configType = '${kebabCase(stackableName + '-app')}'
19
19
  stackable.schema = schema
20
20
  stackable.Generator = Generator
21
21
  stackable.configManagerConfig = {
22
+ version,
22
23
  schema,
23
24
  envWhitelist: ['PORT', 'HOSTNAME'],
24
25
  allowToWatch: ['.env'],
@@ -48,6 +49,9 @@ import { platformaticService, Stackable } from '@platformatic/service'
48
49
  import { schema } from './lib/schema'
49
50
  import { Generator } from './lib/generator'
50
51
  import { ${stackableConfigType} } from './config'
52
+ import { readFileSync } from 'node:fs'
53
+
54
+ const { version } = JSON.parse(readFileSync('package.json', 'utf8'))
51
55
 
52
56
  const stackable: Stackable<${stackableConfigType}> = async function (fastify, opts) {
53
57
  await fastify.register(platformaticService, opts)
@@ -58,6 +62,7 @@ stackable.configType = '${kebabCase(stackableName + '-app')}'
58
62
  stackable.schema = schema
59
63
  stackable.Generator = Generator
60
64
  stackable.configManagerConfig = {
65
+ version,
61
66
  schema,
62
67
  envWhitelist: ['PORT', 'HOSTNAME'],
63
68
  allowToWatch: ['.env'],
@@ -179,7 +184,7 @@ class ${stackableGeneratorType} extends ServiceGenerator {
179
184
  const packageJson = await this.getStackablePackageJson()
180
185
  const config = {
181
186
  $schema: './stackable.schema.json',
182
- module: packageJson.name,
187
+ module: \`\${packageJson.name}@\${packageJson.version}\`,
183
188
  greeting: {
184
189
  text: \`{\${this.getEnvVarName('PLT_GREETING_TEXT')}}\`
185
190
  }
@@ -287,7 +292,7 @@ class ${stackableGeneratorType} extends ServiceGenerator {
287
292
  const packageJson = await this.getStackablePackageJson()
288
293
  const config = {
289
294
  $schema: './stackable.schema.json',
290
- module: packageJson.name,
295
+ module: \`\${packageJson.name}@\${packageJson.version}\`,
291
296
  greeting: {
292
297
  text: \`{\${this.getEnvVarName('PLT_GREETING_TEXT')}}\`
293
298
  }
@@ -359,11 +364,13 @@ function getJsStackableSchemaFile (stackableName) {
359
364
  'use strict'
360
365
 
361
366
  const { schema } = require('@platformatic/service')
367
+ const { version } = require('../package.json')
362
368
 
363
369
  const ${schemaVarName} = {
364
370
  ...schema.schema,
365
371
  $id: '${schemaId}',
366
372
  title: '${schemaTitle}',
373
+ version,
367
374
  properties: {
368
375
  ...schema.schema.properties,
369
376
  module: { type: 'string' },
@@ -400,6 +407,7 @@ const ${schemaVarName} = {
400
407
  ...schema.schema,
401
408
  $id: '${schemaId}',
402
409
  title: '${schemaTitle}',
410
+ version,
403
411
  properties: {
404
412
  ...schema.schema.properties,
405
413
  module: { type: 'string' },
@@ -230,7 +230,9 @@ class StackableGenerator extends FileGenerator {
230
230
  },
231
231
  scripts: {
232
232
  build: 'tsc --build',
233
- 'build:config': 'node ./dist/lib/schema.js | json2ts > config.d.ts',
233
+ 'gen-schema': 'node lib/schema.js > schema.json',
234
+ 'gen-types': 'json2ts > config.d.ts < schema.json',
235
+ 'build:config': 'pnpm run gen-schema && pnpm run gen-types',
234
236
  clean: 'rm -fr ./dist'
235
237
  },
236
238
  engines: {
@@ -261,7 +263,10 @@ class StackableGenerator extends FileGenerator {
261
263
  [startStackableCommand]: './cli/start.js'
262
264
  },
263
265
  scripts: {
264
- 'build:config': 'node lib/schema.js | json2ts > config.d.ts',
266
+ 'gen-schema': 'node lib/schema.js > schema.json',
267
+ 'gen-types': 'json2ts > config.d.ts < schema.json',
268
+ 'build:config': 'pnpm run gen-schema && pnpm run gen-types',
269
+ prepublishOnly: 'pnpm run build:config',
265
270
  lint: 'standard'
266
271
  },
267
272
  engines: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@platformatic/generators",
3
- "version": "1.27.0",
3
+ "version": "1.28.0",
4
4
  "description": "Main classes and utils for generators.",
5
5
  "main": "index.js",
6
6
  "keywords": [],
@@ -10,9 +10,9 @@
10
10
  "@fastify/error": "^3.4.1",
11
11
  "boring-name-generator": "^1.0.3",
12
12
  "change-case-all": "^2.1.0",
13
- "fastify": "^4.26.0",
14
- "pino": "^8.17.2",
15
- "undici": "^6.6.0"
13
+ "fastify": "^4.26.2",
14
+ "pino": "^8.19.0",
15
+ "undici": "^6.9.0"
16
16
  },
17
17
  "devDependencies": {
18
18
  "@types/inquirer": "^9.0.7",
@@ -20,8 +20,8 @@
20
20
  "c8": "^9.1.0",
21
21
  "snazzy": "^9.0.0",
22
22
  "standard": "^17.1.0",
23
- "tsd": "^0.30.4",
24
- "typescript": "^5.3.3"
23
+ "tsd": "^0.30.7",
24
+ "typescript": "^5.4.2"
25
25
  },
26
26
  "scripts": {
27
27
  "lint": "standard | snazzy",