@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.
package/lib/create-plugin.js
CHANGED
|
@@ -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
|
|
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
|
|
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
|
@@ -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
|
|
299
|
-
assert.ok(bg.getFileObject('example.test.js', 'test
|
|
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
|
|
339
|
-
assert.ok(bg.getFileObject('example.test.ts', 'test
|
|
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}
|
|
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}
|
|
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
|
|
43
|
-
'path
|
|
44
|
-
'anotherpath
|
|
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
|
|
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(
|
|
13
|
-
...glob(
|
|
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,
|