-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add
node_modules
to git ignore files list, create gh-tran builder
- Loading branch information
Showing
5 changed files
with
269 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,3 +14,4 @@ | |
|
||
# Dependency directories (remove the comment below to include it) | ||
vendor | ||
node_modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
const fs = require("fs"); | ||
const path = require("path"); | ||
const rm = require("rimraf"); | ||
const mkdirp = require("mkdirp"); | ||
const sh = require("shelljs"); | ||
|
||
const VERSION_CMD = sh.exec("git describe --abbrev=0 --tags"); | ||
const VERSION_DATE_CMD = sh.exec("go run ./scripts/date.go"); | ||
|
||
const VERSION = VERSION_CMD.replace("\n", "").replace("\r", ""); | ||
const VERSION_DATE = VERSION_DATE_CMD.replace("\n", "").replace("\r", ""); | ||
|
||
const ROOT = __dirname; | ||
const TEMPLATES = path.join(ROOT, "templates"); | ||
|
||
async function updateTranExtension(ghTranDir) { | ||
const templatePath = path.join(TEMPLATES, "gh-tran"); | ||
const template = fs.readFileSync(templatePath).toString("utf-8"); | ||
|
||
const templateReplaced = template | ||
.replace("CLI_VERSION", VERSION) | ||
.replace("CLI_VERSION_DATE", VERSION_DATE); | ||
|
||
fs.writeFileSync(path.join(ghTranDir, "gh-tran"), templateReplaced); | ||
} | ||
|
||
async function updateExtension() { | ||
const tmp = path.join(__dirname, "tmp"); | ||
const extensionDir = path.join(tmp, "gh-tran"); | ||
|
||
mkdirp.sync(tmp); | ||
rm.sync(extensionDir); | ||
|
||
console.log(`cloning https://github.com/abdfnx/gh-tran to ${extensionDir}`); | ||
|
||
sh.exec(`git clone https://github.com/abdfnx/gh-tran.git ${extensionDir}`) | ||
|
||
console.log(`done cloning abdfnx/gh-tran to ${extensionDir}`); | ||
|
||
console.log("updating local git..."); | ||
|
||
await updateTranExtension(extensionDir); | ||
} | ||
|
||
updateExtension().catch((err) => { | ||
console.error(`error running scripts/gh-tran/gh-trn.js`, err); | ||
process.exit(1); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"name": "gh-trn-brew", | ||
"version": "0.0.0", | ||
"description": "gh cli extension of tran", | ||
"author": "@abdfnx", | ||
"main": "gh-trn.js", | ||
"scripts": { | ||
"start": "node gh-trn.js" | ||
}, | ||
"keywords": [ | ||
"tran", | ||
"github" | ||
], | ||
"dependencies": { | ||
"mkdirp": "^1.0.4", | ||
"rimraf": "^3.0.2", | ||
"shelljs": "^0.8.5" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
#!/bin/bash | ||
set -e | ||
|
||
repo="abdfnx/gh-tran" | ||
tag="CLI_VERSION" | ||
buildDate="CLI_VERSION_DATE" | ||
|
||
extensionPath="$(dirname "$0")" | ||
arch="$(uname -m)" | ||
|
||
exe="" | ||
|
||
if uname -a | grep Msys > /dev/null; then | ||
if [ $arch = "x86_64" ]; then | ||
exe="windows-x86_64" | ||
elif [ $arch = "i686" ]; then | ||
exe="windows-i386" | ||
elif [ $arch = "i386" ]; then | ||
exe="windows-i386" | ||
fi | ||
elif uname -a | grep Darwin > /dev/null; then | ||
if [ $arch = "x86_64" ]; then | ||
exe="darwin-x86_64" | ||
fi | ||
elif uname -a | grep Linux > /dev/null; then | ||
if [ $arch = "x86_64" ]; then | ||
exe="linux-x86_64" | ||
elif [ $arch = "i686" ]; then | ||
exe="linux-i38" | ||
elif [ $arch = "i386" ]; then | ||
exe="linux-i386" | ||
fi | ||
fi | ||
|
||
if [ "${exe}" == "" ]; then | ||
if [ "$(which go)" = "" ]; then | ||
echo "go must be installed to use this gh extension on this platform" | ||
exit 1 | ||
fi | ||
|
||
exe="cmd.out" | ||
|
||
cd "${extensionPath}" > /dev/null | ||
go build -o "${exe}" -ldflags "-X main.version=${tag} -X main.buildDate=${buildDate}" | ||
cd - > /dev/null | ||
else | ||
if [[ ! -x "${extensionPath}/bin/${exe}" ]]; then | ||
mkdir -p "${extensionPath}/bin" | ||
rm -f "${extensionPath}/bin/*" | ||
gh release -R"${repo}" download "${tag}" -p "${exe}" --dir="${extensionPath}/bin" | ||
chmod +x "${extensionPath}/bin/${exe}" | ||
fi | ||
fi | ||
|
||
exec "${extensionPath}/bin/${exe}" "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,146 @@ | ||
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. | ||
# yarn lockfile v1 | ||
|
||
|
||
balanced-match@^1.0.0: | ||
version "1.0.2" | ||
resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.2.tgz#e83e3a7e3f300b34cb9d87f615fa0cbf357690ee" | ||
integrity sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw== | ||
|
||
brace-expansion@^1.1.7: | ||
version "1.1.11" | ||
resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-1.1.11.tgz#3c7fcbf529d87226f3d2f52b966ff5271eb441dd" | ||
integrity sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA== | ||
dependencies: | ||
balanced-match "^1.0.0" | ||
concat-map "0.0.1" | ||
|
||
concat-map@0.0.1: | ||
version "0.0.1" | ||
resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b" | ||
integrity sha1-2Klr13/Wjfd5OnMDajug1UBdR3s= | ||
|
||
fs.realpath@^1.0.0: | ||
version "1.0.0" | ||
resolved "https://registry.yarnpkg.com/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f" | ||
integrity sha1-FQStJSMVjKpA20onh8sBQRmU6k8= | ||
|
||
function-bind@^1.1.1: | ||
version "1.1.1" | ||
resolved "https://registry.yarnpkg.com/function-bind/-/function-bind-1.1.1.tgz#a56899d3ea3c9bab874bb9773b7c5ede92f4895d" | ||
integrity sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A== | ||
|
||
glob@^7.0.0, glob@^7.1.3: | ||
version "7.2.0" | ||
resolved "https://registry.yarnpkg.com/glob/-/glob-7.2.0.tgz#d15535af7732e02e948f4c41628bd910293f6023" | ||
integrity sha512-lmLf6gtyrPq8tTjSmrO94wBeQbFR3HbLHbuyD69wuyQkImp2hWqMGB47OX65FBkPffO641IP9jWa1z4ivqG26Q== | ||
dependencies: | ||
fs.realpath "^1.0.0" | ||
inflight "^1.0.4" | ||
inherits "2" | ||
minimatch "^3.0.4" | ||
once "^1.3.0" | ||
path-is-absolute "^1.0.0" | ||
|
||
has@^1.0.3: | ||
version "1.0.3" | ||
resolved "https://registry.yarnpkg.com/has/-/has-1.0.3.tgz#722d7cbfc1f6aa8241f16dd814e011e1f41e8796" | ||
integrity sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw== | ||
dependencies: | ||
function-bind "^1.1.1" | ||
|
||
inflight@^1.0.4: | ||
version "1.0.6" | ||
resolved "https://registry.yarnpkg.com/inflight/-/inflight-1.0.6.tgz#49bd6331d7d02d0c09bc910a1075ba8165b56df9" | ||
integrity sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk= | ||
dependencies: | ||
once "^1.3.0" | ||
wrappy "1" | ||
|
||
inherits@2: | ||
version "2.0.4" | ||
resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.4.tgz#0fa2c64f932917c3433a0ded55363aae37416b7c" | ||
integrity sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ== | ||
|
||
interpret@^1.0.0: | ||
version "1.4.0" | ||
resolved "https://registry.yarnpkg.com/interpret/-/interpret-1.4.0.tgz#665ab8bc4da27a774a40584e812e3e0fa45b1a1e" | ||
integrity sha512-agE4QfB2Lkp9uICn7BAqoscw4SZP9kTE2hxiFI3jBPmXJfdqiahTbUuKGsMoN2GtqL9AxhYioAcVvgsb1HvRbA== | ||
|
||
is-core-module@^2.8.1: | ||
version "2.8.1" | ||
resolved "https://registry.yarnpkg.com/is-core-module/-/is-core-module-2.8.1.tgz#f59fdfca701d5879d0a6b100a40aa1560ce27211" | ||
integrity sha512-SdNCUs284hr40hFTFP6l0IfZ/RSrMXF3qgoRHd3/79unUTvrFO/JoXwkGm+5J/Oe3E/b5GsnG330uUNgRpu1PA== | ||
dependencies: | ||
has "^1.0.3" | ||
|
||
minimatch@^3.0.4: | ||
version "3.0.4" | ||
resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.0.4.tgz#5166e286457f03306064be5497e8dbb0c3d32083" | ||
integrity sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA== | ||
dependencies: | ||
brace-expansion "^1.1.7" | ||
|
||
mkdirp@^1.0.4: | ||
version "1.0.4" | ||
resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-1.0.4.tgz#3eb5ed62622756d79a5f0e2a221dfebad75c2f7e" | ||
integrity sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw== | ||
|
||
once@^1.3.0: | ||
version "1.4.0" | ||
resolved "https://registry.yarnpkg.com/once/-/once-1.4.0.tgz#583b1aa775961d4b113ac17d9c50baef9dd76bd1" | ||
integrity sha1-WDsap3WWHUsROsF9nFC6753Xa9E= | ||
dependencies: | ||
wrappy "1" | ||
|
||
path-is-absolute@^1.0.0: | ||
version "1.0.1" | ||
resolved "https://registry.yarnpkg.com/path-is-absolute/-/path-is-absolute-1.0.1.tgz#174b9268735534ffbc7ace6bf53a5a9e1b5c5f5f" | ||
integrity sha1-F0uSaHNVNP+8es5r9TpanhtcX18= | ||
|
||
path-parse@^1.0.7: | ||
version "1.0.7" | ||
resolved "https://registry.yarnpkg.com/path-parse/-/path-parse-1.0.7.tgz#fbc114b60ca42b30d9daf5858e4bd68bbedb6735" | ||
integrity sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw== | ||
|
||
rechoir@^0.6.2: | ||
version "0.6.2" | ||
resolved "https://registry.yarnpkg.com/rechoir/-/rechoir-0.6.2.tgz#85204b54dba82d5742e28c96756ef43af50e3384" | ||
integrity sha1-hSBLVNuoLVdC4oyWdW70OvUOM4Q= | ||
dependencies: | ||
resolve "^1.1.6" | ||
|
||
resolve@^1.1.6: | ||
version "1.22.0" | ||
resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.22.0.tgz#5e0b8c67c15df57a89bdbabe603a002f21731198" | ||
integrity sha512-Hhtrw0nLeSrFQ7phPp4OOcVjLPIeMnRlr5mcnVuMe7M/7eBn98A3hmFRLoFo3DLZkivSYwhRUJTyPyWAk56WLw== | ||
dependencies: | ||
is-core-module "^2.8.1" | ||
path-parse "^1.0.7" | ||
supports-preserve-symlinks-flag "^1.0.0" | ||
|
||
rimraf@^3.0.2: | ||
version "3.0.2" | ||
resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-3.0.2.tgz#f1a5402ba6220ad52cc1282bac1ae3aa49fd061a" | ||
integrity sha512-JZkJMZkAGFFPP2YqXZXPbMlMBgsxzE8ILs4lMIX/2o0L9UBw9O/Y3o6wFw/i9YLapcUJWwqbi3kdxIPdC62TIA== | ||
dependencies: | ||
glob "^7.1.3" | ||
|
||
shelljs@^0.8.5: | ||
version "0.8.5" | ||
resolved "https://registry.yarnpkg.com/shelljs/-/shelljs-0.8.5.tgz#de055408d8361bed66c669d2f000538ced8ee20c" | ||
integrity sha512-TiwcRcrkhHvbrZbnRcFYMLl30Dfov3HKqzp5tO5b4pt6G/SezKcYhmDg15zXVBswHmctSAQKznqNW2LO5tTDow== | ||
dependencies: | ||
glob "^7.0.0" | ||
interpret "^1.0.0" | ||
rechoir "^0.6.2" | ||
|
||
supports-preserve-symlinks-flag@^1.0.0: | ||
version "1.0.0" | ||
resolved "https://registry.yarnpkg.com/supports-preserve-symlinks-flag/-/supports-preserve-symlinks-flag-1.0.0.tgz#6eda4bd344a3c94aea376d4cc31bc77311039e09" | ||
integrity sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w== | ||
|
||
wrappy@1: | ||
version "1.0.2" | ||
resolved "https://registry.yarnpkg.com/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f" | ||
integrity sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8= |