staticky 0.1.1 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (41) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +9 -0
  3. data/README.md +364 -17
  4. data/lib/staticky/application.rb +36 -0
  5. data/lib/staticky/builder.rb +1 -1
  6. data/lib/staticky/cli/commands/build.rb +13 -0
  7. data/lib/staticky/cli/commands/generate.rb +67 -0
  8. data/lib/staticky/cli/commands/version.rb +13 -0
  9. data/lib/staticky/cli/commands.rb +13 -0
  10. data/lib/staticky/cli.rb +0 -60
  11. data/lib/staticky/deps.rb +1 -1
  12. data/lib/staticky/filesystem.rb +0 -3
  13. data/lib/staticky/phlex/view_helpers.rb +6 -2
  14. data/lib/staticky/pluggable.rb +35 -0
  15. data/lib/staticky/resource.rb +14 -15
  16. data/lib/staticky/resources/plugins/phlex.rb +42 -0
  17. data/lib/staticky/resources/plugins/prelude.rb +74 -0
  18. data/lib/staticky/resources/plugins.rb +9 -0
  19. data/lib/staticky/router.rb +13 -18
  20. data/lib/staticky/routing/plugins/prelude.rb +97 -0
  21. data/lib/staticky/routing/plugins.rb +9 -0
  22. data/lib/staticky/server.rb +1 -1
  23. data/lib/staticky/version.rb +1 -1
  24. data/lib/staticky.rb +20 -10
  25. data/site_template/.gitignore +14 -0
  26. data/site_template/.ruby-version +1 -1
  27. data/site_template/Gemfile +4 -3
  28. data/site_template/Procfile.dev +2 -2
  29. data/site_template/README.md +27 -7
  30. data/site_template/Rakefile +31 -2
  31. data/site_template/app/views/layouts/site.rb +2 -2
  32. data/site_template/bin/{lint → setup} +8 -2
  33. data/site_template/config/puma.rb +11 -0
  34. data/site_template/config/staticky.rb +2 -0
  35. data/site_template/lib/icon.rb +1 -1
  36. data/site_template/package.json +1 -1
  37. data/site_template/vite.config.ts +1 -1
  38. metadata +44 -7
  39. data/lib/staticky/container.rb +0 -26
  40. data/lib/staticky/router/definition.rb +0 -49
  41. data/lib/staticky/view_context.rb +0 -17
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 601e3b52395f847f7f7f57909a0063f83063dc0cf5bd02ef21e865d972f3322f
4
- data.tar.gz: 7d8ecdd8e166359930743d01e2c955dc521a4f9d1b231d239d35aa45858cc003
3
+ metadata.gz: 015d7c615ec3f67937c4c6a7c26d4818f394386f8a3bc6b2b10bb834f1759fb8
4
+ data.tar.gz: 6e2a25655085984a6e37ace773f55a8ccfd8ffc702de127f1ec8748df391db13
5
5
  SHA512:
6
- metadata.gz: c1b21ab89e9d6429b3cd3407ae84802c1739e68aa39c969f10c0d82e28ad3cdf187cd1bedcf98a22805fbe9de64c3be96d711f4f554c5addf55c744bcd11b9a6
7
- data.tar.gz: 3695cab76d925bec1ba6e02852ac63a088c88cd2d2fb9e3942c5e33f0ef8aefb19d6c643c6e2ade7d63b438dba6d954a351efaba86939ac4ac5e56be73652343
6
+ metadata.gz: ed18ccdf8f86c13249e5fbc17971ac0b5155a3d15c3760e9308c941892c9f7f488363e5d8a858ad26c67345eb7477ca7c4f2955b35d2b3fc227b5f96f1e16c15
7
+ data.tar.gz: '09147233cded8c538c9b2e2f86c917c94b1c8c9afc5b028cebc482c364c8586fd4efeee2157bb29cccdb7cfdcca7dda8beb6ef027aea7507b94bdf069ee1ab9b'
data/CHANGELOG.md CHANGED
@@ -1,5 +1,14 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [0.2.0] - 2024-09-24
4
+
5
+ - Adds plugin system akin to Roda and Sequel for `Resource` and `Router`
6
+ - Improves initial setup
7
+ - Adds better documentation
8
+ - Switches from `rerun` to `filewatcher` for triggering rebuilds
9
+ - Switches from `rackup` to `puma` for development server
10
+ - Updates default package manager to yarn stable
11
+
3
12
  ## [0.1.1] - 2024-08-18
4
13
 
5
14
  - Fixes nginx and Dockerfile configs for default dokku deployments
data/README.md CHANGED
@@ -36,14 +36,151 @@ staticky new my_blog --url "https://example.com"
36
36
  This will generate a new site at `./my_blog`, install your dependencies and run
37
37
  `rspec` just to make sure everything got set up correctly.
38
38
 
39
+ You can append `--help` to any commands to see info:
40
+
41
+ ```
42
+ staticky new --help
43
+ ```
44
+
45
+ Which outputs:
46
+
47
+ ```
48
+ Command:
49
+ staticky new
50
+
51
+ Usage:
52
+ staticky new PATH
53
+
54
+ Description:
55
+ Create new site
56
+
57
+ Arguments:
58
+ PATH # REQUIRED Relative path where the site will be generated
59
+
60
+ Options:
61
+ --url=VALUE, -u VALUE # Site URL, default: "https://example.com"
62
+ --title=VALUE, -t VALUE # Site title, default: "Example"
63
+ --description=VALUE, -d VALUE # Site description, default: "Example site"
64
+ --twitter=VALUE, -t VALUE # Twitter handle, default: ""
65
+ --help, -h # Print this help
66
+ ```
67
+
68
+ ### Plugins
69
+
70
+ The router and resources use the plugin
71
+ [pattern](https://janko.io/the-plugin-system-of-sequel-and-roda/)
72
+ found in [Sequel](https://github.com/jeremyevans/sequel) and
73
+ [Roda](https://github.com/jeremyevans/roda).
74
+
75
+ This means you can easily extend each of them with plugins to fit the specific
76
+ content of your site.
77
+
78
+ ```ruby
79
+ module MyResourcePlugin
80
+ module InstanceMethods
81
+ def component=(component)
82
+ @component = component
83
+ end
84
+
85
+ def component
86
+ return @component if defined?(@component)
87
+
88
+ raise ArgumentError, "component is required"
89
+ end
90
+ end
91
+ end
92
+ ```
93
+
94
+ In our own classes we can now reference our new plugin:
95
+
96
+ ```ruby
97
+ class SomeResource < Staticky::Resource
98
+ plugin MyResourcePlugin
99
+ end
100
+ ```
101
+
102
+ Or, if we register the plugin with `register_plugin` we can just use our
103
+ shorter symbol:
104
+
105
+ ```ruby
106
+ Staticky::Resources::Plugins.register_plugin(:something, MyResourcePlugin)
107
+
108
+ class SomeResource < Staticky::Resource
109
+ plugin :something
110
+ end
111
+ ```
112
+
113
+ This system lets you define your own specific resources by subclassing and
114
+ extending with your own plugins.
115
+
116
+ Here is an example of hooking into the output of the component
117
+ (a string of HTML):
118
+
119
+ ```ruby
120
+ module MinifyHTML
121
+ module InstanceMethods
122
+ # Calling super works because the base class has no methods, everything is
123
+ # a plugin including the core behavior of a resource.
124
+ def build
125
+ SomehowMinifyTheHTML.call(super)
126
+ end
127
+ end
128
+ end
129
+
130
+ Staticky::Resources::Plugins.register_plugin(:minify_html, MinifyHTML)
131
+
132
+ class ApplicationResource < Staticky::Resource
133
+ plugin :minify_html
134
+ end
135
+ ```
136
+
137
+ Now when an `ApplicationResource` gets rendered, its final output (a string of
138
+ HTML) will be minified.
139
+
140
+ Each plugin can define modules for:
141
+
142
+ |Name|Description|
143
+ |----|-----------|
144
+ |InstanceMethods|Get added as instance methods of the Resource|
145
+ |ClassMethods|Get added as the class methods of the Resource|
146
+
147
+ In addition you have methods you can define that let you hook into the resource
148
+ that adds your plugins:
149
+
150
+ |Name|Description|
151
+ |----|-----------|
152
+ |load_dependencies(plugin, ...)|Hook to load any other plugins required by this one|
153
+ |configure(plugin, ...)|Hook for additional setup required on the class|
154
+
155
+
156
+ ### Routing
157
+
158
+ Your router is a plugin system that by default only has one plugin:
159
+
160
+ ```ruby
161
+ plugin :prelude
162
+ ```
163
+
164
+ This gives you the `match` and `root` methods in your router. You can override
165
+ or extend these methods yourself by redefining them (and optionally calling
166
+ `super`) inside your own plugin or class that inherits from the router.
167
+
39
168
  Once your site is generated you can use the router to define how your content
40
169
  maps to routes in `config/routes.rb`:
41
170
 
42
171
  ```ruby
43
172
  Staticky.router.define do
44
173
  root to: Pages::Home
174
+
175
+ # We can pass in a phlex class
45
176
  match "404", to: Errors::NotFound
46
- match "500", to: Errors::ServiceError
177
+ # Or an instance
178
+ match "500", to: Errors::ServiceError.new
179
+
180
+ # We can specify the resource type
181
+ match "about",
182
+ to: Markdown.new("content/posts/about.md"),
183
+ as: Resources::Markdown
47
184
 
48
185
  # Write your own logic to parse your data into components
49
186
  Site.posts.each_value do |model|
@@ -56,13 +193,139 @@ Each route takes a Phlex component (or any object that outputs a string from
56
193
  `#call`). We can either pass the class for a default initialization (we just
57
194
  call `.new`) or initialize it ourselves.
58
195
 
196
+ The resource will be initialized with a `component` and a `url`. It is used as
197
+ the view context for your phlex components.
198
+
199
+ #### Match
200
+
201
+ This works in a similar way to your Rails routes. Match takes a path and
202
+ a component (either a class or an instance) that it will route to.
203
+
204
+ ```ruby
205
+ match "404", to: Errors::NotFound, as: Resource
206
+ ```
207
+
208
+ #### Root
209
+
210
+ Using `match` you can define a root path like:
211
+
212
+ ```ruby
213
+ match "/", to: Pages::Home
214
+ ```
215
+
216
+ For convenience you can shorten this using `root`:
217
+
218
+ ```ruby
219
+ root to: Pages::Home
220
+ ```
221
+
222
+ ### Resources
223
+
224
+ They initialize the same way `ActiveModel` objects do. That is they take their
225
+ keywords and call the setter according to the keys:
226
+
227
+ ```ruby
228
+ def new(**env)
229
+ super().tap do |resource|
230
+ env.each do |key, value|
231
+ resource.send(:"#{key}=", value)
232
+ end
233
+ end
234
+ end
235
+ ```
236
+
237
+ The base resource has two core plugins it includes by default:
238
+
239
+ ```ruby
240
+ plugin :prelude
241
+ plugin :phlex
242
+ ```
243
+
244
+ Routes define your resources, which in the end are just data objects that
245
+ contain all the information required to produce the static file that eventually
246
+ outputs to your `Staticky.build_path`.
247
+
248
+ Lets say we had a router defined like:
249
+
250
+ ```ruby
251
+ Staticky.router.define do
252
+ match "foo", to: Component
253
+ match "bar", to: Component
254
+ end
255
+ ```
256
+
257
+ Then we could view our resources:
258
+
259
+ ```
260
+ (ruby) Staticky.resources
261
+ [#<Staticky::Resource:0x0000711525d82c18
262
+ @component=#<Component:0x0000711525d74848>,
263
+ @destination=#<Pathname:/your-site-folder/build>,
264
+ @uri=#<URI::Generic /foo>,
265
+ @url="foo">,
266
+ #<Staticky::Resource:0x0000711525d82a88
267
+ @component=#<Component:0x0000711525d74208>,
268
+ @destination=#<Pathname:/your-site-folder/build>,
269
+ @uri=#<URI::Generic /bar>,
270
+ @url="bar">]
271
+ ```
272
+
273
+ The `prelude` plugin provides the following methods:
274
+
275
+ |Method|Description|
276
+ |------|-----------|
277
+ |`filepath`|`Pathname` of where the component's output will be written to|
278
+ |`read`|Read the output of the resource from the file system|
279
+ |`basename`|The file basename (e.g. `index.html`) for the resource|
280
+ |`root?`|Whether or not the resource is the root path|
281
+
282
+ While the `phlex` plugin provides:
283
+
284
+ |Method|Description|
285
+ |------|-----------|
286
+ |`build`|Call the component and output its result as a string|
287
+
288
+ These resources are used by your site builder to output the files that end up in
289
+ the `Staticky.build_path`.
290
+
291
+ Each resource needs to have a `#build` method that creates a file in your build
292
+ folder.
293
+
294
+ The `phlex` plugin will call your components with a `ViewContext` just like
295
+ `ActionView` in Rails. But this context is tailored towards your static site.
296
+
297
+ This view context is a `SimpleDelegator` to your resource with a few extra
298
+ methods:
299
+
300
+ |Method|Description|
301
+ |------|-----------|
302
+ |`root?`|Whether or not this resource is for the root page|
303
+ |`current_path`|The path of the current resource being rendered|
304
+
305
+ These are useful for creating pages that hide or show content depending on which
306
+ path of the site we are building.
307
+
308
+ ### Linking to your routes
309
+
310
+ First you need to include the view helpers somewhere in your component
311
+ hierarchy:
312
+
313
+ ```ruby
314
+ class Component < Phlex::HTML
315
+ include Staticky::Phlex::ViewHelpers
316
+ end
317
+ ```
318
+
319
+ This will add `link_to` to all your components which uses the router to resolve
320
+ any URLs via their path.
321
+
59
322
  Here is an example of what the `Posts::Show` component might look like. We are
60
323
  using a [protos](https://github.com/inhouse-work/protos) component, but you can
61
324
  use plain old Phlex components if you like.
62
325
 
63
326
  ```ruby
64
327
  module Posts
65
- class Show < Protos::Component
328
+ class Show < Component
66
329
  param :post, reader: false
67
330
 
68
331
  def around_template(&)
@@ -70,7 +333,12 @@ module Posts
70
333
  end
71
334
 
72
335
  def view_template
73
- link_to "Home", "/"
336
+ # Links can be resolved to component classes if they are unique:
337
+ link_to "Home", Pages::Home
338
+ # They can also resolve via their url:
339
+ link_to "Posts", "/posts"
340
+ # Absolute links are resolved as is:
341
+ link_to "Email", "mailto:email@example.com"
74
342
 
75
343
  render Posts::Header.new(@post)
76
344
  render Posts::Outline.new(@post, class: css[:outline])
@@ -82,28 +350,37 @@ module Posts
82
350
 
83
351
  def theme
84
352
  {
85
- layout: "mr-0 lg:mr-[--sidebar-width] md:ml-[--sidebar-width]",
86
- outline: %w[
87
- my-md
88
- md:fixed
89
- md:left-0
90
- md:top-[--navbar-height]
91
- md:pl-[--viewport-padding]
92
- md:w-[--sidebar-width]
93
- ],
94
- post: "prose mx-auto pb-lg"
353
+ layout: "bg-background",
354
+ outline: "border",
355
+ post: "max-w-prose mx-auto"
95
356
  }
96
357
  end
97
358
  end
98
359
  end
99
360
  ```
100
361
 
101
- We get `link_to` from the `Staticky::Phlex::ViewHelpers` which resolves either
102
- a URL or a phlex class from your router.
362
+ The advantage of using `link_to` over plain old `a` tags is that changes to your
363
+ routes will raise errors on invalidated links instead of silently
364
+ linking to invalid pages.
365
+
366
+ If your component is unique then you can link directly to them (if its not
367
+ unique then it will link to the last defined `match`):
368
+
369
+ ```ruby
370
+ link_to("Some link", Pages::Home)
371
+ ```
372
+
373
+ Otherwise you can link to the path itself:
374
+
375
+ ```ruby
376
+ link_to("Some link", "/")
377
+ ```
378
+
379
+ ### Building your site
103
380
 
104
381
  When you are developing your site you run `bin/dev` to start your development
105
- server on http://localhost:9292. This will automatically reload after a short
106
- period when you make changes.
382
+ server on [http://localhost:9292](http://localhost:9292).
383
+ This will automatically reload after a short period when you make changes.
107
384
 
108
385
  Assets are handled by Vite by default, but you can have whatever build process
109
386
  you like just by tweaking `Procfile.dev` and your `Rakefile`. You will also need
@@ -155,6 +432,76 @@ Staticky.configure do |config|
155
432
  end
156
433
  ```
157
434
 
435
+ ### Environment
436
+
437
+ You can define the environment of Staticky through its config.
438
+
439
+ ```ruby
440
+ Staticky.configure do |config|
441
+ config.env = :test
442
+ end
443
+ ```
444
+
445
+ This lets you write environment specific code:
446
+
447
+ ```ruby
448
+ if Staticky.env.test?
449
+ # Do something test specific
450
+ end
451
+ ```
452
+
453
+ ## Testing
454
+
455
+ We can setup a separate testing environment by putting the following
456
+ into your `spec/spec_helper.rb`:
457
+
458
+ ```ruby
459
+ Staticky.configure do |config|
460
+ config.root_path = Pathname.new(__dir__).join("fixtures")
461
+ config.build_path = Pathname.new(__dir__).join("fixtures/build")
462
+ config.env = :test
463
+ end
464
+ ```
465
+
466
+ This sets up our build path to something different than our development builds.
467
+
468
+ Staticky uses `Dry::System` to manage its dependencies which means you can stub
469
+ them out if you want:
470
+
471
+ ```ruby
472
+ require "dry/system/stubs"
473
+
474
+ Staticky.application.enable_stubs!
475
+
476
+ RSpec.configure do |config|
477
+ config.before do
478
+ Staticky.application.stub(:files, Staticky::Filesystem.test)
479
+ end
480
+ end
481
+ ```
482
+
483
+ This lets you test your builds using `dry-files` (actually `staticky-files`, but
484
+ the interface is the same with additional capabilities for file folders).
485
+
486
+ The advantage of this is that we can perform our builds on a temporary in memory
487
+ file system rather than actually writing to our disk.
488
+
489
+ The plugins themselves can also be stubbed:
490
+
491
+ ```ruby
492
+ require "dry/system/stubs"
493
+
494
+ Staticky::Resources::Plugins.enable_stubs!
495
+ Staticky::Routing::Plugins.enable_stubs!
496
+
497
+ RSpec.configure do |config|
498
+ config.before do
499
+ Staticky::Resources::Plugins.stub(:prelude, MyOwnResourcePlugin)
500
+ Staticky::Routing::Plugins.stub(:prelude, MyOwnRoutingPlugin)
501
+ end
502
+ end
503
+ ```
504
+
158
505
  ## Development
159
506
 
160
507
  After checking out the repo, run `bin/setup` to install dependencies. Then, run
@@ -0,0 +1,36 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Staticky
4
+ class Application < Dry::System::Container
5
+ # This class coordinates the booting process to add our dependencies.
6
+ # We use zeitwerk to autoload our constants in the lib/staticky folder.
7
+ #
8
+ # Monitoring is enabled to hook into calls to certain dependencies.
9
+ #
10
+ # ```ruby
11
+ # Staticky.application.monitor(:builder, methods: %i[call]) do |event|
12
+ # Staticky.logger.info "Built site in #{event[:time]}ms"
13
+ # end
14
+ # ```
15
+
16
+ use :zeitwerk
17
+ use :monitoring
18
+
19
+ configure do |config|
20
+ config.root = Pathname(__dir__).join("..").join("..")
21
+ config.inflector = Dry::Inflector.new do |inflections|
22
+ inflections.acronym("CLI")
23
+ end
24
+ config.component_dirs.add "lib" do |dir|
25
+ dir.add_to_load_path = false
26
+ dir.auto_register = false
27
+ dir.namespaces.add "staticky", key: nil
28
+ end
29
+ end
30
+
31
+ register(:files, memoize: true) { Staticky::Filesystem.real }
32
+ register(:router, memoize: true) { Staticky::Router.new }
33
+ register(:builder, memoize: true) { Staticky::Builder.new }
34
+ register(:generator) { Staticky::Generator.new }
35
+ end
36
+ end
@@ -28,7 +28,7 @@ module Staticky
28
28
  .resources
29
29
  .each do |resource|
30
30
  publish("before_resource", resource:)
31
- compile output_path(resource.filepath), resource.build
31
+ compile resource.filepath, resource.build
32
32
  publish("after_resource", resource:)
33
33
  end
34
34
  end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Staticky
4
+ module CLI
5
+ module Commands
6
+ class Build < Dry::CLI::Command
7
+ desc "Build site"
8
+
9
+ def call(*) = Staticky.builder.call
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,67 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Staticky
4
+ module CLI
5
+ module Commands
6
+ class Generate < Dry::CLI::Command
7
+ desc "Create new site"
8
+
9
+ argument :path,
10
+ required: true,
11
+ desc: "Relative path where the site will be generated"
12
+
13
+ option :url,
14
+ default: "https://example.com",
15
+ desc: "Site URL",
16
+ aliases: ["-u"]
17
+ option :title,
18
+ default: "Example",
19
+ desc: "Site title",
20
+ aliases: ["-t"]
21
+ option :description,
22
+ default: "Example site",
23
+ desc: "Site description",
24
+ aliases: ["-d"]
25
+ option :twitter,
26
+ default: "",
27
+ desc: "Twitter handle",
28
+ aliases: ["-t"]
29
+
30
+ def call(path:, **)
31
+ path = Pathname.new(path).expand_path
32
+
33
+ Staticky.generator.call(path, **)
34
+
35
+ Dir.chdir(path) do
36
+ system("cd #{path}")
37
+ system("chmod +x bin/*")
38
+ bundle_command("install")
39
+ bundle_command("exec bin/setup")
40
+ end
41
+ end
42
+
43
+ def bundle_command(command, env = {})
44
+ puts "bundle #{command}"
45
+
46
+ # We are going to shell out rather than invoking Bundler::CLI.new(command)
47
+ # because `rails new` loads the Thor gem and on the other hand bundler uses
48
+ # its own vendored Thor, which could be a different version. Running both
49
+ # things in the same process is a recipe for a night with paracetamol.
50
+ #
51
+ # Thanks to James Tucker for the Gem tricks involved in this call.
52
+ _bundle_command = Gem.bin_path("bundler", "bundle")
53
+
54
+ require "bundler"
55
+ Bundler.with_original_env do
56
+ exec_bundle_command(_bundle_command, command, env)
57
+ end
58
+ end
59
+
60
+ def exec_bundle_command(bundle_command, command, env)
61
+ full_command = %("#{Gem.ruby}" "#{bundle_command}" #{command})
62
+ system(env, full_command)
63
+ end
64
+ end
65
+ end
66
+ end
67
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Staticky
4
+ module CLI
5
+ module Commands
6
+ class Version < Dry::CLI::Command
7
+ desc "Print version"
8
+
9
+ def call(*) = puts VERSION
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Staticky
4
+ module CLI
5
+ module Commands
6
+ extend Dry::CLI::Registry
7
+
8
+ register "version", Version
9
+ register "build", Build
10
+ register "new", Generate
11
+ end
12
+ end
13
+ end
data/lib/staticky/cli.rb CHANGED
@@ -4,66 +4,6 @@ require "dry/cli"
4
4
 
5
5
  module Staticky
6
6
  module CLI
7
- module Commands
8
- extend Dry::CLI::Registry
9
-
10
- class Version < Dry::CLI::Command
11
- desc "Print version"
12
-
13
- def call(*) = puts VERSION
14
- end
15
-
16
- class Build < Dry::CLI::Command
17
- desc "Build site"
18
-
19
- def call(*) = Staticky.builder.call
20
- end
21
-
22
- class Generate < Dry::CLI::Command
23
- desc "Create new site"
24
-
25
- argument :path,
26
- required: true,
27
- desc: "Relative path where the site will be generated"
28
-
29
- option :url,
30
- default: "https://example.com",
31
- desc: "Site URL",
32
- aliases: ["-u"]
33
- option :title,
34
- default: "Example",
35
- desc: "Site title",
36
- aliases: ["-t"]
37
- option :description,
38
- default: "Example site",
39
- desc: "Site description",
40
- aliases: ["-d"]
41
- option :twitter,
42
- default: "",
43
- desc: "Twitter handle",
44
- aliases: ["-t"]
45
-
46
- def call(path:, **)
47
- path = Pathname.new(path).expand_path
48
-
49
- Staticky.generator.call(path, **)
50
-
51
- commands = [
52
- "bundle install",
53
- "bundle binstubs bundler rake rspec-core vite_ruby",
54
- "yarn install",
55
- "bin/rspec"
56
- ].join(" && ")
57
-
58
- system(commands, chdir: path) || abort("install failed")
59
- end
60
- end
61
-
62
- register "version", Version
63
- register "build", Build
64
- register "new", Generate
65
- end
66
-
67
7
  def self.new(...)
68
8
  Dry::CLI.new(Commands)
69
9
  end
data/lib/staticky/deps.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Staticky
4
- Deps = Container.injector
4
+ Deps = Application.injector
5
5
  end
@@ -1,8 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "delegate"
4
- require "staticky-files"
5
-
6
3
  module Staticky
7
4
  class Filesystem < SimpleDelegator
8
5
  def self.test