Class: Bridgetown::Commands::New
- Inherits:
-
Bridgetown::Command
- Object
- Samovar::Command
- Bridgetown::Command
- Bridgetown::Commands::New
- Includes:
- Automations, GitHelpers
- Defined in:
- bridgetown-core/lib/bridgetown-core/commands/new.rb
Constant Summary collapse
- DOCSURL =
"https://bridgetownrb.com/docs"
Constants included from Automations
Automations::CODEBERG_REGEX, Automations::CODEBERG_REPO_REGEX, Automations::CODEBERG_TREE_REGEX, Automations::GITHUB_BLOB_REGEX, Automations::GITHUB_REGEX, Automations::GITHUB_REPO_REGEX, Automations::GITHUB_TREE_REGEX, Automations::GITLAB_BLOB_REGEX, Automations::GITLAB_REGEX, Automations::GITLAB_REPO_REGEX, Automations::GITLAB_TREE_REGEX
Class Attribute Summary collapse
-
.created_site_dir ⇒ Object
Returns the value of attribute created_site_dir.
Class Method Summary collapse
Instance Method Summary collapse
-
#call ⇒ Object
rubocop:disable Metrics.
Methods included from GitHelpers
#destroy_existing_repo, #initialize_new_repo, #user_default_branch
Methods included from Automations
#add_gem, #add_initializer, #add_npm_for_gem, #add_npm_package, #apply_from_url, #create_builder, included, #javascript_import, #remove_npm_package, #ruby_configure
Methods inherited from Bridgetown::Command
Class Attribute Details
.created_site_dir ⇒ Object
Returns the value of attribute created_site_dir.
38 39 40 |
# File 'bridgetown-core/lib/bridgetown-core/commands/new.rb', line 38 def created_site_dir @created_site_dir end |
Class Method Details
.exit_on_failure? ⇒ Boolean
29 30 31 |
# File 'bridgetown-core/lib/bridgetown-core/commands/new.rb', line 29 def self.exit_on_failure? false end |
.source_root ⇒ Object
33 34 35 |
# File 'bridgetown-core/lib/bridgetown-core/commands/new.rb', line 33 def self.source_root File.("../../site_template", __dir__) end |
Instance Method Details
#call ⇒ Object
rubocop:disable Metrics
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'bridgetown-core/lib/bridgetown-core/commands/new.rb', line 41 def call # rubocop:disable Metrics case path when "--help", "-help", "-h" print_usage return end self.source_paths = [self.class.source_root] new_site_path = File.(path, Dir.pwd) @site_name = new_site_path.split(File::SEPARATOR).last if preserve_source_location?(new_site_path, ) say_status :conflict, "#{new_site_path} exists and is not empty.", :red Bridgetown.logger.abort_with( "Ensure #{new_site_path} is empty or else try again with `--force` to proceed and " \ "overwrite any files." ) end self.destination_root = self.class.created_site_dir = new_site_path say_status :create, new_site_path create_site new_site_path after_install new_site_path, path, rescue ArgumentError => e say_status :alert, e., :red ensure self.class.created_site_dir = nil # reset afterwards, otherwise hanging tmp dirs in test end |