zixulu 1.74.0 → 1.75.1
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 +40 -8
- package/dist/index.js.map +1 -1
- package/dist/src/utils/modifyJsonc.d.ts +2 -0
- package/dist/src/utils/syncEditorSetting.d.ts +2 -1
- package/dist/test.d.ts +1 -0
- package/package.json +2 -1
- package/src/utils/addEslint.ts +3 -1
- package/src/utils/modifyJsonc.ts +15 -0
- package/src/utils/syncEditorSetting.ts +12 -10
package/dist/index.js
CHANGED
|
@@ -24,6 +24,7 @@ import { Readable } from "stream";
|
|
|
24
24
|
import { JSDOM } from "jsdom";
|
|
25
25
|
import { exec } from "child_process";
|
|
26
26
|
import md5 from "md5";
|
|
27
|
+
import { applyEdits, modify } from "jsonc-parser";
|
|
27
28
|
async function addGitCommit(messageOrParams) {
|
|
28
29
|
const { message, cwd } = "string" == typeof messageOrParams ? {
|
|
29
30
|
message: messageOrParams
|
|
@@ -1100,11 +1101,13 @@ export default defineConfig([
|
|
|
1100
1101
|
globals: globals.browser,
|
|
1101
1102
|
},
|
|
1102
1103
|
rules: {
|
|
1104
|
+
"@typescript-eslint/no-explicit-any": "off",
|
|
1103
1105
|
"@typescript-eslint/no-empty-object-type": "off",
|
|
1106
|
+
"@typescript-eslint/no-non-null-asserted-optional-chain": "off",
|
|
1104
1107
|
"no-empty": "off",
|
|
1105
1108
|
"no-extra-boolean-cast": "off",
|
|
1106
1109
|
"no-unused-vars": "off",${isReact ? `
|
|
1107
|
-
"react-refresh/only-export-components": "
|
|
1110
|
+
"react-refresh/only-export-components": "off",` : ""}
|
|
1108
1111
|
"@typescript-eslint/no-unused-vars": [
|
|
1109
1112
|
"warn",
|
|
1110
1113
|
{
|
|
@@ -4355,6 +4358,21 @@ function hasCursor() {
|
|
|
4355
4358
|
const path = join(userDir, "AppData/Roaming/Cursor");
|
|
4356
4359
|
return existsSync(path);
|
|
4357
4360
|
}
|
|
4361
|
+
function modifyJsonc(text, path, value, options) {
|
|
4362
|
+
options = {
|
|
4363
|
+
...options
|
|
4364
|
+
};
|
|
4365
|
+
options.formattingOptions = {
|
|
4366
|
+
...options.formattingOptions
|
|
4367
|
+
};
|
|
4368
|
+
options.formattingOptions.tabSize ??= 4;
|
|
4369
|
+
options.formattingOptions.insertSpaces ??= true;
|
|
4370
|
+
options.formattingOptions.insertFinalNewline ??= true;
|
|
4371
|
+
options.formattingOptions.keepLines ??= true;
|
|
4372
|
+
options.formattingOptions.eol ??= "\n";
|
|
4373
|
+
const edits = modify(text, path, value, options);
|
|
4374
|
+
return applyEdits(text, edits);
|
|
4375
|
+
}
|
|
4358
4376
|
const syncEditorSetting_userDir = homedir();
|
|
4359
4377
|
const fileSourceMap = {
|
|
4360
4378
|
settings: {
|
|
@@ -4377,19 +4395,32 @@ async function getFile(source) {
|
|
|
4377
4395
|
}
|
|
4378
4396
|
return await readFile(source, "utf-8");
|
|
4379
4397
|
}
|
|
4380
|
-
async function syncEditorFile({ source: { type: sourceType, value: sourceValue }, target: { type: targetType, value: targetValue } }) {
|
|
4398
|
+
async function syncEditorFile({ type, source: { type: sourceType, value: sourceValue }, target: { type: targetType, value: targetValue } }) {
|
|
4381
4399
|
const { dir, base } = parse(targetValue);
|
|
4382
4400
|
await mkdir(dir, {
|
|
4383
4401
|
recursive: true
|
|
4384
4402
|
});
|
|
4385
4403
|
const setting = await readZixuluSetting();
|
|
4386
4404
|
let code = await getFile(sourceValue);
|
|
4387
|
-
if ("
|
|
4388
|
-
|
|
4389
|
-
|
|
4390
|
-
|
|
4391
|
-
|
|
4392
|
-
|
|
4405
|
+
if ("settings" === type) {
|
|
4406
|
+
code = modifyJsonc(code, [
|
|
4407
|
+
"extensions.gallery.serviceUrl"
|
|
4408
|
+
], void 0);
|
|
4409
|
+
code = modifyJsonc(code, [
|
|
4410
|
+
"antigravity.marketplaceExtensionGalleryServiceURL"
|
|
4411
|
+
], void 0);
|
|
4412
|
+
code = modifyJsonc(code, [
|
|
4413
|
+
"antigravity.marketplaceGalleryItemURL"
|
|
4414
|
+
], void 0);
|
|
4415
|
+
if ("Antigravity" === targetType) {
|
|
4416
|
+
code = modifyJsonc(code, [
|
|
4417
|
+
"antigravity.marketplaceExtensionGalleryServiceURL"
|
|
4418
|
+
], "https://marketplace.visualstudio.com/_apis/public/gallery");
|
|
4419
|
+
code = modifyJsonc(code, [
|
|
4420
|
+
"antigravity.marketplaceGalleryItemURL"
|
|
4421
|
+
], "https://marketplace.visualstudio.com/items");
|
|
4422
|
+
}
|
|
4423
|
+
}
|
|
4393
4424
|
if (existsSync(targetValue)) {
|
|
4394
4425
|
const text = await readFile(targetValue, "utf-8");
|
|
4395
4426
|
if (text === code) return void consola_0.success(`${targetValue} 已是最新`);
|
|
@@ -4474,6 +4505,7 @@ async function syncEditorSetting() {
|
|
|
4474
4505
|
if (!setting.syncEditor.onlinePath) setting.syncEditor.targets = targets.filter((v)=>"Online" !== v);
|
|
4475
4506
|
const onlinePath = setting.syncEditor.onlinePath;
|
|
4476
4507
|
const configs = types.filter((item)=>"extensions" !== item).map((fileType)=>targets.map((target)=>({
|
|
4508
|
+
type: fileType,
|
|
4477
4509
|
source: {
|
|
4478
4510
|
type: source,
|
|
4479
4511
|
value: fileSourceMap[fileType][source]
|