@adpt/cli
Version:
AdaptJS command line interface
79 lines • 2.74 kB
JavaScript
;
/*
* Copyright 2020 Unbounded Systems, LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
Object.defineProperty(exports, "__esModule", { value: true });
const schema_1 = require("./schema");
// tslint:disable-next-line: no-var-requires
const pjson = require("../../../package.json");
/**
* Schema for user config.
*/
exports.userConfigSchema = {
upgradeCheck: {
description: "Periodically check for new versions of the Adapt CLI",
default: true,
asType: "boolean",
},
upgradeChannel: {
description: "Which channel of upgrades to subscribe to (latest or next)",
default: "latest",
asType: "string",
},
upgradeCheckInterval: {
description: "Minimum interval between checks for new versions of the Adapt CLI",
default: "1 day",
asType: "duration",
},
upgradeCheckUrl: {
description: "Location of where to fetch Adapt CLI version summary information",
default: "https://adapt-public.s3-us-west-2.amazonaws.com/upgrade-check.json",
asType: "string",
},
upgradeRemindInterval: {
description: "Minimum interval between reminders about an update",
default: "7 days",
asType: "duration",
},
upgradeIgnore: {
description: "Do not display upgrade reminders for this Adapt version",
default: "",
asType: "string",
},
};
/**
* Array of the valid configuration properties (keys).
*/
exports.userConfigProps = Object.keys(exports.userConfigSchema);
/**
* Map for finding the correct case-sensitive config property from the
* lower case version.
*/
const userConfigLookup = new Map(exports.userConfigProps.map((prop) => [prop.toLowerCase(), prop]));
const now = Date.now();
exports.cliStateDefaults = {
installed: now,
lastUpgradeCheck: now,
version: pjson.version,
};
function lookupConfigProperty(name) {
return userConfigLookup.get(name.toLowerCase());
}
exports.lookupConfigProperty = lookupConfigProperty;
function parseConfigItemString(prop, val) {
return schema_1.parseItem(prop, val, exports.userConfigSchema);
}
exports.parseConfigItemString = parseConfigItemString;
//# sourceMappingURL=config.js.map