Package for aggregating external packages in meteor.js - meteor

I am creating meteor app and I decided to separate it into packages, so I can take control of file loading order.
However, many packages have common dependencies(other external packages) like react or meteorhacks:flow-router. I want to create main myapp:app package with all these dependencies, that other packages in my app will imply.
This is app package.js:
Package.describe({
name: 'myapp:app',
version: '0.0.1'
});
Package.onUse(function(api) {
api.versionsFrom('1.2.1');
// All external packages that will be used by other local packages
api.use([
'twbs:bootstrap',
], 'client');
api.use([
'ecmascript',
'react',
'meteorhacks:flow-router'
], ['client', 'server']);
});
An I have package myapp:taskslist that imply myapp:app:
Package.describe({
name: 'myapp:taskslist',
version: '0.0.1'
});
Package.onUse(function(api) {
api.versionsFrom('1.2.1');
api.imply(['myapp:app']);
api.addFiles([
'client/tasksList.jsx',
'client/task.jsx',
'main.jsx'
], ['client']);
});
However it doesn't work. I have an error No plugin known to handle file 'client/taskList.jsx' because myapp:tasksList, does not have react plugin installed. Shouldn't api.imply() share react to myapp:tasksList package? What's good solution for this problem?

To answer your question directly, no imply does not expose react to myapp:tasksList
You need to think of it like this:
IMPLY passes references OUT
USE takes references IN
All the imply in myapp:tasksList is doing is allowing whatever uses myapp:tasksList to have access to myapp:app.
In order for you to use myapp:app (and all the references it exposes) in myapp:tasksList you also need to add
api.use([
'myapp:app',
]);
to myapp:tasksList

Related

Exporting public C headers with SwiftPM

I have an open source Objective C framework, which I'd like to provide using Swift Package Manager as well.
Normally, I have public headers set in the Xcode project, which, when the framework is built, are copied under the framework bundle, and are discovered when linked to by Xcode.
I can't, however get it to work with SwiftPM.
I created a modulemap for my framework:
framework module LNPopupController {
umbrella header "LNPopupController.h"
export *
module * { export * }
}
and I define the library like so in the Package.swift:
let package = Package(
name: "LNPopupController",
platforms: [
.iOS(.v12),
.macOS(.v10_15)
],
products: [
// Products define the executables and libraries a package produces, and make them visible to other packages.
.library(
name: "LNPopupController",
type: .dynamic,
targets: ["LNPopupController"]),
],
dependencies: [
// Dependencies declare other packages that this package depends on.
// .package(url: /* package url */, from: "1.0.0"),
],
targets: [
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
// Targets can depend on other targets in this package, and on products in packages this package depends on.
.target(
name: "LNPopupController",
dependencies: [],
path: "LNPopupController",
publicHeadersPath: ".",
cSettings: [
.headerSearchPath("."),
.headerSearchPath("Private"),
]),
]
)
When added as a project dependency in Xcode, the framework compiles just fine, but when the dependent target attempts to import LNPopupController, an error is thrown: umbrella header 'LNPopupController.h' not found
Looking at the build folder, indeed, I see that Xcode has built a binary, but has not copied the public headers.
Any way to specify which headers are public, and make the build system copy them for import?
I eventually figured it out. This is what I did for LNPopupController:
I created a include/LNPopupController/ sub-directory tree, and put soft links to all public headers there.
In the package file, I added publicHeadersPath: "include".
You can see the final result here:
https://github.com/LeoNatan/LNPopupController/blob/master/Package.swift
It might not be the most optimal way, but it works for all my ObjC projects which I have tried this method on.

Mobile verification in meteor web/mobile app?

I want to include mobile verification for the users in my app.Tried adding the accounts-phone package ::*$ meteor add okland:accounts-phone *
but error was shown while including that package.
[Edit:1]
*=> Errors while adding packages:
While selecting package versions:
error: Conflict: Constraint npm-bcrypt#=0.7.7 is not satisfied by npm-bcrypt
0.7.8_2.
Constraints on package "npm-bcrypt":
* npm-bcrypt#=0.7.8_2 <- accounts-password 1.1.1
* npm-bcrypt#=0.7.7 <- okland:accounts-phone 0.0.10*
This is a problem with the older versions of bycrpt and the old accounts-base package it depends on. I recently made a pull request to the okland:accounts-phone package which updates accounts-phone to depend on accounts-password and a newer bycrpt version.
Alternatively, if you don't want to wait, you can download his repo locally (okland:accounts-phone) into a packages dir at the root level of your project, and change the packages.js file as such:
Package.describe({
name : 'accounts-phone',
--skipped some lines--
Package.onUse(function (api) {
-api.use('npm-bcrypt#=0.7.8_2', 'server');
+api.use('npm-bcrypt#=0.8.7_1', 'server');
-api.use('accounts-base#1.0.2', ['client', 'server']);
+api.use('accounts-password#1.2.14', ['client', 'server']);
// Export Accounts (etc) to packages using this one.
-api.imply('accounts-base#1.0.2', ['client', 'server']);
+api.imply('accounts-password#1.2.14', ['client', 'server']);
(Make sure to get rid of the '+' and '-', they're just there to indicate what's deleted and what's new). Then, add the local using meteor add accounts-phone'. It will work just fine.

Trouble definding NPm dependancies inside local package

I am trying to create a package, but I cannot require npm modules inside the package. This results in a
Cannot find module '..path../crypto'
/packages/s3policy/lib/s3policy.js
crypto = Npm.require('crypto');
S3Policy = {};
S3Policy.readPolicy...
/packages/s3policy/package.js
Npm.depends({
'crypto': '0.0.3'
});
Package.describe({
name: 's3policy',
summary: 'S3 policy API',
version: '0.0.1'
});
Package.on_use(function (api) {
api.add_files('lib/s3policy.js', ['server']);
api.export('S3Policy');
});
Any idea as to why I am unable to require the crypto module?
Maybe this helps?
crypto is a built in node package (http://nodejs.org/api/crypto.html). It doesn't need to be installed. However, the npm crypto package is 2 year old unmaintained code that is often downloaded by mistake (https://www.npmjs.org/package/crypto). Either Meteor or NPM gets confused because the packages have the same name, but it doesn't really matter because you don't want the NPM package.
Just take crypto out of your npm packages and you should be fine.

Meteor: Could not resolve the specified constraints for this project: Unknown package

What are the constraints that Meteor is trying to resolve when it loads the packages at startup? Is it all related to versioning or is it actually looking at the code that you load with ap.use() in packages.js?
I am getting this error when I try to start up my project. I have a super-simple package file that I created with the meter create --package command. I put all of my files that make up the package into the directory that it created and moved that directory to .meteor/packages. I'm just trying to create a local package for now. Here's the contents of package.js in that directory:
Package.describe({
name: 'ammap-meteor',
summary: 'mapping library packaged for meteor ',
version: '1.0.0',
});
Package.onUse(function(api) {
api.versionsFrom('METEOR#0.9.0');
api.addFiles('ammap.js');
api.addFiles('ammap_amcharts_extension.js');
});
Package.onTest(function(api) {
api.use('tinytest');
api.use('ammap-meteor');
api.addFiles('ammap-meteor-tests.js');
});
My ammap-meteor-tests.js file is blank for the moment but it exists. Would that make a difference? And I assume you just omit the git: property from Package.onUse() for a local package, is that right?
OK, I was able to get past that error with the publish command:
meteor publish --create
So I did not succeed in making a local package (still not clear on that) but at least I can get the package to load now.

How do I depend on another package when writing a package for Meteor

I am writing a package for my own Meteor App. I need to depend on a package named 'urlify' since it is not cover my needs.
in your smart.json, you can use packages indicate dependancies. (for mrt to work)
{
"name": "YOUR_PACKAGE_NAME",
"packages": {
"urlify": "0.1.0"
}
}
in your package.json indicate dependancies for meteor.
Package.on_use(function (api) {
api.use(['urlify'], ['client', 'server']);
});

Resources