Nativescript 6 - environment specific files not working - nativescript

I just recently migrated my app to NS 6 and I noticed that the environment specific files are not processed properly.
E.g. I have settings.debug.json and settings.release.json. In code, I reference them as import * as settings from '/settings.json' . In NS < 6, this used to work, but now I get an error that that settings.json does not exist.
I have very limited experience with Webpack. Is there a setting I need to configure there for this to work?
Here is my package.json
{
"name": "<app>",
"nativescript": {
"id": "<id>",
"tns-ios": {
"version": "6.0.1"
},
"tns-android": {
"version": "6.0.1"
}
},
"description": "",
"license": "SEE LICENSE IN <your-license-filename>",
"repository": "<fill-your-repository-here>",
"dependencies": {
"moment": "^2.24.0",
"nativescript-appversion": "^1.4.2",
"nativescript-geolocation": "5.1.0",
"nativescript-iqkeyboardmanager": "1.3.0",
"nativescript-loading-indicator": "2.4.0",
"nativescript-local-notifications": "3.1.0",
"nativescript-plugin-firebase": "9.0.2",
"nativescript-theme-core": "~1.0.4",
"tns-core-modules": "6.0.1"
},
"devDependencies": {
"nativescript-dev-webpack": "1.0.2",
"typescript": "3.4.5"
},
"readme": "",
"author": ""
}
Thank you.

You can conditionally load the files using the TNS_ENV variable.
const settings = TNS_ENV !== 'production' ? require('./settings.debug.json') : require('./settings.release.json')

Related

node ace configure is not a registered command in Adonisjs

I've been given an adonisjs project that has the following package.json:
{
"name": "adonis-api-app",
"version": "4.1.0",
"adonis-version": "4.1.0",
"description": "Adonisjs boilerplate for API server with pre-configured JWT",
"main": "index.js",
"scripts": {
"start": "node server.js",
"test": "node ace test"
},
"keywords": [
"adonisjs",
"adonis-app"
],
"author": "",
"license": "UNLICENSED",
"private": true,
"dependencies": {
"#adonisjs/ace": "^5.0.8",
"#adonisjs/auth": "^3.0.7",
"#adonisjs/bodyparser": "^2.0.5",
"#adonisjs/cors": "^1.0.7",
"#adonisjs/fold": "^4.0.9",
"#adonisjs/framework": "^5.0.9",
"#adonisjs/ignitor": "^2.0.8",
"#adonisjs/lucid": "^6.1.3",
"#adonisjs/mail": "^3.0.10",
"#adonisjs/validator": "^5.0.6",
"adonis-scheduler": "^3.0.2",
"buffer": "^6.0.3",
"dayjs": "^1.10.4",
"exceljs": "^4.2.1",
"json2csv": "^5.0.6",
"lodash": "^4.17.21",
"mysql": "^2.18.1",
"mysql2": "^2.2.5",
"nuxt-video-player": "^1.0.17"
},
"autoload": {
"App": "./app"
}
I've been asked to make the platform multilingual. So I went to this website for instructions on how to implement i18n: https://docs.adonisjs.com/guides/i18n
As per the instructions, I installed with these commands:
npm i #adonisjs/i18n
node ace configure #adonisjs/i18n
error: `configure` is not a registered command
How come my node ace configure doesn't work? How do I correct the problem?
UPDATE
I think this means my adonisjs framework is from the year 2018. And the earliest version of the i18n module is from 2021. Which i18n module would be compatible with my version of the adonisjs framework?

Use cucumber and XRAY in protractor

I'm using Cucumber in my project with protractor and now I want to integrate it with Jira using XRAY but looking at the documentation, it uses jasmine and I don't know how to use both frameworks because if I put the code as indicated in the documentation using the "jasmine" framework instead of "custom" it doesn't recognize the cucumber sentences of the features.
Can someone help me? Thanks in advance
I include package.json and xrayconfig.ts .
xrayconfig.ts:
import { Config, protractor } from 'protractor';
import * as reporter from "cucumber-html-reporter";
import 'jasmine';
const XrayReporter = require('protractor-xray-reporter');
let onPrepareDefer;
let onCompleteDefer;
export let config: Config = {
directConnect: true,//Running chrome
capabilities: {
'browserName': 'chrome'
},
framework: 'jasmine',
frameworkPath: require.resolve('protractor-cucumber-framework'),
"types": ["chai", "cucumber", "node"],
specs: ['../Features/*.feature'],
cucumberOpts: {
tags:"#scenarioLola", //only executed this scenario
require: [
'../JSFiles/stepDefinitions/*.js' // accepts a glob
]
},
'onPrepare': function() {
let globals = require('protractor');
let browser = globals.browser;
onPrepareDefer = protractor.promise.defer();
onCompleteDefer = protractor.promise.defer();
const options = {
'screenshot': 'always',
'version': '1.0',
'jiraUser': 'user',
'jiraPassword': 'pwd',
'xrayUrl': 'https://jira.com/rest/raven/1.0/import/execution'
};
jasmine.getEnv().addReporter(XrayReporter(options, onPrepareDefer, onCompleteDefer, browser));
return onPrepareDefer.promise;
},
'onComplete': function() {
return onCompleteDefer.promise;
}
};
package.json
{
"name": "project",
"version": "1.0.0",
"description": "Project one",
"main": "index.js",
"scripts": {
"test": "protractor JSFiles/cucumberconfig.js",
"pretest": "tsc",
"protractor": "./node_modules/protractor/built/cli.js",
"webdriver-update": "./node_modules/.bin/webdriver-manager update"
},
"author": "Carol",
"license": "ISC",
"dependencies": {
"#types/cucumber": "^6.0.1",
"#types/jasmine": "^3.5.11",
"#types/jasminewd2": "2.0.8",
"#types/node": "^14.0.13",
"#types/jest": "^26.0.0",
"chai": "^4.2.0",
"chai-as-promised": "^7.1.1",
"cucumber": "^6.0.5",
"cucumber-html-reporter": "^5.2.0",
"jasmine": "~3.5.0",
"protractor-cucumber-framework": "^6.2.1",
"typescript": "~3.9.5",
"protractor-jasmine2-screenshot-reporter": "0.5.0"
},
"devDependencies": {
"install-peers": "^1.0.3",
"protractor": "^7.0.0",
"protractor-zephyr-reporter": "^1.2.1",
"ts-node": "^8.10.2",
"jasmine-spec-reporter": "5.0.2",
"jasmine-core": "3.5.0"
}
}

Nativescript app size is growing each time when a new screen is added

I have 10 xml files, and 23 js files, and 1 css file
4 font styles, 25 10kb images. Thats all
my app folder size is 2.77 mb
these are the dependencies
{
"nativescript": {
"id": "org.nativescript.higherstudy",
"tns-android": {
"version": "6.3.0"
},
"tns-ios": {
"version": "6.3.0"
}
},
"description": "NativeScript Application",
"license": "SEE LICENSE IN <your-license-filename>",
"repository": "<fill-your-repository-here>",
"dependencies": {
"#nativescript/theme": "~2.2.1",
"#nstudio/nativescript-floatingactionbutton": "^1.1.0",
"#nstudio/nativescript-loading-indicator": "^2.0.0",
"nativescript-carousel": "^6.1.1",
"nativescript-pdf-view": "^2.1.0",
"nativescript-permissions": "^1.3.8",
"nativescript-phone": "^1.4.1",
"nativescript-toast": "^2.0.0",
"nativescript-ui-listview": "^8.0.1",
"tns-core-modules": "~6.3.0"
},
"devDependencies": {
"nativescript-dev-webpack": "~1.4.0"
},
"gitHead": "94f487c5279f7abc2cc61cb48e357d1756865a40",
"readme": "NativeScript Application"
}
when i build the app on Sidekick the size of apk file is 43,873kb which is 43mb
each time when i add xml js file the size was growing with a range of 5 to 8 mb in size.
is it time to stop using nativescript who will download my simple app with big size.
the problem video link https://youtu.be/FtcbagvDqR8

CFBundleIdentifier Collision while uploading a macOS app developed with Electron and built with electron-builder

I am currently developing an Electron app and I am able to generate the .app and .pkg for the macOS operating systems. Although I can run it from the .app generated, when I try to upload the .pkg (mas) I get the following error on AppStore Connect:
CFBundleIdentifier Collision -
The Info.plist CFBundleIdentifier value 'org.phantomjs' of 'phantomjs'
is already in use by another application.
I have tried updating Electron to the latest stable version (2.0.9), and updating electron-builder to the latest version (20.28.4). I've tried searching for the org.phantomjs string in the resulting .app and I am unable to find a Info.plist with that Bundle Identifier
Here I attach my package.json in case it is useful:
{
"name": "myAppName",
"version": "0.0.1",
"author": "Me <me#mymail.com>",
"description": "My Description",
"license": "MIT",
"main": "./dist/electron/main.js",
"repository": {
"type": "git",
"url": "git+https://github.com/****.git"
},
"scripts": {
"build": "node .electron-vue/build.js && electron-builder",
"build:dir": "node .electron-vue/build.js && electron-builder --dir",
"build:clean": "cross-env BUILD_TARGET=clean node .electron-vue/build.js",
"build:web": "cross-env BUILD_TARGET=web node .electron-vue/build.js",
"dev": "node .electron-vue/dev-runner.js",
"lint": "eslint --ext .js,.vue -f ./node_modules/eslint-friendly-formatter src",
"lint:fix": "eslint --ext .js,.vue -f ./node_modules/eslint-friendly-formatter --fix src",
"pack": "npm run pack:main && npm run pack:renderer",
"pack:main": "cross-env NODE_ENV=production webpack --progress --colors --config .electron-vue/webpack.main.config.js",
"pack:renderer": "cross-env NODE_ENV=production webpack --progress --colors --config .electron-vue/webpack.renderer.config.js",
"postinstall": "npm run lint:fix"
},
"build": {
"productName": "myAppName",
"appId": "this.is.a.real.appid",
"buildVersion": "5",
"directories": {
"output": "build"
},
"files": [
"dist/electron/**/*"
],
"dmg": {
"contents": [
{
"x": 410,
"y": 150,
"type": "link",
"path": "/Applications"
},
{
"x": 130,
"y": 150,
"type": "file"
}
]
},
"mac": {
"icon": "build/icons/icon.icns",
"category": "public.app-category.developer-tools",
"target": [
{
"target": "mas"
}
]
},
"mas": {
"entitlements": "build/entitlements.mas.plist",
"entitlementsInherit": "build/entitlements.mas.inherit.plist",
"icon": "build/icons/icon.icns",
"category": "public.app-category.developer-tools"
},
"win": {
"icon": "build/icons/icon.ico",
"target": [
{
"target": "nsis"
},
{
"target": "appx"
}
]
},
"linux": {
"icon": "build/icons"
},
"fileAssociations": [
{
"ext": "myExtension",
"name": "My Project",
"description": "File containing a My Project.",
"icon": "build/icons/Project.icns",
"role": "Editor",
"isPackage": true
}
],
"copyright": "Copyright © 2018 Me"
},
"dependencies": {
"#appshuttle.io/bell": "0.0.12",
"#appshuttle.io/pollock": "0.0.28",
"#appshuttle.io/turing": "0.0.16",
"#fortawesome/fontawesome-svg-core": "^1.2.2",
"#fortawesome/free-brands-svg-icons": "^5.0.13",
"#fortawesome/free-regular-svg-icons": "^5.0.13",
"#fortawesome/free-solid-svg-icons": "^5.0.13",
"#fortawesome/vue-fontawesome": "0.1.1",
"axios": "^0.16.1",
"electron-updater": "^3.0.3",
"email-validator": "^2.0.4",
"grunt": "^1.0.3",
"nedb": "^1.8.0",
"p5": "^0.6.1",
"path": "^0.12.7",
"spectre.css": "^0.5.3",
"vue": "^2.3.3",
"vue-color": "^2.4.6",
"vue-electron": "^1.0.6",
"vue-router": "^2.5.3",
"vuedraggable": "^2.16.0",
"vuex": "^2.3.1"
},
"devDependencies": {
"babel-core": "^6.26.3",
"babel-eslint": "^7.2.3",
"babel-loader": "^7.1.5",
"babel-plugin-transform-runtime": "^6.23.0",
"babel-preset-env": "^1.7.0",
"babel-preset-stage-0": "^6.24.1",
"babel-register": "^6.24.1",
"babili-webpack-plugin": "^0.1.2",
"cfonts": "^1.2.0",
"chalk": "^2.4.1",
"copy-webpack-plugin": "^4.5.2",
"cross-env": "^5.2.0",
"css-loader": "^0.28.11",
"del": "^3.0.0",
"devtron": "^1.4.0",
"electron": "^2.0.0",
"electron-builder": "20.28.4",
"electron-debug": "^2.0.0",
"electron-devtools-installer": "^2.2.4",
"eslint": "^4.19.1",
"eslint-config-standard": "^10.2.1",
"eslint-friendly-formatter": "^3.0.0",
"eslint-loader": "^1.9.0",
"eslint-plugin-html": "^3.1.1",
"eslint-plugin-import": "^2.13.0",
"eslint-plugin-node": "^5.1.1",
"eslint-plugin-promise": "^3.8.0",
"eslint-plugin-standard": "^3.1.0",
"extract-text-webpack-plugin": "^3.0.0",
"file-loader": "^0.11.2",
"html-webpack-plugin": "^2.30.1",
"mini-css-extract-plugin": "^0.4.1",
"multispinner": "^0.2.1",
"node-loader": "^0.6.0",
"node-sass": "^4.9.2",
"sass-loader": "^6.0.7",
"style-loader": "^0.18.2",
"url-loader": "^0.5.9",
"vue-html-loader": "^1.2.4",
"vue-loader": "^15.4.0",
"vue-style-loader": "^3.0.1",
"vue-template-compiler": "^2.4.2",
"webpack": "^3.12.0",
"webpack-dev-server": "^2.7.1",
"webpack-hot-middleware": "^2.22.3"
}
}
Thanks so much in advance!
Found a solution (As mentioned by #countravioli in this Github Issue):
I found that there was a file called app.asar.unpacked that contained multiple Bundle Identifiers once the .pkg was created and signed. Deleting this file in the .app and then creating a .pkg didn't work for me so I used a Build Hook as proposed in the Github Issue. To prevent the file to being inserted to the .pkg file. To do this, I added a hook to the build section of my package.json at the end of the rest of its contents:
package.json
{ //package.json Root ...
build: {
// build content ...
"afterPack": "./afterPack.js"
}
}
An then created a file called afterPack.js in the folder where my package.json is located with the following contents:
const fs = require('fs');
const fse = require('fs-extra');
const path = require('path');
module.exports = function (params) {
const unpackFile = path.join(params.appOutDir, 'YOUR_APP_NAME.app/Contents/Resources/app.asar.unpacked');
console.log('EXISTS?', fs.existsSync(unpackFile));
console.log("REMOVE", unpackFile);
fse.removeSync(unpackFile);
};
I was able to upload the package to AppStore Connect without any issue.

NativeScript : An Uncaught Exception Occurred on main thread on android(In ios runs perfectly)

I am new to nativescript i developed a simple app for learning purpose. i tried to run it in ios it works.whereas in android i cant run
the following is the error iam facing
Following is my Package.json
{
"description": "NativeScript Application",
"license": "SEE LICENSE IN <your-license-filename>",
"readme": "NativeScript Application",
"repository": "<fill-your-repository-here>",
"nativescript": {
"id": "org.nativescript.excercises",
"tns-ios": {
"version": "2.5.2"
},
"tns-android": {
"version": "2.5.0"
}
},
"dependencies": {
"nativescript-checkbox": "^1.2.6",
"nativescript-platform-css": "^1.4.0",
"nativescript-star-ratings": "^0.1.0",
"nativescript-theme-core": "~1.0.2",
"nativescript-web-image-cache": "^3.4.0",
"tns-core-modules": "^2.5.1"
},
"devDependencies": {
"babel-traverse": "6.23.1",
"babel-types": "6.23.0",
"babylon": "6.16.1",
"lazy": "1.0.11",
"nativescript-dev-android-snapshot": "^0.*.*"
}
}
Thanks in advance

Resources