Skip to content

Commit

Permalink
feat(create-indiekit): add config to debug Indiekit in VS Code
Browse files Browse the repository at this point in the history
  • Loading branch information
jackdbd committed Oct 15, 2024
1 parent 86b654f commit 8bd2e7b
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 14 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
"lint:fix": "npm run lint:prettier:fix && npm run lint:js:fix && npm run lint:css:fix",
"test": "node --test --test-reporter=spec",
"test:coverage": "node --test --experimental-test-coverage",
"test:create-indiekit": "lerna run test --scope create-indiekit",
"test:lcov": "node --test --experimental-test-coverage --test-reporter=lcov --test-reporter-destination=coverage/lcov.info"
},
"workspaces": [
Expand Down
18 changes: 18 additions & 0 deletions packages/create-indiekit/files/template.vscode_launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Debug Indiekit",
"skipFiles": ["<node_internals>/**"],
"program": "${workspaceFolder}/node_modules/@indiekit/indiekit/bin/cli.js",
// "args": ["--config", "path/to/your/indiekit.config.js"]
"args": ["serve"],
"env": {
"GITHUB_TOKEN": "${env:GITHUB_TOKEN}",
"MONGO_URL": "${env:MONGO_URL}"
}
}
]
}
4 changes: 4 additions & 0 deletions packages/create-indiekit/lib/files.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ export const getFiles = async (setup) => {
path: ".gitignore",
contents: await getFileContents("template.gitignore"),
},
{
path: path.join(".vscode", "launch.json"),
contents: await getFileContents("template.vscode_launch.json"),
},
];

if (useDocker) {
Expand Down
6 changes: 5 additions & 1 deletion packages/create-indiekit/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"type": "module",
"main": "index.js",
"bin": {
"create-indiekit": "bin/create.js"
"create-indiekit": "bin/create.js delete-me"
},
"files": [
"bin",
Expand All @@ -35,6 +35,10 @@
"url": "https://github.com/getindiekit/indiekit.git",
"directory": "packages/create-indiekit"
},
"scripts": {
"create": "node bin/create.js",
"test": "node --test --test-reporter=spec"
},
"dependencies": {
"@indiekit/preset-eleventy": "^1.0.0-beta.10",
"@indiekit/preset-hugo": "^1.0.0-beta.10",
Expand Down
28 changes: 15 additions & 13 deletions packages/create-indiekit/test/unit/files.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { strict as assert } from "node:assert";
import path from "node:path";
import { describe, it, mock } from "node:test";
import { getFileContents, getFiles } from "../../lib/files.js";

Expand All @@ -23,16 +24,17 @@ describe("create-indiekit/lib/files", () => {
it("Gets files to create", async () => {
const result = await getFiles({ me: "https://website.example" });

assert.deepEqual(result, [
{
path: "README.md",
contents: `# Indiekit server for https://website.example\n\nLearn more at <https://getindiekit.com>\n`,
},
{
path: ".gitignore",
contents: "node_modules/\n",
},
]);
assert.deepEqual(result[0], {
path: "README.md",
contents: `# Indiekit server for https://website.example\n\nLearn more at <https://getindiekit.com>\n`,
});

assert.deepEqual(result[1], {
path: ".gitignore",
contents: "node_modules/\n",
});

assert.equal(result[2].path, path.join(".vscode", "launch.json"));
});

it("Gets files to create, including docker files", async () => {
Expand All @@ -41,8 +43,8 @@ describe("create-indiekit/lib/files", () => {
useDocker: true,
});

assert.equal(result[2].path, "docker-compose.yml");
assert.equal(result[3].path, "Dockerfile");
assert.equal(result[4].path, ".dockerignore");
assert.equal(result[3].path, "docker-compose.yml");
assert.equal(result[4].path, "Dockerfile");
assert.equal(result[5].path, ".dockerignore");
});
});

0 comments on commit 8bd2e7b

Please sign in to comment.