Skip to content

Commit

Permalink
Scaffolding improvements and glimmer run rake task
Browse files Browse the repository at this point in the history
  • Loading branch information
AndyObtiva committed Oct 17, 2020
1 parent f03b7a2 commit f2516b0
Show file tree
Hide file tree
Showing 7 changed files with 49 additions and 14 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,13 @@

### 4.17.2.4

- Fix SWTProxy.deconstruct method
- New `glimmer run` glimmer command task.
- Add built in support for handling jar file paths like that in ImageProxy code processing "uri:classloader" path
- Document that gif background_image only works without on_top and no_trim styles in Windows
- Give a good error message when Git is not properly setup for Glimmer Scaffolding
- Give an error message when attempting to scaffold over an already scaffolded directory
- Fix issue on Windows regarding use of the new EXPERIMENTAL Animated gif support in the `composite#background_image` property
- Fix SWTProxy.deconstruct method


### 4.17.2.3
Expand Down
24 changes: 20 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,7 @@ Glimmer App:
- [Hello, World!](#hello-world)
- [Tic Tac Toe](#tic-tac-toe)
- [Contact Manager](#contact-manager)
- [Desktop Apps Built with Glimmer DSL for SWT](#desktop-apps-built-with-glimmer-dsl-for-swt)
- [Table of contents](#table-of-contents)
- [Background](#background)
- [Platform Support](#platform-support)
Expand Down Expand Up @@ -268,9 +269,10 @@ Glimmer App:
- [Glimmer GUI DSL Syntax](#glimmer-gui-dsl-syntax)
- [DSL Auto-Expansion](#dsl-auto-expansion)
- [Widgets](#widgets)
- [Display](#display)
- [SWT Proxies](#swt-proxies)
- [Dialog](#dialog)
- [Display](#display)
- [Multi-Threading](#multi-threading)
- [Menus](#menus)
- [ScrolledComposite](#scrolledcomposite)
- [Widget Styles](#widget-styles)
Expand All @@ -280,6 +282,7 @@ Glimmer App:
- [Widget Properties](#widget-properties)
- [Color](#color)
- [Font](#font)
- [Image](#image)
- [Cursor](#cursor)
- [Layouts](#layouts)
- [Layout Data](#layout-data)
Expand All @@ -294,10 +297,10 @@ Glimmer App:
- [Observing Models](#observing-models)
- [Custom Widgets](#custom-widgets)
- [Simple Example](#simple-example)
- [Lifecycle Hook Example](#lifecycle-hook-example)
- [Custom Widget Lifecycle Hooks](#custom-widget-lifecycle-hooks)
- [Lifecycle Hooks Example](#lifecycle-hooks-example)
- [Custom Widget API](#custom-widget-api)
- [Content/Options Example](#contentoptions-example)
- [Custom Widget Lifecycle Hooks](#custom-widget-lifecycle-hooks)
- [Gotcha](#gotcha)
- [Final Notes](#final-notes)
- [Custom Shells](#custom-shells)
Expand Down Expand Up @@ -538,6 +541,7 @@ Select a Glimmer task to run: (Press ↑/↓ arrow to move, Enter to select and
glimmer package:jar # Generate JAR file
glimmer package:lock_jars # Lock JARs
glimmer package:native[type] # Generate Native files
glimmer run[app_path] # Runs Glimmer app or custom shell gem in the current directory, unless app_path is specified, then runs it instead (app_path is optional)
glimmer sample:code[name] # Outputs code for a Glimmer internal sample [included in gem] (name is required)
glimmer sample:list[query] # Lists Glimmer internal samples [included in gem]. Filters by query if specified (query is optional)
glimmer sample:run[name] # Runs a Glimmer internal sample [included in gem]. If no name is supplied, it runs all samples
Expand Down Expand Up @@ -979,7 +983,19 @@ And, here is the Windows version of the boilerplate Preferences dialog.

![Glimmer Scaffold App Windows Preferences](images/glimmer-scaffolding-app-windows-preferences.png)

In order to run the app after making changes, you must run the `glimmer` command and pass it the generated script under the `bin` directory as an argument:
In order to run the app after making changes, you must run the `glimmer run`. It automatically detects the generated run script under the `bin` directory and uses it as an argument.

```
glimmer run
```

Alternatively, to mantually run the app, you may type:

```
glimmer run[bin/greeter]
```

or:

```
glimmer bin/greeter
Expand Down
7 changes: 0 additions & 7 deletions TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,6 @@ Here is a list of tasks to do (moved to [CHANGELOG.md](CHANGELOG.md) once done).

## Next

- Remove requirement for global github user when scaffolding an app (should be needed for custom shell only). Also, halt scaffolding if it is missing for custom shell.
- Give an error message when attempting to scaffold over an already scaffolded directory
- Add ability to run app with simply `glimmer run` if inside a scaffolded app
- Update TOC

## After Next

- glimmer scaffold:web2desktop[appname,website]
- Build a mini Glimmer app to launch samples (sample of samples meta-sample)

Expand Down
2 changes: 1 addition & 1 deletion glimmer-dsl-swt.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Gem::Specification.new do |s|
s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
s.require_paths = ["lib".freeze]
s.authors = ["AndyMaleh".freeze]
s.date = "2020-10-16"
s.date = "2020-10-17"
s.description = "Glimmer DSL for SWT (JRuby Desktop Development GUI Library)".freeze
s.email = "andy.am@gmail.com".freeze
s.executables = ["glimmer".freeze, "girb".freeze]
Expand Down
14 changes: 14 additions & 0 deletions lib/glimmer/rake_task.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,20 @@ module RakeTask
require 'puts_debuggerer' if ("#{ENV['pd']}#{ENV['PD']}").to_s.downcase.include?('true')

namespace :glimmer do
desc 'Runs Glimmer app or custom shell gem in the current directory, unless app_path is specified, then runs it instead (app_path is optional)'
task :run, [:app_path] do |t, args|
require_relative 'launcher'
if args[:app_path].nil?
require 'fileutils'
current_directory_name = File.basename(FileUtils.pwd)
assumed_shell_script = File.join('.', 'bin', current_directory_name)
assumed_shell_script = Dir.glob('./bin/*').detect {|f| File.file?(f)} if !File.exist?(assumed_shell_script)
Glimmer::Launcher.new([assumed_shell_script]).launch
else
Glimmer::Launcher.new([args[:app_path]]).launch
end
end

namespace :sample do
task :requires do
require_relative 'rake_task/sample'
Expand Down
2 changes: 1 addition & 1 deletion lib/glimmer/rake_task/package.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def gemspec
end

def lock_jars
puts 'Locking gem jar-dependencies by downloading & storing in vendor/jars...'
puts 'Locking gem jar-dependencies by downloading and storing in vendor/jars...'
FileUtils.mkdir_p('vendor/jars')
command = "lock_jars --vendor-dir vendor/jars"
puts command
Expand Down
8 changes: 8 additions & 0 deletions lib/glimmer/rake_task/scaffold.rb
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,10 @@ class << self
def app(app_name)
gem_name = file_name(app_name)
gem_summary = human_name(app_name)
return puts("The directory '#{gem_name}' already exists. Please either remove or pick a different name.") if Dir.exist?(gem_name)
system "jruby -S gem install juwelier -v2.4.9 --no-document" unless juwelier_exists?
system "jruby -r git-glimmer -S juwelier --markdown --rspec --summary '#{gem_summary}' --description '#{gem_summary}' #{gem_name}"
return puts('Your Git user.name and/or github.user are missing! Please add in for Juwelier to help Glimmer with Scaffolding.') if `git config --get github.user`.strip.empty? && `git config --get user.name`.strip.empty?
cd gem_name
rm_rf 'lib'
write '.gitignore', GITIGNORE
Expand Down Expand Up @@ -181,6 +183,7 @@ def custom_shell(custom_shell_name, namespace, shell_type = nil)
namespace ||= current_dir_name
root_dir = File.exists?('app') ? 'app' : 'lib'
parent_dir = "#{root_dir}/views/#{file_name(namespace)}"
return puts("The file '#{parent_dir}/#{file_name(custom_shell_name)}.rb' already exists. Please either remove or pick a different name.") if File.exist?("#{parent_dir}/#{file_name(custom_shell_name)}.rb")
mkdir_p parent_dir unless File.exists?(parent_dir)
write "#{parent_dir}/#{file_name(custom_shell_name)}.rb", custom_shell_file(custom_shell_name, namespace, shell_type)
end
Expand All @@ -189,6 +192,7 @@ def custom_widget(custom_widget_name, namespace)
namespace ||= current_dir_name
root_dir = File.exists?('app') ? 'app' : 'lib'
parent_dir = "#{root_dir}/views/#{file_name(namespace)}"
return puts("The file '#{parent_dir}/#{file_name(custom_widget_name)}.rb' already exists. Please either remove or pick a different name.") if File.exist?("#{parent_dir}/#{file_name(custom_widget_name)}.rb")
mkdir_p parent_dir unless File.exists?(parent_dir)
write "#{parent_dir}/#{file_name(custom_widget_name)}.rb", custom_widget_file(custom_widget_name, namespace)
end
Expand All @@ -210,8 +214,10 @@ def custom_shell_gem(custom_shell_name, namespace)
return puts('Namespace is required! Usage: glimmer scaffold:gem:customshell[name,namespace]') unless `git config --get github.user`.to_s.strip == 'AndyObtiva'
namespace = 'glimmer'
end
return puts("The directory '#{gem_name}' already exists. Please either remove or pick a different name.") if Dir.exist?(gem_name)
system "jruby -S gem install juwelier -v2.4.9 --no-document" unless juwelier_exists?
system "jruby -r git-glimmer -S juwelier --markdown --rspec --summary '#{gem_summary}' --description '#{gem_summary}' #{gem_name}"
return puts('Your Git user.name and/or github.user are missing! Please add in for Juwelier to help Glimmer with Scaffolding.') if `git config --get github.user`.strip.empty? && `git config --get user.name`.strip.empty?
cd gem_name
write '.gitignore', GITIGNORE
write '.ruby-version', RUBY_VERSION
Expand Down Expand Up @@ -278,8 +284,10 @@ def custom_widget_gem(custom_widget_name, namespace)
namespace = 'glimmer'
end

return puts("The directory '#{gem_name}' already exists. Please either remove or pick a different name.") if Dir.exist?(gem_name)
system "jruby -S gem install juwelier -v2.4.9 --no-document" unless juwelier_exists?
system "jruby -r git-glimmer -S juwelier --markdown --rspec --summary '#{gem_summary}' --description '#{gem_summary}' #{gem_name}"
return puts('Your Git user.name and/or github.user are missing! Please add in for Juwelier to help Glimmer with Scaffolding.') if `git config --get github.user`.strip.empty? && `git config --get user.name`.strip.empty?
cd gem_name
write '.gitignore', GITIGNORE
write '.ruby-version', RUBY_VERSION
Expand Down

0 comments on commit f2516b0

Please sign in to comment.