~/$ mkdir gatsby_pages ~/$ cd gatsby_pages ~/gatsby_pages$ gatsby new
create-gatsby version 3.13.1
Welcome to Gatsby!
This command will generate a new Gatsby site for you in /home/qkboo/work-blog/gatsby_pages with the setup you select. Let's answer some questions: What would you like to call your site? ✔ · backtest What would you like to name the folder where your site will be created? ✔ gatsby_pages/ backtest ✔ Will you be using JavaScript or TypeScript? · JavaScript ✔ Will you be using a CMS? · No (or I'll add it later) ✔ Would you like to install a styling system? · No (or I'll add it later) Thanks! Here's what we'll now do: 🛠 Create a new Gatsby site in the folder backtest ✔ Created site from template ✔ Installed Gatsby ✔ Installed plugins ✔ Created site in backtest 🎉 Your new Gatsby site backtest has been successfully created at /home/qkboo/work-blog/gatsby_pages/backtest. Start by going to the directory with cd backtest Start the local development server with npm run develop See all commands at https://www.gatsbyjs.com/docs/reference/gatsby-cli/
이렇게 생성된 디렉토리를 살펴보면 다음 같이 gatsby 프로젝트 구조가 생성되어 있다.
1 2 3 4 5 6 7 8 9 10 11 12 13 14
~/gatsby_pages$ ll backtest/ total 1128 drwxr-xr-x 7 qkboo qkboo 4096 Jan 26 22:28 ./ drwxr-xr-x 3 qkboo qkboo 4096 Jan 26 22:25 ../ drwxr-xr-x 22 qkboo qkboo 4096 Jan 26 22:28 .cache/ drwxr-xr-x 8 qkboo qkboo 4096 Jan 26 22:26 .git/ -rw-r--r-- 1 qkboo qkboo 32 Jan 26 22:25 .gitignore -rw-r--r-- 1 qkboo qkboo 1952 Jan 26 22:25 README.md -rw-r--r-- 1 qkboo qkboo 160 Jan 26 22:26 gatsby-config.js drwxr-xr-x 864 qkboo qkboo 36864 Jan 26 22:26 node_modules/ -rw-r--r-- 1 qkboo qkboo 1075858 Jan 26 22:26 package-lock.json -rw-r--r-- 1 qkboo qkboo 424 Jan 26 22:25 package.json drwxr-xr-x 5 qkboo qkboo 4096 Jan 26 22:28 public/ drwxr-xr-x 4 qkboo qkboo 4096 Jan 26 22:25 src/
서버 develop 모드 실행
gastby-CLI 명령으로 The development server 에서 서버를 실행해 보자, 개발용 서버는 로컬에서 실행하고 검증하고 좋다.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
~/gatsby_pages$ cd backtest/$ ~/gatsby_pages$ cd backtest/$ gatsby develop ...
success write out requires - 0.005s ⠀ You can now view backtest in the browser. ⠀ http://localhost:8000/ ⠀ View GraphiQL, an in-browser IDE, to explore your site's data and schema ⠀ http://localhost:8000/___graphql ⠀ Note that the development build is not optimized. To create a production build, use gatsby build ⠀ success Building development bundle - 11.658s success Writing page-data.json and slice-data.json files to public directory - 0.152s - 3/4 26.32/s
만약 그런데 gatsby 를 전역 환경에 설치하지 못했다면 npm 명령으로 실행할 수 있다.
1 2 3
>~/gatsby_pages/backtest$ npm run develop backtest@1.0.0 develop gatsby develop
어느날 git 의 레포지토리의 파일이 모두 changed 상태로 보여 당황했다. 한 파일을 diff 로 보니 줄의 마지막에 ^M 이 보였다. 에디터가 OS에 따라서 LF 를 CRLF 로 바꿔서 보여주는 것이었다.
CRLF 상황
Linux 를 20.04 LTS 를 사용하다 os-release-upgrade 를 사용해서 22.04 LTS 로 업그레이드 했다.
그리고 한동안 다른 작업을 하다 소스를 다루게 되어서 윈도우 11에서 VS code 로 WSL의 우분투 폴더를 열어 보니 git 의 staging area 에 커밋할 파일이 엄청 들어와 있는 것이다. 찾다 보니 아래 그림 같이 줄바꿈 코드로 CRLR 로 인식을 한 것이다.
소스 파일을 수정할 일이 아니라서 검색을 좀 해보니 git 의 전역 설정에서 가능할 것 같았다. 다음 링크를 참조했다.