@nextnode-solutions/nn 1.1.4 → 1.1.5
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/dist/index.js +41 -29
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -19885,10 +19885,10 @@ set -e
|
|
|
19885
19885
|
|
|
19886
19886
|
# Init script for ${appName}
|
|
19887
19887
|
# 1. Sets passwords for Supabase service roles
|
|
19888
|
-
# 2. Runs all SQL files in /docker-entrypoint-initdb.d/migrations/ in order
|
|
19888
|
+
# 2. Runs all SQL files in /docker-entrypoint-initdb.d/nn-migrations/ in order
|
|
19889
19889
|
|
|
19890
19890
|
ROLES_SQL="/etc/postgresql.schema.sql"
|
|
19891
|
-
MIGRATIONS_DIR="/docker-entrypoint-initdb.d/migrations"
|
|
19891
|
+
MIGRATIONS_DIR="/docker-entrypoint-initdb.d/nn-migrations"
|
|
19892
19892
|
|
|
19893
19893
|
# Set passwords for supabase_auth_admin and authenticator
|
|
19894
19894
|
if [ -f "$ROLES_SQL" ]; then
|
|
@@ -20072,7 +20072,9 @@ function generateLocalSupabaseServices(supabaseConfig, appName, ports) {
|
|
|
20072
20072
|
lines.push(" volumes:");
|
|
20073
20073
|
lines.push(" - supabase-db-data:/var/lib/postgresql/data");
|
|
20074
20074
|
lines.push(" - ./supabase/roles.sql:/etc/postgresql.schema.sql:ro");
|
|
20075
|
-
lines.push(
|
|
20075
|
+
lines.push(
|
|
20076
|
+
" - ./supabase/init:/docker-entrypoint-initdb.d/nn-migrations"
|
|
20077
|
+
);
|
|
20076
20078
|
lines.push(
|
|
20077
20079
|
" - ./supabase/init-db.sh:/docker-entrypoint-initdb.d/zz-init.sh"
|
|
20078
20080
|
);
|
|
@@ -20786,8 +20788,19 @@ function gracefulKill(proc, timeoutMs = 5e3) {
|
|
|
20786
20788
|
async function waitForHealthy(checkFn, label, maxMs = 6e4) {
|
|
20787
20789
|
let delay = 500;
|
|
20788
20790
|
let elapsed = 0;
|
|
20791
|
+
let lastLog = 0;
|
|
20789
20792
|
while (elapsed < maxMs) {
|
|
20790
|
-
if (checkFn())
|
|
20793
|
+
if (checkFn()) {
|
|
20794
|
+
consola.success(`${label} healthy`);
|
|
20795
|
+
return true;
|
|
20796
|
+
}
|
|
20797
|
+
if (elapsed - lastLog >= 1e4) {
|
|
20798
|
+
const remaining = Math.ceil((maxMs - elapsed) / 1e3);
|
|
20799
|
+
consola.info(
|
|
20800
|
+
`Waiting for ${label} to become healthy... (${remaining}s remaining)`
|
|
20801
|
+
);
|
|
20802
|
+
lastLog = elapsed;
|
|
20803
|
+
}
|
|
20791
20804
|
await sleep(delay);
|
|
20792
20805
|
elapsed += delay;
|
|
20793
20806
|
delay = Math.min(delay * 2, 4e3);
|
|
@@ -20987,11 +21000,27 @@ var init_up = __esm({
|
|
|
20987
21000
|
writeEnvLocal(projectDir, envVars);
|
|
20988
21001
|
}
|
|
20989
21002
|
const composePath = join6(nnDir, "docker-compose.local.yml");
|
|
21003
|
+
let appProc;
|
|
21004
|
+
let dockerLogProc;
|
|
21005
|
+
const cleanup = async () => {
|
|
21006
|
+
consola.info("\nShutting down...");
|
|
21007
|
+
if (appProc?.pid) {
|
|
21008
|
+
await gracefulKill(appProc);
|
|
21009
|
+
}
|
|
21010
|
+
if (dockerLogProc?.pid) {
|
|
21011
|
+
await gracefulKill(dockerLogProc);
|
|
21012
|
+
}
|
|
21013
|
+
if (services.names.length > 0 && existsSync6(composePath)) {
|
|
21014
|
+
stopDockerServices(composePath);
|
|
21015
|
+
}
|
|
21016
|
+
consola.info("Local environment stopped.");
|
|
21017
|
+
process.exit(0);
|
|
21018
|
+
};
|
|
21019
|
+
process.on("SIGINT", cleanup);
|
|
21020
|
+
process.on("SIGTERM", cleanup);
|
|
20990
21021
|
if (services.names.length > 0) {
|
|
20991
21022
|
if (areServicesRunning(composePath)) {
|
|
20992
|
-
consola.info(
|
|
20993
|
-
"Services are already running. Attaching to logs..."
|
|
20994
|
-
);
|
|
21023
|
+
consola.info("Services already running, checking health...");
|
|
20995
21024
|
} else {
|
|
20996
21025
|
const composeContent = generateLocalCompose(
|
|
20997
21026
|
config,
|
|
@@ -21003,11 +21032,11 @@ var init_up = __esm({
|
|
|
21003
21032
|
consola.info("Starting Docker services...");
|
|
21004
21033
|
const envFilePath = join6(nnDir, ".env");
|
|
21005
21034
|
startDockerServices(composePath, envFilePath);
|
|
21006
|
-
await waitForHealthy(
|
|
21007
|
-
() => allServicesHealthy(composePath),
|
|
21008
|
-
"Docker services"
|
|
21009
|
-
);
|
|
21010
21035
|
}
|
|
21036
|
+
await waitForHealthy(
|
|
21037
|
+
() => allServicesHealthy(composePath),
|
|
21038
|
+
"Docker services"
|
|
21039
|
+
);
|
|
21011
21040
|
printStartupSummary(composePath, services, ports);
|
|
21012
21041
|
} else {
|
|
21013
21042
|
consola.info("No services configured \u2014 starting app only");
|
|
@@ -21019,7 +21048,7 @@ var init_up = __esm({
|
|
|
21019
21048
|
}
|
|
21020
21049
|
const devCmd = detectDevCommand(projectDir);
|
|
21021
21050
|
consola.info(`Starting app: ${devCmd.command} ${devCmd.args.join(" ")}`);
|
|
21022
|
-
|
|
21051
|
+
appProc = spawn3(devCmd.command, devCmd.args, {
|
|
21023
21052
|
cwd: projectDir,
|
|
21024
21053
|
stdio: ["ignore", "pipe", "pipe"],
|
|
21025
21054
|
env: { ...process.env, ...envVars }
|
|
@@ -21029,26 +21058,9 @@ var init_up = __esm({
|
|
|
21029
21058
|
}
|
|
21030
21059
|
const colorOffset = services.names.length + 1;
|
|
21031
21060
|
pipeWithPrefix(appProc, "app", colorOffset);
|
|
21032
|
-
let dockerLogProc;
|
|
21033
21061
|
if (services.names.length > 0) {
|
|
21034
21062
|
dockerLogProc = streamDockerLogs(composePath);
|
|
21035
21063
|
}
|
|
21036
|
-
const cleanup = async () => {
|
|
21037
|
-
consola.info("\nShutting down...");
|
|
21038
|
-
if (appProc.pid) {
|
|
21039
|
-
await gracefulKill(appProc);
|
|
21040
|
-
}
|
|
21041
|
-
if (dockerLogProc?.pid) {
|
|
21042
|
-
await gracefulKill(dockerLogProc);
|
|
21043
|
-
}
|
|
21044
|
-
if (services.names.length > 0 && existsSync6(composePath)) {
|
|
21045
|
-
stopDockerServices(composePath);
|
|
21046
|
-
}
|
|
21047
|
-
consola.info("Local environment stopped.");
|
|
21048
|
-
process.exit(0);
|
|
21049
|
-
};
|
|
21050
|
-
process.on("SIGINT", cleanup);
|
|
21051
|
-
process.on("SIGTERM", cleanup);
|
|
21052
21064
|
appProc.on("exit", (code) => {
|
|
21053
21065
|
if (code !== null && code !== 0) {
|
|
21054
21066
|
consola.error(`App exited with code ${code}`);
|