From 37cc612263b8904f09ba936f597a52c8688a0d5a Mon Sep 17 00:00:00 2001 From: Adam Bird Date: Mon, 29 Nov 2021 13:17:43 -0500 Subject: [PATCH] types: cli and hooks types for config (#9625) --- packages/core/config/config.interface.ts | 56 ++++++++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/packages/core/config/config.interface.ts b/packages/core/config/config.interface.ts index 6cf425b79..996979e6c 100644 --- a/packages/core/config/config.interface.ts +++ b/packages/core/config/config.interface.ts @@ -94,6 +94,52 @@ interface IConfigAndroid extends IConfigPlatform { enableMultithreadedJavascript?: boolean; } +interface IConfigCLI { + /** + * Set the package manager to use for this project. + * Defaults to the CLI set package manager, or `npm` if not set globally + */ + packageManager: 'yarn' | 'pnpm' | 'npm'; +} + +interface IConfigHook { + // prettier-ignore + /** + * Event name for when to run the hook. + * Possible event names are any of the following with the pattern + * `before-*` and `after-*` + * + * * `buildAndroidPlugin` - Builds aar file for Android plugin, runs during prepareNativeApp + * * `buildAndroid` - Builds Android app + * * `buildIOS` - Builds iOS app + * * `checkEnvironment` - Validate project env, runs during ns doctor, clean, and most build commands + * * `checkForChanges` - Changes occured during watch + * * `install` - Application installed to device/emulator + * * `prepare` - Compiles webpack and prepares native app in platforms folder + * * `prepareNativeApp` - Preparing the actual native app, runs during prepare/watch hook + * * `resolveCommand` - Resolves command and arguments, runs before all cli commands + * * `watch` - Setup watchers for live sync, runs during prepare hook + * * `watchPatterns` - Setup watch patterns, runs during watch hook + */ + type: + | 'before-buildAndroidPlugin' | 'after-buildAndroidPlugin' + | 'before-buildAndroid' | 'after-buildAndroid' + | 'before-buildIOS' | 'after-buildIOS' + | 'before-checkEnvironment' | 'after-checkEnvironment' + | 'before-checkForChanges' | 'after-checkForChanges' + | 'before-install' | 'after-install' + | 'before-prepare' | 'after-prepare' + | 'before-prepareNativeApp' | 'after-prepareNativeApp' + | 'before-resolveCommand' | 'after-resolveCommand' + | 'before-watch' | 'after-watch' + | 'before-watchPatterns' | 'after-watchPatterns'; + + /** + * Path to the hook script file to run + */ + script: string; +} + export interface NativeScriptConfig { /** * App's bundle id @@ -147,4 +193,14 @@ export interface NativeScriptConfig { * Optionally specify a list of npm package names for which you would like the NativeScript CLI to ignore when attaching native dependencies to the build */ ignoredNativeDependencies?: string[]; + + /** + * Set cli options + */ + cli?: IConfigCLI; + + /** + * Set project persistent hooks to run + */ + hooks?: IConfigHook[]; }