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(create-waku): install dependencies automatically when creating a new waku #728

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

Conversation

Rec0iL99
Copy link
Contributor

@Rec0iL99 Rec0iL99 commented May 28, 2024

Workflow:

> pnpm start                                                                                                                        

> create-waku@0.9.2-alpha.0 start /Users/joelmathew/WebProjects/waku-dev/waku/packages/create-waku
> node ./dist/index.js

✔ Project Name … waku-project
Setting up project...

Installing dependencies by running pnpm install...
Scope: all 32 workspace projects
Done in 1.6s

Done. Now run:

cd waku-project
pnpm dev

Copy link

vercel bot commented May 28, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Ignored Deployment
Name Status Preview Updated (UTC)
waku ⬜️ Ignored (Inspect) Visit Preview Jun 26, 2024 3:13pm

Copy link

codesandbox-ci bot commented May 28, 2024

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Copy link
Owner

@dai-shi dai-shi left a comment

Choose a reason for hiding this comment

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

Hi, thanks for working on it! Please see comments.

cc @ojj1123 would you like to give a review?

packages/create-waku/package.json Outdated Show resolved Hide resolved
packages/create-waku/src/index.ts Outdated Show resolved Hide resolved
packages/create-waku/src/index.ts Outdated Show resolved Hide resolved
Copy link
Contributor

@ojj1123 ojj1123 left a comment

Choose a reason for hiding this comment

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

Good works! I review for something.

packages/create-waku/src/index.ts Outdated Show resolved Hide resolved
packages/create-waku/src/index.ts Outdated Show resolved Hide resolved
@dai-shi
Copy link
Owner

dai-shi commented Jun 20, 2024

@Rec0iL99 Are you still around?

@Rec0iL99
Copy link
Contributor Author

@Rec0iL99 Are you still around?

@dai-shi sorry to keep this open for a while now. I had intended to finish this last weekend but got caught up with some work. I'll finish this by the weekend.

packages/create-waku/src/index.ts Outdated Show resolved Hide resolved
packages/create-waku/src/index.ts Outdated Show resolved Hide resolved

process.chdir(targetDir);

const installProcess = spawn(packageManager, ['install']);
Copy link
Sponsor Contributor

Choose a reason for hiding this comment

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

Suggested change
const installProcess = spawn(packageManager, ['install']);
const installProcess = spawn(packageManager, ['install'], { encoding: 'utf8' });

Copy link
Contributor Author

@Rec0iL99 Rec0iL99 Jun 26, 2024

Choose a reason for hiding this comment

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

Hi @himself65, encoding is not a property that exists on the options object for spawn.

Copy link
Sponsor Contributor

Choose a reason for hiding this comment

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

first to know this

Copy link
Sponsor Contributor

Choose a reason for hiding this comment

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

Oh, I think if you just wanna bypass the output, use stdio: 'inherit'


installProcess.stdout.setEncoding('utf8');
installProcess.stdout.on('data', (data) => {
console.log(data);
Copy link
Owner

Choose a reason for hiding this comment

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

#728 (comment)

Does it show the indicator as expected? cc @ojj1123

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes. I could see the indicator as expected!

Copy link
Owner

Choose a reason for hiding this comment

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

#728 (comment) I wonder if stdio: inherit works.

Copy link
Contributor

@ojj1123 ojj1123 Jul 1, 2024

Choose a reason for hiding this comment

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

The docs is explaining a difference between stdio: "inherit" and stdio: "pipe" but it's a bit confusing for me.
I've tried to use stdio: "inherit", it could also show the loading indicator.

stdio: "pipe"(default)

  • child stdios(stdin, stdout, stderr) and parent ones are mapped(piping) each other. But if we want to access the data, we have to use the events like this:
childProcess.stdout.on("data", (data) => {
  console.log(data)
})

stdio: "inherit"

  • parent's stdios are handed off to the child process. That is, child process could use parent's stdios. So we don't need to use the events.

I think no matter we use stdio: "pipe" or stdio: "inherit". But if we use "inherit", we don't need to use the events:

diff --git a/packages/create-waku/src/index.ts b/packages/create-waku/src/index.ts
index 1eb01d3..98ede50 100644
--- a/packages/create-waku/src/index.ts
+++ b/packages/create-waku/src/index.ts
@@ -210,16 +210,8 @@ async function init() {

   process.chdir(targetDir);

-  const installProcess = spawn(packageManager, ['install']);
-
-  installProcess.stdout.setEncoding('utf8');
-  installProcess.stdout.on('data', (data) => {
-    console.log(data);
-  });
-
-  installProcess.stderr.setEncoding('utf8');
-  installProcess.stderr.on('data', (data) => {
-    console.log(data);
+  const installProcess = spawn(packageManager, ['install'], {
+    stdio: 'inherit',
   });

   installProcess.on('close', (code) => {

Copy link
Contributor

@ojj1123 ojj1123 Jul 1, 2024

Choose a reason for hiding this comment

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

+) If we use stdio: "inherit"(or anything other than "pipe"), childProcess's stdin, stdout and stderr could be null:

const installProcess = spawn(packageManager, ['install'], {
  stdio: 'inherit',
});

installProcess.stdout // it could be null so we need to null-check
installProcess.stdout.on("data", callbackFn)

스크린샷 2024-07-01 19 23 18


process.chdir(targetDir);

const installProcess = spawn(packageManager, ['install']);
Copy link
Sponsor Contributor

Choose a reason for hiding this comment

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

Oh, I think if you just wanna bypass the output, use stdio: 'inherit'

@dai-shi
Copy link
Owner

dai-shi commented Jul 23, 2024

@Rec0iL99 Are you still around?

@ojj1123
Copy link
Contributor

ojj1123 commented Jul 25, 2024

If @Rec0iL99 is busy and there is no response, it's okay for me to get this work.

@dai-shi
Copy link
Owner

dai-shi commented Jul 25, 2024

@ojj1123 Yeah, please go ahead.

@ojj1123

This comment was marked as outdated.

@ojj1123
Copy link
Contributor

ojj1123 commented Jul 28, 2024

Yes. I could see the indicator as expected!
#728 (comment)

Oh it does NOT show the loading indicator on installing. I got mistakes. 😅
We should use stdio: "inherit"!

I couldn't push my commit to this PR, so I made a new PR 👉 #808

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.

4 participants