diff --git a/CHANGELOG.md b/CHANGELOG.md index c38f9e1e9..58f9cd1b5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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)) diff --git a/README.md b/README.md index df49c9a4a..7ea0a5d0b 100644 --- a/README.md +++ b/README.md @@ -113,10 +113,10 @@ Bridgetown is built by: |@jaredcwhite|@jaredmoody|@andrewmcodes|@ParamagicDev|@MikeRogers0| |Portland, OR|Portland, OR|Wilmington, NC|Providence, RI|Ny-Ålesund, Svalbard| -|||||| -|:---:|:---:|:---:|:---:|:---:| -|@wout|@codemargaret|@julianrubisch|@ianbayne|You Next?| -|Brighton, UK|Portland, OR|Vienna, Austria|Tokyo, Japan|Anywhere| +||||||| +|:---:|:---:|:---:|:---:|:---:|:---:| +|@wout|@codemargaret|@julianrubisch|@ianbayne|@ayushn21|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! diff --git a/bridgetown-core/lib/bridgetown-core/commands/new.rb b/bridgetown-core/lib/bridgetown-core/commands/new.rb index 7f77a13e7..f79708644 100644 --- a/bridgetown-core/lib/bridgetown-core/commands/new.rb +++ b/bridgetown-core/lib/bridgetown-core/commands/new.rb @@ -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 " \ @@ -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 diff --git a/bridgetown-core/lib/site_template/package.json b/bridgetown-core/lib/site_template/package.json.erb similarity index 96% rename from bridgetown-core/lib/site_template/package.json rename to bridgetown-core/lib/site_template/package.json.erb index ac7293d60..66c45cb1e 100644 --- a/bridgetown-core/lib/site_template/package.json +++ b/bridgetown-core/lib/site_template/package.json.erb @@ -1,5 +1,5 @@ { - "name": "new-bridgetown-site", + "name": "<%= @site_name %>", "version": "1.0.0", "private": true, "scripts": { diff --git a/bridgetown-core/test/test_new_command.rb b/bridgetown-core/test/test_new_command.rb index 5ebe8e159..c1a2ccb4d 100644 --- a/bridgetown-core/test/test_new_command.rb +++ b/bridgetown-core/test/test_new_command.rb @@ -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))