wattpm 2.67.0 → 2.68.0

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.
@@ -1,4 +1,4 @@
1
- import { configCandidates } from '@platformatic/basic'
1
+ import { configCandidates, detectStackable } from '@platformatic/basic'
2
2
  import { loadConfigurationFile as loadRawConfigurationFile, saveConfigurationFile } from '@platformatic/config'
3
3
  import { ensureLoggableError } from '@platformatic/utils'
4
4
  import { bold } from 'colorette'
@@ -44,22 +44,9 @@ async function parseLocalFolder (path) {
44
44
  }
45
45
 
46
46
  // Check which stackable we should use
47
- const { dependencies, devDependencies } = packageJson
48
-
49
- /* c8 ignore next 11 */
50
- let stackable = '@platformatic/node'
51
-
52
- if (dependencies?.next || devDependencies?.next) {
53
- stackable = '@platformatic/next'
54
- } else if (dependencies?.['@remix-run/dev'] || devDependencies?.['@remix-run/dev']) {
55
- stackable = '@platformatic/remix'
56
- } else if (dependencies?.vite || devDependencies?.vite) {
57
- stackable = '@platformatic/vite'
58
- } else if (dependencies?.astro || devDependencies?.astro) {
59
- stackable = '@platformatic/astro'
60
- }
47
+ const { name: stackable, label } = await detectStackable(path, packageJson)
61
48
 
62
- return { id: packageJson.name ?? basename(path), url, packageJson, stackable }
49
+ return { id: packageJson.name ?? basename(path), url, packageJson, stackable, label }
63
50
  }
64
51
 
65
52
  async function findExistingConfiguration (root, path) {
@@ -88,7 +75,7 @@ export async function appendEnvVariable (envFile, key, value) {
88
75
  return writeFile(envFile, contents, 'utf-8')
89
76
  }
90
77
 
91
- async function fixConfiguration (logger, root, configOption) {
78
+ async function fixConfiguration (logger, root, configOption, skipDependencies, packageManager) {
92
79
  const configurationFile = await findRuntimeConfigurationFile(logger, root, configOption)
93
80
 
94
81
  /* c8 ignore next 3 - Hard to test */
@@ -106,7 +93,7 @@ async function fixConfiguration (logger, root, configOption) {
106
93
  continue
107
94
  }
108
95
 
109
- const { id, packageJson, stackable } = await parseLocalFolder(resolve(root, path))
96
+ const { id, packageJson, stackable, label } = await parseLocalFolder(resolve(root, path))
110
97
 
111
98
  packageJson.dependencies ??= {}
112
99
  packageJson.dependencies[stackable] = `^${version}`
@@ -115,11 +102,23 @@ async function fixConfiguration (logger, root, configOption) {
115
102
  $schema: `https://schemas.platformatic.dev/${stackable}/${version}.json`
116
103
  }
117
104
 
118
- logger.info(`Detected stackable ${bold(stackable)} for service ${bold(id)}, adding to the service dependencies.`)
105
+ if (stackable === '@platformatic/node') {
106
+ logger.info(
107
+ `Service ${bold(id)} is a ${bold('generic Node.js application')}. Adding ${bold(stackable)} to its package.json dependencies.`
108
+ )
109
+ } else {
110
+ logger.info(
111
+ `Service ${bold(id)} is using ${bold(label)}. Adding ${bold(stackable)} to its package.json dependencies.`
112
+ )
113
+ }
119
114
 
120
115
  await saveConfigurationFile(resolve(path, 'package.json'), packageJson)
121
116
  await saveConfigurationFile(resolve(path, 'watt.json'), wattJson)
122
117
  }
118
+
119
+ if (!skipDependencies) {
120
+ return await installDependencies(logger, root, config.services, false, packageManager)
121
+ }
123
122
  }
124
123
 
125
124
  async function importService (logger, configurationFile, id, path, url, branch) {
@@ -363,7 +362,7 @@ export async function resolveServices (
363
362
 
364
363
  export async function importCommand (logger, args) {
365
364
  const {
366
- values: { config, id, http, branch },
365
+ values: { config, id, http, branch, 'skip-dependencies': skipDependencies, 'package-manager': packageManager },
367
366
  positionals
368
367
  } = parseArgs(
369
368
  args,
@@ -383,6 +382,15 @@ export async function importCommand (logger, args) {
383
382
  branch: {
384
383
  type: 'string',
385
384
  short: 'b'
385
+ },
386
+ 'skip-dependencies': {
387
+ type: 'boolean',
388
+ short: 's',
389
+ default: false
390
+ },
391
+ 'package-manager': {
392
+ type: 'string',
393
+ short: 'P'
386
394
  }
387
395
  },
388
396
  false
@@ -397,7 +405,7 @@ export async function importCommand (logger, args) {
397
405
  Two arguments = root and URL
398
406
  */
399
407
  if (positionals.length === 0) {
400
- return fixConfiguration(logger, '', config)
408
+ return fixConfiguration(logger, '', config, skipDependencies, packageManager)
401
409
  } else if (positionals.length === 1) {
402
410
  root = getRoot()
403
411
  rawUrl = positionals[0]
@@ -513,6 +521,14 @@ export const help = {
513
521
  {
514
522
  usage: '-b, --branch <branch>',
515
523
  description: 'The branch to clone (the default is main)'
524
+ },
525
+ {
526
+ usage: '-s, --skip-dependencies',
527
+ description: 'Do not install services dependencies'
528
+ },
529
+ {
530
+ usage: 'P, --package-manager <executable>',
531
+ description: 'Use an alternative package manager (the default is to autodetect it)'
516
532
  }
517
533
  ]
518
534
  },
package/lib/packages.js CHANGED
@@ -16,6 +16,7 @@ export const packages = [
16
16
  '@platformatic/globals',
17
17
  '@platformatic/itc',
18
18
  '@platformatic/metrics',
19
+ '@platformatic/nest',
19
20
  '@platformatic/next',
20
21
  '@platformatic/node',
21
22
  '@platformatic/remix',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wattpm",
3
- "version": "2.67.0",
3
+ "version": "2.68.0",
4
4
  "description": "The Node.js Application Server",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -36,12 +36,12 @@
36
36
  "semver": "^7.7.0",
37
37
  "split2": "^4.2.0",
38
38
  "table": "^6.8.2",
39
- "@platformatic/basic": "2.67.0",
40
- "@platformatic/control": "2.67.0",
41
- "@platformatic/runtime": "2.67.0",
42
- "@platformatic/config": "2.67.0",
43
- "create-platformatic": "2.67.0",
44
- "@platformatic/utils": "2.67.0"
39
+ "@platformatic/basic": "2.68.0",
40
+ "@platformatic/config": "2.68.0",
41
+ "@platformatic/control": "2.68.0",
42
+ "@platformatic/runtime": "2.68.0",
43
+ "@platformatic/utils": "2.68.0",
44
+ "create-platformatic": "2.68.0"
45
45
  },
46
46
  "devDependencies": {
47
47
  "borp": "^0.20.0",
@@ -51,7 +51,7 @@
51
51
  "neostandard": "^0.12.0",
52
52
  "typescript": "^5.5.4",
53
53
  "undici": "^7.0.0",
54
- "@platformatic/node": "2.67.0"
54
+ "@platformatic/node": "2.68.0"
55
55
  },
56
56
  "scripts": {
57
57
  "test": "npm run lint && borp --concurrency=1 --timeout=300000",
package/schema.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "$id": "https://schemas.platformatic.dev/wattpm/2.67.0.json",
2
+ "$id": "https://schemas.platformatic.dev/wattpm/2.68.0.json",
3
3
  "$schema": "http://json-schema.org/draft-07/schema#",
4
4
  "type": "object",
5
5
  "properties": {