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 initiating a project within the current directory #212

Merged
merged 1 commit into from
Dec 12, 2021

Conversation

seanyusa
Copy link
Contributor

This PR is intended to address #203. Reading through the code, it seems like this functionality was intended to be supported and seemed like a simple fix so I thought I'd give it a go!

Before:

The installation would successfully create all template project files but fail on

process.chdir(relativeProjectDir);

Thus not completing the git init step and failing to print out success instructions.

Output

>>> TURBOREPO

>>> Welcome to Turborepo! Let's get you set up with a new codebase.

? Where would you like to create your turborepo? .
? Which package manager do you want to use? Yarn
? Do you want me to run `yarn install`? Yes

>>> Bootstrapping a new turborepo with the following:

 - apps/web: Next.js with TypeScript
 - apps/docs: Next.js with TypeScript
 - packages/ui: Shared React component library
 - packages/config: Shared configuration (ESLint)
 - packages/tsconfig: Shared TypeScript `tsconfig.json`


Aborting installation.
Unexpected error. Please report it as a bug:
Error: ENOENT: no such file or directory, chdir '/Users/sean/development/test-dir' -> ''
    at process.wrappedChdir (internal/bootstrap/switches/does_own_process_state.js:116:14)
    at process.chdir (/Users/sean/development/turborepo/node_modules/graceful-fs/polyfills.js:22:11)
    at run (/Users/sean/development/turborepo/create-turbo/dist/index.js:277:11)
    at processTicksAndRejections (internal/process/task_queues.js:95:5) {
  errno: -2,
  code: 'ENOENT',
  syscall: 'chdir',
  path: '/Users/sean/development/test-dir',
  dest: ''
}

% ls -al
total 288
Dec 12 12:20 .
Dec 12 12:14 ..
Dec 12 12:20 .gitignore
Dec 12 12:20 README.md
Dec 12 12:20 apps
Dec 12 12:20 node_modules
Dec 12 12:20 package.json
Dec 12 12:20 packages
Dec 12 12:20 yarn.lock

After:

Changes dir correctly for current directory by directly using projectDir. in preparation for the tryGitInit call.

Output

>>> TURBOREPO

>>> Welcome to Turborepo! Let's get you set up with a new codebase.

? Where would you like to create your turborepo? .
? Which package manager do you want to use? Yarn
? Do you want me to run `yarn install`? Yes

>>> Bootstrapping a new turborepo with the following:

 - apps/web: Next.js with TypeScript
 - apps/docs: Next.js with TypeScript
 - packages/ui: Shared React component library
 - packages/config: Shared configuration (ESLint)
 - packages/tsconfig: Shared TypeScript `tsconfig.json`

>>> Success! Check the README for development and deploy instructions!

% ls -al
total 288
Dec 12 12:32 .
Dec 12 12:31 ..
Dec 12 12:32 .git
Dec 12 12:32 .gitignore
Dec 12 12:32 README.md
Dec 12 12:32 apps
Dec 12 12:32 node_modules
Dec 12 12:32 package.json
Dec 12 12:32 packages
Dec 12 12:32 yarn.lock

Testing

Can manually test by running create-turbo using . as the project directory.

I wasn't able to run the jest tests as is (Jest encountered an unexpected token), didn't have too much time to see what was required to make things work. Should the tests be working right now?

Further Improvements

  • Adding a test for current directory support at some point would be nice.
  • Seems like the message for creating a project within a current directory simply says the following at the moment: (Success! Check the README for development and deploy instructions!) Can improve this output to produce similar instructions to those that are shown when not using the current directory. (Your new Turborepo is ready. To build all apps and packages, run the following...)

@vercel
Copy link

vercel bot commented Dec 12, 2021

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/vercel/turbo-site/8iPFW1KMuUYfbiS58GBWhFThxnny
✅ Preview: https://turbo-site-git-fork-seanyusa-seanyusa-current-dir-fix.vercel.sh

@jaredpalmer jaredpalmer merged commit 62ca631 into vercel:main Dec 12, 2021
@seanyusa seanyusa deleted the seanyusa/current-dir-fix branch December 12, 2021 19:09
sokra pushed a commit that referenced this pull request Oct 25, 2022
This implements `try_join_all` with `join_all`, making it respect the order of futures provided, as well as deterministically return the first error that occurred not by time, but by the future order.

This was preventing #212 from inserting script tags in a consistent order.

Test Plan: `cargo test`
sokra pushed a commit that referenced this pull request Oct 25, 2022
This commits webpack's chunk tests (test/cases/chunks) and skips those
that do not pass yet.

Test Plan: `cargo test -p next-dev -- --nocapture` and verify the
non-skipped tests run.
jridgewell pushed a commit to vercel/next.js that referenced this pull request Mar 10, 2023
…rcel/turborepo#212)

This commits webpack's chunk tests (test/cases/chunks) and skips those
that do not pass yet.

Test Plan: `cargo test -p next-dev -- --nocapture` and verify the
non-skipped tests run.
sokra pushed a commit to vercel/next.js that referenced this pull request Mar 13, 2023
…rcel/turborepo#212)

This commits webpack's chunk tests (test/cases/chunks) and skips those
that do not pass yet.

Test Plan: `cargo test -p next-dev -- --nocapture` and verify the
non-skipped tests run.
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.

2 participants