alwaysai
Version:
The alwaysAI command-line interface (CLI)
35 lines • 1.78 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.modelPublishComponent = void 0;
const alwayscli_1 = require("@alwaysai/alwayscli");
const logSymbols = require("log-symbols");
const model_1 = require("../../core/model");
const infrastructure_1 = require("../../infrastructure");
const util_1 = require("../../util");
const validate_package_1 = require("../../subcommands/model/validate-package");
const model_package_json_file_1 = require("../../core/model/model-package-json-file");
async function modelPublishComponent(props) {
const { force } = props;
try {
if (!(await (0, validate_package_1.validatePackageComponent)(process.cwd())) && !force) {
throw new alwayscli_1.CliTerseError(`Model has configuration errors! Please resolve them and try again.`);
}
// Read parsed JSON here to allow publishing when validation fails
// This makes validation errors into warnings when `force` is set
const modelJson = (0, model_package_json_file_1.ModelPackageJsonFile)(process.cwd()).readParsed();
const { id } = modelJson;
await (0, util_1.runWithSpinner)(async () => {
await model_1.modelPackageCloudClient.publish();
}, [], 'Publish model to cloud');
const { version: latestVersion } = await (0, infrastructure_1.CliRpcClient)().getModelVersion({
id
});
(0, util_1.echo)(`${logSymbols.success} Published ${id} version ${latestVersion}`);
}
catch (exception) {
util_1.logger.error((0, util_1.stringifyError)(exception));
throw new alwayscli_1.CliTerseError(exception.message);
}
}
exports.modelPublishComponent = modelPublishComponent;
//# sourceMappingURL=model-publish-component.js.map