@nextnode-solutions/nn 1.1.3 → 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 +43 -33
- 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
|
|
@@ -20071,12 +20071,12 @@ function generateLocalSupabaseServices(supabaseConfig, appName, ports) {
|
|
|
20071
20071
|
lines.push(" POSTGRES_USER: ${POSTGRES_USER:-supabase_admin}");
|
|
20072
20072
|
lines.push(" volumes:");
|
|
20073
20073
|
lines.push(" - supabase-db-data:/var/lib/postgresql/data");
|
|
20074
|
-
lines.push(" -
|
|
20074
|
+
lines.push(" - ./supabase/roles.sql:/etc/postgresql.schema.sql:ro");
|
|
20075
20075
|
lines.push(
|
|
20076
|
-
" -
|
|
20076
|
+
" - ./supabase/init:/docker-entrypoint-initdb.d/nn-migrations"
|
|
20077
20077
|
);
|
|
20078
20078
|
lines.push(
|
|
20079
|
-
" -
|
|
20079
|
+
" - ./supabase/init-db.sh:/docker-entrypoint-initdb.d/zz-init.sh"
|
|
20080
20080
|
);
|
|
20081
20081
|
lines.push("");
|
|
20082
20082
|
lines.push(" supabase-auth:");
|
|
@@ -20140,9 +20140,9 @@ function generateLocalSupabaseServices(supabaseConfig, appName, ports) {
|
|
|
20140
20140
|
lines.push(" SUPABASE_ANON_KEY: ${SUPABASE_ANON_KEY}");
|
|
20141
20141
|
lines.push(" SUPABASE_SERVICE_KEY: ${SUPABASE_SERVICE_ROLE_KEY}");
|
|
20142
20142
|
lines.push(" volumes:");
|
|
20143
|
-
lines.push(" -
|
|
20143
|
+
lines.push(" - ./supabase/kong.yml:/var/lib/kong/kong.yml.tpl:ro");
|
|
20144
20144
|
lines.push(
|
|
20145
|
-
" -
|
|
20145
|
+
" - ./supabase/kong-entrypoint.sh:/usr/local/bin/kong-entrypoint.sh:ro"
|
|
20146
20146
|
);
|
|
20147
20147
|
lines.push("");
|
|
20148
20148
|
lines.push(" supabase-meta:");
|
|
@@ -20788,8 +20788,19 @@ function gracefulKill(proc, timeoutMs = 5e3) {
|
|
|
20788
20788
|
async function waitForHealthy(checkFn, label, maxMs = 6e4) {
|
|
20789
20789
|
let delay = 500;
|
|
20790
20790
|
let elapsed = 0;
|
|
20791
|
+
let lastLog = 0;
|
|
20791
20792
|
while (elapsed < maxMs) {
|
|
20792
|
-
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
|
+
}
|
|
20793
20804
|
await sleep(delay);
|
|
20794
20805
|
elapsed += delay;
|
|
20795
20806
|
delay = Math.min(delay * 2, 4e3);
|
|
@@ -20989,11 +21000,27 @@ var init_up = __esm({
|
|
|
20989
21000
|
writeEnvLocal(projectDir, envVars);
|
|
20990
21001
|
}
|
|
20991
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);
|
|
20992
21021
|
if (services.names.length > 0) {
|
|
20993
21022
|
if (areServicesRunning(composePath)) {
|
|
20994
|
-
consola.info(
|
|
20995
|
-
"Services are already running. Attaching to logs..."
|
|
20996
|
-
);
|
|
21023
|
+
consola.info("Services already running, checking health...");
|
|
20997
21024
|
} else {
|
|
20998
21025
|
const composeContent = generateLocalCompose(
|
|
20999
21026
|
config,
|
|
@@ -21005,11 +21032,11 @@ var init_up = __esm({
|
|
|
21005
21032
|
consola.info("Starting Docker services...");
|
|
21006
21033
|
const envFilePath = join6(nnDir, ".env");
|
|
21007
21034
|
startDockerServices(composePath, envFilePath);
|
|
21008
|
-
await waitForHealthy(
|
|
21009
|
-
() => allServicesHealthy(composePath),
|
|
21010
|
-
"Docker services"
|
|
21011
|
-
);
|
|
21012
21035
|
}
|
|
21036
|
+
await waitForHealthy(
|
|
21037
|
+
() => allServicesHealthy(composePath),
|
|
21038
|
+
"Docker services"
|
|
21039
|
+
);
|
|
21013
21040
|
printStartupSummary(composePath, services, ports);
|
|
21014
21041
|
} else {
|
|
21015
21042
|
consola.info("No services configured \u2014 starting app only");
|
|
@@ -21021,7 +21048,7 @@ var init_up = __esm({
|
|
|
21021
21048
|
}
|
|
21022
21049
|
const devCmd = detectDevCommand(projectDir);
|
|
21023
21050
|
consola.info(`Starting app: ${devCmd.command} ${devCmd.args.join(" ")}`);
|
|
21024
|
-
|
|
21051
|
+
appProc = spawn3(devCmd.command, devCmd.args, {
|
|
21025
21052
|
cwd: projectDir,
|
|
21026
21053
|
stdio: ["ignore", "pipe", "pipe"],
|
|
21027
21054
|
env: { ...process.env, ...envVars }
|
|
@@ -21031,26 +21058,9 @@ var init_up = __esm({
|
|
|
21031
21058
|
}
|
|
21032
21059
|
const colorOffset = services.names.length + 1;
|
|
21033
21060
|
pipeWithPrefix(appProc, "app", colorOffset);
|
|
21034
|
-
let dockerLogProc;
|
|
21035
21061
|
if (services.names.length > 0) {
|
|
21036
21062
|
dockerLogProc = streamDockerLogs(composePath);
|
|
21037
21063
|
}
|
|
21038
|
-
const cleanup = async () => {
|
|
21039
|
-
consola.info("\nShutting down...");
|
|
21040
|
-
if (appProc.pid) {
|
|
21041
|
-
await gracefulKill(appProc);
|
|
21042
|
-
}
|
|
21043
|
-
if (dockerLogProc?.pid) {
|
|
21044
|
-
await gracefulKill(dockerLogProc);
|
|
21045
|
-
}
|
|
21046
|
-
if (services.names.length > 0 && existsSync6(composePath)) {
|
|
21047
|
-
stopDockerServices(composePath);
|
|
21048
|
-
}
|
|
21049
|
-
consola.info("Local environment stopped.");
|
|
21050
|
-
process.exit(0);
|
|
21051
|
-
};
|
|
21052
|
-
process.on("SIGINT", cleanup);
|
|
21053
|
-
process.on("SIGTERM", cleanup);
|
|
21054
21064
|
appProc.on("exit", (code) => {
|
|
21055
21065
|
if (code !== null && code !== 0) {
|
|
21056
21066
|
consola.error(`App exited with code ${code}`);
|