new cfx option:makepack

3 views
Skip to first unread message

Julián Ceballos

unread,
Jul 11, 2010, 8:52:06 AM7/11/10
to mozilla-labs-jetpack
Hi, i'm beggining to hack in Jetpack, so i was watching the python
code in the sdk, and following the jetpack idea, i've wrote one option
in the __init__.py of cuddlefish or i don't know, maybe would be a
better idea include that option in an external file. The option name
is makepack, is a new option that create the basic architecture for a
new addon in jetpack main directory, the code is basicly this:

if command == "makepack":
if sys.argv[2]!=None:
packPath = os.path.abspath(os.path.dirname('__file__'))
+'/'+sys.argv[2]
try:
for d in ['','/lib','/data']:
os.mkdir(packPath+d)
except:
print 'The Directory already exist.'
package = open(packPath+'/package.json','w')
package.write('{\n"author":"",\n"description":"new
addon"\n}')
package.close()
main = open(packPath+'/lib/main.js','w')
main.write('exports.main = function(){};')
main.close()
else:
print 'Please give me the name of your new package.'
return

And well that's it, and i'd like to give so much funcionality for make
so much easy create addons, i don't know, maybe something like this:

$ cfx makepack gmailaddon with widget
$ cfx makepack gmailaddon with context-menu
$ cfx makepack gmailaddon with browser-tab

And of course make so much beautiful and fast the code.

Well, i don't have an account but i've asked already =).

What do you think about this idea?

Drew

unread,
Jul 12, 2010, 7:25:48 PM7/12/10
to mozilla-la...@googlegroups.com
Great idea. I mentioned your post to Atul this morning and he said that
Brian has been thinking about doing something similar. Actually there's
a bug on it already:

https://bugzilla.mozilla.org/show_bug.cgi?id=566814

I've attached your patch and CC'ed you there. Thanks!

Drew

Julián Ceballos

unread,
Jul 12, 2010, 10:18:18 PM7/12/10
to mozilla-la...@googlegroups.com
El 12/07/10 18:25, Drew escribi�:
Well i've changed my code to follow your code style so my code actually is:

def mkpkg(arguments=sys.argv[1:],
env_root=os.path.abspath(os.path.dirname('__file__'))):
if len(arguments) == 2:


try:
for d in ['','/lib','/data']:

os.mkdir(env_root+'/'+arguments[1]+'/'+d)
except:
print >> sys.stderr, 'The Directory already exist.'

open(env_root+'/'+arguments[1]+'/package.json','w').write('{\n\t"author":"",\n\t"description":"new
addon"\n}')

open(env_root+'/'+arguments[1]+'/lib/main.js','w').write('exports.main =
function(){\n};')
if len(arguments) > 2:
print >> sys.stderr,'Too many arguments.'
if len(arguments) < 2:
print >> sys.stderr,'Please give me the name of your new package.'

--
Juli�n Ceballos
Developer Mozilla M�xico

Julián Ceballos

unread,
Jul 13, 2010, 1:20:45 PM7/13/10
to mozilla-labs-jetpack
Hi Everybody i've modified my code again, little modifications, but
well the code is on this gists

http://gist.github.com/473366

I'm thinking in begin today adding the function to create templates
with requires and a little structure for main.js file.

The bug is https://bugzilla.mozilla.org/show_bug.cgi?id=566814


On Jul 12, 9:18 pm, Julián Ceballos <cristianjuliancebal...@gmail.com>
wrote:

Julián Ceballos

unread,
Jul 27, 2010, 11:25:25 PM7/27/10
to mozilla-la...@googlegroups.com

I've updated my code in the gist:
http://gist.github.com/473366

This code have a validation of modules and a complex template for an addon with
an argument to add requires to the lib/main.js template.

Look the bug https://bugzilla.mozilla.org/show_bug.cgi?id=566814

El 12/07/10 18:25, Drew escribi�:

--

Reply all
Reply to author
Forward
0 new messages