@platformatic/node 2.0.0-alpha.5 → 2.0.0-alpha.7

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/config.d.ts CHANGED
@@ -150,4 +150,11 @@ export interface PlatformaticNodeJsStackable {
150
150
  }
151
151
  | boolean
152
152
  | string;
153
+ deploy?: {
154
+ include?: string[];
155
+ buildCommand?: string;
156
+ installCommand?: string;
157
+ startCommand?: string;
158
+ [k: string]: unknown;
159
+ };
153
160
  }
package/index.js CHANGED
@@ -1,4 +1,12 @@
1
- import { BaseStackable, createServerListener, getServerUrl, importFile, injectViaRequest } from '@platformatic/basic'
1
+ import {
2
+ BaseStackable,
3
+ createServerListener,
4
+ getServerUrl,
5
+ importFile,
6
+ injectViaRequest,
7
+ schemaOptions,
8
+ transformConfig
9
+ } from '@platformatic/basic'
2
10
  import { ConfigManager } from '@platformatic/config'
3
11
  import inject from 'light-my-request'
4
12
  import { existsSync } from 'node:fs'
@@ -18,7 +26,7 @@ const validFields = [
18
26
  'exports#.#node',
19
27
  'exports#.#import',
20
28
  'exports#.#require',
21
- 'exports#.#default',
29
+ 'exports#.#default'
22
30
  ]
23
31
 
24
32
  const validFilesBasenames = ['index', 'main', 'app', 'application', 'server', 'start', 'bundle', 'run', 'entrypoint']
@@ -136,6 +144,12 @@ export class NodeStackable extends BaseStackable {
136
144
  return { statusCode, headers, body, payload, rawPayload }
137
145
  }
138
146
 
147
+ getMeta () {
148
+ return {
149
+ deploy: this.configManager.current.deploy
150
+ }
151
+ }
152
+
139
153
  async _listen () {
140
154
  const serverOptions = this.serverConfig
141
155
 
@@ -215,7 +229,7 @@ export async function buildStackable (opts) {
215
229
 
216
230
  const { entrypoint, hadEntrypointField } = await getEntrypointInformation(root)
217
231
 
218
- const configManager = new ConfigManager({ schema, source: opts.config ?? {} })
232
+ const configManager = new ConfigManager({ schema, source: opts.config ?? {}, schemaOptions, transformConfig })
219
233
  await configManager.parseAndValidate()
220
234
 
221
235
  return new NodeStackable(opts, root, configManager, entrypoint, hadEntrypointField)
@@ -223,8 +237,11 @@ export async function buildStackable (opts) {
223
237
 
224
238
  export default {
225
239
  configType: 'nodejs',
226
- configManagerConfig: {},
240
+ configManagerConfig: {
241
+ schemaOptions,
242
+ transformConfig
243
+ },
227
244
  buildStackable,
228
245
  schema,
229
- version: packageJson.version,
246
+ version: packageJson.version
230
247
  }
package/lib/schema.js CHANGED
@@ -15,6 +15,7 @@ export const schema = {
15
15
  },
16
16
  server: utilsSchema.server,
17
17
  watch: schemaComponents.watch,
18
+ deploy: schemaComponents.deploy
18
19
  },
19
20
  additionalProperties: false,
20
21
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@platformatic/node",
3
- "version": "2.0.0-alpha.5",
3
+ "version": "2.0.0-alpha.7",
4
4
  "description": "Platformatic Node.js Stackable",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -16,20 +16,20 @@
16
16
  "homepage": "https://github.com/platformatic/platformatic#readme",
17
17
  "dependencies": {
18
18
  "light-my-request": "^5.13.0",
19
- "@platformatic/basic": "2.0.0-alpha.5",
20
- "@platformatic/config": "2.0.0-alpha.5",
21
- "@platformatic/utils": "2.0.0-alpha.5"
19
+ "@platformatic/basic": "2.0.0-alpha.7",
20
+ "@platformatic/utils": "2.0.0-alpha.7",
21
+ "@platformatic/config": "2.0.0-alpha.7"
22
22
  },
23
23
  "devDependencies": {
24
24
  "borp": "^0.17.0",
25
25
  "express": "^4.19.2",
26
26
  "eslint": "9",
27
27
  "fastify": "^4.28.1",
28
+ "json-schema-to-typescript": "^15.0.1",
28
29
  "neostandard": "^0.11.1",
29
- "json-schema-to-typescript": "^15.0.0",
30
30
  "typescript": "^5.5.4",
31
- "@platformatic/composer": "2.0.0-alpha.5",
32
- "@platformatic/service": "2.0.0-alpha.5"
31
+ "@platformatic/composer": "2.0.0-alpha.7",
32
+ "@platformatic/service": "2.0.0-alpha.7"
33
33
  },
34
34
  "scripts": {
35
35
  "test": "npm run lint && borp --concurrency=1 --timeout=180000",
package/schema.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "$id": "https://schemas.platformatic.dev/@platformatic/vite/2.0.0-alpha.5.json",
2
+ "$id": "https://schemas.platformatic.dev/@platformatic/vite/2.0.0-alpha.7.json",
3
3
  "$schema": "http://json-schema.org/draft-07/schema#",
4
4
  "title": "Platformatic Node.js Stackable",
5
5
  "type": "object",
@@ -491,6 +491,33 @@
491
491
  "type": "string"
492
492
  }
493
493
  ]
494
+ },
495
+ "deploy": {
496
+ "type": "object",
497
+ "properties": {
498
+ "include": {
499
+ "type": "array",
500
+ "items": {
501
+ "type": "string"
502
+ },
503
+ "default": [
504
+ "dist"
505
+ ]
506
+ },
507
+ "buildCommand": {
508
+ "type": "string",
509
+ "default": "npm run build"
510
+ },
511
+ "installCommand": {
512
+ "type": "string",
513
+ "default": "npm ci --omit-dev"
514
+ },
515
+ "startCommand": {
516
+ "type": "string",
517
+ "default": "npm run start"
518
+ }
519
+ },
520
+ "default": {}
494
521
  }
495
522
  },
496
523
  "additionalProperties": false
package/test/node.test.js CHANGED
@@ -1,4 +1,4 @@
1
- import { deepStrictEqual, ifError } from 'node:assert'
1
+ import { deepStrictEqual, ifError, ok } from 'node:assert'
2
2
  import { resolve } from 'node:path'
3
3
  import { test } from 'node:test'
4
4
  import {
@@ -6,7 +6,7 @@ import {
6
6
  getLogs,
7
7
  setFixturesDir,
8
8
  verifyJSONViaHTTP,
9
- verifyJSONViaInject,
9
+ verifyJSONViaInject
10
10
  } from '../../basic/test/helper.js'
11
11
 
12
12
  const packageRoot = resolve(import.meta.dirname, '..')
@@ -22,11 +22,11 @@ test('can detect and start a Node.js application with no configuration files', a
22
22
  await verifyJSONViaHTTP(url, '/direct', 200, { ok: true })
23
23
  await verifyJSONViaInject(runtime, 'main', 'GET', '/direct', 200, { ok: true })
24
24
 
25
+ const missingConfigurationMessage =
26
+ 'The service main had no valid entrypoint defined in the package.json file. Falling back to the file index.js.'
27
+
25
28
  const logs = await getLogs(runtime)
26
- deepStrictEqual(
27
- logs.map(m => m.msg),
28
- ['The service main had no valid entrypoint defined in the package.json file. Falling back to the file index.js.']
29
- )
29
+ ok(logs.map(m => m.msg).includes(missingConfigurationMessage))
30
30
  })
31
31
 
32
32
  test('can detect and start a Node.js application with no configuration files and when not the entrypoint', async t => {
@@ -39,14 +39,11 @@ test('can detect and start a Node.js application with no configuration files and
39
39
  await verifyJSONViaHTTP(url, '/mesh', 200, { ok: true })
40
40
  await verifyJSONViaInject(runtime, 'main', 'GET', '/mesh', 200, { ok: true })
41
41
 
42
- const logs = await getLogs(runtime)
42
+ const missingConfigurationMessage =
43
+ 'The service internal had no valid entrypoint defined in the package.json file. Falling back to the file index.js.'
43
44
 
44
- deepStrictEqual(
45
- logs.map(m => m.msg),
46
- [
47
- 'The service internal had no valid entrypoint defined in the package.json file. Falling back to the file index.js.',
48
- ]
49
- )
45
+ const logs = await getLogs(runtime)
46
+ ok(logs.map(m => m.msg).includes(missingConfigurationMessage))
50
47
  })
51
48
 
52
49
  test('can detect and start a Node.js application with no build function defined', async t => {