@awsless/cli 0.0.45 → 0.0.46-next.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.
- package/dist/app.json +1 -1
- package/dist/app.stage.json +1 -1
- package/dist/bin.js +4410 -4215
- package/dist/build-json-schema.js +272 -447
- package/dist/handlers/bundle.mjs +534 -0
- package/dist/handlers/icon.mjs +104 -0
- package/dist/handlers/image.mjs +136 -0
- package/dist/handlers/on-error-log.mjs +177 -0
- package/dist/handlers/on-failure.mjs +138 -0
- package/dist/handlers/pubsub-publisher.mjs +43 -0
- package/dist/handlers/pubsub-server.mjs +63196 -0
- package/dist/handlers/rpc.mjs +465 -0
- package/dist/stack.json +1 -1
- package/dist/stack.stage.json +1 -1
- package/dist/test-global-setup.js +1 -0
- package/package.json +18 -24
- package/dist/prebuild/icon/HASH +0 -1
- package/dist/prebuild/icon/bundle.zip +0 -0
- package/dist/prebuild/image/HASH +0 -1
- package/dist/prebuild/image/bundle.zip +0 -0
- package/dist/prebuild/on-error-log/HASH +0 -1
- package/dist/prebuild/on-error-log/bundle.zip +0 -0
- package/dist/prebuild/on-failure/HASH +0 -1
- package/dist/prebuild/on-failure/bundle.zip +0 -0
- package/dist/prebuild/pubsub-publisher/HASH +0 -1
- package/dist/prebuild/pubsub-publisher/bundle.zip +0 -0
- package/dist/prebuild/pubsub-server/HASH +0 -1
- package/dist/prebuild/pubsub-server/index.mjs +0 -236
- package/dist/prebuild/rpc/HASH +0 -1
- package/dist/prebuild/rpc/bundle.zip +0 -0
- package/dist/prebuild.js +0 -192
package/dist/prebuild/rpc/HASH
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
f38809250d79b61a8f7c1d54fc37f82eaaa3e4eb
|
|
Binary file
|
package/dist/prebuild.js
DELETED
|
@@ -1,192 +0,0 @@
|
|
|
1
|
-
// src/prebuild.ts
|
|
2
|
-
import { mkdir } from "fs/promises";
|
|
3
|
-
import { join as join2 } from "path";
|
|
4
|
-
|
|
5
|
-
// src/feature/function/prebuild.ts
|
|
6
|
-
import { days, seconds, toDays, toSeconds } from "@awsless/duration";
|
|
7
|
-
import { mebibytes, toMebibytes } from "@awsless/size";
|
|
8
|
-
import { aws } from "@terraforge/aws";
|
|
9
|
-
import { Output, findInputDeps, resolveInputs } from "@terraforge/core";
|
|
10
|
-
import { writeFile } from "fs/promises";
|
|
11
|
-
import { join } from "path";
|
|
12
|
-
|
|
13
|
-
// src/feature/function/build/typescript/rolldown.ts
|
|
14
|
-
import { createHash } from "crypto";
|
|
15
|
-
import { Minimatch } from "minimatch";
|
|
16
|
-
import { rolldown } from "rolldown";
|
|
17
|
-
import { importAsString } from "rollup-plugin-string-import";
|
|
18
|
-
|
|
19
|
-
// src/cli/ui/style.ts
|
|
20
|
-
import chalk from "chalk";
|
|
21
|
-
var color = {
|
|
22
|
-
primary: chalk.bold.hex("#FF9000"),
|
|
23
|
-
// primary: chalk.bold.magentaBright,
|
|
24
|
-
// title: chalk.white,
|
|
25
|
-
normal: chalk.reset.white,
|
|
26
|
-
label: chalk.reset.white.bold,
|
|
27
|
-
dim: chalk.dim,
|
|
28
|
-
line: chalk.black,
|
|
29
|
-
// link: chalk.cyan,
|
|
30
|
-
info: chalk.blue,
|
|
31
|
-
success: chalk.green,
|
|
32
|
-
warning: chalk.yellow,
|
|
33
|
-
error: chalk.red,
|
|
34
|
-
attr: chalk.yellow
|
|
35
|
-
// cursor: chalk.bgWhite.blackBright,
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
// src/cli/debug.ts
|
|
39
|
-
var queue = [];
|
|
40
|
-
var debugError = (error) => {
|
|
41
|
-
queue.push({
|
|
42
|
-
date: /* @__PURE__ */ new Date(),
|
|
43
|
-
type: color.error.dim("error"),
|
|
44
|
-
message: typeof error === "string" ? error : error instanceof Error ? color.error(error.message || "") : JSON.stringify(error)
|
|
45
|
-
});
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
// src/feature/function/build/typescript/rolldown.ts
|
|
49
|
-
var createModuleMatcher = (patterns = []) => {
|
|
50
|
-
const globs = patterns.map((pattern) => {
|
|
51
|
-
return new Minimatch(pattern.replaceAll("\\", "/"), { dot: true });
|
|
52
|
-
});
|
|
53
|
-
return (id) => {
|
|
54
|
-
const path = id.replaceAll("\\", "/");
|
|
55
|
-
return globs.some((glob) => glob.match(path));
|
|
56
|
-
};
|
|
57
|
-
};
|
|
58
|
-
var bundleTypeScriptWithRolldown = async ({
|
|
59
|
-
format = "esm",
|
|
60
|
-
minify = true,
|
|
61
|
-
file,
|
|
62
|
-
nativeDir,
|
|
63
|
-
external,
|
|
64
|
-
moduleSideEffects,
|
|
65
|
-
externalAwsSdk = true,
|
|
66
|
-
codeSplitting = true,
|
|
67
|
-
importAsString: importAsStringList
|
|
68
|
-
}) => {
|
|
69
|
-
const hasModuleSideEffects = createModuleMatcher(moduleSideEffects);
|
|
70
|
-
const bundle = await rolldown({
|
|
71
|
-
input: file,
|
|
72
|
-
platform: "node",
|
|
73
|
-
external: (importee) => {
|
|
74
|
-
return externalAwsSdk && (importee.startsWith("@aws-sdk") || importee.startsWith("aws-sdk")) || external?.includes(importee);
|
|
75
|
-
},
|
|
76
|
-
onwarn: (error) => {
|
|
77
|
-
debugError(error.message);
|
|
78
|
-
},
|
|
79
|
-
treeshake: {
|
|
80
|
-
moduleSideEffects: (id) => file === id || hasModuleSideEffects(id)
|
|
81
|
-
},
|
|
82
|
-
plugins: [
|
|
83
|
-
// nodeResolve({ preferBuiltins: true }),
|
|
84
|
-
// nativeDir
|
|
85
|
-
// ? natives({
|
|
86
|
-
// copyTo: nativeDir,
|
|
87
|
-
// targetEsm: format === 'esm',
|
|
88
|
-
// sourcemap: true,
|
|
89
|
-
// })
|
|
90
|
-
// : undefined,
|
|
91
|
-
importAsStringList ? importAsString({
|
|
92
|
-
include: importAsStringList
|
|
93
|
-
}) : void 0
|
|
94
|
-
]
|
|
95
|
-
});
|
|
96
|
-
const ext = format === "esm" ? "mjs" : "js";
|
|
97
|
-
const result = await bundle.generate({
|
|
98
|
-
format,
|
|
99
|
-
sourcemap: "hidden",
|
|
100
|
-
exports: "auto",
|
|
101
|
-
entryFileNames: `index.${ext}`,
|
|
102
|
-
chunkFileNames: `[name].${ext}`,
|
|
103
|
-
codeSplitting,
|
|
104
|
-
minify
|
|
105
|
-
});
|
|
106
|
-
const hash = createHash("sha1");
|
|
107
|
-
const files = [];
|
|
108
|
-
for (const item of result.output) {
|
|
109
|
-
if (item.type !== "chunk") {
|
|
110
|
-
continue;
|
|
111
|
-
}
|
|
112
|
-
const code = Buffer.from(item.code, "utf8");
|
|
113
|
-
const map = item.map ? Buffer.from(item.map.toString(), "utf8") : void 0;
|
|
114
|
-
hash.update(code);
|
|
115
|
-
files.push({
|
|
116
|
-
name: item.fileName,
|
|
117
|
-
code,
|
|
118
|
-
map
|
|
119
|
-
});
|
|
120
|
-
}
|
|
121
|
-
return {
|
|
122
|
-
hash: hash.digest("hex"),
|
|
123
|
-
files
|
|
124
|
-
};
|
|
125
|
-
};
|
|
126
|
-
|
|
127
|
-
// src/feature/function/build/zip.ts
|
|
128
|
-
import { createReadStream } from "fs";
|
|
129
|
-
import JSZip from "jszip";
|
|
130
|
-
var zipFiles = (files) => {
|
|
131
|
-
const zip = new JSZip();
|
|
132
|
-
for (const file of files) {
|
|
133
|
-
if ("path" in file) {
|
|
134
|
-
zip.file(file.name, createReadStream(file.path));
|
|
135
|
-
} else {
|
|
136
|
-
zip.file(file.name, file.code);
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
return zip.generateAsync({
|
|
140
|
-
type: "nodebuffer",
|
|
141
|
-
compression: "DEFLATE",
|
|
142
|
-
compressionOptions: {
|
|
143
|
-
level: 9
|
|
144
|
-
}
|
|
145
|
-
});
|
|
146
|
-
};
|
|
147
|
-
|
|
148
|
-
// src/feature/function/prebuild.ts
|
|
149
|
-
var prebuild = async (file, output, external = []) => {
|
|
150
|
-
const bundle = await bundleTypeScriptWithRolldown({
|
|
151
|
-
file,
|
|
152
|
-
minify: true,
|
|
153
|
-
external
|
|
154
|
-
});
|
|
155
|
-
const archive = await zipFiles(bundle.files);
|
|
156
|
-
await writeFile(join(output, "HASH"), bundle.hash);
|
|
157
|
-
await writeFile(join(output, "bundle.zip"), archive);
|
|
158
|
-
};
|
|
159
|
-
var prebuildBundle = async (file, output) => {
|
|
160
|
-
const bundle = await bundleTypeScriptWithRolldown({
|
|
161
|
-
file,
|
|
162
|
-
minify: true,
|
|
163
|
-
externalAwsSdk: false,
|
|
164
|
-
codeSplitting: false
|
|
165
|
-
});
|
|
166
|
-
await Promise.all(bundle.files.map((item) => writeFile(join(output, item.name), item.code)));
|
|
167
|
-
await writeFile(join(output, "HASH"), bundle.hash);
|
|
168
|
-
};
|
|
169
|
-
|
|
170
|
-
// src/prebuild.ts
|
|
171
|
-
var cwd = join2(process.cwd(), "./dist");
|
|
172
|
-
var builds = {
|
|
173
|
-
rpc: "../src/feature/rpc/server/handle.ts",
|
|
174
|
-
image: "../src/feature/image/server/handle.ts",
|
|
175
|
-
icon: "../src/feature/icon/server/handle.ts",
|
|
176
|
-
"on-failure": "../src/feature/on-failure/server/handle.ts",
|
|
177
|
-
"on-error-log": "../src/feature/on-error-log/server/handle.ts",
|
|
178
|
-
"pubsub-publisher": "../src/feature/pubsub/publisher/handle.ts"
|
|
179
|
-
};
|
|
180
|
-
for (const [name, file] of Object.entries(builds)) {
|
|
181
|
-
const output = join2(cwd, "prebuild", name);
|
|
182
|
-
await mkdir(output, { recursive: true });
|
|
183
|
-
await prebuild(join2(cwd, file), output, ["sharp"]);
|
|
184
|
-
}
|
|
185
|
-
var bundles = {
|
|
186
|
-
"pubsub-server": "../src/feature/pubsub/server/index.ts"
|
|
187
|
-
};
|
|
188
|
-
for (const [name, file] of Object.entries(bundles)) {
|
|
189
|
-
const output = join2(cwd, "prebuild", name);
|
|
190
|
-
await mkdir(output, { recursive: true });
|
|
191
|
-
await prebuildBundle(join2(cwd, file), output);
|
|
192
|
-
}
|