@fonoster/ctl 0.21.0 → 0.22.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -78,7 +78,7 @@ class Update extends AuthenticatedCommand_1.AuthenticatedCommand {
|
|
|
78
78
|
if (flags["from-file"]) {
|
|
79
79
|
try {
|
|
80
80
|
const client = yield this.createSdkClient();
|
|
81
|
-
yield (0, createOrUpdateApplication_1.createOrUpdateApplication)(client, flags["from-file"], ref);
|
|
81
|
+
yield (0, createOrUpdateApplication_1.createOrUpdateApplication)(client, flags["from-file"], ref, true);
|
|
82
82
|
this.log("Done!");
|
|
83
83
|
return;
|
|
84
84
|
}
|
|
@@ -87,9 +87,12 @@ class Update extends AuthenticatedCommand_1.AuthenticatedCommand {
|
|
|
87
87
|
return;
|
|
88
88
|
}
|
|
89
89
|
}
|
|
90
|
+
if (!ref) {
|
|
91
|
+
this.error("An Application ref is required. Pass it as the positional argument or use --from-file with a `ref` field.");
|
|
92
|
+
}
|
|
90
93
|
const client = yield this.createSdkClient();
|
|
91
94
|
const applications = new SDK.Applications(client);
|
|
92
|
-
const applicationFromDB = yield applications.getApplication(
|
|
95
|
+
const applicationFromDB = yield applications.getApplication(ref);
|
|
93
96
|
if (!applicationFromDB) {
|
|
94
97
|
this.error("Application not found.");
|
|
95
98
|
}
|
|
@@ -208,8 +211,7 @@ Update.description = "modify the configuration of an Application";
|
|
|
208
211
|
Update.examples = ["<%= config.bin %> <%= command.id %>"];
|
|
209
212
|
Update.args = {
|
|
210
213
|
ref: core_1.Args.string({
|
|
211
|
-
description: "the Application to update"
|
|
212
|
-
required: true
|
|
214
|
+
description: "the Application to update (optional when `ref` is set in --from-file)"
|
|
213
215
|
})
|
|
214
216
|
};
|
|
215
217
|
Update.flags = {
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import * as SDK from "@fonoster/sdk";
|
|
2
|
-
export declare function createOrUpdateApplication(client: SDK.Client, filePath: string, appRef?: string): Promise<import("@fonoster/types").BaseApiObject>;
|
|
2
|
+
export declare function createOrUpdateApplication(client: SDK.Client, filePath: string, appRef?: string, isUpdate?: boolean): Promise<import("@fonoster/types").BaseApiObject>;
|
|
@@ -68,8 +68,8 @@ const fs_1 = require("fs");
|
|
|
68
68
|
const path_1 = __importDefault(require("path"));
|
|
69
69
|
const SDK = __importStar(require("@fonoster/sdk"));
|
|
70
70
|
const js_yaml_1 = require("js-yaml");
|
|
71
|
-
function createOrUpdateApplication(
|
|
72
|
-
return __awaiter(this,
|
|
71
|
+
function createOrUpdateApplication(client_1, filePath_1, appRef_1) {
|
|
72
|
+
return __awaiter(this, arguments, void 0, function* (client, filePath, appRef, isUpdate = false) {
|
|
73
73
|
var _a, _b, _c;
|
|
74
74
|
const fileContent = (0, fs_1.readFileSync)(filePath, "utf8");
|
|
75
75
|
const fileExt = path_1.default.extname(filePath).toLowerCase();
|
|
@@ -86,12 +86,17 @@ function createOrUpdateApplication(client, filePath, appRef) {
|
|
|
86
86
|
const applications = new SDK.Applications(client);
|
|
87
87
|
delete config.testCases;
|
|
88
88
|
(_c = (_b = (_a = config.intelligence) === null || _a === void 0 ? void 0 : _a.config) === null || _b === void 0 ? void 0 : _b.languageModel) === null || _c === void 0 ? true : delete _c.apiKey;
|
|
89
|
-
if (
|
|
90
|
-
|
|
89
|
+
if (isUpdate) {
|
|
90
|
+
// The positional appRef takes precedence over any `ref` in the file; fall
|
|
91
|
+
// back to the file's `ref` when the positional is omitted.
|
|
92
|
+
const ref = appRef !== null && appRef !== void 0 ? appRef : config.ref;
|
|
93
|
+
if (!ref) {
|
|
94
|
+
throw new Error("An Application ref is required to update. Provide it as the positional argument or include `ref` in the file.");
|
|
95
|
+
}
|
|
96
|
+
delete config.ref;
|
|
97
|
+
const updateConfig = Object.assign(Object.assign({}, config), { ref });
|
|
91
98
|
return applications.updateApplication(updateConfig);
|
|
92
99
|
}
|
|
93
|
-
|
|
94
|
-
return applications.createApplication(config);
|
|
95
|
-
}
|
|
100
|
+
return applications.createApplication(config);
|
|
96
101
|
});
|
|
97
102
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fonoster/ctl",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.22.1",
|
|
4
4
|
"description": "Fonoster Control Tool",
|
|
5
5
|
"author": "Pedro Sanders <psanders@fonoster.com>",
|
|
6
6
|
"homepage": "https://github.com/fonoster/fonoster#readme",
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"bugs": {
|
|
31
31
|
"url": "https://github.com/fonoster/fonoster/issues"
|
|
32
32
|
},
|
|
33
|
-
"gitHead": "
|
|
33
|
+
"gitHead": "643925587e6ba287fb36414c5d09fbac6db47ca1",
|
|
34
34
|
"bin": {
|
|
35
35
|
"fonoster": "./bin/run.js"
|
|
36
36
|
},
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
}
|
|
52
52
|
},
|
|
53
53
|
"dependencies": {
|
|
54
|
-
"@fonoster/sdk": "^0.
|
|
54
|
+
"@fonoster/sdk": "^0.22.0",
|
|
55
55
|
"@inquirer/prompts": "^7.1.0",
|
|
56
56
|
"@oclif/core": "^4.0.34",
|
|
57
57
|
"@oclif/plugin-warn-if-update-available": "^3.1.28",
|