Module: Locomotive::Wagon

Defined in:
lib/locomotive/wagon.rb,
lib/locomotive/wagon/cli.rb,
lib/locomotive/wagon/version.rb,
lib/locomotive/wagon/exceptions.rb,
lib/locomotive/wagon/tools/glob.rb,
lib/locomotive/wagon/tools/listen.rb,
lib/locomotive/wagon/tools/tcp_port.rb,
lib/locomotive/wagon/tools/yaml_ext.rb,
lib/locomotive/wagon/generators/page.rb,
lib/locomotive/wagon/generators/site.rb,
lib/locomotive/wagon/generators/section.rb,
lib/locomotive/wagon/generators/snippet.rb,
lib/locomotive/wagon/generators/webpack.rb,
lib/locomotive/wagon/generators/site/base.rb,
lib/locomotive/wagon/commands/init_command.rb,
lib/locomotive/wagon/commands/pull_command.rb,
lib/locomotive/wagon/commands/push_command.rb,
lib/locomotive/wagon/commands/sync_command.rb,
lib/locomotive/wagon/generators/site/blank.rb,
lib/locomotive/wagon/commands/clone_command.rb,
lib/locomotive/wagon/commands/serve_command.rb,
lib/locomotive/wagon/generators/public_form.rb,
lib/locomotive/wagon/generators/site/cloned.rb,
lib/locomotive/wagon/middlewares/error_page.rb,
lib/locomotive/wagon/commands/delete_command.rb,
lib/locomotive/wagon/generators/content_type.rb,
lib/locomotive/wagon/generators/relationship.rb,
lib/locomotive/wagon/commands/generate_command.rb,
lib/locomotive/wagon/decorators/page_decorator.rb,
lib/locomotive/wagon/decorators/site_decorator.rb,
lib/locomotive/wagon/generators/site_metafields.rb,
lib/locomotive/wagon/commands/loggers/base_logger.rb,
lib/locomotive/wagon/commands/loggers/pull_logger.rb,
lib/locomotive/wagon/commands/loggers/push_logger.rb,
lib/locomotive/wagon/commands/loggers/sync_logger.rb,
lib/locomotive/wagon/decorators/section_decorator.rb,
lib/locomotive/wagon/decorators/snippet_decorator.rb,
lib/locomotive/wagon/commands/authenticate_command.rb,
lib/locomotive/wagon/commands/concerns/api_concern.rb,
lib/locomotive/wagon/commands/concerns/netrc_concern.rb,
lib/locomotive/wagon/commands/concerns/steam_concern.rb,
lib/locomotive/wagon/decorators/theme_asset_decorator.rb,
lib/locomotive/wagon/decorators/translation_decorator.rb,
lib/locomotive/wagon/commands/concerns/spinner_concern.rb,
lib/locomotive/wagon/decorators/content_type_decorator.rb,
lib/locomotive/wagon/decorators/content_asset_decorator.rb,
lib/locomotive/wagon/decorators/content_entry_decorator.rb,
lib/locomotive/wagon/decorators/concerns/to_hash_concern.rb,
lib/locomotive/wagon/commands/concerns/deploy_file_concern.rb,
lib/locomotive/wagon/decorators/editable_element_decorator.rb,
lib/locomotive/wagon/decorators/content_type_field_decorator.rb,
lib/locomotive/wagon/commands/concerns/instrumentation_concern.rb,
lib/locomotive/wagon/decorators/concerns/persist_assets_concern.rb,
lib/locomotive/wagon/commands/pull_sub_commands/pull_base_command.rb,
lib/locomotive/wagon/commands/pull_sub_commands/pull_site_command.rb,
lib/locomotive/wagon/commands/push_sub_commands/push_base_command.rb,
lib/locomotive/wagon/commands/push_sub_commands/push_site_command.rb,
lib/locomotive/wagon/commands/sync_sub_commands/sync_site_command.rb,
lib/locomotive/wagon/commands/pull_sub_commands/pull_pages_command.rb,
lib/locomotive/wagon/commands/push_sub_commands/push_pages_command.rb,
lib/locomotive/wagon/commands/sync_sub_commands/sync_pages_command.rb,
lib/locomotive/wagon/commands/pull_sub_commands/pull_sections_command.rb,
lib/locomotive/wagon/commands/pull_sub_commands/pull_snippets_command.rb,
lib/locomotive/wagon/commands/push_sub_commands/push_sections_command.rb,
lib/locomotive/wagon/commands/push_sub_commands/push_snippets_command.rb,
lib/locomotive/wagon/commands/sync_sub_commands/concerns/base_concern.rb,
lib/locomotive/wagon/commands/pull_sub_commands/concerns/assets_concern.rb,
lib/locomotive/wagon/commands/pull_sub_commands/pull_theme_assets_command.rb,
lib/locomotive/wagon/commands/pull_sub_commands/pull_translations_command.rb,
lib/locomotive/wagon/commands/push_sub_commands/push_theme_assets_command.rb,
lib/locomotive/wagon/commands/push_sub_commands/push_translations_command.rb,
lib/locomotive/wagon/commands/sync_sub_commands/sync_translations_command.rb,
lib/locomotive/wagon/commands/pull_sub_commands/pull_content_types_command.rb,
lib/locomotive/wagon/commands/push_sub_commands/push_content_types_command.rb,
lib/locomotive/wagon/commands/pull_sub_commands/pull_content_assets_command.rb,
lib/locomotive/wagon/commands/push_sub_commands/push_content_assets_command.rb,
lib/locomotive/wagon/commands/pull_sub_commands/pull_content_entries_command.rb,
lib/locomotive/wagon/commands/push_sub_commands/push_content_entries_command.rb,
lib/locomotive/wagon/commands/sync_sub_commands/sync_content_entries_command.rb

Defined Under Namespace

Modules: ApiConcern, AssetsConcern, BaseConcern, CLI, DeployFileConcern, Generators, InstrumentationConcern, Middlewares, NetrcConcern, PersistAssetsConcern, SpinnerConcern, SteamConcern, ToHashConcern, YamlExt Classes: AuthenticateCommand, BaseLogger, CloneCommand, ContentAssetDecorator, ContentEntryDecorator, ContentEntryWithLocalizedAttributesDecorator, ContentEntryWithOnlyRelationshipsDecorator, ContentTypeDecorator, ContentTypeFieldDecorator, ContentTypeWithOnlyRelationshipsDecorator, DeleteCommand, EditableElementDecorator, GenerateCommand, GeneratorException, Glob, InitCommand, Listen, PageDecorator, PullBaseCommand, PullCommand, PullContentAssetsCommand, PullContentEntriesCommand, PullContentTypesCommand, PullLogger, PullPagesCommand, PullSectionsCommand, PullSiteCommand, PullSnippetsCommand, PullThemeAssetsCommand, PullTranslationsCommand, PushBaseCommand, PushCommand, PushContentAssetsCommand, PushContentEntriesCommand, PushContentTypesCommand, PushLogger, PushPagesCommand, PushSectionsCommand, PushSiteCommand, PushSnippetsCommand, PushThemeAssetsCommand, PushTranslationsCommand, RemoteSiteDecorator, SectionDecorator, ServeCommand, SiteDecorator, SiteFinder, SnippetDecorator, SyncCommand, SyncContentEntriesCommand, SyncLogger, SyncPagesCommand, SyncSiteCommand, SyncTranslationsCommand, TcpPort, ThemeAssetDecorator, TranslationDecorator, UpdateSiteDecorator

Constant Summary collapse

DEFAULT_PLATFORM_URL =
'https://station.locomotive.works'.freeze
VERSION =
'3.2.0.alpha2'

Class Method Summary collapse

Class Method Details

.authenticate(url, email, password, shell) ⇒ Object

Authenticate an user to the Hosting platform. If the user does not exist, then create an account for her/him. At the end, store the API key in the ~/.netrc file

Parameters:

  • email (String)

    The email of the user

  • password (String)

    The password of the user

  • shell (Object)

    Used to ask for/prompt information



17
18
19
20
# File 'lib/locomotive/wagon.rb', line 17

def self.authenticate(url, email, password, shell)
  require_relative 'wagon/commands/authenticate_command'
  Locomotive::Wagon::AuthenticateCommand.authenticate(url, email, password, shell)
end

.clone(name, path, options, shell) ⇒ Object

Clone a site from a remote LocomotiveCMS engine.

Parameters:

  • name (String)

    Name of the site (arbitrary)

  • path (String)

    The root path where the site will be cloned

  • connection_info (Hash)

    The host, email and password needed to access the remote engine

  • options (Hash)

    The options for the API reader



108
109
110
111
# File 'lib/locomotive/wagon.rb', line 108

def self.clone(name, path, options, shell)
  require_relative 'wagon/commands/clone_command'
  Locomotive::Wagon::CloneCommand.clone(name, path, options, shell)
end

.delete(env, path, resource, slug, shell) ⇒ Object

Delete one or all remote resource(s)

Parameters:

  • env (String)

    The environment we use to deploy the site to

  • path (String)

    The path of the site

  • resource (String)

    The resource from which we want to delete an entry or all entries

  • slug (String)

    The slug of the resource to delete



119
120
121
122
# File 'lib/locomotive/wagon.rb', line 119

def self.delete(env, path, resource, slug, shell)
  require_relative 'wagon/commands/delete_command'
  Locomotive::Wagon::DeleteCommand.delete(env, path, resource, slug, shell)
end

.generate(name, args, options = {}) ⇒ Object

Generate components for the LocomotiveCMS site such as content types, snippets, pages.

Parameters:

  • name (Symbol)

    The name of the generator

  • *args (Array)

    The arguments for the generator

  • options (Hash) (defaults to: {})

    The options for the generator



59
60
61
62
# File 'lib/locomotive/wagon.rb', line 59

def self.generate(name, args, options = {})
  require_relative 'wagon/commands/generate_command'
  Locomotive::Wagon::GenerateCommand.generate(name, args, options)
end

.init(generator_klass, args, options = {}) ⇒ Object

Create a site from a site generator.

Parameters:

  • generator (Object)

    The wrapping class of the generator itself

  • args (Array)
    name of the site, destination path of the site
  • options (Hash) (defaults to: {})

    General options (ex: –force-color)



28
29
30
31
# File 'lib/locomotive/wagon.rb', line 28

def self.init(generator_klass, args, options = {})
  require_relative 'wagon/commands/init_command'
  Locomotive::Wagon::InitCommand.generate(generator_klass, args, options)
end

.pull(env, path, options = {}, shell) ⇒ Object

Pull a site from a remote LocomotiveCMS engine described by the config/deploy.yml file of the site and for a specific environment.

Parameters:

  • path (String)

    The path of the site

  • connection_info (Hash)

    The information to get connected to the remote site

  • options (Hash) (defaults to: {})

    The options passed to the pull process



84
85
86
87
# File 'lib/locomotive/wagon.rb', line 84

def self.pull(env, path, options = {}, shell)
  require_relative 'wagon/commands/pull_command'
  Locomotive::Wagon::PullCommand.pull(env, path, options, shell)
end

.push(env, path, options = {}, shell) ⇒ Object

Push a site to a remote LocomotiveCMS engine described by the config/deploy.yml file of the site and for a specific environment.

Parameters:

  • env (String)

    The environment we deploy the site to

  • path (String)

    The path of the site

  • shell (Object)

    The Thor shell used to ask for information if needed

  • options (Hash) (defaults to: {})

    The options passed to the push process



72
73
74
75
# File 'lib/locomotive/wagon.rb', line 72

def self.push(env, path, options = {}, shell)
  require_relative 'wagon/commands/push_command'
  Locomotive::Wagon::PushCommand.push(env, path, options, shell)
end

.require_misc_gemsObject



124
125
126
127
128
129
130
131
132
133
134
135
136
# File 'lib/locomotive/wagon.rb', line 124

def self.require_misc_gems
  return if ENV['WAGON_GEMFILE'].nil?

  # at this point, we are sure that in a bundle exec contact
  begin
    require 'bundler'
    ::Bundler.require(:misc)
  rescue Exception => e
    puts "Warning: cant' require the Gemfile misc group, reason: #{e.message}"
    # Bundler is not defined or there is an issue
    # with one of the gems in the misc group
  end
end

.serve(path, options, shell) ⇒ Object

Start the thin server which serves the LocomotiveCMS site from the system.

Parameters:

  • path (String)

    The path of the site

  • options (Hash)

    The options for the thin server (host, port)



38
39
40
41
# File 'lib/locomotive/wagon.rb', line 38

def self.serve(path, options, shell)
  require_relative 'wagon/commands/serve_command'
  Locomotive::Wagon::ServeCommand.start(path, options, shell)
end

.stop(path, force = false, shell) ⇒ Object

Stop the thin server.

Parameters:

  • path (String)

    The path of the site

  • force (Hash) (defaults to: false)

    If true, block the current thread for 2s



48
49
50
51
# File 'lib/locomotive/wagon.rb', line 48

def self.stop(path, force = false, shell)
  require_relative 'wagon/commands/serve_command'
  Locomotive::Wagon::ServeCommand.stop(path, force, shell)
end

.sync(env, path, options = {}, shell) ⇒ Object

Synchronize the local content with the one from a remote Locomotive engine. by the config/deploy.yml file of the site and for a specific environment.

Parameters:

  • path (String)

    The path of the site

  • connection_info (Hash)

    The information to get connected to the remote site

  • options (Hash) (defaults to: {})

    The options passed to the pull process



96
97
98
99
# File 'lib/locomotive/wagon.rb', line 96

def self.sync(env, path, options = {}, shell)
  require_relative 'wagon/commands/sync_command'
  Locomotive::Wagon::SyncCommand.sync(env, path, options, shell)
end