Skip to content

Commit

Permalink
Add inferred name attribute to default package.json (#188)
Browse files Browse the repository at this point in the history
* Add inferred name attribute to default package.json

* Update changelog

* Add my name to the contributors list
  • Loading branch information
ayushn21 authored Nov 23, 2020
1 parent 54d7bf1 commit d03dc3c
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 6 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# main

* Change the `name` attribute of the default `package.json` to be inferred from the path passed to `bridgetown new`

# 0.18.6 / 2020-11-12

* Change the logging level for "Executing inline Ruby…" messages to the debug level [#184](https://github.com/bridgetownrb/bridgetown/pull/184) ([ianbayne](https://github.com/ianbayne))
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,10 @@ Bridgetown is built by:
|<a href="https://github.com/jaredcwhite">@jaredcwhite</a>|<a href="https://github.com/jaredmoody">@jaredmoody</a>|<a href="https://github.com/andrewmcodes">@andrewmcodes</a>|<a href="https://github.com/ParamagicDev">@ParamagicDev</a>|<a href="https://github.com/MikeRogers0">@MikeRogers0</a>|
|Portland, OR|Portland, OR|Wilmington, NC|Providence, RI|Ny-Ålesund, Svalbard|

|<img src="https://avatars.githubusercontent.com/wout?s=256" alt="" width="128" />|<img src="https://avatars.githubusercontent.com/codemargaret?s=256" alt="" width="128" />|<img src="https://avatars.githubusercontent.com/julianrubisch?s=256" alt="" width="128" />|<img src="https://avatars.githubusercontent.com/ianbayne?s=256" alt="" width="128" />|<img src="https://www.gravatar.com/avatar/00000000000000000000000000000000?d=identicon&s=128&" alt="" width="128" />|
|:---:|:---:|:---:|:---:|:---:|
|<a href="https://github.com/wout">@wout</a>|<a href="https://github.com/codemargaret">@codemargaret</a>|<a href="https://github.com/julianrubisch">@julianrubisch</a>|<a href="https://github.com/ianbayne">@ianbayne</a>|You Next?|
|Brighton, UK|Portland, OR|Vienna, Austria|Tokyo, Japan|Anywhere|
|<img src="https://avatars.githubusercontent.com/wout?s=256" alt="" width="128" />|<img src="https://avatars.githubusercontent.com/codemargaret?s=256" alt="" width="128" />|<img src="https://avatars.githubusercontent.com/julianrubisch?s=256" alt="" width="128" />|<img src="https://avatars.githubusercontent.com/ianbayne?s=256" alt="" width="128" />|<img src="https://avatars.githubusercontent.com/ayushn21?s=256" alt="" width="128" />|<img src="https://www.gravatar.com/avatar/00000000000000000000000000000000?d=identicon&s=128&" alt="" width="128" />|
|:---:|:---:|:---:|:---:|:---:|:---:|
|<a href="https://github.com/wout">@wout</a>|<a href="https://github.com/codemargaret">@codemargaret</a>|<a href="https://github.com/julianrubisch">@julianrubisch</a>|<a href="https://github.com/ianbayne">@ianbayne</a>|<a href="https://github.com/ayushn21">@ayushn21</a>|You Next?|
|Brighton, UK|Portland, OR|Vienna, Austria|Tokyo, Japan|London, UK|Anywhere|

Interested in joining the Bridgetown Core Team? Send a DM to Jared on the [Bridgetown Community forum](https://community.bridgetownrb.com) and let's chat!

Expand Down
3 changes: 3 additions & 0 deletions bridgetown-core/lib/bridgetown-core/commands/new.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ def new_site
raise ArgumentError, "You must specify a path." if args.empty?

new_site_path = File.expand_path(args.join(" "), Dir.pwd)
@site_name = new_site_path.split(File::SEPARATOR).last

if preserve_source_location?(new_site_path, options)
say_status :conflict, "#{new_site_path} exists and is not empty.", :red
Bridgetown.logger.abort_with "Ensure #{new_site_path} is empty or else " \
Expand Down Expand Up @@ -75,6 +77,7 @@ def create_site(new_site_path)
"src/_posts/#{Time.now.strftime("%Y-%m-%d")}-welcome-to-bridgetown.md"
)
template("Gemfile.erb", "Gemfile")
template("package.json.erb", "package.json")
end

# After a new site has been created, print a success notification and
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "new-bridgetown-site",
"name": "<%= @site_name %>",
"version": "1.0.0",
"private": true,
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion bridgetown-core/test/test_new_command.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def site_template_source
static_template_files = dir_contents(site_template).reject do |f|
File.extname(f) == ".erb"
end
static_template_files << "/Gemfile"
static_template_files.push "/Gemfile", "/package.json"

capture_output do
Bridgetown::Commands::Base.start(argumentize(@args))
Expand Down

0 comments on commit d03dc3c

Please sign in to comment.