@platformatic/service 0.45.0 → 0.46.1

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
@@ -2,7 +2,7 @@
2
2
 
3
3
  const { isKeyEnabled } = require('@platformatic/utils')
4
4
  const { readFile } = require('fs/promises')
5
- const { dirname, join } = require('path')
5
+ const { join } = require('path')
6
6
 
7
7
  const compiler = require('./lib/compile')
8
8
  const setupCors = require('./lib/plugins/cors')
@@ -108,7 +108,7 @@ platformaticService.configManagerConfig = {
108
108
  let outDir = typescript.outDir
109
109
  if (outDir === undefined) {
110
110
  let tsConfigFile = typescript.tsConfigFile || 'tsconfig.json'
111
- tsConfigFile = join(dirname(this.fullPath), tsConfigFile)
111
+ tsConfigFile = join(this.dirname, tsConfigFile)
112
112
  try {
113
113
  const tsConfig = JSON.parse(await readFile(tsConfigFile, 'utf8'))
114
114
  outDir = tsConfig.compilerOptions.outDir
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@platformatic/service",
3
- "version": "0.45.0",
3
+ "version": "0.46.1",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "bin": {
@@ -65,11 +65,11 @@
65
65
  "pino-pretty": "^10.0.0",
66
66
  "rfdc": "^1.3.0",
67
67
  "ua-parser-js": "^1.0.35",
68
- "@platformatic/client": "0.45.0",
69
- "@platformatic/config": "0.45.0",
70
- "@platformatic/swagger-ui-theme": "0.45.0",
71
- "@platformatic/utils": "0.45.0",
72
- "@platformatic/telemetry": "0.45.0"
68
+ "@platformatic/client": "0.46.1",
69
+ "@platformatic/config": "0.46.1",
70
+ "@platformatic/swagger-ui-theme": "0.46.1",
71
+ "@platformatic/utils": "0.46.1",
72
+ "@platformatic/telemetry": "0.46.1"
73
73
  },
74
74
  "standard": {
75
75
  "ignore": [
@@ -222,186 +222,6 @@ t.test('should not compile typescript plugin with start without tsconfig', async
222
222
  }
223
223
  })
224
224
 
225
- t.test('start command should not compile typescript if `typescript` is false', async (t) => {
226
- const testDir = path.join(urlDirname(import.meta.url), '..', 'fixtures', 'typescript-plugin-nocompile')
227
- const cwd = await getCWD(t)
228
-
229
- await cp(testDir, cwd, { recursive: true })
230
-
231
- const child = execa('node', [cliPath, 'start'], { cwd })
232
- t.teardown(exitOnTeardown(child))
233
-
234
- const jsPluginPath = path.join(cwd, 'dist', 'plugin.js')
235
- try {
236
- await access(jsPluginPath)
237
- t.fail("should not have created 'dist/plugin.js'")
238
- } catch (err) {
239
- // cannot start because the plugin is not compiled
240
- t.equal(err.code, 'ENOENT')
241
- t.equal(err.path, jsPluginPath)
242
- t.pass()
243
- }
244
- })
245
-
246
- t.test('should compile typescript plugin with start command with different cwd', async (t) => {
247
- const testDir = path.join(urlDirname(import.meta.url), '..', 'fixtures', 'typescript-plugin')
248
- const dest = path.join(urlDirname(import.meta.url), '..', 'tmp', `typescript-plugin-clone-${count++}`)
249
-
250
- await cp(testDir, dest, { recursive: true })
251
-
252
- const child = execa('node', [cliPath, 'start', '-c', path.join(dest, 'platformatic.service.json')])
253
-
254
- t.teardown(exitOnTeardown(child))
255
-
256
- const splitter = split()
257
- child.stdout.pipe(splitter)
258
- child.stderr.pipe(process.stderr)
259
-
260
- for await (const data of splitter) {
261
- const sanitized = stripAnsi(data)
262
- if (sanitized.includes('Typescript plugin loaded')) {
263
- t.pass()
264
- return
265
- }
266
- }
267
- t.fail('should compile typescript plugin with start command')
268
- })
269
-
270
- t.test('valid tsconfig file inside an inner folder', { skip: isWin }, async (t) => {
271
- const testDir = path.join(urlDirname(import.meta.url), '..', 'fixtures', 'typescript-plugin')
272
- const cwd = await getCWD(t)
273
-
274
- await cp(testDir, cwd, { recursive: true })
275
-
276
- try {
277
- await execa('node', [cliPath, 'compile'], { cwd, stdio: 'inherit' })
278
- } catch (err) {
279
- t.fail('should not catch any error')
280
- }
281
-
282
- t.pass()
283
- })
284
-
285
- t.test('should compile typescript plugin with start command from a folder', async (t) => {
286
- const testDir = path.join(urlDirname(import.meta.url), '..', 'fixtures', 'typescript-autoload')
287
- const cwd = await getCWD(t)
288
-
289
- await cp(testDir, cwd, { recursive: true })
290
-
291
- const child = execa('node', [cliPath, 'start'], { cwd })
292
-
293
- t.teardown(exitOnTeardown(child))
294
-
295
- const splitter = split()
296
- child.stdout.pipe(splitter)
297
-
298
- for await (const data of splitter) {
299
- const sanitized = stripAnsi(data)
300
- if (sanitized.includes('Typescript plugin loaded')) {
301
- t.pass()
302
- return
303
- }
304
- }
305
- t.fail('should compile typescript plugin with start command')
306
- })
307
-
308
- t.test('should start the service if it was precompiled and typescript is `false`', async (t) => {
309
- const testDir = path.join(urlDirname(import.meta.url), '..', 'fixtures', 'typescript-plugin-nocompile')
310
- const cwd = await getCWD(t)
311
-
312
- await cp(testDir, cwd, { recursive: true })
313
-
314
- await execa('node', [cliPath, 'compile'], { cwd })
315
-
316
- const child = execa('node', [cliPath, 'start'], { cwd })
317
-
318
- const splitter = split()
319
- child.stdout.pipe(splitter)
320
-
321
- for await (const data of splitter) {
322
- const sanitized = stripAnsi(data)
323
- if (sanitized.includes('Typescript plugin loaded')) {
324
- t.pass()
325
- return
326
- }
327
- }
328
- t.fail('should load the typescript plugin without compiling it')
329
- })
330
-
331
- t.test('should not start the service if it was not precompiled and typescript is `false`', async (t) => {
332
- const testDir = path.join(urlDirname(import.meta.url), '..', 'fixtures', 'typescript-plugin-nocompile')
333
- const cwd = await getCWD(t)
334
-
335
- await cp(testDir, cwd, { recursive: true })
336
-
337
- const child = execa('node', [cliPath, 'start'], { cwd })
338
-
339
- const splitter = split()
340
- child.stdout.pipe(splitter)
341
- child.stderr.pipe(splitter)
342
-
343
- for await (const data of splitter) {
344
- const sanitized = stripAnsi(data)
345
- if (sanitized.includes('Unknown file extension ".ts" for')) {
346
- t.pass()
347
- return
348
- }
349
- }
350
- t.fail('should load the typescript plugin without compiling it')
351
- })
352
-
353
- t.test('should compile typescript plugin with string config', async (t) => {
354
- const testDir = path.join(urlDirname(import.meta.url), '..', 'fixtures', 'typescript-plugin-string')
355
- const cwd = await getCWD(t)
356
-
357
- await cp(testDir, cwd, { recursive: true })
358
-
359
- const child = execa('node', [cliPath, 'compile'], { cwd })
360
-
361
- t.teardown(exitOnTeardown(child))
362
-
363
- const splitter = split()
364
- child.stdout.pipe(splitter)
365
-
366
- for await (const data of splitter) {
367
- const sanitized = stripAnsi(data)
368
- if (sanitized.includes('Typescript compilation completed successfully.')) {
369
- const jsPluginPath = path.join(cwd, 'dist', 'plugin.js')
370
- try {
371
- await access(jsPluginPath)
372
- } catch (err) {
373
- t.fail(err)
374
- }
375
-
376
- t.pass()
377
- return
378
- }
379
- }
380
- t.fail('should compile typescript plugin with a compile command')
381
- })
382
-
383
- t.test('should not start the service if it was not precompiled and typescript is `"false"`', async (t) => {
384
- const testDir = path.join(urlDirname(import.meta.url), '..', 'fixtures', 'typescript-plugin-nocompile')
385
- const cwd = await getCWD(t)
386
-
387
- await cp(testDir, cwd, { recursive: true })
388
-
389
- const child = execa('node', [cliPath, 'start'], { cwd })
390
-
391
- const splitter = split()
392
- child.stdout.pipe(splitter)
393
- child.stderr.pipe(splitter)
394
-
395
- for await (const data of splitter) {
396
- const sanitized = stripAnsi(data)
397
- if (sanitized.includes('Unknown file extension ".ts" for')) {
398
- t.pass()
399
- return
400
- }
401
- }
402
- t.fail('should load the typescript plugin without compiling it')
403
- })
404
-
405
225
  t.test('should not compile bad typescript plugin', async (t) => {
406
226
  const testDir = path.join(urlDirname(import.meta.url), '..', 'fixtures', 'bad-typescript-plugin')
407
227
  const cwd = await getCWD(t)