@nextnode-solutions/nn 1.1.4 → 1.1.6
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 +54 -37
- 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
|
);
|
|
@@ -20784,13 +20786,23 @@ function gracefulKill(proc, timeoutMs = 5e3) {
|
|
|
20784
20786
|
});
|
|
20785
20787
|
}
|
|
20786
20788
|
async function waitForHealthy(checkFn, label, maxMs = 6e4) {
|
|
20787
|
-
|
|
20788
|
-
let
|
|
20789
|
-
|
|
20790
|
-
|
|
20791
|
-
|
|
20792
|
-
|
|
20793
|
-
|
|
20789
|
+
const start = Date.now();
|
|
20790
|
+
let nextLog = start;
|
|
20791
|
+
consola.info(`Waiting for ${label} to become healthy...`);
|
|
20792
|
+
while (Date.now() - start < maxMs) {
|
|
20793
|
+
if (checkFn()) {
|
|
20794
|
+
consola.success(`${label} healthy`);
|
|
20795
|
+
return true;
|
|
20796
|
+
}
|
|
20797
|
+
const now = Date.now();
|
|
20798
|
+
if (now >= nextLog) {
|
|
20799
|
+
const remaining = Math.ceil((maxMs - (now - start)) / 1e3);
|
|
20800
|
+
consola.info(
|
|
20801
|
+
`Still waiting for ${label}... (${remaining}s remaining)`
|
|
20802
|
+
);
|
|
20803
|
+
nextLog = now + 1e4;
|
|
20804
|
+
}
|
|
20805
|
+
await sleep(2e3);
|
|
20794
20806
|
}
|
|
20795
20807
|
consola.warn(`${label} did not become healthy within ${maxMs / 1e3}s`);
|
|
20796
20808
|
return false;
|
|
@@ -20900,9 +20912,15 @@ function ensureGitignore(projectDir) {
|
|
|
20900
20912
|
function allServicesHealthy(composePath) {
|
|
20901
20913
|
const statuses = getServiceStatuses(composePath);
|
|
20902
20914
|
if (statuses.length === 0) return false;
|
|
20903
|
-
|
|
20904
|
-
(s2) => s2.state
|
|
20915
|
+
const unhealthy = statuses.filter(
|
|
20916
|
+
(s2) => s2.state !== "running" || s2.health !== "" && s2.health !== "healthy"
|
|
20905
20917
|
);
|
|
20918
|
+
if (unhealthy.length > 0) {
|
|
20919
|
+
consola.debug(
|
|
20920
|
+
`Not ready: ${unhealthy.map((s2) => `${s2.name}(state=${s2.state},health=${s2.health})`).join(", ")}`
|
|
20921
|
+
);
|
|
20922
|
+
}
|
|
20923
|
+
return unhealthy.length === 0;
|
|
20906
20924
|
}
|
|
20907
20925
|
function printStartupSummary(composePath, services, ports) {
|
|
20908
20926
|
console.log("");
|
|
@@ -20987,11 +21005,27 @@ var init_up = __esm({
|
|
|
20987
21005
|
writeEnvLocal(projectDir, envVars);
|
|
20988
21006
|
}
|
|
20989
21007
|
const composePath = join6(nnDir, "docker-compose.local.yml");
|
|
21008
|
+
let appProc;
|
|
21009
|
+
let dockerLogProc;
|
|
21010
|
+
const cleanup = async () => {
|
|
21011
|
+
consola.info("\nShutting down...");
|
|
21012
|
+
if (appProc?.pid) {
|
|
21013
|
+
await gracefulKill(appProc);
|
|
21014
|
+
}
|
|
21015
|
+
if (dockerLogProc?.pid) {
|
|
21016
|
+
await gracefulKill(dockerLogProc);
|
|
21017
|
+
}
|
|
21018
|
+
if (services.names.length > 0 && existsSync6(composePath)) {
|
|
21019
|
+
stopDockerServices(composePath);
|
|
21020
|
+
}
|
|
21021
|
+
consola.info("Local environment stopped.");
|
|
21022
|
+
process.exit(0);
|
|
21023
|
+
};
|
|
21024
|
+
process.on("SIGINT", cleanup);
|
|
21025
|
+
process.on("SIGTERM", cleanup);
|
|
20990
21026
|
if (services.names.length > 0) {
|
|
20991
21027
|
if (areServicesRunning(composePath)) {
|
|
20992
|
-
consola.info(
|
|
20993
|
-
"Services are already running. Attaching to logs..."
|
|
20994
|
-
);
|
|
21028
|
+
consola.info("Services already running, checking health...");
|
|
20995
21029
|
} else {
|
|
20996
21030
|
const composeContent = generateLocalCompose(
|
|
20997
21031
|
config,
|
|
@@ -21003,11 +21037,11 @@ var init_up = __esm({
|
|
|
21003
21037
|
consola.info("Starting Docker services...");
|
|
21004
21038
|
const envFilePath = join6(nnDir, ".env");
|
|
21005
21039
|
startDockerServices(composePath, envFilePath);
|
|
21006
|
-
await waitForHealthy(
|
|
21007
|
-
() => allServicesHealthy(composePath),
|
|
21008
|
-
"Docker services"
|
|
21009
|
-
);
|
|
21010
21040
|
}
|
|
21041
|
+
await waitForHealthy(
|
|
21042
|
+
() => allServicesHealthy(composePath),
|
|
21043
|
+
"Docker services"
|
|
21044
|
+
);
|
|
21011
21045
|
printStartupSummary(composePath, services, ports);
|
|
21012
21046
|
} else {
|
|
21013
21047
|
consola.info("No services configured \u2014 starting app only");
|
|
@@ -21019,7 +21053,7 @@ var init_up = __esm({
|
|
|
21019
21053
|
}
|
|
21020
21054
|
const devCmd = detectDevCommand(projectDir);
|
|
21021
21055
|
consola.info(`Starting app: ${devCmd.command} ${devCmd.args.join(" ")}`);
|
|
21022
|
-
|
|
21056
|
+
appProc = spawn3(devCmd.command, devCmd.args, {
|
|
21023
21057
|
cwd: projectDir,
|
|
21024
21058
|
stdio: ["ignore", "pipe", "pipe"],
|
|
21025
21059
|
env: { ...process.env, ...envVars }
|
|
@@ -21029,26 +21063,9 @@ var init_up = __esm({
|
|
|
21029
21063
|
}
|
|
21030
21064
|
const colorOffset = services.names.length + 1;
|
|
21031
21065
|
pipeWithPrefix(appProc, "app", colorOffset);
|
|
21032
|
-
let dockerLogProc;
|
|
21033
21066
|
if (services.names.length > 0) {
|
|
21034
21067
|
dockerLogProc = streamDockerLogs(composePath);
|
|
21035
21068
|
}
|
|
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
21069
|
appProc.on("exit", (code) => {
|
|
21053
21070
|
if (code !== null && code !== 0) {
|
|
21054
21071
|
consola.error(`App exited with code ${code}`);
|