Skip to content

Commit aa4064c

Browse files
committed
build
1 parent 6bb3359 commit aa4064c

13 files changed

Lines changed: 119 additions & 26 deletions

File tree

.config/eslint/tsconfig.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
{
2-
"extends": "../typescript/tsconfig.node.json"
2+
"extends": "../typescript/tsconfig.node.json",
3+
"compilerOptions": {
4+
"noEmitOnError": true
5+
}
36
}

ReadMe.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# 🚧

create-devcontainer/configs/typescript/workspace.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,11 @@ export const createTypeScriptWorkspaceConfigs = async (
6060
},
6161
dependencies: {
6262
...dependencies,
63+
...commanderVersion,
6364
eslint: "^8.57.0", // Wait until typescript-eslint updates peer dependencies to ESLint 9
6465
},
6566
devDependencies: {
6667
...devDependencies,
67-
...commanderVersion,
6868
},
6969
}),
7070
),

create-devcontainer/formatting.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import type { ConfigFile } from "./types.js";
44

55
export const prettierConfig: prettier.Config = {
66
printWidth: 120,
7-
plugins: ["prettier-plugin-packagejson"],
7+
plugins: [import.meta.resolve("prettier-plugin-packagejson")],
88
};
99

1010
export const stringify = (value: unknown): string => JSON.stringify(value, null, 2);

create-devcontainer/index.ts

Lines changed: 36 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,40 @@
1+
import { mkdir, writeFile } from "node:fs/promises";
2+
import path from "node:path";
3+
4+
import { Argument, program } from "@commander-js/extra-typings";
5+
16
import { createBaseConfigs } from "./configs/base/index.js";
27
import { createTypeScriptConfigs } from "./configs/typescript/index.js";
38
import { formatConfigs } from "./formatting.js";
9+
import { packageJson } from "./package.js";
10+
import type { ConfigFile } from "./types.js";
11+
12+
program.name(packageJson.name).version(packageJson.version);
13+
14+
program
15+
.addArgument(
16+
new Argument("[template]", "specify a template for the devcontainer")
17+
.choices(["base", "typescript"])
18+
.default("base"),
19+
)
20+
.action(async (template) => {
21+
const currentPath = process.cwd();
22+
const projectName = path.basename(currentPath) || "project";
23+
24+
const baseConfig = await createBaseConfigs(projectName);
25+
26+
let configFiles: ConfigFile[] = [];
27+
if (template === "base") {
28+
configFiles = await formatConfigs({ ...baseConfig });
29+
} else if (template === "typescript") {
30+
const configs = await createTypeScriptConfigs(baseConfig);
31+
configFiles = await formatConfigs({ ...configs });
32+
}
33+
for (const configFile of configFiles) {
34+
const filePath = path.resolve(currentPath, configFile.path);
35+
await mkdir(path.dirname(filePath), { recursive: true });
36+
await writeFile(filePath, configFile.content);
37+
}
38+
});
439

5-
const baseConfigs = await createBaseConfigs("test");
6-
const typeScriptConfigs = await createTypeScriptConfigs(baseConfigs);
7-
const configFiles = await formatConfigs({ ...typeScriptConfigs });
8-
for (const configFile of configFiles) {
9-
console.log(configFile.path);
10-
console.log(configFile.content);
11-
}
40+
await program.parseAsync();

create-devcontainer/package.json

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"name": "create-devcontainer",
3+
"version": "0.0.0",
34
"description": "TODO",
45
"keywords": [
56
"create",
@@ -8,17 +9,10 @@
89
"setup"
910
],
1011
"type": "module",
11-
"exports": {
12-
"development": {
13-
"import": "./src/index.ts"
14-
},
15-
"default": {
16-
"types": "./dist/index.d.ts",
17-
"import": "./dist/index.js"
18-
}
19-
},
20-
"bin": "./dist/index.js",
12+
"bin": "./index.js",
2113
"dependencies": {
14+
"@commander-js/extra-typings": "^12.1.0",
15+
"commander": "~12.1.0",
2216
"cspell-lib": "^8.8.1",
2317
"dedent": "^1.5.3",
2418
"default-composer": "^0.6.0",

create-devcontainer/package.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import { createRequire } from "node:module";
2+
3+
import type pkg from "./package.json";
4+
5+
const require = createRequire(import.meta.url);
6+
export const packageJson = require("./package.json") as typeof pkg;
Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
{
2-
"extends": "../typescript/tsconfig.node.json"
2+
"extends": "../typescript/tsconfig.node.json",
3+
"compilerOptions": {
4+
"noEmitOnError": true
5+
}
36
}

create-devcontainer/templates/typescript/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"@commander-js/extra-typings": "^12.1.0",
66
"@eslint/js": "^9.2.0",
77
"@tsconfig/node20": "^20.1.4",
8+
"commander": "~12.1.0",
89
"cspell": "^8.8.1",
910
"eslint": "^8.57.0",
1011
"eslint-config-prettier": "^9.1.0",
@@ -24,7 +25,6 @@
2425
"@types/eslint": "^8.56.10",
2526
"@types/eslint-config-prettier": "^6.11.3",
2627
"@types/eslint__js": "^8.42.3",
27-
"@types/node": "^20.12.11",
28-
"commander": "~12.1.0"
28+
"@types/node": "^20.12.11"
2929
}
3030
}

create-devcontainer/tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@
55
"declaration": true,
66
"outDir": "dist/"
77
},
8-
"exclude": ["templates"]
8+
"exclude": ["templates", "dist"]
99
}

0 commit comments

Comments
 (0)