diff --git a/.vscodeignore b/.vscodeignore index c699c86..6b78192 100644 --- a/.vscodeignore +++ b/.vscodeignore @@ -24,7 +24,5 @@ node_modules/**/.editorconfig node_modules/**/LICENSE* node_modules/**/license* node_modules/**/test/* -node_modules/dayjs/esm -node_modules/dayjs/locale -node_modules/dayjs/plugin node_modules/php-parser +node_modules/compare-versions/lib/esm diff --git a/package.json b/package.json index 6b1210b..1f3e80e 100644 --- a/package.json +++ b/package.json @@ -642,17 +642,17 @@ "mocha": "^9.2.0", "prettier": "^3.1.0", "rimraf": "^5.0.5", + "semver": "^7.5.4", "simple-git": "^3.19.1", "tsx": "^4.6.2", "typescript": "^5.3.3" }, "dependencies": { - "dayjs": "^1.11.10", + "compare-versions": "^6.1.0", "detect-indent": "^6.0.0", "find-up": "^5.0.0", "mem": "^8.1.1", "phpfmt": "^0.0.6", - "pjson": "^1.0.9", - "semver": "^7.5.4" + "pjson": "^1.0.9" } } diff --git a/src/PHPFmt.ts b/src/PHPFmt.ts index 818d42c..5f22121 100644 --- a/src/PHPFmt.ts +++ b/src/PHPFmt.ts @@ -4,7 +4,7 @@ import fs from 'fs/promises'; import os from 'os'; import detectIndent from 'detect-indent'; import findUp from 'find-up'; -import * as semver from 'semver'; +import { compare } from 'compare-versions'; import phpfmt, { type PHPFmt as IPHPFmt } from 'phpfmt'; import { type Widget, PHPFmtStatus } from './Widget'; import { Transformation } from './Transformation'; @@ -213,11 +213,17 @@ export class PHPFmt { const phpVersion = match[1]; if (this.config.use_old_phpfmt) { - if (semver.lt(phpVersion, '5.6.0') || semver.gt(phpVersion, '8.0.0')) { + if ( + compare(phpVersion, '5.6.0', '<') || + compare(phpVersion, '8.0.0', '>') + ) { throw new PHPFmtError('PHP version < 5.6 or > 8.0'); } } else { - if (semver.lt(phpVersion, '5.6.0') || semver.gt(phpVersion, '8.3.0')) { + if ( + compare(phpVersion, '5.6.0', '<') || + compare(phpVersion, '8.3.0', '>') + ) { throw new PHPFmtError('PHP version < 5.6 or > 8.3'); } } diff --git a/src/Widget.ts b/src/Widget.ts index 4630c76..9e888a3 100644 --- a/src/Widget.ts +++ b/src/Widget.ts @@ -6,7 +6,6 @@ import { type TextEditor, ThemeColor } from 'vscode'; -import dayjs from 'dayjs'; export enum PHPFmtStatus { Ready = 'check-all', @@ -79,10 +78,8 @@ export class Widget { } private logMessage(message: string, logLevel: LogLevel): void { - const now = dayjs(); - this.outputChannel.appendLine( - `${now.format('HH:mm:ss.SSS')} [${logLevel}] ${message}` - ); + const now = new Date().toLocaleString(); + this.outputChannel.appendLine(`${now} [${logLevel}] ${message}`); } private logObject(data: unknown): void { diff --git a/tsconfig.json b/tsconfig.json index 0cdf817..b31a54e 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -16,7 +16,7 @@ "sourceMap": true, "esModuleInterop": true, "allowSyntheticDefaultImports": true, - "useUnknownInCatchVariables": false, + "useUnknownInCatchVariables": false }, "exclude": [ "node_modules", diff --git a/yarn.lock b/yarn.lock index 2fb2ad3..5cf8ede 100644 --- a/yarn.lock +++ b/yarn.lock @@ -674,6 +674,11 @@ color-name@~1.1.4: resolved "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz#c2a09a87acbde69543de6f63fa3995c826c536a2" integrity sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA== +compare-versions@^6.1.0: + version "6.1.0" + resolved "https://registry.yarnpkg.com/compare-versions/-/compare-versions-6.1.0.tgz#3f2131e3ae93577df111dba133e6db876ffe127a" + integrity sha512-LNZQXhqUvqUTotpZ00qLSaify3b4VFD588aRr8MKFw4CMUr98ytzCW5wDH5qx/DEY5kCDXcbcRuCqL0szEf2tg== + concat-map@0.0.1: version "0.0.1" resolved "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b" @@ -698,11 +703,6 @@ crypt@0.0.2: resolved "https://registry.yarnpkg.com/crypt/-/crypt-0.0.2.tgz#88d7ff7ec0dfb86f713dc87bbb42d044d3e6c41b" integrity sha512-mCxBlsHFYh9C+HVpiEacem8FEBnMXgU9gy4zmNC+SXAZNB/1idgp/aulFJ4FgCi7GPEVbfyng092GqL2k2rmow== -dayjs@^1.11.10: - version "1.11.10" - resolved "https://registry.yarnpkg.com/dayjs/-/dayjs-1.11.10.tgz#68acea85317a6e164457d6d6947564029a6a16a0" - integrity sha512-vjAczensTgRcqDERK0SR2XMwsF/tSvnvlv6VcF2GIhg6Sx4yOIt/irsr1RDJsKiIyBzJDpCoXiWWq28MqH2cnQ== - debug@4, debug@^4.1.1, debug@^4.3.2, debug@^4.3.4: version "4.3.4" resolved "https://registry.yarnpkg.com/debug/-/debug-4.3.4.tgz#1319f6579357f2338d3337d2cdd4914bb5dcc865"