@awsless/cli 0.0.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.
Files changed (50) hide show
  1. package/README.MD +487 -0
  2. package/dist/app.json +1 -0
  3. package/dist/app.stage.json +1 -0
  4. package/dist/bin.d.ts +1 -0
  5. package/dist/bin.js +49025 -0
  6. package/dist/build-json-schema.js +1925 -0
  7. package/dist/chunk-2TBBLACH.js +37 -0
  8. package/dist/chunk-3YEPERYO.js +1021 -0
  9. package/dist/chunk-4JFIJMQ6.js +46 -0
  10. package/dist/chunk-5TWBDDXS.js +60 -0
  11. package/dist/chunk-7NRPMOO4.js +876 -0
  12. package/dist/chunk-7XIGSOF4.js +100 -0
  13. package/dist/chunk-DSXFE5X2.js +174 -0
  14. package/dist/chunk-E7FQOYML.js +12 -0
  15. package/dist/chunk-GH475CSF.js +5005 -0
  16. package/dist/chunk-JHYKYQ5P.js +163 -0
  17. package/dist/chunk-LBISIOIM.js +28 -0
  18. package/dist/chunk-RCNT4C4P.js +50 -0
  19. package/dist/chunk-SIAA4J6H.js +21 -0
  20. package/dist/chunk-XNYTWFP6.js +241 -0
  21. package/dist/chunk-Z37AK4IA.js +546 -0
  22. package/dist/chunk-ZKH7AMP3.js +42 -0
  23. package/dist/dist-es-GXHCNXAC.js +489 -0
  24. package/dist/dist-es-J7SL4PXO.js +88 -0
  25. package/dist/dist-es-LL3VAI2X.js +70 -0
  26. package/dist/dist-es-QND3CYLI.js +380 -0
  27. package/dist/dist-es-STVZUSZG.js +21 -0
  28. package/dist/dist-es-TCFHB4OF.js +324 -0
  29. package/dist/dist-es-YFQTZTNE.js +167 -0
  30. package/dist/event-streams-74K5M656.js +244 -0
  31. package/dist/layers/sharp-arm.zip +0 -0
  32. package/dist/loadSso-O7PM54HL.js +592 -0
  33. package/dist/prebuild/icon/HASH +1 -0
  34. package/dist/prebuild/icon/bundle.zip +0 -0
  35. package/dist/prebuild/image/HASH +1 -0
  36. package/dist/prebuild/image/bundle.zip +0 -0
  37. package/dist/prebuild/on-error-log/HASH +1 -0
  38. package/dist/prebuild/on-error-log/bundle.zip +0 -0
  39. package/dist/prebuild/on-failure/HASH +1 -0
  40. package/dist/prebuild/on-failure/bundle.zip +0 -0
  41. package/dist/prebuild/rpc/HASH +1 -0
  42. package/dist/prebuild/rpc/bundle.zip +0 -0
  43. package/dist/prebuild.js +159 -0
  44. package/dist/signin-6SPMGGJN.js +704 -0
  45. package/dist/sso-oidc-5IIWGKXY.js +829 -0
  46. package/dist/stack.json +1 -0
  47. package/dist/stack.stage.json +1 -0
  48. package/dist/sts-6SQWH4BL.js +3788 -0
  49. package/dist/test-global-setup.js +22 -0
  50. package/package.json +120 -0
@@ -0,0 +1,159 @@
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 { pascalCase } from "change-case";
11
+ import { writeFile } from "fs/promises";
12
+ import { join } from "path";
13
+
14
+ // src/feature/function/build/typescript/rolldown.ts
15
+ import { createHash } from "crypto";
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 bundleTypeScriptWithRolldown = async ({
50
+ format = "esm",
51
+ minify = true,
52
+ file,
53
+ nativeDir,
54
+ external,
55
+ importAsString: importAsStringList
56
+ }) => {
57
+ const bundle = await rolldown({
58
+ input: file,
59
+ platform: "node",
60
+ external: (importee) => {
61
+ return importee.startsWith("@aws-sdk") || importee.startsWith("aws-sdk") || external?.includes(importee);
62
+ },
63
+ onwarn: (error) => {
64
+ debugError(error.message);
65
+ },
66
+ treeshake: {
67
+ moduleSideEffects: (id) => file === id
68
+ },
69
+ plugins: [
70
+ // nodeResolve({ preferBuiltins: true }),
71
+ // nativeDir
72
+ // ? natives({
73
+ // copyTo: nativeDir,
74
+ // targetEsm: format === 'esm',
75
+ // sourcemap: true,
76
+ // })
77
+ // : undefined,
78
+ importAsStringList ? importAsString({
79
+ include: importAsStringList
80
+ }) : void 0
81
+ ]
82
+ });
83
+ const ext = format === "esm" ? "mjs" : "js";
84
+ const result = await bundle.generate({
85
+ format,
86
+ sourcemap: "hidden",
87
+ exports: "auto",
88
+ entryFileNames: `index.${ext}`,
89
+ chunkFileNames: `[name].${ext}`,
90
+ minify
91
+ });
92
+ const hash = createHash("sha1");
93
+ const files = [];
94
+ for (const item of result.output) {
95
+ if (item.type !== "chunk") {
96
+ continue;
97
+ }
98
+ const code = Buffer.from(item.code, "utf8");
99
+ const map = item.map ? Buffer.from(item.map.toString(), "utf8") : void 0;
100
+ hash.update(code);
101
+ files.push({
102
+ name: item.fileName,
103
+ code,
104
+ map
105
+ });
106
+ }
107
+ return {
108
+ hash: hash.digest("hex"),
109
+ files
110
+ };
111
+ };
112
+
113
+ // src/feature/function/build/zip.ts
114
+ import { createReadStream } from "fs";
115
+ import JSZip from "jszip";
116
+ var zipFiles = (files) => {
117
+ const zip = new JSZip();
118
+ for (const file of files) {
119
+ if ("path" in file) {
120
+ zip.file(file.name, createReadStream(file.path));
121
+ } else {
122
+ zip.file(file.name, file.code);
123
+ }
124
+ }
125
+ return zip.generateAsync({
126
+ type: "nodebuffer",
127
+ compression: "DEFLATE",
128
+ compressionOptions: {
129
+ level: 9
130
+ }
131
+ });
132
+ };
133
+
134
+ // src/feature/function/prebuild.ts
135
+ var prebuild = async (file, output, external = []) => {
136
+ const bundle = await bundleTypeScriptWithRolldown({
137
+ file,
138
+ minify: true,
139
+ external
140
+ });
141
+ const archive = await zipFiles(bundle.files);
142
+ await writeFile(join(output, "HASH"), bundle.hash);
143
+ await writeFile(join(output, "bundle.zip"), archive);
144
+ };
145
+
146
+ // src/prebuild.ts
147
+ var cwd = join2(process.cwd(), "./dist");
148
+ var builds = {
149
+ rpc: "../src/feature/rpc/server/handle.ts",
150
+ image: "../src/feature/image/server/handle.ts",
151
+ icon: "../src/feature/icon/server/handle.ts",
152
+ "on-failure": "../src/feature/on-failure/server/handle.ts",
153
+ "on-error-log": "../src/feature/on-error-log/server/handle.ts"
154
+ };
155
+ for (const [name, file] of Object.entries(builds)) {
156
+ const output = join2(cwd, "prebuild", name);
157
+ await mkdir(output, { recursive: true });
158
+ await prebuild(join2(cwd, file), output, ["sharp"]);
159
+ }