Compilation Issues building Nativescript app after upgrade to NS 7.0.6 - nativescript

After a long time, I have upgraded my Nativescript app which was running fine on NS version 5. After upgraded to NS 7.0.6 through NS version 6, I started getting following errors coming from the plugin dependencies. Please note I have tried deleting the node_modules, hooks and platform folders.
node_modules/#nativescript/core/global-types.d.ts:1:1 - error TS6200: Definitions of the following identifiers conflict with those in another file: "audio", "beacon", "cspreport", "download", "embed", "eventsource", "favicon", "fetch", "font", "form", "frame", "hyperlink", "iframe", "image", "imageset", "import", "internal", "location", "manifest", "object", "ping", "plugin", "prefetch", "script", "serviceworker", "sharedworker", "subresource", "style", "track", "video", "worker", "xmlhttprequest", "xslt", HeaderInit, WeakRef
1 declare var global: NodeJS.Global & typeof globalThis;
~~~~~~~
node_modules/tns-core-modules/node_modules/#nativescript/core/tns-core-modules.d.ts:4:1
4 declare enum RequestContext {
~~~~~~~
Conflicts are in this file.
node_modules/#nativescript/core/global-types.d.ts:136:14 - error TS2300: Duplicate identifier 'ModuleType'.
136 declare type ModuleType = 'markup' | 'script' | 'style';
~~~~~~~~~~
node_modules/tns-core-modules/node_modules/#nativescript/core/module.d.ts:95:14
95 declare type ModuleType = "markup" | "script" | "style";
~~~~~~~~~~
'ModuleType' was also declared here.
node_modules/tns-core-modules/node_modules/#nativescript/core/module.d.ts:2:13 - error TS2403: Subsequent variable declarations must have the same type. Variable 'global' must be of type 'Global & typeof globalThis', but here has type 'Global'.
2 declare var global: NodeJS.Global;
~~~~~~
node_modules/#nativescript/core/global-types.d.ts:1:13
1 declare var global: NodeJS.Global & typeof globalThis;
~~~~~~
'global' was also declared here.
node_modules/tns-core-modules/node_modules/#nativescript/core/module.d.ts:95:14 - error TS2300: Duplicate identifier 'ModuleType'.
95 declare type ModuleType = "markup" | "script" | "style";
~~~~~~~~~~
node_modules/#nativescript/core/global-types.d.ts:136:14
136 declare type ModuleType = 'markup' | 'script' | 'style';
~~~~~~~~~~
'ModuleType' was also declared here.
node_modules/tns-core-modules/node_modules/#nativescript/core/tns-core-modules.d.ts:4:1 - error TS6200: Definitions of the following identifiers conflict with those in another file: "audio", "beacon", "cspreport", "download", "embed", "eventsource", "favicon", "fetch", "font", "form", "frame", "hyperlink", "iframe", "image", "imageset", "import", "internal", "location", "manifest", "object", "ping", "plugin", "prefetch", "script", "serviceworker", "sharedworker", "subresource", "style", "track", "video", "worker", "xmlhttprequest", "xslt", HeaderInit, WeakRef
4 declare enum RequestContext {
~~~~~~~
node_modules/#nativescript/core/global-types.d.ts:1:1
1 declare var global: NodeJS.Global & typeof globalThis;
~~~~~~~
Conflicts are in this file.
node_modules/tns-core-modules/node_modules/#nativescript/core/tns-core-modules.d.ts:5:5 - error TS2432: In an enum with multiple declarations, only one declaration can omit an initializer for its first enum element.
5 "audio", "beacon", "cspreport", "download", "embed", "eventsource", "favicon", "fetch",
~~~~~~~
Found 6 errors.
Following are my plugin dependencies:
"dependencies": {
"#nativescript/core": "~7.0.11",
"crypto-js": "^4.0.0",
"nativescript-appversion": "^1.4.4",
"nativescript-grid-view": "^5.1.0",
"nativescript-purchase": "^2.0.14",
"nativescript-screen-orientation": "^2.0.0",
"nativescript-social-share-ns-7": "^11.6.0",
"nativescript-theme-core": "~1.0.6",
"nativescript-toast": "^2.0.0",
"nativescript-ui-chart": "8.0.2",
"nativescript-ui-sidedrawer": "9.0.3",
"nativescript-unit-test-runner": "0.7.0",
"rxjs": "~6.6.3"
}
Since this is part of plugin, I am not sure how I can have these fixed? Any help is highly appreciated. Please let me know in case you need any other details.

Related

Stricter lint of Golang in VSCode

I'm using VSCode for my Golang projects with the default lint settings, and I can't find a way to have a strict lint of my Go files, underlining the problems in the code, that would allow me to abide strictly to official Go guidelines, such as:
Starting comments of functions with the function name,
Using only camel case in variables,
Using only snake case in package name,
etc...
How to get strict linting behaviour in VSCode?
Yes you can. staticcheck is VSCode's default go linter.
Staticcheck's default configuration ignores certain rules. You can opt back in to all rules with your own staticcheck.conf with a checks=["all"] entry.
# https://staticcheck.io/docs/configuration
# checks = ["all", "-ST1000", "-ST1003", "-ST1016", "-ST1020", "-ST1021", "-ST1022", "-ST1023"]
checks = ["all"]
initialisms = ["ACL", "API", "ASCII", "CPU", "CSS", "DNS",
"EOF", "GUID", "HTML", "HTTP", "HTTPS", "ID",
"IP", "JSON", "QPS", "RAM", "RPC", "SLA",
"SMTP", "SQL", "SSH", "TCP", "TLS", "TTL",
"UDP", "UI", "GID", "UID", "UUID", "URI",
"URL", "UTF8", "VM", "XML", "XMPP", "XSRF",
"XSS", "SIP", "RTP", "AMQP", "DB", "TS"]
dot_import_whitelist = []
http_status_code_whitelist = ["200", "400", "404", "500"]

How to properly create a types npm package for a private feed

I have a private NPM package feed I want to use for scoped packages.
I've read the Publishing article of the TypeScript docs. Also I tried to create the package according to the #types/jquery package.
So this is what I came up with: Created (and published) a package with the name "#myscope/i18n". It's a pretty simple one and contains a .d.ts file with the declaration of a global interface I18N with the method translate(string). The tarball includes the following files:
index.d.ts
/**
* Static members of I18N
*/
interface I18NStatic {
/**
* Returns the translation value based on the specified key
*
* #param key The translation key.
*/
translate(key: string): string;
}
declare module "i18n" {
export = I18N;
}
declare var I18N: I18NStatic;
package.json
{
"name": "#myscope/i18n",
"version": "1.0.11",
"description": "TypeScript definitions for MyScope Translator",
"license": "MIT",
"main": "",
"repository": {
"type": "git",
"url": "https://myscope.visualstudio.com/example/_git/i18n"
},
"scripts": {},
"dependencies": {},
"peerDependencies": {},
"typeScriptVersion": "2.0"
}
I consume it in a ASP.NET Core project with the following package.json
{
"version": "1.0.0",
"name": "asp.net",
"private": true,
"devDependencies": {
"#types/jquery": "2.0.48",
"#types/semantic-ui": "2.2.4",
"#myscope/i18n": "1.0.11"
}
}
But when I try to use I18N.translate(string) in my TS files I always get this Error
Error TS2304 (TS) Cannot find name 'I18N'. Example.UI.WebApp (tsconfig project) C:\Users\Sandro\Source\Repos\example\Example.UI.WebApp\TypeScript\Address.ts
When I use index.d.ts directly in my project (not via npm) it works perfectly. But as soon as I delete it again, it stops working. I have no errors or warnings in the "Dependencies/npm" section of the project in solution explorer view.
What am I missing?

How to bundle AWS Cognito within Aurelia Framework

Since my previous post on another question was deleted, even though it was pretty explicit in presenting the problem (in that context), I will try again as a stand alone question.
I am trying to bundle Amazon Cognito with aurelia.json. I have followed everything I could thin of in the answers provided by jsachs and Nathan in the mentioned article, however I think something is incomplete.
{
"name": "account-components-bundle.js",
"source": {
"include": [
"**/components/account/**/*.js",
"**/components/account/**/*.{html,css}"
]
},
"dependencies": [
{
"name": "aws-sdk",
"path": "../node_modules/aws-sdk/dist",
"main": "aws-sdk.min",
"exports": "AWS"
}
],
"prepend": [
"node_modules/aws-sdk/dist/aws-sdk.min.js",
"node_modules/amazon-cognito-identity-js/dist/aws-cognito-sdk.min.js",
"node_modules/amazon-cognito-identity-js/dist/amazon-cognito-identity.min.js",
"node_modules/bluebird/js/browser/bluebird.core.js",
"node_modules/requirejs/require.js"
]
},
If you add only the prepend directive, au build will not throw any error, however I have no way of calling the Cognito classes.
Adding the dependencies directive in the form above will eventually bundle the package, however at page load you will get the following error (please keep in mind I am not calling anything yet within our own code):
Unhandled rejection Error: Script error for "aws-sdk/global", needed by: components/account/login
http://requirejs.org/docs/errors.html#scripterror
at makeError (https://white.dev/dist/aurelia-bundle.js:4419:17)
at HTMLScriptElement.onScriptError (https://white.dev/dist/aurelia-bundle.js:5989:36)
From previous event:
at DefaultLoader.loadModule (https://white.dev/dist/aurelia-bundle.js:14914:14)
at ViewEngine.importViewModelResource (https://white.dev/dist/aurelia-bundle.js:23006:26)
at CompositionEngine.ensureViewModel (https://white.dev/dist/aurelia-bundle.js:24276:32)
at CompositionEngine.createController (https://white.dev/dist/aurelia-bundle.js:24252:19)
at CompositionEngine._createControllerAndSwap (https://white.dev/dist/aurelia-bundle.js:24227:19)
at CompositionEngine.compose (https://white.dev/dist/aurelia-bundle.js:24313:21)
at processInstruction (https://white.dev/dist/aurelia-bundle.js:24798:32)
at Compose.bind (https://white.dev/dist/aurelia-bundle.js:24689:7)
at Controller.bind (https://white.dev/dist/aurelia-bundle.js:23196:24)
at View.bind (https://white.dev/dist/aurelia-bundle.js:21200:24)
at If._runValueChanged (https://white.dev/dist/aurelia-bundle.js:24887:19)
at If.valueChanged (https://white.dev/dist/aurelia-bundle.js:24842:31)
at If.bind (https://white.dev/dist/aurelia-bundle.js:24831:12)
From previous event:
at CompositionEngine._createControllerAndSwap (https://white.dev/dist/aurelia-bundle.js:24227:45)
at CompositionEngine.compose (https://white.dev/dist/aurelia-bundle.js:24313:21)
at TemplatingEngine.compose (https://white.dev/dist/aurelia-bundle.js:24576:38)
at Aurelia.setRoot (https://white.dev/dist/aurelia-bundle.js:13886:21)
at Object._callee$ (https://white.dev/dist/app-bundle.js:86:37)
at tryCatch (https://white.dev/dist/aurelia-bundle.js:3:27199)
at Generator.invoke [as _invoke] (https://white.dev/dist/aurelia-bundle.js:3:28901)
at Generator.t.(anonymous function) [as next] (https://white.dev/dist/aurelia-bundle.js:3:27447)
at step (https://white.dev/dist/app-bundle.js:25:44)
at https://white.dev/dist/app-bundle.js:36:29
From previous event:
at step (https://white.dev/dist/app-bundle.js:35:55)
at https://white.dev/dist/app-bundle.js:43:24
From previous event:
at Object.<anonymous> (https://white.dev/dist/app-bundle.js:22:20)
at Object.configure (https://white.dev/dist/app-bundle.js:97:25)
at https://white.dev/dist/aurelia-bundle.js:12465:29
From previous event:
at config (https://white.dev/dist/aurelia-bundle.js:12460:56)
at https://white.dev/dist/aurelia-bundle.js:12496:14
From previous event:
at bootstrap (https://white.dev/dist/aurelia-bundle.js:12495:26)
at https://white.dev/dist/aurelia-bundle.js:12482:9
at <anonymous>
From previous event:
at run (https://white.dev/dist/aurelia-bundle.js:12477:61)
at Object.<anonymous> (https://white.dev/dist/aurelia-bundle.js:12502:37)
at Object.execCb (https://white.dev/dist/aurelia-bundle.js:5947:33)
at Module.check (https://white.dev/dist/aurelia-bundle.js:5134:51)
at Module.enable (https://white.dev/dist/aurelia-bundle.js:5427:22)
at Object.enable (https://white.dev/dist/aurelia-bundle.js:5808:39)
at Module.<anonymous> (https://white.dev/dist/aurelia-bundle.js:5412:33)
at https://white.dev/dist/aurelia-bundle.js:4385:23
at each (https://white.dev/dist/aurelia-bundle.js:4310:31)
at Module.enable (https://white.dev/dist/aurelia-bundle.js:5364:17)
at Module.init (https://white.dev/dist/aurelia-bundle.js:5039:26)
at https://white.dev/dist/aurelia-bundle.js:5711:36
The moment I go further and try to extend the dependencies (not use the already compiled libraries), I get to the same old problem mentioned in the previous post.
"dependencies": [
{
"name": "lodash",
"path": "../node_modules/lodash",
"main": "index"
},
{
"name": "xmlbuilder",
"path": "../node_modules/xmlbuilder",
"main": "lib/index"
},
{
"name": "aws-sdk",
"path": "../node_modules/aws-sdk",
"main": "lib/aws",
"exports": "AWS"
}
],
This dependencies, when running au build, will lead to
File not found or not accessible: /path/to/project/node_modules/aws-sdk/lib/region_config_data.json.js. Requested by /path/to/project/node_modules/aws-sdk/lib/aws.js
{ Error: ENOENT: no such file or directory, open '/path/to/project/node_modules/aws-sdk/lib/region_config_data.json.js'
at Object.fs.openSync (fs.js:584:18)
at Object.fs.readFileSync (fs.js:491:33)
at Object.exports.readFileSync (/path/to/project/node_modules/aurelia-cli/lib/file-system.js:74:13)
at fileRead (/path/to/project/node_modules/aurelia-cli/lib/build/bundled-source.js:101:27)
at Object.context.fileRead (/path/to/project/node_modules/aurelia-cli/lib/build/amodro-trace/lib/loader/Loader.js:179:18)
at Object.context.load (/path/to/project/node_modules/aurelia-cli/lib/build/amodro-trace/lib/loader/Loader.js:370:32)
at Module.load (eval at <anonymous> (/path/to/project/node_modules/aurelia-cli/lib/build/amodro-trace/lib/loader/Loader.js:14:1), <anonymous>:832:29)
at Module.fetch (eval at <anonymous> (/path/to/project/node_modules/aurelia-cli/lib/build/amodro-trace/lib/loader/Loader.js:14:1), <anonymous>:822:66)
at Module.check (eval at <anonymous> (/path/to/project/node_modules/aurelia-cli/lib/build/amodro-trace/lib/loader/Loader.js:14:1), <anonymous>:854:30)
at Module.enable (eval at <anonymous> (/path/to/project/node_modules/aurelia-cli/lib/build/amodro-trace/lib/loader/Loader.js:14:1), <anonymous>:1173:22)
errno: -2,
code: 'ENOENT',
syscall: 'open',
I think this is caused by the fact that requirejs in comparison to nodejs require() may not support loading json files and it always expects the file to be a js one.
At this point in my debugging quest I am kinda stuck. Has anyone got any suggestions in how this can be achieved? I would be very grateful.
To avoid and exclude some previous questions to my approaches, I have tried to add to the bundle dependencies "amazon-cognito-identity-js" as well, in more than one form (both dist and lib files). The outcome is the same as the one above. I get stuck at json.js error.
Edit 1
I managed to clean all compile errors with the following form for aurelia.json, however the classes are not loading properly.
"bundles": [
{
"name": "app-bundle.js",
"source": {
"include": [
"**/src/main.js",
"**/src/app.js",
"**/src/environment.js",
"**/src/app.{html,css}"
]
}
},
...
{
"name": "vendor-bundle.js",
"dependencies": [
...
{
"name": "lodash",
"path": "../node_modules/lodash",
"main": "index"
},
{
"name": "xmlbuilder",
"path": "../node_modules/xmlbuilder",
"main": "lib/index"
},
{
"name": "aws-sdk",
"path": "../node_modules/aws-sdk",
"main": "dist/aws-sdk",
"exports": "AWS"
}
],
"append": [
"node_modules/amazon-cognito-identity-js/dist/aws-cognito-sdk.min.js",
"node_modules/amazon-cognito-identity-js/dist/amazon-cognito-identity.min.js"
]
},
...
]
Funny to give the answer myself, but hey... if it will help others...
I managed to bundle the scripts by prepending them in the aurelia-bundle.js ahead of every other scripts that need to be loaded. Please understand, that (for me), placing the scripts in any other position that the following, will end up in neither loading correctly or not loading at all.
Don't pretend this is a general solution, but hey... works for me.
Please find a more detailed history here.
{
"name": "aurelia-bundle.js",
"prepend": [
"node_modules/aws-sdk/dist/aws-sdk.min.js",
"node_modules/amazon-cognito-identity-js/dist/aws-cognito-sdk.min.js",
"node_modules/amazon-cognito-identity-js/dist/amazon-cognito-identity.min.js",
"node_modules/babel-polyfill/dist/polyfill.min.js",
"node_modules/whatwg-fetch/fetch.js",
"node_modules/bluebird/js/browser/bluebird.core.js",
"node_modules/aurelia-cli/lib/resources/scripts/configure-bluebird.js",
"node_modules/requirejs/require.js"
],
"dependencies": [
"aurelia-animator-css",
"aurelia-binding",
"aurelia-bootstrapper",
"aurelia-dependency-injection",
"aurelia-event-aggregator",

Pebble sdk 2.x unable to load resource

I know pebble 2.x is a bit outdated, but that's the watch that I recently got and am interested in writing a small app on this.
I am unable to load the resource files (images and font) in my pebble app. Below is the error message when I try to run pebble build:
Setting top to : /home/mixi/Documents/pebble-dev/helloworld
Setting out to : /home/mixi/Documents/pebble-dev/helloworld/build
Checking for program gcc,cc : arm-none-eabi-gcc
Checking for program ar : arm-none-eabi-ar
Found Pebble SDK in : /home/mixi/.pebble-sdk/SDKs/current/sdk-core/pebble/aplite
'configure' finished successfully (0.220s)
Waf: Entering directory `/home/mixi/Documents/pebble-dev/helloworld/build'
Error Generating Resources: File: bt-icon.png has specified invalid type: bitmap
Must be one of (raw, png, png-trans, font)
Generating resources failed
My appinfo.json:
{
"uuid": "93c49fe2-0b1e-44b8-8fff-22d9c87adab9",
"shortName": "helloworld",
"longName": "helloworld",
"companyName": "MakeAwesomeHappen",
"versionLabel": "1.0",
"sdkVersion": "2.9",
"targetPlatforms": ["aplite", "basalt", "chalk"],
"watchapp": {
"watchface": true
},
"appKeys": {
"dummy": 0
},
"resources": {
"media": [
{
"type": "bitmap",
"name": "IMAGE_BT_ICON",
"file": "bt-icon.png"
}
]
},
"versionCode": 1
}
My Pebble version:
Pebble Tool v4.0 (active SDK: v2.9)
I also tried creating a test app on pebblecloud with their sample. The sample runs fine without resource, but also fails when I add a new resource to the project. Is there a fix to this?
Apparently, pebble 2.x does not like "bitmap" type. All I had to do was change resource type to "png" in the JSON file:
"media": [
{
"type": "png",
"name": "IMAGE_BT_ICON",
"file": "bt-icon.png"
}
]
OMG =A=..
As for CloudPebble, the drop down for Resource Type doesn't seem to show up and it seems to select Bitmap by default.. Maybe it'll be fixed in the near future idk.

Syntax error occurs with cli node/coffeescript app installed globally via npm

I have a cli app written in coffee-script. The cli app uses commander (https://github.com/tj/commander.js) to take arguments. I have three files in my bin dir:
mediatidy
mediatidy-config
mediatidy-media
If I run bin/mediatidy in the project folder in bash commander executes fine. If I type bin/mediatidy config or bin/mediatidy media in bash commander also executes fine and is waiting for an <action>.
The odd thing is I published the project to npm and get different results when installed globally. If I install the project via sudo npm mediatidy -g (I am using Mac OSX 10.10) I can see the following files in /usr/local/bin/:
mediatidy
mediatidy-config
mediatidy-media
If I run bin/mediatidy in the project folder in bash commander executes fine. If I type bin/mediatidy config or bin/mediatidy media in bash I get the following error:
mediatidy config
/usr/local/lib/node_modules/mediatidy/bin/mediatidy-config:3
program = require 'commander'
^^^^^^^^^^^
SyntaxError: Unexpected string
at Module._compile (module.js:439:25)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Function.Module.runMain (module.js:497:10)
at startup (node.js:119:16)
at node.js:906:3
Looks like a coffeescript compilation error... wat.
If I run the same command but with the dash, bin/mediatidy-config, it works fine. I have another app that is private that works without having to use the dash that is globally installed. What am I missing here?
edit: added my package.json file:
package.json:
{
"preferGlobal": true,
"main": "index",
"name": "mediatidy",
"description": "Keep your media nice and tidy!",
"version": "0.1.1",
"repository": {
"type": "git",
"url": "git#github.com:tkdan235/mediatidy.git"
},
"engines": {
"node": ">=0.10.0"
},
"directories": {
"bin": "bin",
"lib": "lib"
},
"dependencies": {
"async": "^0.9.0",
"coffee-script": "^1.8.0",
"colors": "^0.6.2",
"commander": "^2.1.0",
"fs-extra": "^0.11.1",
"lodash": "^2.4.1",
"nconf": "^0.7.1",
"node-dir": "^0.1.6",
"node-ffprobe": "^1.2.2",
"prompt": "^0.2.14",
"sqlite3": "^2.2.7"
},
"coffeelintConfig": {
"max_line_length": {
"name": "max_line_length",
"value": 120,
"level": "error",
"limitComments": true
}
}
}
This actually appears to be a limitation of Commander.js. At first glance, it doesn't appear to call the scripts as shell scripts. Instead, it calls them with node which won't be compiling the CoffeeScript code. See https://github.com/tj/commander.js/blob/master/index.js#L447-L479 (line 469 in particular).
Update:
After some further digging, it looks like this WAS once supported and working. The way sub-commands were called was just their script name. Then this pull request broke it: https://github.com/tj/commander.js/pull/173. The last working version for this behavior was in 2.1.0. You could pin your version to 2.1.0 to get this behavior back.

Resources