wirejs-deploy-amplify-basic 0.1.157-llm → 0.1.159-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,12 +5,14 @@ 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
|
+
|
|
12
15
|
const SELF_DIR = path.dirname(__filename);
|
|
13
|
-
const TEMP_DIR = path.join(SELF_DIR, 'temp');
|
|
14
16
|
const PROJECT_API_DIR = path.join(CWD, 'api');
|
|
15
17
|
const PROJECT_DIST_DIR = path.join(CWD, 'dist');
|
|
16
18
|
const BACKEND_DIR = path.join(CWD, 'amplify');
|
|
@@ -32,14 +34,14 @@ async function createSkeleton() {
|
|
|
32
34
|
await fs.promises.mkdir(COMPUTE_DIR, { recursive: true });
|
|
33
35
|
|
|
34
36
|
// skeleton for backend assets
|
|
35
|
-
await copy(path.join(SELF_DIR, 'amplify-backend-assets'),
|
|
36
|
-
|
|
37
|
+
await copy(path.join(SELF_DIR, 'amplify-backend-assets'), BACKEND_DIR);
|
|
38
|
+
|
|
37
39
|
// skeleton for hosting assets
|
|
38
|
-
await copy(path.join(SELF_DIR, 'amplify-hosting-assets'),
|
|
40
|
+
await copy(path.join(SELF_DIR, 'amplify-hosting-assets'), HOSTING_DIR);
|
|
39
41
|
console.log("done creating deployment directories")
|
|
40
42
|
|
|
41
43
|
console.log("installing SSR server deps");
|
|
42
|
-
execSync(`npm install --prefix ${COMPUTE_DIR}
|
|
44
|
+
execSync(`npm install --prefix ${COMPUTE_DIR}`)
|
|
43
45
|
}
|
|
44
46
|
|
|
45
47
|
/**
|
|
@@ -54,7 +56,7 @@ async function installDeps() {
|
|
|
54
56
|
...{
|
|
55
57
|
'@aws-amplify/backend': '^1.14.0',
|
|
56
58
|
'@aws-amplify/backend-cli': '^1.4.8',
|
|
57
|
-
"@aws-sdk/client-dynamodb": "^3.
|
|
59
|
+
"@aws-sdk/client-dynamodb": "^3.774.0", // for GSI handler
|
|
58
60
|
'aws-cdk': '^2.177.0',
|
|
59
61
|
'aws-cdk-lib': '^2.177.0',
|
|
60
62
|
'constructs': '^10.4.2',
|
|
@@ -101,6 +103,64 @@ async function discoverResources() {
|
|
|
101
103
|
);
|
|
102
104
|
}
|
|
103
105
|
|
|
106
|
+
// /**
|
|
107
|
+
// *
|
|
108
|
+
// * @returns {string[]}
|
|
109
|
+
// */
|
|
110
|
+
// function discoverApiDeps() {
|
|
111
|
+
// return execSync(`npm ls --omit=dev --all --parseable -w ./api`)
|
|
112
|
+
// .toString()
|
|
113
|
+
// .split('\n')
|
|
114
|
+
// .map(line => line.trim())
|
|
115
|
+
// .filter(line => line.includes('node_modules'));
|
|
116
|
+
// }
|
|
117
|
+
|
|
118
|
+
// async function installApiDeps() {
|
|
119
|
+
// console.log("adding deps to package.json");
|
|
120
|
+
// // add deps used by Amplify to deploy backend
|
|
121
|
+
// const packageData = JSON.parse(
|
|
122
|
+
// await fs.promises.readFile(path.join(LAMBDA_BUILD_DIR, 'package.json'))
|
|
123
|
+
// );
|
|
124
|
+
// packageData.dependencies = {
|
|
125
|
+
// 'jose': '^6.1.0',
|
|
126
|
+
// ...(packageData.dependencies || {}),
|
|
127
|
+
// 'wirejs-resources': `file:${SELF_DIR}`
|
|
128
|
+
// };
|
|
129
|
+
// await fs.promises.writeFile(
|
|
130
|
+
// path.join(LAMBDA_BUILD_DIR, 'package.json'),
|
|
131
|
+
// JSON.stringify(packageData, null, 2)
|
|
132
|
+
// );
|
|
133
|
+
|
|
134
|
+
// console.log("installing all deps")
|
|
135
|
+
|
|
136
|
+
// // install all
|
|
137
|
+
// execSync('npm i');
|
|
138
|
+
|
|
139
|
+
// console.log("done installing deps");
|
|
140
|
+
// }
|
|
141
|
+
|
|
142
|
+
// /**
|
|
143
|
+
// *
|
|
144
|
+
// * @param {string[]} deps
|
|
145
|
+
// */
|
|
146
|
+
// async function prepareApiLambda(deps) {
|
|
147
|
+
// await copy
|
|
148
|
+
// (path.join(CWD, 'api', 'dist'),
|
|
149
|
+
// path.join(LAMBDA_BUILD_DIR, 'dist')
|
|
150
|
+
// );
|
|
151
|
+
// await copy(
|
|
152
|
+
// path.join(CWD, 'api', 'dist', 'package.json'),
|
|
153
|
+
// path.join(LAMBDA_BUILD_DIR, 'dist', 'package.json')
|
|
154
|
+
// );
|
|
155
|
+
|
|
156
|
+
// buildSync({
|
|
157
|
+
// entryPoints: path.join(LAMBDA_BUILD_DIR, 'handler.ts'),
|
|
158
|
+
// bundle: true,
|
|
159
|
+
// packages: 'external',
|
|
160
|
+
// outfile: 'handler.js',
|
|
161
|
+
// });
|
|
162
|
+
// }
|
|
163
|
+
|
|
104
164
|
async function deployFrontend() {
|
|
105
165
|
console.log("copying frontend assets");
|
|
106
166
|
await copy(PROJECT_DIST_DIR, STATIC_DIR);
|
|
@@ -132,6 +192,7 @@ if (action === 'prebuild') {
|
|
|
132
192
|
await createSkeleton();
|
|
133
193
|
await installDeps();
|
|
134
194
|
await discoverResources();
|
|
195
|
+
// await prepareApiLambda(discoverApiDeps());
|
|
135
196
|
|
|
136
197
|
console.log("prebuild done");
|
|
137
198
|
} 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.159-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.159-llm"
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|
|
50
50
|
"@aws-amplify/backend": "^1.14.0",
|