Skip to content

Commit

Permalink
fix(cli): bug
Browse files Browse the repository at this point in the history
  • Loading branch information
Airkro committed Jul 24, 2024
1 parent 3c7b1a8 commit 947fcb0
Show file tree
Hide file tree
Showing 16 changed files with 499 additions and 108 deletions.
19 changes: 16 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Created by https://gitignore.io/api/node,windows
# Edit at https://gitignore.io?templates=node,windows
# Created by https://gitignore.io/api/ssh,certificates,node,windows
# Edit at https://gitignore.io?templates=ssh,certificates,node,windows

### certificates ###
*.pem
*.key
*.crt
*.cer
*.der
*.priv

### Node ###
# Logs
Expand Down Expand Up @@ -141,6 +149,11 @@ dist
# SvelteKit build / generate output
.svelte-kit

### SSH ###
**/.ssh/id_*
**/.ssh/*_id_*
**/.ssh/known_hosts

### Windows ###
# Windows thumbnail cache files
Thumbs.db
Expand All @@ -167,7 +180,7 @@ $RECYCLE.BIN/
# Windows shortcuts
*.lnk

# End of https://gitignore.io/api/node,windows
# End of https://gitignore.io/api/ssh,certificates,node,windows

.ssh
.bring-it
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2021 Eric Chen
Copyright (c) 2024 Eric Chen

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
21 changes: 14 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,11 @@
"url": "https://github.com/airkro/bring-it/issues"
},
"scripts": {
"build": "best-shot prod",
"lint:staged": "nice-move lint staged",
"prepare": "nice-move git hooks"
"lint:version": "syncpack lint",
"prepare": "nice-move git hooks",
"version:pin": "syncpack fix-mismatches"
},
"workspaces": [
"packages/*"
Expand All @@ -27,25 +30,28 @@
"@nice-move/cli": "^0.11.13",
"@nice-move/eslint-config-base": "^0.11.11",
"@nice-move/prettier-config": "^0.12.4",
"best-shot": "^0.5.13",
"@nice-move/syncpack-config": "^0.2.4",
"@nice-move/tsconfig": "^0.2.4",
"best-shot": "0.5.11",
"eslint": "^8.57.0",
"garou": "^0.7.6",
"prettier": "^3.3.3",
"typescript": "^5.5.4"
"syncpack": "^12.3.3",
"typescript": "~5.5.4"
},
"peerDependencies": {
"@bring-it/npm": "workspace:*",
"@bring-it/utils": "workspace:*"
"@bring-it/npm": "workspace:~",
"@bring-it/utils": "workspace:~"
},
"pnpm": {
"overrides": {
"cpu-features": "npm:[email protected]"
"cpu-features": "npm:cheetor@^0.0.0"
}
},
"packageManager": "[email protected]",
"engines": {
"node": "^18.0.0 || ^20.0.0",
"npm": ">=9.5.0"
"npm": "^9.5.0"
},
"eslintConfig": {
"extends": "@nice-move/eslint-config-base"
Expand All @@ -54,6 +60,7 @@
"bundle": [
"packages/**"
],
"import-groups": "nice-move-preset",
"internal-regex": "^@bring-it\\/utils"
},
"prettier": "@nice-move/prettier-config"
Expand Down
17 changes: 11 additions & 6 deletions packages/cli/lib/action/pack.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@ import { globbySync } from 'globby';

import { ignore } from '@bring-it/utils';

function checkTarget(pattern) {
function checkTarget(pattern, cwd) {
if (pattern.length === 0) {
throw new Error('Error: no pattern input');
}

const list = globbySync(pattern, {
dot: true,
ignore,
cwd,
});

if (list.length > 0) {
Expand All @@ -24,8 +25,8 @@ function checkTarget(pattern) {
throw new Error('Error: no files targeting');
}

export async function action({ pattern, name, dir }) {
const target = checkTarget(pattern);
export async function action({ pattern, name, dir, cwd }) {
const target = checkTarget(pattern, cwd);

const filename = resolve(process.cwd(), dir, name);

Expand All @@ -35,9 +36,13 @@ export async function action({ pattern, name, dir }) {
execFileSync('mkdir', ['-p', dir]);
}

execFileSync('tar', ['-c', '-f', `${filename}.tar`, ...target]);
function exec(command, args) {
execFileSync(command, args, { cwd });
}

exec('tar', ['-c', '-f', `${filename}.tar`, ...target]);

execFileSync('tar', ['-c', '-f', `${filename}.tar.gz`, '-z', ...target]);
exec('tar', ['-c', '-f', `${filename}.tar.gz`, '-z', ...target]);

execFileSync('zip', ['-r', '-FS', '-q', `${filename}.zip`, ...target]);
exec('zip', ['-r', '-FS', '-q', `${filename}.zip`, ...target]);
}
5 changes: 5 additions & 0 deletions packages/cli/lib/cmd/pack.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ export function builder(cli) {
description: 'archive output path name',
default: '.bring-it',
},
cwd: {
alias: 'c',
description: 'current working directory',
default: process.cwd(),
},
});
}

Expand Down
2 changes: 1 addition & 1 deletion packages/cli/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@bring-it/cli",
"version": "0.9.4",
"version": "0.9.5",
"description": "Common command line interface of 'bring-it'",
"license": "MIT",
"author": {
Expand Down
9 changes: 7 additions & 2 deletions packages/notify/lib/utils.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { createRequire } from 'node:module';

import { sync } from 'conventional-commits-parser';
// eslint-disable-next-line import/no-unresolved
import { CommitParser } from 'conventional-commits-parser';
import { clean } from 'fast-clean';
import gitlog from 'gitlog';
import groupBy from 'lodash/groupBy.js';
Expand Down Expand Up @@ -161,6 +162,10 @@ const DEPOT_URL = `${PROJECT_WEB_URL}/d/${DEPOT_NAME}`;

const headerPattern = /^(\w*)(?:\((\S*)\))?:\s?(.*)$/;

const parser = new CommitParser({
headerPattern,
});

async function getCommits() {
const io =
!GIT_PREVIOUS_COMMIT || (GIT_COMMIT && GIT_COMMIT === GIT_PREVIOUS_COMMIT)
Expand All @@ -172,7 +177,7 @@ async function getCommits() {
(await getLogs()).map(({ abbrevHash, hash, subject }) => ({
hash,
abbrevHash,
message: sync(subject, { headerPattern }),
message: parser.parse(subject),
subject,
url: `${DEPOT_URL}/git/commit/${hash}`,
})),
Expand Down
8 changes: 4 additions & 4 deletions packages/notify/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@bring-it/notify",
"version": "0.3.8",
"version": "0.3.9",
"description": "Send releases notifications",
"license": "MIT",
"author": {
Expand Down Expand Up @@ -40,19 +40,19 @@
"prepublishOnly": "pnpm run build"
},
"devDependencies": {
"conventional-commits-parser": "^5.0.0",
"conventional-commits-parser": "^6.0.0",
"fast-clean": "^1.3.2",
"gitlog": "^5.0.2",
"lodash": "^4.17.21",
"mdast-util-to-markdown": "^2.1.0",
"semver": "^7.6.3"
},
"peerDependencies": {
"@bring-it/cli": "workspace:^"
"@bring-it/cli": "workspace:~"
},
"engines": {
"node": "^18.0.0 || ^20.0.0",
"npm": ">=9.0.0"
"npm": "^9.5.0"
},
"publishConfig": {
"access": "public",
Expand Down
6 changes: 3 additions & 3 deletions packages/npm/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@bring-it/npm",
"version": "0.5.6",
"version": "0.5.7",
"description": "Publish npm packages when needed",
"license": "MIT",
"author": {
Expand Down Expand Up @@ -48,11 +48,11 @@
"validate-npm-package-name": "^5.0.1"
},
"peerDependencies": {
"@bring-it/cli": "workspace:^"
"@bring-it/cli": "workspace:~"
},
"engines": {
"node": "^18.0.0 || ^20.0.0",
"npm": ">=9.0.0"
"npm": "^9.5.0"
},
"publishConfig": {
"access": "public",
Expand Down
4 changes: 2 additions & 2 deletions packages/sample/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@bring-it/sample",
"version": "0.4.5",
"version": "0.4.6",
"description": "Generate code sample files",
"license": "MIT",
"author": {
Expand Down Expand Up @@ -42,7 +42,7 @@
"globby": "^14.0.2"
},
"peerDependencies": {
"@bring-it/cli": "workspace:^"
"@bring-it/cli": "workspace:~"
},
"engines": {
"node": "^18.0.0 || ^20.0.0"
Expand Down
4 changes: 2 additions & 2 deletions packages/sentry/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@bring-it/sentry",
"version": "0.5.4",
"version": "0.5.5",
"description": "Update sentry artifacts",
"license": "MIT",
"author": {
Expand Down Expand Up @@ -45,7 +45,7 @@
"@npmcli/promise-spawn": "^7.0.2"
},
"peerDependencies": {
"@bring-it/cli": "workspace:^"
"@bring-it/cli": "workspace:~"
},
"engines": {
"node": "^18.0.0 || ^20.0.0"
Expand Down
4 changes: 2 additions & 2 deletions packages/sftp/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@bring-it/sftp",
"version": "0.3.4",
"version": "0.3.5",
"description": "SFTP deployment tool for frontend",
"license": "MIT",
"author": {
Expand Down Expand Up @@ -53,7 +53,7 @@
"ssh-config": "^4.4.4"
},
"peerDependencies": {
"@bring-it/cli": "workspace:^"
"@bring-it/cli": "workspace:~"
},
"engines": {
"node": "^18.0.0 || ^20.0.0"
Expand Down
2 changes: 1 addition & 1 deletion packages/utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"chalk": "^5.3.0"
},
"peerDependencies": {
"@bring-it/cli": "workspace:^"
"@bring-it/cli": "workspace:~"
},
"engines": {
"node": "^18.0.0 || ^20.0.0"
Expand Down
Loading

0 comments on commit 947fcb0

Please sign in to comment.