Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use git commit instead of yarn commit and simplify things #1243

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

yarn lint:commit
4 changes: 4 additions & 0 deletions .husky/prepare-commit-msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

exec < /dev/tty && npx cz --hook || true
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,29 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/

import { commit } from '../utils/git.js'

export default {
command: 'commit',
desc: 'commit staged changes in git running Husky pre-commit hooks and git-cz',
handler: (_argv) => {
// eslint-disable-next-line no-unused-expressions
commit().status
module.exports = {
extends: ['@commitlint/config-conventional'],
parserOpts: {
headerPattern: /^(\w*)\((\w*)\)-(\w*)\s(.*)$/,
headerCorrespondence: ['type', 'scope', 'subject']
},
rules: {
'type-enum': [
2,
'always',
[
'WIP',
'feat',
'fix',
'docs',
'chore',
'style',
'refactor',
'test',
'perf',
'revert'
]
],
'type-case': [0]
}
}
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,12 @@
"lint": "lerna run lint --stream",
"lint:changes": "yarn lint --since HEAD^",
"lint:fix": "lerna run lint:fix --stream",
"lint:commit": "ui-scripts lint-commit",
"lint:commit": "commitlint --edit",
"lint:staged": "lint-staged",
"update:package:list": "lerna run generate:package:list --stream --scope @instructure/instui-config",
"commit:package:list": "git add packages/instui-config/package-lists/**/package-list.json",
"generate:component": "yarn workspace @instructure/instui-cli instui create component",
"generate:package": "yarn workspace @instructure/instui-cli instui create package",
"commit": "ui-scripts commit",
"bootstrap": "time yarn node scripts/bootstrap.js",
"build": "lerna run build --stream",
"build:watch": "lerna run build:watch --stream",
Expand Down Expand Up @@ -66,6 +65,8 @@
},
"devDependencies": {
"@babel/cli": "^7.22.9",
"@commitlint/cli": "^17.6.7",
"@commitlint/config-conventional": "^17.6.7",
"@instructure/ui-scripts": "workspace:*",
"@instructure/ui-token-scripts": "workspace:*",
"@types/react-dom": "^18.2.7",
Expand Down
10 changes: 0 additions & 10 deletions packages/ui-scripts/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,16 +64,6 @@ To fix lint issues:

`yarn ui-scripts lint --fix`

To lint a commit message (the `HEAD` commit):

`yarn ui-scripts lint-commit`

#### `commit`

To write a correctly formatted commit message and commit the staged changes:

`yarn ui-scripts commit`

#### `install-react`

To install a specific version of React and ReactDOM without updating `package.json`
Expand Down
4 changes: 0 additions & 4 deletions packages/ui-scripts/lib/commands/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@
*/

import bump from './bump.js'
import commit from './commit.js'
import lintCommit from './lint-commit.js'
import server from './server.js'
import tag from './tag.js'
import deprecate from './deprecate.js'
Expand All @@ -38,8 +36,6 @@ import build from '../build/babel.js'

export const yargCommands = [
bump,
commit,
lintCommit,
server,
tag,
deprecate,
Expand Down
41 changes: 0 additions & 41 deletions packages/ui-scripts/lib/commands/lint-commit.js

This file was deleted.

2 changes: 0 additions & 2 deletions packages/ui-scripts/lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@ readEnv()

const commands = [
'bump',
'commit',
'lint-commit',
'server',
'tag',
'help',
Expand Down
24 changes: 0 additions & 24 deletions packages/ui-scripts/lib/utils/git.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@
*/
import { runCommandSync, error, info, warn } from '@instructure/command-utils'

import validateMessage from 'validate-commit-msg'

const USERNAME = 'instructure-ui-ci'
const EMAIL = '[email protected]'

Expand Down Expand Up @@ -101,28 +99,6 @@ export function checkIfGitTagExists(version) {
}
}

export function commit() {
setupGit()
try {
runGitCommand(['commit', '--dry-run'])
} catch (err) {
error(err)
process.exit(1)
}
try {
runCommandSync('yarn', ['husky:pre-commit'])
} catch (err) {
error(err)
process.exit(1)
}
return runCommandSync('git-cz')
}

export function lintCommitMessage() {
const commitMessage = runGitCommand(['log', '-1', '--pretty=%B'])
return validateMessage(commitMessage)
}

export function createGitTagForRelease(version) {
const tag = `v${version}`
const { GIT_REMOTE_NAME } = process.env
Expand Down
3 changes: 0 additions & 3 deletions packages/ui-scripts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,8 @@
"dependencies": {
"@babel/cli": "^7.22.9",
"@instructure/command-utils": "8.39.0",
"@instructure/cz-lerna-changelog": "8.39.0",
"@instructure/pkg-utils": "8.39.0",
"@lerna/project": "^6.4.1",
"commitizen": "^4.3.0",
"dotenv": "^16.3.1",
"find-up": "^6.3.0",
"http-server": "^14.1.1",
Expand All @@ -35,7 +33,6 @@
"prettier": "^2.8.8",
"semver": "^7.5.4",
"stylelint": "^15.10.1",
"validate-commit-msg": "^2.14.0",
"webpack-cli": "^5.1.4",
"webpack-dev-server": "^4.15.1",
"yargs": "^17.7.2"
Expand Down
3 changes: 0 additions & 3 deletions packages/ui-scripts/tsconfig.build.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@
{
"path": "../command-utils/tsconfig.build.json"
},
{
"path": "../cz-lerna-changelog/tsconfig.build.json"
},
{
"path": "../pkg-utils/tsconfig.build.json"
}
Expand Down
Loading
Loading