@platformatic/generators 2.72.0 → 3.0.0-alpha.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/lib/base-generator.js +4 -2
- package/lib/create-plugin.js +0 -4
- package/lib/import-generator.js +15 -18
- package/package.json +2 -4
package/lib/base-generator.js
CHANGED
|
@@ -28,6 +28,8 @@ const fakeLogger = {
|
|
|
28
28
|
}
|
|
29
29
|
/* c8 ignore start */
|
|
30
30
|
|
|
31
|
+
const DEFAULT_SERVICES_PATH = 'services'
|
|
32
|
+
|
|
31
33
|
class BaseGenerator extends FileGenerator {
|
|
32
34
|
constructor (opts = {}) {
|
|
33
35
|
super(opts)
|
|
@@ -403,7 +405,7 @@ class BaseGenerator extends FileGenerator {
|
|
|
403
405
|
...this.config.dependencies
|
|
404
406
|
},
|
|
405
407
|
engines: {
|
|
406
|
-
node: '
|
|
408
|
+
node: '>=22.16.0'
|
|
407
409
|
}
|
|
408
410
|
}
|
|
409
411
|
|
|
@@ -470,7 +472,7 @@ class BaseGenerator extends FileGenerator {
|
|
|
470
472
|
|
|
471
473
|
async loadFromDir (serviceName, runtimeRootPath) {
|
|
472
474
|
const runtimePkgConfigFileData = JSON.parse(await readFile(join(runtimeRootPath, this.runtimeConfig), 'utf-8'))
|
|
473
|
-
const servicesPath = runtimePkgConfigFileData.autoload
|
|
475
|
+
const servicesPath = runtimePkgConfigFileData.autoload?.path ?? DEFAULT_SERVICES_PATH
|
|
474
476
|
const servicePkgJsonFileData = JSON.parse(
|
|
475
477
|
await readFile(join(runtimeRootPath, servicesPath, serviceName, 'platformatic.json'), 'utf-8')
|
|
476
478
|
)
|
package/lib/create-plugin.js
CHANGED
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
const { join } = require('path')
|
|
4
4
|
|
|
5
5
|
const JS_PLUGIN_WITH_TYPES_SUPPORT = `\
|
|
6
|
-
/// <reference path="../global.d.ts" />
|
|
7
6
|
'use strict'
|
|
8
7
|
/** @param {import('fastify').FastifyInstance} fastify */
|
|
9
8
|
module.exports = async function (fastify, opts) {
|
|
@@ -12,7 +11,6 @@ module.exports = async function (fastify, opts) {
|
|
|
12
11
|
`
|
|
13
12
|
|
|
14
13
|
const TS_PLUGIN_WITH_TYPES_SUPPORT = `\
|
|
15
|
-
/// <reference path="../global.d.ts" />
|
|
16
14
|
import { FastifyInstance, FastifyPluginOptions } from 'fastify'
|
|
17
15
|
|
|
18
16
|
export default async function (fastify: FastifyInstance, opts: FastifyPluginOptions) {
|
|
@@ -21,7 +19,6 @@ export default async function (fastify: FastifyInstance, opts: FastifyPluginOpti
|
|
|
21
19
|
`
|
|
22
20
|
|
|
23
21
|
const JS_ROUTES_WITH_TYPES_SUPPORT = `\
|
|
24
|
-
/// <reference path="../global.d.ts" />
|
|
25
22
|
'use strict'
|
|
26
23
|
/** @param {import('fastify').FastifyInstance} fastify */
|
|
27
24
|
module.exports = async function (fastify, opts) {
|
|
@@ -32,7 +29,6 @@ module.exports = async function (fastify, opts) {
|
|
|
32
29
|
`
|
|
33
30
|
|
|
34
31
|
const TS_ROUTES_WITH_TYPES_SUPPORT = `\
|
|
35
|
-
/// <reference path="../global.d.ts" />
|
|
36
32
|
import { FastifyInstance, FastifyPluginOptions } from 'fastify'
|
|
37
33
|
|
|
38
34
|
declare module 'fastify' {
|
package/lib/import-generator.js
CHANGED
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
-
const {
|
|
4
|
-
const { safeRemove } = require('@platformatic/utils')
|
|
5
|
-
const { glob } = require('glob')
|
|
3
|
+
const { safeRemove, findConfigurationFileRecursive } = require('@platformatic/utils')
|
|
6
4
|
const { BaseGenerator } = require('./base-generator')
|
|
7
5
|
const { spawnSync } = require('node:child_process')
|
|
8
|
-
const { stat, readFile } = require('node:fs/promises')
|
|
9
|
-
const { join, dirname } = require('node:path')
|
|
6
|
+
const { stat, readFile, readdir } = require('node:fs/promises')
|
|
7
|
+
const { join, dirname, resolve, relative } = require('node:path')
|
|
10
8
|
|
|
11
9
|
class ImportGenerator extends BaseGenerator {
|
|
12
10
|
constructor (options = {}) {
|
|
@@ -120,7 +118,7 @@ class ImportGenerator extends BaseGenerator {
|
|
|
120
118
|
async #generateConfigFile (originalPath, updatedPath) {
|
|
121
119
|
// Determine if there is a watt.json file in the application path - If it's missing, insert one
|
|
122
120
|
// For import it means we don't update the file, for copy it means it was already copied in #copy.
|
|
123
|
-
const existingConfig = await
|
|
121
|
+
const existingConfig = await findConfigurationFileRecursive(originalPath)
|
|
124
122
|
|
|
125
123
|
if (existingConfig) {
|
|
126
124
|
return
|
|
@@ -203,30 +201,29 @@ class ImportGenerator extends BaseGenerator {
|
|
|
203
201
|
}
|
|
204
202
|
|
|
205
203
|
async #copy (root) {
|
|
206
|
-
const files = await
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
})
|
|
204
|
+
const files = await readdir(root, { withFileTypes: true, recursive: true })
|
|
205
|
+
|
|
206
|
+
for await (const file of files) {
|
|
207
|
+
const absolutePath = resolve(file.parentPath, file.name)
|
|
208
|
+
let path = relative(root, dirname(absolutePath))
|
|
212
209
|
|
|
213
|
-
|
|
214
|
-
|
|
210
|
+
if (
|
|
211
|
+
file.isDirectory() ||
|
|
212
|
+
['package-lock.json', 'pnpm-lock.yaml', 'yarn.lock'].includes(file.name) ||
|
|
213
|
+
path.includes('node_modules')
|
|
214
|
+
) {
|
|
215
215
|
continue
|
|
216
216
|
}
|
|
217
217
|
|
|
218
218
|
/* c8 ignore next 6 */
|
|
219
|
-
let path = dirname(file.relative())
|
|
220
219
|
if (path === '.') {
|
|
221
220
|
path = ''
|
|
222
|
-
} else if (path.startsWith('./')) {
|
|
223
|
-
path = path.substring(2)
|
|
224
221
|
}
|
|
225
222
|
|
|
226
223
|
this.addFile({
|
|
227
224
|
path,
|
|
228
225
|
file: file.name,
|
|
229
|
-
contents: await readFile(file.
|
|
226
|
+
contents: await readFile(resolve(file.parentPath, file.name))
|
|
230
227
|
})
|
|
231
228
|
}
|
|
232
229
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@platformatic/generators",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0-alpha.1",
|
|
4
4
|
"description": "Main classes and utils for generators.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"keywords": [],
|
|
@@ -11,11 +11,9 @@
|
|
|
11
11
|
"change-case-all": "^2.1.0",
|
|
12
12
|
"execa": "^9.6.0",
|
|
13
13
|
"fastify": "^5.0.0",
|
|
14
|
-
"glob": "^11.0.2",
|
|
15
14
|
"pino": "^9.0.0",
|
|
16
15
|
"undici": "^7.0.0",
|
|
17
|
-
"@platformatic/
|
|
18
|
-
"@platformatic/utils": "2.72.0"
|
|
16
|
+
"@platformatic/utils": "3.0.0-alpha.1"
|
|
19
17
|
},
|
|
20
18
|
"devDependencies": {
|
|
21
19
|
"@types/inquirer": "^9.0.7",
|