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

deno init should add name, version and exports fields to deno.json #22287

Closed
littledivy opened this issue Feb 6, 2024 · 9 comments
Closed

deno init should add name, version and exports fields to deno.json #22287

littledivy opened this issue Feb 6, 2024 · 9 comments
Labels
cli related to cli/ dir

Comments

@littledivy
Copy link
Member

No description provided.

@littledivy littledivy added cli related to cli/ dir enhancement labels Feb 6, 2024
@muddlebee
Copy link
Contributor

@littledivy would like to work on this 👀

@littledivy
Copy link
Member Author

sure!

@muddlebee
Copy link
Contributor

muddlebee commented Feb 19, 2024

@littledivy

so if I run the command deno init test
something like below should appear in deno.json. correct?

{
  "name" : "test",
  "version": "1.0.0",
  "imports": {},
  "tasks": {
    "dev": "deno run --watch main.ts"
  }
}

but if deno init only then the new fields(name) should be empty?

{
  "name" : "",
  "version": "1.0.0",
  "imports": {},
  "tasks": {
    "dev": "deno run --watch main.ts"
  }
}

deno init docs

@muddlebee
Copy link
Contributor

muddlebee commented Feb 19, 2024

I am thinking of the approach in codebase, to keep the deno init json template like below and overwrite with the dir option from the deno init <dir> command inside the deno.json {{name}}. original code here

{
  "name" : "{{name}}", 
  "version": "1.0.0",
  "imports": {},
  "tasks": {
    "dev": "deno run --watch main.ts"
  }
}

@littledivy
Copy link
Member Author

Sounds good. This can be the template JSON:

{
  "name": "{{name}}", 
  "version": "0.1.0",
  "exports": {},
  "tasks": {
    "dev": "deno run --watch main.ts"
  }
}

Also note that If dir is not provided it should use the current working directory name.

@dsherret
Copy link
Member

dsherret commented Feb 20, 2024

Maybe we should only do this when running something like deno init --lib? Not everyone will be developing a library so probably deno init shouldn't do this by default. For example, when adding all three of these fields then someone will get opted into library only lint rules like no-slow-types, which is not necessary for applications.

@bartlomieju
Copy link
Member

Maybe we should only do this when running something like deno init --lib? Not everyone will be developing a library so probably deno init shouldn't do this by default. For example, when adding all three of these fields then someone will get opted into library only lint rules like no-slow-types, which is not necessary for applications.

Exactly my thought, +1 for --lib.

@muddlebee
Copy link
Contributor

I have done the changes as per comments above ☝️ and added some unit tests.

@muddlebee
Copy link
Contributor

muddlebee commented Feb 22, 2024

added some changes to the deno init docs https://github.com/denoland/deno-docs/pull/345/files to reflect the above.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cli related to cli/ dir
Projects
None yet
Development

No branches or pull requests

4 participants