wirejs-deploy-amplify-basic 0.1.157-llm → 0.1.158-llm
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.
|
@@ -4,7 +4,11 @@ import {
|
|
|
4
4
|
defineBackend,
|
|
5
5
|
} from '@aws-amplify/backend';
|
|
6
6
|
import { Duration, RemovalPolicy, NestedStack } from "aws-cdk-lib";
|
|
7
|
-
import {
|
|
7
|
+
import {
|
|
8
|
+
FunctionUrlAuthType,
|
|
9
|
+
IFunction,
|
|
10
|
+
Runtime,
|
|
11
|
+
} from 'aws-cdk-lib/aws-lambda';
|
|
8
12
|
import { NodejsFunction, OutputFormat } from 'aws-cdk-lib/aws-lambda-nodejs';
|
|
9
13
|
import { Bucket, BlockPublicAccess } from 'aws-cdk-lib/aws-s3';
|
|
10
14
|
import { Table, AttributeType, BillingMode } from 'aws-cdk-lib/aws-dynamodb';
|
|
@@ -17,6 +21,8 @@ import { auth } from './auth/resource';
|
|
|
17
21
|
|
|
18
22
|
// @ts-ignore
|
|
19
23
|
import generatedResources from './generated-resources';
|
|
24
|
+
import { copyFileSync } from 'fs';
|
|
25
|
+
import { cwd } from 'process';
|
|
20
26
|
|
|
21
27
|
const __filename = import.meta.url.replace(/^file:/, '');
|
|
22
28
|
const __dirname = path.dirname(__filename);
|
|
@@ -38,20 +44,29 @@ const SELF_INVOCATION_ID = randomUUID();
|
|
|
38
44
|
*/
|
|
39
45
|
const backend = defineBackend({ auth });
|
|
40
46
|
|
|
47
|
+
// const api = new Function(backend.stack, 'ApiHandler', {
|
|
48
|
+
// runtime: Runtime.NODEJS_22_X,
|
|
49
|
+
// memorySize: 2 * 1024,
|
|
50
|
+
// handler: 'handler.handler',
|
|
51
|
+
// code: Code.fromAsset(path.join(__dirname, 'api')),
|
|
52
|
+
// timeout: Duration.minutes(15),
|
|
53
|
+
// });
|
|
54
|
+
|
|
55
|
+
copyFileSync(
|
|
56
|
+
path.join(__dirname, 'api', 'handler.ts'),
|
|
57
|
+
path.join(cwd(), 'api', 'wirejs-handler.ts')
|
|
58
|
+
);
|
|
59
|
+
|
|
41
60
|
const api = new NodejsFunction(backend.stack, 'ApiHandler', {
|
|
42
61
|
runtime: Runtime.NODEJS_22_X,
|
|
43
62
|
memorySize: 2 * 1024,
|
|
44
63
|
handler: 'handler',
|
|
45
|
-
entry: path.join(
|
|
64
|
+
entry: path.join(cwd(), 'api', 'wirejs-handler.ts'),
|
|
46
65
|
bundling: {
|
|
47
|
-
|
|
48
|
-
format: OutputFormat.ESM
|
|
49
|
-
nodeModules: [
|
|
50
|
-
'jsdom',
|
|
51
|
-
],
|
|
66
|
+
nodeModules: ['jsdom'],
|
|
67
|
+
format: OutputFormat.ESM
|
|
52
68
|
},
|
|
53
|
-
depsLockFilePath: path.join(
|
|
54
|
-
timeout: Duration.minutes(15),
|
|
69
|
+
depsLockFilePath: path.join(cwd(), 'package-lock.json')
|
|
55
70
|
});
|
|
56
71
|
|
|
57
72
|
/**
|
package/build.js
CHANGED
|
@@ -5,15 +5,19 @@ import path from 'path';
|
|
|
5
5
|
import fs from 'fs';
|
|
6
6
|
import { rimraf } from 'rimraf';
|
|
7
7
|
import copy from 'recursive-copy';
|
|
8
|
-
import { execSync } from 'child_process';
|
|
8
|
+
import { exec, execSync } from 'child_process';
|
|
9
|
+
import { buildSync } from 'esbuild';
|
|
10
|
+
import { randomUUID } from 'crypto';
|
|
9
11
|
|
|
10
12
|
const CWD = process.cwd();
|
|
11
13
|
const __filename = import.meta.url.replace(/^file:/, '');
|
|
14
|
+
|
|
15
|
+
const TEMP_ID = randomUUID();
|
|
12
16
|
const SELF_DIR = path.dirname(__filename);
|
|
13
|
-
const TEMP_DIR = path.join(SELF_DIR, 'temp');
|
|
14
17
|
const PROJECT_API_DIR = path.join(CWD, 'api');
|
|
15
18
|
const PROJECT_DIST_DIR = path.join(CWD, 'dist');
|
|
16
19
|
const BACKEND_DIR = path.join(CWD, 'amplify');
|
|
20
|
+
const LAMBDA_BUILD_DIR = path.join(CWD, `lambda-${TEMP_ID}`);
|
|
17
21
|
const HOSTING_DIR = path.join(CWD, '.amplify-hosting');
|
|
18
22
|
const STATIC_DIR = path.join(HOSTING_DIR, 'static');
|
|
19
23
|
const COMPUTE_DIR = path.join(HOSTING_DIR, 'compute', 'default');
|
|
@@ -30,16 +34,17 @@ async function createSkeleton() {
|
|
|
30
34
|
await fs.promises.mkdir(HOSTING_DIR, { recursive: true });
|
|
31
35
|
await fs.promises.mkdir(STATIC_DIR, { recursive: true });
|
|
32
36
|
await fs.promises.mkdir(COMPUTE_DIR, { recursive: true });
|
|
37
|
+
await fs.promises.mkdir(LAMBDA_BUILD_DIR, { recursive: true });
|
|
33
38
|
|
|
34
39
|
// skeleton for backend assets
|
|
35
|
-
await copy(path.join(SELF_DIR, 'amplify-backend-assets'),
|
|
36
|
-
|
|
40
|
+
await copy(path.join(SELF_DIR, 'amplify-backend-assets'), BACKEND_DIR);
|
|
41
|
+
|
|
37
42
|
// skeleton for hosting assets
|
|
38
|
-
await copy(path.join(SELF_DIR, 'amplify-hosting-assets'),
|
|
43
|
+
await copy(path.join(SELF_DIR, 'amplify-hosting-assets'), HOSTING_DIR);
|
|
39
44
|
console.log("done creating deployment directories")
|
|
40
45
|
|
|
41
46
|
console.log("installing SSR server deps");
|
|
42
|
-
execSync(`npm install --prefix ${COMPUTE_DIR}
|
|
47
|
+
execSync(`npm install --prefix ${COMPUTE_DIR}`)
|
|
43
48
|
}
|
|
44
49
|
|
|
45
50
|
/**
|
|
@@ -54,7 +59,6 @@ async function installDeps() {
|
|
|
54
59
|
...{
|
|
55
60
|
'@aws-amplify/backend': '^1.14.0',
|
|
56
61
|
'@aws-amplify/backend-cli': '^1.4.8',
|
|
57
|
-
"@aws-sdk/client-dynamodb": "^3.799.0",
|
|
58
62
|
'aws-cdk': '^2.177.0',
|
|
59
63
|
'aws-cdk-lib': '^2.177.0',
|
|
60
64
|
'constructs': '^10.4.2',
|
|
@@ -101,6 +105,64 @@ async function discoverResources() {
|
|
|
101
105
|
);
|
|
102
106
|
}
|
|
103
107
|
|
|
108
|
+
// /**
|
|
109
|
+
// *
|
|
110
|
+
// * @returns {string[]}
|
|
111
|
+
// */
|
|
112
|
+
// function discoverApiDeps() {
|
|
113
|
+
// return execSync(`npm ls --omit=dev --all --parseable -w ./api`)
|
|
114
|
+
// .toString()
|
|
115
|
+
// .split('\n')
|
|
116
|
+
// .map(line => line.trim())
|
|
117
|
+
// .filter(line => line.includes('node_modules'));
|
|
118
|
+
// }
|
|
119
|
+
|
|
120
|
+
// async function installApiDeps() {
|
|
121
|
+
// console.log("adding deps to package.json");
|
|
122
|
+
// // add deps used by Amplify to deploy backend
|
|
123
|
+
// const packageData = JSON.parse(
|
|
124
|
+
// await fs.promises.readFile(path.join(LAMBDA_BUILD_DIR, 'package.json'))
|
|
125
|
+
// );
|
|
126
|
+
// packageData.dependencies = {
|
|
127
|
+
// 'jose': '^6.1.0',
|
|
128
|
+
// ...(packageData.dependencies || {}),
|
|
129
|
+
// 'wirejs-resources': `file:${SELF_DIR}`
|
|
130
|
+
// };
|
|
131
|
+
// await fs.promises.writeFile(
|
|
132
|
+
// path.join(LAMBDA_BUILD_DIR, 'package.json'),
|
|
133
|
+
// JSON.stringify(packageData, null, 2)
|
|
134
|
+
// );
|
|
135
|
+
|
|
136
|
+
// console.log("installing all deps")
|
|
137
|
+
|
|
138
|
+
// // install all
|
|
139
|
+
// execSync('npm i');
|
|
140
|
+
|
|
141
|
+
// console.log("done installing deps");
|
|
142
|
+
// }
|
|
143
|
+
|
|
144
|
+
// /**
|
|
145
|
+
// *
|
|
146
|
+
// * @param {string[]} deps
|
|
147
|
+
// */
|
|
148
|
+
// async function prepareApiLambda(deps) {
|
|
149
|
+
// await copy
|
|
150
|
+
// (path.join(CWD, 'api', 'dist'),
|
|
151
|
+
// path.join(LAMBDA_BUILD_DIR, 'dist')
|
|
152
|
+
// );
|
|
153
|
+
// await copy(
|
|
154
|
+
// path.join(CWD, 'api', 'dist', 'package.json'),
|
|
155
|
+
// path.join(LAMBDA_BUILD_DIR, 'dist', 'package.json')
|
|
156
|
+
// );
|
|
157
|
+
|
|
158
|
+
// buildSync({
|
|
159
|
+
// entryPoints: path.join(LAMBDA_BUILD_DIR, 'handler.ts'),
|
|
160
|
+
// bundle: true,
|
|
161
|
+
// packages: 'external',
|
|
162
|
+
// outfile: 'handler.js',
|
|
163
|
+
// });
|
|
164
|
+
// }
|
|
165
|
+
|
|
104
166
|
async function deployFrontend() {
|
|
105
167
|
console.log("copying frontend assets");
|
|
106
168
|
await copy(PROJECT_DIST_DIR, STATIC_DIR);
|
|
@@ -132,6 +194,7 @@ if (action === 'prebuild') {
|
|
|
132
194
|
await createSkeleton();
|
|
133
195
|
await installDeps();
|
|
134
196
|
await discoverResources();
|
|
197
|
+
// await prepareApiLambda(discoverApiDeps());
|
|
135
198
|
|
|
136
199
|
console.log("prebuild done");
|
|
137
200
|
} else if (action === 'inject-backend') {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "wirejs-deploy-amplify-basic",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.158-llm",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
"recursive-copy": "^2.0.14",
|
|
45
45
|
"rimraf": "^6.0.1",
|
|
46
46
|
"wirejs-dom": "^1.0.44",
|
|
47
|
-
"wirejs-resources": "^0.1.
|
|
47
|
+
"wirejs-resources": "^0.1.158-llm"
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|
|
50
50
|
"@aws-amplify/backend": "^1.14.0",
|