@platformatic/basic
Advanced tools
Comparing version 2.0.0-alpha.5 to 2.0.0-alpha.6
39
index.js
@@ -6,2 +6,3 @@ import { existsSync } from 'node:fs' | ||
import { workerData } from 'node:worker_threads' | ||
import pino from 'pino' | ||
import { packageJson, schema } from './lib/schema.js' | ||
@@ -32,11 +33,2 @@ import { importFile } from './lib/utils.js' | ||
if (!opts.config) { | ||
const serviceRoot = relative(process.cwd(), opts.context.directory) | ||
errorMessage += [ | ||
'', // Do not remove this | ||
`Platformatic has auto-detected that service ${opts.context.serviceId} ${autodetectDescription}.`, | ||
`We suggest you create a platformatic.application.json file in the folder ${serviceRoot} with the "$schema" property set to "https://schemas.platformatic.dev/${pkg}/${packageJson.version}.json".`, | ||
].join('\n') | ||
} | ||
throw new Error(errorMessage) | ||
@@ -58,3 +50,5 @@ } | ||
if (!opts.config) { | ||
const hadConfig = opts.config | ||
if (!hadConfig) { | ||
const candidate = resolve(root, 'platformatic.application.json') | ||
@@ -72,8 +66,31 @@ | ||
toImport = '@platformatic/next' | ||
} else if (dependencies?.['@remix-run/dev'] || devDependencies?.['@remix-run/dev']) { | ||
autodetectDescription = 'is using Remix' | ||
toImport = '@platformatic/remix' | ||
} else if (dependencies?.vite || devDependencies?.vite) { | ||
autodetectDescription = 'is using Vite' | ||
toImport = '@platformatic/vite' | ||
} else if (dependencies?.astro || devDependencies?.astro) { | ||
autodetectDescription = 'is using Astro' | ||
toImport = '@platformatic/astro' | ||
} | ||
const imported = await importStackablePackage(opts, toImport, autodetectDescription) | ||
if (!hadConfig) { | ||
const serviceRoot = relative(process.cwd(), opts.context.directory) | ||
const logger = pino({ | ||
level: opts.context.serverConfig?.logger?.level ?? 'warn', | ||
name: opts.context.serviceId | ||
}) | ||
logger.warn( | ||
[ | ||
`Platformatic has auto-detected that service ${opts.context.serviceId} ${autodetectDescription}.\n`, | ||
`We suggest you create a platformatic.application.json file in the folder ${serviceRoot} with the "$schema" `, | ||
`property set to "https://schemas.platformatic.dev/${toImport}/${packageJson.version}.json".` | ||
].join('') | ||
) | ||
} | ||
return imported.buildStackable(opts) | ||
@@ -87,3 +104,3 @@ } | ||
schema, | ||
version: packageJson.version, | ||
version: packageJson.version | ||
} | ||
@@ -90,0 +107,0 @@ |
@@ -16,3 +16,3 @@ import pino from 'pino' | ||
const pinoOptions = { | ||
level: (this.configManager.current.server ?? this.serverConfig)?.logger?.level ?? 'trace', | ||
level: (this.configManager.current.server ?? this.serverConfig)?.logger?.level ?? 'trace' | ||
} | ||
@@ -26,6 +26,6 @@ | ||
// Setup globals | ||
globalThis.platformatic = { | ||
this.registerGlobals({ | ||
setOpenapiSchema: this.setOpenapiSchema.bind(this), | ||
setGraphqlSchema: this.setGraphqlSchema.bind(this), | ||
} | ||
setGraphqlSchema: this.setGraphqlSchema.bind(this) | ||
}) | ||
} | ||
@@ -50,3 +50,3 @@ | ||
allow: config.watch?.allow, | ||
ignore: config.watch?.ignore, | ||
ignore: config.watch?.ignore | ||
} | ||
@@ -87,2 +87,6 @@ } | ||
} | ||
registerGlobals (globals) { | ||
globalThis.platformatic = Object.assign(globalThis.platformatic ?? {}, globals) | ||
} | ||
} |
@@ -16,3 +16,12 @@ import { ITC } from '@platformatic/itc' | ||
constructor ({ loader, context }) { | ||
super({}) | ||
super({ | ||
handlers: { | ||
log (message) { | ||
workerData.loggingPort.postMessage(JSON.parse(message)) | ||
}, | ||
fetch: request => { | ||
return this.#fetch(request) | ||
} | ||
} | ||
}) | ||
@@ -32,8 +41,2 @@ const childHandler = ({ process: child }) => { | ||
this.handle('log', message => { | ||
workerData.loggingPort.postMessage(JSON.parse(message)) | ||
}) | ||
this.handle('fetch', this.#fetch.bind(this)) | ||
this.#prepareChildEnvironment(loader, context) | ||
@@ -80,3 +83,3 @@ } | ||
`--import=${childProcessWorkerFile}`, | ||
process.env.NODE_OPTIONS ?? '', | ||
process.env.NODE_OPTIONS ?? '' | ||
].join(' ') | ||
@@ -83,0 +86,0 @@ } |
{ | ||
"name": "@platformatic/basic", | ||
"version": "2.0.0-alpha.5", | ||
"version": "2.0.0-alpha.6", | ||
"description": "", | ||
@@ -22,5 +22,5 @@ "main": "index.js", | ||
"undici": "^6.19.5", | ||
"@platformatic/config": "2.0.0-alpha.5", | ||
"@platformatic/utils": "2.0.0-alpha.5", | ||
"@platformatic/itc": "2.0.0-alpha.5" | ||
"@platformatic/config": "2.0.0-alpha.6", | ||
"@platformatic/itc": "2.0.0-alpha.6", | ||
"@platformatic/utils": "2.0.0-alpha.6" | ||
}, | ||
@@ -40,4 +40,4 @@ "devDependencies": { | ||
"ws": "^8.18.0", | ||
"@platformatic/composer": "2.0.0-alpha.5", | ||
"@platformatic/service": "2.0.0-alpha.5" | ||
"@platformatic/composer": "2.0.0-alpha.6", | ||
"@platformatic/service": "2.0.0-alpha.6" | ||
}, | ||
@@ -44,0 +44,0 @@ "scripts": { |
{ | ||
"$id": "https://schemas.platformatic.dev/@platformatic/basic/2.0.0-alpha.5.json", | ||
"$id": "https://schemas.platformatic.dev/@platformatic/basic/2.0.0-alpha.6.json", | ||
"$schema": "http://json-schema.org/draft-07/schema#", | ||
@@ -4,0 +4,0 @@ "title": "Platformatic Stackable", |
@@ -14,2 +14,3 @@ import { createDirectory, withResolvers } from '@platformatic/utils' | ||
const HMR_TIMEOUT = process.env.CI ? 20000 : 10000 | ||
let hrmVersion = Date.now() | ||
@@ -63,3 +64,3 @@ export let fixturesDir | ||
hostname: 'localhost', | ||
protocol: 'http:', | ||
protocol: 'http:' | ||
}, | ||
@@ -69,3 +70,3 @@ { | ||
keepAliveTimeout: 10, | ||
keepAliveMaxTimeout: 10, | ||
keepAliveMaxTimeout: 10 | ||
} | ||
@@ -79,3 +80,3 @@ ) | ||
method: 'GET', | ||
path: '/api/v1/logs/all', | ||
path: '/api/v1/logs/all' | ||
}) | ||
@@ -120,3 +121,3 @@ | ||
for (const content of contents) { | ||
ok(content instanceof RegExp ? content.test(html) : html.includes(content)) | ||
ok(content instanceof RegExp ? content.test(html) : html.includes(content), content) | ||
} | ||
@@ -132,3 +133,3 @@ } | ||
for (const content of contents) { | ||
ok(content instanceof RegExp ? content.test(html) : html.includes(content)) | ||
ok(content instanceof RegExp ? content.test(html) : html.includes(content), content) | ||
} | ||
@@ -141,3 +142,3 @@ } | ||
const ac = new AbortController() | ||
const timeout = sleep(10000, 'timeout', { signal: ac.signal }) | ||
const timeout = sleep(HMR_TIMEOUT, 'timeout', { signal: ac.signal }) | ||
@@ -144,0 +145,0 @@ const url = baseUrl.replace('http:', 'ws:') + path |
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
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
33749
619
0
6
+ Added@platformatic/config@2.0.0-alpha.6(transitive)
+ Added@platformatic/itc@2.0.0-alpha.6(transitive)
+ Added@platformatic/utils@2.0.0-alpha.6(transitive)
+ Added@watchable/unpromise@1.0.2(transitive)
- Removed@platformatic/config@2.0.0-alpha.5(transitive)
- Removed@platformatic/itc@2.0.0-alpha.5(transitive)
- Removed@platformatic/utils@2.0.0-alpha.5(transitive)