@fonoster/ctl 0.7.39 → 0.7.40

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.
@@ -0,0 +1,15 @@
1
+ import { Command, Interfaces } from "@oclif/core";
2
+ export type Args<T extends typeof Command> = Interfaces.InferredArgs<T["args"]>;
3
+ export declare abstract class BaseCommand<T extends typeof Command> extends Command {
4
+ static baseFlags: {
5
+ insecure: Interfaces.BooleanFlag<boolean>;
6
+ };
7
+ protected flags: Flags<T>;
8
+ protected args: Args<T>;
9
+ init(): Promise<void>;
10
+ protected catch(err: Error & {
11
+ exitCode?: number;
12
+ }): Promise<any>;
13
+ protected finally(_: Error | undefined): Promise<any>;
14
+ }
15
+ export type Flags<T extends typeof Command> = Interfaces.InferredFlags<(typeof BaseCommand)["baseFlags"] & T["flags"]>;
@@ -0,0 +1,80 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.BaseCommand = void 0;
13
+ /* eslint-disable import/no-unresolved */
14
+ /*
15
+ * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com)
16
+ * http://github.com/fonoster/fonoster
17
+ *
18
+ * This file is part of Fonoster
19
+ *
20
+ * Licensed under the MIT License (the "License");
21
+ * you may not use this file except in compliance with
22
+ * the License. You may obtain a copy of the License at
23
+ *
24
+ * https://opensource.org/licenses/MIT
25
+ *
26
+ * Unless required by applicable law or agreed to in writing, software
27
+ * distributed under the License is distributed on an "AS IS" BASIS,
28
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
29
+ * See the License for the specific language governing permissions and
30
+ * limitations under the License.
31
+ */
32
+ const core_1 = require("@oclif/core");
33
+ class BaseCommand extends core_1.Command {
34
+ init() {
35
+ const _super = Object.create(null, {
36
+ init: { get: () => super.init },
37
+ ctor: { get: () => super.ctor }
38
+ });
39
+ return __awaiter(this, void 0, void 0, function* () {
40
+ yield _super.init.call(this);
41
+ const { args, flags } = yield this.parse({
42
+ flags: this.ctor.flags,
43
+ baseFlags: _super.ctor.baseFlags,
44
+ enableJsonFlag: this.ctor.enableJsonFlag,
45
+ args: this.ctor.args,
46
+ strict: this.ctor.strict
47
+ });
48
+ this.flags = flags;
49
+ this.args = args;
50
+ });
51
+ }
52
+ catch(err) {
53
+ const _super = Object.create(null, {
54
+ catch: { get: () => super.catch }
55
+ });
56
+ return __awaiter(this, void 0, void 0, function* () {
57
+ // add any custom logic to handle errors from the command
58
+ // or simply return the parent class error handling
59
+ return _super.catch.call(this, err);
60
+ });
61
+ }
62
+ finally(_) {
63
+ const _super = Object.create(null, {
64
+ finally: { get: () => super.finally }
65
+ });
66
+ return __awaiter(this, void 0, void 0, function* () {
67
+ // called after run and catch regardless of whether or not the command errored
68
+ return _super.finally.call(this, _);
69
+ });
70
+ }
71
+ }
72
+ exports.BaseCommand = BaseCommand;
73
+ // define flags that can be inherited by any command that extends BaseCommand
74
+ BaseCommand.baseFlags = {
75
+ insecure: core_1.Flags.boolean({
76
+ char: "i",
77
+ description: "allow connections to a server without TLS enabled",
78
+ default: false
79
+ })
80
+ };
package/dist/Help.d.ts ADDED
@@ -0,0 +1,6 @@
1
+ import { Help } from "@oclif/core";
2
+ export default class CustomHelp extends Help {
3
+ protected showRootHelp(): Promise<void>;
4
+ private showLogo;
5
+ private get customCommands();
6
+ }
package/dist/Help.js ADDED
@@ -0,0 +1,52 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ /*
7
+ * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com)
8
+ * http://github.com/fonoster/fonoster
9
+ *
10
+ * This file is part of Fonoster
11
+ *
12
+ * Licensed under the MIT License (the "License");
13
+ * you may not use this file except in compliance with
14
+ * the License. You may obtain a copy of the License at
15
+ *
16
+ * https://opensource.org/licenses/MIT
17
+ *
18
+ * Unless required by applicable law or agreed to in writing, software
19
+ * distributed under the License is distributed on an "AS IS" BASIS,
20
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21
+ * See the License for the specific language governing permissions and
22
+ * limitations under the License.
23
+ */
24
+ // eslint-disable-next-line import/no-unresolved
25
+ const core_1 = require("@oclif/core");
26
+ const figlet_1 = __importDefault(require("figlet"));
27
+ class CustomHelp extends core_1.Help {
28
+ showRootHelp() {
29
+ this.showLogo();
30
+ this.log(this.formatRoot());
31
+ this.log("");
32
+ this.log(this.formatCommands(this.customCommands));
33
+ this.log("");
34
+ return Promise.resolve();
35
+ }
36
+ showLogo() {
37
+ this.log("\x1b[32m");
38
+ this.log(figlet_1.default.textSync("Fonoster", {
39
+ horizontalLayout: "default",
40
+ verticalLayout: "default",
41
+ width: 60,
42
+ whitespaceBreak: true
43
+ }));
44
+ this.log("\x1b[0m");
45
+ }
46
+ get customCommands() {
47
+ return this.sortedCommands
48
+ .filter((c) => c.id)
49
+ .sort((a, b) => (a.id.includes(":") ? 1 : b.id.includes(":") ? -1 : 0));
50
+ }
51
+ }
52
+ exports.default = CustomHelp;
@@ -1,5 +1,5 @@
1
1
  import { Command } from "@oclif/core";
2
- export default class AuthLogin extends Command {
2
+ export default class List extends Command {
3
3
  static description: string;
4
4
  static examples: string[];
5
5
  run(): Promise<void>;
@@ -0,0 +1,101 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
36
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
37
+ return new (P || (P = Promise))(function (resolve, reject) {
38
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
39
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
40
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
41
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
42
+ });
43
+ };
44
+ var __importDefault = (this && this.__importDefault) || function (mod) {
45
+ return (mod && mod.__esModule) ? mod : { "default": mod };
46
+ };
47
+ Object.defineProperty(exports, "__esModule", { value: true });
48
+ /* eslint-disable import/no-unresolved */
49
+ /*
50
+ * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com)
51
+ * http://github.com/fonoster/fonoster
52
+ *
53
+ * This file is part of Fonoster
54
+ *
55
+ * Licensed under the MIT License (the "License");
56
+ * you may not use this file except in compliance with
57
+ * the License. You may obtain a copy of the License at
58
+ *
59
+ * https://opensource.org/licenses/MIT
60
+ *
61
+ * Unless required by applicable law or agreed to in writing, software
62
+ * distributed under the License is distributed on an "AS IS" BASIS,
63
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
64
+ * See the License for the specific language governing permissions and
65
+ * limitations under the License.
66
+ */
67
+ const SDK = __importStar(require("@fonoster/sdk"));
68
+ const core_1 = require("@oclif/core");
69
+ const cliui_1 = __importDefault(require("cliui"));
70
+ const config_1 = require("../../config");
71
+ const constants_1 = require("../../constants");
72
+ class List extends core_1.Command {
73
+ run() {
74
+ return __awaiter(this, void 0, void 0, function* () {
75
+ const workspaces = (0, config_1.getConfig)(constants_1.CONFIG_FILE);
76
+ const currentWorkspace = workspaces.find((w) => w.active);
77
+ if (!currentWorkspace) {
78
+ this.error("No active workspace found.");
79
+ }
80
+ const client = new SDK.Client({
81
+ endpoint: currentWorkspace.endpoint,
82
+ accessKeyId: currentWorkspace.workspaceRef
83
+ });
84
+ yield client.loginWithApiKey(currentWorkspace.accessKeyId, currentWorkspace.accessKeySecret);
85
+ const applications = new SDK.Applications(client);
86
+ const response = yield applications.listApplications({
87
+ pageSize: 1000,
88
+ pageToken: ""
89
+ });
90
+ const ui = (0, cliui_1.default)({ width: 120 });
91
+ ui.div({ text: "REF", padding: [0, 0, 0, 0] }, { text: "NAME", padding: [0, 0, 0, 0] }, { text: "TYPE", padding: [0, 0, 0, 0] });
92
+ response.items.forEach((workspace) => {
93
+ ui.div({ text: workspace.ref, padding: [0, 0, 0, 0] }, { text: workspace.name, padding: [0, 0, 0, 0] }, { text: workspace.type, padding: [0, 0, 0, 0] });
94
+ });
95
+ this.log(ui.toString());
96
+ });
97
+ }
98
+ }
99
+ List.description = "list all existing Applications";
100
+ List.examples = ["<%= config.bin %> <%= command.id %>"];
101
+ exports.default = List;
@@ -0,0 +1,6 @@
1
+ import { Command } from "@oclif/core";
2
+ export default class Bug extends Command {
3
+ static description: string;
4
+ static examples: string[];
5
+ run(): Promise<void>;
6
+ }
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ /* eslint-disable import/no-unresolved */
13
+ /*
14
+ * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com)
15
+ * http://github.com/fonoster/fonoster
16
+ *
17
+ * This file is part of Fonoster
18
+ *
19
+ * Licensed under the MIT License (the "License");
20
+ * you may not use this file except in compliance with
21
+ * the License. You may obtain a copy of the License at
22
+ *
23
+ * https://opensource.org/licenses/MIT
24
+ *
25
+ * Unless required by applicable law or agreed to in writing, software
26
+ * distributed under the License is distributed on an "AS IS" BASIS,
27
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
28
+ * See the License for the specific language governing permissions and
29
+ * limitations under the License.
30
+ */
31
+ const core_1 = require("@oclif/core");
32
+ class Bug extends core_1.Command {
33
+ run() {
34
+ return __awaiter(this, void 0, void 0, function* () {
35
+ const link = " https://github.com/fonoster/fonoster/issues/new?assignees=&labels=&template=bug_report.md&title=";
36
+ this.log(`Please report bugs to the link below:\n${link}`);
37
+ });
38
+ }
39
+ }
40
+ Bug.description = "start a bug report 🐞";
41
+ Bug.examples = ["<%= config.bin %> <%= command.id %>"];
42
+ exports.default = Bug;
@@ -0,0 +1,6 @@
1
+ import { Command } from "@oclif/core";
2
+ export default class Feedback extends Command {
3
+ static description: string;
4
+ static examples: string[];
5
+ run(): Promise<void>;
6
+ }
@@ -0,0 +1,45 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ /* eslint-disable import/no-unresolved */
13
+ /*
14
+ * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com)
15
+ * http://github.com/fonoster/fonoster
16
+ *
17
+ * This file is part of Fonoster
18
+ *
19
+ * Licensed under the MIT License (the "License");
20
+ * you may not use this file except in compliance with
21
+ * the License. You may obtain a copy of the License at
22
+ *
23
+ * https://opensource.org/licenses/MIT
24
+ *
25
+ * Unless required by applicable law or agreed to in writing, software
26
+ * distributed under the License is distributed on an "AS IS" BASIS,
27
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
28
+ * See the License for the specific language governing permissions and
29
+ * limitations under the License.
30
+ */
31
+ const core_1 = require("@oclif/core");
32
+ class Feedback extends core_1.Command {
33
+ run() {
34
+ return __awaiter(this, void 0, void 0, function* () {
35
+ const link = " https://docs.google.com/forms/d/e/1FAIpQLSd1G2ahRYqkbksOvz7XhNHfSLepUh3KzRHsXh2HXfZr68nhtQ/viewform?vc=0&c=0&w=1&flr=0";
36
+ this.log(`Please report bugs to the link below:\n${link}`);
37
+ });
38
+ }
39
+ }
40
+ Feedback.description = `let us know how we're doing
41
+ ...
42
+ Help us improve by providing some feedback
43
+ `;
44
+ Feedback.examples = ["<%= config.bin %> <%= command.id %>"];
45
+ exports.default = Feedback;
@@ -0,0 +1,6 @@
1
+ import { Command } from "@oclif/core";
2
+ export default class Current extends Command {
3
+ static description: string;
4
+ static examples: string[];
5
+ run(): Promise<void>;
6
+ }
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ /* eslint-disable import/no-unresolved */
13
+ /*
14
+ * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com)
15
+ * http://github.com/fonoster/fonoster
16
+ *
17
+ * This file is part of Fonoster
18
+ *
19
+ * Licensed under the MIT License (the "License");
20
+ * you may not use this file except in compliance with
21
+ * the License. You may obtain a copy of the License at
22
+ *
23
+ * https://opensource.org/licenses/MIT
24
+ *
25
+ * Unless required by applicable law or agreed to in writing, software
26
+ * distributed under the License is distributed on an "AS IS" BASIS,
27
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
28
+ * See the License for the specific language governing permissions and
29
+ * limitations under the License.
30
+ */
31
+ const core_1 = require("@oclif/core");
32
+ const config_1 = require("../../config");
33
+ const constants_1 = require("../../constants");
34
+ class Current extends core_1.Command {
35
+ run() {
36
+ return __awaiter(this, void 0, void 0, function* () {
37
+ const workspaces = (0, config_1.getConfig)(constants_1.CONFIG_FILE);
38
+ const currentWorkspace = workspaces.find((w) => w.active === true);
39
+ const { workspaceName, workspaceRef } = currentWorkspace;
40
+ this.log(`Current Workspace: ${workspaceName} (${workspaceRef})`);
41
+ });
42
+ }
43
+ }
44
+ Current.description = "show the name of the current Workspace";
45
+ Current.examples = ["<%= config.bin %> <%= command.id %>"];
46
+ exports.default = Current;
@@ -0,0 +1,6 @@
1
+ import { Command } from "@oclif/core";
2
+ export default class List extends Command {
3
+ static description: string;
4
+ static examples: string[];
5
+ run(): Promise<void>;
6
+ }
@@ -0,0 +1,53 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ /* eslint-disable import/no-unresolved */
16
+ /*
17
+ * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com)
18
+ * http://github.com/fonoster/fonoster
19
+ *
20
+ * This file is part of Fonoster
21
+ *
22
+ * Licensed under the MIT License (the "License");
23
+ * you may not use this file except in compliance with
24
+ * the License. You may obtain a copy of the License at
25
+ *
26
+ * https://opensource.org/licenses/MIT
27
+ *
28
+ * Unless required by applicable law or agreed to in writing, software
29
+ * distributed under the License is distributed on an "AS IS" BASIS,
30
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
31
+ * See the License for the specific language governing permissions and
32
+ * limitations under the License.
33
+ */
34
+ const core_1 = require("@oclif/core");
35
+ const cliui_1 = __importDefault(require("cliui"));
36
+ const config_1 = require("../../config");
37
+ const constants_1 = require("../../constants");
38
+ class List extends core_1.Command {
39
+ run() {
40
+ return __awaiter(this, void 0, void 0, function* () {
41
+ const workspaces = (0, config_1.getConfig)(constants_1.CONFIG_FILE);
42
+ const ui = (0, cliui_1.default)({ width: 120 });
43
+ ui.div({ text: "REF", padding: [0, 0, 0, 0] }, { text: "NAME", padding: [0, 0, 0, 0] }, { text: "STATUS", padding: [0, 0, 0, 0] });
44
+ workspaces.forEach((workspace) => {
45
+ ui.div({ text: workspace.workspaceRef, padding: [0, 0, 0, 0] }, { text: workspace.workspaceName, padding: [0, 0, 0, 0] }, { text: workspace.active ? "[ACTIVE]" : "", padding: [0, 0, 0, 0] });
46
+ });
47
+ this.log(ui.toString());
48
+ });
49
+ }
50
+ }
51
+ List.description = "list all linked Workspaces";
52
+ List.examples = ["<%= config.bin %> <%= command.id %>"];
53
+ exports.default = List;
@@ -0,0 +1,8 @@
1
+ import { BaseCommand } from "../../BaseCommand";
2
+ export default class Login extends BaseCommand<typeof Login> {
3
+ static description: string;
4
+ static examples: string[];
5
+ run(): Promise<void>;
6
+ private saveConfig;
7
+ private getWorkspaceFromDB;
8
+ }
@@ -0,0 +1,146 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
36
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
37
+ return new (P || (P = Promise))(function (resolve, reject) {
38
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
39
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
40
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
41
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
42
+ });
43
+ };
44
+ Object.defineProperty(exports, "__esModule", { value: true });
45
+ /* eslint-disable import/no-unresolved */
46
+ /*
47
+ * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com)
48
+ * http://github.com/fonoster/fonoster
49
+ *
50
+ * This file is part of Fonoster
51
+ *
52
+ * Licensed under the MIT License (the "License");
53
+ * you may not use this file except in compliance with
54
+ * the License. You may obtain a copy of the License at
55
+ *
56
+ * https://opensource.org/licenses/MIT
57
+ *
58
+ * Unless required by applicable law or agreed to in writing, software
59
+ * distributed under the License is distributed on an "AS IS" BASIS,
60
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
61
+ * See the License for the specific language governing permissions and
62
+ * limitations under the License.
63
+ */
64
+ const SDK = __importStar(require("@fonoster/sdk"));
65
+ const prompts_1 = require("@inquirer/prompts");
66
+ const BaseCommand_1 = require("../../BaseCommand");
67
+ const config_1 = require("../../config");
68
+ const saveConfig_1 = require("../../config/saveConfig");
69
+ const constants_1 = require("../../constants");
70
+ class Login extends BaseCommand_1.BaseCommand {
71
+ run() {
72
+ return __awaiter(this, void 0, void 0, function* () {
73
+ this.log("This utility will help you add a Workspace.");
74
+ this.log("Press ^C at any time to quit.");
75
+ const answers = {
76
+ endpoint: yield (0, prompts_1.input)({
77
+ message: "Endpoint",
78
+ default: "api.fonoster.dev"
79
+ }),
80
+ accessKeyId: yield (0, prompts_1.input)({
81
+ message: "Access Key Id",
82
+ required: true
83
+ }),
84
+ accessKeySecret: yield (0, prompts_1.password)({
85
+ message: "Access Key Secret"
86
+ }),
87
+ confirm: yield (0, prompts_1.confirm)({
88
+ message: "Ready?"
89
+ })
90
+ };
91
+ if (!answers.confirm) {
92
+ this.log("Aborted!");
93
+ return;
94
+ }
95
+ try {
96
+ const workspaceFromDB = yield this.getWorkspaceFromDB(answers);
97
+ this.saveConfig(Object.assign(Object.assign({}, answers), { workspaceAccessKeyId: workspaceFromDB.accessKeyId, ref: workspaceFromDB.ref, name: workspaceFromDB.name }));
98
+ }
99
+ catch (e) {
100
+ this.error(e.message);
101
+ }
102
+ });
103
+ }
104
+ saveConfig(params) {
105
+ const { endpoint, workspaceAccessKeyId, accessKeyId, accessKeySecret, ref: workspaceRef, name: workspaceName } = params;
106
+ const workspace = {
107
+ workspaceAccessKeyId,
108
+ endpoint,
109
+ accessKeyId,
110
+ accessKeySecret,
111
+ workspaceRef,
112
+ workspaceName
113
+ };
114
+ const config = (0, config_1.getConfig)(constants_1.CONFIG_FILE);
115
+ const updatedConfig = (0, config_1.addWorkspace)(workspace, config);
116
+ (0, saveConfig_1.saveConfig)(constants_1.CONFIG_FILE, updatedConfig);
117
+ this.log("Added Workspace!");
118
+ }
119
+ getWorkspaceFromDB(params) {
120
+ return __awaiter(this, void 0, void 0, function* () {
121
+ const { flags } = yield this.parse(BaseCommand_1.BaseCommand);
122
+ const { endpoint, accessKeyId, accessKeySecret } = params;
123
+ // Get Workspace configuration (which validates the login)
124
+ const client = new SDK.Client({
125
+ endpoint,
126
+ accessKeyId,
127
+ allowInsecure: flags.insecure
128
+ });
129
+ try {
130
+ yield client.loginWithApiKey(accessKeyId, accessKeySecret);
131
+ const workspaces = new SDK.Workspaces(client);
132
+ const workspaceFromDB = (yield workspaces.listWorkspaces()).items[0];
133
+ if (!workspaceFromDB) {
134
+ this.error("Invalid credentials!");
135
+ }
136
+ return workspaceFromDB;
137
+ }
138
+ catch (e) {
139
+ this.error(e.message);
140
+ }
141
+ });
142
+ }
143
+ }
144
+ Login.description = "add a Workspace to the local environment";
145
+ Login.examples = ["<%= config.bin %> <%= command.id %>"];
146
+ exports.default = Login;
@@ -0,0 +1,9 @@
1
+ import { Command } from "@oclif/core";
2
+ export default class Logout extends Command {
3
+ static description: string;
4
+ static examples: string[];
5
+ static args: {
6
+ ref: import("@oclif/core/lib/interfaces").Arg<string, Record<string, unknown>>;
7
+ };
8
+ run(): Promise<void>;
9
+ }
@@ -28,53 +28,28 @@ Object.defineProperty(exports, "__esModule", { value: true });
28
28
  * See the License for the specific language governing permissions and
29
29
  * limitations under the License.
30
30
  */
31
- const sdk_1 = require("@fonoster/sdk");
32
- const prompts_1 = require("@inquirer/prompts");
33
31
  const core_1 = require("@oclif/core");
34
32
  const config_1 = require("../../config");
35
33
  const saveConfig_1 = require("../../config/saveConfig");
36
34
  const constants_1 = require("../../constants");
37
- class AuthLogin extends core_1.Command {
35
+ class Logout extends core_1.Command {
38
36
  run() {
39
37
  return __awaiter(this, void 0, void 0, function* () {
40
- this.log("This utility will help you link to a Workspace.");
41
- this.log("Press ^C at any time to quit.");
42
- const answers = {
43
- endpoint: yield (0, prompts_1.input)({
44
- message: "Endpoint",
45
- default: "api.fonoster.dev"
46
- }),
47
- accessKeyId: yield (0, prompts_1.input)({
48
- message: "Access Key Id",
49
- required: true
50
- }),
51
- accessKeySecret: yield (0, prompts_1.password)({
52
- message: "Access Key Secret"
53
- }),
54
- confirm: yield (0, prompts_1.confirm)({
55
- message: "Ready?"
56
- })
57
- };
58
- if (!answers.confirm) {
59
- this.log("Aborted!");
38
+ const { args } = yield this.parse(Logout);
39
+ if (!args.ref) {
40
+ this.error("Missing Workspace reference");
60
41
  return;
61
42
  }
62
- // Get Workspace configuration (which validates the login)
63
- const client = new sdk_1.Client({
64
- endpoint: answers.endpoint,
65
- accessKeyId: answers.accessKeyId,
66
- allowInsecure: true
67
- });
68
- yield client.loginWithApiKey(answers.accessKeySecret);
69
- this.log("Saving configuration...");
70
- const config = (0, config_1.getConfig)(constants_1.CONFIG_FILE);
71
- const answerWithoutConfirm = Object.assign(Object.assign({}, answers), { confirm: undefined });
72
- const updatedConfig = (0, config_1.addWorkspace)(answerWithoutConfirm, config);
73
- (0, saveConfig_1.saveConfig)(constants_1.CONFIG_FILE, updatedConfig);
43
+ const workspaces = (0, config_1.getConfig)(constants_1.CONFIG_FILE);
44
+ const updatedWorkspaces = (0, config_1.removeWorkspace)(args.ref, workspaces);
45
+ (0, saveConfig_1.saveConfig)(constants_1.CONFIG_FILE, updatedWorkspaces);
74
46
  this.log("Done!");
75
47
  });
76
48
  }
77
49
  }
78
- AuthLogin.description = "log in to a Fonoster deployment";
79
- AuthLogin.examples = ["<%= config.bin %> <%= command.id %>"];
80
- exports.default = AuthLogin;
50
+ Logout.description = "remove a linked Workspace";
51
+ Logout.examples = ["<%= config.bin %> <%= command.id %>"];
52
+ Logout.args = {
53
+ ref: core_1.Args.string({ description: "The Workspace to unlink from" })
54
+ };
55
+ exports.default = Logout;
@@ -0,0 +1,9 @@
1
+ import { Command } from "@oclif/core";
2
+ export default class Set extends Command {
3
+ static description: string;
4
+ static examples: string[];
5
+ static args: {
6
+ ref: import("@oclif/core/lib/interfaces").Arg<string, Record<string, unknown>>;
7
+ };
8
+ run(): Promise<void>;
9
+ }
@@ -0,0 +1,57 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ /* eslint-disable import/no-unresolved */
13
+ /*
14
+ * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com)
15
+ * http://github.com/fonoster/fonoster
16
+ *
17
+ * This file is part of Fonoster
18
+ *
19
+ * Licensed under the MIT License (the "License");
20
+ * you may not use this file except in compliance with
21
+ * the License. You may obtain a copy of the License at
22
+ *
23
+ * https://opensource.org/licenses/MIT
24
+ *
25
+ * Unless required by applicable law or agreed to in writing, software
26
+ * distributed under the License is distributed on an "AS IS" BASIS,
27
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
28
+ * See the License for the specific language governing permissions and
29
+ * limitations under the License.
30
+ */
31
+ const core_1 = require("@oclif/core");
32
+ const config_1 = require("../../config");
33
+ const saveConfig_1 = require("../../config/saveConfig");
34
+ const constants_1 = require("../../constants");
35
+ class Set extends core_1.Command {
36
+ run() {
37
+ return __awaiter(this, void 0, void 0, function* () {
38
+ const { args } = yield this.parse(Set);
39
+ if (!args.ref) {
40
+ this.error("Missing Workspace reference");
41
+ return;
42
+ }
43
+ const workspaces = (0, config_1.getConfig)(constants_1.CONFIG_FILE);
44
+ const updatedWorkspaces = (0, config_1.setCurrentWorkspace)(args.ref, workspaces);
45
+ const currentWorkspace = updatedWorkspaces.find((w) => w.workspaceRef === args.ref);
46
+ (0, saveConfig_1.saveConfig)(constants_1.CONFIG_FILE, updatedWorkspaces);
47
+ const { workspaceName, workspaceRef } = currentWorkspace;
48
+ this.log(`Current Workspace: ${workspaceName} (${workspaceRef})`);
49
+ });
50
+ }
51
+ }
52
+ Set.description = "make a Workspace the default";
53
+ Set.examples = ["<%= config.bin %> <%= command.id %>"];
54
+ Set.args = {
55
+ ref: core_1.Args.string({ description: "The Workspace to unlink from" })
56
+ };
57
+ exports.default = Set;
@@ -1,10 +1,15 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.addWorkspace = addWorkspace;
4
+ const validations_1 = require("./validations");
4
5
  function addWorkspace(config, workspaces) {
6
+ validations_1.workspaceConfigSchema.parse(config);
7
+ const deactivateAll = (workspaces) => workspaces.map((workspace) => (Object.assign(Object.assign({}, workspace), { active: false })));
5
8
  const workspaceIndex = workspaces.findIndex((workspace) => workspace.workspaceRef === config.workspaceRef);
6
9
  if (workspaceIndex === -1) {
7
- return workspaces.concat(Object.assign(Object.assign({}, config), { active: true }));
10
+ return deactivateAll(workspaces).concat(Object.assign(Object.assign({}, config), { active: true }));
8
11
  }
12
+ workspaces = deactivateAll(workspaces);
9
13
  workspaces[workspaceIndex] = Object.assign(Object.assign({}, config), { active: true });
14
+ return workspaces;
10
15
  }
@@ -1,6 +1,7 @@
1
1
  import { z } from "zod";
2
2
  declare const workspaceConfigSchema: z.ZodObject<{
3
3
  endpoint: z.ZodString;
4
+ workspaceAccessKeyId: z.ZodString;
4
5
  accessKeyId: z.ZodString;
5
6
  accessKeySecret: z.ZodString;
6
7
  workspaceRef: z.ZodString;
@@ -8,6 +9,7 @@ declare const workspaceConfigSchema: z.ZodObject<{
8
9
  active: z.ZodOptional<z.ZodBoolean>;
9
10
  }, "strip", z.ZodTypeAny, {
10
11
  endpoint?: string;
12
+ workspaceAccessKeyId?: string;
11
13
  accessKeyId?: string;
12
14
  accessKeySecret?: string;
13
15
  workspaceRef?: string;
@@ -15,6 +17,7 @@ declare const workspaceConfigSchema: z.ZodObject<{
15
17
  active?: boolean;
16
18
  }, {
17
19
  endpoint?: string;
20
+ workspaceAccessKeyId?: string;
18
21
  accessKeyId?: string;
19
22
  accessKeySecret?: string;
20
23
  workspaceRef?: string;
@@ -22,6 +22,9 @@ exports.workspaceConfigSchema = void 0;
22
22
  const zod_1 = require("zod");
23
23
  const workspaceConfigSchema = zod_1.z.object({
24
24
  endpoint: zod_1.z.string().min(1, "The endpoint value is required"),
25
+ workspaceAccessKeyId: zod_1.z
26
+ .string()
27
+ .min(1, "The workspaceAccessKeyId value is required"),
25
28
  accessKeyId: zod_1.z.string().min(1, "The accessKeyId value is required"),
26
29
  accessKeySecret: zod_1.z.string().min(1, "The accessKeySecret value is required"),
27
30
  workspaceRef: zod_1.z.string().min(1, "The workspaceRef value is required"),
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@fonoster/ctl",
3
- "version": "0.7.39",
4
- "description": "Fonoster Command Line Interface",
3
+ "version": "0.7.40",
4
+ "description": "Fonoster Control Tool",
5
5
  "author": "Pedro Sanders <psanders@fonoster.com>",
6
6
  "homepage": "https://github.com/fonoster/fonoster#readme",
7
7
  "license": "MIT",
@@ -30,7 +30,7 @@
30
30
  "bugs": {
31
31
  "url": "https://github.com/fonoster/fonoster/issues"
32
32
  },
33
- "gitHead": "1f99bffac20ff5107d56701e71ee52dd759e0a02",
33
+ "gitHead": "aa7ebbccc2edfcdaa11250cb615340db71f639e6",
34
34
  "bin": {
35
35
  "fonoster": "./bin/run.js"
36
36
  },
@@ -38,17 +38,21 @@
38
38
  "bin": "fonoster",
39
39
  "commands": "./dist/commands",
40
40
  "dirname": "fonoster",
41
- "topicSeparator": ":"
41
+ "topicSeparator": ":",
42
+ "helpClass": "./dist/help"
42
43
  },
43
44
  "dependencies": {
44
- "@fonoster/sdk": "^0.7.39",
45
- "@fonoster/websdk": "^0.4.13",
45
+ "@fonoster/sdk": "^0.7.40",
46
46
  "@inquirer/prompts": "^7.1.0",
47
47
  "@oclif/core": "^4.0.34",
48
+ "cliui": "^8.0.1",
49
+ "figlet": "^1.8.0",
50
+ "terminal-link": "^3.0.0",
48
51
  "zod": "^3.23.8"
49
52
  },
50
53
  "devDependencies": {
51
- "@types/node": "^18.19.67",
54
+ "@types/figlet": "^1.7.0",
55
+ "@types/node": "22.10.1",
52
56
  "ts-node": "^10.9.2"
53
57
  }
54
58
  }