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

Feat/#210 auto install deps when creating a new ts srcbook #210 #342

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

Aswanth-c
Copy link
Contributor

@Aswanth-c Aswanth-c commented Oct 9, 2024

Fixed Issue #210

Changes

  • Added a toggle button for auto-installing dependencies.
  • Added AutoInstallation field in database
  • Ran database migrations.
  • Added a conditional check and automatic installation of tsx, typescript, and @types/node upon TypeScript Srcbook creation.

Question:

Currently, the packages are installed automatically only upon the creation of a Srcbook. I was not sure if it was a design choice to require the user to press the install button for npm packages, so I have left it as is. if needed. I can change it to automatically install when the user presses Run

"idx": 11,
"version": "6",
"when": 1728457840317,
"tag": "0011_apps_external_id_unique",
Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm I wonder if this is a rebase issue, but I expect only one entry in the journal for this PR. Maybe we need to rebase and rerun the migration?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

On the main branch, the journal entry and snapshot for the 11th migration 0011_apps_external_id_unique.sql are missing while the migration is present.

}
setInitialInstallAttempt(true);
};
setTimeout(() => handleAutoInstallation(), 1500);
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is there a timeout set here?

@BeRecursive22
Copy link
Contributor

BeRecursive22 commented Oct 14, 2024

@nichochar @Aswanth-c

I have observed that if you add cell:format after creating cell:create, the deps are automatically installed. I was wondering why we didn't go with option?

image

There might be some edge cases...I haven't considered.

@nichochar
Copy link
Contributor

Actually, that's the kind of option I was assuming.

Trigger cell:create, and then on callback once things are created, call a deps:install event (we shouldn't use cell:format for this as it's semantically a bit weird)

useEffect(() => {
const handleAutoInstallation = () => {
if (autoInstallDependencies) {
npmInstall();
Copy link
Contributor

Choose a reason for hiding this comment

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

As @BeRecursive22 commented, we have an event we can send up called deps:install rather than re-implement the logic here.

This works but for consistency of how we interface with the server, it might be better to dispatch the websocket event. cc @benjreinhart might have an opinion.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I agree that it's a better option to install packages once the code cell is created rather than when the component mounts; I will change that.

npmInstall();. function executes deps:install under the hood,
isn't it better to call npmInstall(); function? as it does more checks and error handling

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.

Auto-install deps when creating a new TS Srcbook
3 participants