Skip to content

[WIP] init endpoint of ui-server#685

Closed
LakshSingla wants to merge 4 commits into
webpack:webpack-cli-uifrom
LakshSingla:webpack-cli-ui
Closed

[WIP] init endpoint of ui-server#685
LakshSingla wants to merge 4 commits into
webpack:webpack-cli-uifrom
LakshSingla:webpack-cli-ui

Conversation

@LakshSingla

Copy link
Copy Markdown

What kind of change does this PR introduce?
Feature

Did you add tests for your changes?
No

If relevant, did you update the documentation?
No

Summary
Created the route for POST: init for default scaffold. Does not work as expected due to issues in stdin of the child process spawned.

#649

Does this PR introduce a breaking change?
No

Other information
None

@jsf-clabot

jsf-clabot commented Nov 6, 2018

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@rishabh3112 rishabh3112 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

May that helps !!

Comment thread packages/ui-server/app.js Outdated
const cookieParser = require("cookie-parser");
const logger = require("morgan");
const indexRouter = require("./routes/index");
const apiRouter = require("./routes/api");

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Redundant import

Suggested change
const apiRouter = require("./routes/api");

Comment thread packages/ui-server/routes/index.js Outdated
res.json({ title: "Express" });
});

router.use(require('./api'));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

use /api as the base route for the server calls.
We would be using /api/init for json calls to render /init and same for other endpoints.

Suggested change
router.use(require('./api'));
router.use('/api',require('./api'));

@rishabh3112

Copy link
Copy Markdown
Contributor

Sign CLA too

@webpack-bot

Copy link
Copy Markdown

@LakshSingla Thanks for your update.

I labeled the Pull Request so reviewers will review it again.

@rishabh3112 Please review the new changes.

@LakshSingla

Copy link
Copy Markdown
Author

@rishabh3112 Thanks for the suggestions. I have made the required changes. But I am still stuck on how to call the actual init process. I have used execa to create a child process and passed in the options to its stdin (which I receive in the request). But I am facing an issue because of the way I am passing the stdin due to which all output is dumped into the child process at once and it cannot read it for subsequent queries.
webpack-init-1

@rishabh3112

Copy link
Copy Markdown
Contributor

I think we should refactor and change interface of webpack-scaffold all together so as to avoid running child process. A configuration generating file which will take answers to questions as json input and generates file.

This way debugging in future would be better.Let have others viewpoint.
cc @evenstensberg @ematipico

@LakshSingla

Copy link
Copy Markdown
Author

@rishabh3112 I was thinking the same thing, to provide an alternative way of programmatically passing in the parameters for init.

@LakshSingla

Copy link
Copy Markdown
Author

@rishabh3112 Should I start with the refactoring? Also what all needs to be refactored? I would begin with the webpack init command located at @webpack-cli/init.

@ematipico

Copy link
Copy Markdown
Contributor

Yes, inquirier logic and generator logic have to be separated in order to achieve this PR.

The server will just pass an object to the generator, which will create the webpack file for us. The object will contain the same set of answers.

Because of the fact that we are using typescript, I think there could be an interface that design the object answers that we can pass to the generator. If there isn't, we should create it.

I think to make things easier, using typescript for the server might be a better fit because of the typings...

@LakshSingla

LakshSingla commented Nov 8, 2018

Copy link
Copy Markdown
Author

@ematipico Should I open a seperate issue regarding this issue? Also, I suppose that the generator logic to be moved and inquirer logic stay in place at @webpack-cli/packages/generators/index-generator.ts.

@rishabh3112

rishabh3112 commented Nov 8, 2018

Copy link
Copy Markdown
Contributor

I think better would be that every generator exports:

  1. class cli: would be default class
  2. class ui: would be processing Object.

and also a function that would return a multi-dimensional array having questions.

Then for passing Object we can:

import { ui } from "@webpack-cli/init"
...
let input: Object; // or we may have a interface here instead of object
// taking input from server
ui(input);
...

Review approch @ematipico I would do necessary updations then. Also, @evenstensberg didn't gave review for design as he said to me he will be. If you have suggestions you may let me know. After that I would design other pages as well.

@LakshSingla

Copy link
Copy Markdown
Author

@rishabh3112 Thanks for help with the PR! As soon as you are done with the necessary refactoring, lemme know so that I can make the required changes.

@LakshSingla

Copy link
Copy Markdown
Author

@rishabh3112 Any updates in refactoring ??

@rishabh3112

rishabh3112 commented Nov 17, 2018

Copy link
Copy Markdown
Contributor

I am having my end semester exams till the end of this month.
So will do it after my exams!

@evenstensberg

Copy link
Copy Markdown
Member

No worries

Comment thread packages/ui-server/bin/www/index.js Outdated

const port = process.env.PORT || 8000;

console.log(port);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

remove log here

Comment thread packages/ui-server/bin/www/index.js Outdated

console.log(port);

app(path.join('..', '..', 'static')).listen(port, () => {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

extract to var

Comment thread packages/ui-server/bin/www/index.js Outdated
console.log(port);

app(path.join('..', '..', 'static')).listen(port, () => {
console.log(`server started on 127.0.0.1:${port}`);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

use webpack logger

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Made the necessary changes

@ematipico

Copy link
Copy Markdown
Contributor

@LakshSingla I guess it would be better to open a separate issue

@rishabh3112

Copy link
Copy Markdown
Contributor

#700

@fokusferit

Copy link
Copy Markdown
Contributor

hey @rishabh3112 any update on this PR ?

@fokusferit

Copy link
Copy Markdown
Contributor

Just to understand this correctly, this one can be close as @rishabh3112 continue the work at #756 right?

@evenstensberg

Copy link
Copy Markdown
Member

Could you rebase this?

@evenstensberg

Copy link
Copy Markdown
Member

As per meetings, we're decided that UI should be third party

@evenstensberg

Copy link
Copy Markdown
Member

Thank you so much for taking the time to create this Pull Request, you've helped shape the way we're going with webpack(cli) ❤️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants