zixulu 1.71.5 → 1.71.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.
- package/dist/index.js +36 -23
- package/dist/index.js.map +1 -1
- package/dist/src/utils/hasCode.d.ts +2 -0
- package/dist/src/utils/hasCursor.d.ts +2 -0
- package/dist/test.d.ts +1 -0
- package/package.json +1 -1
- package/src/utils/addPrettier.ts +2 -2
- package/src/utils/hasCode.ts +10 -0
- package/src/utils/hasCursor.ts +10 -0
- package/src/utils/syncEditorSetting.ts +27 -8
- package/src/utils/syncVscode.ts +6 -3
package/dist/index.js
CHANGED
|
@@ -1458,7 +1458,7 @@ generated
|
|
|
1458
1458
|
const prettierConfig = `// @ts-check
|
|
1459
1459
|
|
|
1460
1460
|
/**
|
|
1461
|
-
* @type {import("prettier").Options}
|
|
1461
|
+
* @type {import("@1adybug/prettier").Options}
|
|
1462
1462
|
*/
|
|
1463
1463
|
const config = {
|
|
1464
1464
|
semi: false,
|
|
@@ -1468,7 +1468,7 @@ const config = {
|
|
|
1468
1468
|
printWidth: 160,
|
|
1469
1469
|
plugins: ["@1adybug/prettier"],
|
|
1470
1470
|
controlStatementBraces: "add",
|
|
1471
|
-
|
|
1471
|
+
multiLineBraces: "add",
|
|
1472
1472
|
}
|
|
1473
1473
|
|
|
1474
1474
|
export default config
|
|
@@ -4325,6 +4325,16 @@ async function getEditorExtensions({ source }) {
|
|
|
4325
4325
|
data = data.filter((item)=>!item.startsWith("anysphere.") && "github.copilot" !== item && "github.copilot-chat" !== item);
|
|
4326
4326
|
return new Set(data);
|
|
4327
4327
|
}
|
|
4328
|
+
function hasCode() {
|
|
4329
|
+
const userDir = homedir();
|
|
4330
|
+
const path = join(userDir, "AppData/Roaming/Code");
|
|
4331
|
+
return existsSync(path);
|
|
4332
|
+
}
|
|
4333
|
+
function hasCursor() {
|
|
4334
|
+
const userDir = homedir();
|
|
4335
|
+
const path = join(userDir, "AppData/Roaming/Cursor");
|
|
4336
|
+
return existsSync(path);
|
|
4337
|
+
}
|
|
4328
4338
|
const syncEditorSetting_userDir = homedir();
|
|
4329
4339
|
const fileSourceMap = {
|
|
4330
4340
|
settings: {
|
|
@@ -4347,8 +4357,12 @@ async function getFile(source) {
|
|
|
4347
4357
|
}
|
|
4348
4358
|
async function syncEditorFile({ source, target }) {
|
|
4349
4359
|
const { dir, base } = parse(target);
|
|
4360
|
+
await mkdir(dir, {
|
|
4361
|
+
recursive: true
|
|
4362
|
+
});
|
|
4350
4363
|
const setting = await readZixuluSetting();
|
|
4351
|
-
|
|
4364
|
+
let code = await getFile(source);
|
|
4365
|
+
if (target === fileSourceMap.settings.Code) code = code.replace(/\n^ *"extensions\.gallery\.serviceUrl":.+,?$/m, "");
|
|
4352
4366
|
if (existsSync(target)) {
|
|
4353
4367
|
const text = await readFile(target, "utf-8");
|
|
4354
4368
|
if (text === code) return void consola_0.success(`${target} 已是最新`);
|
|
@@ -4372,36 +4386,31 @@ async function syncEditorFile({ source, target }) {
|
|
|
4372
4386
|
}
|
|
4373
4387
|
async function syncEditorSetting() {
|
|
4374
4388
|
const setting = await readZixuluSetting();
|
|
4389
|
+
const sourceChoices = [
|
|
4390
|
+
"Online"
|
|
4391
|
+
];
|
|
4392
|
+
if (hasCode()) sourceChoices.unshift("Code");
|
|
4393
|
+
if (hasCursor()) sourceChoices.unshift("Cursor");
|
|
4375
4394
|
const { source } = await inquirer_0.prompt([
|
|
4376
4395
|
{
|
|
4377
4396
|
type: "list",
|
|
4378
4397
|
name: "source",
|
|
4379
4398
|
message: "选择同步来源",
|
|
4380
|
-
choices:
|
|
4381
|
-
"Code",
|
|
4382
|
-
"Cursor",
|
|
4383
|
-
"Online"
|
|
4384
|
-
],
|
|
4399
|
+
choices: sourceChoices,
|
|
4385
4400
|
default: setting.syncEditor?.source ?? "Cursor"
|
|
4386
4401
|
}
|
|
4387
4402
|
]);
|
|
4388
4403
|
setting.syncEditor ??= {};
|
|
4389
4404
|
setting.syncEditor.source = source;
|
|
4405
|
+
const targetChoices = sourceChoices.filter((v)=>v !== source);
|
|
4406
|
+
if (0 === targetChoices.length) return consola_0.info("没有可同步的目标");
|
|
4390
4407
|
const { targets, types } = await inquirer_0.prompt([
|
|
4391
4408
|
{
|
|
4392
4409
|
type: "checkbox",
|
|
4393
4410
|
name: "targets",
|
|
4394
4411
|
message: "选择同步目标",
|
|
4395
|
-
choices:
|
|
4396
|
-
|
|
4397
|
-
"Cursor",
|
|
4398
|
-
"Online"
|
|
4399
|
-
].filter((v)=>v !== source),
|
|
4400
|
-
default: (setting.syncEditor?.targets ?? [
|
|
4401
|
-
"Code",
|
|
4402
|
-
"Cursor",
|
|
4403
|
-
"Online"
|
|
4404
|
-
]).filter((v)=>v !== source)
|
|
4412
|
+
choices: targetChoices,
|
|
4413
|
+
default: setting.syncEditor?.targets?.filter((item)=>targetChoices.includes(item)) ?? targetChoices
|
|
4405
4414
|
},
|
|
4406
4415
|
{
|
|
4407
4416
|
type: "checkbox",
|
|
@@ -4425,11 +4434,12 @@ async function syncEditorSetting() {
|
|
|
4425
4434
|
const { onlinePath } = await inquirer_0.prompt({
|
|
4426
4435
|
type: "input",
|
|
4427
4436
|
name: "onlinePath",
|
|
4428
|
-
message: "请输入 blog
|
|
4429
|
-
default: setting.syncEditor?.onlinePath
|
|
4437
|
+
message: "请输入 blog 文件夹的路径(留空则跳过)",
|
|
4438
|
+
default: setting.syncEditor?.onlinePath
|
|
4430
4439
|
});
|
|
4431
|
-
setting.syncEditor.onlinePath = onlinePath;
|
|
4440
|
+
setting.syncEditor.onlinePath = onlinePath.trim() ?? void 0;
|
|
4432
4441
|
}
|
|
4442
|
+
if (!setting.syncEditor.onlinePath) setting.syncEditor.targets = targets.filter((v)=>"Online" !== v);
|
|
4433
4443
|
const onlinePath = setting.syncEditor.onlinePath;
|
|
4434
4444
|
const configs = types.filter((item)=>"extensions" !== item).map((fileType)=>targets.map((target)=>({
|
|
4435
4445
|
source: fileSourceMap[fileType][source],
|
|
@@ -4482,6 +4492,9 @@ async function syncEditorSetting() {
|
|
|
4482
4492
|
if (targets.includes("Online")) await writeFile(join(onlinePath, "static", "extensions.json"), JSON.stringify(Array.from(sourceExtensions), null, 4));
|
|
4483
4493
|
}
|
|
4484
4494
|
if (targets.includes("Online")) {
|
|
4495
|
+
await execAsync("npm run format", {
|
|
4496
|
+
cwd: onlinePath
|
|
4497
|
+
});
|
|
4485
4498
|
if (await hasChangeNoCommit(onlinePath)) {
|
|
4486
4499
|
await addGitCommit({
|
|
4487
4500
|
message: getCommitMessage("feature", "sync editor setting"),
|
|
@@ -4566,7 +4579,7 @@ async function syncVscode() {
|
|
|
4566
4579
|
if (0 === options.length) return;
|
|
4567
4580
|
const userDir = homedir();
|
|
4568
4581
|
const snippetSource = join(userDir, "AppData/Roaming/Code/User/snippets");
|
|
4569
|
-
const setting = join(userDir, "AppData/Roaming/Code/User/settings.json");
|
|
4582
|
+
const setting = (await readFile(join(userDir, "AppData/Roaming/Code/User/settings.json"), "utf-8")).replace(/}[ \n\r]*$/, ` "chat.disableAIFeatures": true,\n}`);
|
|
4570
4583
|
const dir = `vscode-${dayjs().format("YYYYMMDDHHmmss")}`;
|
|
4571
4584
|
try {
|
|
4572
4585
|
await mkdir(dir, {
|
|
@@ -4578,7 +4591,7 @@ async function syncVscode() {
|
|
|
4578
4591
|
recursive: true
|
|
4579
4592
|
});
|
|
4580
4593
|
consola_0.start("开始下载最新 VSCode 配置");
|
|
4581
|
-
await
|
|
4594
|
+
await writeFile(join(dir, "settings.json"), setting, "utf-8");
|
|
4582
4595
|
const files = await readdir(snippetSource);
|
|
4583
4596
|
for (const file of files)await copyFile(join(snippetSource, file), join(snippetTarget, file));
|
|
4584
4597
|
consola_0.success("下载最新 VSCode 配置完成");
|