@langri-sha/projen-husky 0.1.0

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/CHANGELOG.json ADDED
@@ -0,0 +1,20 @@
1
+ {
2
+ "name": "@langri-sha/projen-husky",
3
+ "entries": [
4
+ {
5
+ "date": "Thu, 09 May 2024 07:29:32 GMT",
6
+ "version": "0.1.0",
7
+ "tag": "@langri-sha/projen-husky_v0.1.0",
8
+ "comments": {
9
+ "minor": [
10
+ {
11
+ "author": "filip.dupanovic@gmail.com",
12
+ "package": "@langri-sha/projen-husky",
13
+ "commit": "508fb179ee3454c0e43f7ea2a9ed25ca6310e27b",
14
+ "comment": "feat(husky): Add support for managing Git hooks"
15
+ }
16
+ ]
17
+ }
18
+ }
19
+ ]
20
+ }
package/CHANGELOG.md ADDED
@@ -0,0 +1,13 @@
1
+ # Change Log - @langri-sha/projen-husky
2
+
3
+ This log was last generated on Thu, 09 May 2024 07:29:32 GMT and should not be manually modified.
4
+
5
+ <!-- Start content -->
6
+
7
+ ## 0.1.0
8
+
9
+ Thu, 09 May 2024 07:29:32 GMT
10
+
11
+ ### Minor changes
12
+
13
+ - feat(husky): Add support for managing Git hooks (filip.dupanovic@gmail.com)
package/lib/index.d.ts ADDED
@@ -0,0 +1,16 @@
1
+ import { Component, type Project } from 'projen';
2
+ type Hooks = 'pre-commit' | 'applypatch-msg' | 'pre-applypatch' | 'post-applypatch' | 'pre-commit' | 'pre-merge-commit' | 'prepare-commit-msg' | 'commit-msg' | 'post-commit' | 'pre-rebase' | 'post-checkout' | 'post-merge' | 'pre-push';
3
+ /**
4
+ * Husky options.
5
+ */
6
+ export type HuskyOptions = {
7
+ [hook in Hooks]?: string | string[];
8
+ };
9
+ /**
10
+ * A component for maintaining Git hooks with Husky.
11
+ */
12
+ export declare class Husky extends Component {
13
+ constructor(project: Project, options?: HuskyOptions);
14
+ }
15
+ export {};
16
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,KAAK,OAAO,EAAY,MAAM,QAAQ,CAAA;AAE1D,KAAK,KAAK,GACN,YAAY,GACZ,gBAAgB,GAChB,gBAAgB,GAChB,iBAAiB,GACjB,YAAY,GACZ,kBAAkB,GAClB,oBAAoB,GACpB,YAAY,GACZ,aAAa,GACb,YAAY,GACZ,eAAe,GACf,YAAY,GACZ,UAAU,CAAA;AAEd;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG;KACxB,IAAI,IAAI,KAAK,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE;CACpC,CAAA;AAED;;GAEG;AACH,qBAAa,KAAM,SAAQ,SAAS;gBACtB,OAAO,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE,YAAY;CAwBrD"}
package/lib/index.js ADDED
@@ -0,0 +1,25 @@
1
+ import path from 'node:path';
2
+ import { Component, TextFile } from 'projen';
3
+ /**
4
+ * A component for maintaining Git hooks with Husky.
5
+ */
6
+ export class Husky extends Component {
7
+ constructor(project, options) {
8
+ super(project);
9
+ for (const [hook, commands] of Object.entries(options ?? {}).map(([hook, commands]) => [hook, Array.isArray(commands) ? commands : [commands]])) {
10
+ const file = new TextFile(project, path.join('.husky', hook), {
11
+ editGitignore: false,
12
+ marker: true,
13
+ readonly: true,
14
+ });
15
+ if (!project.ejected) {
16
+ file.addLine(`# ${file.marker}`);
17
+ }
18
+ for (const command of commands) {
19
+ file.addLine(command);
20
+ }
21
+ file.addLine('');
22
+ }
23
+ }
24
+ }
25
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAA;AAC5B,OAAO,EAAE,SAAS,EAAgB,QAAQ,EAAE,MAAM,QAAQ,CAAA;AAwB1D;;GAEG;AACH,MAAM,OAAO,KAAM,SAAQ,SAAS;IAClC,YAAY,OAAgB,EAAE,OAAsB;QAClD,KAAK,CAAC,OAAO,CAAC,CAAA;QAEd,KAAK,MAAM,CAAC,IAAI,EAAE,QAAQ,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,OAAO,IAAI,EAAE,CAAC,CAAC,GAAG,CAC9D,CAAC,CAAC,IAAI,EAAE,QAAQ,CAAC,EAAE,EAAE,CACnB,CAAC,IAAI,EAAE,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAU,CACnE,EAAE,CAAC;YACF,MAAM,IAAI,GAAG,IAAI,QAAQ,CAAC,OAAO,EAAE,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,EAAE;gBAC5D,aAAa,EAAE,KAAK;gBACpB,MAAM,EAAE,IAAI;gBACZ,QAAQ,EAAE,IAAI;aACf,CAAC,CAAA;YAEF,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC;gBACrB,IAAI,CAAC,OAAO,CAAC,KAAK,IAAI,CAAC,MAAM,EAAE,CAAC,CAAA;YAClC,CAAC;YAED,KAAK,MAAM,OAAO,IAAI,QAAQ,EAAE,CAAC;gBAC/B,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,CAAA;YACvB,CAAC;YAED,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,CAAA;QAClB,CAAC;IACH,CAAC;CACF"}
package/license ADDED
@@ -0,0 +1,20 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 Filip Dupanović <filip.dupanovic@gmail.com> (https://langri-sha.com)
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
6
+ this software and associated documentation files (the "Software"), to deal in
7
+ the Software without restriction, including without limitation the rights to
8
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9
+ the Software, and to permit persons to whom the Software is furnished to do so,
10
+ subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package/package.json ADDED
@@ -0,0 +1,25 @@
1
+ {
2
+ "name": "@langri-sha/projen-husky",
3
+ "version": "0.1.0",
4
+ "license": "MIT",
5
+ "type": "module",
6
+ "main": "lib/index.js",
7
+ "scripts": {
8
+ "prepublishOnly": "rm -rf lib; tsc --project tsconfig.build.json"
9
+ },
10
+ "devDependencies": {
11
+ "@langri-sha/jest-test": "0.7.1",
12
+ "@langri-sha/tsconfig": "0.9.0",
13
+ "@types/node": "20.12.7",
14
+ "projen": "0.81.1"
15
+ },
16
+ "peerDependencies": {
17
+ "husky": "^9.0.0",
18
+ "projen": "^0.81.1",
19
+ "typescript": "^5.0.0"
20
+ },
21
+ "publishConfig": {
22
+ "access": "public"
23
+ },
24
+ "types": "lib/index.d.ts"
25
+ }
package/readme ADDED
@@ -0,0 +1,29 @@
1
+ # @langri-sha/projen-codeowners
2
+
3
+ A [projen] component for managing [CODEOWNERS].
4
+
5
+ ## Usage
6
+
7
+ ```sh
8
+ npm install -D projen @langri-sha/projen-codeowners`.
9
+ ```
10
+
11
+ Then, create the `Codeowners` component for your root project:
12
+
13
+ ```js
14
+ import { Project } from 'projen'
15
+ import { Codeowners } from '@langri-sha/projen-codeowners`
16
+
17
+ const project = new Project({
18
+ name: 'my-project',
19
+ })
20
+
21
+ new Codeowners(project, {
22
+ '*': '@admins',
23
+ '*.js': ['@developers', '@frontend']
24
+ }
25
+ ```
26
+
27
+ [projen]: https://projen.io/
28
+ [codeowners]:
29
+ https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/customizing-your-repository/about-code-owners
package/src/index.ts ADDED
@@ -0,0 +1,54 @@
1
+ import path from 'node:path'
2
+ import { Component, type Project, TextFile } from 'projen'
3
+
4
+ type Hooks =
5
+ | 'pre-commit'
6
+ | 'applypatch-msg'
7
+ | 'pre-applypatch'
8
+ | 'post-applypatch'
9
+ | 'pre-commit'
10
+ | 'pre-merge-commit'
11
+ | 'prepare-commit-msg'
12
+ | 'commit-msg'
13
+ | 'post-commit'
14
+ | 'pre-rebase'
15
+ | 'post-checkout'
16
+ | 'post-merge'
17
+ | 'pre-push'
18
+
19
+ /**
20
+ * Husky options.
21
+ */
22
+ export type HuskyOptions = {
23
+ [hook in Hooks]?: string | string[]
24
+ }
25
+
26
+ /**
27
+ * A component for maintaining Git hooks with Husky.
28
+ */
29
+ export class Husky extends Component {
30
+ constructor(project: Project, options?: HuskyOptions) {
31
+ super(project)
32
+
33
+ for (const [hook, commands] of Object.entries(options ?? {}).map(
34
+ ([hook, commands]) =>
35
+ [hook, Array.isArray(commands) ? commands : [commands]] as const,
36
+ )) {
37
+ const file = new TextFile(project, path.join('.husky', hook), {
38
+ editGitignore: false,
39
+ marker: true,
40
+ readonly: true,
41
+ })
42
+
43
+ if (!project.ejected) {
44
+ file.addLine(`# ${file.marker}`)
45
+ }
46
+
47
+ for (const command of commands) {
48
+ file.addLine(command)
49
+ }
50
+
51
+ file.addLine('')
52
+ }
53
+ }
54
+ }