20190607のGitに関する記事は4件です。

vue-cliのビルドファイルをGitHub Pagesにデプロイ

1.vue.config.js に正しい publicPath を設定

https://<USERNAME>.github.io/ にデプロイしている場合は、publicPathを省略することができる(デフォルトは "/"のため)。

https://<USERNAME>.github.io/<REPO>/にデプロイしている場合(例えば、リポジトリがhttps://github.com/<USERNAME>/<REPO>にある場合)、publicPath"/<REPO>/" に設定。

例えば、リポジトリ名が "my-project"の場合、vue.config.js(config/dev.env.js) は次のようになる。

module.exports = {
  publicPath: process.env.NODE_ENV === 'production'
    ? '/my-project/'
    : '/'
}

2.プロジェクト内で、次の内容でdeploy.shを作成し、それを実行してデプロイ

deploy.sh
#!/usr/bin/env sh

# エラー
set -e

# build
npm run build

# 出力されたディレクトリに移動
cd dist

# カスタムドメインにデプロイする場合
# echo 'www.example.com' > CNAME

git init
git add -A
git commit -m 'deploy'

# https://<USERNAME>.github.io にデプロイする場合
# git push -f git@github.com:<USERNAME>/<USERNAME>.github.io.git master

# https://<USERNAME>.github.io/<REPO> にデプロイする場合
# git push -f git@github.com:<USERNAME>/<REPO>.git master:gh-pages

cd -

シェルスクリプトファイル(deploy.sh)を実行
chmod 755 deploy.sh
./deploy.sh

これでデプロイが完了です

Reference
  • このエントリーをはてなブックマークに追加
  • Qiitaで続きを読む

【2019年版】チームが幸せなiOSプロジェクトの作り方

はじめに

チーム開発向けのプロジェクトキッティング

やりたいこと

チーム開発の時のコンフリクト絶対許さないプロジェクトの誕生を祝いたい

使うもの

  • XcodeGen
  • CocoaPods(Carthageの場合は臨機応変に)
  • xcconfig-extractor
  • MacOS 10.14.5 以上
  • Xcode 10.2 以上
  • .gitignore
  • SwiftLint

使用上の注意

※自己責任

下準備

1、XcodeGenのインストール

$ brew install xcodegen

# インスコ確認
$ xcodegen --help
Usage: xcodegen generate [options]

Generate an Xcode project from a spec
<以下、省略>

2、CocoaPodsのインストール

$ brew install cocoapods

# インスコ確認
$ pod --version
1.6.1(適宜)

3、xcconfig-extractorのインストール

brewで入れられなかったの悔しい

$ bash <(curl -sL https://raw.githubusercontent.com/toshi0383/scripts/master/swiftpm/install.sh) toshi0383/xcconfig-extractor

# バージョン確認
xcconfig-extractor --version
0.5.0

準備

1、xcodeで新規プロジェクト作る

2、swift5にアップ

Build Settings -> swiftで検索してSwift Language VersionをSwift 5にする

3、xcconfigの作成

commmand一発でやってくれるので楽チン

$ xcconfig-extractor {prj_dir}/{prj_name}.xcodeproj configs

4、project.ymlの作成

下記をコピってをエディタかなんかで自分のプロジェクト名に全置換
作成したらREADMEとかに置いてある階層に設置

project.yml
name: <project name>
fileGroups:
  - configs
configFiles:
  Debug: configs/Debug.xcconfig
  Release: configs/Release.xcconfig
targets:
  <project name>:
    type: application
    platform: iOS
    sources: <project name>
    configFiles:
      Debug: configs/<project name>-Debug.xcconfig
      Release: configs/<project name>-Release.xcconfig
    settings:
      CURRENT_PROJECT_VERSION: 1
    scheme:
      testTargets:
        - <project name>Tests
        - <project name>UITests
  <project name>Tests:
    type: bundle.unit-test
    platform: iOS
    sources: <project name>Tests
    configFiles:
      Debug: configs/<project name>Tests-Debug.xcconfig
      Release: configs/<project name>Tests-Release.xcconfig
    dependencies:
      - target: <project name>
  <project name>UITests:
    type: bundle.ui-testing
    platform: iOS
    sources: <project name>UITests
    configFiles:
      Debug: configs/<project name>UITests-Debug.xcconfig
      Release: configs/<project name>UITests-Release.xcconfig
    dependencies:
      - target: <project name>

5、xcodeprojファイルの作成

$ xcodegen

.gitignoreとの戦い編

1、.gitignore作成

gitignore.ioで作成する

今回使用したのはXcode、macOS、Swiftの3つ

エディタでファイル作ったらコピペ
プロジェクトディレクトリに置く

2、.gitignoreのカスタマイズ

75行目くらいのCocoaPodsのところ

 75 # CocoaPods
 76 # We recommend against adding the Pods directory to your .gitignore. However
 77 # you should judge for yourself, the pros and cons are mentioned at:
 78 # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
 79 # Pods/
 80 # Add this line if you want to avoid checking in source code from the Xcode workspace
 81 # *.xcworkspace

79行目、81行目の#を削除でこんにちわ

 75 # CocoaPods
 76 # We recommend against adding the Pods directory to your .gitignore. However
 77 # you should judge for yourself, the pros and cons are mentioned at:
 78 # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
 79 Pods/
 80 # Add this line if you want to avoid checking in source code from the Xcode workspace
 81 *.xcworkspace

116行目くらいのXcode Patchのところ

116 ### Xcode Patch ###
117 *.xcodeproj/*
118 !*.xcodeproj/project.pbxproj
119 !*.xcodeproj/xcshareddata/
120 !*.xcworkspace/contents.xcworkspacedata

119行目の!*.xcodeproj/project.pbxprojの!を削除

116 ### Xcode Patch ###
117 *.xcodeproj/*
118 *.xcodeproj/project.pbxproj
119 !*.xcodeproj/xcshareddata/
120 !*.xcworkspace/contents.xcworkspacedata

3、CocoaPodsをセットアップ

結構時間かかる

$ pod setup

4、Podfileを作成

プロジェクトディレクトリでチャカチャカターン!

$ pod init

5、Podfileを編集

  • 2行目のplatformのコメントアウト外してビルドターゲット入れないとxcodegen + pod installでエラー出る
  • 6行目のuse_frameworks!のコメントアウト外す
  • とりまSwiftLint入れる
  1 # Uncomment the next line to define a global platform for your project
  2 platform :ios, '12.0'
  3
  4 target '<project name>' do
  5   # Comment the next line if you're not using Swift and don't want to use dynamic frameworks
  6   use_frameworks!
  7
  8   # Pods for <project name>
  9   pod 'SwiftLint'
 10
 11   target '<project name>Tests' do
 12     inherit! :search_paths
 13     # Pods for testing
 14   end
 15
 16   target '<project name>UITests' do
 17     inherit! :search_paths
 18     # Pods for testing
 19   end
 20
 21 end

6、SwiftLint導入

$ pod install

# ここで以下が自動生成される

Podfile.lock
Pods/
.xcworkspace

7、Xcodeでビルド通るか確認する

ビルド通れば幸せでgit push
ビルド通ってなければ参考記事.gitignoreを後から適用する手順を使って頑張る

Podfile.lockは@mono0926さんの記事CocoaPods・Carthageでインストールした成果物はバージョン管理に含めるべきか?を読んで監視することにしました

git監視から外すのは以下3つ

  1. Pods/
  2. .xcworkspace
  3. [project name].xcodeproj/project.pbxproj

運用

ライブラリを追加する時

$ pod install
$ xcodegen

これだけでチームが幸せ☺️

参考記事

Xcodegenを導入しました。
XcodeGenを導入してハマったこと

  • このエントリーをはてなブックマークに追加
  • Qiitaで続きを読む

それは突然やって来た

"Github Desktop"なるもの

  • インストなりして動かしていたら元を忘れてしまったが、(多分自分のRSSリーダーだと思うが)Github Desktop v2がリリースされたとの事
  • 記事見てオフィシャルサイトからDLしてインスト
  • Github上の自分のリポジトリからクローンしてリモートリポジトリを作成
  • すごく原始的だけどGCEからコピペでファイルをローカルに保存
  • ローカルからローカルリポジトリへコミット
  • ローカルリポジトリからリモートリポジトリへプッシュ
  • 出来た!

何がよくて何がいけなかったのは、今は追いかけない方がいいと思う

  • リモートリポジトリへプッシュ出来た事に変わりはない。ではなぜSource treeはダメでGithub desktopなら平気なのかは分からない。でもプッシュ出来たので一先ずはよしとしよう。目的達成出来たからね:grinning:

今日の気持ち

  • ここで改めて言う必要はないと思うけど、大切な事だから忘れないように書いておく
  • 今の会社は辞める。気持ちは完全に固まった
  • 自分はコンピュータエンジニアでいる、居続ける。そこだけはブレない
  • このエントリーをはてなブックマークに追加
  • Qiitaで続きを読む

ローカルで削除したファイルをリモートに反映させる

git add -u

git commit -m "cleanup"

git push origin hoge

  • このエントリーをはてなブックマークに追加
  • Qiitaで続きを読む