@dbos-inc/create 1.3.9-preview → 1.3.12-preview
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/package.json +1 -1
- package/templates/hello/dbos-config.yaml +8 -6
- package/templates/hello/knexfile.js +1 -0
- package/templates/hello/package-lock.json +3 -1
- package/templates/hello/start_postgres_docker.js +40 -0
- package/templates/hello/start_postgres_docker.bat +0 -36
- package/templates/hello/start_postgres_docker.sh +0 -23
package/package.json
CHANGED
|
@@ -4,12 +4,14 @@
|
|
|
4
4
|
# yaml-language-server: $schema=https://raw.githubusercontent.com/dbos-inc/dbos-sdk/main/dbos-config.schema.json
|
|
5
5
|
|
|
6
6
|
database:
|
|
7
|
-
hostname:
|
|
7
|
+
hostname: localhost
|
|
8
8
|
port: 5432
|
|
9
|
-
username:
|
|
9
|
+
username: postgres
|
|
10
10
|
password: ${PGPASSWORD}
|
|
11
|
-
app_db_name:
|
|
11
|
+
app_db_name: hello
|
|
12
12
|
connectionTimeoutMillis: 3000
|
|
13
|
-
app_db_client:
|
|
14
|
-
migrate:
|
|
15
|
-
|
|
13
|
+
app_db_client: knex
|
|
14
|
+
migrate:
|
|
15
|
+
- npx knex migrate:latest
|
|
16
|
+
rollback:
|
|
17
|
+
- npx knex migrate:rollback
|
|
@@ -45,13 +45,14 @@
|
|
|
45
45
|
"axios": "1.6.7",
|
|
46
46
|
"commander": "12.0.0",
|
|
47
47
|
"fast-glob": "3.3.2",
|
|
48
|
+
"inquirer": "^8.2.6",
|
|
48
49
|
"kafkajs": "^2.2.4",
|
|
49
50
|
"knex": "3.1.0",
|
|
50
51
|
"koa": "2.15.0",
|
|
51
52
|
"lodash": "4.17.21",
|
|
52
53
|
"openapi-types": "12.1.3",
|
|
53
54
|
"pg": "8.11.3",
|
|
54
|
-
"reflect-metadata": "0.2.
|
|
55
|
+
"reflect-metadata": "0.2.2",
|
|
55
56
|
"serialize-error": "8.1.0",
|
|
56
57
|
"uuid": "9.0.1",
|
|
57
58
|
"validator": "13.11.0",
|
|
@@ -65,6 +66,7 @@
|
|
|
65
66
|
},
|
|
66
67
|
"devDependencies": {
|
|
67
68
|
"@prisma/client": "^5.3.1",
|
|
69
|
+
"@types/inquirer": "^8.2.10",
|
|
68
70
|
"@types/koa": "^2.15.0",
|
|
69
71
|
"@types/koa__cors": "^5.0.0",
|
|
70
72
|
"@types/koa__router": "^12.0.4",
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
const { execSync } = require('child_process');
|
|
2
|
+
|
|
3
|
+
// Default PostgreSQL port
|
|
4
|
+
let port = '5432';
|
|
5
|
+
|
|
6
|
+
// Set the host PostgreSQL port with the -p/--port flag.
|
|
7
|
+
process.argv.forEach((val, index) => {
|
|
8
|
+
if (val === '-p' || val === '--port') {
|
|
9
|
+
if (process.argv[index + 1]) {
|
|
10
|
+
port = process.argv[index + 1];
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
if (!process.env.PGPASSWORD) {
|
|
16
|
+
console.error("Error: PGPASSWORD is not set.");
|
|
17
|
+
process.exit(1);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
try {
|
|
21
|
+
execSync(`docker run --rm --name=dbos-db --env=POSTGRES_PASSWORD="${process.env.PGPASSWORD}" --env=PGDATA=/var/lib/postgresql/data --volume=/var/lib/postgresql/data -p ${port}:5432 -d postgres:16.1`);
|
|
22
|
+
console.log("Waiting for PostgreSQL to start...");
|
|
23
|
+
|
|
24
|
+
let attempts = 30;
|
|
25
|
+
const checkDatabase = setInterval(() => {
|
|
26
|
+
try {
|
|
27
|
+
execSync('docker exec dbos-db psql -U postgres -c "SELECT 1;"', { stdio: 'ignore' });
|
|
28
|
+
console.log("PostgreSQL started!");
|
|
29
|
+
clearInterval(checkDatabase);
|
|
30
|
+
console.log("Database started successfully!");
|
|
31
|
+
} catch (error) {
|
|
32
|
+
if (--attempts === 0) {
|
|
33
|
+
clearInterval(checkDatabase);
|
|
34
|
+
console.error("Failed to start PostgreSQL.");
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}, 1000);
|
|
38
|
+
} catch (error) {
|
|
39
|
+
console.error("Error starting PostgreSQL in Docker:", error.message);
|
|
40
|
+
}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
@echo off
|
|
2
|
-
|
|
3
|
-
setlocal ENABLEEXTENSIONS
|
|
4
|
-
|
|
5
|
-
echo Checking if PGPASSWORD is set.
|
|
6
|
-
if "%PGPASSWORD%"=="" (
|
|
7
|
-
echo Error: PGPASSWORD is not set.
|
|
8
|
-
exit /b 1
|
|
9
|
-
)
|
|
10
|
-
|
|
11
|
-
echo Starting PostgreSQL in a local Docker container
|
|
12
|
-
docker run --rm --name=dbos-db --env=POSTGRES_PASSWORD=%PGPASSWORD% --env=PGDATA=/var/lib/postgresql/data --volume=/var/lib/postgresql/data -p 5432:5432 -d postgres:16.1
|
|
13
|
-
|
|
14
|
-
if %errorlevel% == 125 (
|
|
15
|
-
echo Error: Check if the Docker container already exists
|
|
16
|
-
exit /b 1
|
|
17
|
-
) else (
|
|
18
|
-
goto :start
|
|
19
|
-
)
|
|
20
|
-
|
|
21
|
-
:start
|
|
22
|
-
echo Waiting for PostgreSQL to start...
|
|
23
|
-
for /l %%i in (1,1,30) do (
|
|
24
|
-
docker exec dbos-db psql -U postgres -c "SELECT 1;" >NUL 2>&1
|
|
25
|
-
|
|
26
|
-
if %errorlevel% equ 0 (
|
|
27
|
-
(
|
|
28
|
-
echo PostgreSQL started!
|
|
29
|
-
goto :break
|
|
30
|
-
)
|
|
31
|
-
timeout /t 1 /nobreak
|
|
32
|
-
)
|
|
33
|
-
)
|
|
34
|
-
:break
|
|
35
|
-
|
|
36
|
-
echo Database started successfully^!
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
#!/bin/bash
|
|
2
|
-
set -e
|
|
3
|
-
|
|
4
|
-
# Check if PGPASSWORD is set
|
|
5
|
-
if [[ -z "${PGPASSWORD}" ]]; then
|
|
6
|
-
echo "Error: PGPASSWORD is not set." >&2
|
|
7
|
-
exit 1
|
|
8
|
-
fi
|
|
9
|
-
|
|
10
|
-
# Start Postgres in a local Docker container
|
|
11
|
-
docker run --rm --name=dbos-db --env=POSTGRES_PASSWORD=${PGPASSWORD} --env=PGDATA=/var/lib/postgresql/data --volume=/var/lib/postgresql/data -p 5432:5432 -d postgres:16.1
|
|
12
|
-
|
|
13
|
-
# Wait for PostgreSQL to start
|
|
14
|
-
echo "Waiting for PostgreSQL to start..."
|
|
15
|
-
for i in {1..30}; do
|
|
16
|
-
if docker exec dbos-db psql -U postgres -c "SELECT 1;" > /dev/null 2>&1; then
|
|
17
|
-
echo "PostgreSQL started!"
|
|
18
|
-
break
|
|
19
|
-
fi
|
|
20
|
-
sleep 1
|
|
21
|
-
done
|
|
22
|
-
|
|
23
|
-
echo "Database started successfully!"
|