@apimatic/cli 1.1.0-alpha.13 → 1.1.0-alpha.14
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.
- package/README.md +22 -45
- package/lib/actions/actionResult.d.ts +8 -0
- package/lib/actions/actionResult.js +25 -0
- package/lib/actions/actionResult.js.map +1 -0
- package/lib/actions/portal/generatePortalAction.d.ts +15 -0
- package/lib/actions/portal/generatePortalAction.js +76 -0
- package/lib/actions/portal/generatePortalAction.js.map +1 -0
- package/lib/actions/portal/recipe/new-recipe.d.ts +3 -2
- package/lib/actions/portal/recipe/new-recipe.js +18 -25
- package/lib/actions/portal/recipe/new-recipe.js.map +1 -1
- package/lib/actions/portal/serve.d.ts +17 -0
- package/lib/actions/portal/serve.js +36 -0
- package/lib/actions/portal/serve.js.map +1 -0
- package/lib/actions/portal/toc/new-toc.d.ts +2 -1
- package/lib/actions/portal/toc/new-toc.js +21 -21
- package/lib/actions/portal/toc/new-toc.js.map +1 -1
- package/lib/application/portal/serve/portal-watcher.d.ts +8 -0
- package/lib/application/portal/serve/portal-watcher.js +60 -0
- package/lib/application/portal/serve/portal-watcher.js.map +1 -0
- package/lib/application/portal/serve/serve-handler.d.ts +16 -0
- package/lib/application/portal/serve/serve-handler.js +90 -0
- package/lib/application/portal/serve/serve-handler.js.map +1 -0
- package/lib/application/portal/serve/watcher-handler.d.ts +5 -0
- package/lib/application/portal/serve/watcher-handler.js +27 -0
- package/lib/application/portal/serve/watcher-handler.js.map +1 -0
- package/lib/application/portal/toc/sdl-parser.d.ts +2 -1
- package/lib/application/portal/toc/sdl-parser.js +4 -4
- package/lib/application/portal/toc/sdl-parser.js.map +1 -1
- package/lib/client-utils/sdk-client.js +5 -22
- package/lib/client-utils/sdk-client.js.map +1 -1
- package/lib/commands/api/transform.js +2 -6
- package/lib/commands/api/transform.js.map +1 -1
- package/lib/commands/api/validate.js +2 -6
- package/lib/commands/api/validate.js.map +1 -1
- package/lib/commands/auth/login.js +31 -33
- package/lib/commands/auth/login.js.map +1 -1
- package/lib/commands/auth/logout.js +1 -5
- package/lib/commands/auth/logout.js.map +1 -1
- package/lib/commands/auth/status.js +1 -5
- package/lib/commands/auth/status.js.map +1 -1
- package/lib/commands/portal/generate.d.ts +7 -9
- package/lib/commands/portal/generate.js +17 -67
- package/lib/commands/portal/generate.js.map +1 -1
- package/lib/commands/portal/quickstart.d.ts +2 -2
- package/lib/commands/portal/quickstart.js +50 -18
- package/lib/commands/portal/quickstart.js.map +1 -1
- package/lib/commands/portal/recipe/new.d.ts +2 -3
- package/lib/commands/portal/recipe/new.js +16 -23
- package/lib/commands/portal/recipe/new.js.map +1 -1
- package/lib/commands/portal/serve.d.ts +7 -5
- package/lib/commands/portal/serve.js +60 -97
- package/lib/commands/portal/serve.js.map +1 -1
- package/lib/commands/portal/toc/new.d.ts +1 -1
- package/lib/commands/portal/toc/new.js +20 -24
- package/lib/commands/portal/toc/new.js.map +1 -1
- package/lib/commands/sdk/generate.js +2 -10
- package/lib/commands/sdk/generate.js.map +1 -1
- package/lib/controllers/portal/quickstart.d.ts +0 -2
- package/lib/controllers/portal/quickstart.js +2 -60
- package/lib/controllers/portal/quickstart.js.map +1 -1
- package/lib/infrastructure/file-service.d.ts +13 -0
- package/lib/infrastructure/file-service.js +54 -0
- package/lib/infrastructure/file-service.js.map +1 -0
- package/lib/infrastructure/services/portal-service.d.ts +4 -4
- package/lib/infrastructure/services/portal-service.js +21 -43
- package/lib/infrastructure/services/portal-service.js.map +1 -1
- package/lib/infrastructure/zip-service.d.ts +6 -0
- package/lib/infrastructure/zip-service.js +25 -0
- package/lib/infrastructure/zip-service.js.map +1 -0
- package/lib/prompts/portal/common/base-prompts.d.ts +7 -0
- package/lib/prompts/portal/common/base-prompts.js +19 -0
- package/lib/prompts/portal/common/base-prompts.js.map +1 -0
- package/lib/prompts/portal/generate.d.ts +3 -1
- package/lib/prompts/portal/generate.js +29 -16
- package/lib/prompts/portal/generate.js.map +1 -1
- package/lib/prompts/portal/quickstart.d.ts +5 -6
- package/lib/prompts/portal/quickstart.js +28 -20
- package/lib/prompts/portal/quickstart.js.map +1 -1
- package/lib/prompts/portal/recipe/new-recipe.js +4 -5
- package/lib/prompts/portal/recipe/new-recipe.js.map +1 -1
- package/lib/prompts/portal/serve.d.ts +4 -6
- package/lib/prompts/portal/serve.js +24 -15
- package/lib/prompts/portal/serve.js.map +1 -1
- package/lib/prompts/portal/toc/new-toc.js +5 -4
- package/lib/prompts/portal/toc/new-toc.js.map +1 -1
- package/lib/types/file/directoryPath.d.ts +7 -0
- package/lib/types/file/directoryPath.js +16 -0
- package/lib/types/file/directoryPath.js.map +1 -0
- package/lib/types/file/fileName.d.ts +5 -0
- package/lib/types/file/fileName.js +9 -0
- package/lib/types/file/fileName.js.map +1 -0
- package/lib/types/file/filePath.d.ts +8 -0
- package/lib/types/file/filePath.js +11 -0
- package/lib/types/file/filePath.js.map +1 -0
- package/lib/types/portal/quickstart.d.ts +1 -1
- package/lib/types/portal/serve.d.ts +13 -0
- package/lib/types/portal/serve.js +2 -0
- package/lib/types/portal/serve.js.map +1 -0
- package/lib/utils/utils.d.ts +1 -4
- package/lib/utils/utils.js +10 -25
- package/lib/utils/utils.js.map +1 -1
- package/lib/validators/common/directoryValidator.d.ts +3 -7
- package/lib/validators/common/directoryValidator.js +10 -37
- package/lib/validators/common/directoryValidator.js.map +1 -1
- package/lib/validators/portal/serve-validator.d.ts +6 -0
- package/lib/validators/portal/serve-validator.js +15 -0
- package/lib/validators/portal/serve-validator.js.map +1 -0
- package/package.json +4 -3
- package/lib/actions/portal/generate.d.ts +0 -7
- package/lib/actions/portal/generate.js +0 -54
- package/lib/actions/portal/generate.js.map +0 -1
- package/lib/controllers/portal/generate.d.ts +0 -3
- package/lib/controllers/portal/generate.js +0 -106
- package/lib/controllers/portal/generate.js.map +0 -1
- package/lib/controllers/portal/serve.d.ts +0 -3
- package/lib/controllers/portal/serve.js +0 -136
- package/lib/controllers/portal/serve.js.map +0 -1
- package/lib/services/portal/server.d.ts +0 -14
- package/lib/services/portal/server.js +0 -97
- package/lib/services/portal/server.js.map +0 -1
- package/lib/validators/common/portValidator.d.ts +0 -5
- package/lib/validators/common/portValidator.js +0 -16
- package/lib/validators/common/portValidator.js.map +0 -1
- package/lib/validators/portal/serveValidator.d.ts +0 -6
- package/lib/validators/portal/serveValidator.js +0 -17
- package/lib/validators/portal/serveValidator.js.map +0 -1
|
@@ -2,42 +2,49 @@ import { Flags, Command } from "@oclif/core";
|
|
|
2
2
|
import { outro, password, text } from "@clack/prompts";
|
|
3
3
|
import { getMessageInRedColor, replaceHTML } from "../../utils/utils.js";
|
|
4
4
|
import { SDKClient } from "../../client-utils/sdk-client.js";
|
|
5
|
+
import { getAuthInfo } from "../../client-utils/auth-manager.js";
|
|
5
6
|
class Login extends Command {
|
|
6
7
|
async run() {
|
|
7
8
|
const { flags } = await this.parse(Login);
|
|
8
9
|
const configDir = this.config.configDir;
|
|
9
10
|
try {
|
|
11
|
+
// Check if already logged in
|
|
12
|
+
const storedAuthInfo = await getAuthInfo(configDir);
|
|
13
|
+
if (storedAuthInfo && storedAuthInfo.authKey) {
|
|
14
|
+
if (storedAuthInfo.email) {
|
|
15
|
+
return this.log(`You are already logged in as '${storedAuthInfo.email}'. Use 'auth:logout' to logout before logging in again.`);
|
|
16
|
+
}
|
|
17
|
+
return this.log(`You are already logged in with authentication key. Use 'auth:logout' to logout before logging in again.`);
|
|
18
|
+
}
|
|
10
19
|
const client = SDKClient.getInstance();
|
|
11
20
|
// If user is setting auth key
|
|
12
21
|
if (flags["auth-key"]) {
|
|
13
22
|
const response = client.setAuthKey(flags["auth-key"], configDir);
|
|
14
23
|
return this.log(response);
|
|
15
24
|
}
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
return getMessageInRedColor("Email is required.");
|
|
23
|
-
}
|
|
24
|
-
const emailRegex = /^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/;
|
|
25
|
-
if (!emailRegex.test(input)) {
|
|
26
|
-
return getMessageInRedColor("Please enter a valid email address.");
|
|
27
|
-
}
|
|
25
|
+
// If user logs in with email and password
|
|
26
|
+
const email = await text({
|
|
27
|
+
message: "Enter your registered email:",
|
|
28
|
+
validate: (input) => {
|
|
29
|
+
if (!input) {
|
|
30
|
+
return getMessageInRedColor("Email is required.");
|
|
28
31
|
}
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
validate: (input) => {
|
|
33
|
-
if (!input) {
|
|
34
|
-
return getMessageInRedColor("Password is required.");
|
|
35
|
-
}
|
|
32
|
+
const emailRegex = /^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/;
|
|
33
|
+
if (!emailRegex.test(input)) {
|
|
34
|
+
return getMessageInRedColor("Please enter a valid email address.");
|
|
36
35
|
}
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
const pass = await password({
|
|
39
|
+
message: "Please enter your password:",
|
|
40
|
+
validate: (input) => {
|
|
41
|
+
if (!input) {
|
|
42
|
+
return getMessageInRedColor("Password is required.");
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
const response = await client.login(email, pass, configDir);
|
|
47
|
+
outro(response);
|
|
41
48
|
}
|
|
42
49
|
catch (error) {
|
|
43
50
|
if (error && error.response) {
|
|
@@ -58,16 +65,7 @@ class Login extends Command {
|
|
|
58
65
|
}
|
|
59
66
|
}
|
|
60
67
|
Login.description = "Login using your APIMatic credentials or an API Key";
|
|
61
|
-
Login.examples = [
|
|
62
|
-
`$ apimatic auth:login
|
|
63
|
-
Enter your registered email: apimatic-user@gmail.com
|
|
64
|
-
Please enter your password: *********
|
|
65
|
-
|
|
66
|
-
You have successfully logged into APIMatic
|
|
67
|
-
`,
|
|
68
|
-
`$ apimatic auth:login --auth-key=xxxxxx
|
|
69
|
-
Authentication key successfully set`
|
|
70
|
-
];
|
|
68
|
+
Login.examples = [`$ apimatic auth:login`, `$ apimatic auth:login --auth-key=xxxxxx`];
|
|
71
69
|
Login.flags = {
|
|
72
70
|
"auth-key": Flags.string({ default: "", description: "Set authentication key for all commands" })
|
|
73
71
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"login.js","sourceRoot":"","sources":["../../../src/commands/auth/login.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AACvD,OAAO,EAAE,oBAAoB,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACzE,OAAO,EAAE,SAAS,EAAE,MAAM,kCAAkC,CAAC;
|
|
1
|
+
{"version":3,"file":"login.js","sourceRoot":"","sources":["../../../src/commands/auth/login.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AACvD,OAAO,EAAE,oBAAoB,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACzE,OAAO,EAAE,SAAS,EAAE,MAAM,kCAAkC,CAAC;AAC7D,OAAO,EAAE,WAAW,EAAE,MAAM,oCAAoC,CAAC;AAEjE,MAAqB,KAAM,SAAQ,OAAO;IASxC,KAAK,CAAC,GAAG;QACP,MAAM,E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C;eAPiB,KAAK"}
|
|
@@ -13,10 +13,6 @@ class Login extends Command {
|
|
|
13
13
|
}
|
|
14
14
|
}
|
|
15
15
|
Login.description = "Clear local login credentials";
|
|
16
|
-
Login.examples = [
|
|
17
|
-
`$ apimatic auth:logout
|
|
18
|
-
Logged out
|
|
19
|
-
`
|
|
20
|
-
];
|
|
16
|
+
Login.examples = [`$ apimatic auth:logout`];
|
|
21
17
|
export default Login;
|
|
22
18
|
//# sourceMappingURL=logout.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logout.js","sourceRoot":"","sources":["../../../src/commands/auth/logout.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAEtC,OAAO,EAAE,SAAS,EAAE,MAAM,kCAAkC,CAAC;AAE7D,MAAqB,KAAM,SAAQ,OAAO;
|
|
1
|
+
{"version":3,"file":"logout.js","sourceRoot":"","sources":["../../../src/commands/auth/logout.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAEtC,OAAO,EAAE,SAAS,EAAE,MAAM,kCAAkC,CAAC;AAE7D,MAAqB,KAAM,SAAQ,OAAO;IAKxC,KAAK,CAAC,GAAG;QACP,IAAI,CAAC;YACH,MAAM,MAAM,GAAG,SAAS,CAAC,WAAW,EAAE,CAAC;YACvC,MAAM,QAAQ,GAAG,MAAM,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;YAE5D,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;QACrB,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IAAI,CAAC,KAAK,CAAC,KAAe,CAAC,CAAC;QAC9B,CAAC;IACH,CAAC;;AAbM,iBAAW,GAAG,+BAA+B,CAAC;AAE9C,cAAQ,GAAG,CAAC,wBAAwB,CAAC,CAAC;eAH1B,KAAK"}
|
|
@@ -13,10 +13,6 @@ class Status extends Command {
|
|
|
13
13
|
}
|
|
14
14
|
}
|
|
15
15
|
Status.description = "View current authentication state";
|
|
16
|
-
Status.examples = [
|
|
17
|
-
`$ apimatic auth:status
|
|
18
|
-
Currently logged in as apimatic-client@gmail.com
|
|
19
|
-
`
|
|
20
|
-
];
|
|
16
|
+
Status.examples = [`$ apimatic auth:status`];
|
|
21
17
|
export default Status;
|
|
22
18
|
//# sourceMappingURL=status.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"status.js","sourceRoot":"","sources":["../../../src/commands/auth/status.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAEtC,OAAO,EAAE,SAAS,EAAE,MAAM,kCAAkC,CAAC;AAE7D,MAAqB,MAAO,SAAQ,OAAO;
|
|
1
|
+
{"version":3,"file":"status.js","sourceRoot":"","sources":["../../../src/commands/auth/status.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAEtC,OAAO,EAAE,SAAS,EAAE,MAAM,kCAAkC,CAAC;AAE7D,MAAqB,MAAO,SAAQ,OAAO;IAKzC,KAAK,CAAC,GAAG;QACP,IAAI,CAAC;YACH,MAAM,MAAM,GAAG,SAAS,CAAC,WAAW,EAAE,CAAC;YACvC,MAAM,QAAQ,GAAG,MAAM,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;YAE5D,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;QACrB,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IAAI,CAAC,KAAK,CAAC,KAAe,CAAC,CAAC;QAC9B,CAAC;IACH,CAAC;;AAbM,kBAAW,GAAG,mCAAmC,CAAC;AAElD,eAAQ,GAAG,CAAC,wBAAwB,CAAC,CAAC;eAH1B,MAAM"}
|
|
@@ -1,18 +1,16 @@
|
|
|
1
|
-
import { Command } from "@oclif/core";
|
|
2
|
-
export
|
|
1
|
+
import { Command, Config } from "@oclif/core";
|
|
2
|
+
export declare class PortalGenerate extends Command {
|
|
3
3
|
static description: string;
|
|
4
4
|
static flags: {
|
|
5
|
-
folder: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
6
|
-
destination: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
5
|
+
folder: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
6
|
+
destination: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
7
7
|
force: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
8
8
|
zip: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
9
|
-
"auth-key": import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
9
|
+
"auth-key": import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
10
10
|
};
|
|
11
11
|
static examples: string[];
|
|
12
12
|
private readonly prompts;
|
|
13
|
-
constructor(argv: string[], config:
|
|
13
|
+
constructor(argv: string[], config: Config);
|
|
14
14
|
run(): Promise<void>;
|
|
15
|
-
private
|
|
16
|
-
private validatePaths;
|
|
17
|
-
private checkExistingPortal;
|
|
15
|
+
private getConfigDir;
|
|
18
16
|
}
|
|
@@ -1,77 +1,33 @@
|
|
|
1
|
-
var _a;
|
|
2
|
-
import * as path from "path";
|
|
3
|
-
import fsExtra from "fs-extra";
|
|
4
1
|
import { Command, Flags } from "@oclif/core";
|
|
5
|
-
import {
|
|
2
|
+
import { DirectoryPath } from "../../types/file/directoryPath.js";
|
|
3
|
+
import { GeneratePortalAction } from "../../actions/portal/generatePortalAction.js";
|
|
6
4
|
import { PortalGeneratePrompts } from "../../prompts/portal/generate.js";
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
const DEFAULT_FOLDER = "./";
|
|
10
|
-
const DEFAULT_DESTINATION = path.resolve("./");
|
|
11
|
-
const GENERATED_PORTAL_ARTIFACTS_FOLDER = "generated_portal";
|
|
12
|
-
const GENERATED_PORTAL_ARTIFACTS_ZIP = ".generated_portal.zip";
|
|
13
|
-
class PortalGenerate extends Command {
|
|
5
|
+
const DEFAULT_WORKING_DIRECTORY = "./";
|
|
6
|
+
export class PortalGenerate extends Command {
|
|
14
7
|
constructor(argv, config) {
|
|
15
8
|
super(argv, config);
|
|
9
|
+
this.getConfigDir = () => {
|
|
10
|
+
return new DirectoryPath(this.config.configDir);
|
|
11
|
+
};
|
|
16
12
|
this.prompts = new PortalGeneratePrompts();
|
|
17
13
|
}
|
|
18
14
|
async run() {
|
|
19
|
-
const { flags } = await this.parse(
|
|
20
|
-
const
|
|
21
|
-
const
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
const validationResult = await this.validatePaths(paths);
|
|
27
|
-
if (validationResult.isFailed()) {
|
|
28
|
-
this.error(validationResult.error);
|
|
29
|
-
}
|
|
30
|
-
await portalGenerateAction.generatePortal(paths, flags, this.config.configDir);
|
|
31
|
-
}
|
|
32
|
-
async getPortalPaths(flags) {
|
|
33
|
-
return {
|
|
34
|
-
sourceFolderPath: flags.folder,
|
|
35
|
-
destinationFolderPath: flags.destination,
|
|
36
|
-
generatedPortalArtifactsFolderPath: path.join(flags.destination, GENERATED_PORTAL_ARTIFACTS_FOLDER),
|
|
37
|
-
generatedPortalArtifactsZipFilePath: path.join(flags.destination, GENERATED_PORTAL_ARTIFACTS_ZIP)
|
|
38
|
-
};
|
|
39
|
-
}
|
|
40
|
-
async validatePaths(paths) {
|
|
41
|
-
if (!(await fsExtra.pathExists(paths.sourceFolderPath))) {
|
|
42
|
-
return Result.failure(getMessageInRedColor(`Portal build input folder ${paths.sourceFolderPath} does not exist.`));
|
|
43
|
-
}
|
|
44
|
-
if (!(await fsExtra.pathExists(path.dirname(paths.generatedPortalArtifactsFolderPath)))) {
|
|
45
|
-
return Result.failure(getMessageInRedColor(`Destination path ${path.dirname(paths.generatedPortalArtifactsFolderPath)} does not exist.`));
|
|
46
|
-
}
|
|
47
|
-
return Result.success("Paths validated successfully.");
|
|
48
|
-
}
|
|
49
|
-
async checkExistingPortal(paths, flags) {
|
|
50
|
-
if (fsExtra.existsSync(paths.generatedPortalArtifactsFolderPath) && !flags.force && !flags.zip) {
|
|
51
|
-
if (!(await this.prompts.overwriteExistingPortalArtifactsPrompt())) {
|
|
52
|
-
return false;
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
else if (fsExtra.existsSync(paths.generatedPortalArtifactsZipFilePath) && !flags.force && flags.zip) {
|
|
56
|
-
if (!(await this.prompts.existingDestinationPortalZipPrompt())) {
|
|
57
|
-
return false;
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
return true;
|
|
15
|
+
const { flags: { folder, destination, force, zip: zipPortal, "auth-key": authKey } } = await this.parse(PortalGenerate);
|
|
16
|
+
const workingDirectory = new DirectoryPath(folder !== null && folder !== void 0 ? folder : DEFAULT_WORKING_DIRECTORY);
|
|
17
|
+
const buildDirectory = folder ? new DirectoryPath(folder, "build") : workingDirectory.join("build");
|
|
18
|
+
const portalDirectory = destination ? new DirectoryPath(destination) : workingDirectory.join("portal");
|
|
19
|
+
const action = new GeneratePortalAction(this.getConfigDir(), authKey);
|
|
20
|
+
const result = await action.execute(buildDirectory, portalDirectory, force, zipPortal);
|
|
21
|
+
result.mapAll(() => this.prompts.displayOutroMessage(portalDirectory.toString()), (message) => this.prompts.logError(message));
|
|
61
22
|
}
|
|
62
23
|
}
|
|
63
|
-
_a = PortalGenerate;
|
|
64
24
|
PortalGenerate.description = "Generate and download a static API Documentation portal. Requires an input directory containing API specifications, a config file and optionally, markdown guides. For details, refer to the [documentation](https://docs.apimatic.io/platform-api/#/http/guides/generating-on-prem-api-portal/build-file-reference)";
|
|
65
25
|
PortalGenerate.flags = {
|
|
66
26
|
folder: Flags.string({
|
|
67
|
-
|
|
68
|
-
default: DEFAULT_FOLDER,
|
|
69
|
-
description: "path to the input directory containing API specifications and config files"
|
|
27
|
+
description: "[default: ./] path to the parent directory containing the 'build' folder, which includes API specifications and configuration files."
|
|
70
28
|
}),
|
|
71
29
|
destination: Flags.string({
|
|
72
|
-
|
|
73
|
-
default: DEFAULT_DESTINATION,
|
|
74
|
-
description: "path to the downloaded portal"
|
|
30
|
+
description: "[default: <folder>/portal] path where the portal will be generated."
|
|
75
31
|
}),
|
|
76
32
|
force: Flags.boolean({
|
|
77
33
|
char: "f",
|
|
@@ -83,14 +39,8 @@ PortalGenerate.flags = {
|
|
|
83
39
|
description: "download the generated portal as a .zip archive"
|
|
84
40
|
}),
|
|
85
41
|
"auth-key": Flags.string({
|
|
86
|
-
default: "",
|
|
87
42
|
description: "override current authentication state with an authentication key"
|
|
88
43
|
})
|
|
89
44
|
};
|
|
90
|
-
PortalGenerate.examples = [
|
|
91
|
-
`$ apimatic portal:generate --folder="./portal/" --destination="D:/"
|
|
92
|
-
Your portal has been generated at D:/
|
|
93
|
-
`
|
|
94
|
-
];
|
|
95
|
-
export default PortalGenerate;
|
|
45
|
+
PortalGenerate.examples = [`$ apimatic portal:generate`, `$ apimatic portal:generate --folder="./" --destination="./portal"`];
|
|
96
46
|
//# sourceMappingURL=generate.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate.js","sourceRoot":"","sources":["../../../src/commands/portal/generate.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"generate.js","sourceRoot":"","sources":["../../../src/commands/portal/generate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAU,KAAK,EAAE,MAAM,aAAa,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,MAAM,mCAAmC,CAAC;AAClE,OAAO,EAAE,oBAAoB,EAAE,MAAM,8CAA8C,CAAC;AACpF,OAAO,EAAE,qBAAqB,EAAE,M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,OAAO,CAAC,mBAAmB,CAAC,eAAe,CAAC,QAAQ,EAAE,CAAC,EAClE,CAAC,OAAO,EAAE,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,CAC5C,CAAC;IACJ,CAAC;;AAjDM,0BAAW,GAChB,sTAAsT,AADtS,CACuS;AAElT,oBAAK,GAAG;IACb,MAAM,EAAE,KAAK,CAAC,MAAM,CAAC;QACnB,WAAW,EACT,sIAAsI;KACzI,CAAC;IACF,WAAW,EAAE,KAAK,CAAC,MAAM,CAAC;QACxB,WAAW,EAAE,qEAAqE;KACnF,CAAC;IACF,KAAK,EAAE,KAAK,CAAC,OAAO,CAAC;QACnB,IAAI,EAAE,GAAG;QACT,OAAO,EAAE,KAAK;QACd,WAAW,EAAE,iDAAiD;KAC/D,CAAC;IACF,GAAG,EAAE,KAAK,CAAC,OAAO,CAAC;QACjB,OAAO,EAAE,KAAK;QACd,WAAW,EAAE,iDAAiD;KAC/D,CAAC;IACF,UAAU,EAAE,KAAK,CAAC,MAAM,CAAC;QACvB,WAAW,EAAE,kEAAkE;KAChF,CAAC;CACH,AApBW,CAoBV;AAEK,uBAAQ,GAAG,CAAC,4BAA4B,EAAE,mEAAmE,CAAC,AAAtG,CAAuG"}
|
|
@@ -4,7 +4,7 @@ export default class PortalQuickstart extends Command {
|
|
|
4
4
|
static examples: string[];
|
|
5
5
|
private getSpecFile;
|
|
6
6
|
private getSpecValidationSummary;
|
|
7
|
-
private
|
|
8
|
-
private getGeneratedPortalPath;
|
|
7
|
+
private getWorkingDirectory;
|
|
9
8
|
run(): Promise<void>;
|
|
9
|
+
private getServerPort;
|
|
10
10
|
}
|
|
@@ -1,9 +1,16 @@
|
|
|
1
|
+
import getPort from "get-port";
|
|
1
2
|
import { Command } from "@oclif/core";
|
|
2
3
|
import { ApiValidationExternalApisController } from "@apimatic/sdk";
|
|
3
4
|
import { SDKClient } from "../../client-utils/sdk-client.js";
|
|
4
5
|
import { PortalQuickstartPrompts } from "../../prompts/portal/quickstart.js";
|
|
5
6
|
import { PortalQuickstartController } from "../../controllers/portal/quickstart.js";
|
|
6
7
|
import { getMessageInRedColor } from "../../utils/utils.js";
|
|
8
|
+
import { DirectoryPath } from "../../types/file/directoryPath.js";
|
|
9
|
+
import { PortalServeAction } from "../../actions/portal/serve.js";
|
|
10
|
+
import { ServeHandler } from "../../application/portal/serve/serve-handler.js";
|
|
11
|
+
import { PortalService } from "../../infrastructure/services/portal-service.js";
|
|
12
|
+
import { PortalServePrompts } from "../../prompts/portal/serve.js";
|
|
13
|
+
import { GeneratePortalAction } from "../../actions/portal/generatePortalAction.js";
|
|
7
14
|
class PortalQuickstart extends Command {
|
|
8
15
|
async getSpecFile(prompts, controller) {
|
|
9
16
|
const specPath = await prompts.specPrompt();
|
|
@@ -22,19 +29,14 @@ class PortalQuickstart extends Command {
|
|
|
22
29
|
}
|
|
23
30
|
return apiValidationSummary;
|
|
24
31
|
}
|
|
25
|
-
async
|
|
26
|
-
const
|
|
32
|
+
async getWorkingDirectory(prompts, controller, specFile, apiValidationSummary, languages) {
|
|
33
|
+
const workingDirectory = await prompts.workingDirectoryPrompt();
|
|
27
34
|
prompts.displayBuildDirectoryGenerationMessage();
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
prompts.
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
async getGeneratedPortalPath(prompts, controller, directory) {
|
|
34
|
-
prompts.displayPortalGenerationMessage();
|
|
35
|
-
const generatedPortalPath = await controller.generatePortalArtifacts(directory, this.config.configDir);
|
|
36
|
-
prompts.displayPortalGenerationSuccessMessage();
|
|
37
|
-
return generatedPortalPath;
|
|
35
|
+
const buildDirectory = new DirectoryPath(workingDirectory, "build").toString();
|
|
36
|
+
await controller.setupBuildDirectory(prompts, buildDirectory, specFile, apiValidationSummary, languages);
|
|
37
|
+
prompts.displayBuildDirectoryGenerationSuccessMessage(buildDirectory);
|
|
38
|
+
prompts.displayBuildDirectoryAsTree(buildDirectory);
|
|
39
|
+
return workingDirectory;
|
|
38
40
|
}
|
|
39
41
|
async run() {
|
|
40
42
|
const prompts = new PortalQuickstartPrompts();
|
|
@@ -49,7 +51,7 @@ class PortalQuickstart extends Command {
|
|
|
49
51
|
loggedIn = true;
|
|
50
52
|
prompts.displayLoggedInMessage();
|
|
51
53
|
}
|
|
52
|
-
catch (
|
|
54
|
+
catch (_a) {
|
|
53
55
|
prompts.displayLoggingInErrorMessage();
|
|
54
56
|
}
|
|
55
57
|
}
|
|
@@ -59,17 +61,47 @@ class PortalQuickstart extends Command {
|
|
|
59
61
|
const specFile = await this.getSpecFile(prompts, controller);
|
|
60
62
|
const apiValidationSummary = await this.getSpecValidationSummary(prompts, controller, specFile, apiValidationController);
|
|
61
63
|
const languages = await prompts.sdkLanguagesPrompt();
|
|
62
|
-
const
|
|
63
|
-
const
|
|
64
|
-
const
|
|
65
|
-
|
|
66
|
-
|
|
64
|
+
const workingDirectory = await this.getWorkingDirectory(prompts, controller, specFile, apiValidationSummary, languages);
|
|
65
|
+
const portalServePrompts = new PortalServePrompts();
|
|
66
|
+
const portalServeAction = new PortalServeAction(portalServePrompts, new ServeHandler(), new PortalService());
|
|
67
|
+
//TODO: This needs to be moved within the action. Port should not be initialized again here.
|
|
68
|
+
const port = await this.getServerPort(3000);
|
|
69
|
+
const buildDirectory = new DirectoryPath(workingDirectory, "build");
|
|
70
|
+
const portalDirectory = new DirectoryPath(workingDirectory, "portal");
|
|
71
|
+
const generatePortalAction = new GeneratePortalAction(new DirectoryPath(this.config.configDir), null);
|
|
72
|
+
const serveFlags = {
|
|
73
|
+
folder: buildDirectory.toString(),
|
|
74
|
+
destination: portalDirectory.toString(),
|
|
75
|
+
port: port,
|
|
76
|
+
open: true,
|
|
77
|
+
"no-reload": false,
|
|
78
|
+
ignore: "",
|
|
79
|
+
"auth-key": undefined
|
|
80
|
+
};
|
|
81
|
+
const serverPaths = {
|
|
82
|
+
sourceDirectoryPath: buildDirectory.toString(),
|
|
83
|
+
destinationDirectoryPath: portalDirectory.toString()
|
|
84
|
+
};
|
|
85
|
+
const servePortalResult = await portalServeAction.servePortal(serveFlags, serverPaths, generatePortalAction.execute);
|
|
86
|
+
if (servePortalResult.isFailed()) {
|
|
87
|
+
portalServePrompts.logError(getMessageInRedColor(servePortalResult.error));
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
if (servePortalResult.isCancelled()) {
|
|
91
|
+
portalServePrompts.logError(getMessageInRedColor(servePortalResult.value));
|
|
92
|
+
return;
|
|
67
93
|
}
|
|
94
|
+
prompts.displayOutroMessage(buildDirectory.toString());
|
|
68
95
|
}
|
|
69
96
|
catch (error) {
|
|
70
97
|
this.error(getMessageInRedColor(error instanceof Error ? error.message : String(error)));
|
|
71
98
|
}
|
|
72
99
|
}
|
|
100
|
+
async getServerPort(port) {
|
|
101
|
+
const defaultPorts = [3000, 3001, 3002];
|
|
102
|
+
const preferredPorts = typeof port === "number" ? [port, ...defaultPorts.filter((p) => p !== port)] : defaultPorts;
|
|
103
|
+
return await getPort({ port: preferredPorts });
|
|
104
|
+
}
|
|
73
105
|
}
|
|
74
106
|
PortalQuickstart.description = "Create your first API Portal using APIMatic's Docs as Code offering.";
|
|
75
107
|
PortalQuickstart.examples = ["$ apimatic portal:quickstart"];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"quickstart.js","sourceRoot":"","sources":["../../../src/commands/portal/quickstart.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AACtC,OAAO,EAAE,mCAAmC,EAAgC,MAAM,eAAe,CAAC;AAClG,OAAO,EAAE,SAAS,EAAE,MAAM,kCAAkC,CAAC;AAC7D,OAAO,EAAE,uBAAuB,EAAE,MAAM,oCAAoC,CAAC;AAC7E,OAAO,EAAE,0BAA0B,EAAE,MAAM,wCAAwC,CAAC;AAEpF,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"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C,CAAC,CAAC,CAAC;QAC3F,CAAC;IACH,CAAC;IAEO,KAAK,CAAC,aAAa,CAAC,IAAwB;QAClD,MAAM,YAAY,GAAG,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;QAExC,MAAM,cAAc,GAAG,OAAO,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,GAAG,YAAY,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC;QAEnH,OAAO,MAAM,OAAO,CAAC,EAAE,IAAI,EAAE,cAAc,EAAE,CAAC,CAAC;IACjD,CAAC;;AA9JM,4BAAW,GAAG,sEAAsE,CAAC;AAErF,yBAAQ,GAAG,CAAC,8BAA8B,CAAC,CAAC;eAHhC,gBAAgB"}
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import { Command } from "@oclif/core";
|
|
2
|
-
export default class
|
|
2
|
+
export default class PortalRecipeNew extends Command {
|
|
3
3
|
static summary: string;
|
|
4
4
|
static description: string;
|
|
5
5
|
static examples: string[];
|
|
6
6
|
static flags: {
|
|
7
7
|
name: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
8
|
-
folder: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
9
|
-
"build-config": import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
8
|
+
folder: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
10
9
|
};
|
|
11
10
|
run(): Promise<void>;
|
|
12
11
|
}
|
|
@@ -1,16 +1,18 @@
|
|
|
1
|
-
var _a;
|
|
2
|
-
import * as path from "path";
|
|
3
1
|
import { Command, Flags } from "@oclif/core";
|
|
4
2
|
import { PortalRecipeAction } from "../../../actions/portal/recipe/new-recipe.js";
|
|
5
3
|
import { PortalRecipePrompts } from "../../../prompts/portal/recipe/new-recipe.js";
|
|
6
4
|
import { getMessageInRedColor } from "../../../utils/utils.js";
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
import { DirectoryPath } from "../../../types/file/directoryPath.js";
|
|
6
|
+
const DEFAULT_WORKING_DIRECTORY = "./";
|
|
7
|
+
class PortalRecipeNew extends Command {
|
|
9
8
|
async run() {
|
|
10
|
-
|
|
9
|
+
var _a;
|
|
10
|
+
const { flags } = await this.parse(PortalRecipeNew);
|
|
11
11
|
const portalRecipeAction = new PortalRecipeAction();
|
|
12
12
|
const portalRecipePrompts = new PortalRecipePrompts();
|
|
13
|
-
const
|
|
13
|
+
const workingDirectory = new DirectoryPath((_a = flags.folder) !== null && _a !== void 0 ? _a : DEFAULT_WORKING_DIRECTORY);
|
|
14
|
+
const buildDirectory = flags.folder ? new DirectoryPath(flags.folder, "build") : workingDirectory.join("build");
|
|
15
|
+
const createRecipeResult = await portalRecipeAction.createRecipe(buildDirectory, this.config.configDir, flags.name);
|
|
14
16
|
if (createRecipeResult.isFailed()) {
|
|
15
17
|
portalRecipePrompts.logError(getMessageInRedColor(createRecipeResult.error));
|
|
16
18
|
}
|
|
@@ -19,26 +21,17 @@ class PortalNewRecipe extends Command {
|
|
|
19
21
|
}
|
|
20
22
|
}
|
|
21
23
|
}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
`$ apimatic portal:recipe:new --name="My API Recipe" --folder="./build-folder"
|
|
27
|
-
Generated recipe has been added to build directory at: C:/build-folder/`,
|
|
28
|
-
`$ apimatic portal:recipe:new
|
|
29
|
-
Generated recipe has been added to build directory at: C:/`
|
|
24
|
+
PortalRecipeNew.summary = "Generate an API Recipe for a static API Documentation portal.";
|
|
25
|
+
PortalRecipeNew.description = "To learn more about API Recipes, visit: https://docs.apimatic.io/platform-api/#/http/guides/generating-on-prem-api-portal/api-recipes";
|
|
26
|
+
PortalRecipeNew.examples = [
|
|
27
|
+
`$ apimatic portal:recipe:new`,
|
|
28
|
+
`$ apimatic portal:recipe:new --name="My API Recipe" --folder="./build-folder"`
|
|
30
29
|
];
|
|
31
|
-
|
|
30
|
+
PortalRecipeNew.flags = {
|
|
32
31
|
name: Flags.string({ description: "name for the recipe" }),
|
|
33
32
|
folder: Flags.string({
|
|
34
|
-
|
|
35
|
-
description: "path to the build directory containing the specs folder, content folder, and the build config file. Defaults to the current working directory if not provided.",
|
|
36
|
-
default: DEFAULT_FOLDER
|
|
37
|
-
}),
|
|
38
|
-
"build-config": Flags.string({
|
|
39
|
-
parse: async (input) => path.resolve(input),
|
|
40
|
-
description: "path to the APIMATIC-BUILD.json file. Defaults to the APIMATIC-BUILD.json file in the build directory if not provided."
|
|
33
|
+
description: "[default: ./] Path to the parent directory containing the 'build' folder, which includes API specifications and configuration files."
|
|
41
34
|
})
|
|
42
35
|
};
|
|
43
|
-
export default
|
|
36
|
+
export default PortalRecipeNew;
|
|
44
37
|
//# sourceMappingURL=new.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"new.js","sourceRoot":"","sources":["../../../../src/commands/portal/recipe/new.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"new.js","sourceRoot":"","sources":["../../../../src/commands/portal/recipe/new.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,kBAAkB,EAAE,MAAM,8CAA8C,CAAC;AAClF,OAAO,EAAE,mBAAmB,EAAE,MAAM,8CAA8C,CAAC;AACnF,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAC/D,OAAO,EAAE,aAAa,EAAE,MAAM,sCAAsC,CAAC;AAErE,MAAM,yBAAyB,GAAG,IAAI,CAAC;AAEvC,MAAqB,eAAgB,SAAQ,OAAO;IAkB3C,KAAK,CAAC,GAAG;;QACd,MAAM,EAAE,K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
|
@@ -1,16 +1,18 @@
|
|
|
1
|
-
import { Command } from "@oclif/core";
|
|
1
|
+
import { Command, Config } from "@oclif/core";
|
|
2
2
|
export default class PortalServe extends Command {
|
|
3
3
|
static description: string;
|
|
4
4
|
static flags: {
|
|
5
|
-
port: import("@oclif/core/interfaces").OptionFlag<number, import("@oclif/core/interfaces").CustomOptions>;
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
port: import("@oclif/core/interfaces").OptionFlag<number | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
6
|
+
folder: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
7
|
+
destination: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
8
8
|
open: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
9
9
|
"no-reload": import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
10
10
|
ignore: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
11
11
|
"auth-key": import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
12
12
|
};
|
|
13
|
+
private readonly prompts;
|
|
14
|
+
constructor(argv: string[], config: Config);
|
|
13
15
|
static examples: string[];
|
|
14
16
|
run(): Promise<void>;
|
|
15
|
-
private
|
|
17
|
+
private getServerPort;
|
|
16
18
|
}
|