Showing posts with label module. Show all posts
Showing posts with label module. Show all posts

Monday, July 24, 2017

How to Create Magento-2 Extension Package to upload on Magento-2 official site?

Leave a Comment

I develop a extension in Magento-2. When a upload this extension on Magento official site then they send some errors in package.When I check this in production mode it is not showing any error.Please help me to create correct package of the Magento-2 extension.

Errors

Loading composer repositories with package information Updating dependencies (including require-dev) Your requirements could not be resolved to an installable set of packages.  Problem 1 - Installation request for magento/magento2ce 2.0.13 -> satisfiable by magento/magento2ce[2.0.13]. - company/module-extensionname 1.0.0 requires magento/framework 100.1.* -> satisfiable by magento/framework[100.1.0-rc1, 100.1.0-rc2, 100.1.0-rc3, 100.1.0, 100.1.1, 100.1.2, 100.1.3, 100.1.4, 100.1.5, 100.1.6, 100.1.7]. - don't install magento/framework 100.1.0-rc1|remove magento/magento2ce 2.0.13 - don't install magento/framework 100.1.0-rc2|remove magento/magento2ce 2.0.13 - don't install magento/framework 100.1.0-rc3|remove magento/magento2ce 2.0.13 - don't install magento/framework 100.1.0|remove magento/magento2ce 2.0.13 - don't install magento/framework 100.1.1|remove magento/magento2ce 2.0.13 - don't install magento/framework 100.1.2|remove magento/magento2ce 2.0.13 - don't install magento/framework 100.1.3|remove magento/magento2ce 2.0.13 - don't install magento/framework 100.1.4|remove magento/magento2ce 2.0.13 - don't install magento/framework 100.1.5|remove magento/magento2ce 2.0.13 - don't install magento/framework 100.1.6|remove magento/magento2ce 2.0.13 - don't install magento/framework 100.1.7|remove magento/magento2ce 2.0.13 - Installation request for comapny/module-extensionname 1.0.0 -> satisfiable by comapny/module-extensionname[1.0.0].   Installation failed, reverting ./composer.json to its original content. [Pipeline] } [Pipeline] // stage [Pipeline] sh [DockerOperationsPHP70Magento20CEVarnish] Running shell script + echo Failure 

composer.json

{   "name": "company/module-extensionname",   "description": "Lorem Ipsum is simply dummy text of the printing and typesetting industry.",   "type": "magento2-module",   "version": "1.0.0",   "license": [     "OSL-3.0",     "AFL-3.0"   ],   "require": {     "php": "~5.5.0|~5.6.0|~7.0.0",     "magento/framework": "100.1.*"   },   "authors": [     {       "name": "Tomas Jindal",       "email": "test@test.com",       "homepage": "https://stackoverflow.com",       "role": "Developer"     }   ],   "autoload": {     "files": [ "registration.php" ],     "psr-4": {       "company\\extensionname\\": ""     }   } } 

1 Answers

Answers 1

Give proper extension name For example you make extension name is Requestquote and you give name RequestQuote this is not acceptable in magento market place.

follow the below link and make composer.json file

https://magento.stackexchange.com/questions/105533/how-to-create-extension-package-in-magento-2

Read More

Saturday, July 15, 2017

Is __main__ guaranteed to always be importable?

Leave a Comment

Is there any case where doing:

import __main__ 

might lead to an ImportError? All cases I've tried seem to indicate that this always works. The docs on __main__ don't seems to state anything on the matter.

To give some context: I am trying to inject some names in __main__.__dict__ using the usersitecustomize hook in order to (mainly) have them available when the REPL fires up.

Granted that no redefinitions of __import__ occur (as a comment stated), this essentially boils down to if I need to wrap it in a try-except or not.

1 Answers

Answers 1

It probably is. Python initializes __main__ in this file: https://github.com/python/cpython/blob/master/Python/pylifecycle.c#L1327

However please note that modules like runpy and IPython replace the __main__ module with their own dynamically created ones to prevent collisions with their own launch scripts and to provide expected behaviour in case of runpy.

runpy itself is part of the Python Standard Library and provides the implementation of the -m flag which allows arbitrary modules to be executed as script.

An alternative is IPython which offers the feature to execute code at the launch of a new REPL.

For more details, see here: http://ipython.readthedocs.io/en/stable/config/intro.html?highlight=exec_lines

Read More

Thursday, June 29, 2017

Module using another function of the same module

Leave a Comment

I have something like this:

  • MyModule
    • index.js
    • myFunction1.js
    • myFunction2.js

In index.js file i'm exporting all modules function (myFunction1 and myFunction2). But, in myFunction2 I use myFunction1.

If I import the index (all the module) and call it like MyModule.myFunction1 inside myFunction2, I get an error (function does not exists).

If I import myFunction1.js and call it like myFunction1(), I can't make an Stub of it when I'm going to test it.

Any aproach to do something like this?

6 Answers

Answers 1

////////////////////// // File: ./index.js // ////////////////////// const myFunction1 = require('./myFunction1.js'); const myFunction2 = require('./myFunction2.js');  module.exports = {     myFunction1,     myFunction2 };  //////////////////////////// // File: ./myFunction1.js // //////////////////////////// module.exports = function1(x){     return x; };  //////////////////////////// // File: ./myFunction2.js // //////////////////////////// const myFunction1 = require('./myFunction1.js'); // or dropping the `.js` require('./myFunction1') module.exports = function2(x){     return myFunction1(x); }; 

Answers 2

index.js

let fnk1 = (a) => {   return a + ' 1 ' } let fnk2 = (a) => {   return fnk1(a) } module.exports = {  fnk1,  fnk2 } 

test.js

let Mymodule = require('./index') console.log(Mymodule.fnk2('argValue')); 

Answers 3

This should do the trick. It would be better if they were in the same file.

module.exports.myFunction1 = function() { ... }  module.exports.myFunction2 = function() {    module.exports.myFunction1() } 

If you need them to be in separate files, you can require function1 inside of the function2 file. The thing is, each file is its own module. From the Node.js docs:

Node.js has a simple module loading system. In Node.js, files and modules are in one-to-one correspondence (each file is treated as a separate module).

Answers 4

Diego's answer works fine, except that OP seems to want to use index.js in myFunction2.js. Use the same code as Diego's for index.js

for index.js (same as Diego's)

const myFunction1 = require('./myFunction1.js'); const myFunction2 = require('./myFunction2.js');  module.exports = {     myFunction1,     myFunction2 }; 

for myFunction1.js (small fix)

module.exports = function function1(x){     return x; }; 

for myFunction2.js (changed to include index.js):

const MyModule = require('./index.js');  module.exports = function function2(x){     return MyModule.myFunction1(x); }; 

and a test.js :

const myFunction2 = require('./myFunction2.js');  console.log(myFunction2(20)) 

Answers 5

const myFunction1 = require('./myFunction1.js');  const myFunction2 = require('./myFunction2.js');  module.exports = {      myFunction1:myFunction1,      myFunction2:function(x){        return myFunction2(x,myFunction1);      }  }  ////////////////////////////  // File: ./myFunction1.js //  ////////////////////////////  module.exports = function1(x){      return x;  };    ////////////////////////////  // File: ./myFunction2.js //  ////////////////////////////    module.exports = function2(x,myFunction1){      return myFunction1(x);  };

Answers 6

You problem is not clear because you did not post your code. Since, here is a working solution for your problem:

MyModule.js:

function myFunction1() {   console.log("- I am myFunction1") }  function myFunction2() {   console.log("- I am myFunction2")   myFunction1() }  module.exports = {   myFunction1,   myFunction2 } 

index.js

const MyModule = require('./MyModule')  console.log("Call myFunction1") MyModule.myFunction1() console.log("Call myFunction1") MyModule.myFunction2() 

If you execute node index.js, you get the following output:

Call myFunction1 - I am myFunction1 Call myFunction2 - I am myFunction2 - I am myFunction1 
Read More

Saturday, August 13, 2016

In Webpack, how to use custom source template to construct specific module

Leave a Comment

I know some inner functionality inside Webpack. Something about dependencies, template, and module building. However, there is little comment inside its source and no full document site for now. So, i can't chain them all to deal with my problem.

With my current requirement, i need to render specific module with custom source template (similar to this module in webpack).

Note: To be clear, the generated module's dependency array is not static. For example, one time it may be ['./a', './b', './c'], another time it may be ['./b', './c','./d']. That is up to some dynamic config before build.

For more detail example, i need a module call main.js. In build time, it need to be dynamically generated with target dependencies like(for being not sure which modules would be dependencies):

// main.js var a = require('./a') var b = require('./b') var c = require('./c') var d = require('./d') ... 

In fact, if i only need to dynamically require them all, i can just construct an entry point dynamically.

// webpack.config.js {     entry: {         main: [             './a',             './b',             './c',             ...         ]     }, } 

and it(webpack) will generate a module may like this:

__webpack_require__(1); __webpack_require__(2); __webpack_require__(3);  return __webpack_require__(4); 

But i need to do something more:

var a = __webpack_require__(1); var b = __webpack_require__(2); var c = __webpack_require__(3); var d = __webpack_require__(4); ...  // do something with a,b,c,d... under my custom need ...  return somthing or nothing; 

As you guys who know about webpack, it's very very complicated and hard to understand and track its plugin(event) hierarchy.

Need some expertise! :)


I'm sorry foy my unclear question before.

However, there is some kind of weird atmosphere. I set up a bounty for attention and guidance. Someone's free-minded answer drove me to make comment with impoliteness somehow. And then some peacemaker shows up with comments unrelated to the question or answer. That sucks.

Focusing on that thing just makes things worse and nothing helped. Not letting it go just means someone has petty mind.

1 Answers

Answers 1

Often in webpack you're only requiring one file, and maybe different libs that the files depend on. If you require main, then webpack is going to resolve the dependencies based on the CommonJS syntax which you can read about here. Does removing the extra requirements in your webpack.config.js file solve this? e.g. having only the following as the config:

// webpack.config.js {   entry: [ "./main" ],   ... } 

It sounds like you don't really understand how webpack works-- the idea of it is to emulate how Node's CommonJS syntax allows your javascript to be modular and placed in separate files, while also being performant and not requiring tons of AJAX requests by your browser. If you want to read more about Webpack's config file, check out this page.


As a side note, returning at the end of the module does absolutely nothing. If you want to export, you can use module.exports, but having a line like return true or something at the end of your main.js file doesn't get caught anywhere meaningful.

Read More

Friday, August 12, 2016

How to use custom source template to construct specific module in webpack

Leave a Comment

I know a bit inner functionality inside Webpack. Something about dependencies, template, and module building. However, there is little comment inside its source and no full document site for now. So, i can't chain them all to deal with my problem.

With my current requirement, i need to render specific module with custom source template.

For example, i have a module call main.js. In build time, it need to be dynamically generated with target dependencies like(for being not sure which modules would be dependencies):

// main.js var a = require('./a') var b = require('./b') var c = require('./c') var d = require('./d') ... 

In fact, if i only need to dynamically require them all, i can just construct an entry point dynamically.

// webpack.config.js {     entry: {         main: [             './a',             './b',             './c',             ...         ]     }, } 

and it(webpack) will generate a module may like this:

__webpack_require__(1); __webpack_require__(2); __webpack_require__(3);  return __webpack_require__(4); 

But i need to do something more:

var a = __webpack_require__(1); var b = __webpack_require__(2); var c = __webpack_require__(3); var d = __webpack_require__(4); ...  // do something with a,b,c,d... ...  return somthing or nothing; 

As you guys who know about webpack, it's very very complicated and hard to understand and track its plugin(event) hierarchy.

Need some expertise! :)

1 Answers

Answers 1

Often in webpack you're only requiring one file, and maybe different libs that the files depend on. If you require main, then webpack is going to resolve the dependencies based on the CommonJS syntax which you can read about here. Does removing the extra requirements in your webpack.config.js file solve this? e.g. having only the following as the config:

// webpack.config.js {   entry: [ "./main" ],   ... } 

It sounds like you don't really understand how webpack works-- the idea of it is to emulate how Node's CommonJS syntax allows your javascript to be modular and placed in separate files, while also being performant and not requiring tons of AJAX requests by your browser. If you want to read more about Webpack's config file, check out this page.


As a side note, returning at the end of the module does absolutely nothing. If you want to export, you can use module.exports, but having a line like return true or something at the end of your main.js file doesn't get caught anywhere meaningful.

Read More

Thursday, August 11, 2016

iOS : Could not build module <framework-name>

Leave a Comment

I've got Library from another team. I'm trying to use library in our project and while do so getting an error Could not build module 'Common Library' (name of framework)

Screenshot 1

Below are solutions that I worked on but didn't helped :

1. Delete Derived data content. Clean and Build.  2. Framework is added in 'Link binary with libraries' of Build phases.  3. While adding framework checkmarked : Target and Copy content to folder. 

Even I tried this stackoverflow-link but didn't got any break-through!

screenshot 2

screenshot 3

The only thing that worked was deleting Objective-C bridging header path in Swift compiler - code generation section of build settings in Project.

However, thereafter I'm not able to get Common interface to create instance (i.e. Common dosen't appears in drop-down list)

Any other fix?

2 Answers

Answers 1

Check whether the framework you are integrating is supporting your project architecture.

To see the framework supported architecture, use Terminal and navigate to Framework folder.

use, "lipo -info myFramework.framework/MyFramework"

And, if you want to use the framework files in your project, check whether the files are available in Framework/Headers Folder.

Getting this error :

Screenshot

Try, "file myFramework.framework/MyFramework" in Terminal

Answers 2

I found the same issue of framework when i try to add framework then i can't add framework and got error like same as you got.

Then i remove and reinstall X-Code and its working fine. so please try this.

Read More

Wednesday, April 27, 2016

Installing Torch Extension fb-caffe-exts from github

Leave a Comment

I am a new Torch user. How do you install the fb-caffe-exts extension for Torch from Github? fb-caffe-exts

0 Answers

Read More

Sunday, April 10, 2016

Embed a framework without module in a Pod

Leave a Comment

I'm using a 3rd party library provided as a framework : Library.framework. Apparently, it can only be used in my Swift project via the Bridging Header by doing #import <Library/Library.h>. Which is fine in most cases.

However, I'm currently developing a Pod in which I want to use Library.framework. This means that I cannot rely on the Bridging Header.

I tried to link the Library.framework in my Pod target (see General > Linked Frameworks and Libraries) but then, once the Pod is installed in my app, Xcode says the Pod cannot compile because some files in Library are not found.

What would be the best strategy to adopt here ?

2 Answers

Answers 1

I think I made it.

The trick was to add the .h files in both source_files and public_header_files in the Pod.podspec.

Like this :

s.source_files = 'Library.framework/Headers/*.h' s.public_header_files = 'Library.framework/Headers/*.h' 

This way, all the header files appear in the Pod-umbrella.h and can now be used in my app.

Answers 2

In your pod project I assume you have a file named [PodName].h, it will look similar to the file below. You could try to add the header in this file.

// //  PodName.h //  PodName // //  Created by John Doe on 06.04.2016. //  Copyright © 2016 John Doe Inc. All rights reserved. //  #import <UIKit/UIKit.h>  //! Project version number for PodName. FOUNDATION_EXPORT double PodNameVersionNumber;  //! Project version string for PodName. FOUNDATION_EXPORT const unsigned char PodNameVersionString[];  // In this header, you should import all the public headers of your framework using statements like #import <PodName/PublicHeader.h>  #import <Library/Library.h> // Add framework header here. 
Read More