forked from aws/aws-sdk-js-v3
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
147 lines (135 loc) · 4.8 KB
/
index.js
File metadata and controls
147 lines (135 loc) · 4.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
// @ts-check
const yargs = require("yargs");
const path = require("path");
const { emptyDirSync, rmdirSync } = require("fs-extra");
const { generateClients, generateGenericClient, generateProtocolTests } = require("./code-gen");
const { codeOrdering } = require("./code-ordering");
const { copyToClients, copyServerTests } = require("./copy-to-clients");
const {
CODE_GEN_SDK_OUTPUT_DIR,
CODE_GEN_GENERIC_CLIENT_OUTPUT_DIR,
CODE_GEN_PROTOCOL_TESTS_OUTPUT_DIR,
DEFAULT_CODE_GEN_INPUT_DIR,
TEMP_CODE_GEN_INPUT_DIR,
} = require("./code-gen-dir");
const { eslintFixCode } = require("./code-eslint-fix");
const { buildSmithyTypeScript } = require("./build-smithy-typescript");
const { SMITHY_TS_COMMIT } = require("./config");
const SMITHY_TS_DIR = path.normalize(path.join(__dirname, "..", "..", "..", "smithy-typescript"));
const SDK_CLIENTS_DIR = path.normalize(path.join(__dirname, "..", "..", "clients"));
const PRIVATE_CLIENTS_DIR = path.normalize(path.join(__dirname, "..", "..", "private"));
const {
models,
globs,
output: clientsDir,
noPrivateClients,
s: serverOnly,
batchSize,
keepFiles,
repo,
commit,
d: noSmithyCheckout,
p: protocolTestsOnly,
} = yargs(process.argv.slice(2))
.alias("m", "models")
.string("m")
.describe("m", "The path to directory with models.")
.alias("g", "globs")
.array("g")
.describe("g", "A list of smithy model globs")
.conflicts("models", "globs") //either models(path) or globs is accepted
.alias("o", "output")
.string("o")
.describe("o", "The output directory for built clients")
.default("o", SDK_CLIENTS_DIR)
.alias("n", "noPrivateClients")
.boolean("n")
.describe("n", "Disable generating private clients")
.alias("d", "noSmithyCheckout")
.boolean("d")
.describe("d", "use existing Smithy version instead of target hash")
.alias("p", "protocolTestsOnly")
.boolean("p")
.describe("p", "Generate protocol tests only")
.alias("s", "server-artifacts")
.boolean("s")
.describe("s", "Generate server artifacts instead of client ones")
.boolean("keepFiles")
.describe("keepFiles", "Don't clean up temp files")
.conflicts("s", ["m", "g", "n"])
.describe("b", "Batchsize for generating clients")
.number("b")
.alias("b", "batch-size")
.default("b", 50)
.describe("r", "The location where smithy-typescript is cloned.")
.string("r")
.alias("r", "repo")
.default("r", SMITHY_TS_DIR)
.describe("c", "The smithy-typescript commit to be used for codegen.")
.string("c")
.alias("c", "commit")
.default("c", SMITHY_TS_COMMIT)
.help().argv;
(async () => {
const { prettifyCode } = await import("./code-prettify.mjs");
try {
if (!noSmithyCheckout) {
await buildSmithyTypeScript(repo, commit);
}
if (serverOnly === true) {
await generateProtocolTests();
await eslintFixCode();
await prettifyCode(CODE_GEN_PROTOCOL_TESTS_OUTPUT_DIR);
await copyServerTests(CODE_GEN_PROTOCOL_TESTS_OUTPUT_DIR, PRIVATE_CLIENTS_DIR);
if (!keepFiles) {
emptyDirSync(CODE_GEN_PROTOCOL_TESTS_OUTPUT_DIR);
emptyDirSync(TEMP_CODE_GEN_INPUT_DIR);
rmdirSync(TEMP_CODE_GEN_INPUT_DIR);
}
return;
}
if (!protocolTestsOnly) {
await generateClients(models || globs || DEFAULT_CODE_GEN_INPUT_DIR, batchSize);
}
if (!noPrivateClients) {
await generateGenericClient();
await generateProtocolTests();
}
await eslintFixCode();
if (!protocolTestsOnly) {
await codeOrdering(CODE_GEN_SDK_OUTPUT_DIR);
await prettifyCode(CODE_GEN_SDK_OUTPUT_DIR);
}
if (!noPrivateClients) {
await codeOrdering(CODE_GEN_GENERIC_CLIENT_OUTPUT_DIR);
await prettifyCode(CODE_GEN_GENERIC_CLIENT_OUTPUT_DIR);
await prettifyCode(CODE_GEN_PROTOCOL_TESTS_OUTPUT_DIR);
}
if (!protocolTestsOnly) {
await copyToClients(CODE_GEN_SDK_OUTPUT_DIR, clientsDir);
}
if (!noPrivateClients) {
await copyToClients(CODE_GEN_GENERIC_CLIENT_OUTPUT_DIR, PRIVATE_CLIENTS_DIR);
await copyToClients(CODE_GEN_PROTOCOL_TESTS_OUTPUT_DIR, PRIVATE_CLIENTS_DIR);
await copyServerTests(CODE_GEN_PROTOCOL_TESTS_OUTPUT_DIR, PRIVATE_CLIENTS_DIR);
}
require("../api-examples/get-examples");
await require("../api-examples/merge-examples").merge();
const compress = require("../endpoints-ruleset/compress");
compress();
if (!keepFiles) {
emptyDirSync(CODE_GEN_SDK_OUTPUT_DIR);
if (!noPrivateClients) {
emptyDirSync(CODE_GEN_GENERIC_CLIENT_OUTPUT_DIR);
emptyDirSync(CODE_GEN_PROTOCOL_TESTS_OUTPUT_DIR);
}
emptyDirSync(TEMP_CODE_GEN_INPUT_DIR);
rmdirSync(TEMP_CODE_GEN_INPUT_DIR);
}
require("./customizations/workspaces-thin-client")();
require("../runtime-dependency-version-check/runtime-dep-version-check");
} catch (e) {
console.log(e);
process.exit(1);
}
})();