From 6f444c4b6942af48e3932a5b88e0373a431f878b Mon Sep 17 00:00:00 2001 From: silverwind Date: Sat, 16 Mar 2024 13:40:14 +0100 Subject: [PATCH 1/7] move some scripts from 'build' to 'tools' directory --- .dockerignore | 3 ++- .gitignore | 2 +- Makefile | 16 +++++++++------- .../content/administration/cmd-embedded.zh-cn.md | 6 +++--- .../development/hacking-on-gitea.en-us.md | 2 +- .../development/hacking-on-gitea.zh-cn.md | 2 +- {build => tools}/generate-images.js | 0 {build => tools}/generate-svg.js | 0 {build => tools}/watch.sh | 0 9 files changed, 17 insertions(+), 14 deletions(-) rename {build => tools}/generate-images.js (100%) rename {build => tools}/generate-svg.js (100%) rename {build => tools}/watch.sh (100%) diff --git a/.dockerignore b/.dockerignore index 80cbeb040cf87..8b40c7888d215 100644 --- a/.dockerignore +++ b/.dockerignore @@ -62,7 +62,7 @@ cpu.out /data /indexers /log -/public/img/avatar + /tests/integration/gitea-integration-* /tests/integration/indexers-* /tests/e2e/gitea-e2e-* @@ -78,6 +78,7 @@ cpu.out /public/assets/js /public/assets/css /public/assets/fonts +/public/assets/img/avatar /public/assets/img/webpack /vendor /web_src/fomantic/node_modules diff --git a/.gitignore b/.gitignore index 8f2544866a167..abf9565cff3b8 100644 --- a/.gitignore +++ b/.gitignore @@ -58,7 +58,7 @@ cpu.out /data /indexers /log -/public/img/avatar +/public/assets/img/avatar /tests/integration/gitea-integration-* /tests/integration/indexers-* /tests/e2e/gitea-e2e-* diff --git a/Makefile b/Makefile index 88bcf0e17cc4c..f8fa65063c612 100644 --- a/Makefile +++ b/Makefile @@ -147,6 +147,8 @@ TAR_EXCLUDES := .git data indexers queues log node_modules $(EXECUTABLE) $(FOMAN GO_DIRS := build cmd models modules routers services tests WEB_DIRS := web_src/js web_src/css +ESLINT_FILES := web_src/js build tools *.config.js tests/e2e +STYLELINT_FILES := web_src/css web_src/js/components/*.vue SPELLCHECK_FILES := $(GO_DIRS) $(WEB_DIRS) docs/content templates options/locale/locale_en-US.ini .github EDITORCONFIG_FILES := templates .github/workflows options/locale/locale_en-US.ini @@ -375,19 +377,19 @@ lint-backend-fix: lint-go-fix lint-go-vet lint-editorconfig .PHONY: lint-js lint-js: node_modules - npx eslint --color --max-warnings=0 --ext js,vue web_src/js build *.config.js tests/e2e + npx eslint --color --max-warnings=0 --ext js,vue $(ESLINT_FILES) .PHONY: lint-js-fix lint-js-fix: node_modules - npx eslint --color --max-warnings=0 --ext js,vue web_src/js build *.config.js tests/e2e --fix + npx eslint --color --max-warnings=0 --ext js,vue $(ESLINT_FILES) --fix .PHONY: lint-css lint-css: node_modules - npx stylelint --color --max-warnings=0 web_src/css web_src/js/components/*.vue + npx stylelint --color --max-warnings=0 $(STYLELINT_FILES) .PHONY: lint-css-fix lint-css-fix: node_modules - npx stylelint --color --max-warnings=0 web_src/css web_src/js/components/*.vue --fix + npx stylelint --color --max-warnings=0 $(STYLELINT_FILES) --fix .PHONY: lint-swagger lint-swagger: node_modules @@ -444,7 +446,7 @@ lint-yaml: .venv .PHONY: watch watch: - @bash build/watch.sh + @bash tools/watch.sh .PHONY: watch-frontend watch-frontend: node-check node_modules @@ -916,7 +918,7 @@ $(WEBPACK_DEST): $(WEBPACK_SOURCES) $(WEBPACK_CONFIGS) package-lock.json .PHONY: svg svg: node-check | node_modules rm -rf $(SVG_DEST_DIR) - node build/generate-svg.js + node tools/generate-svg.js .PHONY: svg-check svg-check: svg @@ -960,7 +962,7 @@ generate-gitignore: .PHONY: generate-images generate-images: | node_modules npm install --no-save fabric@6.0.0-beta19 imagemin-zopfli@7 - node build/generate-images.js $(TAGS) + node tools/generate-images.js $(TAGS) .PHONY: generate-manpage generate-manpage: diff --git a/docs/content/administration/cmd-embedded.zh-cn.md b/docs/content/administration/cmd-embedded.zh-cn.md index 4570bb58a39ed..995e3fd774bb7 100644 --- a/docs/content/administration/cmd-embedded.zh-cn.md +++ b/docs/content/administration/cmd-embedded.zh-cn.md @@ -37,7 +37,7 @@ gitea embedded list [--include-vendored] [patterns...] - 列出所有模板文件,无论在哪个虚拟目录下:`**.tmpl` - 列出所有邮件模板文件:`templates/mail/**.tmpl` -- 列出 `public/img` 目录下的所有文件:`public/img/**` +- 列出 `public/assets/img` 目录下的所有文件:`public/asset/img/**` 不要忘记为模式使用引号,因为空格、`*` 和其他字符可能对命令行解释器有特殊含义。 @@ -49,8 +49,8 @@ gitea embedded list [--include-vendored] [patterns...] ```sh $ gitea embedded list '**openid**' -public/img/auth/openid_connect.svg -public/img/openid-16x16.png +public/assets/img/auth/openid_connect.svg +public/assets/img/openid-16x16.png templates/user/auth/finalize_openid.tmpl templates/user/auth/signin_openid.tmpl templates/user/auth/signup_openid_connect.tmpl diff --git a/docs/content/development/hacking-on-gitea.en-us.md b/docs/content/development/hacking-on-gitea.en-us.md index 982dbcf6ead5a..004e803827db6 100644 --- a/docs/content/development/hacking-on-gitea.en-us.md +++ b/docs/content/development/hacking-on-gitea.en-us.md @@ -214,7 +214,7 @@ REPO_INDEXER_CONN_STR = http://elastic:changeme@localhost:9200 ### Building and adding SVGs -SVG icons are built using the `make svg` target which compiles the icon sources defined in `build/generate-svg.js` into the output directory `public/assets/img/svg`. Custom icons can be added in the `web_src/svg` directory. +SVG icons are built using the `make svg` target which compiles the icon sources into the output directory `public/assets/img/svg`. Custom icons can be added in the `web_src/svg` directory. ### Building the Logo diff --git a/docs/content/development/hacking-on-gitea.zh-cn.md b/docs/content/development/hacking-on-gitea.zh-cn.md index a31e1dc511c2b..5a971b5806157 100644 --- a/docs/content/development/hacking-on-gitea.zh-cn.md +++ b/docs/content/development/hacking-on-gitea.zh-cn.md @@ -201,7 +201,7 @@ REPO_INDEXER_CONN_STR = http://elastic:changeme@localhost:9200 ### 构建和添加 SVGs -SVG 图标是使用 `make svg` 目标构建的,该目标将 `build/generate-svg.js` 中定义的图标源编译到输出目录 `public/img/svg` 中。可以在 `web_src/svg` 目录中添加自定义图标。 +SVG 图标是使用 `make svg` 目标构建的,该目标将图标源编译到输出目录 `public/assets/img/svg`。可以在 `web_src/svg` 目录中添加自定义图标。 ### 构建 Logo diff --git a/build/generate-images.js b/tools/generate-images.js similarity index 100% rename from build/generate-images.js rename to tools/generate-images.js diff --git a/build/generate-svg.js b/tools/generate-svg.js similarity index 100% rename from build/generate-svg.js rename to tools/generate-svg.js diff --git a/build/watch.sh b/tools/watch.sh similarity index 100% rename from build/watch.sh rename to tools/watch.sh From ea9ec28a31a068a64ab1004ed7bdd2ea5f3ca627 Mon Sep 17 00:00:00 2001 From: silverwind Date: Sat, 16 Mar 2024 13:49:06 +0100 Subject: [PATCH 2/7] fix ESLINT_FILES --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index f8fa65063c612..1cddad1e93201 100644 --- a/Makefile +++ b/Makefile @@ -147,7 +147,7 @@ TAR_EXCLUDES := .git data indexers queues log node_modules $(EXECUTABLE) $(FOMAN GO_DIRS := build cmd models modules routers services tests WEB_DIRS := web_src/js web_src/css -ESLINT_FILES := web_src/js build tools *.config.js tests/e2e +ESLINT_FILES := web_src/js tools *.config.js tests/e2e STYLELINT_FILES := web_src/css web_src/js/components/*.vue SPELLCHECK_FILES := $(GO_DIRS) $(WEB_DIRS) docs/content templates options/locale/locale_en-US.ini .github EDITORCONFIG_FILES := templates .github/workflows options/locale/locale_en-US.ini From 1437dd813d4f5a7ced7ced79e29f94ca39c0fe15 Mon Sep 17 00:00:00 2001 From: silverwind Date: Sat, 16 Mar 2024 13:49:28 +0100 Subject: [PATCH 3/7] Update .dockerignore --- .dockerignore | 1 - 1 file changed, 1 deletion(-) diff --git a/.dockerignore b/.dockerignore index 8b40c7888d215..5cec84c9a3ac0 100644 --- a/.dockerignore +++ b/.dockerignore @@ -62,7 +62,6 @@ cpu.out /data /indexers /log - /tests/integration/gitea-integration-* /tests/integration/indexers-* /tests/e2e/gitea-e2e-* From 8ed29f231652c2edb402468572669a4cd1c87d39 Mon Sep 17 00:00:00 2001 From: silverwind Date: Sat, 16 Mar 2024 13:52:18 +0100 Subject: [PATCH 4/7] move eslint disables inline --- .eslintrc.yaml | 4 ---- tools/generate-images.js | 4 ++-- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/.eslintrc.yaml b/.eslintrc.yaml index 5f291f13e7506..b450a388e1564 100644 --- a/.eslintrc.yaml +++ b/.eslintrc.yaml @@ -42,10 +42,6 @@ overrides: worker: true rules: no-restricted-globals: [2, addEventListener, blur, close, closed, confirm, defaultStatus, defaultstatus, error, event, external, find, focus, frameElement, frames, history, innerHeight, innerWidth, isFinite, isNaN, length, locationbar, menubar, moveBy, moveTo, name, onblur, onerror, onfocus, onload, onresize, onunload, open, opener, opera, outerHeight, outerWidth, pageXOffset, pageYOffset, parent, print, removeEventListener, resizeBy, resizeTo, screen, screenLeft, screenTop, screenX, screenY, scroll, scrollbars, scrollBy, scrollTo, scrollX, scrollY, status, statusbar, stop, toolbar, top] - - files: ["build/generate-images.js"] - rules: - i/no-unresolved: [0] - i/no-extraneous-dependencies: [0] - files: ["*.config.*"] rules: i/no-unused-modules: [0] diff --git a/tools/generate-images.js b/tools/generate-images.js index db31d19e2a491..cc2855c18e7ff 100755 --- a/tools/generate-images.js +++ b/tools/generate-images.js @@ -1,7 +1,7 @@ #!/usr/bin/env node -import imageminZopfli from 'imagemin-zopfli'; +import imageminZopfli from 'imagemin-zopfli'; // eslint-disable-line i/no-unresolved +import {loadSVGFromString, Canvas, Rect, util} from 'fabric/node'; // eslint-disable-line i/no-unresolved import {optimize} from 'svgo'; -import {loadSVGFromString, Canvas, Rect, util} from 'fabric/node'; import {readFile, writeFile} from 'node:fs/promises'; import {argv, exit} from 'node:process'; From 5d907045b09f0b9a4c984307fd50e05a5236c003 Mon Sep 17 00:00:00 2001 From: silverwind Date: Sat, 16 Mar 2024 14:24:25 +0100 Subject: [PATCH 5/7] Update docs/content/development/hacking-on-gitea.zh-cn.md --- docs/content/development/hacking-on-gitea.zh-cn.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/content/development/hacking-on-gitea.zh-cn.md b/docs/content/development/hacking-on-gitea.zh-cn.md index 5a971b5806157..0b3160d2d96da 100644 --- a/docs/content/development/hacking-on-gitea.zh-cn.md +++ b/docs/content/development/hacking-on-gitea.zh-cn.md @@ -201,7 +201,7 @@ REPO_INDEXER_CONN_STR = http://elastic:changeme@localhost:9200 ### 构建和添加 SVGs -SVG 图标是使用 `make svg` 目标构建的,该目标将图标源编译到输出目录 `public/assets/img/svg`。可以在 `web_src/svg` 目录中添加自定义图标。 +SVG 图标是使用 make svg 命令构建的,该命令将 build/generate-svg.js 中定义的图标资源编译到输出目录 public/assets/img/svg 中。可以在 web_src/svg 目录中添加自定义图标。 ### 构建 Logo From 00d786045cb65d40a5621c62aa4113be2a151b4a Mon Sep 17 00:00:00 2001 From: silverwind Date: Sat, 16 Mar 2024 14:50:03 +0100 Subject: [PATCH 6/7] Update docs/content/development/hacking-on-gitea.zh-cn.md Co-authored-by: Nanguan Lin --- docs/content/development/hacking-on-gitea.zh-cn.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/content/development/hacking-on-gitea.zh-cn.md b/docs/content/development/hacking-on-gitea.zh-cn.md index 0b3160d2d96da..7dfea30538fd8 100644 --- a/docs/content/development/hacking-on-gitea.zh-cn.md +++ b/docs/content/development/hacking-on-gitea.zh-cn.md @@ -201,7 +201,7 @@ REPO_INDEXER_CONN_STR = http://elastic:changeme@localhost:9200 ### 构建和添加 SVGs -SVG 图标是使用 make svg 命令构建的,该命令将 build/generate-svg.js 中定义的图标资源编译到输出目录 public/assets/img/svg 中。可以在 web_src/svg 目录中添加自定义图标。 +SVG 图标是使用 `make svg` 命令构建的,该命令将图标资源编译到输出目录 `public/assets/img/svg` 中。可以在 `web_src/svg` 目录中添加自定义图标。 ### 构建 Logo From 242e90561066abf260be79ecb73c45ee2bc0bbaa Mon Sep 17 00:00:00 2001 From: silverwind Date: Sat, 16 Mar 2024 14:50:28 +0100 Subject: [PATCH 7/7] Update docs/content/administration/cmd-embedded.zh-cn.md Co-authored-by: Nanguan Lin --- docs/content/administration/cmd-embedded.zh-cn.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/content/administration/cmd-embedded.zh-cn.md b/docs/content/administration/cmd-embedded.zh-cn.md index 995e3fd774bb7..a2df1aa2f5110 100644 --- a/docs/content/administration/cmd-embedded.zh-cn.md +++ b/docs/content/administration/cmd-embedded.zh-cn.md @@ -37,7 +37,7 @@ gitea embedded list [--include-vendored] [patterns...] - 列出所有模板文件,无论在哪个虚拟目录下:`**.tmpl` - 列出所有邮件模板文件:`templates/mail/**.tmpl` -- 列出 `public/assets/img` 目录下的所有文件:`public/asset/img/**` +列出 `public/assets/img` 目录下的所有文件:`public/assets/img/**` 不要忘记为模式使用引号,因为空格、`*` 和其他字符可能对命令行解释器有特殊含义。