@visualon/gitea-releaser 0.0.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/.editorconfig ADDED
@@ -0,0 +1,24 @@
1
+ # EditorConfig is awesome:http://EditorConfig.org
2
+
3
+ # top-most EditorConfig file
4
+ root = true
5
+
6
+ # Don't use tabs for indentation.
7
+ [*]
8
+ charset = utf-8
9
+ indent_style = space
10
+ indent_size = 2
11
+ insert_final_newline = true
12
+ trim_trailing_whitespace = true
13
+ max_line_length = 160
14
+ end_of_line = lf
15
+
16
+ # Markdown files
17
+ [*.md]
18
+ max_line_length = off
19
+ trim_trailing_whitespace = false
20
+
21
+
22
+ [*.{cmd,bat}]
23
+ end_of_line = crlf
24
+
package/.eslintignore ADDED
@@ -0,0 +1,28 @@
1
+ /.git/
2
+ /coverage/
3
+ /docs/
4
+ /node_modules/
5
+
6
+ obj/
7
+ bin/
8
+ /tmp/
9
+
10
+ /sp/
11
+ /src/
12
+ /test/
13
+ /Client/
14
+
15
+ libs/scripting/src/lib/placeholder/PlaceholderScriptLexer.ts
16
+ libs/scripting/src/lib/placeholder/PlaceholderScriptParser.ts
17
+
18
+ # angular
19
+ /.angular/
20
+ /dist/
21
+ /.nx/cache
22
+
23
+ # yarn v2+
24
+ .pnp.*
25
+ .yarn/*
26
+
27
+
28
+ /.pnpm-store
package/.eslintrc.json ADDED
@@ -0,0 +1,168 @@
1
+ {
2
+ "root": true,
3
+ "plugins": ["@nx", "jest"],
4
+ "overrides": [
5
+ {
6
+ "files": ["*.ts", "*.tsx"],
7
+ "extends": ["plugin:@nx/typescript"],
8
+ "rules": {}
9
+ },
10
+ {
11
+ "files": ["*.js", "*.jsx", "*.mjs"],
12
+ "extends": ["plugin:@nx/javascript"],
13
+ "rules": {}
14
+ },
15
+ {
16
+ "files": ["*.ts", "*.tsx", "*.js", "*.jsx", "*.mjs"],
17
+ "parserOptions": {
18
+ "project": ["./tsconfig.*?.json"],
19
+ "extraFileExtensions": [".mjs"]
20
+ },
21
+ "plugins": ["@angular-eslint/eslint-plugin", "@typescript-eslint"],
22
+ "extends": [
23
+ "eslint:recommended",
24
+ "plugin:import/errors",
25
+ "plugin:import/warnings",
26
+ "plugin:import/typescript",
27
+ "plugin:jest/recommended",
28
+ "plugin:jest/style",
29
+ "plugin:@typescript-eslint/eslint-recommended",
30
+ "plugin:@typescript-eslint/recommended",
31
+ "plugin:@typescript-eslint/recommended-requiring-type-checking",
32
+ "plugin:promise/recommended",
33
+ "plugin:jest-formatting/recommended",
34
+ "plugin:@angular-eslint/recommended",
35
+ "plugin:@angular-eslint/template/process-inline-templates",
36
+ "prettier"
37
+ ],
38
+ "settings": {
39
+ "import/resolver": {
40
+ "typescript": {
41
+ "project": "./tsconfig.base.json"
42
+ }
43
+ }
44
+ },
45
+ "rules": { "import/no-cycle": 2 }
46
+ },
47
+ {
48
+ "files": ["*.ts"],
49
+ "rules": {
50
+ "@typescript-eslint/explicit-member-accessibility": "off",
51
+ "@typescript-eslint/explicit-function-return-type": "off",
52
+ "@typescript-eslint/interface-name-prefix": 0,
53
+ "@typescript-eslint/no-empty-interface": [
54
+ "error",
55
+ {
56
+ "allowSingleExtends": true
57
+ }
58
+ ],
59
+ "@typescript-eslint/no-parameter-properties": "off",
60
+ "@typescript-eslint/no-unused-vars": [
61
+ 2,
62
+ {
63
+ "vars": "all",
64
+ "args": "after-used",
65
+ "ignoreRestSiblings": false,
66
+ "argsIgnorePattern": "^_"
67
+ }
68
+ ],
69
+ "@typescript-eslint/no-unsafe-member-access": 1,
70
+ "@typescript-eslint/no-unsafe-assignment": 1,
71
+ "@typescript-eslint/no-redundant-type-constituents": 1,
72
+ "@typescript-eslint/no-base-to-string": 1,
73
+ "curly": [2, "all"],
74
+ "no-restricted-imports": [
75
+ "error",
76
+ {
77
+ "paths": ["lodash"]
78
+ }
79
+ ],
80
+ "import/default": 0,
81
+ "import/named": 0,
82
+ "import/namespace": 0,
83
+ "import/no-named-as-default-member": 0,
84
+ "import/order": [
85
+ "error",
86
+ {
87
+ "alphabetize": {
88
+ "order": "asc"
89
+ }
90
+ }
91
+ ],
92
+ "sort-imports": [
93
+ "error",
94
+ {
95
+ "ignoreCase": false,
96
+ "ignoreDeclarationSort": true,
97
+ "ignoreMemberSort": false,
98
+ "memberSyntaxSortOrder": ["none", "all", "multiple", "single"]
99
+ }
100
+ ]
101
+ }
102
+ },
103
+ {
104
+ "files": ["jest.*.{js,mjs}", "*.config.{js,mjs}", "tools/**/*.mjs"],
105
+ "env": {
106
+ "node": true
107
+ },
108
+ "rules": {
109
+ "@typescript-eslint/no-unused-vars": "off",
110
+ "@typescript-eslint/no-unsafe-assignment": 0,
111
+ "@typescript-eslint/no-var-requires": 0,
112
+ "@typescript-eslint/restrict-template-expressions": 0,
113
+ "@typescript-eslint/no-unsafe-return": 0,
114
+ "@typescript-eslint/no-unsafe-call": 0,
115
+ "@typescript-eslint/no-unsafe-member-access": 0
116
+ }
117
+ },
118
+ {
119
+ "files": ["__mocks__/**.js"],
120
+ "env": {
121
+ "node": true
122
+ }
123
+ },
124
+ {
125
+ "files": ["{libs,apps}/**/*.ts"],
126
+ "env": {
127
+ "browser": true
128
+ },
129
+ "rules": {
130
+ "@typescript-eslint/restrict-template-expressions": [
131
+ "error",
132
+ {
133
+ "allowBoolean": true,
134
+ "allowNullish": true
135
+ }
136
+ ]
137
+ }
138
+ },
139
+ {
140
+ "files": ["{libs,apps}/**/*.spec.ts"],
141
+ "env": {
142
+ "jest/globals": true,
143
+ "node": true
144
+ },
145
+ "rules": {
146
+ "@nx/enforce-module-boundaries": [
147
+ "error",
148
+ {
149
+ "enforceBuildableLibDependency": true,
150
+ "allow": [],
151
+ "depConstraints": [
152
+ {
153
+ "sourceTag": "*",
154
+ "onlyDependOnLibsWithTags": ["*"]
155
+ }
156
+ ]
157
+ }
158
+ ]
159
+ }
160
+ },
161
+ {
162
+ "files": ["*.html"],
163
+ "parser": "@angular-eslint/template-parser",
164
+ "plugins": ["@angular-eslint/template"],
165
+ "rules": {}
166
+ }
167
+ ]
168
+ }
@@ -0,0 +1,32 @@
1
+ name: publish
2
+
3
+ on:
4
+ push:
5
+ tags:
6
+ - v*
7
+
8
+ permissions:
9
+ contents: read
10
+
11
+ jobs:
12
+ publish-npm:
13
+ runs-on: ubuntu-latest
14
+
15
+ permissions:
16
+ contents: write
17
+
18
+ steps:
19
+ - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
20
+ - run: corepack enable
21
+ - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1
22
+ with:
23
+ node-version-file: .node-version
24
+ registry-url: https://registry.npmjs.org/
25
+ - run: pnpm install
26
+ - run: pnpm version ${GITHUB_REF_NAME#v}
27
+ - run: pnpm publish --access public
28
+ env:
29
+ NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
30
+ - uses: ncipollo/release-action@6c75be85e571768fa31b40abf38de58ba0397db5 # v1.13.0
31
+ with:
32
+ generateReleaseNotes: true
@@ -0,0 +1,34 @@
1
+ name: test
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - main
7
+ merge_group:
8
+ pull_request:
9
+ branches:
10
+ - main
11
+
12
+ permissions:
13
+ contents: read
14
+
15
+ concurrency:
16
+ group: ${{ github.workflow }}-${{ github.event.number || github.ref }}
17
+ cancel-in-progress: true
18
+
19
+ jobs:
20
+ test:
21
+ runs-on: ubuntu-latest
22
+ steps:
23
+ - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
24
+
25
+ - run: corepack enable
26
+
27
+ - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1
28
+ with:
29
+ node-version-file: .node-version
30
+
31
+ - run: pnpm install
32
+
33
+ - run: pnpm lint:prettier
34
+ - run: pnpm pack
@@ -0,0 +1,6 @@
1
+ #!/bin/sh
2
+
3
+ # shellcheck source=/dev/null
4
+ . "$(dirname "$0")/_/husky.sh"
5
+
6
+ pnpm lint-staged
@@ -0,0 +1,5 @@
1
+ {
2
+ "*.{ts,js,mjs,cjs}": ["prettier --cache --write"],
3
+ "*.md": ["markdownlint-cli2-fix", "prettier --cache --write"],
4
+ "!*.{cjs,js,mjs,md,ts}": "prettier --cache --ignore-unknown --write"
5
+ }
@@ -0,0 +1,26 @@
1
+ {
2
+ "config": {
3
+ "extends": "markdownlint/style/prettier",
4
+ "list-marker-space": {
5
+ "ul_multi": 1,
6
+ "ul_single": 1
7
+ },
8
+ "ul-indent": {
9
+ "indent": 2
10
+ },
11
+
12
+ // Disable some built-in rules
13
+ "no-emphasis-as-heading": false,
14
+ "first-line-heading": false,
15
+ "line-length": false,
16
+ "no-emphasis-as-header": false,
17
+ "no-inline-html": false,
18
+ "single-h1": false
19
+ },
20
+
21
+ // Define glob expressions to use (only valid at root)
22
+ // "globs": ["**/*.md"],
23
+
24
+ // Define glob expressions to ignore
25
+ "ignores": [".yarn", "**/node_modules/**", "**/TestResults/**", "**/bin/**", "**/obj/**", "coverage/", "LICENSE"]
26
+ }
package/.node-version ADDED
@@ -0,0 +1 @@
1
+ 20.10.0
@@ -0,0 +1,27 @@
1
+ # Add files here to ignore them from prettier formatting
2
+ yarn.lock
3
+ /.git/
4
+
5
+ libs/scripting/src/lib/placeholder/PlaceholderScriptLexer.ts
6
+ libs/scripting/src/lib/placeholder/PlaceholderScriptParser.ts
7
+
8
+ bin/
9
+ obj/
10
+ coverage/
11
+ .coverage/
12
+ dist/
13
+ /.angular/
14
+ /tmp/
15
+ /.vs/
16
+ node_modules/
17
+
18
+ # yarn v2+
19
+ /.yarn/*
20
+ /.pnp.*
21
+
22
+ .eslintcache
23
+
24
+ /.nx/cache
25
+
26
+ pnpm-lock.yaml
27
+ /.pnpm-store
@@ -0,0 +1,5 @@
1
+ {
2
+ "singleQuote": true,
3
+ "trailingComma": "all",
4
+ "plugins": ["prettier-plugin-packagejson"]
5
+ }
package/LICENSE ADDED
@@ -0,0 +1,9 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 VisualOn GmbH
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6
+
7
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8
+
9
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,3 @@
1
+ # gitea-releaser
2
+
3
+ gitea releaser tool
package/package.json ADDED
@@ -0,0 +1,31 @@
1
+ {
2
+ "name": "@visualon/gitea-releaser",
3
+ "version": "0.0.3",
4
+ "license": "MIT",
5
+ "author": "VisualOn GmbH",
6
+ "type": "module",
7
+ "bin": "./src/index.js",
8
+ "dependencies": {
9
+ "clipanion": "4.0.0-rc.2",
10
+ "conventional-changelog-conventionalcommits": "7.0.2",
11
+ "conventional-changelog-core": "7.0.0"
12
+ },
13
+ "devDependencies": {
14
+ "@types/conventional-changelog-core": "4.2.7",
15
+ "husky": "8.0.3",
16
+ "lint-staged": "15.2.0",
17
+ "markdownlint-cli2": "0.11.0",
18
+ "prettier": "3.1.1",
19
+ "prettier-plugin-packagejson": "2.4.8"
20
+ },
21
+ "packageManager": "pnpm@8.13.1",
22
+ "engines": {
23
+ "node": "^18.12.0 || >=20.0.0",
24
+ "pnpm": "^8.0.0"
25
+ },
26
+ "scripts": {
27
+ "lint:prettier": "prettier --cache --check --ignore-unknown .",
28
+ "prettier:fix": "prettier --cache --write --ignore-unknown .",
29
+ "start": "node src/index.js"
30
+ }
31
+ }
package/renovate.json ADDED
@@ -0,0 +1,5 @@
1
+ {
2
+ "$schema": "https://docs.renovatebot.com/renovate-schema.json",
3
+ "extends": ["visualon/renovate-config"],
4
+ "automergeType": "pr"
5
+ }
@@ -0,0 +1,78 @@
1
+ import conventionalChangelogPreset from 'conventional-changelog-conventionalcommits';
2
+ import conventionalChangelogCore from 'conventional-changelog-core';
3
+
4
+ /**
5
+ * @type {import('conventional-changelog-core').Options}
6
+ */
7
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-call
8
+ export const config = conventionalChangelogPreset({
9
+ types: [
10
+ {
11
+ type: 'feat',
12
+ section: 'Features',
13
+ },
14
+ {
15
+ type: 'feature',
16
+ section: 'Features',
17
+ },
18
+ {
19
+ type: 'fix',
20
+ section: 'Bug Fixes',
21
+ },
22
+ {
23
+ type: 'perf',
24
+ section: 'Performance Improvements',
25
+ },
26
+ {
27
+ type: 'revert',
28
+ section: 'Reverts',
29
+ },
30
+ {
31
+ type: 'docs',
32
+ section: 'Documentation',
33
+ },
34
+ {
35
+ type: 'style',
36
+ section: 'Styles',
37
+ },
38
+ {
39
+ type: 'chore',
40
+ section: 'Miscellaneous Chores',
41
+ },
42
+ {
43
+ type: 'refactor',
44
+ section: 'Code Refactoring',
45
+ },
46
+ {
47
+ type: 'test',
48
+ section: 'Tests',
49
+ },
50
+ {
51
+ type: 'build',
52
+ section: 'Build System',
53
+ },
54
+ {
55
+ type: 'ci',
56
+ section: 'Continuous Integration',
57
+ },
58
+ ],
59
+ });
60
+
61
+ /**
62
+ *
63
+ * @param {string} version
64
+ * @param {boolean} onTag
65
+ * @returns
66
+ */
67
+ export function getChangelog(version, onTag) {
68
+ return conventionalChangelogCore(
69
+ {
70
+ config,
71
+ releaseCount: onTag ? 2 : 1,
72
+ },
73
+ { version, linkCompare: false },
74
+ undefined,
75
+ undefined,
76
+ { headerPartial: '' },
77
+ );
78
+ }
package/src/index.js ADDED
@@ -0,0 +1,80 @@
1
+ import { Command, runExit } from 'clipanion';
2
+ import { getChangelog } from './changelog/util.js';
3
+
4
+ class GiteaReleaseCommand extends Command {
5
+ async execute() {
6
+ const url = new URL(process.env.GIT_URL);
7
+ const api = `${url.origin}/api/v1`;
8
+ const repo = url.pathname.replace(/\.git$/, '').replace(/^\//, '');
9
+ const token = process.env.GITEA_TOKEN;
10
+ const tag = process.env.TAG_NAME;
11
+
12
+ this.context.stdout.write(`Using api: ${api}.\n`);
13
+ this.context.stdout.write(`Using repository: ${repo}\n`);
14
+
15
+ if (!token) {
16
+ this.context.stdout.write('GITEA_TOKEN environment variable not set.\n');
17
+ return 1;
18
+ }
19
+
20
+ if (tag) {
21
+ this.context.stdout.write(`Using tag: ${tag}\n`);
22
+ } else {
23
+ this.context.stdout.write('No tag found for this commit. Please tag the commit and try again.\n');
24
+ return 1;
25
+ }
26
+
27
+ this.context.stdout.write(`Checking remote tag ${tag}.\n`);
28
+ let resp = await fetch(`${api}/repos/${repo}/tags/${tag}`, {
29
+ headers: {
30
+ Authorization: `Bearer ${token}`,
31
+ },
32
+ });
33
+
34
+ if (!resp.ok) {
35
+ this.context.stdout.write(`Tag ${tag} not found on remote.\n`);
36
+ return 1;
37
+ }
38
+
39
+ this.context.stdout.write(`Checking remote release ${tag}.\n`);
40
+ resp = await fetch(`${api}/repos/${repo}/releases/tags/${tag}`, {
41
+ headers: {
42
+ Authorization: `Bearer ${token}`,
43
+ },
44
+ });
45
+ if (resp.ok) {
46
+ this.context.stdout.write(`Release ${tag} already exists.\n`);
47
+ return 1;
48
+ } else if (resp.status !== 404) {
49
+ this.context.stdout.write(`Error checking for release ${tag}.\n${resp.status}: ${resp.statusText}\n`);
50
+ return 1;
51
+ }
52
+
53
+ const stream = getChangelog(tag, true).setEncoding('utf8');
54
+ const changes = (await stream.toArray()).join('');
55
+
56
+ this.context.stdout.write(`Creating release ${tag}.\n`);
57
+ resp = await fetch(`${api}/repos/${repo}/releases`, {
58
+ method: 'POST',
59
+ headers: {
60
+ 'Content-Type': 'application/json',
61
+ Authorization: `Bearer ${token}`,
62
+ },
63
+ body: JSON.stringify({
64
+ draft: false,
65
+ prerelease: tag.includes('-'),
66
+ tag_name: tag,
67
+ name: tag.replace(/^v/, ''),
68
+ body: changes,
69
+ target_commitish: 'main',
70
+ }),
71
+ });
72
+
73
+ if (!resp.ok) {
74
+ this.context.stdout.write(`Error creating release ${tag}.\n${resp.status}: ${resp.statusText}\n`);
75
+ return 1;
76
+ }
77
+ }
78
+ }
79
+
80
+ void runExit(GiteaReleaseCommand);