Skip to content

Commit d337114

Browse files
committed
feat(cli): drop the local wavegrid.json option from init (store-only)
The interactive "Also write a local wavegrid.json here?" prompt was confusing and duplicative: init already persists everything to the centralized store, so a second local copy just raised "why two configs?". Remove the prompt and the local-write path entirely (no flag) so init is purely store-driven. A local wavegrid.json is still *read* (confstash) for git-checkout workflows if someone authors one by hand.
1 parent e0dd265 commit d337114

3 files changed

Lines changed: 8 additions & 32 deletions

File tree

packages/cli/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ wavegrid start # run server + receiver
2424

2525
| Command | Purpose |
2626
| --- | --- |
27-
| `wavegrid init [name]` | Create a project in the store; **generates secrets once**; optionally add a first user + a local `wavegrid.json`. |
27+
| `wavegrid init [name]` | Create a project in the store; **generates secrets once**; optionally add a first user. |
2828
| `wavegrid start` | Load the active project and run server + receiver in-process. |
2929
| `wavegrid projects` | List projects, marking the active one. |
3030
| `wavegrid use <name>` | Set the active project. |

packages/cli/__tests__/commands.test.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,7 @@ describe('runInit', () => {
8989
mode: 'auto',
9090
createUser: true,
9191
username: 'artist',
92-
password: 'hunter2',
93-
writeLocal: false
92+
password: 'hunter2'
9493
};
9594
const name = await runInit(argv, autoPrompter());
9695
expect(name).toBe('ring-demo');
@@ -113,7 +112,7 @@ describe('buildEnvLines', () => {
113112
it('emits generated secrets for the active project', async () => {
114113
const cwd = isolate();
115114
await runInit(
116-
{ projectName: 'p', shape: 'preset', preset: 'ring-6', mode: 'auto', createUser: false, writeLocal: false },
115+
{ projectName: 'p', shape: 'preset', preset: 'ring-6', mode: 'auto', createUser: false },
117116
autoPrompter()
118117
);
119118
const text = buildEnvLines({}, cwd).join('\n');

packages/cli/src/commands/init.ts

Lines changed: 5 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,8 @@
11
import { resolveLayout } from '@wavegrid/layout';
2-
import { writeFileSync } from 'fs';
32
import type { Inquirerer, Question } from 'inquirerer';
4-
import { join } from 'path';
53
import c from 'yanse';
64

7-
import {
8-
buildConfig,
9-
CONFIG_FILENAME,
10-
type InitAnswers,
11-
knownPresets,
12-
serializeConfig,
13-
type ShapeKind
14-
} from '../config-file';
5+
import { buildConfig, type InitAnswers, knownPresets, type ShapeKind } from '../config-file';
156
import { getStore } from '../project';
167

178
interface RawArgv {
@@ -23,16 +14,15 @@ interface FullInitAnswers extends InitAnswers {
2314
createUser?: boolean;
2415
username?: string;
2516
password?: string;
26-
writeLocal?: boolean;
2717
}
2818

2919
/**
3020
* `wavegrid init [name]` — create a project in the centralized store, generate
31-
* its secrets ONCE, and optionally add a first UI user + a local wavegrid.json.
32-
* Everything the CLI produces is plain configuration + generated secrets; there
33-
* is no shape-specific executable code.
21+
* its secrets ONCE, and optionally add a first UI user. Everything the CLI
22+
* produces lives in the store; there is no shape-specific executable code and
23+
* no duplicate local config file.
3424
*/
35-
export async function runInit(argv: RawArgv, prompter: Inquirerer, cwd = process.cwd()): Promise<string> {
25+
export async function runInit(argv: RawArgv, prompter: Inquirerer): Promise<string> {
3626
const defaultName = typeof argv.project === 'string' ? argv.project : 'default';
3727

3828
const questions: Question[] = [
@@ -114,12 +104,6 @@ export async function runInit(argv: RawArgv, prompter: Inquirerer, cwd = process
114104
name: 'password',
115105
message: 'Password',
116106
when: (a: Partial<FullInitAnswers>) => a.createUser === true
117-
},
118-
{
119-
type: 'confirm',
120-
name: 'writeLocal',
121-
message: 'Also write a local wavegrid.json here?',
122-
default: false
123107
}
124108
];
125109

@@ -142,12 +126,6 @@ export async function runInit(argv: RawArgv, prompter: Inquirerer, cwd = process
142126
store.addUser(projectName, answers.username, answers.password);
143127
}
144128

145-
let localPath: string | undefined;
146-
if (answers.writeLocal) {
147-
localPath = join(cwd, CONFIG_FILENAME);
148-
writeFileSync(localPath, serializeConfig(config));
149-
}
150-
151129
console.log('');
152130
console.log(c.green(` ✓ Created project ${c.bold(projectName)}`));
153131
console.log(` → Layout: ${c.cyan(layout.name)} (${layout.topology}, ${layout.count} cannons)`);
@@ -161,7 +139,6 @@ export async function runInit(argv: RawArgv, prompter: Inquirerer, cwd = process
161139
if (answers.createUser && answers.username) {
162140
console.log(` → User: ${c.cyan(answers.username)}`);
163141
}
164-
if (localPath) console.log(` → Wrote: ${c.cyan(localPath)}`);
165142
console.log('');
166143
console.log(` Start it with ${c.bold(`wavegrid start${projectName === 'default' ? '' : ` --project ${projectName}`}`)}`);
167144
console.log('');

0 commit comments

Comments
 (0)