0.0.3 • Published 5 years ago

toplogis-test-lib v0.0.3

Weekly downloads
16
License
-
Repository
-
Last release
5 years ago

環境

安裝 Node

  • 建議先安裝 NVM,使用 NVM 安裝 Node,方便版本的切換
  • 本專案使用版本為(v8.12.0
  • 使用 vscode 開發
  • git clone project
  > git clone ${project repo}
  • 安裝 套件
  > cd ${workspace folder}
  > npm install

VSCODE 插件

  • 專案添加了 ESLintstylelint 檢查語法與格式
  • 使用 husky 於 commit 前檢查
  • (可選)在開發中 watch 檔案異動做檢查 ,需安裝以下插件
  1. .vscode/setting.json 工作區設定修正
"editor.detectIndentation": false,
"editor.insertSpaces": true,
"editor.tabSize": 2,
  1. 插件 Vetur,並在 .vscode/setting.json 工作區設定添加
"vetur.format.defaultFormatter.js": "none",
"vetur.format.defaultFormatter.html": "none",
"vetur.format.defaultFormatter.scss": "none",
"vetur.format.defaultFormatter.css": "none",
  1. 插件 Prettier,並在 .vscode/setting.json 工作區設定添加
"prettier.eslintIntegration": true,
"prettier.stylelintIntegration": true,
"prettier.disableLanguages": [],
  1. 插件 ESLint,並在 .vscode/setting.json 工作區設定添加
"eslint.packageManager": "npm", // or yarn
"eslint.alwaysShowStatus": true,
"eslint.trace.server": "verbose",
"eslint.nodePath": "./node_modules",
"eslint.autoFixOnSave": true,
"eslint.validate": [
  "javascript",
  {
    "language": "vue",
    "autoFix": true
  },
],
  1. 插件 stylelint,並在 .vscode/setting.json 工作區設定添加

    此部分在修改 stylelint 設定檔後(.stylelintrc*),需重啟 vscode

"css.validate": false,
"scss.validate": false,
  1. 插件 EditorConfig for VS Code


Building frontend using webpack

  • 開發
  > npm run client:dev
  • 打包
  > npm run client:build


A.I.O.( All-In-One backend framework of Asynchronous I/O )

開發

  • vscode 偵錯設定 .vscode/launch.json
  1. 使用 Node
{
  "version": "0.2.0",
  "configurations": [
    {
      "type": "node",
      "request": "launch",
      "name": "啟動程式",
      "program": "${workspaceRoot}/server/bin/www",
      "env": {
        "NODE_ENV": "development",
        "SERVER_MANAGER": "VSCODE"
      }
    },
    {
      "type": "node",
      "request": "attach",
      "name": "附加至處理序",
      "port": 5858
    }
  ]
}
  1. 推薦使用 nodemon(自動重啟)
{
  "version": "0.2.0",
  "configurations": [
    {
      "type": "node",
      "request": "launch",
      "name": "nodemon",
      "runtimeExecutable": "nodemon",
      "program": "${workspaceRoot}/server/bin/www",
      "restart": true,
      "console": "integratedTerminal",
      "internalConsoleOptions": "neverOpen",
      "env": {
        "NODE_ENV": "development",
        "SERVER_MANAGER": "VSCODE"
      }
    },
    {
      "type": "node",
      "request": "attach",
      "name": "附加至處理序",
      "port": 5858
    }
  ]
}

正式環境使用

  • (可選)安裝 PM2( Process Manager )
  > npm install pm2 -g
  > pm2 install pm2-logrotate # 安裝日誌管理套件
  > pm2 set pm2-logrotate:max_size 500M # 設置日誌文件大小
  > pm2 set pm2-logrotate:workerInterval 60 # 每分鐘檢查日誌文件大小
  > pm2 set pm2-logrotate:retain 30 # 要保留的日誌文件數
  > pm2 set pm2-logrotate:compress true # 壓縮日誌文件
  > pm2 set pm2-logrotate:dateFormat YYYYMMDD-HHmm # 日誌文件檔名
  > pm2 set pm2-logrotate:rotateInterval '0 0 * * *' # 設置日誌文件週期