但我很确定,当我遵循插件中进行的 linting 时,github action 中的 linting 测试会失败。
啊哈!!!pnpm i 似乎是我错过的魔法。我已经将 ‘pnpm i’ 添加到我的更新 discourse 核心的脚本和执行 linting 的脚本中。。。
所以现在我的脚本的作用如下:
if [[ "$ARG" == "eslint" ]]
then
# 参见 https://github.com/discourse/.github/blob/main/.github/workflows/discourse-plugin.yml
if [ -f plugin.rb ]
then
echo "正在 lint 当前目录。"
else
echo "不在插件中。使用 $DEFAULT_PLUGIN"
cd $DEFAULT_PLUGIN
fi
echo "正在 LINT $(pwd)"
#cd /home/pfaffman/src/literatecomputing/discourse-display-email
# pnpm install
echo "正在执行 `pnpm i`"
pnpm -i
echo -n ESLINT . . .
pnpm eslint --no-error-on-unmatched-pattern {test,assets,admin/assets}/javascripts
exit_code="?"
if [[ $exit_code -ne 0 ]]
then
echo "eslint 不满意 -- $exit_code -- 尝试修复"
pnpm eslint --fix --no-error-on-unmatched-pattern {test,assets,admin/assets}/javascripts
exit_code="?"
if [[ $exit_code -ne 0 ]]
then
echo "eslint 仍然不满意 -- $exit_code -- 结束"
exit
fi
fi
echo ESLINT 完成。
## styllint
echo -n STYLELINT . . .
pnpm stylelint --allow-empty-input "assets/**/*.scss"
exit_code="?"
if [[ $exit_code -ne 0 ]]
then
echo "stylelint 不满意。尝试修复 . . . "
fi
pnpm stylelint --fix --allow-empty-input "assets/**/*.scss"
pnpm stylelint --allow-empty-input "assets/**/*.scss"
exit_code="?"
if [[ $exit_code -ne 0 ]]
then
echo "stylelint 仍然不满意。这很遗憾。结束"
exit
fi
echo "完成!"
## end stylelint
## PRETTIER
echo -n "Prettier . . . "
if [ -n "$(find assets -type f \( -name "*.scss" -o -name "*.js" -o -name "*.gjs" -o -name "*.hbs" \) 2>/dev/null)" ]; then
#pnpm prettier --write 'assets/**/*.{scss,js,gjs,es6,hbs}'
# echo "正在执行 pnpm prettier --write --log-level warn assets/**/*.{scss,js,gjs,es6,hbs}"
pnpm prettier --write --log-level error "assets/**/*.{scss,js,gjs,hbs}"
if [[ $? -ne 0 ]]
then
echo "prettier assets 做了点事!!! -- $?"
sleep 5
fi
fi
if [ -n "$(find admin/assets -type f \( -name "*.scss" -o -name "*.js" -o -name "*.gjs" -o -name "*.hbs" \) 2>/dev/null)" ]; then
#pnpm prettier --write 'assets/**/*.{scss,js,gjs,es6,hbs}'
# echo "正在执行 pnpm prettier --write --log-level warn admin/assets/**/*.{scss,js,gjs,hbs}"
pnpm prettier --write --log-level log "assets/**/*.{scss,js,gjs,es6,hbs}"
if [[ $? -ne 0 ]]
then
echo "prettier admin/assets 做了点事!!! -- $?"
pnpm prettier --check --log-level log "assets/**/*.{scss,js,gjs,es6,hbs}"
fi
fi
if [ -n "$(find test -type f \( -name "*.js" -o -name "*.gjs" \) 2>/dev/null)" ]; then
#pnpm prettier --write 'assets/**/*.{scss,js,gjs,es6,hbs}'
# echo "正在执行 pnpm prettier --write --log-level warn assets/**/*.{scss,js,gjs,es6,hbs}"
pnpm prettier --write --log-level warn "test/**/*.{js,gjs}"
if [[ $? -ne 0 ]]
then
echo "prettier test 做了点事!!! -- $?"
pnpm prettier --check --loglevel log "test/**/*.{js,gjs}"
fi
fi
echo "Prettier 完成"
echo "ember-template-lint"
pnpm ember-template-lint --fix --no-error-on-unmatched-pattern assets/javascripts admin/assets/javascripts
exit_code="?"
if [[ $exit_code -ne 0 ]]
then
echo "完成 ember-template-lint --fix --no-error-on-unmatched-pattern assets/javascripts -- $exit_code"
echo sleep 5
sleep 5
fi
#bundle exec stree write Gemfile $(git ls-files '*.rb') $(git ls-files '*.rake') $(git ls-files '*.thor')
bundle exec stree check Gemfile $(git ls-files '*.rb') $(git ls-files '*.rake') $(git ls-files '*.thor')
exit_code="?"
if [[ $exit_code -ne 0 ]]
then
echo "stree 不满意。尝试在 2 秒内修复 . . . "
sleep 2
echo "开始!!!"
bundle exec stree write Gemfile $(git ls-files '*.rb') $(git ls-files '*.rake') $(git ls-files '*.thor')
fi
bundle exec stree check Gemfile $(git ls-files '*.rb') $(git ls-files '*.rake') $(git ls-files '*.thor')
exit_code="?"
if [[ $exit_code -ne 0 ]]
then
echo "stree 仍然不满意。这很遗憾。等待让你更遗憾"
sleep 15
fi
echo stree 完成
echo "rubocop!"
bundle exec rubocop -A $(find . -name "*.rb"|grep -v gems)
exit_code="?"
if [[ $exit_code -ne 0 ]]
then
echo "rubocop 完成 -- $exit_code"
sleep 15
fi
exit
fi
但我也有这个,我认为它的作用几乎相同:
if [[ "$ARG" == "lint" ]]
then
cd ~/src/discourse-repos/discourse
find plugins/discourse-pfaffmanager/assets -type f \( -name "*.scss" -o -name "*.js" -o -name "*.gjs" -o -name "*.hbs" -o -name "*.rb" \) -exec ./bin/lint --fix {} +
cd -
fi
现在唯一的区别是核心 linting 对此不满意(而且我认为我明白为什么核心能找到它而插件找不到,而且尽早修复这些弃用没有坏处):
/home/pfaffman/src/discourse-repos/discourse/plugins/discourse-pfaffmanager/assets/javascripts/discourse/components/modal/really-delete.gjs
2:8 error Use Glimmer components(@glimmer/component) instead of classic components(@ember/component) ember/no-classic-components
✖ 1 个问题 (1 个错误,0 个警告)
如果我使用 bin/lint,那么我就不必担心 linting 会发生变化,从而需要更新我 54 行的脚本,对吗?
等等。在 skeleton 仓库中记录它们在哪里?
我很想得到一些关于如何有条不紊地推出更改的指导,尽管我理解我的一小部分东西并不是你们的问题。。。这不应该在这里,但我已经尝试了几次来弄清楚 mass-pr,但还没有成功。我通常只是定期从 skeleton 的最新 pull 中复制一些 .whatever 文件,然后听之任之。
而且有 16 个这样的脚本。我是否需要关注该仓库,并在其中任何一个更新时运行它?而且很多主题似乎没有克隆 skeleton 仓库,所以它们无法复制所需的文件?
而且有几个以类似 sed: can’t read s/default.yml/stree-compat.yml/: No such file or directory 的错误失败?因为它们没有克隆 skeleton 仓库?(我一有机会就会在适当的地方开一个主题)。