[language]
binary = "node"
name = "typescript"
version = "3.10"

[project]
dependencies = []
dev_dependencies = [
  "typescript",
  "@types/node",
  "ts-node",
  "ts-node-dev",
  "jest",
  "@jest/globals",
  "@types/jest",
  "ts-jest",
  "eslint",
  "@typescript-eslint/parser",
  "@typescript-eslint/eslint-plugin",
  "prettier",
  "eslint-config-prettier",
]

[project.tool]
binary = "pnpm"

[project.tool.commands]
initializers = [["init"]]
add_dependency = ["add"]
add_development_dependency = ["add", "--save-dev"]
run_tests = ["test"]

[[project.post.commands]]
command = "pnpm"
args = ["pkg", "set", "name=$PROJECT_NAME"]

[[project.post.commands]]
command = "pnpm"
args = [
  "pkg",
  "set",
  "scripts.start-dev=npx ts-node-dev --respawn --pretty --transpile-only src/index.ts",
]

[[project.post.commands]]
command = "pnpm"
args = ["pkg", "set", "scripts.test=npx jest"]

[[project.post.commands]]
command = "pnpm"
args = ["pkg", "set", "scripts.prettier=npx prettier . --write"]

[[project.post.commands]]
command = "pnpm"
args = ["pkg", "set", "scripts.lint=npx eslint ."]

[code.directories]
source = "src"
test = "test"

[[code.source]]
file = "main.ts"
variant = "leet"
contents = '''
export function leet(arg1: string): number {
  return arg1.length;
}
'''


[[code.source]]
file = "main.ts"
contents = '''
export function _(input: number[]): number[] {
  return [];
}
'''


[[code.test]]
file = "main.test.ts"
contents = '''
import { describe, expect, test } from "@jest/globals";
import { _ } from "../src/main";

describe("tests should pass", () => {
  test("one", () => {
    const inputOne: number[] = [];
    const expectedOutput: number[] = [];
    const outputOne = _(inputOne);
    expect(outputOne).toEqual(expectedOutput);
  });

  test("two", () => {
    const inputTwo: number[] = [];
    const expectedOutput: number[] = [];
    const outputTwo = _(inputTwo);
    expect(outputTwo).toEqual(expectedOutput);
  });
});
'''

[[code.test]]
file = "main.test.ts"
variant = "leet"
contents = '''
import { describe, expect, test } from "@jest/globals";
import { leet } from "../src/main";

describe("tests should pass", () => {
  test("one", () => {
    const inputOne = "yes";
    const expectedOutput = 3;
    const output = leet(inputOne);
    expect(output).toEqual(expectedOutput);
  });
});
'''


[[config]]
file = "jest.config.js"
contents = '''
module.exports = {
  preset: "ts-jest",
  testEnvironment: "node",
};
'''


[[config]]
file = "tsconfig.json"
contents = '''
{
  "compilerOptions": {
    "esModuleInterop": true,
    "module": "commonjs",
    "moduleResolution": "node",
    "noImplicitAny": true,
    "outDir": "dist",
    "sourceMap": true,
    "strict": true,
    "target": "es6"
  },
  "lib": ["es2015"]
}
'''

[[config]]
file = ".eslintrc.js"
contents = '''
module.exports = {
  env: {
    es2022: true,
    node: true,
  },
  extends: [
    "eslint:recommended",
    "plugin:@typescript-eslint/recommended",
    "prettier",
  ],
  ignorePatterns: ["dist", "build"],
  parser: "@typescript-eslint/parser",
  parserOptions: {
    ecmaVersion: "latest",
    sourceType: "module",
  },
  plugins: ["@typescript-eslint"],
  rules: {},
};
'''
