Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generated directory has no .gitignore file #11

Closed
MurakamiShinyu opened this issue Aug 8, 2020 · 4 comments
Closed

Generated directory has no .gitignore file #11

MurakamiShinyu opened this issue Aug 8, 2020 · 4 comments
Assignees
Labels
enhancement New feature or request help wanted Extra attention is needed
Milestone

Comments

@MurakamiShinyu
Copy link
Member

npm create book <directory> の実行によって生成されるディレクトリに .gitignore ファイルが存在しないで、代わりに .gitignore が存在するという現象があります。yarn を使った場合には発生しないようです。npmを使ったときにも必ずしそうなるわけではないようです(条件が特定できていません)。

問題が起きたときのログ:

$ npm create book testpub
? description test publication
? author name MurakamiShinyu
? author email murakami@vivliostyle.org
? license CC0-1.0
? choose theme @vivliostyle/theme-bunko - 文庫用のテーマ

Creating a new package in /Users/shinyu/viv/testpub.

Installing dependencies.
yarn install v1.22.4
info No lockfile found.
[1/4] 🔍  Resolving packages...
warning @vivliostyle/cli > jsdom > request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142
warning @vivliostyle/cli > jsdom > request-promise-native@1.0.9: request-promise-native has been deprecated because it extends the now deprecated request package, see https://github.com/request/request/issues/3142
warning @vivliostyle/cli > jsdom > request > har-validator@5.1.5: this library is no longer supported
[2/4] 🚚  Fetching packages...
[3/4] 🔗  Linking dependencies...
[4/4] 🔨  Building fresh packages...
success Saved lockfile.
✨  Done in 54.72s.
    
Initialized a git repository

Success! Created testpub.

1. cd testpub
2. create and edit Markdown files
3. edit entry field in your vivliostyle.config.js
4. yarn build or npm run build

See https://docs.vivliostyle.org for further information.

🖋 Happy writing!

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               
~/viv/  
$ cd testpub/~/viv/testpub/  $ ls -la
total 336
drwxr-xr-x   11 shinyu  staff     352 Aug  8 18:13 .
drwxr-xr-x   97 shinyu  staff    3104 Aug  8 18:12 ..
drwxr-xr-x    9 shinyu  staff     288 Aug  8 18:13 .git
-rw-r--r--    1 shinyu  staff    1909 Aug  8 18:12 .npmignore
-rw-r--r--    1 shinyu  staff    7407 Aug  8 18:12 LICENSE
-rw-r--r--    1 shinyu  staff     417 Aug  8 18:12 README.md
-rw-r--r--    1 shinyu  staff    6175 Aug  8 18:12 manuscript.md
drwxr-xr-x  401 shinyu  staff   12832 Aug  8 18:13 node_modules
-rw-r--r--    1 shinyu  staff     344 Aug  8 18:12 package.json
-rw-r--r--    1 shinyu  staff    1272 Aug  8 18:12 vivliostyle.config.js
-rw-r--r--    1 shinyu  staff  135788 Aug  8 18:13 yarn.lock

.npmignore が存在して .gitignore が存在しない。

これではgitにコミットする前に mv .npmignore .gitignore によりファイル名の変更が必要です。

npmでの .gitignore ファイルの扱いの問題のようです。Stackoverflow に関係しそうな情報がありました:
https://stackoverflow.com/questions/24976950/how-do-i-include-a-gitignore-file-as-part-of-my-npm-module

npmの次のissueが関連するようです:
npm/npm#1862

@uetchy uetchy added enhancement New feature or request help wanted Extra attention is needed labels Aug 10, 2020
@akabekobeko akabekobeko self-assigned this Sep 13, 2020
@akabekobeko akabekobeko added this to the 1.0.0 milestone Jul 5, 2021
@MurakamiShinyu
Copy link
Member Author

いま試したのですが、 yarn create book を実行しても .gitignore ファイルが生成されません。(.npmignore も生成されません)  yarn と npm のどちらでも .gitignore ファイルが生成されず、gitにコミットするとき自分で .gitignore ファイルを作ってないと、node_modules 内の大量のファイルをコミットしてしまうという事故になりかねないです。

@MurakamiShinyu MurakamiShinyu changed the title Generated directory has .npmignore file instead of the .gitignore Generated directory has no .gitignore file Apr 21, 2022
@akabekobeko
Copy link
Member

akabekobeko commented Jun 4, 2022

Node 用のをコピーするよう修正する

現状は yarnnpx どちらも templates/default/.gitignore をコピーできていないようなので、create-book 本体で後処理する方向で検討。生成されたプロジェクト ディレクトリー内に .gitignore がなければ自前でコピーする。

@akabekobeko
Copy link
Member

ローカルで事後処理を実装 & デバッグして本件の原因判明。

npm pack したイメージを npm i した後の node_modules を見ると templates/default 内に .ignore は存在しない。create-book を npm としてビルドした時点で . ファイルは除外されるのだと思われる。

これを前提として以下の方法を試す。

  1. templates/defalt.gitignoregitignore というファイル名にする
  2. gitignore なら除外されず残るのでコピーされるはず、失敗した場合は事後処理でコピー
  3. コピーされた gitignore.gitignore へリネームする

@akabekobeko
Copy link
Member

#58 で修正、v1.0.0 としてリリースしたので close します。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants