Stworzenie module-starter.

Summary:
Ref T2496

Stworzenie module starter

Reviewers: kuba-orlik

Reviewed By: kuba-orlik

Subscribers: kuba-orlik

Maniphest Tasks: T2496, T249

Differential Revision: https://hub.sealcode.org/D1181
This commit is contained in:
kittenfromvoid 2021-10-20 08:41:50 +02:00
parent ee1fb0613f
commit 3d6ed22e5f
12 changed files with 6853 additions and 0 deletions

12
.arcconfig Normal file
View File

@ -0,0 +1,12 @@
{
"phabricator.uri": "https://hub.sealcode.org/",
"arc.land.onto.default": "hotwire",
"load": [
"arcanist-linters",
"arc-unit-mocha/src"
],
"unit.engine": "MochaEngine",
"unit.mocha.include": [
".test/**/*.ts"
]
}

18
.arclint Normal file
View File

@ -0,0 +1,18 @@
{
"linters": {
"prettier": {
"type": "prettier",
"bin": "./node_modules/.bin/prettier",
"include": [
"(src/.*\\.[tj]s$)"
]
},
"eslint": {
"type": "eslint",
"include": [
"(src/.*\\.ts$)",
"(src/.*\\.js$)"
]
}
}
}

37
.eslintrc.js Normal file
View File

@ -0,0 +1,37 @@
module.exports = {
env: { node: true },
parser: "@typescript-eslint/parser",
plugins: ["@typescript-eslint", "prettier"],
extends: [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"plugin:@typescript-eslint/recommended-requiring-type-checking",
"plugin:prettier/recommended",
],
ignorePatterns: [".eslintrc.js", "src/**/*.test.ts", "@types/*"],
parserOptions: {
sourceType: "module",
ecmaFeatures: {
modules: true,
},
project: ["./tsconfig.json"],
},
rules: {
"@typescript-eslint/require-await": 0,
"no-await-in-loop": 2,
},
settings: { jsdoc: { mode: "typescript" } },
overrides: [
{
files: ["*.subtest.ts", "*.test.ts"],
rules: {
"@typescript-eslint/no-unsafe-member-access": 0,
"prefer-const": 0,
"@typescript-eslint/no-unsafe-call": 0,
"@typescript-eslint/no-unsafe-return": 0,
"@typescript-eslint/no-unsafe-assignment": 0,
"no-await-in-loop": 1, // sometimes it's easier to debug when requests run sequentially
},
},
],
};

8
.gitignore vendored
View File

@ -0,0 +1,8 @@
node_modules
lib
.idea
.xunit
.nyc_output
coverage
@types

14
.prettierrc Normal file
View File

@ -0,0 +1,14 @@
{
useTabs: true,
tabWidth: 4,
trailingComma: "es5",
"overrides": [
{
"files": "*.yml",
"options": {
"tabWidth": 2,
"useTabs": false
}
}
]
}

3
jenkins.sanity.sh Normal file
View File

@ -0,0 +1,3 @@
#!/bin/bash -xe
npm run test
npm run build

6620
package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

31
package.json Normal file
View File

@ -0,0 +1,31 @@
{
"name": "module-starter",
"version": "0.0.1",
"description": "module template",
"main": "lib/index.js",
"scripts": {
"test": "node test.js",
"build": "tsc",
"prepare": "npm run build",
"test-reports": "npm run build && rm -fr .xunit coverage && npm run test -- --cover --test-report"
},
"author": "",
"license": "ISC",
"devDependencies": {
"@types/mocha": "^9.0.0",
"@typescript-eslint/eslint-plugin": "^4.29.3",
"@typescript-eslint/parser": "^4.29.3",
"eslint": "^7.32.0",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-prettier": "^3.4.1",
"eslint-plugin-with-tsc-error": "^0.0.7",
"mocha": "^9.1.1",
"mri": "^1.1.6",
"nyc": "^15.1.0",
"prettier": "^2.3.2",
"source-map-support": "^0.5.19",
"ts-node": "^10.2.1",
"typescript": "^4.3.5"
},
"types": "./@types/index.d.ts"
}

11
src/example.test.ts Normal file
View File

@ -0,0 +1,11 @@
import { Example } from "./index";
import * as assert from "assert";
describe("Example", () => {
describe("example", () => {
it("should equal 'example'", () => {
const example = new Example();
assert.equal(example.example(), "example");
});
});
});

5
src/index.ts Normal file
View File

@ -0,0 +1,5 @@
export class Example {
example(): string {
return "example";
}
}

68
test.js Normal file
View File

@ -0,0 +1,68 @@
const mri = require("mri");
const { spawn } = require("child_process");
const argv = process.argv.slice(2);
const args = mri(argv);
const bin_dir = "./node_modules/.bin/";
const mocha = bin_dir + "mocha";
let mocha_options = [
"--recursive",
"--timeout=10000",
"--require",
"source-map-support/register",
"-r",
" ts-node/register"
];
if (args["test-report"]) {
mocha_options = [
...mocha_options,
"--reporter",
"xunit",
"--reporter-option",
"output=.xunit",
];
}
const mocha_files = ["src/**/*.test.ts"];
let command = [mocha, ...mocha_options, ...mocha_files];
if (args.cover) {
const nyc = [
bin_dir + "nyc",
"-all",
"--exclude",
"lib",
"--source-map",
"false",
];
if (args["cover-html"]) {
nyc.push("--reporter", "lcov");
} else {
nyc.push("--reporter", "clover");
}
command = [...nyc, ...command];
}
if (args.debug) {
command = ["node", "inspect", ...command];
}
console.log("spawning mocha...", command);
const proc = spawn(command[0], command.slice(1), {
stdio: "inherit",
env: process.env,
});
proc.on("exit", function (code) {
if (args["test-report"]) {
process.exit(0);
} else {
process.exit(code);
}
});

26
tsconfig.json Normal file
View File

@ -0,0 +1,26 @@
{
"compilerOptions": {
"module": "commonjs",
"moduleResolution": "node",
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"target": "ES6",
"declaration": true,
"esModuleInterop": true,
"lib": [
"ES6",
"ESNext"
],
"outDir": "lib",
"checkJs": true,
"allowJs": true,
"declarationDir": "@types",
"resolveJsonModule": true,
"sourceMap": true
},
"include":[
"src/**/*"
],
"exclude": ["src/**/*.test.ts"]
}