Coder Social home page Coder Social logo

smclab / titaniumifier Goto Github PK

View Code? Open in Web Editor NEW
95.0 14.0 15.0 249 KB

Get a Titanium™ SDK CommonJS module out of a Node package!

License: GNU Lesser General Public License v2.1

JavaScript 100.00%
titanium-sdk titaniumifier browserify commonjs node-js

titaniumifier's Introduction

Titaniumifier

Build Status npm Gitter

Build your Titanium CommonJS Modules as they should be: as CommonJS packages, allowing more than one file.

Developed around substack’s browserify, titaniumifier is a tool that can be used to build a zip file following Titanium SDK conventions with a package.json as its starting point.

The Titaniumifier Wiki is where you’ll find the most up to date documentation.

Installation and usage

If you’re serious with it you can use the Grunt plugin.

If you just want to test it out you can use the titaniumifier CLI (good for quick tests):

# install it globally
$ [sudo] npm install --global titaniumifier

# move into a node package
$ cd path/to/project

# this will build dist/NAME-commonjs.VERSION.zip
$ titaniumifier --out dist

What is it for?

You’ll want to give titaniumifier a try if you want to write

  • a Titanium CommonJS distributable module
    • more complex than a single file,
    • some npm dependencies;
  • a package that works on both Node.js and Titanium SDK;
  • a wrapper for an existing package existing on npm.

Once you’re done writing your package you’ll be able to publish it on npm for users to

  • use it with Node.js;
  • include it as a dependency of a titaniumified package.

What is it not for?

Even with titaniumifier you still wont be ablo to

  • use or depend on ‘complex’ e ‘deeply node-ish’ packages like socket.io without work;
  • install Node.js packages in your app using npm install ...;

TODO

  • Make the built module easily debuggable from Titanium Studio (this is pretty big;)
  • Document and explore transpilation (this is a research mostly related to source maps/debug features;)
  • Make titaniumified repositories crawlable from gitTio;
  • Shim the following globals
    • Buffer with Titanium.Buffer
    • TypedArrays,
    • set/clearImmediate,
    • process.nextTick;
  • Shim the following built-ins
    • http,
    • net (with Titanium.Network.TCPSocket),
    • stream (and make fs work with it.)

The shimming process could be a community effort into the development of ti-http, ti-net etc. Contact us if you’re interested in working on it. In case don’t limit yourself to pure JS, give native development a chance.

Compatibility

Titanium SDK

The reference packages have been tested extensively from Titanium SDK 3.2 onward. There should be no reson for titaniumified packages to not work on older SDK versions.

Issues with Titanium SDK 3.x will be considered critical. With older versions we’ll try to do our best.

Because it does not mangle your Resources folder it is compatible with Alloy and TiShadow (and similars.) Please report any issue you have.

Node.js (in packages)

Currently Node.js 0.10 environment is shimmed in the packaging process. Once Node.js 0.12 is out there will be some interesting challenge to cope with (generators, WeakMap etc.)

Once that happens we’ll shim whatever is necessary.

Node.js (build-time)

This code is tested against Node.js 0.10 and 0.11.

Please steal this code (aka examples)

At the moment, you’ll use titaniumifier through its grunt plugin, grunt-titaniumifier.

There are 2 reference packages at the moment:

Contributing and whishlist

If you feel like helping, we’ll accept pull requests with great joy.

Here are a few ideas to help this project:

We love feedback

Please, don’t be afraid in opening new issues, even just for asking some help.

Credits

Humbly made by the spry ladies and gents at SMC.

License

This library, titaniumifier, is free software ("Licensed Software"); you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; including but not limited to, the implied warranty of MERCHANTABILITY, NONINFRINGEMENT, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA

titaniumifier's People

Contributors

adam-lynch avatar gitter-badger avatar robbe92 avatar shinout avatar yuchi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

titaniumifier's Issues

Documentation

The docs are obviously lacking, making it hard to analyze it. I'd like to see the following, but the list is not comprehensive:

  • Clearer description of exactly what it does and what problem its solves
  • Usage documentation
  • Examples, and details on whether their generation
  • What are the caveats? What can't it do? (I'm probably most interested in this)
  • On which mobile platforms has this been tested? Which versions of Titanium? Which versions of node.js and npm?
  • TODOs

Strip “use strict” from code (3.5.0.GA)

Looks like the new JSC bundled with Titanium SDK 3.5.0.GA is now JITing. Which is good news. The bad news is that this exposed a flaw in the optimized code that happens to be on strict mode ("use strict").

As @jamesfalkner found on smclab/liferay-connector and @rremy on smclab/ti-soap#3, in some specific cases we get the the following error:

[ERROR] Script Error {
[ERROR]   ...
[ERROR]   message = "Attempted to assign to readonly property."
[ERROR] }

Searching for it brings us to this kind of issues: requirejs/requirejs#392

Seriously I’m out of ideas. The only one is just throwing "use strict" out of the window with a global transformer, opting out for deeper optimizations.

I summon @jhaynie, in the hope he can shed some light on this issue.
What was the actual change that happened on 3.5.0? Is the JSC team aware of the issue?

Using of external modules

Hi,

in my TiJSPDF project I want tho embed external module. In index.js it is a reference to the module.

In configuration.json is a "link".

If I start titaniumifier I got an error:

Error: Cannot find module 'de.appwerft.qrcode' 

What I have to do to solve it?

Zip module issue

I don't know if is my environment, but somehow when unzipping the zip file generated by titaniumifier with grunt-zip I get all files empty:
_users_inakiabt_src_titanium_reste

Unzipping manually with unzip cli works as expected.

Here's my Gruntfile.js

    grunt.initConfig({
        unzip: {
            mod: {
                src: [
                    'dist/reste-commonjs-1.0.0.zip'
                ],
                dest: '.'
            }
        },
        titaniumifier: {
            "build": {
                files: {
                    'dist': ['.']
                },
                options: {
                    bundle: true,
                    module: true
                }
            }
        },
    });
    grunt.loadNpmTasks('grunt-titaniumifier');
    grunt.loadNpmTasks('grunt-zip');

    grunt.registerTask('app:setup', [
        'titaniumifier:build',
        'unzip:mod'
    ]);

I found that unzipping it with unzip cli, zip the result module folder with zip cli and then unzip it again with grunt unzip:mod works as expected too.

Also I tried your Gruntfile.js from https://github.com/smclab/grunt-titaniumifier/blob/master/Gruntfile.js and I get empty files too after run grunt test:ios.

Could be an incompatibility between adm-zip (used by titaniumifier) and jszip (used by grunt-zip)? I found this adm-zip issue cthackers/adm-zip#102 but I guess is not related.

Unzipping the zip file generated by titaniumifier programmatically with adm-zip works as expected:

var AdZip = require('adm-zip');
var zip = new AdZip('./reste-commonjs-1.0.0.zip');
zip.extractAllTo('.');

gitTio might not index titaniumified modules

Hi,

I red gitTio documentation about how to contribute, it came out it uses manifest to seek and index modules from repos. As titaniumifier build a zip file, manifest is not exposed (better said: it might not be exposed if gitTio behaviour is not to dig into zip file, and I guess it isn't).
Evidence of that is I found no titaniumified modules in gitTio (such a shame!).

I solved this by manually copying manifest file, or it might be a chained grunt task to unzip module after titaniumification.

What's your opinion about this?

Thanks

Parse

Hi, I'm so excited for this!!!! I'm trying to create a commonjs module for Parse+Titanium to contribute to the community.

Can you help me with the conversion?

  1. Download SDK from source.
  2. "cd" to downloaded zip
  3. "node install"
  4. install titaniumifier if not already
  5. run titaniumifier

Log:

iMacs-iMac:Downloads ryan$ cd parse-1.7.0/
iMacs-iMac:parse-1.7.0 ryan$ npm install
iMacs-iMac:parse-1.7.0 ryan$ titaniumifier --out dist

  ℹ  working on '/Users/ryan/Downloads/parse-1.7.0'
  ℹ  will write in '/Users/ryan/Downloads/parse-1.7.0/dist'

  ✖  errors!
/usr/local/lib/node_modules/titaniumifier/node_modules/bluebird/js/main/promise.js:677
            throw e;
                  ^
Error: Cannot find module './lib/browser/Parse.js' from '/Users/ryan/Downloads/parse-1.7.0'
    at /usr/local/lib/node_modules/titaniumifier/node_modules/titanium-resolve/node_modules/resolve/lib/async.js:42:25
    at load (/usr/local/lib/node_modules/titaniumifier/node_modules/titanium-resolve/node_modules/resolve/lib/async.js:60:43)
    at /usr/local/lib/node_modules/titaniumifier/node_modules/titanium-resolve/node_modules/resolve/lib/async.js:66:22
    at /usr/local/lib/node_modules/titaniumifier/node_modules/titanium-resolve/node_modules/resolve/lib/async.js:21:47
    at FSReqWrap.oncomplete (fs.js:95:15)

Error building module throw e; ^

Hi All,

So i have read through the docs i have created a folder on my desktop called sobytes-aws and i have ran npm init and run through the installation.

my package.json now looks like this i have added the guid from the first run.

{
  "name": "sobytes-aws",
  "version": "1.0.0",
  "description": "AWS Appcelerator",
  "titaniumManifest": {
    "guid": "55261e93-f586-9dfc-6142-9728114b3d2e"
  },
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "keywords": [
    "aws"
  ],
  "author": "Samuel East",
  "license": "ISC"
}

now i have ran titaniumifier with the following.

sudo titaniumifier --in aws-sdk-js-master --out sobytes-aws

And i get the following error.


  ℹ  working on '/Users/dev/Desktop/aws-sdk-js-master'
  ℹ  will write in '/Users/dev/Desktop/sobytes-aws'

  ✖  errors!

/usr/local/lib/node_modules/titaniumifier/node_modules/bluebird/js/main/promise.js:677
            throw e;
                  ^
Error: No `guid` found. Here’s one for you: fc1c63f3-8614-ae13-1b4c-fbbd50f07cd7
    at validatePackage (/usr/local/lib/node_modules/titaniumifier/lib/manifest.js:16:11)
    at tryCatcher (/usr/local/lib/node_modules/titaniumifier/node_modules/bluebird/js/main/util.js:26:23)
    at Promise._settlePromiseFromHandler (/usr/local/lib/node_modules/titaniumifier/node_modules/bluebird/js/main/promise.js:507:31)
    at Promise._settlePromiseAt (/usr/local/lib/node_modules/titaniumifier/node_modules/bluebird/js/main/promise.js:581:18)
    at Promise._settlePromises (/usr/local/lib/node_modules/titaniumifier/node_modules/bluebird/js/main/promise.js:697:14)
    at Async._drainQueue (/usr/local/lib/node_modules/titaniumifier/node_modules/bluebird/js/main/async.js:123:16)
    at Async._drainQueues (/usr/local/lib/node_modules/titaniumifier/node_modules/bluebird/js/main/async.js:133:10)
    at Async.drainQueues (/usr/local/lib/node_modules/titaniumifier/node_modules/bluebird/js/main/async.js:15:14)
    at process._tickCallback (node.js:448:13)

Any suggestions?

Merge descendant’s `nativeDependencies` once traversed

(See #13)

Given the following (fictious) dependency graph

liferay-connector
├── it.smc.navitems (native)
└── superagent
    └── it.smc.softkeyboard (native)

There’s nothing in the build process which tells us about it.smc.softkeyboard.

We need to parse all the package.json of traversed packages to discover them.

Refactoring checklist

Some ideas to triage/implement

  • support for jumped requires, in prelude.js we can check for require.length === 2 to avoid errors
  • we can refactor the code to be more correctly decoupled (we’re almost there):
    • titaniumifier/manifest gets a package.json and gives back a manifest
    • titaniumifier/bundle is just a preconfigured browserify (similar to deprecated @tonylukasavage’s titaniumifiy) and shares browserify’s API
    • titaniumifier/build gets an entry point and builds a CommonJS module zip out of it.
  • once we have browserify API in place we can read from Resources/**/*.js or app/**/*.js for every occurence of require('npm/something'), build a single bundle for all of them and have a companion Resources/npm/something.js call the bundle’s require; it’s a matter of module.exports = PRELUDE_HERE because it returns the internal require().

CLI

I love grunt, but before tying into a bunch of build systems, it seems more important to give this tool its own CLI. This will allow for better docs, clearer usage, and tie-ins to any build chain, be it 3rd party or custom.

Problem trying to titaniumifier sendemail

Hello,
I tried to titaniumifier sendemail(https://www.npmjs.com/package/sendmail) and the follow error was given:
(...error in \bluebird\js\main\promise.js:680)
Error: Cannot find module './dist-tools/transform.js'
(..stacktrace)

So I copied the dist-tools inside ./node_modules/aws-sdk/dist-tools to ./node_modules and it worked but failed in:
module.js:327
throw err;
^
Error: Cannot find module '../'
at Function.Module._resolveFilename (module.js:325:15)
at Function.Module._load (module.js:276:25)
at Module.require (module.js:353:17)
at require (internal/module.js:12:17)
at Object.(C:\path\to\sendemail\node_modules\dist-tools\service-collector.js:5:11)
at Module._compile (module.js:409:26)
at Object.Module._extensions..js (module.js:416:10)
at Module.load (module.js:343:32)
at Function.Module._load (module.js:300:12)
at Module.require (module.js:353:17)
at require (internal/module.js:12:17)
at Object. (C:\path\to\sendemail\node_modules\dist-tools\transform.js:2:17)
at Module._compile (module.js:409:26)
at Object.Module._extensions..js (module.js:416:10)
at Module.load (module.js:343:32)
at Function.Module._load (module.js:300:12)

That makes some sense to you?
I'm using windows
The titaniumifier is suposed to work with severals dependencies?
Do I have to titaniumifier each dependencie? (I don't think that's it, but seems a valid question)

Thanks for your time man

Support module assets

Hihi, this is going to be tough. See how os-titanium requires __context.js to be in a specific position.

In theory modules can have assets… does it work for CommonJS ones?

/cc @tonylukasavage @FokkeZB

Support for newer node versions

I know this tool is old now, however I use it successfully to generate this module https://github.com/Astrovic/TiDropboxAPIv2
There is only one problem: every time I have to switch to node 8.x to make it work. If I use a higher version, I get the error attached below.
Would it be possible to fix it? Thanks anyway 👍

  ✖  errors!
/Users/astrovic/.nvm/versions/node/v12.22.1/lib/node_modules/titaniumifier/node_modules/bluebird/js/main/promise.js:680
            throw e;
            ^

RangeError [ERR_OUT_OF_RANGE]: The value of "value" is out of range. It must be >= -2147483648 and <= 2147483647. Received 2792807700
    at checkInt (internal/buffer.js:68:11)
    at writeU_Int32LE (internal/buffer.js:688:3)
    at Buffer.writeInt32LE (internal/buffer.js:857:10)
    at Object.entryHeaderToBinary (/Users/astrovic/.nvm/versions/node/v12.22.1/lib/node_modules/titaniumifier/node_modules/adm-zip/headers/entryHeader.js:216:18)
    at Object.packHeader (/Users/astrovic/.nvm/versions/node/v12.22.1/lib/node_modules/titaniumifier/node_modules/adm-zip/zipEntry.js:260:39)
    at /Users/astrovic/.nvm/versions/node/v12.22.1/lib/node_modules/titaniumifier/node_modules/adm-zip/zipFile.js:198:41
    at Array.forEach (<anonymous>)
    at Object.compressToBuffer (/Users/astrovic/.nvm/versions/node/v12.22.1/lib/node_modules/titaniumifier/node_modules/adm-zip/zipFile.js:182:23)
    at Object.toBuffer (/Users/astrovic/.nvm/versions/node/v12.22.1/lib/node_modules/titaniumifier/node_modules/adm-zip/adm-zip.js:472:25)
    at writeModule (/Users/astrovic/.nvm/versions/node/v12.22.1/lib/node_modules/titaniumifier/lib/packer-build.js:112:59)
    at /Users/astrovic/.nvm/versions/node/v12.22.1/lib/node_modules/titaniumifier/bin/titaniumifier:48:16
    at tryCatcher (/Users/astrovic/.nvm/versions/node/v12.22.1/lib/node_modules/titaniumifier/node_modules/bluebird/js/main/util.js:26:23)
    at Promise._settlePromiseFromHandler (/Users/astrovic/.nvm/versions/node/v12.22.1/lib/node_modules/titaniumifier/node_modules/bluebird/js/main/promise.js:510:31)
    at Promise._settlePromiseAt (/Users/astrovic/.nvm/versions/node/v12.22.1/lib/node_modules/titaniumifier/node_modules/bluebird/js/main/promise.js:584:18)
    at Async._drainQueue (/Users/astrovic/.nvm/versions/node/v12.22.1/lib/node_modules/titaniumifier/node_modules/bluebird/js/main/async.js:128:12)
    at Async._drainQueues (/Users/astrovic/.nvm/versions/node/v12.22.1/lib/node_modules/titaniumifier/node_modules/bluebird/js/main/async.js:133:10) {
  code: 'ERR_OUT_OF_RANGE'
}

Uncaught SyntaxError

Hi @yuchi thanks for Titaniumifier.
We've been using a module we "titaniumfied" a while ago but it stopped to work on Android with Titanium SDK 6.3.0.GA.
I can successfully titaniumify the node package but when I require it on Android I get this:

V8Exception: Exception occurred at /html-to-text/html-to-text.js:1: Uncaught SyntaxError: Invalid or unexpected token

The package is this one https://www.npmjs.com/package/html-to-text and attached follows the generated JS file.
Please let me know if there is something we can do to have it running again on the newest SDK.

Thanks!

html-to-text.js.zip

Trying to titaniumifier AWS node sdk

Hi All,

I am trying to use titaniumifier to package the AWS sdk as a common js module think this would be awesome in Appcelertor.

So i have downloaded the AWS sdk from here.

https://github.com/aws/aws-sdk-js

And unzipped cd into the project and ran.

sudo titaniumifier --out dist

But i am getting the following errors.

✖  errors!

/usr/local/lib/node_modules/titaniumifier/node_modules/bluebird/js/main/promise.js:677
            throw e;
                  ^
Error: No `guid` found. Here’s one for you: bc9a73bd-f2d1-7c27-8642-abef022754cf
    at validatePackage (/usr/local/lib/node_modules/titaniumifier/lib/manifest.js:16:11)
    at tryCatcher (/usr/local/lib/node_modules/titaniumifier/node_modules/bluebird/js/main/util.js:26:23)
    at Promise._settlePromiseFromHandler (/usr/local/lib/node_modules/titaniumifier/node_modules/bluebird/js/main/promise.js:507:31)
    at Promise._settlePromiseAt (/usr/local/lib/node_modules/titaniumifier/node_modules/bluebird/js/main/promise.js:581:18)
    at Promise._settlePromises (/usr/local/lib/node_modules/titaniumifier/node_modules/bluebird/js/main/promise.js:697:14)
    at Async._drainQueue (/usr/local/lib/node_modules/titaniumifier/node_modules/bluebird/js/main/async.js:123:16)
    at Async._drainQueues (/usr/local/lib/node_modules/titaniumifier/node_modules/bluebird/js/main/async.js:133:10)
    at Async.drainQueues (/usr/local/lib/node_modules/titaniumifier/node_modules/bluebird/js/main/async.js:15:14)
    at process._tickCallback (node.js:448:13)

Would love some help on this thanks.

Support for `docs` and `example` folders

We completely forgot that good modules also have an example and docs directory. They are bundled in the zip and used for example by gitTio to launch an example app.

Zip files contain entryName's incompatible with gitTio

@rborn reported that nl.fokkezb.html2as could not be installed via gitTio. I did some tracing and saw this:

≫ gittio install nl.fokkezb.html2as
[INFO]  nl.fokkezb.html2as searching...
[ERROR] nl.fokkezb.html2as:ios no distributable available
[INFO]  [email protected]:commonjs downloading...
zipFile /var/folders/9f/sl63bfh578x0v3ktkwjk0_ym0000gn/T/1418284938485-044433511327952147.zip
tmpDir /var/folders/9f/sl63bfh578x0v3ktkwjk0_ym0000gn/T/1418284940985-011517406674101949
entry.entryName /modules/commonjs/nl.fokkezb.html2as/1.0.0/LICENSE
file /modules/commonjs/nl.fokkezb.html2as/1.0.0/LICENSE
[ERROR] Error: EACCES, permission denied '/modules'

The zipFile is the temporary path where the zip was downloaded. For each file the tmpDir is concatenated with entry.entryName, resulting in file as the path where the file will be extracted. In the zips created when distributing a native Titanium module the entryName doesn't start with /, but as you can see with those created by titaniumifier do.

Example of a native install:

≫ gittio install ti.ga
[INFO]  ti.ga searching...
[ERROR] ti.ga:commonjs no distributable available
[INFO]  [email protected]:ios downloading...
zipFile /var/folders/9f/sl63bfh578x0v3ktkwjk0_ym0000gn/T/1418285211757-8856470708269626.zip
tmpDir /var/folders/9f/sl63bfh578x0v3ktkwjk0_ym0000gn/T/1418285215541-38186876522377133
entry.entryName modules/iphone/ti.ga/1.0.0/manifest
file /var/folders/9f/sl63bfh578x0v3ktkwjk0_ym0000gn/T/1418285215541-38186876522377133/modules/iphone/ti.ga/1.0.0/manifest
entry.entryName modules/iphone/ti.ga/1.0.0/libti.ga.a
file /var/folders/9f/sl63bfh578x0v3ktkwjk0_ym0000gn/T/1418285215541-38186876522377133/modules/iphone/ti.ga/1.0.0/libti.ga.a
entry.entryName modules/iphone/ti.ga/1.0.0/documentation/index.html
file /var/folders/9f/sl63bfh578x0v3ktkwjk0_ym0000gn/T/1418285215541-38186876522377133/modules/iphone/ti.ga/1.0.0/documentation/index.html
entry.entryName modules/iphone/ti.ga/1.0.0/example/app.js
file /var/folders/9f/sl63bfh578x0v3ktkwjk0_ym0000gn/T/1418285215541-38186876522377133/modules/iphone/ti.ga/1.0.0/example/app.js
entry.entryName modules/iphone/ti.ga/1.0.0/example/index.js
file /var/folders/9f/sl63bfh578x0v3ktkwjk0_ym0000gn/T/1418285215541-38186876522377133/modules/iphone/ti.ga/1.0.0/example/index.js
entry.entryName modules/iphone/ti.ga/1.0.0/module.xcconfig
file /var/folders/9f/sl63bfh578x0v3ktkwjk0_ym0000gn/T/1418285215541-38186876522377133/modules/iphone/ti.ga/1.0.0/module.xcconfig
[INFO]  [email protected]:ios installing...
[INFO]  ti.ga:ios adding to tiapp.xml
[INFO]  [email protected]:ios installed

Manage (and merge) nativeDependencies

This is both for @smclab and @FokkeZB.

By now we’re already excluding from bundling every module defined in nativeDependencies.

So what you get is something like the following:

package.json:

{
  "main": "ti-cool-module",
  "nativeDependencies": {
    "liferay-connector": "*"
  }
}

and that means that when you do the following without liferay-connector installed, it will throw

ti-cool-module.js

var liferay = require('liferay-connector'); // Throws if not installed

Issue n.1 — see #14

If a module requires a module which has a nativeDependency, that information is lost and we’ll try to fetch it. BAD!

Issue n.2 — see #14

Even if issue n.1 wasn’t there, we loose the information once we build the zip/manifest/module.

Issue n.3

(This is for @FokkeZB) Would it be possible for gitTio to download them for the user as you do for widgets? How would you prefer them to be saved?

The best place is in the zip itself, side-by-side with the manifest in a package.json file. Does this work for you?

The `as` option overrides the module's directory name but not `moduleid`

I want the moduleid of https://github.com/FokkeZB/ti-html2as to be different (nl.fokkezb.html2as) from the NPM package name (ti-html2as). In the Gruntfile.js I use the as option:

titaniumifier: {
  module: {
    options: {
      as: "nl.fokkezb.html2as"
    }
  }
}

This correctly names the directory name of the module nl.fokkezb.html2as but the moduleid property in the manifest file is still ti-html2as and this is how it shows up on gitt.io. In the example project it does work when I require('nl.fokkezb.html2as') so this is confusing.

This should be fixed by letting as override package.name for the manifest file just like it does for the module directory name.

Support for SDK 8.x?

When I try to use my previously titaniumified module on Android with Titanium SDK 8.x I get an:

context.sourceUrl = url;
TypeError: Cannot create property 'sourceUrl' on boolean 'true'

error. I have no idea where this is coming from since I can't find anything called sourceUrl in any code in my project. Does anyone have an idea on how to fix it?
Thanks!

I cannot install it because of errors

annakozy$ sudo npm install --global titaniumifier
Password:
npm WARN deprecated [email protected]: Please use node-uuid instead. It is much better.
/usr/local/etc/bin/install-titaniumifier-plugin -> /usr/local/etc/lib/node_modules/titaniumifier/bin/install-titaniumifier-plugin
/usr/local/etc/bin/titaniumifier -> /usr/local/etc/lib/node_modules/titaniumifier/bin/titaniumifier

[email protected] install /usr/local/etc/lib/node_modules/titaniumifier/node_modules/fidonet-mailer-binkp-crypt
node-gyp configure build

gyp WARN EACCES user "root" does not have permission to access the dev dir "/Users/annakozy/.node-gyp/5.0.0"
gyp WARN EACCES attempting to reinstall using temporary dev dir "/usr/local/etc/lib/node_modules/titaniumifier/node_modules/fidonet-mailer-binkp-crypt/.node-gyp"
CXX(target) Release/obj.target/crypt/crypt.o
In file included from ../crypt.cc:5:
../../nan/nan.h:324:27: error: redefinition of 'NanEnsureHandleOrPersistent'
NAN_INLINE v8::Local NanEnsureHandleOrPersistent(const v8::Local &val) {
^
../../nan/nan.h:319:17: note: previous definition is here
v8::Handle NanEnsureHandleOrPersistent(const v8::Handle &val) {
^
../../nan/nan.h:344:27: error: redefinition of 'NanEnsureLocal'
NAN_INLINE v8::Local NanEnsureLocal(const v8::Handle &val) {
^
../../nan/nan.h:334:27: note: previous definition is here
NAN_INLINE v8::Local NanEnsureLocal(const v8::Local &val) {
^
../../nan/nan.h:757:13: error: no member named 'smalloc' in namespace 'node'
, node::smalloc::FreeCallback callback
~~~~~~^
../../nan/nan.h:768:12: error: no matching function for call to 'New'
return node::Buffer::New(v8::Isolate::GetCurrent(), data, size);
^~~~~~~~~~~~~~~~~
/usr/local/etc/lib/node_modules/titaniumifier/node_modules/fidonet-mailer-binkp-crypt/.node-gyp/5.0.0/include/node/node_buffer.h:31:40: note:
candidate function not viable: no known conversion from 'uint32_t'
(aka 'unsigned int') to 'enum encoding' for 3rd argument
NODE_EXTERN v8::MaybeLocalv8::Object New(v8::Isolate* isolate,
^
/usr/local/etc/lib/node_modules/titaniumifier/node_modules/fidonet-mailer-binkp-crypt/.node-gyp/5.0.0/include/node/node_buffer.h:43:40: note:
candidate function not viable: 2nd argument ('const char ') would lose
const qualifier
NODE_EXTERN v8::MaybeLocalv8::Object New(v8::Isolate
isolate,
^
/usr/local/etc/lib/node_modules/titaniumifier/node_modules/fidonet-mailer-binkp-crypt/.node-gyp/5.0.0/include/node/node_buffer.h:28:40: note:
candidate function not viable: requires 2 arguments, but 3 were provided
NODE_EXTERN v8::MaybeLocalv8::Object New(v8::Isolate* isolate, size_t length);
^
/usr/local/etc/lib/node_modules/titaniumifier/node_modules/fidonet-mailer-binkp-crypt/.node-gyp/5.0.0/include/node/node_buffer.h:36:40: note:
candidate function not viable: requires 5 arguments, but 3 were provided
NODE_EXTERN v8::MaybeLocalv8::Object New(v8::Isolate* isolate,
^
In file included from ../crypt.cc:5:
../../nan/nan.h:772:12: error: no viable conversion from
'v8::MaybeLocalv8::Object' to 'v8::Localv8::Object'
return node::Buffer::New(v8::Isolate::GetCurrent(), size);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/local/etc/lib/node_modules/titaniumifier/node_modules/fidonet-mailer-binkp-crypt/.node-gyp/5.0.0/include/node/v8.h:210:7: note:
candidate constructor (the implicit copy constructor) not viable: no known
conversion from 'v8::MaybeLocalv8::Object' to 'const
v8::Localv8::Object &' for 1st argument
class Local {
^
/usr/local/etc/lib/node_modules/titaniumifier/node_modules/fidonet-mailer-binkp-crypt/.node-gyp/5.0.0/include/node/v8.h:210:7: note:
candidate constructor (the implicit move constructor) not viable: no known
conversion from 'v8::MaybeLocalv8::Object' to 'v8::Localv8::Object &&'
for 1st argument
class Local {
^
/usr/local/etc/lib/node_modules/titaniumifier/node_modules/fidonet-mailer-binkp-crypt/.node-gyp/5.0.0/include/node/v8.h:214:13: note:
candidate template ignored: could not match 'Local' against 'MaybeLocal'
V8_INLINE Local(Local that)
^
/usr/local/etc/lib/node_modules/titaniumifier/node_modules/fidonet-mailer-binkp-crypt/.node-gyp/5.0.0/include/node/v8.h:326:13: note:
candidate template ignored: could not match 'S ' against
'v8::MaybeLocalv8::Object'
V8_INLINE Local(S
that)
^
In file included from ../crypt.cc:5:
../../nan/nan.h:779:26: error: no member named 'Use' in namespace 'node::Buffer'
return node::Buffer::Use(v8::Isolate::GetCurrent(), data, size);
~~~~~~~~~~~~~~^
In file included from ../crypt.cc:1:
In file included from /usr/local/etc/lib/node_modules/titaniumifier/node_modules/fidonet-mailer-binkp-crypt/.node-gyp/5.0.0/include/node/node.h:42:
/usr/local/etc/lib/node_modules/titaniumifier/node_modules/fidonet-mailer-binkp-crypt/.node-gyp/5.0.0/include/node/v8.h:221:5: error:
assigning to 'v8::Primitive *volatile' from incompatible type
'v8::Value *'
TYPE_CHECK(T, S);
^~~~~~~~~~~~~~~~
/usr/local/etc/lib/node_modules/titaniumifier/node_modules/fidonet-mailer-binkp-crypt/.node-gyp/5.0.0/include/node/v8.h:180:37: note:
expanded from macro 'TYPE_CHECK'
(static_cast<T volatile_>(0)) = static_cast<S_>(0);
^ ~~~~~~~~~~~~~~~~~~
../../nan/nan.h:501:12: note: in instantiation of function template
specialization 'v8::Localv8::Primitive::Localv8::Value' requested here
return NanEscapeScope(NanNew(v8::Undefined(v8::Isolate::GetCurrent())));
^
../../nan/nan.h:483:30: note: expanded from macro 'NanEscapeScope'

define NanEscapeScope(val) scope.Escape(Nan::imp::NanEnsureLocal(val))

                         ^

In file included from ../crypt.cc:1:
In file included from /usr/local/etc/lib/node_modules/titaniumifier/node_modules/fidonet-mailer-binkp-crypt/.node-gyp/5.0.0/include/node/node.h:42:
/usr/local/etc/lib/node_modules/titaniumifier/node_modules/fidonet-mailer-binkp-crypt/.node-gyp/5.0.0/include/node/v8.h:221:5: error:
assigning to 'v8::Boolean volatile' from incompatible type 'v8::Value *'
TYPE_CHECK(T, S);
^~~~~~~~~~~~~~~~
/usr/local/etc/lib/node_modules/titaniumifier/node_modules/fidonet-mailer-binkp-crypt/.node-gyp/5.0.0/include/node/v8.h:180:37: note:
expanded from macro 'TYPE_CHECK'
*(static_cast<T
volatile_>(0)) = static_cast<S_>(0);
^ ~~~~~~~~~~~~~~~~~~
../../nan/nan.h:511:12: note: in instantiation of function template
specialization 'v8::Localv8::Boolean::Localv8::Value' requested here
return NanEscapeScope(NanNew(v8::True(v8::Isolate::GetCurrent())));
^
../../nan/nan.h:483:30: note: expanded from macro 'NanEscapeScope'

define NanEscapeScope(val) scope.Escape(Nan::imp::NanEnsureLocal(val))

                         ^

In file included from ../crypt.cc:1:
In file included from /usr/local/etc/lib/node_modules/titaniumifier/node_modules/fidonet-mailer-binkp-crypt/.node-gyp/5.0.0/include/node/node.h:42:
/usr/local/etc/lib/node_modules/titaniumifier/node_modules/fidonet-mailer-binkp-crypt/.node-gyp/5.0.0/include/node/v8.h:221:5: error:
assigning to 'v8::Function volatile' from incompatible type 'v8::Value *'
TYPE_CHECK(T, S);
^~~~~~~~~~~~~~~~
/usr/local/etc/lib/node_modules/titaniumifier/node_modules/fidonet-mailer-binkp-crypt/.node-gyp/5.0.0/include/node/v8.h:180:37: note:
expanded from macro 'TYPE_CHECK'
*(static_cast<T
volatile_>(0)) = static_cast<S_>(0);
^ ~~~~~~~~~~~~~~~~~~
../../nan/nan.h:1645:12: note: in instantiation of function template
specialization 'v8::Localv8::Function::Localv8::Value' requested here
return NanEscapeScope(NanNew(handle)->Get(kCallbackIndex)
^
../../nan/nan.h:483:30: note: expanded from macro 'NanEscapeScope'

define NanEscapeScope(val) scope.Escape(Nan::imp::NanEnsureLocal(val))

                         ^

In file included from ../crypt.cc:1:
In file included from /usr/local/etc/lib/node_modules/titaniumifier/node_modules/fidonet-mailer-binkp-crypt/.node-gyp/5.0.0/include/node/node.h:42:
/usr/local/etc/lib/node_modules/titaniumifier/node_modules/fidonet-mailer-binkp-crypt/.node-gyp/5.0.0/include/node/v8.h:221:5: error:
assigning to 'v8::Object volatile' from incompatible type 'v8::Value *'
TYPE_CHECK(T, S);
^~~~~~~~~~~~~~~~
/usr/local/etc/lib/node_modules/titaniumifier/node_modules/fidonet-mailer-binkp-crypt/.node-gyp/5.0.0/include/node/v8.h:180:37: note:
expanded from macro 'TYPE_CHECK'
*(static_cast<T
volatile_>(0)) = static_cast<S_>(0);
^ ~~~~~~~~~~~~~~~~~~
../../nan/nan.h:1776:12: note: in instantiation of function template
specialization 'v8::Localv8::Object::Localv8::Value' requested here
return NanEscapeScope(
^
../../nan/nan.h:483:30: note: expanded from macro 'NanEscapeScope'

define NanEscapeScope(val) scope.Escape(Nan::imp::NanEnsureLocal(val))

                         ^

10 errors generated.
make: *** [Release/obj.target/crypt/crypt.o] Error 1
gyp ERR! build error
gyp ERR! stack Error: make failed with exit code: 2
gyp ERR! stack at ChildProcess.onExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:270:23)
gyp ERR! stack at emitTwo (events.js:87:13)
gyp ERR! stack at ChildProcess.emit (events.js:172:7)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:200:12)
gyp ERR! System Darwin 14.5.0
gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "configure" "build"
gyp ERR! cwd /usr/local/etc/lib/node_modules/titaniumifier/node_modules/fidonet-mailer-binkp-crypt
gyp ERR! node -v v5.0.0
gyp ERR! node-gyp -v v3.0.3
gyp ERR! not ok
npm ERR! Darwin 14.5.0
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "install" "--global" "titaniumifier"
npm ERR! node v5.0.0
npm ERR! npm v3.3.6
npm ERR! code ELIFECYCLE

npm ERR! [email protected] install: node-gyp configure build
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] install script 'node-gyp configure build'.
npm ERR! This is most likely a problem with the fidonet-mailer-binkp-crypt package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node-gyp configure build
npm ERR! You can get their info via:
npm ERR! npm owner ls fidonet-mailer-binkp-crypt
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR! /Users/annakozy/npm-debug.log
Annas-iMac:~ annakozy$

Requiring alloy modules

There's no way to require, inside my module, "alloy/animation"?
If I try to build my custom module and, obviously, the build process failed with this message

Error: Cannot find module 'alloy/animation' from /my/module/path

Gulp is a no-op (That

Since the Gulp API handles promises you can call the titaniumifier API directly and return it's result inside a gulp task. This is line with how browserify integrate with Gulp and doesn't actually need a Gulp plugin:

Something like:

var pkg = require(__dirname + 'package.json');

gulp.task('build', function() {
  return  titaniumifier.packer.build({
    entry: '.',
    as: pkg.name,
    noDependencies: true
  })
  .then(function (zip) {
    return zip.writeModule(dest);
  });
});

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.