Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(options): use the 'nsconfig.json' file to set tns options #5296

Closed
wants to merge 4 commits into from
Closed

feat(options): use the 'nsconfig.json' file to set tns options #5296

wants to merge 4 commits into from

Conversation

bgrand-ch
Copy link

@bgrand-ch bgrand-ch commented Apr 14, 2020

PR Checklist

What is the current behavior?

Tns options are to be written each time to build, run, deploy, debug and test an Android and iOS application.

What is the new behavior?

In addition to the current behavior, all tns options can be defined in the nsconfig.json file.

In the nsconfig.json file, you need to add the tnsOptions key with android and ios subkeys.

Option names are unchanged, they are those of the documentation of the CLI.

Example

nsconfig.json

{
    "tnsOptions": {
        "android": {
            "copyTo": "./_build/android",
            "keyStorePath": "./keys/android.keystore",
            "keyStoreAlias": "my_ns_project",
            "release": true,
            "aab": true,
            "env": {
                "uglify": true
            }
        }
    }
}

CLI

tns build android --nsconfig --key-store-password "my_pwd" --key-store-alias-password "my_pwd"

(see the original idea)

Fixes/Implements/Closes

Fixes

@project-bot project-bot bot added this to Pull Request in CLI Team Apr 14, 2020
@cla-bot cla-bot bot added the cla: yes label Apr 14, 2020
@bgrand-ch bgrand-ch changed the title All tns options in nsconfig.json file feat(options): use the 'nsconfig.json' file to set tns options Apr 15, 2020
@bgrand-ch
Copy link
Author

@DimitarTachev @rosen-vladimirov Hello, I am at your disposal for any changes. Have a nice day 😊

@rigor789
Copy link
Member

rigor789 commented Sep 8, 2020

Hi @elvticc - I have wanted something like this for a long time! With the recent introduction of nativescript.config.ts I think we can go a step further, and allow setting many of CLI configuration there, including the options.

import { NativeScriptConfig } from '@nativescript/core'

export default {
  id: 'org.nativescript.app',
  // ...
  cli: {
    packageManager: 'yarn',
    android: {
      copyTo: './_build/android'
    }
  },
} as NativeScriptConfig

The syntax/api is subject to change, merely just a quick example of what I imagined.

@bgrand-ch
Copy link
Author

Hi @rigor789, I will update this to include the new nativescript.config.ts file and preserve backward compatibility with the nsconfig.json file. I will try with all the options 👍 I'll be back soon.

@rigor789
Copy link
Member

rigor789 commented Sep 9, 2020

@elvticc the CLI should automatically fall back to nsconfig when there is no new config found. The logic has been extracted to project-config-service which you can inject wherever and read values, or the whole config.

I think in options.ts we can inject/resolve the config service:

const projectConfig = injector.resolve('projectConfigService')
// add guards if it's not set/found etc.
const cliOptions = projectConfig.getValue('cli') // I think this should work, and return the object

// do any processing of the options (can probably be enclosed in a function within `options.ts`)
// just an example, doesn't have to be called this - or even called this way
this.argv = this.processConfigOptions(cliOptions)

// probably better to just have a single line that calls a function that 
// does all the config fetching, manipulation and setting argv

Other than that, I think we want these to be used by default - and provide a flag to opt-out? --skip-config (don't like that name, but can't think of anything at the moment)

If you want to to work on this together, feel free to ping me - I'm usually available

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
CLI Team
  
Pull Request
Development

Successfully merging this pull request may close these issues.

None yet

2 participants