@tsed/cli-plugin-eslint 3.19.0 → 3.19.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/hooks/EslintInitHook.d.ts +5 -2
- package/lib/hooks/EslintInitHook.js +8 -3
- package/lib/hooks/EslintInitHook.js.map +1 -1
- package/package.json +3 -3
- package/templates/init/.husky/.gitignore.hbs +1 -0
- package/templates/init/.husky/_/.gitignore.hbs +1 -0
- package/templates/init/.husky/_/husky.sh.hbs +31 -0
- package/templates/init/.husky/post-commit.hbs +4 -0
- package/templates/init/.husky/pre-commit.hbs +4 -0
|
@@ -3,10 +3,13 @@ import { ProjectPackageJson, RootRendererService } from "@tsed/cli-core";
|
|
|
3
3
|
export declare class EslintInitHook {
|
|
4
4
|
protected packageJson: ProjectPackageJson;
|
|
5
5
|
protected rootRenderer: RootRendererService;
|
|
6
|
-
onExec(ctx: InitCmdContext): {
|
|
6
|
+
onExec(ctx: InitCmdContext): ({
|
|
7
7
|
title: string;
|
|
8
8
|
task: (ctx: any) => Promise<import("rxjs").Observable<unknown>>;
|
|
9
|
-
}
|
|
9
|
+
} | {
|
|
10
|
+
title: string;
|
|
11
|
+
task: () => void;
|
|
12
|
+
})[];
|
|
10
13
|
addScripts(ctx: InitCmdContext): void;
|
|
11
14
|
addDependencies(ctx: InitCmdContext): void;
|
|
12
15
|
addDevDependencies(ctx: InitCmdContext): void;
|
|
@@ -9,9 +9,6 @@ let EslintInitHook = class EslintInitHook {
|
|
|
9
9
|
if (!ctx.eslint) {
|
|
10
10
|
return [];
|
|
11
11
|
}
|
|
12
|
-
this.addScripts(ctx);
|
|
13
|
-
this.addDependencies(ctx);
|
|
14
|
-
this.addDevDependencies(ctx);
|
|
15
12
|
return [
|
|
16
13
|
{
|
|
17
14
|
title: "Generate files for eslint",
|
|
@@ -30,6 +27,14 @@ let EslintInitHook = class EslintInitHook {
|
|
|
30
27
|
templateDir: `${templateDir_1.TEMPLATE_DIR}/init`
|
|
31
28
|
});
|
|
32
29
|
}
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
title: "Add dependencies",
|
|
33
|
+
task: () => {
|
|
34
|
+
this.addScripts(ctx);
|
|
35
|
+
this.addDependencies(ctx);
|
|
36
|
+
this.addDevDependencies(ctx);
|
|
37
|
+
}
|
|
33
38
|
}
|
|
34
39
|
];
|
|
35
40
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EslintInitHook.js","sourceRoot":"","sources":["../../src/hooks/EslintInitHook.ts"],"names":[],"mappings":";;;;AACA,6CAAmG;AACnG,sDAAkD;AAGlD,IAAa,cAAc,GAA3B,MAAa,cAAc;IAQzB,MAAM,CAAC,GAAmB;QACxB,IAAI,CAAC,GAAG,CAAC,MAAM,EAAE;YACf,OAAO,EAAE,CAAC;SACX;QAED,
|
|
1
|
+
{"version":3,"file":"EslintInitHook.js","sourceRoot":"","sources":["../../src/hooks/EslintInitHook.ts"],"names":[],"mappings":";;;;AACA,6CAAmG;AACnG,sDAAkD;AAGlD,IAAa,cAAc,GAA3B,MAAa,cAAc;IAQzB,MAAM,CAAC,GAAmB;QACxB,IAAI,CAAC,GAAG,CAAC,MAAM,EAAE;YACf,OAAO,EAAE,CAAC;SACX;QAED,OAAO;YACL;gBACE,KAAK,EAAE,2BAA2B;gBAClC,IAAI,EAAE,CAAC,GAAQ,EAAE,EAAE;oBACjB,OAAO,IAAI,CAAC,YAAY,CAAC,SAAS,CAChC;wBACE,eAAe;wBACf,GAAG,CAAC,UAAU,IAAI,yBAAyB;wBAC3C,GAAG,CAAC,UAAU,IAAI,uBAAuB;wBACzC,GAAG,CAAC,UAAU,IAAI,uBAAuB;wBACzC,GAAG,CAAC,UAAU,IAAI,wBAAwB;wBAC1C,GAAG,CAAC,UAAU,IAAI,uBAAuB;wBACzC,GAAG,CAAC,UAAU,IAAI,2BAA2B;wBAC7C,GAAG,CAAC,QAAQ,IAAI,qBAAqB;wBACrC,GAAG,CA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IAAI,GAAG,CAAC,QAAQ,EAAE;YAChB,IAAI,CAAC,WAAW,CAAC,kBAAkB,CACjC;gBACE,QAAQ,EAAE,QAAQ;aACnB,EACD,GAAG,CACJ,CAAC;SACH;IACH,CAAC;CACF,CAAA;AA/FC;IADC,iBAAM,EAAE;sCACc,6BAAkB;mDAAC;AAG1C;IADC,iBAAM,EAAE;sCACe,8BAAmB;oDAAC;AAG5C;IADC,iBAAM,CAAC,MAAM,CAAC;;;;4CAsCd;AA7CU,cAAc;IAD1B,qBAAU,EAAE;GACA,cAAc,CAiG1B;AAjGY,wCAAc","sourcesContent":["import {InitCmdContext} from \"@tsed/cli\";\nimport {Inject, Injectable, OnExec, ProjectPackageJson, RootRendererService} from \"@tsed/cli-core\";\nimport {TEMPLATE_DIR} from \"../utils/templateDir\";\n\n@Injectable()\nexport class EslintInitHook {\n @Inject()\n protected packageJson: ProjectPackageJson;\n\n @Inject()\n protected rootRenderer: RootRendererService;\n\n @OnExec(\"init\")\n onExec(ctx: InitCmdContext) {\n if (!ctx.eslint) {\n return [];\n }\n\n return [\n {\n title: \"Generate files for eslint\",\n task: (ctx: any) => {\n return this.rootRenderer.renderAll(\n [\n \".eslintrc.hbs\",\n ctx.lintstaged && \".husky/_/.gitignore.hbs\",\n ctx.lintstaged && \".husky/_/husky.sh.hbs\",\n ctx.lintstaged && \".husky/.gitignore.hbs\",\n ctx.lintstaged && \".husky/post-commit.hbs\",\n ctx.lintstaged && \".husky/pre-commit.hbs\",\n ctx.lintstaged && \"lint-staged.config.js.hbs\",\n ctx.prettier && \".prettierignore.hbs\",\n ctx.prettier && \".prettierrc.hbs\"\n ],\n ctx,\n {\n templateDir: `${TEMPLATE_DIR}/init`\n }\n );\n }\n },\n {\n title: \"Add dependencies\",\n task: () => {\n this.addScripts(ctx);\n this.addDependencies(ctx);\n this.addDevDependencies(ctx);\n }\n }\n ];\n }\n\n addScripts(ctx: InitCmdContext) {\n this.packageJson.addScripts({\n \"test:lint\": \"eslint '**/*.{ts,js}'\",\n \"test:lint:fix\": \"eslint '**/*.{ts,js}' --fix\"\n });\n\n if (ctx.prettier) {\n this.packageJson.addScripts({\n prettier: \"prettier '**/*.{ts,js,json,md,yml,yaml}' --write\",\n prepare: \"is-ci || husky install\"\n });\n }\n }\n\n addDependencies(ctx: InitCmdContext) {\n this.packageJson.addDependencies({}, ctx);\n }\n\n addDevDependencies(ctx: InitCmdContext) {\n this.packageJson.addDevDependencies(\n {\n eslint: \"latest\",\n \"eslint-config-prettier\": \"latest\",\n \"eslint-plugin-prettier\": \"latest\",\n \"@typescript-eslint/parser\": \"latest\",\n \"@typescript-eslint/eslint-plugin\": \"latest\"\n },\n ctx\n );\n\n if (ctx.lintstaged) {\n this.packageJson.addDevDependencies(\n {\n \"is-ci\": \"latest\",\n husky: \"latest\",\n \"lint-staged\": \"latest\"\n },\n ctx\n );\n }\n\n if (ctx.prettier) {\n this.packageJson.addDevDependencies(\n {\n prettier: \"latest\"\n },\n ctx\n );\n }\n }\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tsed/cli-plugin-eslint",
|
|
3
|
-
"version": "3.19.
|
|
3
|
+
"version": "3.19.3",
|
|
4
4
|
"main": "./lib/index.js",
|
|
5
5
|
"typings": "./lib/index.d.ts",
|
|
6
6
|
"description": "Ts.ED CLI plugin. Add EsLint support",
|
|
7
7
|
"devDependencies": {
|
|
8
|
-
"@tsed/cli": "3.19.
|
|
9
|
-
"@tsed/cli-core": "3.19.
|
|
8
|
+
"@tsed/cli": "3.19.3",
|
|
9
|
+
"@tsed/cli-core": "3.19.3"
|
|
10
10
|
},
|
|
11
11
|
"scripts": {
|
|
12
12
|
"build": "tsc --build tsconfig.compile.json",
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
_
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
*
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
if [ -z "$husky_skip_init" ]; then
|
|
3
|
+
debug () {
|
|
4
|
+
if [ "$HUSKY_DEBUG" = "1" ]; then
|
|
5
|
+
echo "husky (debug) - $1"
|
|
6
|
+
fi
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
readonly hook_name="$(basename "$0")"
|
|
10
|
+
debug "starting $hook_name..."
|
|
11
|
+
|
|
12
|
+
if [ "$HUSKY" = "0" ]; then
|
|
13
|
+
debug "HUSKY env variable is set to 0, skipping hook"
|
|
14
|
+
exit 0
|
|
15
|
+
fi
|
|
16
|
+
|
|
17
|
+
if [ -f ~/.huskyrc ]; then
|
|
18
|
+
debug "sourcing ~/.huskyrc"
|
|
19
|
+
. ~/.huskyrc
|
|
20
|
+
fi
|
|
21
|
+
|
|
22
|
+
export readonly husky_skip_init=1
|
|
23
|
+
sh -e "$0" "$@"
|
|
24
|
+
exitCode="$?"
|
|
25
|
+
|
|
26
|
+
if [ $exitCode != 0 ]; then
|
|
27
|
+
echo "husky - $hook_name hook exited with code $exitCode (error)"
|
|
28
|
+
fi
|
|
29
|
+
|
|
30
|
+
exit $exitCode
|
|
31
|
+
fi
|