@platformatic/generators 1.15.1 → 1.16.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.
@@ -59,10 +59,11 @@ ${customization.requires || ''}
59
59
 
60
60
  async function getServer (t) {
61
61
  ${customization.pre || ''}
62
- const config = JSON.parse(await readFile(join(__dirname, '..', 'platformatic.${mod}.json'), 'utf8'))
62
+ const config = JSON.parse(await readFile(join(__dirname, '..', 'platformatic.json'), 'utf8'))
63
63
  // Add your config customizations here. For example you want to set
64
64
  // all things that are set in the config file to read from an env variable
65
- config.server.logger.level = 'warn'
65
+ config.server ||= {}
66
+ config.server.logger ||= {}
66
67
  config.watch = false
67
68
  ${customization.config || ''}
68
69
  // Add your config customizations here
@@ -125,9 +126,11 @@ type TestContext = Parameters<Exclude<testfn, undefined>>[0]
125
126
  export async function getServer (t: TestContext) {
126
127
  ${customizations.pre}
127
128
  // We go up two folder because this files executes in the dist folder
128
- const config = JSON.parse(await readFile(join(__dirname, '..', '..', 'platformatic'), 'utf8'))
129
+ const config = JSON.parse(await readFile(join(__dirname, '..', '..', 'platformatic.json'), 'utf8'))
129
130
  // Add your config customizations here. For example you want to set
130
131
  // all things that are set in the config file to read from an env variable
132
+ config.server ||= {}
133
+ config.server.logger ||= {}
131
134
  config.server.logger.level = 'warn'
132
135
  config.watch = false
133
136
  ${customizations.config}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@platformatic/generators",
3
- "version": "1.15.1",
3
+ "version": "1.16.0",
4
4
  "description": "Main classes and utils for generators.",
5
5
  "main": "index.js",
6
6
  "keywords": [],
@@ -295,8 +295,8 @@ test('should generate javascript plugin, routes and tests', async (t) => {
295
295
  assert.ok(bg.getFileObject('example.js', 'plugins'))
296
296
  assert.ok(bg.getFileObject('root.js', 'routes'))
297
297
 
298
- assert.ok(bg.getFileObject('root.test.js', 'test/routes'))
299
- assert.ok(bg.getFileObject('example.test.js', 'test/plugins'))
298
+ assert.ok(bg.getFileObject('root.test.js', join('test', 'routes')))
299
+ assert.ok(bg.getFileObject('example.test.js', join('test', 'plugins')))
300
300
  })
301
301
 
302
302
  test('should generate tsConfig file and typescript files', async (t) => {
@@ -335,8 +335,8 @@ test('should generate tsConfig file and typescript files', async (t) => {
335
335
  assert.ok(bg.getFileObject('example.ts', 'plugins'))
336
336
  assert.ok(bg.getFileObject('root.ts', 'routes'))
337
337
 
338
- assert.ok(bg.getFileObject('root.test.ts', 'test/routes'))
339
- assert.ok(bg.getFileObject('example.test.ts', 'test/plugins'))
338
+ assert.ok(bg.getFileObject('root.test.ts', join('test', 'routes')))
339
+ assert.ok(bg.getFileObject('example.test.ts', join('test', 'plugins')))
340
340
  })
341
341
 
342
342
  test('should throw if preapare fails', async (t) => {
@@ -521,7 +521,7 @@ test('support packages', async (t) => {
521
521
  {
522
522
  name: '@fastify/static',
523
523
  options: {
524
- root: '{PLT_ROOT}/public'
524
+ root: join('{PLT_ROOT}', 'public')
525
525
  }
526
526
  }
527
527
  ]
@@ -561,7 +561,7 @@ test('support packages', async (t) => {
561
561
  {
562
562
  name: '@fastify/static',
563
563
  options: {
564
- root: '{PLT_ROOT}/{PLT_MY_SERVICE_FST_PLUGIN_STATIC_ROOT}'
564
+ root: join('{PLT_ROOT}', '{PLT_MY_SERVICE_FST_PLUGIN_STATIC_ROOT}')
565
565
  }
566
566
  }
567
567
  ]
@@ -39,9 +39,9 @@ describe('FileGenerator', () => {
39
39
  fg.addFile({ path: '/anotherpath', file: 'foobar.txt', contents: 'foobar' })
40
40
 
41
41
  assert.deepEqual(fg.listFiles(), [
42
- 'path/helloworld.txt',
43
- 'path/foobar.txt',
44
- 'anotherpath/foobar.txt'
42
+ join('path', 'helloworld.txt'),
43
+ join('path', 'foobar.txt'),
44
+ join('anotherpath', 'foobar.txt')
45
45
  ])
46
46
  })
47
47
  test('should append file content', async (t) => {
package/test/runner.js CHANGED
@@ -2,16 +2,16 @@
2
2
 
3
3
  const { tap, spec } = require('node:test/reporters')
4
4
  const { run } = require('node:test')
5
- const path = require('node:path')
5
+ const { join } = require('node:path')
6
6
  const glob = require('glob').globSync
7
7
 
8
8
  /* eslint-disable new-cap */
9
9
  const reporter = process.stdout.isTTY ? new spec() : tap
10
10
 
11
11
  const files = [
12
- ...glob(path.join(__dirname, '*.test.js')),
13
- ...glob(path.join(__dirname, 'cli', '*.test.mjs'))
14
- ]
12
+ ...glob('*.test.{js,mjs}', { cwd: __dirname }),
13
+ ...glob('*/*.test.{js,mjs}', { cwd: __dirname })
14
+ ].map(file => join(__dirname, file))
15
15
 
16
16
  const stream = run({
17
17
  files,