Ionic with ui-router.stateHelper - ionic-framework

Is it possiable to use ionic with ui-router.stateHelper
I want to use this for help me working with nested views:
the property children is what I'm looking for.
If its not possible, how can i do something similar, without defining each child state with name: parent.child?
after installing and import im getting the next error:
TypeError: Cannot read property '#' of undefined at updateView (http://localhost:8100/lib/ionic/js/ionic.bundle.js:62199:69)
at http://localhost:8100/lib/ionic/js/ionic.bundle.js:62194:9
at invokeLinkFn (http://localhost:8100/lib/ionic/js/ionic.bundle.js:21830:9)
at nodeLinkFn (http://localhost:8100/lib/ionic/js/ionic.bundle.js:21330:11)
at compositeLinkFn (http://localhost:8100/lib/ionic/js/ionic.bundle.js:20721:13)
at compositeLinkFn (http://localhost:8100/lib/ionic/js/ionic.bundle.js:20725:13)
at compositeLinkFn (http://localhost:8100/lib/ionic/js/ionic.bundle.js:20725:13)
at publicLinkFn (http://localhost:8100/lib/ionic/js/ionic.bundle.js:20596:30)
at http://localhost:8100/lib/ionic/js/ionic.bundle.js:14815:27
at Scope.$eval (http://localhost:8100/lib/ionic/js/ionic.bundle.js:29026:28) <ion-nav-view class="view-container" nav-view-transition="ios">

Ok This is working.. I had problem with the indjection.
this is the right way: (im using browserify)
npm install angular-ui-router.statehelper
then in the package.json
under browser:
"angular-ui-router-helper": "./node_modules/angular-ui-router.statehelper/statehelper.min.js"
and under browserify-shim
"browserify-shim": {
"angular": "angular",
"ionic": "ionic",
"angular-ui-router-helper": {
"exports": "angular.module('ui.router.stateHelper')"
}
},
and then in the index.js:
var rootModule = angular.module('AppName', ['ionic',require('angular-ui-router-helper').name]);
Then u can inject the stateHelperProvider to the config method :)

Related

url-loader without webpack?

I have a component library that will be shipping with a few small assets (images). Those assets are imported into various components in the library.
The build script uses babel (without webpack) to transpile the js(x) to a build directory, and is currently dumping the images into build/assets/images.
This works when testing the build, but when using the component in another project (using webpack) the component tries to refer the node_modules folder:
Example component:
import myImage from './assets/images/myImage.png';
const MyComponent = () => (
<img src={myImage} />
);
export MyComponent;
Usage:
import MyComponent from 'myLibrary/MyComponent';
export default () => (
<MyComponent />
);
The error message:
myImage.png:1 GET http://localhost:9001/node_modules/myLibrary/assets/images/myImage.png 404 (Not Found)
As I understand the 'best' way to include assets is to use the url-loader so they're converted to data uri's. However, trying to use the url-loader without Webpack isn't working:
babel.config.js
...
plugins: [
[
"url-loader",
{
"extensions": ["png", "jpg", "jpeg", "gif", "svg", "pdf"],
"limit": 0
}
]
]
...
Error: Cannot find module 'babel-plugin-url-loader'
I found this and it works for PNG and SVG files - worked perfectly for what I needed!
https://www.npmjs.com/package/babel-plugin-inline-import-data-uri

Jest: Cannot use import statement outside a module

I got an error when I run test using Jest, I tried to fix this error for 2 hours. But, I couldn't fix it. My module is using gapi-script package and error is occurred in this package. However, I don't know why this is occurred and how to fix it.
jest.config.js
module.exports = {
"collectCoverage": true,
"rootDir": "./",
"testRegex": "__tests__/.+\\.test\\.js",
"transform": {
'^.+\\.js?$': "babel-jest"
},
"moduleFileExtensions": ["js"],
"moduleDirectories": [
"node_modules",
"lib"
]
}
babel.config.js
module.exports = {
presets: [
'#babel/preset-env',
]
};
methods.test.js
import methods, { typeToActions } from '../lib/methods';
methods.js
import { gapi } from "gapi-script";
...
Error Message
C:\haram\github\react-youtube-data-api\node_modules\gapi-script\index.js:1
({"Object.":function(module,exports,require,__dirname,__filename,global,jest){import
{ gapi, gapiComplete } from './gapiScript';
SyntaxError: Cannot use import statement outside a module
What is wrong with my setting?
As of this writing, Jest is in the process of providing support for ES6 modules. You can track the progress here:
https://jestjs.io/docs/en/ecmascript-modules
For now, you can eliminate this error by running this command:
node --experimental-vm-modules node_modules/.bin/jest
instead of simply:
jest
Be sure to check the link before using this solution.
I solved this with the help of Paulo Coghi's answer to another question -
Does Jest support ES6 import/export?
Step 1:
Add your test environment to .babelrc in the root of your project:
{
"env": {
"test": {
"plugins": ["#babel/plugin-transform-modules-commonjs"]
}
}
}
Step 2:
Install the ECMAScript 6 transform plugin:
npm install --save-dev #babel/plugin-transform-modules-commonjs
Jest needs babel to work with modules.
For the testing alone, you do not need jest.config.js, just name the testfiles xxx.spec.js or xxx.test.js or put the files in a folder named test.
I use this babel.config.js:
module.exports = function (api) {
api.cache(true)
const presets = [
"#babel/preset-env"
]
return {
presets
}
}
Adding "type": "module" in package.json or using mjs as stated in other answers is not necessary when your setup is not too complicated.
I have also faced the same issue and this was resolved by adding following command-line option as a environment variable.
export NODE_OPTIONS=--experimental-vm-modules npx jest //linux
setx NODE_OPTIONS "--experimental-vm-modules npx jest" //windows
Upgrading Jest (package.json) to version 29 (latest as of now) solved this problem for me.

Migrating to Meteor 1.7.0.4 : MongoDB : "updating the path ... would create a conflict at ..."

Im using meteor, and im trying to go from meteor 1.6 to 1.7
But im encountering errors im unable to get informations about in my tests :
tests.jpg
I get multiple things like this (some are maybe redondant, unused or obsolete) :
Error: Updating the path 'relationChangeRate' would create a conflict at 'relationChangeRate'
at Function.MongoError.create (C:\Users\fquesselaire\AppData\Local\.meteor\packages\npm-mongo\3.0.11\npm\node_modules\mongodb-core\lib\error.js:45:10)
at toError (C:\Users\fquesselaire\AppData\Local\.meteor\packages\npm-mongo\3.0.11\npm\node_modules\mongodb\lib\utils.js:149:22)
at C:\Users\fquesselaire\AppData\Local\.meteor\packages\npm-mongo\3.0.11\npm\node_modules\mongodb\lib\collection.js:1029:39
at C:\Users\fquesselaire\AppData\Local\.meteor\packages\npm-mongo\3.0.11\npm\node_modules\mongodb-core\lib\connection\pool.js:544:18
at _combinedTickCallback (internal/process/next_tick.js:131:7)
at process._tickDomainCallback (internal/process/next_tick.js:218:9)
not occurring in 1.6.*
I tried upgrade my mongodb to 3.6.6, no effect.
Im also unable to get the entire stack in tests to see what is exactly enforcing.
my .meteor/versions :
255kb:meteor-status#1.5.0
accounts-base#1.4.2
accounts-password#1.5.1
akasha:fs-extra#0.26.3
alanning:roles#1.2.16
aldeed:autoform#6.3.0
aldeed:autoform-bs-button-group-input#2.0.0
aldeed:autoform-select2#3.0.1
aldeed:collection2-core#2.1.2
aldeed:template-extension#4.1.0
allow-deny#1.1.0
arillo:flow-router-helpers#0.5.2
autoupdate#1.4.1
babel-compiler#7.1.1
babel-runtime#1.2.4
base64#1.0.11
binary-heap#1.0.10
blaze#2.3.2
blaze-html-templates#1.1.2
blaze-tools#1.0.10
boilerplate-generator#1.5.0
caching-compiler#1.1.12
caching-html-compiler#1.1.3
callback-hook#1.1.0
check#1.3.1
coffeescript#1.0.17
cultofcoders:mocha#2.4.6
dburles:collection-helpers#1.1.0
dburles:factory#1.1.0
ddp#1.4.0
ddp-client#2.3.3
ddp-common#1.4.0
ddp-rate-limiter#1.0.7
ddp-server#2.2.0
deps#1.0.12
diff-sequence#1.1.0
dynamic-import#0.4.1
ecmascript#0.11.1
ecmascript-runtime#0.7.0
ecmascript-runtime-client#0.7.2
ecmascript-runtime-server#0.7.1
ejson#1.1.0
email#1.2.3
es5-shim#4.8.0
fourseven:scss#4.9.0
geojson-utils#1.0.10
hot-code-push#1.0.4
html-tools#1.0.11
htmljs#1.0.11
http#1.4.1
id-map#1.1.0
idmontie:migrations#1.0.3
jquery#1.11.11
kadira:blaze-layout#2.3.0
kadira:flow-router#2.12.1
lai:collection-extensions#0.2.1_1
launch-screen#1.1.1
livedata#1.0.18
lmieulet:meteor-coverage#1.1.4
localstorage#1.2.0
logging#1.1.20
matb33:collection-hooks#0.8.4
meteor#1.9.2
meteor-base#1.4.0
meteorhacks:picker#1.0.3
meteortesting:browser-tests#1.0.0
meteortesting:mocha#1.0.0
minifier-css#1.3.1
minifier-js#2.3.5
minimongo#1.4.4
mobile-experience#1.0.5
mobile-status-bar#1.0.14
modern-browsers#0.1.2
modules#0.12.2
modules-runtime#0.10.2
momentjs:moment#2.22.2
mongo#1.5.1
mongo-dev-server#1.1.0
mongo-id#1.0.7
mouse0270:bootstrap-notify#3.1.3
natestrauser:select2#4.0.3
npm-bcrypt#0.9.3
npm-mongo#3.0.11
observe-sequence#1.0.16
ordered-dict#1.1.0
ostrio:cookies#2.3.0
ostrio:files#1.10.1
practicalmeteor:chai#2.1.0_1
practicalmeteor:loglevel#1.2.0_2
practicalmeteor:mocha-core#1.0.1
practicalmeteor:sinon#1.14.1_2
promise#0.11.1
raix:eventemitter#0.1.3
random#1.1.0
rate-limit#1.0.9
reactive-dict#1.2.1
reactive-var#1.0.11
reload#1.2.0
retry#1.1.0
rocketchat:streamer#0.5.0
routepolicy#1.0.13
service-configuration#1.0.11
session#1.1.8
sewdn:collection-behaviours#0.3.0
sha#1.0.9
shell-server#0.3.1
socket-stream-client#0.2.2
softwarerero:accounts-t9n#1.3.11
spacebars#1.0.15
spacebars-compiler#1.1.3
srp#1.0.12
standard-minifier-css#1.4.1
standard-minifier-js#2.3.4
templating#1.3.2
templating-compiler#1.3.3
templating-runtime#1.3.2
templating-tools#1.1.2
tmeasday:check-npm-versions#0.3.2
tmeasday:test-reporter-helpers#0.2.1
tracker#1.2.0
ui#1.0.13
underscore#1.0.10
url#1.2.0
useraccounts:bootstrap#1.14.2
useraccounts:core#1.14.2
useraccounts:flow-routing#1.14.2
webapp#1.6.2
webapp-hashing#1.0.9
zimme:active-route#2.3.2
my node packages :
"dependencies": {
"#babel/runtime": "^7.0.0-beta.54",
"#mdi/font": "^2.5.94",
"babel-runtime": "^6.26.0",
"bcrypt": "^3.0.0",
"bootstrap": "^3.3.7",
"bootstrap-material-design": "^0.5.10",
"bootstrap-slider": "^10.0.2",
"bootstrap-toggle": "^2.2.2",
"clone": "^2.1.1",
"csv-parse": "^2.5.0",
"d3": "^5.5.0",
"file-saver": "^1.3.8",
"fs-extra": "^3.0.1",
"gm": "^1.23.0",
"jquery": "^2.2.4",
"jsondiffpatch": "^0.3.11",
"lodash": "^4.17.10",
"meteor-node-stubs": "^0.4.1",
"mkdirp": "^0.5.1",
"object-path": "^0.11.4",
"popper.js": "^1.14.3",
"select2": "^4.0.4",
"select2-bootstrap-theme": "^0.1.0-beta.10",
"simpl-schema": "^1.5.3",
"uuid": "^3.3.2",
"xmldoc": "^1.1.0",
"zip-local": "^0.3.4"
},
"devDependencies": {
"chromedriver": "^2.40.0",
"gulp": "^3.9.1",
"selenium-webdriver": "^3.6.0"
}
if you have any clue about what is going on ?
i can give more informations about what's happening in the app, but right now a simple explain about what this error mean would be awesome already. as i said, this error only append in 1.7.
EDIT: forget to say that my test throw this on WORKING code.
Features are working well, but not the tests.
EDIT²:
This method is the one that update the collection projectSettings.
_duplicateProjectSettings(newSession) {
const settings = this.session.projectSettings();
delete settings._id;
settings.sessionId = newSession._id;
const newSettings = newSession.projectSettings();
ProjectSettings.update(newSettings._id, { $set: settings });
}
relationChangeRate is a simpl-schema field of projectSettings collection as it (i use collection2-core) :
relationChangeRate: {
type: Number,
allowedValues: _.values(RelationRates),
defaultValue: 0.0
}
projectSettings extends mongo.collection, but in this case, update method is not override.
The code seams correct to me, as the _id is well removed and set to the new object before update request. but maybe im wrong ?
EDIT³:
ProjectSettings is a collection-helper:
Here is the code :
Sessions.helpers({
[...]
projectSettings() {
const conds = { sessionId: this._id };
return ProjectSettings.findOne(conds);
},
[...]
A collection helper basically add a method on each document from this collection. It means that any session object will have this method. In a collection helper, "this" refer to the current collection object.
so should be good ?
_duplicateProjectSettings could be write like this:
_duplicateProjectSettings(newSession) {
// const settings = this.session.projectSettings();
const settings = ProjectSettings.findOne({ sessionId: this.session._id });
delete settings._id;
settings.sessionId = newSession._id;
// const newSettings = newSession.projectSettings();
const newSettings = ProjectSettings.findOne({ sessionId: newSession._id });
ProjectSettings.update(newSettings._id, { $set: settings });
}
(I tried it too, same result)
Running this from shell worked for me... not the best solution. I had the problem when I tried to login with accounts-password package.
$ meteor mongo
meteor:PRIMARY> db.adminCommand( { setFeatureCompatibilityVersion: "3.4" } )
Ok,
This is an half-answer but
After some extended search i figured that i had a test script that reset MONGO_URL as follow :
set MONGO_URL=
set TEST_BROWSER_DRIVER=chrome
set TEST_WATCH=1
set TEST_CLIENT=0
set TEST_SERVER=1
meteor test -p 3100 --driver-package=cultofcoders:mocha %*
after figuring that i launched the tests on my local dev db, and tests passed (smashing my db by the way lol). So, it means it could be version related, or test-conditions related.
I am not able to print the version of mongodb used for tests, so i don't know the tests conditions exactly.
All i know is so :
Meteor "normal run" Mongo version : 3.6.4
My local Mongo version : 3.6.6

r.js throws an error every time I try to assign a variable in Coffee-Script

So I'm using r.js to build a bunch of my files -- some of which are Coffee-Script. I am using the Require plugin require-cs to handle this.
Here is a look at my Require.js config, a la rjs:
rjs.optimize({
baseUrl: SRC_PATH,
include: channelMap[channel],
optimize: 'none',
stubModules: ['cs', 'tpl', 'less', 'text'],
exclude: ['normalize', 'coffee-script', 'underscore'],
CoffeeScript: {
header: false,
// since we use AMD, there's no need for IIFE
bare: true
},
separateCSS: true,
skipModuleInsertion: true,
// If something needs to be present for tests too and not only for
// the build step, then add it tools/karma-amd.js instead
paths: _.extend({
'less-builder': 'vendor/require-less/less-builder',
'normalize': 'vendor/require-less/normalize'
}, rjsPaths),
wrap: true,
less: {
paths: [path.join(BASE_SHOP_FOLDER, 'static', 'zalando', 'css', channel)]
},
out: path.join(BUILD_PATH, channel, BUILD_BASE_FILE_NAME + '.js')
}, function () {
// this needs to be async because less builder uses
// process.nextTick() to write the file
process.nextTick(done);
});
Even the most simple .coffee file seems to fail violently. E.g.
define [], ->
foo = "hello world"
return foo
throws the following error:
the variable "foo" can't be assigned with undefined because it has not been declared before
foo = "hello world"
^^^
When I use replace require-cs's coffee-script.js with the older version of 1.6.3 everything works just fine.
Your code compiles BTW. Try to go to CoffeeScriptDahWebSite and click on TRY COFFEESCRIPT and you will see that it is valid code.
From the define [], () -> code ..., I assume you are using the CoffeeScript plugin with require.js. I am ready to bet your issue is in the require.js configuration (which should be your main.js file or whatever you named it) since the error you get looks oddly like the JavaScript interpreter trying to run the invalid code you wrote (for JavaScript that is :). Meaning, your plugin is not there at all.
If you give me your require configuration maybe I can edit this answer and help you more.
Cheers!
EDIT
I see you edited your question, but you provided me the wrong file. What you showed me was the r.js optimizer configuration, instead of the main.js which specifies how cs.js and coffee-script.js files are loaded. The error might be in your optimizer, but I can't know without seeing your other config.
A reiteration of that, show me the entry point of your program, the data-main that is loaded in your HTML.
I was unable to recreate the issue:
$ cat ./etc/temp1.coffee
define [], ->
foo = "hello world"
return foo
$ coffee --version
CoffeeScript version 1.7.1
$ which coffee
/home/dev/.nvm/v0.10.23/bin/coffee
$ coffee -cp ./etc/temp1.coffee
// Generated by CoffeeScript 1.7.1
(function() {
define([], function() {
var foo;
foo = "hello world";
return foo;
});
}).call(this);
$ coffee -cpb ./etc/temp1.coffee
// Generated by CoffeeScript 1.7.1
define([], function() {
var foo;
foo = "hello world";
return foo;
});
Turns out the problem was with my previous version of 1.7.1. Someone Beautified it and broke everything. Everything works as advertised when I go out of my way to get coffee-script.js from http://coffeescript.org/extras/coffee-script.js

Which DoctrineBundle version works with Symfony 2.0.15?

I've spent days now trying to sort out my deps in Symfony 2.0.15. I can't find a compatible list of bundles and I've been chasing commits around github trying to follow a chain of non-BC changes to get a list of versions that works for me. Eventually I chose to give up and upgraded to composer, only to find that some of the Doctrine core requires Symfony 2.1, yet some of the other Doctrine bundles require Symfony <2.1 and eventually I gave up on that as well.
Can someone with the following Bundles installed please let me know what stable versions they are using from their deps.lock?
[symfony]
git=http://github.com/symfony/symfony.git
version=v2.0.15
[twig]
git=http://github.com/fabpot/Twig.git
version=v1.8.2
[monolog]
git=http://github.com/Seldaek/monolog.git
version=1.0.2
[doctrine-common]
git=http://github.com/doctrine/common.git
version=2.1.4
[doctrine-dbal]
git=http://github.com/doctrine/dbal.git
version=2.1.7
[doctrine]
git=http://github.com/doctrine/doctrine2.git
version=2.1.7
[swiftmailer]
git=http://github.com/swiftmailer/swiftmailer.git
version=v4.1.7
[assetic]
git=http://github.com/kriswallsmith/assetic.git
version=cc2e9adb744df0704a5357adc1cf9287c427420f
[twig-extensions]
git=http://github.com/fabpot/Twig-extensions.git
[metadata]
git=http://github.com/schmittjoh/metadata.git
version=1.0.0
[SensioFrameworkExtraBundle]
git=http://github.com/sensio/SensioFrameworkExtraBundle.git
target=/bundles/Sensio/Bundle/FrameworkExtraBundle
version=origin/2.0
[JMSSecurityExtraBundle]
git=http://github.com/schmittjoh/JMSSecurityExtraBundle.git
target=/bundles/JMS/SecurityExtraBundle
version=origin/1.0.x
[SensioDistributionBundle]
git=http://github.com/sensio/SensioDistributionBundle.git
target=/bundles/Sensio/Bundle/DistributionBundle
version=origin/2.0
[SensioGeneratorBundle]
git=http://github.com/sensio/SensioGeneratorBundle.git
target=/bundles/Sensio/Bundle/GeneratorBundle
version=origin/2.0
[AsseticBundle]
git=http://github.com/symfony/AsseticBundle.git
target=/bundles/Symfony/Bundle/AsseticBundle
version=v1.0.1
[doctrine-mongodb]
git=http://github.com/doctrine/mongodb.git
[doctrine-mongodb-odm]
git=http://github.com/doctrine/mongodb-odm.git
[DoctrineMongoDBBundle]
git=http://github.com/doctrine/DoctrineMongoDBBundle.git
target=/bundles/Symfony/Bundle/DoctrineMongoDBBundle
version=v2.0.1
[DoctrineMigrationsBundle]
git=https://github.com/doctrine/DoctrineMigrationsBundle.git
target=/bundles/Symfony/Bundle/DoctrineMigrationsBundle
version=origin/2.0
[doctrine-migrations]
git=http://github.com/doctrine/migrations.git
[doctrine-fixtures]
git=http://github.com/doctrine/data-fixtures.git
[DoctrineFixturesBundle]
git=https://github.com/doctrine/DoctrineFixturesBundle.git
target=/bundles/Symfony/Bundle/DoctrineFixturesBundle
version=origin/2.0
[DoctrineBundle]
git=http://github.com/doctrine/DoctrineBundle.git
target=/bundles/Doctrine/Bundle/DoctrineBundle
[FOSJsRoutingBundle]
git=http://github.com/FriendsOfSymfony/FOSJsRoutingBundle.git
target=/bundles/FOS/JsRoutingBundle
[GedmoDoctrineExtensions]
git=http://github.com/l3pp4rd/DoctrineExtensions.git
target=/gedmo-doctrine-extensions
[StofDoctrineExtensionsBundle]
git=http://github.com/stof/StofDoctrineExtensionsBundle.git
target=/bundles/Stof/DoctrineExtensionsBundle
With these combinations I get a constant set of errors due to classes not existing or renamed methods, which I then look up in the github repositories and try to fix to a commit/tag which resolves this error, only to get another set of errors because of other classes not existing or renamed methods. I can't go back to the stable state I had a few weeks ago because of the namespace changes to the Doctrine organisation - (#see What happened to Doctrine's Symfony Bundle repos?)
Alternatively I don't mind switching to composer; heres the composer.json that I tried, but doesn't work
{
"require": {
"symfony/symfony" : "v2.0.15",
"symfony/doctrine-bridge": "2.1.x-dev",
"doctrine/common" : "2.1.4",
"doctrine/orm" : "2.1.6",
"symfony/finder" : "v2.0.15",
"symfony/assetic-bundle" : "2.0.x-dev",
"twig/extensions" : "dev-master",
"jms/security-extra-bundle" : "1.0.x",
"sensio/framework-extra-bundle" : "2.0.x-dev",
"sensio/distribution-bundle" : "2.0.x-dev",
"sensio/generator-bundle" : "2.0.x-dev",
"doctrine/doctrine-bundle": "v1.0.0-beta1",
"doctrine/mongodb-odm-bundle": "v2.0.1",
},
"autoload": {
"psr-0": {
"Oh": "src/"
}
}
}
Whenever I try to fix dependencies in the composer.json I seem to get in a cycle of upgrading and degrading the same packages over and over again but always getting the error "Your requirements could not be solved to an installable set of packages.". If someone could provide me with their composer.json setup using Symfony 2.0.15 with the Doctrine,MongoDB,DoctrineFixtures and DoctrineMigrations bundles I'd be most grateful.
Here's part of my working composer configuration:
{
"require": {
"php": ">=5.3.3",
"symfony/symfony": "2.0.15",
"doctrine/orm": "2.1.7",
"twig/extensions": "*",
"symfony/assetic-bundle": "2.0.x-dev",
"sensio/generator-bundle": "2.0.*",
"sensio/framework-extra-bundle": "2.0.*",
"jms/security-extra-bundle": "1.0.*",
"stof/doctrine-extensions-bundle": "*",
"doctrine/doctrine-migrations-bundle": "2.0.*"
}
}
I'm not using ODM though.