@rubytech/create-maxy 0.3.5 → 0.3.7

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.
Files changed (2) hide show
  1. package/dist/index.js +35 -28
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -170,6 +170,10 @@ function ensureNeo4jPassword() {
170
170
  // Fresh install — safe to set initial password
171
171
  const password = resetNeo4jWithFreshPassword();
172
172
  writeFileSync(passwordFile, password, { mode: 0o600 });
173
+ // Also save to persistent location (~/.maxy/)
174
+ const persistDir = resolve(process.env.HOME ?? "/root", ".maxy");
175
+ mkdirSync(persistDir, { recursive: true });
176
+ writeFileSync(join(persistDir, ".neo4j-password"), password, { mode: 0o600 });
173
177
  }
174
178
  function installNeo4j() {
175
179
  if (commandExists("neo4j")) {
@@ -187,8 +191,12 @@ function installNeo4j() {
187
191
  shell("apt-get", ["update", "-qq"], { sudo: true });
188
192
  shell("apt-get", ["install", "-y", "-qq", "neo4j"], { sudo: true });
189
193
  shell("sed", ["-i", "s/#server.default_listen_address=0.0.0.0/server.default_listen_address=127.0.0.1/", "/etc/neo4j/neo4j.conf"], { sudo: true });
190
- // Generate strong random password
194
+ // Generate strong random password — stored in persistent location (~/.maxy/)
191
195
  const password = randomBytes(24).toString("base64url");
196
+ const persistDir = resolve(process.env.HOME ?? "/root", ".maxy");
197
+ mkdirSync(persistDir, { recursive: true });
198
+ writeFileSync(join(persistDir, ".neo4j-password"), password, { mode: 0o600 });
199
+ // Also write to install dir (will be there when deploy step runs)
192
200
  const configDir = resolve(INSTALL_DIR, "platform/config");
193
201
  mkdirSync(configDir, { recursive: true });
194
202
  writeFileSync(join(configDir, ".neo4j-password"), password, { mode: 0o600 });
@@ -229,21 +237,20 @@ function deployPayload() {
229
237
  if (!existsSync(PAYLOAD_DIR)) {
230
238
  throw new Error(`Payload not found at ${PAYLOAD_DIR}. Package may be corrupted.`);
231
239
  }
232
- // Preserve config (passwords, accounts) across deploys
233
- const configDir = join(INSTALL_DIR, "platform/config");
234
- const passwordFile = join(configDir, ".neo4j-password");
235
- const accountsDir = join(configDir, "accounts");
236
- const configBackup = join(INSTALL_DIR, ".config-backup");
237
- // Back up config before wiping
238
- let hasPasswordBackup = false;
239
- if (existsSync(passwordFile)) {
240
- mkdirSync(configBackup, { recursive: true });
241
- cpSync(passwordFile, join(configBackup, ".neo4j-password"));
242
- hasPasswordBackup = true;
243
- }
244
- if (existsSync(accountsDir)) {
245
- mkdirSync(configBackup, { recursive: true });
246
- cpSync(accountsDir, join(configBackup, "accounts"), { recursive: true });
240
+ // Persistent config lives at ~/.maxy/ — survives rm -rf ~/maxy
241
+ const persistentDir = resolve(process.env.HOME ?? "/root", ".maxy");
242
+ const persistentPasswordFile = join(persistentDir, ".neo4j-password");
243
+ const persistentAccountsDir = join(persistentDir, "accounts");
244
+ // Migrate: if password is in old location, move to persistent
245
+ const oldPasswordFile = join(INSTALL_DIR, "platform/config/.neo4j-password");
246
+ if (existsSync(oldPasswordFile) && !existsSync(persistentPasswordFile)) {
247
+ mkdirSync(persistentDir, { recursive: true });
248
+ cpSync(oldPasswordFile, persistentPasswordFile);
249
+ }
250
+ const oldAccountsDir = join(INSTALL_DIR, "platform/config/accounts");
251
+ if (existsSync(oldAccountsDir) && !existsSync(persistentAccountsDir)) {
252
+ mkdirSync(persistentDir, { recursive: true });
253
+ cpSync(oldAccountsDir, persistentAccountsDir, { recursive: true });
247
254
  }
248
255
  // Wipe old platform/maxy to prevent stale files
249
256
  for (const dir of ["platform", "maxy", "docs", ".claude"]) {
@@ -258,23 +265,23 @@ function deployPayload() {
258
265
  recursive: true,
259
266
  force: true,
260
267
  });
261
- // Restore backed-up config (password + accounts)
268
+ // Link persistent config into install directory
269
+ const configDir = join(INSTALL_DIR, "platform/config");
262
270
  mkdirSync(configDir, { recursive: true });
263
- if (hasPasswordBackup && existsSync(join(configBackup, ".neo4j-password"))) {
264
- cpSync(join(configBackup, ".neo4j-password"), passwordFile);
265
- console.log(" Restored Neo4j password from previous install.");
266
- }
267
- if (existsSync(join(configBackup, "accounts"))) {
268
- cpSync(join(configBackup, "accounts"), accountsDir, { recursive: true, force: true });
269
- console.log(" Restored account data from previous install.");
271
+ if (existsSync(persistentPasswordFile)) {
272
+ cpSync(persistentPasswordFile, join(configDir, ".neo4j-password"));
273
+ console.log(" Restored Neo4j password.");
270
274
  }
271
- if (existsSync(configBackup)) {
272
- rmSync(configBackup, { recursive: true });
275
+ if (existsSync(persistentAccountsDir)) {
276
+ cpSync(persistentAccountsDir, join(configDir, "accounts"), { recursive: true, force: true });
277
+ console.log(" Restored account data.");
273
278
  }
274
279
  console.log(` Deployed to ${INSTALL_DIR}`);
275
280
  }
276
281
  function buildPlatform() {
277
282
  log("8", TOTAL, "Installing dependencies and building...");
283
+ // Stop the running service before rebuilding (upgrade path)
284
+ spawnSync("systemctl", ["--user", "stop", "maxy"], { stdio: "pipe" });
278
285
  shell("npm", ["install", "--quiet"], { cwd: join(INSTALL_DIR, "platform") });
279
286
  shell("npm", ["run", "build"], { cwd: join(INSTALL_DIR, "platform") });
280
287
  shell("npm", ["install", "--quiet"], { cwd: join(INSTALL_DIR, "maxy") });
@@ -319,10 +326,10 @@ WantedBy=default.target
319
326
  spawnSync("sudo", ["loginctl", "enable-linger", user], { stdio: "inherit" });
320
327
  }
321
328
  catch { /* not critical */ }
322
- // Reload and start
329
+ // Reload and (re)start
323
330
  spawnSync("systemctl", ["--user", "daemon-reload"], { stdio: "inherit" });
324
331
  spawnSync("systemctl", ["--user", "enable", "maxy"], { stdio: "inherit" });
325
- spawnSync("systemctl", ["--user", "start", "maxy"], { stdio: "inherit" });
332
+ spawnSync("systemctl", ["--user", "restart", "maxy"], { stdio: "inherit" });
326
333
  // Wait for the server to come up
327
334
  console.log(" Waiting for web server...");
328
335
  for (let i = 0; i < 20; i++) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rubytech/create-maxy",
3
- "version": "0.3.5",
3
+ "version": "0.3.7",
4
4
  "description": "Install Maxy — your personal AI assistant",
5
5
  "bin": {
6
6
  "create-maxy": "./dist/index.js"