feat: 초기 프로젝트 설정 및 룰.md 파일 추가

This commit is contained in:
2025-07-28 09:53:31 +09:00
commit 09a4d38512
8165 changed files with 1021855 additions and 0 deletions

19
api.hyungi.net/node_modules/pm2-deploy/LICENSE generated vendored Normal file
View File

@@ -0,0 +1,19 @@
Copyright (c) 2010-2015
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

85
api.hyungi.net/node_modules/pm2-deploy/README.md generated vendored Normal file
View File

@@ -0,0 +1,85 @@
# Deploy system for PM2
This is the module that allows to do `pm2 deploy`.
Documentation: http://pm2.keymetrics.io/docs/usage/deployment/
[![build status](https://badgen.net/travis/Unitech/pm2/master)](https://travis-ci.org/Unitech/pm2-deploy) [![npm package version](https://badgen.net/npm/v/pm2-deploy)](https://npm.im/pm2-deploy) [![install size](https://badgen.net/packagephobia/install/pm2-deploy)](https://packagephobia.now.sh/result?p=pm2-deploy) [![github license](https://badgen.net/github/license/Unitech/pm2-deploy)](https://github.com/Unitech/pm2-deploy/blob/master/LICENSE) [![js semistandard style](https://badgen.net/badge/code%20style/semistandard/pink)](https://github.com/Flet/semistandard)
## Instalation
$ npm install pm2-deploy
## Programmatic Usage
```js
var deployForEnv = require('pm2-deploy').deployForEnv;
// Define deploy configuration with target environments
var deployConfig = {
prod: {
user: 'node',
host: '212.83.163.168',
ref: 'origin/master',
repo: 'git@github.com:Unitech/eip-vitrine.git',
path: '/var/www/test-deploy'
},
dev: {
user: 'node',
host: '212.83.163.168',
ref: 'origin/master',
repo: 'git@github.com:Unitech/eip-vitrine.git',
path: '/var/www/test-dev'
}
};
// Invoke deployment for `dev` environment
deployForEnv(deployConfig, 'dev', [], function (err, args) {
if (err) {
console.error('Deploy failed:', err.message);
return console.error(err.stack);
}
console.log('Success!');
});
// Rollback `prod` environment
deployForEnv(deployConfig, 'prod', ['revert', 1], function (err, args) {
if (err) {
console.error('Rollback failed:', err.message);
return console.error(err.stack);
}
console.log('Success!');
});
```
## API
<!-- Generated by documentation.js. Update this documentation by updating the source code. -->
#### Table of Contents
- [deployForEnv](#deployforenv)
- [Parameters](#parameters)
- [DeployCallback](#deploycallback)
- [Parameters](#parameters-1)
### deployForEnv
Deploy to a single environment
#### Parameters
- `deployConfig` **[object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** object containing deploy configs for all environments
- `env` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** the name of the environment to deploy to
- `args` **[array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)** custom deploy command-line arguments
- `cb` **[DeployCallback](#deploycallback)** done callback
Returns **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** return value is always `false`
### DeployCallback
Type: [Function](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function)
#### Parameters
- `error` **[Error](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error)** deployment error
- `args` **[array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)** custom command-line arguments provided to deploy

376
api.hyungi.net/node_modules/pm2-deploy/deploy generated vendored Normal file
View File

@@ -0,0 +1,376 @@
#!/usr/bin/env bash
#
# deploy(1) - Minimalistic shell script to deploy Git repositories.
# Released under the MIT License.
#
# https://github.com/visionmedia/deploy
#
VERSION="0.6.0"
CONFIG=./deploy.conf
LOG=/tmp/pm2-deploy-${USER:-default}.log
FORCE=0
REF=
ENV=
#
# Read PIPED JSON
#
read conf
#
# Output usage information.
#
usage() {
cat <<-EOF
Usage: deploy [options] <env> [command]
Options:
-C, --chdir <path> change the working directory to <path>
-c, --config <path> set config path. defaults to ./deploy.conf
-V, --version output program version
-h, --help output help information
-f, --force skip local change checking
Commands:
setup run remote setup commands
revert [n] revert to [n]th last deployment or 1
config [key] output config file or [key]
curr[ent] output current release commit
prev[ious] output previous release commit
exec|run <cmd> execute the given <cmd>
list list previous deploy commits
ref [ref] deploy [ref]
EOF
}
#
# Abort with <msg>
#
abort() {
echo
echo " $@" 1>&2
echo
exit 1
}
#
# Log <msg>.
#
log() {
echo " ○ $@"
}
#
# Get config value by <key>.
#
config_get() {
local key=$1
echo $(expr "$conf" : '.*"'$key'":"\([^"]*\)"')
}
#
# Output version.
#
version() {
echo $VERSION
}
#
# Return the ssh command to run.
#
ssh_command() {
local user="`config_get user`"
if test -n "$user"; then
local url="$user@`config_get host`"
else
local url="`config_get host`"
fi
local unexpanded_key="`config_get key`"
local key="${unexpanded_key/#\~/$HOME}"
local forward_agent="`config_get forward-agent`"
local port="`config_get port`"
local needs_tty="`config_get needs_tty`"
local ssh_options="`config_get ssh_options`"
test -n "$forward_agent" && local agent="-A"
test -n "$key" && local identity="-i $key"
test -n "$port" && local port="-p $port"
test -n "$needs_tty" && local tty="-t"
test -n "ssh_options" && local ssh_opts="$ssh_options"
echo "ssh $ssh_opts $tty $agent $port $identity $url"
}
#
# Run the given remote <cmd>.
#
runRemote() {
local shell="`ssh_command`"
echo $shell "\"$@\"" >> $LOG
$shell $@
}
#
# Run the given local <cmd>.
#
runLocal() {
echo "\"$@\"" >> $LOG
/usr/bin/env bash -c "$*"
}
#
# Run the given <cmd> either locally or remotely
#
run() {
local host="`config_get host`"
if [[ $host == localhost ]]
then
runLocal $@
else
runRemote $@
fi
}
#
# Output config or [key].
#
config() {
echo $(expr "$conf" : '.*"$key":"\([^"]*\)"')
}
#
# Execute hook <name> relative to the path configured.
#
hook() {
test -n "$1" || abort hook name required
local hook=$1
local path=`config_get path`
local cmd=`config_get $hook`
if test -n "$cmd"; then
log "executing $hook \`$cmd\`"
run "cd $path/current; \
SHARED=\"$path/shared\" \
$cmd 2>&1 | tee -a $LOG; \
exit \${PIPESTATUS[0]}"
test $? -eq 0
else
log hook $hook
fi
}
#
# Pre Setup hook runs on the host before the actual setup runs
# multiple commands or a script
#
hook_pre_setup() {
local cmd=`config_get pre-setup`
if test -n "$cmd"; then
local is_script=($cmd)
if [ -f "${is_script[0]}" ]; then
log "executing pre-setup script \`$cmd\`"
local shell="`ssh_command`"
runLocal "$shell 'bash -s' -- < $cmd"
else
log "executing pre-setup \`$cmd\`"
run "$cmd"
fi
test $? -eq 0
else
log hook pre-setup
fi
}
#
# Run setup.
#
setup() {
local path=`config_get path`
local repo=`config_get repo`
local ref=`config_get ref`
local fetch=`config_get fetch`
local branch=${ref#*/}
hook_pre_setup || abort pre-setup hook failed
run "mkdir -p $path/{shared/{logs,pids},source}"
test $? -eq 0 || abort setup paths failed
log running setup
log cloning $repo
if test "$fetch" != "fast"; then
log "full fetch"
run "git clone --branch $branch $repo $path/source"
else
log "fast fetch"
run "git clone --depth=5 --branch $branch $repo $path/source"
fi
test $? -eq 0 || abort failed to clone
run "ln -sfn $path/source $path/current"
test $? -eq 0 || abort symlink failed
hook post-setup || abort post-setup hook failed
log setup complete
}
#
# Deploy [ref].
#
deploy() {
local ref=$1
local branch=$2
if test -z "$branch"; then
branch=${ref#*/}
fi
local path=`config_get path`
local fetch=`config_get fetch`
log "deploying ${ref}"
# 1- Execute local commands
log executing pre-deploy-local
local pdl=`config_get pre-deploy-local`
runLocal $pdl || abort pre-deploy-local hook failed
# 2- Execute pre deploy commands on remote server
hook pre-deploy || abort pre-deploy hook failed
# 3- Fetch updates
log fetching updates
if test "$fetch" != "fast"; then
log "full fetch"
run "cd $path/source && git fetch --all --tags"
else
log "fast fetch"
run "cd $path/source && git fetch --depth=5 --all --tags"
fi
test $? -eq 0 || abort fetch failed
# 4- If no reference retrieve shorthand name for the remote repo
if test -z "$ref"; then
log fetching latest tag
ref=`run "cd $path/source && git for-each-ref \
--sort=-*authordate \
--format='%(refname)' \
--count=1 | cut -d '/' -f 3"`
test $? -eq 0 || abort failed to determine latest tag
fi
# 5- Reset to ref
log resetting HEAD to $ref
run "cd $path/source && git reset --hard $ref"
test $? -eq 0 || abort git reset failed
# 6- Link current
run "ln -sfn $path/source $path/current"
test $? -eq 0 || abort symlink failed
# deploy log
run "cd $path/source && \
echo \`git rev-parse HEAD\` \
>> $path/.deploys"
test $? -eq 0 || abort deploy log append failed
hook post-deploy || abort post-deploy hook failed
# done
log successfully deployed $ref
}
#
# Get current commit.
#
current_commit() {
local path=`config_get path`
run "cd $path/source && \
git rev-parse --short HEAD"
}
#
# Get <n>th deploy commit.
#
nth_deploy_commit() {
local n=$1
local path=`config_get path`
run "cat $path/.deploys | tail -n $n | head -n 1 | cut -d ' ' -f 1"
}
#
# List deploys.
#
list_deploys() {
local path=`config_get path`
run "tac $path/.deploys | awk '{printf \"%d\t%s\n\", NR-1, \$0}'"
}
#
# Revert to the <n>th last deployment.
#
revert_to() {
local n=$1
log "reverting $n deploy(s)"
local commit=`nth_deploy_commit $((n + 1))`
deploy "$commit"
}
#
# Ensure all changes are committed and pushed before deploying.
#
check_for_local_changes() {
local path=`config_get path`
if [ $FORCE -eq 1 ]
then
return
fi
git --no-pager diff --exit-code --quiet || abort "commit or stash your changes before deploying"
git --no-pager diff --exit-code --quiet --cached || abort "commit your staged changes before deploying"
[ -z "`git rev-list @{upstream}.. -n 1`" ] || abort "push your changes before deploying"
}
# parse argv
while test $# -ne 0; do
arg=$1; shift
case $arg in
-h|--help) usage; exit ;;
-V|--version) version; exit ;;
-C|--chdir) log cd $1; cd $1; shift ;;
-F|--force) FORCE=1 ;;
run|exec) run "cd `config_get path`/current && $@"; exit ;;
console) console; exit ;;
curr|current) current_commit; exit ;;
prev|previous) nth_deploy_commit 2; exit ;;
revert) revert_to ${1-1}; exit ;;
setup) setup $@; exit ;;
list) list_deploys; exit ;;
config) config $@; exit ;;
ref) REF=$1; BRANCH=$2 ;;
esac
done
check_for_local_changes
echo
# deploy
deploy "${REF:-`config_get ref`}" "${BRANCH}"

149
api.hyungi.net/node_modules/pm2-deploy/deploy.js generated vendored Normal file
View File

@@ -0,0 +1,149 @@
'use strict';
// eslint-disable-next-line camelcase
var child_process = require('child_process');
var format = require('util').format;
var path = require('path');
var series = require('run-series');
var tv4 = require('tv4');
var schema = {
type: 'object',
properties: {
user: { type: 'string', minLength: 1 },
host: { type: ['string', 'array'] },
repo: { type: 'string' },
path: { type: 'string' },
ref: { type: 'string' },
fetch: { type: 'string' },
},
required: ['host', 'repo', 'path', 'ref'],
};
/**
* Spawn a modified version of visionmedia/deploy
* @private
* @param {object} config config to be piped to deploy
* @param {array} args custom deploy command-line arguments
* @param {DeployCallback} cb done callback
*/
function spawn(config, args, cb) {
var cmd = format('echo \'%j\' | "%s"', config, require.resolve('./deploy'));
args = args || [];
if (args.length > 0) {
var cmdArgs = args.map(function (arg) {
return format('"%s"', arg);
}).join(' ');
cmd = [cmd, cmdArgs].join(' ');
}
var proc = child_process.spawn('sh', ['-c', cmd], { stdio: 'inherit' });
var error;
proc.on('error', function (err) {
error = err;
});
proc.on('close', function (code) {
if (code === 0) return cb(null, args);
error = error || new Error(format('Deploy failed with exit code: %s', code));
error.code = code;
return cb(error);
});
}
function clone(obj) {
return JSON.parse(JSON.stringify(obj));
}
function castArray(arg) {
return Array.isArray(arg) ? arg : [arg];
}
/**
* Deploy to a single environment
* @param {object} deployConfig object containing deploy configs for all environments
* @param {string} env the name of the environment to deploy to
* @param {array} args custom deploy command-line arguments
* @param {DeployCallback} cb done callback
* @returns {boolean} return value is always `false`
*/
function deployForEnv(deployConfig, env, args, cb) {
if (!deployConfig[env]) {
return cb(new Error(format('%s not defined in deploy section', env)));
}
var envConfig = clone(deployConfig[env]);
if (envConfig.ssh_options) {
envConfig.ssh_options = castArray(envConfig.ssh_options).map(function (option) {
return format('-o %s', option);
}).join(' ');
}
var result = tv4.validateResult(envConfig, schema);
if (!result.valid) {
return cb(result.error);
}
if (process.env.NODE_ENV !== 'test') {
console.log('--> Deploying to %s environment', env);
}
if (process.platform !== 'win32') {
envConfig.path = path.resolve(envConfig.path);
}
var hosts = castArray(envConfig.host);
var jobs = hosts.map(function (host) {
return function job(done) {
if (process.env.NODE_ENV !== 'test') {
console.log('--> on host %s', host.host ? host.host : host);
}
var config = clone(envConfig);
config.host = host;
config['post-deploy'] = prependEnv(config['post-deploy'], config.env);
spawn(config, args, done);
};
});
series(jobs, function (err, result) {
result = Array.isArray(envConfig.host) ? result : result[0];
cb(err, result);
});
return false;
}
function envToString(env) {
env = env || {};
return Object.keys(env).map(function (name) {
return format('%s=%s', name.toUpperCase(), env[name]);
}).join(' ');
}
/**
* Prepend command with environment variables
* @private
* @param {string} cmd command
* @param {object} env object containing environment variables
* @returns {string} concatenated shell command
*/
function prependEnv(cmd, env) {
const envVars = envToString(env);
if (!envVars) return cmd;
if (!cmd) return format('export %s', envVars);
return format('export %s && %s', envVars, cmd);
}
module.exports = {
deployForEnv: deployForEnv,
};
/**
* @callback DeployCallback
* @param {Error} error deployment error
* @param {array} args custom command-line arguments provided to deploy
*/

41
api.hyungi.net/node_modules/pm2-deploy/package.json generated vendored Normal file
View File

@@ -0,0 +1,41 @@
{
"name": "pm2-deploy",
"version": "1.0.2",
"description": "Deployment system for PM2",
"main": "deploy.js",
"files": [
"deploy.js",
"deploy"
],
"engines": {
"node": ">=4.0.0"
},
"repository": {
"type": "git",
"url": "https://github.com/Unitech/pm2-deploy.git"
},
"scripts": {
"lint": "eslint \"**/*.js\"",
"test": "mocha",
"docs": "documentation readme ./deploy.js --section=API"
},
"dependencies": {
"run-series": "^1.1.8",
"tv4": "^1.3.0"
},
"devDependencies": {
"better-assert": "^1.0.2",
"documentation": "^11.0.0",
"eslint": "^5.16.0",
"eslint-config-semistandard": "^13.0.0",
"eslint-config-standard": "^12.0.0",
"eslint-plugin-import": "^2.14.0",
"eslint-plugin-node": "^8.0.1",
"eslint-plugin-promise": "^4.0.1",
"eslint-plugin-standard": "^4.0.0",
"mocha": "^5.2.0",
"should": "^13.2.3"
},
"author": "Alexandre Strzelewicz",
"license": "MIT"
}