markuplint bug fix 環境構築から
拡張機能で動作確認できてないけどPRは出すだけだした
PS D:\My_Things\dev\Tools\markuplint\markuplint> go install github.com/rhysd/actionlint/cmd/actionlint@latest
PS D:\My_Things\dev\Tools\markuplint\markuplint> actionlint -h
Usage: actionlint [FLAGS] [FILES...] [-]
actionlint is a linter for GitHub Actions workflow files.
To check all YAML files in current repository, just run actionlint without
arguments. It automatically finds the nearest '.github/workflows' directory:
actionlint 入った
というかバイナリでよかった https://github.com/rhysd/actionlint/releases
変更前、変更後ともに
https://markuplint.dev/ja/community/contributing#コードへの貢献 の
- yarn lintでコードの整形とリントチェックをしてください
- yarn buildでビルドが正常に行われることを確認してください
- yarn testでテストが成功することを確認してください
にそれぞれ失敗してる
一時的にDockerfile を編集
- --legacy-peer-deps をつける
-
install
という npm script はない
FROM node:21.7
COPY . /markuplint
WORKDIR /markuplint
RUN npm install yarn --legacy-peer-deps
RUN npx yarn install
# RUN npx yarn run install
RUN npx yarn run build
RUN cd /usr/bin && ln -s /markuplint/packages/markuplint/bin/markuplint
ENTRYPOINT ["markuplint"]
すると
PS C:\markuplint\markuplint> docker image build . -t markuplint
[+] Building 218.8s (12/12) FINISHED docker:default
=> [internal] load build definition from Dockerfile 0.0s
=> => transferring dockerfile: 305B 0.0s
=> [internal] load metadata for docker.io/library/node:21.7 1.6s
=> [internal] load .dockerignore 0.0s
=> => transferring context: 2B 0.0s
=> [internal] load build context 5.6s
=> => transferring context: 4.05MB 5.5s
=> CACHED [1/7] FROM docker.io/library/node:21.7@sha256:104b26b5d34f9907f1f1e5e51fd9e557845f1a354f07 0.0s
=> [2/7] COPY . /markuplint 5.6s
=> [3/7] WORKDIR /markuplint 0.0s
=> [4/7] RUN npm install yarn --legacy-peer-deps 64.3s
=> [5/7] RUN npx yarn install 67.5s
=> [6/7] RUN npx yarn run build 58.8s
=> [7/7] RUN cd /usr/bin && ln -s /markuplint/packages/markuplint/bin/markuplint 0.4s
=> exporting to image 14.8s
=> => exporting layers 14.8s
=> => writing image sha256:e3e3700100b1b1097a3e67836cc4c59d5312359a16c5108877b1f193cbf3ca03 0.0s
=> => naming to docker.io/library/markuplint 0.0s
PS C:\markuplint\markuplint> docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
markuplint latest e3e3700100b1 32 seconds ago 3.19GB
作れた
本当にやりたかったのはこういうことなのかも?
- yarn はそもそも入ってるのでローカルにもグローバルにもインストールしない
https://github.com/nodejs/docker-node?tab=readme-ov-file#image-variants -
install
という npm script はないので消す
FROM node:21.7
COPY . /markuplint
WORKDIR /markuplint
RUN yarn install
RUN yarn run build
RUN cd /usr/bin && ln -s /markuplint/packages/markuplint/bin/markuplint
ENTRYPOINT ["markuplint"]
試す
PS C:\markuplint\markuplint> docker image build . -t markuplint
[+] Building 13.0s (12/12) FINISHED docker:default
=> [internal] load build definition from Dockerfile 0.0s
=> => transferring dockerfile: 230B 0.0s
=> [internal] load metadata for docker.io/library/node:21.7 1.9s
=> [auth] library/node:pull token for registry-1.docker.io 0.0s
=> [internal] load .dockerignore 0.0s
=> => transferring context: 2B 0.0s
=> [internal] load build context 11.0s
=> => transferring context: 4.05MB 10.5s
=> [1/6] FROM docker.io/library/node:21.7@sha256:104b26b5d34f9907f1f1e5e51fd9e557845f1a354f07ee9f28814dd9 0.0s
=> CACHED [2/6] COPY . /markuplint 0.0s
=> CACHED [3/6] WORKDIR /markuplint 0.0s
=> CACHED [4/6] RUN yarn install 0.0s
=> CACHED [5/6] RUN yarn run build 0.0s
=> CACHED [6/6] RUN cd /usr/bin && ln -s /markuplint/packages/markuplint/bin/markuplint 0.0s
=> exporting to image 0.0s
=> => exporting layers 0.0s
=> => writing image sha256:9bddcb48689633fa2f0e8cb0a871109e3248588443d3bb795e1967d5a5ff28e8 0.0s
=> => naming to docker.io/library/markuplint 0.0s
View build details: docker-desktop://dashboard/build/default/default/zng69nkdjx5jh071ddqam4xvn
PS C:\markuplint\markuplint> docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
markuplint latest 9bddcb486896 44 minutes ago 2.82GB
できたかも
(何回か試したからキャッシュ効いてる)
PS C:\markuplint\markuplint> docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
markuplint latest 9bddcb486896 44 minutes ago 2.82GB
PS C:\markuplint\markuplint> docker run -it 9bddcb486896
docker: Error response from daemon: failed to create task for container: failed to create shim task: OCI runtime
create failed: runc create failed: unable to start container process: exec: "markuplint": executable file not found in $PATH: unknown.
RUN cd /usr/bin && ln -s /markuplint/packages/markuplint/bin/markuplint
がうまくいってない?
RUN cd /usr/bin && ln -s /markuplint/packages/markuplint/bin/markuplint.mjs
ENTRYPOINT ["markuplint.mjs"]
こういうこと?
FROM node:21.7
COPY . /markuplint
WORKDIR /markuplint
RUN yarn install
RUN yarn run build
RUN cd /usr/bin && ln -s /markuplint/packages/markuplint/bin/markuplint.mjs
ENTRYPOINT ["markuplint.mjs"]
これでやると
PS C:\markuplint\markuplint> docker image build . -t markuplint
[+] Building 8.4s (12/12) FINISHED docker:default
=> [internal] load build definition from Dockerfile 0.1s
=> => transferring dockerfile: 238B 0.0s
=> [internal] load metadata for docker.io/library/node:21.7 1.6s
=> [auth] library/node:pull token for registry-1.docker.io 0.0s
=> [internal] load .dockerignore 0.0s
=> => transferring context: 2B 0.0s
=> [internal] load build context 6.6s
=> => transferring context: 4.05MB 6.6s
=> [1/6] FROM docker.io/library/node:21.7@sha256:104b26b5d34f9907f1f1e5e51fd9e557845f1a354f07ee9f28814dd9574a6154 0.0s
=> CACHED [2/6] COPY . /markuplint 0.0s
=> CACHED [3/6] WORKDIR /markuplint 0.0s
=> CACHED [4/6] RUN yarn install 0.0s
=> CACHED [5/6] RUN yarn run build 0.0s
=> CACHED [6/6] RUN cd /usr/bin && ln -s /markuplint/packages/markuplint/bin/markuplint.mjs 0.0s
=> exporting to image 0.0s
=> => exporting layers 0.0s
=> => writing image sha256:6235fc27741b939c879f677c18c287572eccab264bec3851a73d415d29fb58a4 0.0s
=> => naming to docker.io/library/markuplint 0.0s
View build details: docker-desktop://dashboard/build/default/default/wvnk4i8ro2o3j5sfeqzzkeu25
PS C:\markuplint\markuplint> docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
markuplint latest 6235fc27741b 6 minutes ago 2.82GB
PS C:\markuplint\markuplint> docker run -it 6235fc27741b
An HTML linter for all markup developers
Usage
$ markuplint <HTML file paths (glob format)>
$ <stdout> | markuplint
Options
--config, -c FILE_PATH A configuration file path.
--fix, Fix HTML.
--format, -f FORMAT Output format. Support "JSON", "Simple", "GitHub" and "Standard". Default: "Standard".
--no-search-config No search a configure file automatically.
--ignore-ext Evaluate files that are received even though the type of extension.
--no-import-preset-rules No import preset rules.
--locale Locale of the message of violation. Default is an OS setting.
--no-color, Output no color.
--problem-only, -p Output only problems, without passeds.
--allow-warnings Return status code 0 even if there are warnings.
--allow-empty-input Return status code 1 even if there are no input files.
--verbose Output with detailed information.
--include-node-modules Include files in node_modules directory. Default: false.
--init Initialize settings interactively.
--search Search lines of codes that include the target element by selectors.
--help, -h Show help.
--version, -v Show version.
Examples
$ markuplint verifyee.html --config path/to/.markuplintrc
$ cat verifyee.html | markuplint
終了コード1って出たけどこれで良いのかな
先に yarn して node_modules とかができてると失敗する?
docker 知らなすぎてこれをどう使えばよいかわかってない
こんなふうに、node環境がなくてもCLIとして使えますよってこと?
docker run markuplint test/fixture/002.html
しても何も帰ってこないな
docker run markuplint
と
npx markuplint
が同じに使えれば良いんだよね?
わからないので終わり
Dockerfile
# should 18 be specified?
FROM node:21.7
COPY . /markuplint
WORKDIR /markuplint
# node image have installed yarn on global already
# RUN npm install yarn
# yarn on global
RUN yarn install
# there is no npm script named `install`
# RUN yarn run install
RUN yarn run build
# the file has renamed
RUN cd /usr/bin && ln -s /markuplint/packages/markuplint/bin/markuplint.mjs
ENTRYPOINT ["markuplint.mjs"]
62.62 error glob@11.0.0: The engine "node" is incompatible with this module. Expected version "20 || >=22". Got "21.7.3"
が出たので node 20にしてみる
devのdockerfileのエラー
docker image build . -t markuplint
[+] Building 19.4s (9/13) docker:default
=> [internal] load build definition from Dockerfile 0.0s
=> => transferring dockerfile: 284B 0.0s
=> [internal] load metadata for docker.io/library/node:21.7 1.8s
=> [auth] library/node:pull token for registry-1.docker.io 0.0s
=> [internal] load .dockerignore 0.0s
=> => transferring context: 2B 0.0s
=> [internal] load build context 1.8s
=> => transferring context: 3.11MB 1.7s
=> CACHED [1/8] FROM docker.io/library/node:21.7@sha256:b9ccc4aca32eebf124e0ca0fd573dacffba2b9236987a1d4d2625ce3c162ecc8 0.0s
=> [2/8] COPY . /markuplint 0.8s
=> [3/8] WORKDIR /markuplint 0.0s
=> ERROR [4/8] RUN npm install yarn 15.0s
------
> [4/8] RUN npm install yarn:
14.87 npm ERR! code ERESOLVE
14.87 npm ERR! ERESOLVE unable to resolve dependency tree
14.87 npm ERR!
14.87 npm ERR! While resolving: markuplint-packages@undefined
14.87 npm ERR! Found: typedoc@0.25.12
14.87 npm ERR! node_modules/typedoc
14.88 npm ERR! dev typedoc@"0.25.12" from the root project
14.88 npm ERR!
14.88 npm ERR! Could not resolve dependency:
14.88 npm ERR! peer typedoc@">=0.22 <=0.23" from typedoc-plugin-resolve-crossmodule-references@0.3.3
14.88 npm ERR! node_modules/typedoc-plugin-resolve-crossmodule-references
14.88 npm ERR! dev typedoc-plugin-resolve-crossmodule-references@"0.3.3" from the root project
14.88 npm ERR!
14.88 npm ERR! Fix the upstream dependency conflict, or retry
14.88 npm ERR! this command with --force or --legacy-peer-deps
14.88 npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
14.88 npm ERR!
14.88 npm ERR!
14.88 npm ERR! For a full report see:
14.88 npm ERR! /root/.npm/_logs/2024-03-29T17_15_54_251Z-eresolve-report.txt
14.88
14.88 npm ERR! A complete log of this run can be found in: /root/.npm/_logs/2024-03-29T17_15_54_251Z-debug-0.log
------
Dockerfile:6
--------------------
4 |
5 | WORKDIR /markuplint
6 | >>> RUN npm install yarn
7 | RUN npx yarn install
8 | RUN npx yarn run install
--------------------
ERROR: failed to solve: process "/bin/sh -c npm install yarn" did not complete successfully: exit code: 1
Windows上、powershell で、
PS C:\markuplint\markuplint> npx markuplint .\test\fixture\001.html
PS C:\markuplint\markuplint> npx markuplint .\\test\\fixture\\001.html
<markuplint> passed C:\markuplint\markuplint\test\fixture\001.html
PS C:\markuplint\markuplint> npx markuplint ./test/fixture/001.html
<markuplint> passed C:\markuplint\markuplint\test\fixture\001.html
PS C:\markuplint\markuplint> docker run markuplint .\test\fixture\001.html
PS C:\markuplint\markuplint> docker run markuplint .\\test\\fixture\\001.html
PS C:\markuplint\markuplint> docker run markuplint ./test/fixture/001.html
<markuplint> passed /markuplint/test/fixture/001.html
つまり
-
npx markuplint .\test\fixture\001.html
-> ng -
npx markuplint .\\test\\fixture\\001.html
-> ok -
npx markuplint ./test/fixture/001.html
-> ok -
docker run markuplint .\test\fixture\001.html
-> ng -
docker run markuplint .\\test\\fixture\\001.html
-> ng -
docker run markuplint ./test/fixture/001.html
-> ok
npx markuplint .\test\fixture\001.html
Tab押すとこのパスになるのでこれで動いてほしい気がするけど、npxコマンドから叩くスクリプトのスタンダードを知らないのでわからない。
Windows で npm scripts 動かせないからちょっと編集しないとだめ?と思ったけど、
実行シェルを bash にしたらそれで動くかも?
npm config set script-shell C:\Windows\System32\bash.exe
yarn config set script-shell C:\Windows\System32\bash.exe
と設定してみたけど、
PS C:\markuplint\markuplint> yarn vscode:dev
yarn run v1.22.21
$ cd vscode; yarn --ignore-engines; yarn --ignore-engines vscode:dev
yarn install v1.22.21
[1/4] Resolving packages...
[2/4] Fetching packages...
[3/4] Linking dependencies...
warning "@commitlint/cli > @commitlint/load > cosmiconfig-typescript-loader@5.0.0" has unmet peer dependency "@types/node@*".
warning " > ts-node@10.9.2" has unmet peer dependency "@types/node@*".
warning " > typedoc-plugin-resolve-crossmodule-references@0.3.3" has incorrect peer dependency "typedoc@>=0.22 <=0.23".
warning "workspace-aggregator-86102416-a17a-48e8-a543-bb6de67cbbb0 > @markuplint/vue-parser > vue-eslint-parser@9.4.3" has unmet peer dependency "eslint@>=6.0.0".
warning Workspaces can only be enabled in private projects.
warning Workspaces can only be enabled in private projects.
[4/4] Building fresh packages...
[1/7] ⡀ heapdump
[2/7] ⡀ nx
[3/7] ⡀ esbuild
[4/7] ⡀ es5-ext
error /mnt/c/markuplint/markuplint/node_modules/nx: Command failed.
Exit code: 1
Command: node ./bin/post-install
Arguments:
Directory: /mnt/c/markuplint/markuplint/node_modules/nx
Output:
/mnt/c/markuplint/markuplint/node_modules/nx/src/project-graph/project-graph.js:128
...(projectConfigurationsError?.errors ?? []),
^
SyntaxError: Unexpected token .
at Module._compile (internal/modules/cjs/loader.js:723:23)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
at Module.load (internal/modules/cjs/loader.js:653:32)
at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
at Function.Module._load (internal/modules/cjs/loader.js:585:3)
at Module.require (internal/modules/cjs/loader.js:692:17)
at require (internal/modules/cjs/helpers.js:25:18)
at Object.<anonymous> (/mnt/c/markuplint/markuplint/node_modules/nx/bin/post-install
yarn run v1.22.21
$ run-p vscode:dev:extension vscode:dev:server
/mnt/c/markuplint/markuplint/node_modules/minimatch/dist/commonjs/index.js:192
options;
^
SyntaxError: Unexpected token ;
at Module._compile (internal/modules/cjs/loader.js:723:23)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
at Module.load (internal/modules/cjs/loader.js:653:32)
at Function.Module._load (internal/modules/cjs/loader.js:585:3)
at Module.require (internal/modules/cjs/loader.js:692:17)
at require (internal/modules/cjs/helpers.js:25:18)
at Object.<anonymous> (/mnt/c/markuplint/markuplint/node_modules/npm-run-all2/lib/match-tasks.js:13:23)
at Module._compile (internal/modules/cjs/loader.js:778:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
エラー
vscode上で、ターミナル自体を powershell でなくて wsl で開き yarn
yarn vscode:dev
したら動くっぽい?
okathira@Main:/mnt/c/markuplint/markuplint$ yarn vscode:dev
yarn run v1.22.22
$ cd vscode; yarn --ignore-engines; yarn --ignore-engines vscode:dev
[1/4] Resolving packages...
warning vscode-markuplint@4.7.5: The engine "vscode" appears to be invalid.
$ yarn vscode:build:server --watch
warning vscode-markuplint@4.7.5: The engine "vscode" appears to be invalid.
$ yarn vscode:build:extension --watch
warning vscode-markuplint@4.7.5: The engine "vscode" appears to be invalid.
$ esbuild src/server/index.ts --bundle --packages=external --platform=node --target=node20.9 --format=cjs --outfile=out/server.js --watch
warning vscode-markuplint@4.7.5: The engine "vscode" appears to be invalid.
$ esbuild src/extension.ts --bundle --packages=external --platform=node --target=node20.9 --format=cjs --outfile=out/extension.js --watch
[watch] build finished, watching for changes...
[watch] build finished, watching for changes...
Windows の path で怪しいところ
URL.pathname
と正規表現で file:
スキームを変換しているような箇所は、 pathToFileURL()
や pathToFileURL()
でクロスプラットフォーム対応するのが良い?
ドライブ文字あるとずれるかも
URL(url).pathname
系は全部 fileURLToPath()
も使って ドライブ文字周りのケアが必要?
parseUrl(url).pathname
も同じ
怪しげだけど、こっちはその前に fileURLToPath() 使っているから影響ないかも
前やった https://github.com/markuplint/markuplint/pull/1526 も pathToFileURL() で変換すべきものだった気もする
/
\
がある。
そのため、glob(path.resolve(path))
だとワイルドカードを解釈できず、glob(path.resolve(path).replaceAll('\\', '/'))
のように変換する必要があるっぽい
windowsPathsNoEscape を使っても良い
// test
/* eslint-disable no-console */
import path from 'node:path';
// import { main } from '@markuplint/spec-generator';
import { fileURLToPath } from 'node:url';
import { glob } from 'glob';
import { createDiffieHellmanGroup } from 'node:crypto';
// console.log('outputFilePath', path.resolve(__dirname, 'index.json'));
// console.log('htmlFilePattern', path.resolve(__dirname, 'src', 'spec.*.json'));
// console.log('commonAttrsFilePath', path.resolve(__dirname, 'src', 'spec-common.attributes.json'));
// console.log('commonContentsFilePath', path.resolve(__dirname, 'src', 'spec-common.contents.json'));
// trace htmlFilePattern
async function main() {
const __dirname = path.dirname(fileURLToPath(import.meta.url));
console.log('__dirname', __dirname);
const htmlFilePattern = path.join(__dirname, 'src', 'spec.a.json');
const htmlFilePatternWild = path.join(__dirname, 'src', 'spec.*.json');
console.log('htmlFilePattern', htmlFilePattern);
console.log('htmlFilePatternWild', htmlFilePatternWild);
console.log('glob');
const files = await glob(htmlFilePattern);
const filesWild = await glob(htmlFilePatternWild.replaceAll('\\', '/'));
console.log('files', files);
console.log('filesWild', filesWild);
console.log('glob relative', await glob('.src/spec.*.json'));
}
await main();