Skip to content

Commit

Permalink
format
Browse files Browse the repository at this point in the history
  • Loading branch information
e111077 committed Mar 19, 2024
1 parent ce704cd commit ab298c1
Show file tree
Hide file tree
Showing 14 changed files with 202 additions and 165 deletions.
3 changes: 3 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ package-lock.json
/packages/lit-dev-content/_dev/
/packages/lit-dev-content/_site/
/packages/lit-dev-content/rollupout/
/packages/lit-dev-tutorial-plugin/.vscode-test/
/packages/lit-dev-tutorial-plugin/.test-bin/
/packages/lit-dev-tutorial-plugin/out/
# TODO(aomarks) Would be nice to format samples, but Prettier doesn't always do
# a great job compared to our manual formatting.
/packages/lit-dev-content/samples/
Expand Down
50 changes: 22 additions & 28 deletions packages/lit-dev-tutorial-plugin/.vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,32 +3,26 @@
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
{
"version": "0.2.0",
"configurations": [
{
"name": "Run Extension",
"type": "extensionHost",
"request": "launch",
"args": [
"--extensionDevelopmentPath=${workspaceFolder}"
],
"outFiles": [
"${workspaceFolder}/out/**/*.js"
],
"preLaunchTask": "${defaultBuildTask}"
},
{
"name": "Extension Tests",
"type": "extensionHost",
"request": "launch",
"args": [
"--extensionDevelopmentPath=${workspaceFolder}",
"--extensionTestsPath=${workspaceFolder}/out/test/suite/index"
],
"outFiles": [
"${workspaceFolder}/out/test/**/*.js"
],
"preLaunchTask": "${defaultBuildTask}"
}
]
"version": "0.2.0",
"configurations": [
{
"name": "Run Extension",
"type": "extensionHost",
"request": "launch",
"args": ["--extensionDevelopmentPath=${workspaceFolder}"],
"outFiles": ["${workspaceFolder}/out/**/*.js"],
"preLaunchTask": "${defaultBuildTask}"
},
{
"name": "Extension Tests",
"type": "extensionHost",
"request": "launch",
"args": [
"--extensionDevelopmentPath=${workspaceFolder}",
"--extensionTestsPath=${workspaceFolder}/out/test/suite/index"
],
"outFiles": ["${workspaceFolder}/out/test/**/*.js"],
"preLaunchTask": "${defaultBuildTask}"
}
]
}
18 changes: 9 additions & 9 deletions packages/lit-dev-tutorial-plugin/.vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
// Place your settings in this file to overwrite default and user settings.
{
"files.exclude": {
"out": false // set this to true to hide the "out" folder with the compiled JS files
},
"search.exclude": {
"out": true // set this to false to include "out" folder in search results
},
// Turn off tsc task auto detection since we have the necessary tasks as npm scripts
"typescript.tsc.autoDetect": "off"
}
"files.exclude": {
"out": false // set this to true to hide the "out" folder with the compiled JS files
},
"search.exclude": {
"out": true // set this to false to include "out" folder in search results
},
// Turn off tsc task auto detection since we have the necessary tasks as npm scripts
"typescript.tsc.autoDetect": "off"
}
32 changes: 16 additions & 16 deletions packages/lit-dev-tutorial-plugin/.vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
{
"version": "2.0.0",
"tasks": [
{
"type": "npm",
"script": "watch",
"problemMatcher": "$tsc-watch",
"isBackground": true,
"presentation": {
"reveal": "never"
},
"group": {
"kind": "build",
"isDefault": true
}
}
]
"version": "2.0.0",
"tasks": [
{
"type": "npm",
"script": "watch",
"problemMatcher": "$tsc-watch",
"isBackground": true,
"presentation": {
"reveal": "never"
},
"group": {
"kind": "build",
"isDefault": true
}
}
]
}
111 changes: 71 additions & 40 deletions packages/lit-dev-tutorial-plugin/src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,19 @@
*/

import * as vscode from 'vscode';
import { BeforeAfterDir } from './tree-items/before-after-dir.js';
import { GenericFile } from './tree-items/generic-file.js';
import { PlaygroundFile } from './tree-items/playground-file.js';
import { TutorialStep } from './tree-items/tutorial-step.js';
import { Tutorial } from './tree-items/tutorial.js';
import {BeforeAfterDir} from './tree-items/before-after-dir.js';
import {GenericFile} from './tree-items/generic-file.js';
import {PlaygroundFile} from './tree-items/playground-file.js';
import {TutorialStep} from './tree-items/tutorial-step.js';
import {Tutorial} from './tree-items/tutorial.js';
import {LitDevTutorialTreeProvider, TutorialTreeItem} from './tree-provider.js';

export async function activate() {
const rootPath =
vscode.workspace.workspaceFolders && vscode.workspace.workspaceFolders.length > 0
? vscode.workspace.workspaceFolders[0].uri.fsPath
: undefined;
vscode.workspace.workspaceFolders &&
vscode.workspace.workspaceFolders.length > 0
? vscode.workspace.workspaceFolders[0].uri.fsPath
: undefined;

if (!rootPath) {
return;
Expand All @@ -36,38 +37,68 @@ export async function activate() {
vscode.commands.registerCommand('litDevTutorial.createTutorial', () => {
provider.createTutorial();
});
vscode.commands.registerCommand('litDevTutorial.addStep', (tutorial: Tutorial) => {
TutorialStep.create(tutorial);
});
vscode.commands.registerCommand('litDevTutorial.moveStepUp', (step: TutorialStep) => {
step.moveUp();
});
vscode.commands.registerCommand('litDevTutorial.moveStepDown', (step: TutorialStep) => {
step.moveDown();
});
vscode.commands.registerCommand('litDevTutorial.addAfterStep', (step: TutorialStep) => {
BeforeAfterDir.create(step, 'after');
});
vscode.commands.registerCommand('litDevTutorial.delete', (item: TutorialTreeItem) => {
item.delete();
});
vscode.commands.registerCommand('litDevTutorial.makeSolvable', (item: TutorialStep) => {
item.solvable = true;
item.provider.refresh();
});
vscode.commands.registerCommand('litDevTutorial.makeUnsolvable', (item: TutorialStep) => {
item.solvable = false;
item.provider.refresh();
});
vscode.commands.registerCommand('litDevTutorial.createPlaygroundFile', (dir: BeforeAfterDir) => {
PlaygroundFile.create(dir);
});
vscode.commands.registerCommand('litDevTutorial.revealInSidebar', (item: GenericFile | PlaygroundFile) => {
item.revealInSidebar();
});
vscode.commands.registerCommand('litDevTutorial.renameStep', (item: TutorialStep) => {
item.rename();
});
vscode.commands.registerCommand(
'litDevTutorial.addStep',
(tutorial: Tutorial) => {
TutorialStep.create(tutorial);
}
);
vscode.commands.registerCommand(
'litDevTutorial.moveStepUp',
(step: TutorialStep) => {
step.moveUp();
}
);
vscode.commands.registerCommand(
'litDevTutorial.moveStepDown',
(step: TutorialStep) => {
step.moveDown();
}
);
vscode.commands.registerCommand(
'litDevTutorial.addAfterStep',
(step: TutorialStep) => {
BeforeAfterDir.create(step, 'after');
}
);
vscode.commands.registerCommand(
'litDevTutorial.delete',
(item: TutorialTreeItem) => {
item.delete();
}
);
vscode.commands.registerCommand(
'litDevTutorial.makeSolvable',
(item: TutorialStep) => {
item.solvable = true;
item.provider.refresh();
}
);
vscode.commands.registerCommand(
'litDevTutorial.makeUnsolvable',
(item: TutorialStep) => {
item.solvable = false;
item.provider.refresh();
}
);
vscode.commands.registerCommand(
'litDevTutorial.createPlaygroundFile',
(dir: BeforeAfterDir) => {
PlaygroundFile.create(dir);
}
);
vscode.commands.registerCommand(
'litDevTutorial.revealInSidebar',
(item: GenericFile | PlaygroundFile) => {
item.revealInSidebar();
}
);
vscode.commands.registerCommand(
'litDevTutorial.renameStep',
(item: TutorialStep) => {
item.rename();
}
);
}

// this method is called when your extension is deactivated
Expand Down
28 changes: 14 additions & 14 deletions packages/lit-dev-tutorial-plugin/src/test/runTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,24 @@

import * as path from 'path';

import { runTests } from '@vscode/test-electron';
import {runTests} from '@vscode/test-electron';

async function main() {
try {
// The folder containing the Extension Manifest package.json
// Passed to `--extensionDevelopmentPath`
const extensionDevelopmentPath = path.resolve(__dirname, '../../');
try {
// The folder containing the Extension Manifest package.json
// Passed to `--extensionDevelopmentPath`
const extensionDevelopmentPath = path.resolve(__dirname, '../../');

// The path to test runner
// Passed to --extensionTestsPath
const extensionTestsPath = path.resolve(__dirname, './suite/index');
// The path to test runner
// Passed to --extensionTestsPath
const extensionTestsPath = path.resolve(__dirname, './suite/index');

// Download VS Code, unzip it and run the integration test
await runTests({ extensionDevelopmentPath, extensionTestsPath });
} catch (err) {
console.error('Failed to run tests');
process.exit(1);
}
// Download VS Code, unzip it and run the integration test
await runTests({extensionDevelopmentPath, extensionTestsPath});
} catch (err) {
console.error('Failed to run tests');
process.exit(1);
}
}

main();
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,10 @@ suite('Tutorial Extension', () => {

suite('startup', () => {
test('recognizes lit.dev repo', async () => {
await vscode.commands.executeCommand('vscode.openFolder', vscode.Uri.file(litDevPath));
await vscode.commands.executeCommand(
'vscode.openFolder',
vscode.Uri.file(litDevPath)
);
console.log('opened!');
});
});
Expand Down
4 changes: 3 additions & 1 deletion packages/lit-dev-tutorial-plugin/src/test/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,9 @@ export const prepopulateTutorial = async (

for (let i = options.tutorials.length - 1; i >= 0; i--) {
const tutorial = options.tutorials[i];
const tutorialSection = (tutorial as typeof tutorial & {category ?: 'Learn'|'Build'}).category ?? 'Learn';
const tutorialSection =
(tutorial as typeof tutorial & {category?: 'Learn' | 'Build'}).category ??
'Learn';
const tutorialIndex = dataFileLines.findIndex((line) =>
line.includes(`// ${tutorialSection}`)
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ export class GenericFile extends vscode.TreeItem {

revealInSidebar() {
vscode.commands.executeCommand('vscode.open', vscode.Uri.file(this.path));
vscode.commands.executeCommand('workbench.files.action.showActiveFileInExplorer');
vscode.commands.executeCommand(
'workbench.files.action.showActiveFileInExplorer'
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,8 @@ export class PlaygroundFile extends vscode.TreeItem {

revealInSidebar() {
vscode.commands.executeCommand('vscode.open', vscode.Uri.file(this.path));
vscode.commands.executeCommand('workbench.files.action.showActiveFileInExplorer');
vscode.commands.executeCommand(
'workbench.files.action.showActiveFileInExplorer'
);
}
}
17 changes: 5 additions & 12 deletions packages/lit-dev-tutorial-plugin/src/tree-items/tutorial-step.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export class TutorialStep extends vscode.TreeItem {
private _hasAfter = false;
checkable = false;
beforeDir!: BeforeAfterDir;
afterDir: BeforeAfterDir|undefined = undefined;
afterDir: BeforeAfterDir | undefined = undefined;

get dirName() {
return `${this.step}`.padStart(2, '0');
Expand Down Expand Up @@ -68,10 +68,7 @@ export class TutorialStep extends vscode.TreeItem {

this._hasAfter = value;

const tutorialJsonPath = path.join(
this.tutorial.path,
'tutorial.json'
);
const tutorialJsonPath = path.join(this.tutorial.path, 'tutorial.json');
let tutorialJson = getJson<TutorialJson>(tutorialJsonPath)!;

if (value) {
Expand All @@ -97,15 +94,11 @@ export class TutorialStep extends vscode.TreeItem {
}

this._solvable = solvable;
const tutorialJsonPath = path.join(
this.tutorial.path,
'tutorial.json'
);
const tutorialJsonPath = path.join(this.tutorial.path, 'tutorial.json');
let tutorialJson = getJson<TutorialJson>(tutorialJsonPath)!;

if (solvable) {
delete tutorialJson.steps[this.step].noSolve;

} else {
this.hasAfter = false;
tutorialJson = getJson<TutorialJson>(tutorialJsonPath)!;
Expand Down Expand Up @@ -219,7 +212,7 @@ export class TutorialStep extends vscode.TreeItem {
return;
}

const isSolvableStr = await vscode.window.showQuickPick(['Yes', 'No'],{
const isSolvableStr = await vscode.window.showQuickPick(['Yes', 'No'], {
title: 'Should this step have a "solve" button?',
});

Expand All @@ -231,7 +224,7 @@ export class TutorialStep extends vscode.TreeItem {
let hasAfter = false;

if (!hideSolve) {
const hasAfterStr = await vscode.window.showQuickPick(['Yes', 'No'],{
const hasAfterStr = await vscode.window.showQuickPick(['Yes', 'No'], {
title: 'Is "after" step the "before" of the next step?',
});

Expand Down
Loading

0 comments on commit ab298c1

Please sign in to comment.