# Standard Rake Install/Uninstall Tasks for Extensions

**URL:** <https://www.ruby-forum.com/t/standard-rake-install-uninstall-tasks-for-extensions/125544>\
**Category:** Radiant CMS\
**Created:** [January 10, 2008, 2:07am UTC](https://www.ruby-forum.com/t/standard-rake-install-uninstall-tasks-for-extensions/125544 "2008-01-10T02:07:14Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mario\_TSL](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/df705f/32.png) [@Mario\_TSL](https://www.ruby-forum.com/u/Mario_TSL)\
**Post date:** [January 10, 2008, 2:07am UTC](https://www.ruby-forum.com/t/standard-rake-install-uninstall-tasks-for-extensions/125544/1 "2008-01-10T02:07:14Z")

</div>

I considered adding a recommendation to the Creating Extensions  
Tutorial, but not wanting to offend, I thought I might run the idea past  
people first.

I’m wondering if developers think it’s useful to have standard rake  
tasks for installing/uninstalling extensions. For example:

:radiant:extensions:my\_fancy\_ext:install  
:radiant:extensions:my\_fancy\_ext:uninstall

I thought it might be nice if we always have these two tasks and those  
tasks perform all of the necessary subtasks. Might even have the  
generate Extension task set these up by default and reports “Not  
implemented” until implemented.

Granted, people can continue to do it their own way, but I thought why  
not at least offer a recommendation.

Silly idea?

---

<div class="post-metadata">

**Author:** ![Mario\_TSL](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/df705f/32.png) [@Mario\_TSL](https://www.ruby-forum.com/u/Mario_TSL)\
**Post date:** [January 10, 2008, 10:19pm UTC](https://www.ruby-forum.com/t/standard-rake-install-uninstall-tasks-for-extensions/125544/2 "2008-01-10T22:19:01Z")

</div>

> I’m wondering if developers think it’s useful to have standard rake  
> tasks for installing/uninstalling extensions. For example:
> 
> :radiant:extensions:my\_fancy\_ext:install  
> :radiant:extensions:my\_fancy\_ext:uninstall

> I thought it might be nice if we always have these two tasks and those  
> tasks perform all of the necessary subtasks. Might even have the  
> generate Extension task set these up by default and reports “Not  
> implemented” until implemented.
> 
> Granted, people can continue to do it their own way, but I thought why  
> not at least offer a recommendation.
> 
> Silly idea?

It’s a good idea for me! I usually use install task for my extensions.  
It  
should be easier if everybody use the same task names.

–  
Andrea F.  
[http://gravityblast.com](http://gravityblast.com) - [http://nimboo.net](http://nimboo.net)

---

<div class="post-metadata">

**Author:** ![Mario\_TSL](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/df705f/32.png) [@Mario\_TSL](https://www.ruby-forum.com/u/Mario_TSL)\
**Post date:** [January 11, 2008, 1:15am UTC](https://www.ruby-forum.com/t/standard-rake-install-uninstall-tasks-for-extensions/125544/3 "2008-01-11T01:15:22Z")

</div>

Added a tiny section called “Standard Rake Tasks” to:  
[http://wiki.radiantcms.org/Creating\_Radiant\_Extensions](http://wiki.radiantcms.org/Creating_Radiant_Extensions)

---

<div class="post-metadata">

**Author:** ![Mario\_TSL](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/df705f/32.png) [@Mario\_TSL](https://www.ruby-forum.com/u/Mario_TSL)\
**Post date:** [January 11, 2008, 2:01am UTC](https://www.ruby-forum.com/t/standard-rake-install-uninstall-tasks-for-extensions/125544/4 "2008-01-11T02:01:46Z")

</div>

On 1/10/08, Mario T. Lanza [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Added a tiny section called “Standard Rake Tasks” to:  
> [http://wiki.radiantcms.org/Creating\_Radiant\_Extensions](http://wiki.radiantcms.org/Creating_Radiant_Extensions)

Perhaps that should be put at the bottom in an Additional Notes  
section? Or even better truly work it into the tutorial by adding an  
code examples and screenshots.

–  
John L.  
[http://wiseheartdesign.com](http://wiseheartdesign.com)

---

<div class="post-metadata">

**Author:** ![Mario\_TSL](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/df705f/32.png) [@Mario\_TSL](https://www.ruby-forum.com/u/Mario_TSL)\
**Post date:** [January 11, 2008, 3:17pm UTC](https://www.ruby-forum.com/t/standard-rake-install-uninstall-tasks-for-extensions/125544/5 "2008-01-11T15:17:07Z")

</div>

On Jan 10, 2008 8:01 PM, John L. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> On 1/10/08, Mario T. Lanza [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:
> 
> > Added a tiny section called “Standard Rake Tasks” to:  
> > [http://wiki.radiantcms.org/Creating\_Radiant\_Extensions](http://wiki.radiantcms.org/Creating_Radiant_Extensions)

Why not put those tasks in the generated Rakefile and just have them  
do nothing by default?

We could also make assets/{javascripts,stylesheets,images} directories  
and have the install task copy files from those directories to their  
counterparts in public by default (but should not overwrite something  
already there, probably).

-todd[1]

---

<div class="post-metadata">

**Author:** ![Mario\_TSL](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/df705f/32.png) [@Mario\_TSL](https://www.ruby-forum.com/u/Mario_TSL)\
**Post date:** [January 11, 2008, 3:44pm UTC](https://www.ruby-forum.com/t/standard-rake-install-uninstall-tasks-for-extensions/125544/6 "2008-01-11T15:44:06Z")

</div>

I’ve kind of kept out of this discussion so far, but there does exist an  
‘update’ task that is generated for new extensions since 0.6.3 (I  
believe). It copies files from the extension’s public folder to the  
project/instance public folder. However, there is no reverse operation  
for it currently. I imagine the tasks might look something like this  
(cleanup would be the reverse of update):

task :install =\> [:migrate, :update]

task :uninstall =\> :cleanup do  
ENV[‘VERSION’] = 0  
migrate  
end

Sean

---

<div class="post-metadata">

**Author:** ![Mario\_TSL](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/df705f/32.png) [@Mario\_TSL](https://www.ruby-forum.com/u/Mario_TSL)\
**Post date:** [January 11, 2008, 6:47pm UTC](https://www.ruby-forum.com/t/standard-rake-install-uninstall-tasks-for-extensions/125544/7 "2008-01-11T18:47:42Z")

</div>

Sean C. wrote:

> ENV[‘VERSION’] = 0  
> migrate  
> end

I’ve used the built-in rake ‘update’ task and was wondering how it was  
different from the ‘install’ being proposed here. You’re right Sean,  
they’re really asking for both:  
rake production radiant:extensions:my\_extension\_name:update and,  
rake production radiant:extensions:lmy\_extension\_name:migrate

However, what is also being asked here but can get sticky is an  
‘un-update’ task which, at this point, doesn’t exist. IMHO, it should  
do the following:

```
* Take an inventory of all the files in the extension's public
  folders that would be copied by the 'update' task.
* Look for those files in the application's public folders and:
      o If they exist and are an exact (binary) match, delete them
      o If they are exist but are different (same name, different
        file), leave them alone
      o If they don't exist, do nothing.
* Spit out a report showing which files were deleted, which weren't
  and why, and which were expected but missing.

```

That way people could update a css file or change a jpeg that came with  
their extension and not have to worry that uninstalling would erase  
their work. But I’m not sure what ruby offers to aid in performing a  
diff-check against two files, though. Ideas anyone?

-Chris

---

<div class="post-metadata">

**Author:** ![Mario\_TSL](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/df705f/32.png) [@Mario\_TSL](https://www.ruby-forum.com/u/Mario_TSL)\
**Post date:** [January 11, 2008, 7:30pm UTC](https://www.ruby-forum.com/t/standard-rake-install-uninstall-tasks-for-extensions/125544/8 "2008-01-11T19:30:40Z")

</div>

If you (anyone in this thread) want this, please implement it, test it  
and submit a patch.

Sean

---

<div class="post-metadata">

**Author:** ![Mario\_TSL](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/df705f/32.png) [@Mario\_TSL](https://www.ruby-forum.com/u/Mario_TSL)\
**Post date:** [January 11, 2008, 7:00pm UTC](https://www.ruby-forum.com/t/standard-rake-install-uninstall-tasks-for-extensions/125544/9 "2008-01-11T19:00:05Z")

</div>

Maybe we can use a standard way to organize files for each  
extension.Something  
like:

public/images/extensions/newsletter/ (here all images added by the  
newsletter extension)  
public/stylesheets/extensions/newsletter/ (here all css added by the  
newsletter extension)  
public/javascripts/extensions/newsletter/ (here all js added by the  
newsletter extension)

It could be easier to remove files. What do you think about it?

On Jan 11, 2008 6:46 PM, Chris P. \<  
removed\_email\_address@domain.invalid\> wrote:

> > task :uninstall =\> :cleanup do  
> > However, what is also being asked here but can get sticky is an
> 
> - Spit out a report showing which files were deleted, which weren’t  
> Post: removed\_email\_address@domain.invalid  
> Search: [http://radiantcms.org/mailing-list/search/](http://radiantcms.org/mailing-list/search/)  
> Site: [http://lists.radiantcms.org/mailman/listinfo/radiant](http://lists.radiantcms.org/mailman/listinfo/radiant)

–  
Andrea F.  
[http://gravityblast.com](http://gravityblast.com) - [http://nimboo.net](http://nimboo.net)

---

<div class="post-metadata">

**Author:** ![Mario\_TSL](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/df705f/32.png) [@Mario\_TSL](https://www.ruby-forum.com/u/Mario_TSL)\
**Post date:** [January 12, 2008, 2:07am UTC](https://www.ruby-forum.com/t/standard-rake-install-uninstall-tasks-for-extensions/125544/10 "2008-01-12T02:07:58Z")

</div>

> Why not put those tasks in the generated Rakefile and just have them  
> do nothing by default?

My sentiment exactly.

---

<div class="post-metadata">

**Author:** ![Mario\_TSL](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/df705f/32.png) [@Mario\_TSL](https://www.ruby-forum.com/u/Mario_TSL)\
**Post date:** [January 12, 2008, 2:07am UTC](https://www.ruby-forum.com/t/standard-rake-install-uninstall-tasks-for-extensions/125544/11 "2008-01-12T02:07:06Z")

</div>

> task :install =\> [:migrate, :update]
> 
> task :uninstall =\> :cleanup do  
> ENV[‘VERSION’] = 0  
> migrate  
> end

Additionally, the cleanup should handle removing the files copied to  
public. If the files are indeed copied and not moved, then  
programmatically reversing this should be a cinch. Use the original  
files in the extension directory to locate their public counterpart and  
delete them if the size and timestamp match.
