Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: debugging in vs code #1153

Merged
merged 24 commits into from
Jan 9, 2024
Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
8931e5a
feat: debugging in vs code
johnnyreilly Dec 30, 2023
0d2a9d2
fix: https://github.com/JoshuaKGoldberg/create-typescript-app/pull/11…
johnnyreilly Dec 31, 2023
a092376
fix: speculatively add to the launch.json to fix test
johnnyreilly Dec 31, 2023
e1635f8
feat: speculative tests
johnnyreilly Dec 31, 2023
b84281c
chore: I hate the spellchecker with the fire of a thousand suns
johnnyreilly Dec 31, 2023
f02bd14
chore: remove unused dir
johnnyreilly Dec 31, 2023
76b1dde
Merge branch 'main' into debug-code
johnnyreilly Dec 31, 2023
5e15860
Merge branch 'main' into debug-code
johnnyreilly Dec 31, 2023
438647d
fix: remove problemMatcher
johnnyreilly Dec 31, 2023
8cee7ec
fix: remove problemMatcher
johnnyreilly Dec 31, 2023
2447ec2
Merge branch 'main' into debug-code
johnnyreilly Dec 31, 2023
a98171b
Merge branch 'main' into debug-code
johnnyreilly Jan 1, 2024
e65aaa0
feat: made launch.json conditional
johnnyreilly Jan 3, 2024
397d4fd
fix: launch.json diff
johnnyreilly Jan 3, 2024
099c9ec
feat: include Josh's tips in error message
johnnyreilly Jan 3, 2024
c8ad77b
Merge branch 'main' into debug-code
johnnyreilly Jan 3, 2024
59f1bd8
Merge branch 'main' into debug-code
johnnyreilly Jan 4, 2024
eb65439
Merge branch 'main' of https://github.com/JoshuaKGoldberg/create-type…
johnnyreilly Jan 4, 2024
44752ac
feat: documentation
johnnyreilly Jan 5, 2024
659f2cb
Merge branch 'main' into debug-code
johnnyreilly Jan 6, 2024
08e7e69
chore: newline
johnnyreilly Jan 6, 2024
2301020
chore: newline
johnnyreilly Jan 6, 2024
10e5d1c
fix: snapshots
johnnyreilly Jan 6, 2024
001eb3e
Merge branch 'main' of https://github.com/JoshuaKGoldberg/create-type…
johnnyreilly Jan 6, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .vscode/launch.json
JoshuaKGoldberg marked this conversation as resolved.
Show resolved Hide resolved
johnnyreilly marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,14 @@
"skipFiles": ["<node_internals>/**", "**/node_modules/**"],
"smartStep": true,
"type": "node"
},
{
"name": "Debug Program",
"preLaunchTask": "build",
"program": "lib/index.js",
"request": "launch",
"skipFiles": ["<node_internals>/**"],
"type": "node"
}
],
"version": "0.2.0"
Expand Down
11 changes: 11 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"tasks": [
{
"detail": "Build the project",
"label": "build",
"script": "build",
"type": "npm"
}
],
"version": "2.0.0"
}
301 changes: 301 additions & 0 deletions src/steps/writing/creation/dotVSCode.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,301 @@
import { describe, expect, it } from "vitest";

import { Options } from "../../../shared/types.js";
import { createDotVSCode } from "./dotVSCode.js";

/* spellchecker: disable */
function fakeOptions(
getExcludeValue: (exclusionName: string) => boolean,
bin?: string | undefined,
) {
return {
access: "public",
author: "TestAuthor",
base: "everything",
...(bin ? { bin } : {}),
description: "Test description.",
directory: ".",
email: {
github: "[email protected]",
npm: "[email protected]",
},
...Object.fromEntries(
[
"excludeCompliance",
"excludeAllContributors",
"excludeLintDeprecation",
"excludeLintESLint",
"excludeLintJSDoc",
"excludeLintJson",
"excludeLintKnip",
"excludeLintMd",
"excludeLintPackageJson",
"excludeLintPackages",
"excludeLintPerfectionist",
"excludeLintRegex",
"excludeLintSpelling",
"excludeLintStrict",
"excludeLintStylistic",
"excludeLintYml",
"excludeReleases",
"excludeRenovate",
"excludeTests",
].map((key) => [key, getExcludeValue(key)]),
),
mode: "create",
owner: "TestOwner",
repository: "test-repository",
skipGitHubApi: true,
skipInstall: true,
skipRemoval: true,
title: "Test Title",
} satisfies Options;
}

describe("createDotVSCode", () => {
it("creates a minimal config when all exclusions are enabled", async () => {
expect(await createDotVSCode(fakeOptions(() => true)))
.toMatchInlineSnapshot(`
{
"extensions.json": "{
"recommendations": [
"DavidAnson.vscode-markdownlint",
"dbaeumer.vscode-eslint",
"esbenp.prettier-vscode"
]
}
",
"settings.json": "{
"editor.codeActionsOnSave": { "source.fixAll.eslint": "explicit" },
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": true,
"editor.rulers": [80],
"eslint.probe": [
"javascript",
"javascriptreact",
"json",
"jsonc",
"markdown",
"typescript",
"typescriptreact",
"yaml"
],
"eslint.rules.customizations": [{ "rule": "*", "severity": "warn" }],
"typescript.tsdk": "node_modules/typescript/lib"
}
",
"tasks.json": "{
"tasks": [
{
"detail": "Build the project",
"label": "build",
"script": "build",
"type": "npm"
}
],
"version": "2.0.0"
}
",
}
`);
});

it("creates a full config when all exclusions are disabled and bin is provided", async () => {
expect(await createDotVSCode(fakeOptions(() => false, "bin/index.js")))
.toMatchInlineSnapshot(`
{
"extensions.json": "{
"recommendations": [
"DavidAnson.vscode-markdownlint",
"dbaeumer.vscode-eslint",
"esbenp.prettier-vscode",
"streetsidesoftware.code-spell-checker"
]
}
",
"launch.json": "{
"configurations": [
{
"args": ["run", "\${relativeFile}"],
"autoAttachChildProcesses": true,
"console": "integratedTerminal",
"name": "Debug Current Test File",
"program": "\${workspaceRoot}/node_modules/vitest/vitest.mjs",
"request": "launch",
"skipFiles": ["<node_internals>/**", "**/node_modules/**"],
"smartStep": true,
"type": "node"
},
{
"name": "Debug Program",
"preLaunchTask": "build",
"program": "bin/index.js",
"request": "launch",
"skipFiles": ["<node_internals>/**"],
"type": "node"
}
],
"version": "0.2.0"
}
",
"settings.json": "{
"editor.codeActionsOnSave": { "source.fixAll.eslint": "explicit" },
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": true,
"editor.rulers": [80],
"eslint.probe": [
"javascript",
"javascriptreact",
"json",
"jsonc",
"markdown",
"typescript",
"typescriptreact",
"yaml"
],
"eslint.rules.customizations": [{ "rule": "*", "severity": "warn" }],
"typescript.tsdk": "node_modules/typescript/lib"
}
",
"tasks.json": "{
"tasks": [
{
"detail": "Build the project",
"label": "build",
"script": "build",
"type": "npm"
}
],
"version": "2.0.0"
}
",
}
`);
});

it("creates a full config when all exclusions are disabled and bin is not provided", async () => {
expect(await createDotVSCode(fakeOptions(() => false)))
.toMatchInlineSnapshot(`
{
"extensions.json": "{
"recommendations": [
"DavidAnson.vscode-markdownlint",
"dbaeumer.vscode-eslint",
"esbenp.prettier-vscode",
"streetsidesoftware.code-spell-checker"
]
}
",
"launch.json": "{
"configurations": [
{
"args": ["run", "\${relativeFile}"],
"autoAttachChildProcesses": true,
"console": "integratedTerminal",
"name": "Debug Current Test File",
"program": "\${workspaceRoot}/node_modules/vitest/vitest.mjs",
"request": "launch",
"skipFiles": ["<node_internals>/**", "**/node_modules/**"],
"smartStep": true,
"type": "node"
}
],
"version": "0.2.0"
}
",
"settings.json": "{
"editor.codeActionsOnSave": { "source.fixAll.eslint": "explicit" },
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": true,
"editor.rulers": [80],
"eslint.probe": [
"javascript",
"javascriptreact",
"json",
"jsonc",
"markdown",
"typescript",
"typescriptreact",
"yaml"
],
"eslint.rules.customizations": [{ "rule": "*", "severity": "warn" }],
"typescript.tsdk": "node_modules/typescript/lib"
}
",
"tasks.json": "{
"tasks": [
{
"detail": "Build the project",
"label": "build",
"script": "build",
"type": "npm"
}
],
"version": "2.0.0"
}
",
}
`);
});

it("creates a minimal config including launch.json when all exclusions are enabled and bin is provided", async () => {
expect(await createDotVSCode(fakeOptions(() => true, "bin/index.js")))
.toMatchInlineSnapshot(`
{
"extensions.json": "{
"recommendations": [
"DavidAnson.vscode-markdownlint",
"dbaeumer.vscode-eslint",
"esbenp.prettier-vscode"
]
}
",
"launch.json": "{
"configurations": [
{
"name": "Debug Program",
"preLaunchTask": "build",
"program": "bin/index.js",
"request": "launch",
"skipFiles": ["<node_internals>/**"],
"type": "node"
}
],
"version": "0.2.0"
}
",
"settings.json": "{
"editor.codeActionsOnSave": { "source.fixAll.eslint": "explicit" },
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": true,
"editor.rulers": [80],
"eslint.probe": [
"javascript",
"javascriptreact",
"json",
"jsonc",
"markdown",
"typescript",
"typescriptreact",
"yaml"
],
"eslint.rules.customizations": [{ "rule": "*", "severity": "warn" }],
"typescript.tsdk": "node_modules/typescript/lib"
}
",
"tasks.json": "{
"tasks": [
{
"detail": "Build the project",
"label": "build",
"script": "build",
"type": "npm"
}
],
"version": "2.0.0"
}
",
}
`);
});
});
Loading
Loading