하지만 플러그인에서 수행되는 린팅을 따를 경우, GitHub Action에서 린팅 테스트가 실패하는 것 같습니다.
아하!!! pnpm i가 제가 놓치고 있던 마법이었던 것 같습니다. discourse 코어를 업데이트하는 스크립트와 린팅을 수행하는 스크립트에 'pnpm i’를 추가했습니다. . .
그래서 이제 제 스크립트는 다음과 같이 동작합니다:
if [[ "$ARG" == "eslint" ]]
then
# See https://github.com/discourse/.github/blob/main/.github/workflows/discourse-plugin.yml
if [ -f plugin.rb ]
then
echo "Linting current directory."
else
echo "Not on a plugin. Using $DEFAULT_PLUGIN"
cd $DEFAULT_PLUGIN
fi
echo "LINTING $(pwd)"
#cd /home/pfaffman/src/literatecomputing/discourse-display-email
# pnpm install
echo "Doing `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 was unhappy -- $exit_code -- trying to fix"
pnpm eslint --fix --no-error-on-unmatched-pattern {test,assets,admin/assets}/javascripts
exit_code="$?"
if [[ $exit_code -ne 0 ]]
then
echo "eslint was still unhappy -- $exit_code -- game over"
exit
fi
fi
echo ESLINT done.
## styllint
echo -n STYLELINT . . .
pnpm stylelint --allow-empty-input "assets/**/*.scss"
exit_code="$?"
if [[ $exit_code -ne 0 ]]
then
echo "stylelint is unhappy. Trying to fix . . . "
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 is still unhappy. this is sad. Game over."
exit
fi
echo "DONE!"
## end stylelint
## PRETTIER
echo -n "Prettier . . . "
if [ -n "$(find assets -type f \( -name "*.scss" -or -name "*.js" -or -name "*.gjs" -or -name "*.hbs" \) 2>/dev/null)" ]; then
#pnpm prettier --write 'assets/**/*.{scss,js,gjs,es6,hbs}'
# echo "doing 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 did something!!! -- $?"
sleep 5
fi
fi
if [ -n "$(find admin/assets -type f \( -name "*.scss" -or -name "*.js" -or -name "*.gjs" -or -name "*.hbs" \) 2>/dev/null)" ]; then
#pnpm prettier --write 'assets/**/*.{scss,js,gjs,es6,hbs}'
# echo "doing 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 did something!!! -- $?"
pnpm prettier --check --log-level log "assets/**/*.{scss,js,gjs,es6,hbs}"
fi
fi
if [ -n "$(find test -type f \( -name "*.js" -or -name "*.gjs" \) 2>/dev/null)" ]; then
#pnpm prettier --write 'assets/**/*.{scss,js,gjs,es6,hbs}'
# echo "doing 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 did something!!! -- $?"
pnpm prettier --check --loglevel log "test/**/*.{js,gjs}"
fi
fi
echo "Done with 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 "done with ember-template-lint --fix --no-error-on-unmatched-pattern assets/javascripts -- with $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 is unhappy. Trying to fix in 2 seconds . .. "
sleep 2
echo "here we go!!!"
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 is still unhappy. this is sad. Waiting to make you sadder"
sleep 15
fi
echo done with stree
echo "rubocop!"
bundle exec rubocop -A $(find . -name "*.rb"|grep -v gems)
exit_code="$?"
if [[ $exit_code -ne 0 ]]
then
echo "done with 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
이제 유일한 차이는 코어 린팅이 이 내용에 대해 불만인 것 같습니다(그리고 코어는 발견하지만 플러그인은 발견하지 못하는 이유를 이해하고 있으며, 이러한 비추천(deprecation)을 빨리 수정하는 데는 단점이 없다고 생각합니다):
/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 problem (1 error, 0 warnings)
그리고 bin/lint를 사용하면 린팅이 변경되어 제 54줄짜리 스크립트를 업데이트해야 하는 상황을 걱정할 필요가 없습니다. 맞나요?
잠깐. 스켈레톤 저장소에서 어디에 문서화되어 있나요?
제 작은 규모의 작업물은 사실 당신들의 문제가 아니라는 점은 이해하지만, 변경 사항을 체계적으로 배포하는 방법에 대한 안내를 받고 싶습니다. . . 이 주제는 여기에는 적합하지 않지만, mass-pr를 몇 번 시도해 보았지만 아직 성공하지 못했습니다. 저는 보통 스켈레톤의 최근 풀에서 몇 가지 .whatever 파일을 복사하고 최선의 결과를 기대하는 편입니다.
그리고 그런 스크립트가 16개나 있습니다. 저장소를 관찰하고 그중 하나라도 업데이트될 때마다 실행해야 하나요? 그리고 일부 테마는 스켈레톤을 클론하지 않아 필요한 파일을 복사하지 못해서 실패하는 것 같습니다.
그리고 일부는 스켈레톤 저장소를 클론하지 않기 때문에 sed: can’t read s/default.yml/stree-compat.yml/: No such file or directory와 같은 오류로 실패하는 것 같습니다? (기회가 되면 적절한 곳에서 해당 문제를 위한 주제를 시작하겠습니다).