feat(desktop,launcher): default to ~/.waggle-community (P1.3c)

The Tauri shell's bundled npm environment and its first-launch flag, the
server installer's --data-dir default and the NSIS installer config
fell back to ~/.waggle. Use ~/.waggle-community (ADR-0011).

The Rust shell keeps the name in DEFAULT_DATA_DIR_NAME in lib.rs and the
launcher, which uses only Node built-ins, in DATA_DIR_NAME.
packages/shared/tests/data-dir.test.ts fails when either copy, or the
marketplace's, differs from @waggle/shared.
This commit is contained in:
shumeiko.it
2026-11-04 10:31:32 +01:00
parent b275f0bf89
commit 4fabed70c0
10 changed files with 80 additions and 43 deletions

View File

@@ -26,7 +26,8 @@ Run `waggle-server --help` for the full list.
Supported systems: Windows x64, macOS (Apple silicon and Intel), Linux x64. You need Node.js
20 or newer only for the first `npx` call.
Your data lives in `~/.waggle` (or `WAGGLE_DATA_DIR`). `uninstall` does not touch it.
Your data lives in `~/.waggle-community` (or `WAGGLE_DATA_DIR`), apart from the commercial
Waggle's `~/.waggle`. `uninstall` does not touch it.
The package and command names are temporary until the product name is decided, and until
the release location is set, install from an archive with `--from`.

View File

@@ -1,4 +1,4 @@
import { COMMAND_NAME } from './platform.js';
import { COMMAND_NAME, DATA_DIR_NAME } from './platform.js';
export type Command = 'install' | 'update' | 'run' | 'doctor' | 'uninstall' | 'help' | 'version';
@@ -97,7 +97,7 @@ export function formatHelp(version: string): string {
--sha256 <hex> Expected SHA-256 of the archive
--dir <path> Install directory
--bin-dir <path> Where to put the ${COMMAND_NAME} command
--data-dir <path> Data directory (default: $WAGGLE_DATA_DIR or ~/.waggle)
--data-dir <path> Data directory (default: $WAGGLE_DATA_DIR or ~/${DATA_DIR_NAME})
--port, -p <number> Server port (default: ${DEFAULT_PORT})
--no-open Do not open the browser
--force Reinstall even when this version is installed

View File

@@ -9,6 +9,14 @@ import path from 'node:path';
/** The command the installer puts on the PATH. A working name until the product name is decided. */
export const COMMAND_NAME = 'waggle-server';
/**
* The default data directory under the home directory, kept apart from the
* commercial Waggle's `~/.waggle` (ADR-0011). A temporary name: the final one
* follows the product-name decision (Q8). The launcher uses only Node's
* built-in modules, so this copies `DEFAULT_DATA_DIR_NAME` from `@waggle/shared`.
*/
export const DATA_DIR_NAME = '.waggle-community';
export interface Host {
platform: NodeJS.Platform;
arch: string;
@@ -63,9 +71,9 @@ export function defaultBinDir(host: Host, installDir: string): string {
return host.platform === 'win32' ? p.join(installDir, 'bin') : p.join(host.homedir, '.local', 'bin');
}
/** Same rule as the sidecar's resolveDataDir: WAGGLE_DATA_DIR, else ~/.waggle. */
/** Same rule as the sidecar's resolveDataDir: WAGGLE_DATA_DIR, else ~/.waggle-community. */
export function defaultDataDir(host: Host): string {
return host.env.WAGGLE_DATA_DIR || pathApi(host.platform).join(host.homedir, '.waggle');
return host.env.WAGGLE_DATA_DIR || pathApi(host.platform).join(host.homedir, DATA_DIR_NAME);
}
export function isOnPath(host: Host, dir: string): boolean {

View File

@@ -92,7 +92,8 @@ describe('platform paths', () => {
});
it('follows the sidecar data directory rule', () => {
expect(defaultDataDir(host('linux'))).toBe('/home/ana/.waggle');
expect(defaultDataDir(host('linux'))).toBe('/home/ana/.waggle-community');
expect(defaultDataDir(host('win32'))).toBe('C:\\Users\\ana\\.waggle-community');
expect(defaultDataDir(host('linux', { WAGGLE_DATA_DIR: '/srv/waggle' }))).toBe('/srv/waggle');
});
@@ -107,7 +108,7 @@ describe('payload helpers', () => {
it('gives the server the environment the desktop shell gives it', () => {
const env = serviceEnvironment({
appDir: '/opt/w/app',
dataDir: '/home/ana/.waggle',
dataDir: '/home/ana/.waggle-community',
port: 4000,
platform: 'linux',
baseEnv: { PATH: '/usr/bin', WAGGLE_DATA_DIR: '/stale' },
@@ -119,8 +120,8 @@ describe('payload helpers', () => {
WAGGLE_FRONTEND_DIR: '/opt/w/app/web',
NODE_PATH: '/opt/w/app/node_modules:/opt/w/app/native',
PATH: '/opt/w/app/node_modules/waggle-node-runtime/bin:/opt/w/app:/usr/bin',
NPM_CONFIG_PREFIX: '/home/ana/.waggle/npm/prefix',
NPM_CONFIG_CACHE: '/home/ana/.waggle/npm/cache',
NPM_CONFIG_PREFIX: '/home/ana/.waggle-community/npm/prefix',
NPM_CONFIG_CACHE: '/home/ana/.waggle-community/npm/cache',
});
expect(env.WAGGLE_DATA_DIR).toBeUndefined();

View File

@@ -0,0 +1,24 @@
import fs from 'node:fs';
import path from 'node:path';
import { fileURLToPath } from 'node:url';
import { describe, it, expect } from 'vitest';
import { DEFAULT_DATA_DIR_LABEL, DEFAULT_DATA_DIR_NAME } from '../src/data-dir.js';
import { DATA_DIR_NAME as LAUNCHER_DATA_DIR_NAME } from '../../launcher/src/platform.js';
import { DATA_DIR_NAME as MARKETPLACE_DATA_DIR_NAME } from '../../marketplace/src/data-dir.js';
const ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '../../..');
// ADR-0011: the community edition never defaults to the commercial ~/.waggle.
describe('default data directory', () => {
it('is separate from the commercial edition', () => {
expect(DEFAULT_DATA_DIR_NAME).toBe('.waggle-community');
expect(DEFAULT_DATA_DIR_LABEL).toBe('~/.waggle-community');
});
it('has the same name in the launcher, the marketplace and the Rust shell', () => {
expect(LAUNCHER_DATA_DIR_NAME).toBe(DEFAULT_DATA_DIR_NAME);
expect(MARKETPLACE_DATA_DIR_NAME).toBe(DEFAULT_DATA_DIR_NAME);
const lib = fs.readFileSync(path.join(ROOT, 'app/src-tauri/src/lib.rs'), 'utf8');
expect(lib).toContain(`const DEFAULT_DATA_DIR_NAME: &str = "${DEFAULT_DATA_DIR_NAME}";`);
});
});