Skip to content

feat: typescript entrypoint - #5305

Closed
TomChv wants to merge 25 commits into
dagger:mainfrom
TomChv:feat/ts-entrypoint
Closed

TomChv wants to merge 25 commits into
dagger:mainfrom
TomChv:feat/ts-entrypoint

Conversation

@TomChv

@TomChv TomChv commented Jun 12, 2023

Copy link
Copy Markdown
Member

Handle dagger do with string arguments.
Split code into multiples files and function.
Add local import and test documentation.

Fixes DAG-1423

@TomChv TomChv added area/engine About dagger core engine sdk/nodejs labels Jun 12, 2023
@TomChv
TomChv requested review from sipsma and slumbering June 12, 2023 15:19
@TomChv TomChv self-assigned this Jun 12, 2023
@TomChv
TomChv requested a review from vito June 14, 2023 16:10
@TomChv
TomChv marked this pull request as ready for review June 14, 2023 16:10
@TomChv
TomChv force-pushed the feat/ts-entrypoint branch from f440a76 to d22704d Compare June 14, 2023 16:11
@TomChv TomChv changed the title Feat/ts entrypoint feat: typescript entrypoint Jun 14, 2023
@TomChv
TomChv force-pushed the feat/ts-entrypoint branch from b24e812 to fe12f0a Compare June 14, 2023 16:26

@sipsma sipsma 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.

Looks really great, thanks for putting this together so quickly! Have a couple minor comments/questions, but really the only thing I think we should do before merging is add some integ tests for what's working so far.

I added a bunch of test utils recently, you can see the latest in this PR: https://github.com/dagger/dagger/pull/5308/files#diff-b6e594474025769dd7b1a4bfbeb8b43ab3a26b34796bb76f76be91a0cbbd410d

I'm hoping to get that merged soon, but in the meantime you can rebase on top of that one or just write the tests separately, whatever you prefer.

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.

This is totally fine, but I'm curious if you think every start script users write will be exactly this? If so, could we just put node --loader ts-node/esm ./main.mts in the typescript runtime on this line?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

It could be this or something else, by using the script start, we let the user choose how to start the ci.
This way, he may rename his file ci.ts or ci.mts or use a different loader or anything. What we actually need is to launch the script, we can let the user define its own way.

Comment thread sdk/nodejs/server/convertor.ts Resolved
Comment thread sdk/nodejs/server/server.ts Outdated

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.

Do you think we need to get every file in the dir here, or can we just provide the file that has the serveCommands call (which should be in the callstack of this function)?

My guess was that program.getSourceFiles would then handle visiting every file imported by that one, but could be wrong.

Not a big deal, just a potential small simplification I am curious about.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

That's a great question, I didn't try but since typescript.createProgram expect an array of every files to instrospect.
I assumed it worked the same way as the include in tsconfig.json which require every files involved (even these from node_modules).

I can try to just use the main file and see if it works, we can check this in a follow up to simplify the code.

@TomChv

TomChv commented Jun 15, 2023

Copy link
Copy Markdown
Member Author

I added a bunch of test utils recently, you can see the latest in this PR: https://github.com/dagger/dagger/pull/5308/files#diff-b6e594474025769dd7b1a4bfbeb8b43ab3a26b34796bb76f76be91a0cbbd410d

Nice! I might add more tests in a further PR then!

@TomChv
TomChv force-pushed the feat/ts-entrypoint branch from 96fd2e5 to bc83a08 Compare June 15, 2023 21:31
@TomChv
TomChv requested review from a team as code owners June 15, 2023 21:31
@helderco

Copy link
Copy Markdown
Contributor

There's a lot of unrelated commits here, I assume you did a merge from main instead of rebase. Can you fix that?

@TomChv

TomChv commented Jun 16, 2023

Copy link
Copy Markdown
Member Author

I'll, my bad!

@TomChv
TomChv force-pushed the feat/ts-entrypoint branch from bc83a08 to ac50801 Compare June 16, 2023 07:33
Comment thread sdk/nodejs/server/server.ts Resolved
Comment thread sdk/nodejs/server/server.ts Resolved
Comment thread demos/typescript-entrypoints/main.mts Resolved
Comment thread sdk/nodejs/server/server.ts Resolved
Comment thread sdk/nodejs/server/server.ts Resolved
@TomChv
TomChv force-pushed the feat/ts-entrypoint branch from 82b15ce to 927d7d0 Compare June 19, 2023 11:02
@TomChv
TomChv requested review from sipsma and slumbering June 19, 2023 13:44

@slumbering slumbering 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.

LGTM 🚢

@TomChv

TomChv commented Jun 20, 2023

Copy link
Copy Markdown
Member Author

@sipsma Waiting for your approval to merge :)

@TomChv TomChv mentioned this pull request Jun 20, 2023
5 tasks done

@sipsma sipsma 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.

LGTM! I just merged the CLI PR, which includes the updates to the integ test tooling you may want here: #5308

I do think it's extremely important to get test coverage for TS in there ASAP. You can see what @helderco is doing with integrating python here for a good example on how to approach this: #5300

However, no need for that to be in this PR if you'd prefer a follow up.

@TomChv
TomChv force-pushed the feat/ts-entrypoint branch from 6f3a820 to 7cdb7cf Compare June 28, 2023 11:18
@TomChv
TomChv force-pushed the feat/ts-entrypoint branch 9 times, most recently from 1a81c36 to 546a042 Compare June 28, 2023 18:42
@TomChv
TomChv force-pushed the feat/ts-entrypoint branch from 546a042 to 125ff3e Compare June 28, 2023 18:57
TomChv and others added 9 commits July 3, 2023 18:46
Signed-off-by: Vasek - Tom C <[email protected]>
Signed-off-by: Vasek - Tom C <[email protected]>
Signed-off-by: Vasek - Tom C <[email protected]>
Signed-off-by: Vasek - Tom C <[email protected]>
Signed-off-by: Vasek - Tom C <[email protected]>
@TomChv
TomChv force-pushed the feat/ts-entrypoint branch from 6cadd59 to f88603b Compare July 6, 2023 16:49
@TomChv

TomChv commented Jul 6, 2023

Copy link
Copy Markdown
Member Author

Ok it seems that dependencies installation is a bit messed up with npm but it works well with yarn, the PR is almost ready!
All bugs are almost fixed!

@TomChv

TomChv commented Jul 6, 2023

Copy link
Copy Markdown
Member Author

@sipsma It seems the test TestImportedProjectDir cannot be performed the same way on the Typescript SDK because the fs.readdirSync is relative to the path of the file who executes the code, not the path where the command is executed.
Should I update my command to check from the project dir instead of the workdir? That would change the whole purpose of the test.

Do you have any idea of what we could do to be consistent between all tests?

@gerhard

gerhard commented Jul 14, 2023

Copy link
Copy Markdown
Contributor

What would help move this one along?

@helderco

Copy link
Copy Markdown
Contributor

@gerhard, it's been on hold because of the shift in Zenith design and major refactor from @sipsma:

More context in Discord.

@TomChv

TomChv commented Jul 25, 2023

Copy link
Copy Markdown
Member Author

Closing this PR for now since Zenith include too much breaking change that invalidate this PR.
However some work could be used later to integrate entrypoint on the Node SDK!

@TomChv TomChv closed this Jul 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/engine About dagger core engine

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants