marionettejs / marionette.upgrade Goto Github PK
View Code? Open in Web Editor NEWHelps you upgrade your marionette apps from 1.x :arrow_right: 2.x
Helps you upgrade your marionette apps from 1.x :arrow_right: 2.x
upgrade.py
add import os
rom os import *
import os
import sys
change the command line
from
codemod = "./bin/codemod.py"
to
codemod = "python %s" % os.path.join(os.path.dirname(os.path.abspath(__file__)), "bin", "codemod.py")
bin/codemod.py
comment line 745
# sys.stdout.write(curses.tigetstr('sgr0'))
goto http://www.lfd.uci.edu/~gohlke/pythonlibs/#curses
download and install
workaround to codemod issue: facebookarchive/codemod#32
open cmd
cd your project to upgrade
run script
python c:\Marionette.Upgrade\upgrade.py .\
upgrade.py wants to replace a call to jQuery's $.fn.closest
with destroyst
. It appears to be finding the "close" substring and trying to replace with "destroy".
isInteractive: ($target) ->
- $target.closest('.actions').length or $target.is('.close')
+ $target.destroyst('.actions').length or $target.is('.close')
showThumbnail: ->
Potentially related: #21
OS X - Python 2.7.5
Traceback (most recent call last):
File "upgrade.py", line 1, in <module>
from sub import *
ImportError: No module named sub
If I run the script multiple times it tries to replace "LayoutView" with "LayoutViewView". That should be easy to prevent.
Ran my project through the upgrader and besides the region.close/empty issue others have noted this seemed to be the only function that the upgrader missed.
Like git add -p
, an option to skip a whole file with d
would be awesome.
All in all, the best upgrading experience I ever had :)
for code in which a view has a method to close (now destroy itself), the coffeescript might have looked like:
goAway: ->
@close()
and upgrade.py proposes to replace this with:
goAway: ->
.destroy()
rather than:
goAway: ->
@destroy()
Hi, I was able to successfully upgrade a project to Marionette 2.0.1 in Linux but I'm having problems with a similar project in my Windows7 environment.
Windows7 seems to be having problems with the print statement in line #27
I installed Python 2.7.8
I've tried both the DOS cmd console and the git/bash console. It no worky...
Any ideas?
Hi, This is Nice tool ! Thank you.
I try change Marionette 1.8 -> Marionette 2.2.
But did'nt replace "itemView" to "childVIew" in CollectionView .
Code is
return Backbone.Marionette.CollectionView.extend({
itemView: SampleView,
tagName:"ul",
initialize: function() {
}
});
Why not ? Colon ?
The thing that asks whether you'd like to replace a category of changes seems to either skip some categories, or (if it's only asking for things it found) ask to replace things it hasn't found.
Example:
Replace:
"itemViewEventPrefix" with "childViewEventPrefix"
[y,n,q]
Searching for first instance...
Replace:
"itemViewOptions" with "childViewOptions"
[y,n,q] y
Searching for first instance...
Replace:
"itemEvents" with "childEvents"
[y,n,q]
Searching for first instance...
Replace:
"itemViewContainer" with "childViewContainer"
[y,n,q] _
Note that the first prompt, for itemViewEventPrefix » childViewEventPrefix
, doesn't have a y/n/q response; it didn't open a prompt for input at the question, and instead skipped right to the itemViewOptions » childViewOptions
prompt. That one lets me answer "y", but doesn't find anything, and then it shows the itemEvents » childEvents
replacement but doesn't let me answer the question, instead it goes straight to the itemViewContainer » childViewContainer
prompt.
The upgrade script replaces addChildView
with onChildAdd
, which does not exist in v2. It seems to me that the v2 equivalent of addChildView
is _onCollectionAdd
.
Looking at marionettejs/backbone.marionette@1af07ba and marionettejs/backbone.marionette@78e55ff I guess that onChildAdd
was an intermediate naming which never made it to a release version?
onBeforeClose not getting replaced when attached with a colon onBeforeClose:.
Using subTerm("onBeforeClose", "onBeforeDestroy") fixed it in upgrade.py file instead of subMethod("onBeforeClose", "onBeforeDestroy").
buildItemView has been renamed to buildChildView but the script does not seem to handle this.
I see this when first starting upgrade.py:
Replace:
'.close\(' with '.destroy('
[y,n,q] _
Based on the readme, I expected to see a diff with some context and a file name and line number. Instead I think this is going to blanket-replace all instances of .close(
with .destroy(
, which I don't actually want to do.
It would be nice if the UI explained that I am selecting whether or not I want to attempt to replace any calls of .close(
with .destroy(
.
125 subMethod("addChildView", "onChildAdd")
126 subMethod("removeItemView", "onChildRemove")
This unnoticed changed caused problems for my Marionette app that used initialize before to set current user
Region's close is empty, not destroy
Looks like appendHtml
has been renamed to attachHtml
but I didn't see this documented anywhere
The tool currently attempts to make corrections against every dependency in the "node_modules" folder.
It'd be great if you could preview the changes that were going to be made.
A sample preview would look like:
53 Changes
5 CollectionView changes
10 ItemView changes
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.