From e5cc8ae3ec7ec19f2ec6caeb9f9a9c6935d88c76 Mon Sep 17 00:00:00 2001 From: Shaun Hamilton Date: Wed, 17 Jan 2024 14:04:43 +0200 Subject: [PATCH] feat(2.1.0): auto-start if workspace contains config file (#407) --- CHANGELOG.md | 7 ++++ package-lock.json | 6 ++-- package.json | 91 ++++++++++++++++++++++++----------------------- src/extension.ts | 12 ++++++- src/fixture.ts | 1 + src/typings.ts | 1 + 6 files changed, 70 insertions(+), 48 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 73e7845..8cab829 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,13 @@ Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how ## [Released] +##[2.1.0](#v2.1.0) (2024-01-18) + +### Added + +- `workspace.autoStart` configuration option +- Extension activates and auto-starts if `workspace.autoStart` is `true` + ##[2.0.0](#v2.0.0) (2023-09-28) ### Removed diff --git a/package-lock.json b/package-lock.json index 15c1348..13c2eaa 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "freecodecamp-courses", - "version": "2.0.0", + "version": "2.1.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "freecodecamp-courses", - "version": "2.0.0", + "version": "2.1.0", "license": "BSD-3-Clause", "dependencies": { "node-fetch": "3.3.2" @@ -25,7 +25,7 @@ }, "engines": { "node": "^20.0.0", - "vscode": "^1.82.0" + "vscode": "^1.85.0" } }, "node_modules/@aashutoshrathi/word-wrap": { diff --git a/package.json b/package.json index 738a65b..6ae1198 100644 --- a/package.json +++ b/package.json @@ -1,37 +1,15 @@ { - "name": "freecodecamp-courses", - "displayName": "freeCodeCamp - Courses", - "description": "Provides tooling for quick and easy selection of courses offered by freeCodeCamp", - "version": "2.0.0", + "activationEvents": [ + "workspaceContains:**/freecodecamp.conf.json" + ], "author": "freeCodeCamp", - "publisher": "freeCodeCamp", - "galleryBanner": { - "color": "#0a0a23", - "theme": "dark" - }, - "icon": "images/logo-128X128.png", - "engines": { - "vscode": "^1.82.0", - "node": "^20.0.0" + "bugs": { + "url": "https://github.com/freeCodeCamp/courses-vscode-extension/issues" }, "categories": [ "Education" ], - "keywords": [ - "freecodecamp", - "courses", - "web3", - "rust", - "backend" - ], - "main": "./dist/extension.js", "contributes": { - "jsonValidation": [ - { - "fileMatch": "**/freecodecamp.conf.json", - "url": "./schema.json" - } - ], "commands": [ { "command": "freecodecamp-courses.openCourse", @@ -57,20 +35,18 @@ "command": "freecodecamp-courses.shutdownCourse", "title": "freeCodeCamp: Shutdown Course" } + ], + "jsonValidation": [ + { + "fileMatch": "**/freecodecamp.conf.json", + "url": "./schema.json" + } ] }, - "scripts": { - "vscode:prepublish": "npm run package", - "compile": "webpack", - "watch": "webpack --watch", - "package": "webpack --mode production --devtool hidden-source-map", - "pretest": "npm run compile-tests && npm run compile && npm run lint", - "lint": "eslint src --ext ts", - "pack": "vsce package", - "deploy": "vsce publish", - "vsce": "vsce", - "test:pack": "npm run pack -- --no-git-tag-version --no-update-package-json 1.0.0 -o freecodecamp-courses-test.vsix" + "dependencies": { + "node-fetch": "3.3.2" }, + "description": "Provides tooling for quick and easy selection of courses offered by freeCodeCamp", "devDependencies": { "@types/node": "20.10.5", "@types/vscode": "1.85.0", @@ -83,15 +59,42 @@ "webpack": "5.89.0", "webpack-cli": "5.1.4" }, + "displayName": "freeCodeCamp - Courses", + "engines": { + "node": "^20.0.0", + "vscode": "^1.85.0" + }, + "galleryBanner": { + "color": "#0a0a23", + "theme": "dark" + }, + "icon": "images/logo-128X128.png", + "keywords": [ + "freecodecamp", + "courses", + "web3", + "rust", + "backend" + ], + "license": "BSD-3-Clause", + "main": "./dist/extension.js", + "name": "freecodecamp-courses", + "publisher": "freeCodeCamp", "repository": { "type": "git", "url": "https://github.com/freeCodeCamp/courses-vscode-extension" }, - "license": "BSD-3-Clause", - "bugs": { - "url": "https://github.com/freeCodeCamp/courses-vscode-extension/issues" + "scripts": { + "compile": "webpack", + "deploy": "vsce publish", + "lint": "eslint src --ext ts", + "pack": "vsce package", + "package": "webpack --mode production --devtool hidden-source-map", + "pretest": "npm run compile-tests && npm run compile && npm run lint", + "test:pack": "npm run pack -- --no-git-tag-version --no-update-package-json 1.0.0 -o freecodecamp-courses-test.vsix", + "vsce": "vsce", + "vscode:prepublish": "npm run package", + "watch": "webpack --watch" }, - "dependencies": { - "node-fetch": "3.3.2" - } + "version": "2.1.0" } diff --git a/src/extension.ts b/src/extension.ts index a52e1c7..6db7d80 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -4,10 +4,20 @@ import runCourse from "./commands/run-course"; import developCourse from "./commands/develop-course"; import createNewCourse from "./commands/create-new-course"; import collapse from "./commands/collapse"; +import { getConfig } from "./usefuls"; -export function activate(context: ExtensionContext) { +export async function activate(context: ExtensionContext) { console.log("freeCodeCamp Courses extension is now active!"); + try { + const config = await getConfig(); + if (config.workspace?.autoStart) { + runCourse(); + } + } catch (e) { + console.debug(e); + } + context.subscriptions.push( commands.registerCommand("freecodecamp-courses.openCourse", async () => { openCourse(); diff --git a/src/fixture.ts b/src/fixture.ts index 1fb930f..c7f30f0 100644 --- a/src/fixture.ts +++ b/src/fixture.ts @@ -17,6 +17,7 @@ export const exampleConfig: Config = { }, workspace: { // Workspace settings + autoStart: false, // Whether or not to automatically start course on open of VSCode files: [ // Files to be opened in workspace { diff --git a/src/typings.ts b/src/typings.ts index 5f9b3a2..fe2f3d5 100644 --- a/src/typings.ts +++ b/src/typings.ts @@ -61,6 +61,7 @@ export interface Config { "run-course": string; }; workspace?: { + autoStart?: boolean; files?: File[]; previews?: Preview[]; terminals?: Terminal[];