-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
feat(core): introduce nx import #26847
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎ 1 Skipped Deployment
|
☁️ Nx Cloud ReportCI is running/has finished running commands for commit 847e8be. As they complete they will appear below. Click to see the status, the terminal output, and the build insights. 📂 See all runs for this CI Pipeline Execution ✅ Successfully ran 4 targets
Sent with 💌 from NxCloud. |
6fef53f
to
ebf8ad0
Compare
6bc28c3
to
5c3528b
Compare
🐳 We have a release for that!This PR has a release associated with it. You can try it out using this command: npx [email protected] my-workspace Or just copy this version and use it in your own command: 0.0.0-pr-26847-80c36f5
To request a new release for this pull request, mention someone from the Nx team or the |
615f0e3
to
6e5743d
Compare
d8d201f
to
c317fec
Compare
fb3d93f
to
a2b1a9c
Compare
type: 'input', | ||
name: 'sourceRemoteUrl', | ||
message: | ||
'What is the Remote URL of the repository you want to import?', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can rephrase this to also include local directories.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should test and verify the path passed if it's local
} | ||
|
||
if (!source) { | ||
source = ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Validate this exists.
Q: Can we validate the project? Maybe after import we can verify and log out some hints if things didn't work.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Validated
`Fetching ${ref} from ${sourceRemoteUrl}` | ||
); | ||
await gitClient.addFetchRemote('origin', ref); | ||
await gitClient.fetch('origin', { depth: 1, ref }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Check if all the history if depth: 1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup, that messed it up. I made it the full history...
If it's a local path... it kind of adopts the history depth of the local path... so if people have a shallow clone, then they might be missing some commits 🤔
But if it's a remote path, we get the full history, however long it is
const newPath = join(destinationInSource, file); | ||
|
||
await mkdirAsync(dirname(newPath), { recursive: true }); | ||
try { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we're moving to a gitignored directory, what will happen? (Looks like it just works!)
e2e/nx/src/import.test.ts
Outdated
afterAll(() => cleanupProject()); | ||
|
||
it('should be able to import a vite app', () => { | ||
const remote = 'https://github.com/nrwl/nx.git'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe use a local remote so it's not necessary to have a reference on remote?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
38ae368
to
6c75bf6
Compare
} catch {} | ||
await mkdir(tempImportDirectory, { recursive: true }); | ||
|
||
const sourceGitClient = await cloneFromUpstream( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this fails, we may want to ask user to check their URL / directory path. If there is a typo, or what they are importing isn't a git repo.
6c75bf6
to
cca66f9
Compare
cca66f9
to
847e8be
Compare
} | ||
); | ||
|
||
checkFilesExist( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we make some assertion about the git history of the project files? I trust that it is working, but just to keep it that way.
execSync(`git commit -am "initial commit"`, { | ||
cwd: tempViteProjectPath, | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we create an extra commit or two? Just want to be safe :)
This pull request has already been merged/closed. If you experience issues related to these changes, please open a new issue referencing this pull request. |
Current Behavior
Importing other projects/ repositories into an Nx workspace is a natural part of the Nx adoption story. However, there is no easy built in way of handling this while maintaining
git
history.Expected Behavior
nx import
is a new command which allows teams to merge code from other repositories into a Nx workspace.https://asciinema.org/a/oQiA9qOvA2z85AQvVJ5QRVTp1
Related Issue(s)
Fixes #