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

fix: create new project with clean git repo #68

Merged
merged 1 commit into from
Jan 19, 2021

Conversation

ruslanguns
Copy link
Contributor

This will close #55

@ruslanguns
Copy link
Contributor Author

ruslanguns commented Jan 19, 2021

@beeman you will notice I have added --no-verify flag, I added for those that don't have the main as it's default branch, however having a different branch instead of main you'll get errors running the scripts affected and format ones. So user has to manually fix them by editing the nx.json and package.json file.

Some ideas of how to perform it automatically:

  1. Get the default branch name:

git symbolic-ref --short HEAD

This will prompt the default branch configured in the repo.

  1. Edit the nx.json file with the output

npx json -I -f nx.json -e "this.affected.defaultBase = '<default-branchj>' "

  1. Edit package.json

npx json -I -f package.json -e "this.scripts.format = 'nx format:write --base=remotes/origin/<default-branchj> --head=HEAD' "

npx json -I -f package.json -e "this.scripts.format = 'nx format:write --base=remotes/origin/<default-branchj> --head=HEAD' "

npx json -I -f package.json -e "this.scripts.format = 'nx format:check --base=remotes/origin/<default-branchj> --head=HEAD' "

And that will be enough to fix the affected hunky hook process.

What do you think? what do you recommend?

I created a new issuie #69 in order to follow this up

@nx-cloud
Copy link

nx-cloud bot commented Jan 19, 2021

Nx Cloud Report

CI ran the following commands for commit de59e70. Click to see the status, the terminal output, and the build insights.

Status Command Start Time
#000000 nx build-base cli 1/19/2021, 6:13:50 PM
#000000 nx run-many --target build --all 1/19/2021, 6:13:48 PM
#000000 nx run-many --target e2e --all 1/19/2021, 6:14:02 PM
#000000 nx run-many --target test --all 1/19/2021, 6:13:56 PM

Sent with 💌 from NxCloud.

@ruslanguns ruslanguns force-pushed the ruslan/clean-git-repo branch from c60036d to de59e70 Compare January 19, 2021 18:12
@beeman beeman merged commit 3db6022 into nxpm:main Jan 19, 2021
@beeman
Copy link
Member

beeman commented Jan 19, 2021

Thanks a lot @ruslanguns 👍

@@ -56,6 +56,10 @@ export async function workspaceInit({
const initProject = `yarn nx g @nxpm/stack:init web --web-style-library ${webStyleLibrary}`
runCommand(initProject, target)

log('Rewriting git history')
const rewritingGitHistory = `git commit --amend -CHEAD --no-verify`
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

--no-verify added for avoiding the error of base branch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Creating a new project should leave the user with a clean git repo.
2 participants