@forge/cli
12.10.1-next.512.10.1-next.6-experimental-a8bc05b
out/command-line/controller/settings-controller.jsout/command-line/controller/settings-controller.js+27−2
Index: package/out/command-line/controller/settings-controller.js
===================================================================
--- package/out/command-line/controller/settings-controller.js
+++ package/out/command-line/controller/settings-controller.js
@@ -1,11 +1,12 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
-exports.SettingsController = exports.ALLOWED_SETTINGS = void 0;
+exports.SettingsController = exports.DELETABLE_SETTINGS = exports.ALLOWED_SETTINGS = void 0;
const cli_shared_1 = require("@forge/cli-shared");
const manifest_1 = require("@forge/manifest");
const environment_1 = require("../environment");
-exports.ALLOWED_SETTINGS = ['usage-analytics', 'default-environment', 'seasonal-effects'];
+exports.ALLOWED_SETTINGS = ['usage-analytics', 'default-environment', 'seasonal-effects', 'proxy'];
+exports.DELETABLE_SETTINGS = ['proxy'];
class SettingsController {
settingsView;
cachedConfigService;
getAppConfig;
@@ -61,8 +62,18 @@
set: async (value) => {
const parsedValue = this.parseBoolean(value);
this.cachedConfigService.setSeasonalEffects(parsedValue);
}
+ },
+ proxy: {
+ description: cli_shared_1.Text.settings.globalProxy.description,
+ get: async () => this.cachedConfigService.getGlobalProxy(),
+ set: async (value) => {
+ this.cachedConfigService.setGlobalProxy(value);
+ },
+ delete: async () => {
+ this.cachedConfigService.deleteGlobalProxy();
+ }
}
};
parseBoolean(value) {
switch (value) {
@@ -76,16 +87,30 @@
}
isAllowedSetting(preference) {
return exports.ALLOWED_SETTINGS.includes(preference);
}
+ isSettingDeleteAllowed(preference) {
+ return exports.DELETABLE_SETTINGS.includes(preference);
+ }
async showSettings(json) {
const settings = [];
for (const settingName of exports.ALLOWED_SETTINGS) {
const setting = this.SETTINGS_MAP[settingName];
settings.push([settingName, setting.description, await setting.get()]);
}
this.settingsView.showSettings(settings, json);
}
+ async deleteSetting(preference) {
+ if (!this.isSettingDeleteAllowed(preference)) {
+ throw new cli_shared_1.ValidationError(cli_shared_1.Text.settings.delete.invalidSetting(exports.DELETABLE_SETTINGS));
+ }
+ const setting = this.SETTINGS_MAP[preference];
+ if (!setting.delete) {
+ throw new cli_shared_1.ValidationError(cli_shared_1.Text.settings.delete.invalidSetting(exports.DELETABLE_SETTINGS));
+ }
+ await setting.delete();
+ this.settingsView.deleteSuccess(preference);
+ }
async setSetting(preference, value) {
if (!this.isAllowedSetting(preference)) {
throw new cli_shared_1.ValidationError(cli_shared_1.Text.settings.set.invalidSetting(exports.ALLOWED_SETTINGS));
}