wattpm 2.5.2 → 2.5.4
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/commands/external.js +19 -5
- package/lib/utils.js +18 -4
- package/package.json +6 -6
- package/schema.json +1 -1
package/lib/commands/external.js
CHANGED
|
@@ -6,7 +6,7 @@ import { bold } from 'colorette'
|
|
|
6
6
|
import { execa } from 'execa'
|
|
7
7
|
import { existsSync } from 'node:fs'
|
|
8
8
|
import { readdir, readFile, writeFile } from 'node:fs/promises'
|
|
9
|
-
import { basename, isAbsolute, join, relative, resolve, sep } from 'node:path'
|
|
9
|
+
import { basename, isAbsolute, join, relative, resolve, sep, dirname } from 'node:path'
|
|
10
10
|
import { defaultServiceJson } from '../defaults.js'
|
|
11
11
|
import { version } from '../schema.js'
|
|
12
12
|
import { checkEmptyDirectory, findConfigurationFile, overrideFatal, parseArgs } from '../utils.js'
|
|
@@ -89,6 +89,17 @@ async function findExistingConfiguration (root, path) {
|
|
|
89
89
|
|
|
90
90
|
async function addService (configurationFile, id, path, url) {
|
|
91
91
|
const config = JSON.parse(await readFile(configurationFile, 'utf-8'))
|
|
92
|
+
const root = dirname(configurationFile)
|
|
93
|
+
|
|
94
|
+
let autoloadPath = config.autoload?.path
|
|
95
|
+
|
|
96
|
+
if (autoloadPath) {
|
|
97
|
+
autoloadPath = join(root, autoloadPath)
|
|
98
|
+
if (path.startsWith(autoloadPath)) {
|
|
99
|
+
return
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
92
103
|
/* c8 ignore next */
|
|
93
104
|
config.web ??= []
|
|
94
105
|
config.web.push({ id, path, url })
|
|
@@ -133,7 +144,7 @@ async function fixConfiguration (logger, root) {
|
|
|
133
144
|
$schema: `https://schemas.platformatic.dev/${stackable}/${version}.json`
|
|
134
145
|
}
|
|
135
146
|
|
|
136
|
-
logger.
|
|
147
|
+
logger.info(`Detected stackable ${bold(stackable)} for service ${bold(id)}, adding to the service dependencies.`)
|
|
137
148
|
await writeFile(resolve(root, service, 'package.json'), JSON.stringify(packageJson, null, 2), 'utf-8')
|
|
138
149
|
await writeFile(resolve(root, service, 'watt.json'), JSON.stringify(wattJson, null, 2), 'utf-8')
|
|
139
150
|
}
|
|
@@ -162,7 +173,7 @@ async function importLocal (logger, root, configurationFile, path) {
|
|
|
162
173
|
/* c8 ignore next */
|
|
163
174
|
const displayPath = isAbsolute(path) ? path : relative(root, path)
|
|
164
175
|
|
|
165
|
-
logger.
|
|
176
|
+
logger.info(
|
|
166
177
|
`Path ${bold(resolve(displayPath, wattConfiguration))} already exists. Skipping configuration management ...`
|
|
167
178
|
)
|
|
168
179
|
return
|
|
@@ -176,7 +187,7 @@ async function importLocal (logger, root, configurationFile, path) {
|
|
|
176
187
|
$schema: `https://schemas.platformatic.dev/${stackable}/${version}.json`
|
|
177
188
|
}
|
|
178
189
|
|
|
179
|
-
logger.
|
|
190
|
+
logger.info(`Detected stackable ${bold(stackable)} for service ${bold(id)}, adding to the service dependencies.`)
|
|
180
191
|
await writeFile(resolve(path, 'package.json'), JSON.stringify(packageJson, null, 2), 'utf-8')
|
|
181
192
|
await writeFile(resolve(path, 'watt.json'), JSON.stringify(wattJson, null, 2), 'utf-8')
|
|
182
193
|
}
|
|
@@ -231,6 +242,7 @@ export async function importCommand (logger, args) {
|
|
|
231
242
|
root = positionals[0]
|
|
232
243
|
rawUrl = positionals[1]
|
|
233
244
|
}
|
|
245
|
+
|
|
234
246
|
/* c8 ignore next */
|
|
235
247
|
root = resolve(process.cwd(), root)
|
|
236
248
|
|
|
@@ -238,7 +250,9 @@ export async function importCommand (logger, args) {
|
|
|
238
250
|
|
|
239
251
|
// If the rawUrl exists as local folder, import a local folder, otherwise go for Git.
|
|
240
252
|
// Try a relative from the root folder or from process.cwd().
|
|
241
|
-
const local = [resolve(root, rawUrl), resolve(process.cwd(), rawUrl)].find(c =>
|
|
253
|
+
const local = [resolve(root, rawUrl), resolve(process.cwd(), rawUrl)].find(c => {
|
|
254
|
+
return existsSync(c)
|
|
255
|
+
})
|
|
242
256
|
|
|
243
257
|
if (local) {
|
|
244
258
|
return importLocal(logger, root, configurationFile, local)
|
package/lib/utils.js
CHANGED
|
@@ -3,7 +3,7 @@ import { platformaticRuntime, buildRuntime as pltBuildRuntime } from '@platforma
|
|
|
3
3
|
import { bgGreen, black, bold } from 'colorette'
|
|
4
4
|
import { existsSync } from 'node:fs'
|
|
5
5
|
import { readdir, stat } from 'node:fs/promises'
|
|
6
|
-
import { resolve } from 'node:path'
|
|
6
|
+
import { resolve, dirname } from 'node:path'
|
|
7
7
|
import { parseArgs as nodeParseArgs } from 'node:util'
|
|
8
8
|
import pino from 'pino'
|
|
9
9
|
import pinoPretty from 'pino-pretty'
|
|
@@ -88,8 +88,21 @@ export function getMatchingRuntimeArgs (logger, positional) {
|
|
|
88
88
|
}
|
|
89
89
|
|
|
90
90
|
export async function findConfigurationFile (logger, root) {
|
|
91
|
-
|
|
92
|
-
|
|
91
|
+
let current = root
|
|
92
|
+
let configurationFile
|
|
93
|
+
while (configurationFile === undefined) {
|
|
94
|
+
// Find a wattpm.json or watt.json file
|
|
95
|
+
configurationFile = await ConfigManager.findConfigFile(current, ['watt.json', 'wattpm.json', 'platformatic.json'])
|
|
96
|
+
if (!configurationFile) {
|
|
97
|
+
const newCurrent = dirname(current)
|
|
98
|
+
|
|
99
|
+
if (newCurrent === current) {
|
|
100
|
+
break
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
current = newCurrent
|
|
104
|
+
}
|
|
105
|
+
}
|
|
93
106
|
|
|
94
107
|
if (typeof configurationFile !== 'string') {
|
|
95
108
|
logger.fatal(
|
|
@@ -97,7 +110,8 @@ export async function findConfigurationFile (logger, root) {
|
|
|
97
110
|
)
|
|
98
111
|
}
|
|
99
112
|
|
|
100
|
-
|
|
113
|
+
const resolved = resolve(current, configurationFile)
|
|
114
|
+
return resolved
|
|
101
115
|
}
|
|
102
116
|
|
|
103
117
|
export async function checkEmptyDirectory (logger, path, relativePath) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "wattpm",
|
|
3
|
-
"version": "2.5.
|
|
3
|
+
"version": "2.5.4",
|
|
4
4
|
"description": "The Node.js Application Server",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -34,11 +34,11 @@
|
|
|
34
34
|
"pino-pretty": "^11.2.2",
|
|
35
35
|
"split2": "^4.2.0",
|
|
36
36
|
"table": "^6.8.2",
|
|
37
|
-
"@platformatic/basic": "2.5.
|
|
38
|
-
"@platformatic/config": "2.5.
|
|
39
|
-
"@platformatic/control": "2.5.
|
|
40
|
-
"@platformatic/runtime": "2.5.
|
|
41
|
-
"@platformatic/utils": "2.5.
|
|
37
|
+
"@platformatic/basic": "2.5.4",
|
|
38
|
+
"@platformatic/config": "2.5.4",
|
|
39
|
+
"@platformatic/control": "2.5.4",
|
|
40
|
+
"@platformatic/runtime": "2.5.4",
|
|
41
|
+
"@platformatic/utils": "2.5.4"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
44
|
"borp": "^0.17.0",
|
package/schema.json
CHANGED