Skip to content

Commit e5cc8ae

Browse files
feat(2.1.0): auto-start if workspace contains config file (#407)
1 parent cecabd7 commit e5cc8ae

6 files changed

+70
-48
lines changed

CHANGELOG.md

+7
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,13 @@ Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how
88

99
## [Released]
1010

11+
##[2.1.0](#v2.1.0) (2024-01-18)
12+
13+
### Added
14+
15+
- `workspace.autoStart` configuration option
16+
- Extension activates and auto-starts if `workspace.autoStart` is `true`
17+
1118
##[2.0.0](#v2.0.0) (2023-09-28)
1219

1320
### Removed

package-lock.json

+3-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+47-44
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,15 @@
11
{
2-
"name": "freecodecamp-courses",
3-
"displayName": "freeCodeCamp - Courses",
4-
"description": "Provides tooling for quick and easy selection of courses offered by freeCodeCamp",
5-
"version": "2.0.0",
2+
"activationEvents": [
3+
"workspaceContains:**/freecodecamp.conf.json"
4+
],
65
"author": "freeCodeCamp",
7-
"publisher": "freeCodeCamp",
8-
"galleryBanner": {
9-
"color": "#0a0a23",
10-
"theme": "dark"
11-
},
12-
"icon": "images/logo-128X128.png",
13-
"engines": {
14-
"vscode": "^1.82.0",
15-
"node": "^20.0.0"
6+
"bugs": {
7+
"url": "https://github.com/freeCodeCamp/courses-vscode-extension/issues"
168
},
179
"categories": [
1810
"Education"
1911
],
20-
"keywords": [
21-
"freecodecamp",
22-
"courses",
23-
"web3",
24-
"rust",
25-
"backend"
26-
],
27-
"main": "./dist/extension.js",
2812
"contributes": {
29-
"jsonValidation": [
30-
{
31-
"fileMatch": "**/freecodecamp.conf.json",
32-
"url": "./schema.json"
33-
}
34-
],
3513
"commands": [
3614
{
3715
"command": "freecodecamp-courses.openCourse",
@@ -57,20 +35,18 @@
5735
"command": "freecodecamp-courses.shutdownCourse",
5836
"title": "freeCodeCamp: Shutdown Course"
5937
}
38+
],
39+
"jsonValidation": [
40+
{
41+
"fileMatch": "**/freecodecamp.conf.json",
42+
"url": "./schema.json"
43+
}
6044
]
6145
},
62-
"scripts": {
63-
"vscode:prepublish": "npm run package",
64-
"compile": "webpack",
65-
"watch": "webpack --watch",
66-
"package": "webpack --mode production --devtool hidden-source-map",
67-
"pretest": "npm run compile-tests && npm run compile && npm run lint",
68-
"lint": "eslint src --ext ts",
69-
"pack": "vsce package",
70-
"deploy": "vsce publish",
71-
"vsce": "vsce",
72-
"test:pack": "npm run pack -- --no-git-tag-version --no-update-package-json 1.0.0 -o freecodecamp-courses-test.vsix"
46+
"dependencies": {
47+
"node-fetch": "3.3.2"
7348
},
49+
"description": "Provides tooling for quick and easy selection of courses offered by freeCodeCamp",
7450
"devDependencies": {
7551
"@types/node": "20.10.5",
7652
"@types/vscode": "1.85.0",
@@ -83,15 +59,42 @@
8359
"webpack": "5.89.0",
8460
"webpack-cli": "5.1.4"
8561
},
62+
"displayName": "freeCodeCamp - Courses",
63+
"engines": {
64+
"node": "^20.0.0",
65+
"vscode": "^1.85.0"
66+
},
67+
"galleryBanner": {
68+
"color": "#0a0a23",
69+
"theme": "dark"
70+
},
71+
"icon": "images/logo-128X128.png",
72+
"keywords": [
73+
"freecodecamp",
74+
"courses",
75+
"web3",
76+
"rust",
77+
"backend"
78+
],
79+
"license": "BSD-3-Clause",
80+
"main": "./dist/extension.js",
81+
"name": "freecodecamp-courses",
82+
"publisher": "freeCodeCamp",
8683
"repository": {
8784
"type": "git",
8885
"url": "https://github.com/freeCodeCamp/courses-vscode-extension"
8986
},
90-
"license": "BSD-3-Clause",
91-
"bugs": {
92-
"url": "https://github.com/freeCodeCamp/courses-vscode-extension/issues"
87+
"scripts": {
88+
"compile": "webpack",
89+
"deploy": "vsce publish",
90+
"lint": "eslint src --ext ts",
91+
"pack": "vsce package",
92+
"package": "webpack --mode production --devtool hidden-source-map",
93+
"pretest": "npm run compile-tests && npm run compile && npm run lint",
94+
"test:pack": "npm run pack -- --no-git-tag-version --no-update-package-json 1.0.0 -o freecodecamp-courses-test.vsix",
95+
"vsce": "vsce",
96+
"vscode:prepublish": "npm run package",
97+
"watch": "webpack --watch"
9398
},
94-
"dependencies": {
95-
"node-fetch": "3.3.2"
96-
}
99+
"version": "2.1.0"
97100
}

src/extension.ts

+11-1
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,20 @@ import runCourse from "./commands/run-course";
44
import developCourse from "./commands/develop-course";
55
import createNewCourse from "./commands/create-new-course";
66
import collapse from "./commands/collapse";
7+
import { getConfig } from "./usefuls";
78

8-
export function activate(context: ExtensionContext) {
9+
export async function activate(context: ExtensionContext) {
910
console.log("freeCodeCamp Courses extension is now active!");
1011

12+
try {
13+
const config = await getConfig();
14+
if (config.workspace?.autoStart) {
15+
runCourse();
16+
}
17+
} catch (e) {
18+
console.debug(e);
19+
}
20+
1121
context.subscriptions.push(
1222
commands.registerCommand("freecodecamp-courses.openCourse", async () => {
1323
openCourse();

src/fixture.ts

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ export const exampleConfig: Config = {
1717
},
1818
workspace: {
1919
// Workspace settings
20+
autoStart: false, // Whether or not to automatically start course on open of VSCode
2021
files: [
2122
// Files to be opened in workspace
2223
{

src/typings.ts

+1
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ export interface Config {
6161
"run-course": string;
6262
};
6363
workspace?: {
64+
autoStart?: boolean;
6465
files?: File[];
6566
previews?: Preview[];
6667
terminals?: Terminal[];

0 commit comments

Comments
 (0)