push neon reactor
This commit is contained in:
+69
@@ -0,0 +1,69 @@
|
||||
/*!
|
||||
* Copyright (C) Microsoft Corporation. All rights reserved.
|
||||
*/
|
||||
import { readRepoConfig, setVfs } from '@microsoft/power-apps-actions';
|
||||
import { APP_CONFIG_FILE, WORKING_DIRECTORY } from './Constants.js';
|
||||
import { CliFS } from './FS/CliFs.js';
|
||||
let _cliSettings;
|
||||
let _logger;
|
||||
export async function initializeCliSettings({ source, interactive, fileConfig = {
|
||||
powerConfigPath: `${WORKING_DIRECTORY}/${APP_CONFIG_FILE}`,
|
||||
schemaPath: `${WORKING_DIRECTORY}/.power/schemas`,
|
||||
codeGenPath: `${WORKING_DIRECTORY}/src`,
|
||||
}, }) {
|
||||
const cliFs = new CliFS({
|
||||
cwd: process.cwd(),
|
||||
allowCwdRead: true,
|
||||
allowCwdWrite: true,
|
||||
});
|
||||
// Set VFS at initialize to read the config
|
||||
setVfs(cliFs);
|
||||
let appConfig;
|
||||
try {
|
||||
appConfig = await readRepoConfig(fileConfig.powerConfigPath);
|
||||
}
|
||||
catch (error) {
|
||||
// Ignore error, there are commands where a config file is not needed
|
||||
}
|
||||
_cliSettings = {
|
||||
source,
|
||||
interactive,
|
||||
fileConfig,
|
||||
cliFs,
|
||||
appConfig,
|
||||
};
|
||||
return _cliSettings;
|
||||
}
|
||||
export function setCliLogger(logger) {
|
||||
_logger = logger;
|
||||
}
|
||||
export function getCliLogger() {
|
||||
if (!_logger) {
|
||||
// return a no-op logger if not initialized to prevent crashes
|
||||
/* eslint-disable no-empty-function */
|
||||
return {
|
||||
trackActivityEvent: (_eventName, _eventData) => { },
|
||||
trackErrorEvent: (_eventName, _eventData) => { },
|
||||
trackScenario: (_name, _scenarioData) => {
|
||||
return {
|
||||
scenarioId: '',
|
||||
complete: (_endScenarioData) => { },
|
||||
failure: (_failureData) => { },
|
||||
completeWithError: (_completeWithErrorData) => { },
|
||||
};
|
||||
},
|
||||
stringifyError: (_err) => {
|
||||
return null;
|
||||
},
|
||||
};
|
||||
}
|
||||
/* eslint-enable no-empty-function */
|
||||
return _logger;
|
||||
}
|
||||
export function getSettings() {
|
||||
if (!_cliSettings) {
|
||||
throw new Error('CLI settings have not been initialized. Please call initializeCliSettings first.');
|
||||
}
|
||||
return _cliSettings;
|
||||
}
|
||||
//# sourceMappingURL=CliSettings.js.map
|
||||
Reference in New Issue
Block a user