Skip to content

Commit 07d2772

Browse files
committed
release 3.3.5
2 parents cd7223b + 5bd2f07 commit 07d2772

File tree

12 files changed

+1419
-1201
lines changed

12 files changed

+1419
-1201
lines changed

.vscode/launch.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"DEBUG_SYNCING_EXTENSION": "true"
1919
},
2020
"outFiles": [
21-
"${workspaceFolder}/out/**/*.js"
21+
"${workspaceFolder}/dist/**/*.js"
2222
],
2323
"osx": {
2424
"preLaunchTask": "tsc-watch"

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# Changelogs
22

3+
## 3.3.5 - October 12, 2023
4+
5+
- Fixed: Fix version comparison.
6+
7+
38
## 3.3.4 - November 29, 2022
49

510
- Fixed: Fix code version for code-server ([@achembarpu](https://github.com/achembarpu)).

package.json

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "syncing",
33
"displayName": "%displayName%",
44
"description": "%description%",
5-
"version": "3.3.4",
5+
"version": "3.3.5",
66
"publisher": "nonoroazoro",
77
"author": {
88
"email": "[email protected]",
@@ -120,48 +120,48 @@
120120
"test:cov": "npm run cleanCov && npm test -- --coverage"
121121
},
122122
"dependencies": {
123-
"@octokit/rest": "^19.0.4",
123+
"@octokit/rest": "^19.0.11",
124124
"chokidar": "^3.5.3",
125-
"compare-versions": "^5.0.1",
126-
"date-fns": "^2.29.3",
125+
"date-fns": "^2.30.0",
127126
"extract-zip": "^2.0.1",
128-
"fs-extra": "10.1.0",
129-
"https-proxy-agent": "^5.0.1",
127+
"fs-extra": "11.1.1",
128+
"https-proxy-agent": "^7.0.2",
130129
"jsonc-parser": "^3.2.0",
131-
"jsondiffpatch": "^0.4.1",
130+
"jsondiffpatch": "^0.5.0",
132131
"junk": "^3.1.0",
133132
"lodash.debounce": "^4.0.8",
134133
"lodash.pick": "^4.4.0",
135134
"micromatch": "^4.0.5",
135+
"semver": "^7.5.4",
136136
"tmp-promise": "^3.0.3",
137-
"tslib": "^2.4.0"
137+
"tslib": "^2.6.2"
138138
},
139139
"devDependencies": {
140-
"@types/fs-extra": "^9.0.13",
141-
"@types/jest": "^29.0.3",
140+
"@types/fs-extra": "^11.0.2",
141+
"@types/jest": "^29.5.5",
142142
"@types/lodash.debounce": "^4.0.7",
143143
"@types/lodash.pick": "^4.4.7",
144-
"@types/micromatch": "^4.0.2",
144+
"@types/micromatch": "^4.0.3",
145145
"@types/node": "^10.11.0",
146146
"@types/vscode": "^1.37.0",
147-
"@typescript-eslint/eslint-plugin": "^5.38.0",
148-
"@typescript-eslint/parser": "^5.38.0",
147+
"@typescript-eslint/eslint-plugin": "^6.7.5",
148+
"@typescript-eslint/parser": "^6.7.5",
149149
"cross-env": "^7.0.3",
150-
"eslint": "^8.23.1",
151-
"eslint-config-zoro": "^5.34.0",
150+
"eslint": "^8.51.0",
151+
"eslint-config-zoro": "^6.0.1",
152152
"eslint-plugin-node": "^11.1.0",
153-
"eslint-webpack-plugin": "^3.2.0",
154-
"fork-ts-checker-webpack-plugin": "^7.2.13",
155-
"husky": "^8.0.1",
156-
"jest": "^29.0.3",
157-
"lint-staged": "^13.0.3",
153+
"eslint-webpack-plugin": "^4.0.1",
154+
"fork-ts-checker-webpack-plugin": "^9.0.0",
155+
"husky": "^8.0.3",
156+
"jest": "^29.7.0",
157+
"lint-staged": "^14.0.1",
158158
"native-ext-loader": "^2.3.0",
159-
"rimraf": "^3.0.2",
160-
"ts-jest": "^29.0.1",
161-
"ts-loader": "^9.4.1",
162-
"typescript": "^4.8.3",
163-
"webpack": "^5.74.0",
164-
"webpack-cli": "^4.10.0",
159+
"rimraf": "^5.0.5",
160+
"ts-jest": "^29.1.1",
161+
"ts-loader": "^9.5.0",
162+
"typescript": "^5.2.2",
163+
"webpack": "^5.88.2",
164+
"webpack-cli": "^5.1.4",
165165
"webpackbar": "^5.0.2"
166166
}
167167
}

src/core/Environment.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,15 @@ export class Environment
5757
public readonly snippetsDirectory: string;
5858

5959
/**
60-
* Gets the full path of VSCode's `.obsolete file`.
60+
* Gets the full path of VSCode's `.obsolete` file.
6161
*/
6262
public readonly obsoleteFilePath: string;
6363

64+
/**
65+
* Gets the full path of VSCode's `extensions.json` file.
66+
*/
67+
public readonly extensionsFilePath: string;
68+
6469
private static _instance: Environment;
6570

6671
private constructor()
@@ -76,6 +81,7 @@ export class Environment
7681
this.userDirectory = path.join(this.dataDirectory, "User");
7782
this.snippetsDirectory = this.getSettingsFilePath("snippets");
7883
this.obsoleteFilePath = path.join(this.extensionsDirectory, ".obsolete");
84+
this.extensionsFilePath = path.join(this.extensionsDirectory, "extensions.json");
7985
}
8086

8187
/**

src/core/Extension.ts

Lines changed: 8 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ export class Extension
151151
}
152152

153153
// Added since VSCode v1.20.
154-
await this.updateObsolete(added, updated, removed);
154+
await this.removeVSCodeExtensionFiles();
155155

156156
return result as ISyncedItem;
157157
}
@@ -233,52 +233,21 @@ export class Extension
233233
}
234234

235235
/**
236-
* Updates the VSCode `.obsolete` file.
236+
* Removes VSCode `.obsolete` and `extensions.json` file.
237237
*/
238-
public async updateObsolete(
239-
added: IExtension[] = [],
240-
removed: IExtension[] = [],
241-
updated: IExtension[] = []
242-
): Promise<void>
238+
public async removeVSCodeExtensionFiles(): Promise<void>
243239
{
244-
const filepath = this._env.obsoleteFilePath;
245-
// Record<extensionFolderName, boolean>
246-
let obsolete: Record<string, boolean> | undefined;
247240
try
248241
{
249-
obsolete = await fs.readJson(filepath);
250-
}
251-
catch
252-
{
242+
await fs.remove(this._env.obsoleteFilePath);
253243
}
244+
catch { }
254245

255-
if (obsolete != null)
246+
try
256247
{
257-
for (const ext of [...added, ...updated])
258-
{
259-
delete obsolete[this._env.getExtensionDirectoryName(ext)];
260-
}
261-
262-
for (const ext of removed)
263-
{
264-
obsolete[this._env.getExtensionDirectoryName(ext)] = true;
265-
}
266-
267-
try
268-
{
269-
if (Object.keys(obsolete).length > 0)
270-
{
271-
await fs.outputJson(filepath, obsolete);
272-
}
273-
else
274-
{
275-
await fs.remove(filepath);
276-
}
277-
}
278-
catch
279-
{
280-
}
248+
await fs.remove(this._env.extensionsFilePath);
281249
}
250+
catch { }
282251
}
283252

284253
/**

src/core/Gist.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Octokit } from "@octokit/rest";
2-
import * as createHttpsProxyAgent from "https-proxy-agent";
2+
import { HttpsProxyAgent } from "https-proxy-agent";
33
import pick = require("lodash.pick");
44

55
import { clearSpinner, showConfirmBox, showSpinner, statusError } from "./Toast";
@@ -44,7 +44,7 @@ export class Gist
4444
const options: { auth?: any; request: { agent?: any; timeout?: number } } = { request: { timeout: 8000 } };
4545
if (proxy != null && !isEmptyString(proxy))
4646
{
47-
options.request.agent = createHttpsProxyAgent(proxy);
47+
options.request.agent = new HttpsProxyAgent(proxy);
4848
}
4949

5050
this._token = token;

src/core/Syncing.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { Environment } from "./Environment";
44
import { Gist } from "./Gist";
55
import { isEmptyString } from "../utils/lang";
66
import { localize } from "../i18n";
7+
import { normalizeHttpProxy } from "../utils/normalizer";
78
import { openFile } from "../utils/vscodeAPI";
89
import * as Toast from "./Toast";
910
import type { ISyncingSettings } from "../types";
@@ -202,7 +203,7 @@ export class Syncing
202203
proxy = process.env["http_proxy"] ?? process.env["https_proxy"];
203204
}
204205

205-
return { ...settings, http_proxy: proxy };
206+
return { ...settings, http_proxy: normalizeHttpProxy(proxy) };
206207
}
207208

208209
/**

src/utils/ajax.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import * as createHttpsProxyAgent from "https-proxy-agent";
1+
import { HttpsProxyAgent } from "https-proxy-agent";
22
import * as fs from "fs-extra";
33
import * as https from "https";
44
import * as zlib from "zlib";
@@ -28,7 +28,7 @@ export function post(api: string, data: any, headers: any, proxy?: string): Prom
2828
};
2929
if (proxy != null && !isEmptyString(proxy))
3030
{
31-
options.agent = createHttpsProxyAgent(proxy);
31+
options.agent = new HttpsProxyAgent(proxy);
3232
}
3333

3434
const req = https.request(api, options, res =>
@@ -74,7 +74,7 @@ export function downloadFile(uri: string, savepath: string, proxy?: string): Pro
7474
const options: https.RequestOptions = {};
7575
if (proxy != null && !isEmptyString(proxy))
7676
{
77-
options.agent = createHttpsProxyAgent(proxy);
77+
options.agent = new HttpsProxyAgent(proxy);
7878
}
7979

8080
const file = fs.createWriteStream(savepath);

src/utils/normalizer.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { isEmptyString } from "./lang";
2+
3+
// Matches schema, colon and two slashes.
4+
const URL_PREFIX_REGEX = /^(([^:/?#]+):)?\/\//i;
5+
6+
/**
7+
* Normalizes the Http proxy, fixing protocol.
8+
*/
9+
export function normalizeHttpProxy(proxy: string | undefined)
10+
{
11+
if (proxy == null || isEmptyString(proxy) || URL_PREFIX_REGEX.test(proxy))
12+
{
13+
return proxy;
14+
}
15+
16+
// Add HTTP scheme.
17+
return `http://${proxy}`;
18+
}

src/utils/vscodeWebAPI.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { satisfies } from "compare-versions";
1+
import { coerce, satisfies } from "semver";
22
import * as vscode from "vscode";
33

44
import { CaseInsensitiveMap } from "../collections";
@@ -101,10 +101,10 @@ export function isVSIXSupported(version: ExtensionVersion, includePreRelease: bo
101101
}
102102
}
103103

104-
const requiredVersion = version.properties?.find(p => p.key === ExtensionPropertyType.ENGINE)?.value;
104+
const requiredVersion = coerce(version.properties?.find(p => p.key === ExtensionPropertyType.ENGINE)?.value)?.version;
105105
try
106106
{
107-
return requiredVersion == null ? true : satisfies(vscode.version, requiredVersion);
107+
return requiredVersion == null ? true : satisfies(vscode.version, `^${requiredVersion}`);
108108
}
109109
catch
110110
{

0 commit comments

Comments
 (0)