@naisys/hub 3.0.0-beta.22 → 3.0.0-beta.24

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/naisysHub.js CHANGED
@@ -1,4 +1,4 @@
1
- import { createDualLogger, cwdWithTilde, ensureDotEnv, expandNaisysFolder, runSetupWizard, } from "@naisys/common-node";
1
+ import { createDualLogger, cwdWithTilde, ensureDotEnv, expandNaisysFolder, promptSuperAdminPassword, runSetupWizard, } from "@naisys/common-node";
2
2
  import { createHubDatabaseService } from "@naisys/hub-database";
3
3
  import { program } from "commander";
4
4
  import dotenv from "dotenv";
@@ -26,7 +26,7 @@ import { createNaisysServer } from "./services/naisysServer.js";
26
26
  * Starts the Hub server with sync service.
27
27
  * Can be called standalone or inline from naisys with --integrated-hub flag.
28
28
  */
29
- export const startHub = async (startupType, startSupervisor, plugins, startupAgentPath) => {
29
+ export const startHub = async (startupType, startSupervisor, plugins, startupAgentPath, wizardRan) => {
30
30
  try {
31
31
  const agentPath = startupAgentPath || ".";
32
32
  // Create log service first
@@ -89,10 +89,14 @@ export const startHub = async (startupType, startSupervisor, plugins, startupAge
89
89
  // Use variable to avoid compile-time type dependency on @naisys/supervisor (allows parallel builds)
90
90
  const supervisorModule = "@naisys/supervisor";
91
91
  const { supervisorPlugin } = (await import(supervisorModule));
92
+ const superAdminPassword = wizardRan
93
+ ? await promptSuperAdminPassword("Supervisor Setup")
94
+ : undefined;
92
95
  await fastify.register(supervisorPlugin, {
93
96
  plugins,
94
97
  serverPort,
95
98
  hosted: true,
99
+ superAdminPassword,
96
100
  });
97
101
  }
98
102
  // Start listening
@@ -125,12 +129,13 @@ if (process.argv[1] === fileURLToPath(import.meta.url)) {
125
129
  ],
126
130
  };
127
131
  const hubExampleUrl = new URL("../.env.example", import.meta.url);
132
+ let wizardRan = false;
128
133
  if (process.argv.includes("--setup")) {
129
134
  const { default: path } = await import("path");
130
- await runSetupWizard(path.resolve(".env"), hubExampleUrl, hubWizardConfig);
135
+ wizardRan = await runSetupWizard(path.resolve(".env"), hubExampleUrl, hubWizardConfig);
131
136
  expandNaisysFolder();
132
137
  }
133
- await ensureDotEnv(hubExampleUrl, hubWizardConfig);
138
+ wizardRan = (await ensureDotEnv(hubExampleUrl, hubWizardConfig)) || wizardRan;
134
139
  expandNaisysFolder();
135
140
  program
136
141
  .argument("[agent-path]", "Path to agent configuration file to seed the database (optional)")
@@ -141,6 +146,6 @@ if (process.argv[1] === fileURLToPath(import.meta.url)) {
141
146
  const plugins = [];
142
147
  if (program.opts().erp)
143
148
  plugins.push("erp");
144
- void startHub("standalone", program.opts().supervisor, plugins, program.args[0]);
149
+ void startHub("standalone", program.opts().supervisor, plugins, program.args[0], wizardRan);
145
150
  }
146
151
  //# sourceMappingURL=naisysHub.js.map