zixulu 1.71.7 → 1.72.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/dist/index.js +67 -36
- package/dist/index.js.map +1 -1
- package/dist/src/utils/hasAntiGravity.d.ts +2 -0
- package/dist/src/utils/syncEditorSetting.d.ts +8 -4
- package/package.json +1 -1
- package/src/utils/addAntd.ts +3 -7
- package/src/utils/addEslint.ts +1 -1
- package/src/utils/getEditorExtensions.ts +0 -1
- package/src/utils/hasAntiGravity.ts +10 -0
- package/src/utils/rsbuild.ts +1 -1
- package/src/utils/syncEditorSetting.ts +86 -28
package/dist/index.js
CHANGED
|
@@ -302,7 +302,6 @@ async function addAntd() {
|
|
|
302
302
|
await addDependency({
|
|
303
303
|
package: [
|
|
304
304
|
"@ant-design/icons",
|
|
305
|
-
"@ant-design/v5-patch-for-react-19",
|
|
306
305
|
"antd"
|
|
307
306
|
]
|
|
308
307
|
});
|
|
@@ -329,8 +328,6 @@ import { AntdRegistry } from "@ant-design/nextjs-registry"
|
|
|
329
328
|
import { ConfigProvider } from "antd"
|
|
330
329
|
import zhCN from "antd/locale/zh_CN"
|
|
331
330
|
|
|
332
|
-
import "@ant-design/v5-patch-for-react-19"
|
|
333
|
-
|
|
334
331
|
export interface RegistryProps {
|
|
335
332
|
children?: ReactNode
|
|
336
333
|
}
|
|
@@ -338,7 +335,7 @@ export interface RegistryProps {
|
|
|
338
335
|
const Registry: FC<RegistryProps> = ({ children }) => {
|
|
339
336
|
|
|
340
337
|
return (
|
|
341
|
-
<AntdRegistry
|
|
338
|
+
<AntdRegistry layer>
|
|
342
339
|
<ConfigProvider locale={zhCN}>{children}</ConfigProvider>
|
|
343
340
|
</AntdRegistry>
|
|
344
341
|
)
|
|
@@ -351,8 +348,6 @@ import { ConfigProvider } from "antd"
|
|
|
351
348
|
import zhCN from "antd/locale/zh_CN"
|
|
352
349
|
import { FC, ReactNode } from "react"
|
|
353
350
|
|
|
354
|
-
import "@ant-design/v5-patch-for-react-19"
|
|
355
|
-
|
|
356
351
|
export interface RegistryProps {
|
|
357
352
|
children?: ReactNode
|
|
358
353
|
}
|
|
@@ -360,7 +355,7 @@ export interface RegistryProps {
|
|
|
360
355
|
const Registry: FC<RegistryProps> = ({ children }) => {
|
|
361
356
|
|
|
362
357
|
return (
|
|
363
|
-
<StyleProvider
|
|
358
|
+
<StyleProvider layer>
|
|
364
359
|
<ConfigProvider locale={zhCN}>{children}</ConfigProvider>
|
|
365
360
|
</StyleProvider>
|
|
366
361
|
)
|
|
@@ -1194,9 +1189,7 @@ async function addEslint() {
|
|
|
1194
1189
|
"typescript-eslint",
|
|
1195
1190
|
"globals"
|
|
1196
1191
|
];
|
|
1197
|
-
if (isReact) packages.push(
|
|
1198
|
-
packageName: "eslint-plugin-react-hooks"
|
|
1199
|
-
}, "eslint-plugin-react-refresh");
|
|
1192
|
+
if (isReact) packages.push("eslint-plugin-react-hooks", "eslint-plugin-react-refresh");
|
|
1200
1193
|
await addDependency({
|
|
1201
1194
|
package: packages,
|
|
1202
1195
|
type: "devDependencies"
|
|
@@ -2904,10 +2897,7 @@ async function rsbuild() {
|
|
|
2904
2897
|
package: [
|
|
2905
2898
|
"@rsbuild/plugin-svgr",
|
|
2906
2899
|
"@rsbuild/plugin-babel",
|
|
2907
|
-
|
|
2908
|
-
packageName: "babel-plugin-react-compiler",
|
|
2909
|
-
versionRange: "@rc"
|
|
2910
|
-
}
|
|
2900
|
+
"babel-plugin-react-compiler"
|
|
2911
2901
|
],
|
|
2912
2902
|
type: "devDependencies"
|
|
2913
2903
|
});
|
|
@@ -4317,7 +4307,7 @@ async function getEditorExtensions({ source }) {
|
|
|
4317
4307
|
let data = [];
|
|
4318
4308
|
if ("Online" !== source) {
|
|
4319
4309
|
const output = await execAsync(`${source} --list-extensions`);
|
|
4320
|
-
data = output.split("\n").map((item)=>item.trim()).filter(Boolean)
|
|
4310
|
+
data = output.split("\n").map((item)=>item.trim()).filter(Boolean);
|
|
4321
4311
|
} else {
|
|
4322
4312
|
const response = await fetch("https://luzixu.geskj.com/extensions.json");
|
|
4323
4313
|
data = await response.json();
|
|
@@ -4325,6 +4315,11 @@ async function getEditorExtensions({ source }) {
|
|
|
4325
4315
|
data = data.filter((item)=>!item.startsWith("anysphere.") && "github.copilot" !== item && "github.copilot-chat" !== item);
|
|
4326
4316
|
return new Set(data);
|
|
4327
4317
|
}
|
|
4318
|
+
function hasAntiGravity() {
|
|
4319
|
+
const userDir = homedir();
|
|
4320
|
+
const path = join(userDir, "AppData/Roaming/Antigravity");
|
|
4321
|
+
return existsSync(path);
|
|
4322
|
+
}
|
|
4328
4323
|
function hasCode() {
|
|
4329
4324
|
const userDir = homedir();
|
|
4330
4325
|
const path = join(userDir, "AppData/Roaming/Code");
|
|
@@ -4340,11 +4335,13 @@ const fileSourceMap = {
|
|
|
4340
4335
|
settings: {
|
|
4341
4336
|
Code: join(syncEditorSetting_userDir, "AppData/Roaming/Code/User/settings.json"),
|
|
4342
4337
|
Cursor: join(syncEditorSetting_userDir, "AppData/Roaming/Cursor/User/settings.json"),
|
|
4338
|
+
Antigravity: join(syncEditorSetting_userDir, "AppData/Roaming/Antigravity/User/settings.json"),
|
|
4343
4339
|
Online: "https://luzixu.geskj.com/settings.json"
|
|
4344
4340
|
},
|
|
4345
4341
|
snippets: {
|
|
4346
4342
|
Code: join(syncEditorSetting_userDir, "AppData/Roaming/Code/User/snippets/global.code-snippets"),
|
|
4347
4343
|
Cursor: join(syncEditorSetting_userDir, "AppData/Roaming/Cursor/User/snippets/global.code-snippets"),
|
|
4344
|
+
Antigravity: join(syncEditorSetting_userDir, "AppData/Roaming/Antigravity/User/snippets/global.code-snippets"),
|
|
4348
4345
|
Online: "https://luzixu.geskj.com/global.code-snippets"
|
|
4349
4346
|
}
|
|
4350
4347
|
};
|
|
@@ -4355,34 +4352,42 @@ async function getFile(source) {
|
|
|
4355
4352
|
}
|
|
4356
4353
|
return await readFile(source, "utf-8");
|
|
4357
4354
|
}
|
|
4358
|
-
async function syncEditorFile({ source, target }) {
|
|
4359
|
-
const { dir, base } = parse(
|
|
4355
|
+
async function syncEditorFile({ source: { type: sourceType, value: sourceValue }, target: { type: targetType, value: targetValue } }) {
|
|
4356
|
+
const { dir, base } = parse(targetValue);
|
|
4360
4357
|
await mkdir(dir, {
|
|
4361
4358
|
recursive: true
|
|
4362
4359
|
});
|
|
4363
4360
|
const setting = await readZixuluSetting();
|
|
4364
|
-
let code = await getFile(
|
|
4365
|
-
if (
|
|
4366
|
-
if (
|
|
4367
|
-
|
|
4368
|
-
|
|
4361
|
+
let code = await getFile(sourceValue);
|
|
4362
|
+
if ("Code" === targetType) code = code.replace(/\n^ *"extensions\.gallery\.serviceUrl":.+,?$/m, "");
|
|
4363
|
+
if ("Antigravity" === targetType) code = code.replace(/\n^ *"extensions\.gallery\.serviceUrl":.+,?$/m, "").replace(/} *$/, ` "antigravity.marketplaceExtensionGalleryServiceURL": "https://marketplace.visualstudio.com/_apis/public/gallery",
|
|
4364
|
+
"antigravity.marketplaceGalleryItemURL": "https://marketplace.visualstudio.com/items",
|
|
4365
|
+
"json.schemaDownload.enable": true,
|
|
4366
|
+
}`);
|
|
4367
|
+
if (existsSync(targetValue)) {
|
|
4368
|
+
const text = await readFile(targetValue, "utf-8");
|
|
4369
|
+
if (text === code) return void consola_0.success(`${targetValue} 已是最新`);
|
|
4369
4370
|
{
|
|
4370
|
-
|
|
4371
|
-
|
|
4372
|
-
|
|
4373
|
-
|
|
4374
|
-
|
|
4375
|
-
|
|
4371
|
+
let backup = false;
|
|
4372
|
+
if ("Online" !== targetType) {
|
|
4373
|
+
const answer = await inquirer_0.prompt({
|
|
4374
|
+
type: "confirm",
|
|
4375
|
+
name: "backup",
|
|
4376
|
+
message: `是否备份原文件(${targetValue})`,
|
|
4377
|
+
default: setting.syncEditor?.fileConfigs?.[targetValue]?.backup ?? true
|
|
4378
|
+
});
|
|
4379
|
+
backup = answer.backup;
|
|
4380
|
+
}
|
|
4376
4381
|
setting.syncEditor ??= {};
|
|
4377
4382
|
setting.syncEditor.fileConfigs ??= {};
|
|
4378
|
-
setting.syncEditor.fileConfigs[
|
|
4379
|
-
setting.syncEditor.fileConfigs[
|
|
4383
|
+
setting.syncEditor.fileConfigs[targetValue] ??= {};
|
|
4384
|
+
setting.syncEditor.fileConfigs[targetValue].backup = backup;
|
|
4380
4385
|
await writeZixuluSetting(setting);
|
|
4381
|
-
if (backup) await rename(
|
|
4386
|
+
if (backup) await rename(targetValue, join(dir, `${base}.${Date.now()}.bak`));
|
|
4382
4387
|
}
|
|
4383
4388
|
}
|
|
4384
|
-
await writeFile(
|
|
4385
|
-
consola_0.success(`${
|
|
4389
|
+
await writeFile(targetValue, code, "utf-8");
|
|
4390
|
+
consola_0.success(`${targetValue} 同步完成`);
|
|
4386
4391
|
}
|
|
4387
4392
|
async function syncEditorSetting() {
|
|
4388
4393
|
const setting = await readZixuluSetting();
|
|
@@ -4391,6 +4396,7 @@ async function syncEditorSetting() {
|
|
|
4391
4396
|
];
|
|
4392
4397
|
if (hasCode()) sourceChoices.unshift("Code");
|
|
4393
4398
|
if (hasCursor()) sourceChoices.unshift("Cursor");
|
|
4399
|
+
if (hasAntiGravity()) sourceChoices.unshift("Antigravity");
|
|
4394
4400
|
const { source } = await inquirer_0.prompt([
|
|
4395
4401
|
{
|
|
4396
4402
|
type: "list",
|
|
@@ -4442,8 +4448,14 @@ async function syncEditorSetting() {
|
|
|
4442
4448
|
if (!setting.syncEditor.onlinePath) setting.syncEditor.targets = targets.filter((v)=>"Online" !== v);
|
|
4443
4449
|
const onlinePath = setting.syncEditor.onlinePath;
|
|
4444
4450
|
const configs = types.filter((item)=>"extensions" !== item).map((fileType)=>targets.map((target)=>({
|
|
4445
|
-
source:
|
|
4446
|
-
|
|
4451
|
+
source: {
|
|
4452
|
+
type: source,
|
|
4453
|
+
value: fileSourceMap[fileType][source]
|
|
4454
|
+
},
|
|
4455
|
+
target: {
|
|
4456
|
+
type: target,
|
|
4457
|
+
value: "Online" === target ? join(onlinePath, "static", "settings" === fileType ? "settings.json" : "global.code-snippets") : fileSourceMap[fileType][target]
|
|
4458
|
+
}
|
|
4447
4459
|
}))).flat();
|
|
4448
4460
|
for (const config of configs)await syncEditorFile(config);
|
|
4449
4461
|
if (types.includes("extensions")) {
|
|
@@ -4453,10 +4465,13 @@ async function syncEditorSetting() {
|
|
|
4453
4465
|
const cursorExtensions = await getEditorExtensions({
|
|
4454
4466
|
source: "Cursor"
|
|
4455
4467
|
});
|
|
4468
|
+
const antigravityExtensions = await getEditorExtensions({
|
|
4469
|
+
source: "Antigravity"
|
|
4470
|
+
});
|
|
4456
4471
|
const onlineExtensions = await getEditorExtensions({
|
|
4457
4472
|
source: "Online"
|
|
4458
4473
|
});
|
|
4459
|
-
const sourceExtensions = "Code" === source ? vscodeExtensions : "Cursor" === source ? cursorExtensions : onlineExtensions;
|
|
4474
|
+
const sourceExtensions = "Code" === source ? vscodeExtensions : "Cursor" === source ? cursorExtensions : "Antigravity" === source ? antigravityExtensions : onlineExtensions;
|
|
4460
4475
|
if (targets.includes("Code")) {
|
|
4461
4476
|
const installExtensions = sourceExtensions.difference(vscodeExtensions);
|
|
4462
4477
|
for (const ext of installExtensions)try {
|
|
@@ -4489,6 +4504,22 @@ async function syncEditorSetting() {
|
|
|
4489
4504
|
console.error(`${ext} 卸载失败`);
|
|
4490
4505
|
}
|
|
4491
4506
|
}
|
|
4507
|
+
if (targets.includes("Antigravity")) {
|
|
4508
|
+
const installExtensions = sourceExtensions.difference(antigravityExtensions);
|
|
4509
|
+
for (const ext of installExtensions)try {
|
|
4510
|
+
console.log(`antigravity --install-extension ${ext}`);
|
|
4511
|
+
await execAsync(`antigravity --install-extension ${ext}`);
|
|
4512
|
+
} catch (error) {
|
|
4513
|
+
console.error(`${ext} 安装失败`);
|
|
4514
|
+
}
|
|
4515
|
+
const uninstallExtensions = antigravityExtensions.difference(sourceExtensions);
|
|
4516
|
+
for (const ext of uninstallExtensions)try {
|
|
4517
|
+
console.log(`antigravity --uninstall-extension ${ext}`);
|
|
4518
|
+
await execAsync(`antigravity --uninstall-extension ${ext}`);
|
|
4519
|
+
} catch (error) {
|
|
4520
|
+
console.error(`${ext} 卸载失败`);
|
|
4521
|
+
}
|
|
4522
|
+
}
|
|
4492
4523
|
if (targets.includes("Online")) await writeFile(join(onlinePath, "static", "extensions.json"), JSON.stringify(Array.from(sourceExtensions), null, 4));
|
|
4493
4524
|
}
|
|
4494
4525
|
if (targets.includes("Online")) {
|