@platformatic/basic
Advanced tools
Comparing version 2.0.0-alpha.15 to 2.0.0-alpha.16
13
index.js
@@ -10,4 +10,6 @@ import { existsSync } from 'node:fs' | ||
const importStackablePackageMarker = '__pltImportStackablePackage.js' | ||
function isImportFailedError (error, pkg) { | ||
if (error.code !== 'ERR_MODULE_NOT_FOUND') { | ||
if (error.code !== 'ERR_MODULE_NOT_FOUND' && error.code !== 'MODULE_NOT_FOUND') { | ||
return false | ||
@@ -17,3 +19,4 @@ } | ||
const match = error.message.match(/Cannot find package '(.+)' imported from (.+)/) | ||
return match?.[1] === pkg | ||
return match?.[1] === pkg || error.requireStack?.[0].endsWith(importStackablePackageMarker) | ||
} | ||
@@ -32,3 +35,3 @@ | ||
// Scope to the service | ||
const require = createRequire(resolve(opts.context.directory, 'index.js')) | ||
const require = createRequire(resolve(opts.context.directory, importStackablePackageMarker)) | ||
const imported = require.resolve(pkg) | ||
@@ -44,6 +47,6 @@ return await importFile(imported) | ||
let errorMessage = `Unable to import package, "${pkg}". Please add it as a dependency ` | ||
let errorMessage = `Unable to import package '${pkg}'. Please add it as a dependency ` | ||
if (rootFolder) { | ||
errorMessage += `in the package.json file in the folder ${rootFolder}.` | ||
errorMessage += `in the package.json file in the folder ${relative(rootFolder, opts.context.directory)}.` | ||
} else { | ||
@@ -50,0 +53,0 @@ errorMessage += 'in the root package.json file.' |
@@ -1,2 +0,2 @@ | ||
import deepmerge from '@fastify/deepmerge' | ||
import { deepmerge } from '@platformatic/utils' | ||
import { parseCommandString } from 'execa' | ||
@@ -14,4 +14,2 @@ import { spawn } from 'node:child_process' | ||
const merge = deepmerge() | ||
export class BaseStackable { | ||
@@ -29,3 +27,3 @@ #childManager | ||
this.configManager = configManager | ||
this.serverConfig = merge(options.context.serverConfig, configManager.current.server) | ||
this.serverConfig = deepmerge(options.context.serverConfig ?? {}, configManager.current.server ?? {}) | ||
this.openapiSchema = null | ||
@@ -62,2 +60,6 @@ this.getGraphqlSchema = null | ||
async getEnv () { | ||
return this.configManager.env | ||
} | ||
async getWatchConfig () { | ||
@@ -64,0 +66,0 @@ const config = this.configManager.current |
import { ITC, generateNotification } from '@platformatic/itc' | ||
import { createDirectory, errors } from '@platformatic/utils' | ||
import { createDirectory, ensureLoggableError } from '@platformatic/utils' | ||
import { once } from 'node:events' | ||
@@ -216,5 +216,5 @@ import { rm, writeFile } from 'node:fs/promises' | ||
#handleUnexpectedError (error, message, exitCode) { | ||
this.#logger.error({ err: errors.ensureLoggableError(error) }, message) | ||
this.#logger.error({ err: ensureLoggableError(error) }, message) | ||
process.exit(exitCode) | ||
} | ||
} |
import { ITC } from '@platformatic/itc' | ||
import { createPinoWritable, errors } from '@platformatic/utils' | ||
import { createPinoWritable, ensureLoggableError } from '@platformatic/utils' | ||
import { tracingChannel } from 'node:diagnostics_channel' | ||
@@ -118,3 +118,3 @@ import { once } from 'node:events' | ||
} catch (error) { | ||
this.#logger.error({ err: errors.ensureLoggableError(error) }, 'Handling a message failed.') | ||
this.#logger.error({ err: ensureLoggableError(error) }, 'Handling a message failed.') | ||
process.exit(exitCodes.PROCESS_MESSAGE_HANDLING_FAILED) | ||
@@ -162,3 +162,3 @@ } | ||
Reflect.defineProperty(process, 'stdout', { value: createPinoWritable(this.#logger, 'info') }) | ||
Reflect.defineProperty(process, 'stderr', { value: createPinoWritable(this.#logger, 'error') }) | ||
Reflect.defineProperty(process, 'stderr', { value: createPinoWritable(this.#logger, 'error', true) }) | ||
} else { | ||
@@ -201,5 +201,4 @@ this.#logger = pino({ level: 'info', name: globalThis.platformatic.id }) | ||
function handleUnhandled (type, err) { | ||
process._rawDebug(globalThis.platformatic.id, err) | ||
this.#logger.error( | ||
{ err: errors.ensureLoggableError(err) }, | ||
{ err: ensureLoggableError(err) }, | ||
`Child process for service ${globalThis.platformatic.id} threw an ${type}.` | ||
@@ -206,0 +205,0 @@ ) |
import { generateRequest } from '@platformatic/itc' | ||
import { errors } from '@platformatic/utils' | ||
import { ensureLoggableError } from '@platformatic/utils' | ||
import { once } from 'node:events' | ||
@@ -12,3 +12,3 @@ import { platform } from 'node:os' | ||
process._rawDebug(`Logger thread for child process of service ${workerData.id} ${message}.`, { | ||
error: errors.ensureLoggableError(error) | ||
error: ensureLoggableError(error) | ||
}) | ||
@@ -15,0 +15,0 @@ } |
{ | ||
"name": "@platformatic/basic", | ||
"version": "2.0.0-alpha.15", | ||
"version": "2.0.0-alpha.16", | ||
"description": "", | ||
@@ -19,3 +19,2 @@ "main": "index.js", | ||
"@fastify/error": "^4.0.0", | ||
"@fastify/deepmerge": "^2.0.0", | ||
"execa": "^9.3.1", | ||
@@ -28,5 +27,5 @@ "pino": "^9.3.2", | ||
"ws": "^8.18.0", | ||
"@platformatic/config": "2.0.0-alpha.15", | ||
"@platformatic/itc": "2.0.0-alpha.15", | ||
"@platformatic/utils": "2.0.0-alpha.15" | ||
"@platformatic/config": "2.0.0-alpha.16", | ||
"@platformatic/itc": "2.0.0-alpha.16", | ||
"@platformatic/utils": "2.0.0-alpha.16" | ||
}, | ||
@@ -45,4 +44,4 @@ "devDependencies": { | ||
"vite": "^5.4.0", | ||
"@platformatic/composer": "2.0.0-alpha.15", | ||
"@platformatic/service": "2.0.0-alpha.15" | ||
"@platformatic/composer": "2.0.0-alpha.16", | ||
"@platformatic/service": "2.0.0-alpha.16" | ||
}, | ||
@@ -49,0 +48,0 @@ "scripts": { |
{ | ||
"$id": "https://schemas.platformatic.dev/@platformatic/basic/2.0.0-alpha.15.json", | ||
"$id": "https://schemas.platformatic.dev/@platformatic/basic/2.0.0-alpha.16.json", | ||
"$schema": "http://json-schema.org/draft-07/schema#", | ||
@@ -4,0 +4,0 @@ "title": "Platformatic Stackable", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
44716
11
956
+ Added@platformatic/config@2.0.0-alpha.16(transitive)
+ Added@platformatic/itc@2.0.0-alpha.16(transitive)
+ Added@platformatic/utils@2.0.0-alpha.16(transitive)
- Removed@fastify/deepmerge@^2.0.0
- Removed@platformatic/config@2.0.0-alpha.15(transitive)
- Removed@platformatic/itc@2.0.0-alpha.15(transitive)
- Removed@platformatic/utils@2.0.0-alpha.15(transitive)