These are chat archives for reactioncommerce/reaction

14th
Oct 2015
danielortiz
@danielortiz
Oct 14 2015 00:36 UTC
Hi
I'm trying to import a npm package into a meteor package I'm writing
the problem is, I get an error telling me that "let "can't be used on "use strict" mode
obviously, it's because "use strict" is blocking ES6 stuff..
the package works great outside meteor, how can I make it run on meteor?
I edited the source code replacing "const"and "let"to "var" and it worked, but obviously this isn't a good approach
danielortiz
@danielortiz
Oct 14 2015 00:51 UTC
blob.png
That's the error I'm getting
Spencer Norman
@spencern
Oct 14 2015 01:30 UTC
do you have the ecmascript package in your package?
danielortiz
@danielortiz
Oct 14 2015 01:31 UTC
hmmm, probably not
let me see
Spencer Norman
@spencern
Oct 14 2015 01:32 UTC
My first thought would be to try that
I’m using ES6 in all of my reaction packages currently without issue
danielortiz
@danielortiz
Oct 14 2015 01:32 UTC
hmm, let me try
api.use(["ecmascript"], 'server'); am I right?
Spencer Norman
@spencern
Oct 14 2015 01:33 UTC
looks right
danielortiz
@danielortiz
Oct 14 2015 01:33 UTC
gonna try
danielortiz
@danielortiz
Oct 14 2015 02:01 UTC
@spencern thank you, it worked =D
Spencer Norman
@spencern
Oct 14 2015 02:07 UTC
:+1:
danielortiz
@danielortiz
Oct 14 2015 03:52 UTC
@spencern I'm getting the same problem again =/
Spencer Norman
@spencern
Oct 14 2015 03:52 UTC
Is your package on github?
danielortiz
@danielortiz
Oct 14 2015 03:53 UTC
it was working fine while I was running my package on meteor, now I'm running it on reaction and I'm getting the same problem
yes
no, sorry, my package isn't
I'm gonna make a repo
Spencer Norman
@spencern
Oct 14 2015 03:57 UTC
interesting. Not sure why running it on reaction would make a difference, but if you make a repo, I’ll take a look
it's a bit of a mess..my first meteor package, still figuring out what structure to follow
danielortiz
@danielortiz
Oct 14 2015 04:16 UTC
@spencern maaaaaybe it didn't actually work before
maybe I just forgot to run things properly and it was an old version
but I think it's not the case
Spencer Norman
@spencern
Oct 14 2015 05:25 UTC
I’ll take a look
Spencer Norman
@spencern
Oct 14 2015 05:53 UTC
Your package’s issue is definitely with the npm package you are including frete
I’d file an issue there.
Spencer Norman
@spencern
Oct 14 2015 06:02 UTC
@danielortiz
danielortiz
@danielortiz
Oct 14 2015 14:46 UTC
@spencern weird, because it works ok when running it outside meteor
Ryan
@allpoolspa
Oct 14 2015 14:54 UTC
Hello everyone.
I would like to do product file uploads. Is anyone working on a package for this? Or is there one?
Aaron Judd
@aaronjudd
Oct 14 2015 14:58 UTC
@danielortiz agree with @spencern that your package looks ok, however one thought, you might want to use Meteor.wrapAsync, and bindEnvironment, http://docs.meteor.com/#/full/meteor_wrapasync rather than Fibers. However that works fine our payment packages when included as Fiber = Npm.require("fibers") Future = Npm.require("fibers/future”)
@RyanPPS there’s a discussion here regarding this: reactioncommerce/reaction#467 and some additional details for you.
currently you can load products as JSON, but not the images. We still need a solution for mass import of images in CFS.
@cooloney taxes are manual now, admin UI coming soon..ETA TBD. PR’s happily accepted.
Aaron Judd
@aaronjudd
Oct 14 2015 15:04 UTC
@tritone11 @kefirchik bin/clone-packages.sh is the easiest method. ;-)
@danielortiz you might want to just useapi.use("reactioncommerce:core@0.9.0”); at least for testing, as the core exports ecmascript and all needed packages.
danielortiz
@danielortiz
Oct 14 2015 15:12 UTC
@aaronjudd Yes, I actually tried using wrapAsync, but didn't figure out how to do it with "chained functions "
Aleksei Mironov
@alexmironof
Oct 14 2015 15:14 UTC
@aaronjudd Thanks, for reply! but the problem is that I am on windows machine and I can't use sh scripts :worried:
so I'am using submodules and manually installing, resetting and updating everything
danielortiz
@danielortiz
Oct 14 2015 15:14 UTC
like this Frete().cepOrigem('123456').servico('sedex').prazo('81750230', function(error, res){})
Aaron Judd
@aaronjudd
Oct 14 2015 15:16 UTC

@danielortiz more like:

    wrappedFunc = Meteor.wrapAsync(PayFlow.payment.create, PayFlow.payment);
    try {
      result = {
        saved: true,
        response: wrappedFunc(paymentObj)
      };
    } catch (_error) {
      err = _error;
      ReactionCore.Log.warn(err);
      result = {
        saved: false,
        error: err
      };
    }

(example from reaction-paypal)

but in any case, Fibers should work ;-)
@kefirchik d’oh! why not? lol
danielortiz
@danielortiz
Oct 14 2015 15:18 UTC
yes, it worked fine, but I definitely would like to learn how to do this with wrapAsync
I mean, each of the methods Frete()give me needs a parameter, where do I pass them with wrapAsync?
could you clarify a bit for me how this method should be with wrap async?
Aleksei Mironov
@alexmironof
Oct 14 2015 15:20 UTC
@aaronjudd actually I have msysgit installed and it replaced all windows commands with its linux equivalents, but I've never tested scripts because I thought that it is not possible to use it inside windows :laughing:
Aaron Judd
@aaronjudd
Oct 14 2015 15:20 UTC
@danielortiz I’ll be honest - the docs on that are tough to figure out. I think you have two options, either wrap the function and then call the wrap function with params, or to use .bind -> do a global search in our codebase and you’ll see some working examples
danielortiz
@danielortiz
Oct 14 2015 15:20 UTC
  getDeliveryDate: function(packInfo){
    var myFuture = new Future();
    Frete()
    .cepOrigem(packInfo.cepOrigin)
    .servico(Frete.codigos[packInfo.postMethod])
    .prazo(packInfo.cepDestiny, function (error, results) {
      if(error){
        myFuture.throw(error);
      }else{
        myFuture.return(results);
      }
    })
    return myFuture.wait();
  },
hmm
Aaron Judd
@aaronjudd
Oct 14 2015 15:21 UTC
but I’m with you - if Future / Fibers works, stick with it ;-)
danielortiz
@danielortiz
Oct 14 2015 15:22 UTC
it would be much easier if Frete() just accepted a dictionary object with its parameters
Spencer Norman
@spencern
Oct 14 2015 15:22 UTC
It looks like Frete is a fairly new project - initial commits were just 12 days ago, perhaps you could fork it and make it accept a dictionary object
danielortiz
@danielortiz
Oct 14 2015 15:22 UTC
hmm, that's a good a idea
Aaron Judd
@aaronjudd
Oct 14 2015 15:24 UTC
@kefirchik we’re waiting for your .bat files :shipit:
danielortiz
@danielortiz
Oct 14 2015 15:25 UTC
let me make one more question, do you think I can stick with one npm module, or it's better for me to put all the stuff from the npm module inside my reaction package in the future?
Aaron Judd
@aaronjudd
Oct 14 2015 15:27 UTC
that all depends if the npm package works -> in general I have no issues using npm packages (we actually use them fairly liberally) and if the package works, I’d just go the route you already went. without looking into Frete, seems like it might need some massaging though (based on the comments)
danielortiz
@danielortiz
Oct 14 2015 15:30 UTC
hmm, nice
I think I will do what spencern said, fork the module, make it accept objects and try to figure out what's going on when I use it with meteor
Aaron Judd
@aaronjudd
Oct 14 2015 15:31 UTC
that’s not to suggest I’m against just including the source and modifying as needed - if that’s what it takes, but in general I try to support and contribute back to other packages. All sort of depends on the history/maintenance/maintainer….
danielortiz
@danielortiz
Oct 14 2015 15:36 UTC
I understand
Aleksei Mironov
@alexmironof
Oct 14 2015 15:36 UTC
@aaronjudd I'll try ))) I'm not cmd guru but I definitly would try )))
danielortiz
@danielortiz
Oct 14 2015 15:37 UTC
thank you @aaronjudd and @spencern =), you helped me a lot
Spencer Norman
@spencern
Oct 14 2015 15:48 UTC
:+1:
Spencer Norman
@spencern
Oct 14 2015 19:27 UTC
@mikemurray or @aaronjudd what is the thought behind having a shopid at both the order/cart level and also on each product in the cart.items and order.items array? Is there a scenario where these are different?
Mike Murray
@mikemurray
Oct 14 2015 19:59 UTC
@spencern potentially, if the item belongs to another shop, or parent shop. Also makes it easier to determin what shop an item belongs to so you don't have to do a bunch of hunting for the shop id. (basically a copy of the item as it stands at the moment)
Spencer Norman
@spencern
Oct 14 2015 20:19 UTC
ok, excellent, that’s what I figured. One more question about the cart.itemsand order.items
the object for an order.item looks like this:
_id: 'rnd123',
productId: ‘prd123',
shopId: 'abc123',
quantity: 12,
variants: {variantObject}
variants here seems to always be an object rather than an array of objects, is this intentional? Does variant ever contain an array here?
and is variants._id the id of the variant that is included within the order?
Mike Murray
@mikemurray
Oct 14 2015 20:24 UTC
variants._id is the item included in the order, yes
the parent product is the item, the variant is what you bought
as for why its called variants and is not an array, ¯_(ツ)_/¯
Spencer Norman
@spencern
Oct 14 2015 20:26 UTC
helpful, thanks!
Spencer Norman
@spencern
Oct 14 2015 23:33 UTC
@mikemurray do you know if Meteor 1.2 made it easier for us to use .less or .scss in packages? Trying to get some precompiled css to show up in the app and not having any luck. Have found a few blog posts hinting that 1.2 included some type of css asset pipeline, but haven’t been able to find any details.
Mike Murray
@mikemurray
Oct 14 2015 23:37 UTC
@spencern It did. @import "{package-name}/path-to-file.less" which is supposed to let you import from package
I tried that and got a big fat #nope from meteor
but it should work with the proper configuration
Spencer Norman
@spencern
Oct 14 2015 23:39 UTC
this @import is from within the package.js file?
Mike Murray
@mikemurray
Oct 14 2015 23:39 UTC
in the less file
Spencer Norman
@spencern
Oct 14 2015 23:40 UTC
Oh, within the main app?
Mike Murray
@mikemurray
Oct 14 2015 23:40 UTC
In a test im doing I do this @import "{}/client/styles/core/variables.import.less";
which lest me import from inside the current app. But with the package name in the {} you should be able to import from a package
Spencer Norman
@spencern
Oct 14 2015 23:41 UTC
ok.
Mike Murray
@mikemurray
Oct 14 2015 23:42 UTC
and i believe its the full package name "reactioncommerce:core-theme", not just the name on disk
Spencer Norman
@spencern
Oct 14 2015 23:43 UTC
Ok - the @import line should be within the main less file in the app or can that be in a less file in the package?
Mike Murray
@mikemurray
Oct 14 2015 23:43 UTC
any less file you want
Spencer Norman
@spencern
Oct 14 2015 23:43 UTC
not sure if it’s clear what I’m asking
ah, fantastic
Mike Murray
@mikemurray
Oct 14 2015 23:43 UTC
I'm actually importing what I need per less file
Spencer Norman
@spencern
Oct 14 2015 23:44 UTC
do you have an example file on github i could browse through?
Mike Murray
@mikemurray
Oct 14 2015 23:44 UTC
actually working on one now, becuae I want to test this to the fullest
Spencer Norman
@spencern
Oct 14 2015 23:45 UTC
ok, if you get anything working, I’m very interested. We are working on something similar but haven’t gone very far down the front-end road yet
does anyone have any guides/resources on getting email to work? Meteor's documentation on it is quite limited. I can't even get a test email to send from the meteor shell.