@tywalk/pcf-helper
Version:
Command line helper for building and publishing PCF controls to Dataverse.
55 lines (54 loc) • 3.23 kB
TypeScript
export type SessionOptions = {
verbose?: boolean;
url?: string;
script?: string;
stylesheet?: string;
bundle?: string;
css?: string;
config?: string;
watch?: boolean;
watchRetry?: boolean;
profile?: string;
};
interface FileConfig {
remoteEnvironmentUrl?: string;
remoteScriptToIntercept?: string;
remoteStylesheetToIntercept?: string;
localCssPath?: string;
localBundlePath?: string;
startWatch?: boolean;
watchRetry?: boolean;
}
/**
* Loads configuration for the session task, supporting a combination of
* config file, environment variables, and CLI arguments.
*
* Precedence (highest wins, field-level):
* CLI args (handled by caller) > env vars > active profile session block
* > unified config session block > legacy session.config.json > defaults
*
* The legacy `session.config.json` path keeps working so existing setups do
* not break when upgrading.
*
* @param config Optional path to a legacy JSON config file. If not provided,
* looks for `session.config.json` in the current working directory.
* @param profileName Optional profile name. If provided, that profile's
* session block layers over the top-level session block.
* @returns Resolved session config values.
*/
declare function loadConfig(config?: string, profileName?: string): Partial<FileConfig>;
/**
* Runs an ephemeral browser session that intercepts requests to the specified remote script and stylesheet URLs, serving local files instead.
* It also manages session state by saving cookies and local storage to a file, allowing for persistent login sessions across runs.
* The session will automatically clean up and save state on exit, including handling various exit signals and browser events.
* @param remoteEnvironmentUrl The URL of the remote environment to navigate to.
* @param remoteScriptToIntercept The full URL of the remote script to intercept (e.g., https://app.your-remote-environment.com/static/js/remote-control-bundle.js).
* @param remoteStylesheetToIntercept The full URL of the remote stylesheet to intercept (e.g., https://app.your-remote-environment.com/static/css/remote-control-styles.css).
* @param localBundlePath The local file path to the JavaScript bundle that should be served when the remote script URL is requested.
* @param localCssPath The local file path to the CSS file that should be served when the remote stylesheet URL is requested.
* @param startWatch Optional flag to start the session in watch mode. If true, the process will kick off "pcf-scripts start watch" in parallel to automatically rebuild the bundle on changes.
* @param watchRetry Optional flag to automatically restart the watch process when it exits with a failure code. Defaults to true.
* @returns A promise that resolves when the session is set up and running. The session will continue to run until the process is exited, at which point it will clean up and save state.
*/
declare function runSession(remoteEnvironmentUrl: string, remoteScriptToIntercept: string, remoteStylesheetToIntercept: string, localBundlePath: string, localCssPath: string, startWatch?: boolean, watchRetry?: boolean): Promise<void>;
export { runSession, loadConfig };