branch-deploy
Advanced tools
Comparing version 0.0.1 to 0.0.2
53
index.js
@@ -0,6 +1,53 @@ | ||
import chalk from 'chalk' | ||
import inquirer from 'inquirer' | ||
import { exit } from 'process' | ||
import simpleGit from 'simple-git' | ||
console.log('Hello there') | ||
console.log('This is a placeholder package. Real code comming.') | ||
// @TODO: configurable | ||
exit(1) | ||
const remoteName = 'origin' | ||
const branchNamePrefix = 'deploy' | ||
const git = simpleGit() | ||
// @TODO: check current working directory is git repository | ||
const remoteBranches = (await git.branch(['-r'])).all.map((branch) => | ||
branch.startsWith(`${remoteName}/`) | ||
? branch.substring(remoteName.length + 1) | ||
: branch, | ||
) | ||
const deployBranches = remoteBranches.filter( | ||
(branch) => | ||
branch === branchNamePrefix || branch.startsWith(`${branchNamePrefix}/`), | ||
) | ||
if (deployBranches.length === 0) { | ||
console.error( | ||
chalk.red( | ||
`Not a single deploy branch found in "${remoteName}" starting with ${branchNamePrefix}.`, | ||
), | ||
) | ||
exit(1) | ||
} | ||
const { targetBranches } = await inquirer.prompt({ | ||
type: 'checkbox', | ||
name: 'targetBranches', | ||
message: `Which branch do you want ${chalk.magenta('HEAD')} to push to?`, | ||
choices: deployBranches, | ||
}) | ||
if (targetBranches.length === 0) { | ||
console.log(chalk.yellow('No branch selected.')) | ||
exit(0) | ||
} | ||
for (const targetBranch of targetBranches) { | ||
console.log( | ||
`Pushing ${chalk.magenta('HEAD')} to ${chalk.magenta(targetBranch)}…`, | ||
) | ||
await git.push(remoteName, `HEAD:${targetBranch}`) | ||
} | ||
console.log(chalk.green('Done. 🎉')) |
{ | ||
"name": "branch-deploy", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"description": "Deploy by pushing a deploy* branch made simplier.", | ||
@@ -33,4 +33,5 @@ "main": "index.js", | ||
"chalk": "^5.2.0", | ||
"inquirer": "^9.1.4" | ||
"inquirer": "^9.1.4", | ||
"simple-git": "^3.16.1" | ||
} | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Trivial Package
Supply chain riskPackages less than 10 lines of code are easily copied into your own project and may not warrant the additional supply chain risk of an external dependency.
Found 1 instance in 1 package
2352
45
0
3
+ Addedsimple-git@^3.16.1
+ Added@kwsites/file-exists@1.1.1(transitive)
+ Added@kwsites/promise-deferred@1.1.1(transitive)
+ Addeddebug@4.4.0(transitive)
+ Addedms@2.1.3(transitive)
+ Addedsimple-git@3.27.0(transitive)