diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 322641f9..df08deee 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -24,7 +24,7 @@ on: description: "Publish on Visual Studio Marketplace?" required: true type: choice - default: "yes" + default: "no" options: - "yes" - "no" @@ -32,7 +32,7 @@ on: description: "Publish on Open VSX Registry?" required: true type: choice - default: "yes" + default: "no" options: - "yes" - "no" @@ -65,7 +65,7 @@ jobs: - name: Setup Git run: | git config --global user.name "Release Bot" - git config --global user.email "no-replay@github.com" + git config --global user.email "no-noreply@github.com" - name: Get Current Version Number run: | CURRENT_VERSION=$(cat package.json | jq .version | cut -d'"' -f 2) @@ -90,21 +90,21 @@ jobs: if: ${{ github.event.inputs.releaseChannel == 'stable' }} - name: Version Package run: | + git checkout . npm version $RELEASE_VERSION - git tag -a $RELEASE_VERSION -m "$RELEASE_VERSION" - name: Package Extension (Edge) if: ${{ github.event.inputs.releaseChannel == 'edge' }} run: | node .github/scripts/updateEdgeVersion.js - yarn vsce package --pre-release --yarn --no-git-tag-version --no-update-package-json -o "./live-server-$RELEASE_VERSION.vsix" ${{ github.event.inputs.additionalFlags }} + npx vsce package --pre-release --no-git-tag-version --no-update-package-json -o "./live-server-$RELEASE_VERSION.vsix" ${{ github.event.inputs.additionalFlags }} - name: Package Extension (Stable) - run: yarn vsce package $RELEASE_VERSION --yarn --no-git-tag-version --no-update-package-json -o "./live-server-$RELEASE_VERSION.vsix" ${{ github.event.inputs.additionalFlags }} + run: npx vsce package $RELEASE_VERSION --no-git-tag-version --no-update-package-json -o "./live-server-$RELEASE_VERSION.vsix" ${{ github.event.inputs.additionalFlags }} if: ${{ github.event.inputs.releaseChannel == 'stable' }} - name: Publish to Visual Studio Marketplace (Edge) - run: yarn vsce publish --packagePath "./live-server-$RELEASE_VERSION.vsix" --pre-release --yarn --no-git-tag-version --no-update-package-json -p ${{ secrets.VSC_MKTP_PAT }} ${{ github.event.inputs.additionalFlags }} + run: npx vsce publish --packagePath "./live-server-$RELEASE_VERSION.vsix" --pre-release --no-git-tag-version --no-update-package-json -p ${{ secrets.VSC_MKTP_PAT }} ${{ github.event.inputs.additionalFlags }} if: ${{ github.event.inputs.publishMarketplace == 'yes' && github.event.inputs.releaseChannel == 'edge' }} - name: Publish to Visual Studio Marketplace (Stable) - run: yarn vsce publish --packagePath "./live-server-$RELEASE_VERSION.vsix" --yarn --no-git-tag-version --no-update-package-json -p ${{ secrets.VSC_MKTP_PAT }} ${{ github.event.inputs.additionalFlags }} + run: npx vsce publish --packagePath "./live-server-$RELEASE_VERSION.vsix" --no-git-tag-version --no-update-package-json -p ${{ secrets.VSC_MKTP_PAT }} ${{ github.event.inputs.additionalFlags }} if: ${{ github.event.inputs.publishMarketplace == 'yes' && github.event.inputs.releaseChannel == 'stable' }} - name: Publish to Open VSX Registry (Edge) uses: HaaLeo/publish-vscode-extension@v1 @@ -123,7 +123,7 @@ jobs: - name: Push Tags run: | git log -1 --stat - git push origin main --tags + git push origin master --tags - run: | export GIT_TAG=$(git describe --tags --abbrev=0) echo "GIT_TAG=$GIT_TAG" >> $GITHUB_ENV diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 342867d5..caf2d633 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -3,7 +3,7 @@ name: CI on: push: branches: - - main + - master pull_request: jobs: @@ -28,6 +28,7 @@ jobs: if: matrix.os != 'ubuntu-latest' with: run: npm test + options: "-screen 0 1600x1200x24" - name: Run Tests uses: GabrielBB/xvfb-action@v1 if: matrix.os == 'ubuntu-latest' diff --git a/.gitignore b/.gitignore index 2f2b07f6..59cdc10c 100644 --- a/.gitignore +++ b/.gitignore @@ -4,4 +4,5 @@ _site Gemfile.lock **/*.vsix .vscode-test -.wdio-vscode-service \ No newline at end of file +.wdio-vscode-service +*-CHANGELOG.txt \ No newline at end of file diff --git a/.vscodeignore b/.vscodeignore index 2a1e3b75..cfa5488d 100644 --- a/.vscodeignore +++ b/.vscodeignore @@ -1,5 +1,6 @@ .vscode/** .vscode-test/** +.wdio-vscode-service/** out/test/** test/** src/** diff --git a/lib/live-server/injected.html b/lib/live-server/injected.html index 0ef9f902..da4f4121 100644 --- a/lib/live-server/injected.html +++ b/lib/live-server/injected.html @@ -1,5 +1,5 @@ - \ No newline at end of file + diff --git a/package-lock.json b/package-lock.json index 8242b326..7d7745e4 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "LiveServer", - "version": "5.7.5", + "version": "5.7.9", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "LiveServer", - "version": "5.7.5", + "version": "5.7.9", "license": "MIT", "dependencies": { "http-shutdown": "^1.2.0", @@ -24,6 +24,7 @@ "@wdio/local-runner": "^7.19.3", "@wdio/mocha-framework": "^7.19.3", "@wdio/spec-reporter": "^7.19.1", + "es5-ext": "0.10.53", "glob": "^7.2.0", "husky": "^1.2.1", "mocha": "^9.2.2", @@ -3095,18 +3096,14 @@ } }, "node_modules/es5-ext": { - "version": "0.10.60", - "resolved": "https://registry.npmjs.org/es5-ext/-/es5-ext-0.10.60.tgz", - "integrity": "sha512-jpKNXIt60htYG59/9FGf2PYT3pwMpnEbNKysU+k/4FGwyGtMotOvcZOuW+EmXXYASRqYSXQfGL5cVIthOTgbkg==", + "version": "0.10.53", + "resolved": "https://registry.npmjs.org/es5-ext/-/es5-ext-0.10.53.tgz", + "integrity": "sha512-Xs2Stw6NiNHWypzRTY1MtaG/uJlwCk8kH81920ma8mvN8Xq1gsfhZvpkImLQArw8AHnv8MT2I45J3c0R8slE+Q==", "dev": true, - "hasInstallScript": true, "dependencies": { - "es6-iterator": "^2.0.3", - "es6-symbol": "^3.1.3", - "next-tick": "^1.1.0" - }, - "engines": { - "node": ">=0.10" + "es6-iterator": "~2.0.3", + "es6-symbol": "~3.1.3", + "next-tick": "~1.0.0" } }, "node_modules/es6-iterator": { @@ -6315,9 +6312,9 @@ } }, "node_modules/next-tick": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/next-tick/-/next-tick-1.1.0.tgz", - "integrity": "sha512-CXdUiJembsNjuToQvxayPZF9Vqht7hewsvy2sOWafLvi2awflj9mOC6bHIg50orX8IJvWKY9wYQ/zB2kogPslQ==", + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/next-tick/-/next-tick-1.0.0.tgz", + "integrity": "sha512-mc/caHeUcdjnC/boPWJefDr4KUIWQNv+tlnFnJd38QMou86QtxQzBJfxgGRzvx8jazYRqrVlaHarfO72uNxPOg==", "dev": true }, "node_modules/nice-try": { @@ -12462,14 +12459,14 @@ } }, "es5-ext": { - "version": "0.10.60", - "resolved": "https://registry.npmjs.org/es5-ext/-/es5-ext-0.10.60.tgz", - "integrity": "sha512-jpKNXIt60htYG59/9FGf2PYT3pwMpnEbNKysU+k/4FGwyGtMotOvcZOuW+EmXXYASRqYSXQfGL5cVIthOTgbkg==", + "version": "0.10.53", + "resolved": "https://registry.npmjs.org/es5-ext/-/es5-ext-0.10.53.tgz", + "integrity": "sha512-Xs2Stw6NiNHWypzRTY1MtaG/uJlwCk8kH81920ma8mvN8Xq1gsfhZvpkImLQArw8AHnv8MT2I45J3c0R8slE+Q==", "dev": true, "requires": { - "es6-iterator": "^2.0.3", - "es6-symbol": "^3.1.3", - "next-tick": "^1.1.0" + "es6-iterator": "~2.0.3", + "es6-symbol": "~3.1.3", + "next-tick": "~1.0.0" } }, "es6-iterator": { @@ -12479,7 +12476,7 @@ "dev": true, "requires": { "d": "1", - "es5-ext": "^0.10.35", + "es5-ext": "0.10.53", "es6-symbol": "^3.1.1" } }, @@ -14960,9 +14957,9 @@ "integrity": "sha512-+EUsqGPLsM+j/zdChZjsnX51g4XrHFOIXwfnCVPGlQk/k5giakcKsuxCObBRu6DSm9opw/O6slWbJdghQM4bBg==" }, "next-tick": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/next-tick/-/next-tick-1.1.0.tgz", - "integrity": "sha512-CXdUiJembsNjuToQvxayPZF9Vqht7hewsvy2sOWafLvi2awflj9mOC6bHIg50orX8IJvWKY9wYQ/zB2kogPslQ==", + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/next-tick/-/next-tick-1.0.0.tgz", + "integrity": "sha512-mc/caHeUcdjnC/boPWJefDr4KUIWQNv+tlnFnJd38QMou86QtxQzBJfxgGRzvx8jazYRqrVlaHarfO72uNxPOg==", "dev": true }, "nice-try": { diff --git a/package.json b/package.json index 6fa118dc..a3ce0fcf 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "LiveServer", "displayName": "Live Server", "description": "Launch a development local Server with live reload feature for static & dynamic pages", - "version": "5.7.5", + "version": "5.7.9", "publisher": "ritwickdey", "author": { "name": "Ritwick Dey", @@ -115,11 +115,6 @@ "pattern": "/|/[^\\/]", "description": "Set Custom root of Live Server. \nTo change root the the server to sub folder of workspace, use '/' and relative path from workspace. \nExample: /subfolder1/subfolder2" }, - "liveServer.settings.useBrowserPreview": { - "type": "boolean", - "default": false, - "description": "Open in Browser Preview inside VS Code, instead of default browser" - }, "liveServer.settings.CustomBrowser": { "type": [ "string", @@ -350,7 +345,8 @@ "tslint": "^6.1.3", "typescript": "^4.5.4", "vsce": "^2.7.0", - "wdio-vscode-service": "^2.0.1" + "wdio-vscode-service": "^2.0.1", + "es5-ext": "0.10.53" }, "dependencies": { "http-shutdown": "^1.2.0", @@ -359,8 +355,11 @@ "opn": "^6.0.0", "vsls": "^0.3.967" }, + "overrides": { + "es5-ext": "0.10.53" + }, "announcement": { - "onVersion": "5.7.5", - "message": "[NEW] LiveServer@5.7.5: Changed extension activationEvents to onStartupFinished." + "onVersion": "5.7.9", + "message": "[NEW] LiveServer@5.7.9: Activation load time improved" } } diff --git a/src/Config.ts b/src/Config.ts index 6b8dc984..b455eae3 100644 --- a/src/Config.ts +++ b/src/Config.ts @@ -53,10 +53,6 @@ export class Config { return Config.getSettings('NoBrowser'); } - public static get getUseBrowserPreview(): boolean { - return Config.getSettings('useBrowserPreview'); - } - public static get getAdvancedBrowserCmdline(): string { return Config.getSettings('AdvanceCustomBrowserCmdLine'); } @@ -121,11 +117,11 @@ export class Config { return Config.getSettings('file'); } - public static get getMutiRootWorkspaceName(): string { + public static get getMultiRootWorkspaceName(): string { return Config.getSettings('multiRootWorkspaceName'); } - public static setMutiRootWorkspaceName(val: string) { + public static setMultiRootWorkspaceName(val: string) { return Config.configuration.update('multiRootWorkspaceName', val, false); } } diff --git a/src/Helper.ts b/src/Helper.ts index bb21ec7c..24bdebcf 100644 --- a/src/Helper.ts +++ b/src/Helper.ts @@ -4,7 +4,7 @@ import * as fs from 'fs'; import * as path from 'path'; import { Config } from './Config'; -export const SUPPRORTED_EXT: string[] = [ +export const SUPPORTED_EXT: string[] = [ '.html', '.htm', '.svg' ]; @@ -65,7 +65,7 @@ export class Helper { */ public static IsSupportedFile(file: string): boolean { let ext = path.extname(file) || (file.startsWith('.') ? file : `.${file}`); - return SUPPRORTED_EXT.indexOf(ext.toLowerCase()) > -1; + return SUPPORTED_EXT.indexOf(ext.toLowerCase()) > -1; } @@ -153,4 +153,4 @@ export class Helper { return proxy; } -} \ No newline at end of file +} diff --git a/src/LiveServerHelper.ts b/src/LiveServerHelper.ts index dbac3d1f..d1cae4eb 100644 --- a/src/LiveServerHelper.ts +++ b/src/LiveServerHelper.ts @@ -1,20 +1,18 @@ 'use strict'; -const liveServer = require('live-server'); -const httpShutdown = require('http-shutdown'); export class LiveServerHelper { static StartServer(params, callback) { setTimeout(() => { try { - let ServerInstance = liveServer.start(params); + let ServerInstance = require('live-server').start(params); setTimeout(() => { if (!ServerInstance._connectionKey) { return callback({}); } - httpShutdown(ServerInstance); + require('http-shutdown')(ServerInstance); return callback(ServerInstance); }, 1000); @@ -34,7 +32,7 @@ export class LiveServerHelper { // callback(); /*only Working first time, Unknown Bug*/ }); LiveServerInstance.close(); - liveServer.shutdown(); + require('live-server').shutdown(); setTimeout(() => { callback(); }, 1000); } } \ No newline at end of file diff --git a/src/announcement/index.ts b/src/announcement/index.ts index 72a6dcdb..35fff8f0 100644 --- a/src/announcement/index.ts +++ b/src/announcement/index.ts @@ -1,27 +1,26 @@ import { Memento, extensions, window } from 'vscode'; -import * as opn from 'opn'; export const SETUP_STRING = 'liveServer.setup.version'; export async function checkNewAnnouncement(memento: Memento) { const packageJSON = extensions.getExtension('ritwickdey.LiveServer').packageJSON; - const announment = packageJSON.announcement; + const announcement = packageJSON.announcement; - if (!announment && Object.keys(announment).length === 0) return; + if (!announcement && Object.keys(announcement).length === 0) return; const stateVersion = await memento.get(SETUP_STRING) || '0.0.0'; const installedVersion = packageJSON.version; - if (stateVersion !== installedVersion && installedVersion === announment.onVersion) { + if (stateVersion !== installedVersion && installedVersion === announcement.onVersion) { await memento.update(SETUP_STRING, installedVersion); const showDetails = 'Show Details'; - const choice = await window.showInformationMessage(announment.message, showDetails); + const choice = await window.showInformationMessage(announcement.message, showDetails); if (choice === showDetails) { - const url = announment.url || 'https://github.com/ritwickdey/vscode-live-server'; - opn(url); + const url = announcement.url || 'https://github.com/ritwickdey/vscode-live-server'; + require('opn')(url); } } -} \ No newline at end of file +} diff --git a/src/appModel.ts b/src/appModel.ts index fdbc0da0..65b7f868 100644 --- a/src/appModel.ts +++ b/src/appModel.ts @@ -5,14 +5,11 @@ import { commands, window, workspace, Event, EventEmitter } from 'vscode'; import { LiveServerHelper } from './LiveServerHelper'; import { StatusbarUi } from './StatusbarUi'; import { Config } from './Config'; -import { Helper, SUPPRORTED_EXT } from './Helper'; +import { Helper, SUPPORTED_EXT } from './Helper'; import { workspaceResolver, setOrChangeWorkspace } from './workspaceResolver'; import { IAppModel, GoLiveEvent, GoOfflineEvent } from './IAppModel'; import { LiveShareHelper } from './LiveShareHelper'; -import * as opn from 'opn'; -import * as ips from 'ips'; - export class AppModel implements IAppModel { private IsServerRunning: boolean; @@ -69,7 +66,7 @@ export class AppModel implements IAppModel { ); } if (pathInfos.isNotOkay) { - this.showPopUpMsg('Invaild Path in liveServer.settings.root settings. live Server will serve from workspace root', true); + this.showPopUpMsg('Invalid Path in liveServer.settings.root settings. live Server will serve from workspace root', true); } if (this.isServerBusy) return; @@ -104,7 +101,7 @@ export class AppModel implements IAppModel { this.showPopUpMsg(`The default port : ${Config.getPort - 1} is currently taken, changing port to : ${Config.getPort}.`); this.Golive(pathUri); } else { - this.showPopUpMsg(`Something is went wrong! Please check into Developer Console or report on GitHub.`, true); + this.showPopUpMsg(`Something went wrong! Please check into Developer Console or report on GitHub.`, true); } this.IsServerRunning = true; // to revert status - cheat :p this.ToggleStatusBar(); // reverted @@ -134,9 +131,9 @@ export class AppModel implements IAppModel { changeWorkspaceRoot() { setOrChangeWorkspace() - .then(workspceName => { - if (workspceName === undefined) return; - window.showInformationMessage(`Success! '${workspceName}' workspace is now root of Live Server`); + .then(workspaceName => { + if (workspaceName === undefined) return; + window.showInformationMessage(`Success! '${workspaceName}' workspace is now root of Live Server`); // If server is running, Turn off the server. if (this.IsServerRunning) this.GoOffline(); @@ -158,7 +155,7 @@ export class AppModel implements IAppModel { } private tagMissedCallback() { - this.showPopUpMsg('Live Reload is not possible without body or head tag.', null, true); + this.showPopUpMsg('Live Reload is not possible without a head or body tag.', null, true); } private showPopUpMsg(msg: string, isErrorMsg: boolean = false, isWarning: boolean = false) { @@ -168,8 +165,8 @@ export class AppModel implements IAppModel { else if (isWarning && !Config.getDonotVerifyTags) { const donotShowMsg = 'I understand, Don\'t show again'; window.showWarningMessage(msg, donotShowMsg) - .then(choise => { - if (choise && choise === donotShowMsg) { + .then(choice => { + if (choice && choice === donotShowMsg) { Config.setDonotVerifyTags(true, true); } }); @@ -200,7 +197,7 @@ export class AppModel implements IAppModel { private haveAnySupportedFile() { return new Promise(resolve => { - const globFormat = `**/*[${SUPPRORTED_EXT.join(' | ')}]`; + const globFormat = `**/*[${SUPPORTED_EXT.join(' | ')}]`; workspace.findFiles(globFormat, '**/node_modules/**', 1) .then(async (files) => { if (files && files.length) return resolve(); @@ -209,7 +206,7 @@ export class AppModel implements IAppModel { } private openBrowser(port: number, path: string) { - const host = (Config.getLocalIp ? ips().local : Config.getHost) || '127.0.0.1'; + const host = (Config.getLocalIp ? require('ips')().local : Config.getHost) || '127.0.0.1'; const protocol = Config.getHttps.enable ? 'https' : 'http'; let params: string[] = []; @@ -217,20 +214,8 @@ export class AppModel implements IAppModel { if (path.startsWith('\\') || path.startsWith('/')) { path = path.substring(1, path.length); } - path = path.replace(/\\/gi, '/'); - let useBrowserPreview = Config.getUseBrowserPreview; - if (useBrowserPreview) { - let url = `${protocol}://${host}:${port}/${path}`; - let onSuccess = () => {}; - let onError = (err) => { - this.showPopUpMsg(`Server is started at ${this.runningPort} but failed to open in Browser Preview. Got Browser Preview extension installed?`, true); - console.log('\n\nError Log to open Browser : ', err); - console.log('\n\n'); - }; - commands.executeCommand(`browser-preview.openPreview`, url).then(onSuccess, onError); - return; - } + path = path.replace(/\\/gi, '/'); if (advanceCustomBrowserCmd) { advanceCustomBrowserCmd @@ -289,9 +274,9 @@ export class AppModel implements IAppModel { } try { - opn(`${protocol}://${host}:${port}/${path}`, { app: params || [''] }); + require('opn')(`${protocol}://${host}:${port}/${path}`, { app: params || [''] }); } catch (error) { - this.showPopUpMsg(`Server is started at ${this.runningPort} but failed to open browser. Try to change the CustomBrowser settings.`, true); + this.showPopUpMsg(`Server is started at ${host}:${this.runningPort} but failed to open browser. Try to change the CustomBrowser settings.`, true); console.log('\n\nError Log to open Browser : ', error); console.log('\n\n'); } @@ -303,5 +288,3 @@ export class AppModel implements IAppModel { this.liveShareHelper.dispose(); } } - - diff --git a/src/workspaceResolver.ts b/src/workspaceResolver.ts index c1b1bbbf..b3c7115e 100644 --- a/src/workspaceResolver.ts +++ b/src/workspaceResolver.ts @@ -10,7 +10,7 @@ export function setOrChangeWorkspace() { ignoreFocusOut: true }).then(workspaceName => { if (workspaceName) { - return Config.setMutiRootWorkspaceName(workspaceName).then(() => workspaceName); + return Config.setMultiRootWorkspaceName(workspaceName).then(() => workspaceName); } }); } @@ -30,20 +30,20 @@ export function workspaceResolver(fileUri?: string) { if (fileUri) { const selectedWorkspace = workspaceFolders.find(ws => fileUri.startsWith(ws.uri.fsPath)); if (selectedWorkspace) { - return Config.setMutiRootWorkspaceName(selectedWorkspace.name) + return Config.setMultiRootWorkspaceName(selectedWorkspace.name) .then(() => resolve(selectedWorkspace.uri.fsPath)); } } // If workspace already set by User - if (Config.getMutiRootWorkspaceName) { + if (Config.getMultiRootWorkspaceName) { // A small test that the WorkspaceName (set by user) is valid - const targetWorkspace = workspaceFolders.find(e => e.name === Config.getMutiRootWorkspaceName); + const targetWorkspace = workspaceFolders.find(e => e.name === Config.getMultiRootWorkspaceName); if (targetWorkspace) return resolve(targetWorkspace.uri.fsPath); // reset whatever user is set. - Config.setMutiRootWorkspaceName(null); + Config.setMultiRootWorkspaceName(null); } // Show a quick picker