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

feature: better frameworks like cli #115

Merged
merged 44 commits into from
Sep 11, 2023
Merged

Conversation

vasucp1207
Copy link
Contributor

@vasucp1207 vasucp1207 commented Aug 3, 2023

Method like other frameworks use(mainly vue).

Cli including,

  • Dynamically project name.
  • Choose from different default templates.
  • Overriding the directory if it exits after confirmation.
  • Validates package name.

Should try to commit in #52 but I messed up and also thought it's a completely new strategy so I raised this PR instead.

@vercel
Copy link

vercel bot commented Aug 3, 2023

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

Name Status Preview Comments Updated (UTC)
waku ✅ Ready (Inspect) Visit Preview 💬 Add feedback Sep 5, 2023 10:59pm

@codesandbox-ci
Copy link

codesandbox-ci bot commented Aug 3, 2023

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.

Latest deployment of this branch, based on commit 4c549d9:

Sandbox Source
Vanilla Configuration
Vanilla Typescript Configuration
React Configuration
React Typescript Configuration

@dai-shi
Copy link
Owner

dai-shi commented Aug 3, 2023

Does this cover #81?
Can you also take #89 into account?

@vasucp1207
Copy link
Contributor Author

Regarding #89 , templates only contain necessary files it does not include folders like node_modules etc. Well if you run npm run build a resulted out.cjs file is generated, but I can't figure out now how to publish it to npm to actually check it. Do you have any idea about this.

@dai-shi
Copy link
Owner

dai-shi commented Aug 4, 2023

Regarding #89 , templates only contain necessary files it does not include folders like node_modules etc.

As I understand, #89's request is just to put .gitignore file in those templates.
But, on second thought, I'm not sure what should be in there.
Does create-vue generate .gitignore file?

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.

One big issue for me is now we have to maintain both examples and templates.
As we are adding the "build" process, we should copy files from examples folder, instead of copying them.

contrib/create-waku/cli.js Outdated Show resolved Hide resolved
contrib/create-waku/cli.js Outdated Show resolved Hide resolved
contrib/create-waku/package.json Outdated Show resolved Hide resolved
contrib/create-waku/package.json Outdated Show resolved Hide resolved
@vasucp1207
Copy link
Contributor Author

Regarding #89 , templates only contain necessary files it does not include folders like node_modules etc.

As I understand, #89's request is just to put .gitignore file in those templates. But, on second thought, I'm not sure what should be in there. Does create-vue generate .gitignore file?

Yes, create-vue generates a .gitignore file, I think a minimal file is okay for this like create-vue .gitignore

@vasucp1207 vasucp1207 requested a review from dai-shi August 4, 2023 06:18
let targetDir;
let defaultProjectName = 'waku-project'

const CHOICES = fs.readdirSync(path.resolve(cwd, '../../examples'))
Copy link
Owner

Choose a reason for hiding this comment

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

This doesn't work as we don't publish examples dir.

We have two options.

  1. add build step to copy examples dir
  2. download from github

Eventually, we should go with 1 because it fixes #81, but for now 2 is also fine.
If we were to go with 1, we would like to make the code in TypeScript and transpile with SWC in the build step.

Copy link
Contributor Author

@vasucp1207 vasucp1207 Aug 5, 2023

Choose a reason for hiding this comment

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

This doesn't work as we don't publish examples dir.

We have two options.

  1. add build step to copy examples dir
  2. download from github

Eventually, we should go with 1 because it fixes #81, but for now 2 is also fine. If we were to go with 1, we would like to make the code in TypeScript and transpile with SWC in the build step.

Using esbuild,

  • If we npm run build:esbuild an out.js file generated.
  • Running npm run build:estemplate generates an copy.js file.
  • If we run node copy.js templates copied from example dir and a template folder generated.
  • Finally, running node cli.js works fine.

Problem with transpiling with swr,

  • If we transpiling files with swr then the imports in output files are not working ex,
import { renderTemplate } from './renderTemplate'

This import statement would not be able to resolve the file.

Is, I'm missing something about this swr.

Copy link
Owner

Choose a reason for hiding this comment

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

Okay, I don't mind using esbuild for now. I just thought SWC might work better and we also use it in waku. We can try that later.

Can you move TS files into ./src folder please?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, sure we can look around it in the near future.

@dai-shi
Copy link
Owner

dai-shi commented Aug 31, 2023

Please check CI errors.

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.

Please check CI errors again.

packages/create-waku/package.json Outdated Show resolved Hide resolved
packages/create-waku/src/cli.ts Outdated Show resolved Hide resolved
packages/create-waku/package.json Show resolved Hide resolved
"dist",
"template"
],
"type": "commonjs",
Copy link
Owner

Choose a reason for hiding this comment

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

Future TODO: make type=module and use swc instead of esbuild.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, I will take look into this.

packages/create-waku/src/cli.ts Outdated Show resolved Hide resolved
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.

Let's merge it. Feel free to work on improvements later.

@dai-shi dai-shi merged commit 56b8162 into dai-shi:main Sep 11, 2023
@dai-shi
Copy link
Owner

dai-shi commented Sep 11, 2023

https://www.npmjs.com/package/create-waku/v/0.5.1 is published.
@vasucp1207 Can you please check if it works as expected?

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.

create waku error
3 participants