wattpm 2.10.0 → 2.12.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.
@@ -4,15 +4,31 @@ import { platformaticRuntime } from '@platformatic/runtime'
4
4
  import { ensureLoggableError } from '@platformatic/utils'
5
5
  import { bold } from 'colorette'
6
6
  import { execa } from 'execa'
7
- import { existsSync } from 'node:fs'
8
- import { readdir, readFile, writeFile } from 'node:fs/promises'
9
- import { basename, isAbsolute, join, relative, resolve, sep, dirname } from 'node:path'
7
+ import { existsSync, } from 'node:fs'
8
+ import { readdir, readFile, stat, writeFile } from 'node:fs/promises'
9
+ import { basename, dirname, isAbsolute, join, relative, resolve, sep } from 'node:path'
10
10
  import { defaultServiceJson } from '../defaults.js'
11
11
  import { version } from '../schema.js'
12
- import { checkEmptyDirectory, findConfigurationFile, overrideFatal, parseArgs } from '../utils.js'
12
+ import { findConfigurationFile, overrideFatal, parseArgs } from '../utils.js'
13
13
 
14
14
  const originCandidates = ['origin', 'upstream']
15
15
 
16
+ export async function checkEmptyDirectory (logger, path, relativePath) {
17
+ if (existsSync(path)) {
18
+ const statObject = await stat(path)
19
+
20
+ if (!statObject.isDirectory()) {
21
+ logger.fatal(`Path ${bold(relativePath)} exists but it is not a directory.`)
22
+ }
23
+
24
+ const entries = await readdir(path)
25
+
26
+ if (entries.filter(e => !e.startsWith('.')).length) {
27
+ logger.fatal(`Directory ${bold(relativePath)} is not empty.`)
28
+ }
29
+ }
30
+ }
31
+
16
32
  async function parseConfiguration (logger, configurationFile) {
17
33
  const store = new Store({
18
34
  cwd: process.cwd(),
@@ -1,12 +1,13 @@
1
1
  import { ConfigManager } from '@platformatic/config'
2
2
  import { ensureLoggableError } from '@platformatic/utils'
3
3
  import { bold } from 'colorette'
4
- import { mkdir, writeFile } from 'node:fs/promises'
4
+ import { existsSync, } from 'node:fs'
5
+ import { mkdir, stat, writeFile } from 'node:fs/promises'
5
6
  import { basename, resolve } from 'node:path'
6
7
  import { defaultConfiguration, defaultPackageJson } from '../defaults.js'
7
8
  import { gitignore } from '../gitignore.js'
8
9
  import { schema, version } from '../schema.js'
9
- import { checkEmptyDirectory, parseArgs, verbose } from '../utils.js'
10
+ import { parseArgs, verbose } from '../utils.js'
10
11
 
11
12
  export async function initCommand (logger, args) {
12
13
  const {
@@ -29,12 +30,34 @@ export async function initCommand (logger, args) {
29
30
  const web = resolve(root, 'web')
30
31
  const configurationFile = resolve(root, 'watt.json')
31
32
 
32
- // Check that the target directory is empty, otherwise cloning will likely fail
33
- await checkEmptyDirectory(logger, root, root)
33
+ // Check that the none of the files to be created already exist
34
+ if (existsSync(root)) {
35
+ const statObject = await stat(root)
36
+
37
+ if (!statObject.isDirectory()) {
38
+ logger.fatal(`Path ${bold(root)} exists but it is not a directory.`)
39
+ }
40
+
41
+ const webFolder = resolve(root, 'web')
42
+
43
+ if (existsSync(webFolder)) {
44
+ const statObject = await stat(webFolder)
45
+
46
+ if (!statObject.isDirectory()) {
47
+ logger.fatal(`Path ${bold(webFolder)} exists but it is not a directory.`)
48
+ }
49
+ }
50
+
51
+ for (const file of ['watt.json', 'package.json', '.gitignore']) {
52
+ if (existsSync(resolve(root, file))) {
53
+ logger.fatal(`Path ${bold(resolve(root, file))} already exists.`)
54
+ }
55
+ }
56
+ }
34
57
 
35
58
  // Create the web folder, will implicitly create the root
36
59
  try {
37
- await mkdir(web, { recursive: true, maxRetries: 10, retryDelay: 1000 })
60
+ await mkdir(web, { recursive: true, })
38
61
  /* c8 ignore next 6 */
39
62
  } catch (error) {
40
63
  logger.fatal(
package/lib/utils.js CHANGED
@@ -1,9 +1,7 @@
1
1
  import { ConfigManager, loadConfig as pltConfigLoadConfig, Store } from '@platformatic/config'
2
2
  import { platformaticRuntime, buildRuntime as pltBuildRuntime } from '@platformatic/runtime'
3
3
  import { bgGreen, black, bold } from 'colorette'
4
- import { existsSync } from 'node:fs'
5
- import { readdir, stat } from 'node:fs/promises'
6
- import { resolve, dirname } from 'node:path'
4
+ import { dirname, resolve } from 'node:path'
7
5
  import { parseArgs as nodeParseArgs } from 'node:util'
8
6
  import pino from 'pino'
9
7
  import pinoPretty from 'pino-pretty'
@@ -114,22 +112,6 @@ export async function findConfigurationFile (logger, root) {
114
112
  return resolved
115
113
  }
116
114
 
117
- export async function checkEmptyDirectory (logger, path, relativePath) {
118
- if (existsSync(path)) {
119
- const statObject = await stat(path)
120
-
121
- if (!statObject.isDirectory()) {
122
- logger.fatal(`Path ${bold(relativePath)} exists but it is not a directory.`)
123
- }
124
-
125
- const entries = await readdir(path)
126
-
127
- if (entries.length) {
128
- logger.fatal(`Directory ${bold(relativePath)} is not empty.`)
129
- }
130
- }
131
- }
132
-
133
115
  export async function buildRuntime (logger, configurationFile) {
134
116
  const store = new Store()
135
117
  store.add(platformaticRuntime)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wattpm",
3
- "version": "2.10.0",
3
+ "version": "2.12.0",
4
4
  "description": "The Node.js Application Server",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -31,14 +31,14 @@
31
31
  "help-me": "^5.0.0",
32
32
  "minimist": "^1.2.8",
33
33
  "pino": "^9.4.0",
34
- "pino-pretty": "^12.0.0",
34
+ "pino-pretty": "^13.0.0",
35
35
  "split2": "^4.2.0",
36
36
  "table": "^6.8.2",
37
- "@platformatic/basic": "2.10.0",
38
- "@platformatic/config": "2.10.0",
39
- "@platformatic/control": "2.10.0",
40
- "@platformatic/runtime": "2.10.0",
41
- "@platformatic/utils": "2.10.0"
37
+ "@platformatic/basic": "2.12.0",
38
+ "@platformatic/config": "2.12.0",
39
+ "@platformatic/control": "2.12.0",
40
+ "@platformatic/runtime": "2.12.0",
41
+ "@platformatic/utils": "2.12.0"
42
42
  },
43
43
  "devDependencies": {
44
44
  "borp": "^0.18.0",
@@ -48,7 +48,7 @@
48
48
  "neostandard": "^0.11.1",
49
49
  "typescript": "^5.5.4",
50
50
  "undici": "^6.19.8",
51
- "@platformatic/node": "2.10.0"
51
+ "@platformatic/node": "2.12.0"
52
52
  },
53
53
  "scripts": {
54
54
  "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.10.0.json",
2
+ "$id": "https://schemas.platformatic.dev/wattpm/2.12.0.json",
3
3
  "$schema": "http://json-schema.org/draft-07/schema#",
4
4
  "type": "object",
5
5
  "properties": {
@@ -654,6 +654,11 @@
654
654
  },
655
655
  "additionalProperties": false
656
656
  },
657
+ "startTimeout": {
658
+ "default": 30000,
659
+ "type": "number",
660
+ "minimum": 0
661
+ },
657
662
  "restartOnError": {
658
663
  "default": true,
659
664
  "anyOf": [
@@ -1051,6 +1056,18 @@
1051
1056
  "type": "boolean"
1052
1057
  }
1053
1058
  }
1059
+ },
1060
+ "serviceTimeout": {
1061
+ "anyOf": [
1062
+ {
1063
+ "type": "number",
1064
+ "minimum": 1
1065
+ },
1066
+ {
1067
+ "type": "string"
1068
+ }
1069
+ ],
1070
+ "default": 300000
1054
1071
  }
1055
1072
  },
1056
1073
  "anyOf": [