zedx 0.10.0 → 0.11.0
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/README.md +9 -2
- package/dist/check.js +1 -1
- package/dist/config.d.ts +4 -0
- package/dist/config.js +95 -0
- package/dist/index.js +35 -13
- package/dist/sync.js +3 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -46,7 +46,7 @@ zedx check
|
|
|
46
46
|
|
|
47
47
|
### Sync
|
|
48
48
|
|
|
49
|
-
Sync your Zed config across machines using a private
|
|
49
|
+
Sync your Zed config across machines using a private Git repo as the source of truth.
|
|
50
50
|
|
|
51
51
|
**1. Link a repo (one-time setup)**
|
|
52
52
|
|
|
@@ -54,7 +54,7 @@ Sync your Zed config across machines using a private GitHub repo as the source o
|
|
|
54
54
|
zedx sync init
|
|
55
55
|
```
|
|
56
56
|
|
|
57
|
-
Prompts for a
|
|
57
|
+
Prompts for a Git repo URL (SSH or HTTPS) and a branch name (defaults to `main`). The repo is saved to `~/.config/zedx/config.json`. No files are synced yet.
|
|
58
58
|
|
|
59
59
|
> [!NOTE]
|
|
60
60
|
> `settings.json` and `keymap.json` are tracked. Extension sync is handled via the `auto_install_extensions` field within `settings.json`, which Zed uses to automatically download and install extensions.
|
|
@@ -89,6 +89,13 @@ Installs a file-watcher that triggers `zedx sync` automatically whenever config
|
|
|
89
89
|
|
|
90
90
|
The daemon enforces a 30-second throttle on macOS to avoid rapid re-triggers. When a conflict is detected in daemon mode (no TTY), local always wins and a warning is logged.
|
|
91
91
|
|
|
92
|
+
### Config
|
|
93
|
+
|
|
94
|
+
```bash
|
|
95
|
+
zedx config # Open interactive config menu
|
|
96
|
+
zedx config repo # Change your sync repo and branch directly
|
|
97
|
+
```
|
|
98
|
+
|
|
92
99
|
### Versioning
|
|
93
100
|
|
|
94
101
|
Bump the extension version:
|
package/dist/check.js
CHANGED
|
@@ -42,7 +42,7 @@ export async function runCheck(callerDir) {
|
|
|
42
42
|
extIssues.push({
|
|
43
43
|
file: 'extension.toml',
|
|
44
44
|
message: 'repository still uses the default placeholder URL',
|
|
45
|
-
hint: 'Set it to your actual
|
|
45
|
+
hint: 'Set it to your actual Git repository URL',
|
|
46
46
|
});
|
|
47
47
|
}
|
|
48
48
|
// Detect language entries by looking for uncommented [grammars.*] sections
|
package/dist/config.d.ts
ADDED
package/dist/config.js
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import os from 'os';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import * as p from '@clack/prompts';
|
|
4
|
+
import fs from 'fs-extra';
|
|
5
|
+
import color from 'picocolors';
|
|
6
|
+
import simpleGit from 'simple-git';
|
|
7
|
+
const ZEDX_CONFIG_DIR = path.join(os.homedir(), '.config', 'zedx');
|
|
8
|
+
const ZEDX_CONFIG_PATH = path.join(ZEDX_CONFIG_DIR, 'config.json');
|
|
9
|
+
async function readConfig() {
|
|
10
|
+
if (!(await fs.pathExists(ZEDX_CONFIG_PATH)))
|
|
11
|
+
return null;
|
|
12
|
+
return fs.readJson(ZEDX_CONFIG_PATH);
|
|
13
|
+
}
|
|
14
|
+
async function writeConfig(config) {
|
|
15
|
+
await fs.ensureDir(ZEDX_CONFIG_DIR);
|
|
16
|
+
await fs.writeJson(ZEDX_CONFIG_PATH, config, { spaces: 4 });
|
|
17
|
+
}
|
|
18
|
+
// zedx config repo
|
|
19
|
+
export async function configRepo() {
|
|
20
|
+
console.log('');
|
|
21
|
+
p.intro(`${color.bgBlue(color.bold(' zedx config repo '))} ${color.blue('Change your sync repo and branch…')}`);
|
|
22
|
+
const existing = await readConfig();
|
|
23
|
+
const repo = await p.text({
|
|
24
|
+
message: 'Git repo URL (SSH or HTTPS)',
|
|
25
|
+
placeholder: 'https://github.com/you/zed-config.git',
|
|
26
|
+
initialValue: existing?.syncRepo ?? '',
|
|
27
|
+
validate: v => {
|
|
28
|
+
if (!v.trim())
|
|
29
|
+
return 'Repo URL is required';
|
|
30
|
+
if (!v.startsWith('https://') && !v.startsWith('git@')) {
|
|
31
|
+
return 'Must be a valid HTTPS or SSH git URL';
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
});
|
|
35
|
+
if (p.isCancel(repo)) {
|
|
36
|
+
p.cancel('Cancelled.');
|
|
37
|
+
process.exit(0);
|
|
38
|
+
}
|
|
39
|
+
const branch = await p.text({
|
|
40
|
+
message: 'Branch name',
|
|
41
|
+
placeholder: 'main',
|
|
42
|
+
initialValue: existing?.branch ?? 'main',
|
|
43
|
+
defaultValue: 'main',
|
|
44
|
+
});
|
|
45
|
+
if (p.isCancel(branch)) {
|
|
46
|
+
p.cancel('Cancelled.');
|
|
47
|
+
process.exit(0);
|
|
48
|
+
}
|
|
49
|
+
const spinner = p.spinner();
|
|
50
|
+
spinner.start('Verifying repo is reachable...');
|
|
51
|
+
try {
|
|
52
|
+
const git = simpleGit();
|
|
53
|
+
await git.listRemote(['--heads', repo]);
|
|
54
|
+
spinner.stop('Repo verified.');
|
|
55
|
+
}
|
|
56
|
+
catch {
|
|
57
|
+
spinner.stop(color.red('Could not reach repo. Check the URL and your access.'));
|
|
58
|
+
process.exit(1);
|
|
59
|
+
}
|
|
60
|
+
const updated = {
|
|
61
|
+
...existing,
|
|
62
|
+
syncRepo: repo.trim(),
|
|
63
|
+
branch: (branch || 'main').trim(),
|
|
64
|
+
};
|
|
65
|
+
await writeConfig(updated);
|
|
66
|
+
p.outro(`${color.green('✓')} Sync repo updated.\n\n` +
|
|
67
|
+
` Repo: ${color.cyan(updated.syncRepo)}\n` +
|
|
68
|
+
` Branch: ${color.cyan(updated.branch)}`);
|
|
69
|
+
}
|
|
70
|
+
// zedx config (interactive menu)
|
|
71
|
+
export async function runConfig(direct) {
|
|
72
|
+
if (direct === 'repo') {
|
|
73
|
+
await configRepo();
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
console.log('');
|
|
77
|
+
p.intro(`${color.bgBlue(color.bold(' zedx config '))} ${color.blue('Zedx settings')}`);
|
|
78
|
+
const option = await p.select({
|
|
79
|
+
message: 'What do you want to configure?',
|
|
80
|
+
options: [
|
|
81
|
+
{
|
|
82
|
+
value: 'repo',
|
|
83
|
+
label: 'Sync repo',
|
|
84
|
+
hint: 'Change your git repo and branch for zedx sync',
|
|
85
|
+
},
|
|
86
|
+
],
|
|
87
|
+
});
|
|
88
|
+
if (p.isCancel(option)) {
|
|
89
|
+
p.cancel('Cancelled.');
|
|
90
|
+
process.exit(0);
|
|
91
|
+
}
|
|
92
|
+
if (option === 'repo') {
|
|
93
|
+
await configRepo();
|
|
94
|
+
}
|
|
95
|
+
}
|
package/dist/index.js
CHANGED
|
@@ -7,6 +7,7 @@ import fs from 'fs-extra';
|
|
|
7
7
|
import color from 'picocolors';
|
|
8
8
|
import { addTheme, addLanguage } from './add.js';
|
|
9
9
|
import { runCheck } from './check.js';
|
|
10
|
+
import { runConfig, configRepo } from './config.js';
|
|
10
11
|
import { syncInstall, syncUninstall } from './daemon.js';
|
|
11
12
|
import { generateExtension } from './generator.js';
|
|
12
13
|
import { installDevExtension } from './install.js';
|
|
@@ -59,7 +60,17 @@ function printWelcome() {
|
|
|
59
60
|
`.trim();
|
|
60
61
|
console.log('\n' + color.cyan(color.bold(ascii)) + '\n');
|
|
61
62
|
console.log(color.bold(' The CLI toolkit for Zed Editor') + '\n');
|
|
62
|
-
const
|
|
63
|
+
const syncCommands = [
|
|
64
|
+
['zedx sync', 'Sync Zed settings via a git repo'],
|
|
65
|
+
['zedx sync init', 'Link a git repo as the sync target'],
|
|
66
|
+
['zedx sync select', 'Choose which files to sync interactively'],
|
|
67
|
+
['zedx sync status', 'Show sync state between local and remote'],
|
|
68
|
+
['zedx sync install', 'Install the OS daemon for auto-sync'],
|
|
69
|
+
['zedx sync uninstall', 'Remove the auto-sync daemon'],
|
|
70
|
+
['zedx config', 'Configure zedx settings'],
|
|
71
|
+
['zedx config repo', 'Change your sync repo and branch'],
|
|
72
|
+
];
|
|
73
|
+
const extensionCommands = [
|
|
63
74
|
['zedx create', 'Scaffold a new Zed extension'],
|
|
64
75
|
['zedx add theme <name>', 'Add a theme to an existing extension'],
|
|
65
76
|
['zedx add language <id>', 'Add a language to an existing extension'],
|
|
@@ -67,18 +78,17 @@ function printWelcome() {
|
|
|
67
78
|
['zedx check', 'Validate your extension config'],
|
|
68
79
|
['zedx install', 'Install as a Zed dev extension'],
|
|
69
80
|
['zedx version <major|minor|patch>', 'Bump extension version'],
|
|
70
|
-
['zedx sync', 'Sync Zed settings via a git repo'],
|
|
71
|
-
['zedx sync select', 'Choose which files to sync interactively'],
|
|
72
|
-
['zedx sync init', 'Link a git repo as the sync target'],
|
|
73
|
-
['zedx sync status', 'Show sync state between local and remote'],
|
|
74
|
-
['zedx sync install', 'Install the OS daemon for auto-sync'],
|
|
75
|
-
['zedx sync uninstall', 'Remove the auto-sync daemon'],
|
|
76
81
|
];
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
82
|
+
const pad = 38;
|
|
83
|
+
console.log(` ${color.bold('Sync')}\n`);
|
|
84
|
+
for (const [cmd, desc] of syncCommands) {
|
|
85
|
+
console.log(` ${color.cyan(cmd.padEnd(pad))}${color.dim(desc)}`);
|
|
86
|
+
}
|
|
87
|
+
console.log(`\n ${color.bold('Extensions')}\n`);
|
|
88
|
+
for (const [cmd, desc] of extensionCommands) {
|
|
89
|
+
console.log(` ${color.cyan(cmd.padEnd(pad))}${color.dim(desc)}`);
|
|
80
90
|
}
|
|
81
|
-
console.log(`\n ${color.dim('
|
|
91
|
+
console.log(`\n ${color.dim('Zedx Repo:')} ${color.underline(color.blue('https://github.com/tahayvr/zedx'))}\n`);
|
|
82
92
|
}
|
|
83
93
|
async function runCreate() {
|
|
84
94
|
const options = await promptUser();
|
|
@@ -159,7 +169,7 @@ async function main() {
|
|
|
159
169
|
});
|
|
160
170
|
const syncCmd = program
|
|
161
171
|
.command('sync')
|
|
162
|
-
.description('Sync Zed settings and extensions via a
|
|
172
|
+
.description('Sync Zed settings and extensions via a Git repo')
|
|
163
173
|
.option('--local', 'On conflict, always keep the local version')
|
|
164
174
|
.option('--remote', 'On conflict, always use the remote version')
|
|
165
175
|
.action(async (opts) => {
|
|
@@ -176,7 +186,7 @@ async function main() {
|
|
|
176
186
|
});
|
|
177
187
|
syncCmd
|
|
178
188
|
.command('init')
|
|
179
|
-
.description('Link a
|
|
189
|
+
.description('Link a Git repo as the sync target')
|
|
180
190
|
.action(async () => {
|
|
181
191
|
await syncInit();
|
|
182
192
|
});
|
|
@@ -204,6 +214,18 @@ async function main() {
|
|
|
204
214
|
.action(async () => {
|
|
205
215
|
await syncUninstall();
|
|
206
216
|
});
|
|
217
|
+
const configCmd = program
|
|
218
|
+
.command('config')
|
|
219
|
+
.description('Configure zedx settings')
|
|
220
|
+
.action(async () => {
|
|
221
|
+
await runConfig();
|
|
222
|
+
});
|
|
223
|
+
configCmd
|
|
224
|
+
.command('repo')
|
|
225
|
+
.description('Change your sync repo and branch')
|
|
226
|
+
.action(async () => {
|
|
227
|
+
await configRepo();
|
|
228
|
+
});
|
|
207
229
|
const argv = process.argv.filter(arg => arg !== '--');
|
|
208
230
|
if (argv.length <= 2) {
|
|
209
231
|
printWelcome();
|
package/dist/sync.js
CHANGED
|
@@ -204,7 +204,7 @@ export async function syncInit() {
|
|
|
204
204
|
console.log('');
|
|
205
205
|
p.intro(`${color.bgBlue(color.bold(' zedx sync init '))} ${color.blue('Linking a git repo as the sync target…')}`);
|
|
206
206
|
const repo = await p.text({
|
|
207
|
-
message: '
|
|
207
|
+
message: 'Git repo URL (SSH or HTTPS)',
|
|
208
208
|
placeholder: 'https://github.com/you/zed-config.git',
|
|
209
209
|
validate: v => {
|
|
210
210
|
if (!v.trim())
|
|
@@ -235,7 +235,8 @@ export async function syncInit() {
|
|
|
235
235
|
spinner.stop('Repo verified.');
|
|
236
236
|
}
|
|
237
237
|
catch {
|
|
238
|
-
spinner.stop(color.
|
|
238
|
+
spinner.stop(color.red('Could not reach repo. Check the URL and your access.'));
|
|
239
|
+
process.exit(1);
|
|
239
240
|
}
|
|
240
241
|
const config = {
|
|
241
242
|
syncRepo: repo.trim(),
|