@platformatic/vite 2.0.0-alpha.6 → 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
@@ -161,4 +161,11 @@ export interface PlatformaticViteStackable {
161
161
  }
162
162
  | boolean;
163
163
  };
164
+ deploy?: {
165
+ include?: string[];
166
+ buildCommand?: string;
167
+ installCommand?: string;
168
+ startCommand?: string;
169
+ [k: string]: unknown;
170
+ };
164
171
  }
package/index.js CHANGED
@@ -1,4 +1,12 @@
1
- import { BaseStackable, createServerListener, errors, getServerUrl, importFile } from '@platformatic/basic'
1
+ import {
2
+ BaseStackable,
3
+ transformConfig as basicTransformConfig,
4
+ createServerListener,
5
+ errors,
6
+ getServerUrl,
7
+ importFile,
8
+ schemaOptions
9
+ } from '@platformatic/basic'
2
10
  import { ConfigManager } from '@platformatic/config'
3
11
  import { NodeStackable } from '@platformatic/node'
4
12
  import { readFile } from 'node:fs/promises'
@@ -88,18 +96,23 @@ export class ViteStackable extends BaseStackable {
88
96
  }
89
97
 
90
98
  getMeta () {
91
- if (!this.#basePath) {
92
- this.#basePath = this.#app.config.base.replace(/(^\/)|(\/$)/g, '')
93
- }
99
+ const deploy = this.configManager.current.deploy
100
+ let composer
94
101
 
95
- return {
96
- composer: {
102
+ if (this.url) {
103
+ if (!this.#basePath) {
104
+ this.#basePath = this.#app.config.base.replace(/(^\/)|(\/$)/g, '')
105
+ }
106
+
107
+ composer = {
97
108
  tcp: true,
98
109
  url: this.url,
99
110
  prefix: this.#basePath,
100
111
  wantsAbsoluteUrls: true
101
112
  }
102
113
  }
114
+
115
+ return { deploy, composer }
103
116
  }
104
117
 
105
118
  _getVite () {
@@ -143,18 +156,23 @@ export class ViteSSRStackable extends NodeStackable {
143
156
  }
144
157
 
145
158
  getMeta () {
146
- if (!this.#basePath) {
147
- this.#basePath = this._getApplication().vite.devServer.config.base.replace(/(^\/)|(\/$)/g, '')
148
- }
159
+ const deploy = this.configManager.current.deploy
160
+ let composer
149
161
 
150
- return {
151
- composer: {
162
+ if (this.url) {
163
+ if (!this.#basePath) {
164
+ this.#basePath = this._getApplication().vite.devServer.config.base.replace(/(^\/)|(\/$)/g, '')
165
+ }
166
+
167
+ composer = {
152
168
  tcp: true,
153
169
  url: this.url,
154
170
  prefix: this.#basePath,
155
171
  wantsAbsoluteUrls: true
156
172
  }
157
173
  }
174
+
175
+ return { deploy, composer }
158
176
  }
159
177
  }
160
178
 
@@ -171,12 +189,14 @@ function transformConfig () {
171
189
  if (this.current.vite?.ssr === true) {
172
190
  this.current.vite.ssr = { entrypoint: 'server.js' }
173
191
  }
192
+
193
+ basicTransformConfig.call(this)
174
194
  }
175
195
 
176
196
  export async function buildStackable (opts) {
177
197
  const root = opts.context.directory
178
198
 
179
- const configManager = new ConfigManager({ schema, source: opts.config ?? {}, transformConfig })
199
+ const configManager = new ConfigManager({ schema, source: opts.config ?? {}, schemaOptions, transformConfig })
180
200
  await configManager.parseAndValidate()
181
201
 
182
202
  // When in SSR mode, we use @platformatic/node
@@ -190,6 +210,7 @@ export async function buildStackable (opts) {
190
210
  export default {
191
211
  configType: 'vite',
192
212
  configManagerConfig: {
213
+ schemaOptions,
193
214
  transformConfig
194
215
  },
195
216
  buildStackable,
package/lib/schema.js CHANGED
@@ -11,7 +11,7 @@ export const schema = {
11
11
  type: 'object',
12
12
  properties: {
13
13
  $schema: {
14
- type: 'string',
14
+ type: 'string'
15
15
  },
16
16
  server: utilsSchema.server,
17
17
  watch: schemaComponents.watch,
@@ -20,7 +20,7 @@ export const schema = {
20
20
  type: 'object',
21
21
  properties: {
22
22
  configFile: {
23
- oneOf: [{ type: 'string' }, { type: 'boolean' }],
23
+ oneOf: [{ type: 'string' }, { type: 'boolean' }]
24
24
  },
25
25
  ssr: {
26
26
  oneOf: [
@@ -28,16 +28,17 @@ export const schema = {
28
28
  type: 'object',
29
29
  properties: { entrypoint: { type: 'string' } },
30
30
  required: ['entrypoint'],
31
- additionalProperties: false,
31
+ additionalProperties: false
32
32
  },
33
- { type: 'boolean' },
34
- ],
35
- },
33
+ { type: 'boolean' }
34
+ ]
35
+ }
36
36
  },
37
- additionalProperties: false,
37
+ additionalProperties: false
38
38
  },
39
+ deploy: schemaComponents.deploy
39
40
  },
40
- additionalProperties: false,
41
+ additionalProperties: false
41
42
  }
42
43
 
43
44
  /* c8 ignore next 3 */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@platformatic/vite",
3
- "version": "2.0.0-alpha.6",
3
+ "version": "2.0.0-alpha.7",
4
4
  "description": "Platformatic Vite Stackable",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -16,10 +16,10 @@
16
16
  "homepage": "https://github.com/platformatic/platformatic#readme",
17
17
  "dependencies": {
18
18
  "semver": "^7.6.3",
19
- "@platformatic/basic": "2.0.0-alpha.6",
20
- "@platformatic/node": "2.0.0-alpha.6",
21
- "@platformatic/config": "2.0.0-alpha.6",
22
- "@platformatic/utils": "2.0.0-alpha.6"
19
+ "@platformatic/config": "2.0.0-alpha.7",
20
+ "@platformatic/node": "2.0.0-alpha.7",
21
+ "@platformatic/utils": "2.0.0-alpha.7",
22
+ "@platformatic/basic": "2.0.0-alpha.7"
23
23
  },
24
24
  "devDependencies": {
25
25
  "@fastify/vite": "^6.0.7",
@@ -33,8 +33,8 @@
33
33
  "typescript": "^5.5.4",
34
34
  "vite": "^5.4.0",
35
35
  "ws": "^8.18.0",
36
- "@platformatic/composer": "2.0.0-alpha.6",
37
- "@platformatic/service": "2.0.0-alpha.6"
36
+ "@platformatic/composer": "2.0.0-alpha.7",
37
+ "@platformatic/service": "2.0.0-alpha.7"
38
38
  },
39
39
  "scripts": {
40
40
  "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.6.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 Vite Stackable",
5
5
  "type": "object",
@@ -535,6 +535,33 @@
535
535
  }
536
536
  },
537
537
  "additionalProperties": false
538
+ },
539
+ "deploy": {
540
+ "type": "object",
541
+ "properties": {
542
+ "include": {
543
+ "type": "array",
544
+ "items": {
545
+ "type": "string"
546
+ },
547
+ "default": [
548
+ "dist"
549
+ ]
550
+ },
551
+ "buildCommand": {
552
+ "type": "string",
553
+ "default": "npm run build"
554
+ },
555
+ "installCommand": {
556
+ "type": "string",
557
+ "default": "npm ci --omit-dev"
558
+ },
559
+ "startCommand": {
560
+ "type": "string",
561
+ "default": "npm run start"
562
+ }
563
+ },
564
+ "default": {}
538
565
  }
539
566
  },
540
567
  "additionalProperties": false