@phila/cli 0.0.11 → 0.0.13
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/README.md +6 -6
- package/dist/commands/config.d.ts +2 -0
- package/dist/commands/config.d.ts.map +1 -1
- package/dist/commands/config.js.map +1 -1
- package/dist/commands/deploy.d.ts +8 -2
- package/dist/commands/deploy.d.ts.map +1 -1
- package/dist/commands/deploy.js +30 -10
- package/dist/commands/deploy.js.map +1 -1
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/init.js +40 -4
- package/dist/commands/init.js.map +1 -1
- package/dist/commands/ship.js +2 -2
- package/dist/commands/ship.js.map +1 -1
- package/dist/commands/validate.d.ts.map +1 -1
- package/dist/commands/validate.js +17 -7
- package/dist/commands/validate.js.map +1 -1
- package/dist/templates/_shared/city.config.json.tmpl +1 -0
- package/dist/templates/_shared/webapp-cdk-package.json.tmpl +0 -3
- package/dist/templates/lambda-api-nodejs/README.md.tmpl +5 -5
- package/dist/templates/lambda-api-nodejs/apps/__lambdaName__/index.ts +1 -1
- package/dist/templates/lambda-api-nodejs/apps/__lambdaName__/package.json +2 -2
- package/dist/templates/lambda-api-nodejs/cdk/app.ts.tmpl +2 -2
- package/dist/templates/lambda-api-nodejs/cdk/cdk.json +1 -1
- package/dist/templates/lambda-api-nodejs/cdk/package.json +0 -3
- package/dist/templates/lambda-api-nodejs/package.json.tmpl +3 -0
- package/dist/templates/lambda-dynamo-api/README.md.tmpl +5 -5
- package/dist/templates/lambda-dynamo-api/apps/__lambdaName__/index.ts +1 -1
- package/dist/templates/lambda-dynamo-api/apps/__lambdaName__/package.json +2 -2
- package/dist/templates/lambda-dynamo-api/cdk/app.ts.tmpl +2 -2
- package/dist/templates/lambda-dynamo-api/cdk/cdk.json +3 -8
- package/dist/templates/lambda-dynamo-api/cdk/package.json +0 -3
- package/dist/templates/lambda-dynamo-api/package.json.tmpl +3 -0
- package/dist/templates/lambda-postgres-api/README.md.tmpl +6 -6
- package/dist/templates/lambda-postgres-api/apps/__lambdaName__/index.ts +1 -1
- package/dist/templates/lambda-postgres-api/apps/__lambdaName__/package.json +2 -2
- package/dist/templates/lambda-postgres-api/cdk/app.ts.tmpl +2 -2
- package/dist/templates/lambda-postgres-api/cdk/cdk.json +1 -1
- package/dist/templates/lambda-postgres-api/cdk/package.json +0 -3
- package/dist/templates/lambda-postgres-api/package.json.tmpl +3 -0
- package/dist/templates/static-site/README.md.tmpl +2 -2
- package/dist/templates/static-site/cdk/app.ts.tmpl +2 -2
- package/dist/templates/static-site/cdk/cdk.json +1 -1
- package/dist/templates/static-site/cdk/package.json +0 -3
- package/dist/templates/static-site/frontend/README.md +4 -4
- package/dist/templates/static-site/frontend/build.js +42 -0
- package/dist/templates/static-site/package.json.tmpl +4 -1
- package/dist/templates/webapp-ecs-dotnet/README.md.tmpl +4 -4
- package/dist/templates/webapp-ecs-dotnet/cdk/app.ts.tmpl +3 -4
- package/dist/templates/webapp-ecs-dotnet/cdk/cdk.json +1 -1
- package/dist/templates/webapp-ecs-dotnet/package.json.tmpl +6 -3
- package/dist/templates/webapp-ecs-node/README.md.tmpl +7 -7
- package/dist/templates/webapp-ecs-node/apps/api/Dockerfile +5 -5
- package/dist/templates/webapp-ecs-node/cdk/app.ts.tmpl +3 -4
- package/dist/templates/webapp-ecs-node/cdk/cdk.json +1 -1
- package/dist/templates/webapp-ecs-node/package.json.tmpl +7 -4
- package/dist/templates/webapp-ecs-postgres-dotnet/README.md.tmpl +5 -5
- package/dist/templates/webapp-ecs-postgres-dotnet/cdk/app.ts.tmpl +3 -4
- package/dist/templates/webapp-ecs-postgres-dotnet/cdk/cdk.json +1 -1
- package/dist/templates/webapp-ecs-postgres-dotnet/package.json.tmpl +6 -3
- package/dist/templates/webapp-ecs-postgres-node/README.md.tmpl +8 -8
- package/dist/templates/webapp-ecs-postgres-node/apps/api/Dockerfile +5 -5
- package/dist/templates/webapp-ecs-postgres-node/cdk/app.ts.tmpl +3 -4
- package/dist/templates/webapp-ecs-postgres-node/cdk/cdk.json +1 -1
- package/dist/templates/webapp-ecs-postgres-node/package.json.tmpl +7 -4
- package/dist/templates/webapp-lambda-dotnet/README.md.tmpl +4 -4
- package/dist/templates/webapp-lambda-dotnet/cdk/app.ts.tmpl +3 -4
- package/dist/templates/webapp-lambda-dotnet/cdk/cdk.json +1 -1
- package/dist/templates/webapp-lambda-dotnet/package.json.tmpl +6 -3
- package/dist/templates/webapp-lambda-dynamo-dotnet/README.md.tmpl +4 -4
- package/dist/templates/webapp-lambda-dynamo-dotnet/cdk/app.ts.tmpl +3 -4
- package/dist/templates/webapp-lambda-dynamo-dotnet/cdk/cdk.json +1 -1
- package/dist/templates/webapp-lambda-dynamo-dotnet/package.json.tmpl +6 -3
- package/dist/templates/webapp-lambda-dynamo-node/README.md.tmpl +6 -6
- package/dist/templates/webapp-lambda-dynamo-node/apps/api/index.ts +1 -1
- package/dist/templates/webapp-lambda-dynamo-node/cdk/app.ts.tmpl +3 -4
- package/dist/templates/webapp-lambda-dynamo-node/cdk/cdk.json +1 -1
- package/dist/templates/webapp-lambda-dynamo-node/package.json.tmpl +6 -3
- package/dist/templates/webapp-lambda-node/README.md.tmpl +5 -5
- package/dist/templates/webapp-lambda-node/apps/api/index.ts +1 -1
- package/dist/templates/webapp-lambda-node/cdk/app.ts.tmpl +3 -4
- package/dist/templates/webapp-lambda-node/cdk/cdk.json +1 -1
- package/dist/templates/webapp-lambda-node/package.json.tmpl +6 -3
- package/dist/templates/webapp-lambda-postgres-dotnet/README.md.tmpl +5 -5
- package/dist/templates/webapp-lambda-postgres-dotnet/cdk/app.ts.tmpl +3 -4
- package/dist/templates/webapp-lambda-postgres-dotnet/cdk/cdk.json +1 -1
- package/dist/templates/webapp-lambda-postgres-dotnet/package.json.tmpl +6 -3
- package/dist/templates/webapp-lambda-postgres-node/README.md.tmpl +7 -7
- package/dist/templates/webapp-lambda-postgres-node/apps/api/index.ts +1 -1
- package/dist/templates/webapp-lambda-postgres-node/cdk/app.ts.tmpl +3 -4
- package/dist/templates/webapp-lambda-postgres-node/cdk/cdk.json +1 -1
- package/dist/templates/webapp-lambda-postgres-node/package.json.tmpl +6 -3
- package/dist/utils/install-env.d.ts +1 -1
- package/dist/utils/install-env.js +6 -6
- package/dist/utils/install-env.js.map +1 -1
- package/dist/utils/package-manager.d.ts +34 -2
- package/dist/utils/package-manager.d.ts.map +1 -1
- package/dist/utils/package-manager.js +102 -15
- package/dist/utils/package-manager.js.map +1 -1
- package/dist/utils/template.d.ts +7 -0
- package/dist/utils/template.d.ts.map +1 -1
- package/dist/utils/template.js +8 -1
- package/dist/utils/template.js.map +1 -1
- package/package.json +1 -1
|
@@ -57,15 +57,15 @@ function getSynthEnvironment(config, requestedEnv) {
|
|
|
57
57
|
if (requestedEnv && isValidEnvironment(requestedEnv)) {
|
|
58
58
|
const envConfig = envs[requestedEnv];
|
|
59
59
|
if (envConfig)
|
|
60
|
-
return { env: requestedEnv, vpc: envConfig.vpc };
|
|
60
|
+
return { env: requestedEnv, vpc: envConfig.vpc, profile: envConfig.profile };
|
|
61
61
|
return null;
|
|
62
62
|
}
|
|
63
63
|
if (envs.dev)
|
|
64
|
-
return { env: 'dev', vpc: envs.dev.vpc };
|
|
64
|
+
return { env: 'dev', vpc: envs.dev.vpc, profile: envs.dev.profile };
|
|
65
65
|
if (envs.test)
|
|
66
|
-
return { env: 'test', vpc: envs.test.vpc };
|
|
66
|
+
return { env: 'test', vpc: envs.test.vpc, profile: envs.test.profile };
|
|
67
67
|
if (envs.prod)
|
|
68
|
-
return { env: 'prod', vpc: envs.prod.vpc };
|
|
68
|
+
return { env: 'prod', vpc: envs.prod.vpc, profile: envs.prod.profile };
|
|
69
69
|
return null;
|
|
70
70
|
}
|
|
71
71
|
async function validateCommand(environment) {
|
|
@@ -94,8 +94,17 @@ async function validateCommand(environment) {
|
|
|
94
94
|
process.exit(1);
|
|
95
95
|
}
|
|
96
96
|
const projectDir = process.cwd();
|
|
97
|
-
const pm = (0, package_manager_1.
|
|
97
|
+
const pm = (0, package_manager_1.resolvePackageManager)(config, projectDir);
|
|
98
|
+
const { profile } = synthContext;
|
|
99
|
+
const safePattern = /^[a-zA-Z0-9_-]+$/;
|
|
100
|
+
if (!safePattern.test(profile)) {
|
|
101
|
+
console.log(chalk_1.default.red(`\nError: Invalid profile name '${profile}'.`));
|
|
102
|
+
console.log(chalk_1.default.gray('Profile names must contain only letters, numbers, hyphens, and underscores.\n'));
|
|
103
|
+
process.exit(1);
|
|
104
|
+
}
|
|
98
105
|
console.log(chalk_1.default.blue('\nValidating project (install, build, cdk synth)...\n'));
|
|
106
|
+
console.log(chalk_1.default.gray(`Using AWS profile: ${profile}\n`));
|
|
107
|
+
await (0, deploy_1.ensureSsoLogin)(profile);
|
|
99
108
|
console.log(chalk_1.default.gray('Installing dependencies...\n'));
|
|
100
109
|
const installEnv = await (0, install_env_1.prepareInstallEnv)(projectDir);
|
|
101
110
|
try {
|
|
@@ -106,15 +115,16 @@ async function validateCommand(environment) {
|
|
|
106
115
|
console.log(chalk_1.default.red('\nError: Install failed.\n'));
|
|
107
116
|
process.exit(1);
|
|
108
117
|
}
|
|
109
|
-
await (0, deploy_1.buildProject)(config);
|
|
118
|
+
await (0, deploy_1.buildProject)(config, pm);
|
|
110
119
|
const cdkDir = path.resolve(projectDir, config.cdkPath);
|
|
111
120
|
const compliance = config.compliance || [];
|
|
112
121
|
const complianceArg = compliance.length > 0 ? ` -c compliance=${compliance.join(',')}` : '';
|
|
113
|
-
const contextArgs = ` -c environment=${synthContext.env} -c vpc=${synthContext.vpc}${complianceArg}`;
|
|
122
|
+
const contextArgs = ` -c environment=${synthContext.env} -c vpc=${synthContext.vpc}${complianceArg} --profile ${profile}`;
|
|
114
123
|
console.log(chalk_1.default.gray('Running cdk synth...\n'));
|
|
115
124
|
try {
|
|
116
125
|
const cdkCmd = (0, package_manager_1.getCdkCommand)(pm);
|
|
117
126
|
const cmd = `${cdkCmd} synth${contextArgs}`;
|
|
127
|
+
console.log(chalk_1.default.gray(`Running: cd ${cdkDir} && ${cmd}\n`));
|
|
118
128
|
(0, child_process_1.execSync)(cmd, { cwd: cdkDir, stdio: 'inherit' });
|
|
119
129
|
console.log(chalk_1.default.green('\n✓ Validate complete. Project is ready for deployment.\n'));
|
|
120
130
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validate.js","sourceRoot":"","sources":["../../src/commands/validate.ts"],"names":[],"mappings":";AAAA,gDAAgD;AAChD,wFAAwF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmCxF,
|
|
1
|
+
{"version":3,"file":"validate.js","sourceRoot":"","sources":["../../src/commands/validate.ts"],"names":[],"mappings":";AAAA,gDAAgD;AAChD,wFAAwF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmCxF,0CAgFC;AAjHD,2CAA6B;AAC7B,kDAA0B;AAC1B,iDAAyC;AACzC,qCAAsC;AAEtC,wDAA2D;AAC3D,qCAAwD;AACxD,sDAAyD;AACzD,8DAAmG;AAInG,SAAS,kBAAkB,CAAC,GAAW;IACrC,OAAO,GAAG,KAAK,KAAK,IAAI,GAAG,KAAK,MAAM,IAAI,GAAG,KAAK,MAAM,CAAC;AAC3D,CAAC;AAED,SAAS,mBAAmB,CAC1B,MAAkB,EAClB,YAAqB;IAErB,MAAM,IAAI,GAAG,MAAM,CAAC,YAAY,CAAC;IACjC,IAAI,CAAC,IAAI;QAAE,OAAO,IAAI,CAAC;IACvB,IAAI,YAAY,IAAI,kBAAkB,CAAC,YAAY,CAAC,EAAE,CAAC;QACrD,MAAM,SAAS,GAAG,IAAI,CAAC,YAAY,CAAC,CAAC;QACrC,IAAI,SAAS;YAAE,OAAO,EAAE,GAAG,EAAE,YAAY,EAAE,GAAG,EAAE,SAAS,CAAC,GAAG,EAAE,OAAO,EAAE,SAAS,CAAC,OAAO,EAAE,CAAC;QAC5F,OAAO,IAAI,CAAC;IACd,CAAC;IACD,IAAI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AC,CAAC;QACjC,MAAM,GAAG,GAAG,GAAG,MAAM,SAAS,WAAW,EAAE,CAAC;QAE5C,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,IAAI,CAAC,eAAe,MAAM,OAAO,GAAG,IAAI,CAAC,CAAC,CAAC;QAE7D,IAAA,wBAAQ,EAAC,GAAG,EAAE,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC,CAAC;QACjD,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,KAAK,CAAC,2DAA2D,CAAC,CAAC,CAAC;IACxF,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,GAAG,CAAC,8BAA8B,CAAC,CAAC,CAAC;QACvD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;AACH,CAAC"}
|
|
@@ -22,10 +22,10 @@ View the [architecture diagram](https://github.com/CityOfPhiladelphia/phila-ctl/
|
|
|
22
22
|
|
|
23
23
|
```bash
|
|
24
24
|
# Install dependencies
|
|
25
|
-
|
|
25
|
+
{{installCommand}}
|
|
26
26
|
|
|
27
27
|
# Build all packages
|
|
28
|
-
|
|
28
|
+
{{runScriptPrefix}} build
|
|
29
29
|
```
|
|
30
30
|
|
|
31
31
|
### Deployment
|
|
@@ -48,13 +48,13 @@ city deploy prod
|
|
|
48
48
|
|
|
49
49
|
```bash
|
|
50
50
|
# Build TypeScript
|
|
51
|
-
|
|
51
|
+
{{runScriptPrefix}} build
|
|
52
52
|
|
|
53
53
|
# View CDK diff before deploying
|
|
54
|
-
|
|
54
|
+
{{runScriptPrefix}} diff
|
|
55
55
|
|
|
56
56
|
# Synthesize CloudFormation template
|
|
57
|
-
|
|
57
|
+
{{runScriptPrefix}} synth
|
|
58
58
|
```
|
|
59
59
|
|
|
60
60
|
## Project Structure
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
* by the CDK construct when a database is attached to the stack.
|
|
40
40
|
*/
|
|
41
41
|
|
|
42
|
-
import type { APIGWV1Payload } from '@phila/philaroute/dist/
|
|
42
|
+
import type { APIGWV1Payload } from '@phila/philaroute/dist/aws';
|
|
43
43
|
import type { RestAccumulator } from '@phila/philaroute/dist/types';
|
|
44
44
|
import { Router, http, validate } from '@phila/philaroute';
|
|
45
45
|
|
|
@@ -37,8 +37,8 @@ const stack = new Stack(app, '{{appName}}-' + environment, {
|
|
|
37
37
|
stackName: '{{appName}}-' + environment,
|
|
38
38
|
});
|
|
39
39
|
|
|
40
|
-
//
|
|
41
|
-
new LambdaApi(stack, '{{appName}}Api', {
|
|
40
|
+
// Scope as any so linked @phila/constructs resolves to a single Construct type at runtime.
|
|
41
|
+
new LambdaApi(stack as any, '{{appName}}Api', {
|
|
42
42
|
...context,
|
|
43
43
|
apiId: 'main',
|
|
44
44
|
runtime: 'nodejs20',
|
|
@@ -22,10 +22,10 @@ View the [architecture diagram](https://github.com/CityOfPhiladelphia/phila-ctl/
|
|
|
22
22
|
|
|
23
23
|
```bash
|
|
24
24
|
# Install dependencies
|
|
25
|
-
|
|
25
|
+
{{installCommand}}
|
|
26
26
|
|
|
27
27
|
# Build all packages
|
|
28
|
-
|
|
28
|
+
{{runScriptPrefix}} build
|
|
29
29
|
```
|
|
30
30
|
|
|
31
31
|
### Deployment
|
|
@@ -48,13 +48,13 @@ city deploy prod
|
|
|
48
48
|
|
|
49
49
|
```bash
|
|
50
50
|
# Build TypeScript
|
|
51
|
-
|
|
51
|
+
{{runScriptPrefix}} build
|
|
52
52
|
|
|
53
53
|
# View CDK diff before deploying
|
|
54
|
-
|
|
54
|
+
{{runScriptPrefix}} diff
|
|
55
55
|
|
|
56
56
|
# Synthesize CloudFormation template
|
|
57
|
-
|
|
57
|
+
{{runScriptPrefix}} synth
|
|
58
58
|
```
|
|
59
59
|
|
|
60
60
|
## Project Structure
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
* DynamoDB integration using AWS SDK v3 DocumentClient
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
|
-
import type { APIGWV1Payload } from '@phila/philaroute/dist/
|
|
11
|
+
import type { APIGWV1Payload } from '@phila/philaroute/dist/aws';
|
|
12
12
|
import type { RestAccumulator } from '@phila/philaroute/dist/types';
|
|
13
13
|
import { Router, http, validate } from '@phila/philaroute';
|
|
14
14
|
import { DynamoDBClient } from '@aws-sdk/client-dynamodb';
|
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
"description": "Lambda function handler with DynamoDB",
|
|
5
5
|
"private": true,
|
|
6
6
|
"scripts": {
|
|
7
|
-
"build": "
|
|
8
|
-
"watch": "
|
|
7
|
+
"build": "{{execCommand}} tsc",
|
|
8
|
+
"watch": "{{execCommand}} tsc -w"
|
|
9
9
|
},
|
|
10
10
|
"dependencies": {
|
|
11
11
|
"@phila/philaroute": "^1.0.12",
|
|
@@ -37,8 +37,8 @@ const stack = new Stack(app, '{{appName}}-' + environment, {
|
|
|
37
37
|
stackName: '{{appName}}-' + environment,
|
|
38
38
|
});
|
|
39
39
|
|
|
40
|
-
//
|
|
41
|
-
new LambdaDynamoApi(stack, '{{appName}}Api', {
|
|
40
|
+
// Scope as any so linked @phila/constructs resolves to a single Construct type at runtime.
|
|
41
|
+
new LambdaDynamoApi(stack as any, '{{appName}}Api', {
|
|
42
42
|
...context,
|
|
43
43
|
apiId: 'main',
|
|
44
44
|
runtime: 'nodejs20',
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
{
|
|
2
|
-
"app": "
|
|
2
|
+
"app": "{{execCommand}} ts-node --prefer-ts-exts app.ts",
|
|
3
3
|
"watch": {
|
|
4
|
-
"include": [
|
|
5
|
-
"**"
|
|
6
|
-
],
|
|
4
|
+
"include": ["**"],
|
|
7
5
|
"exclude": [
|
|
8
6
|
"README.md",
|
|
9
7
|
"cdk*.json",
|
|
@@ -19,10 +17,7 @@
|
|
|
19
17
|
"context": {
|
|
20
18
|
"@aws-cdk/aws-lambda:recognizeLayerVersion": true,
|
|
21
19
|
"@aws-cdk/core:checkSecretUsage": true,
|
|
22
|
-
"@aws-cdk/core:target-partitions": [
|
|
23
|
-
"aws",
|
|
24
|
-
"aws-cn"
|
|
25
|
-
],
|
|
20
|
+
"@aws-cdk/core:target-partitions": ["aws", "aws-cn"],
|
|
26
21
|
"@aws-cdk-containers/ecs-service-extensions:enableDefaultLogDriver": true,
|
|
27
22
|
"@aws-cdk/aws-ec2:uniqueImdsv2TemplateName": true,
|
|
28
23
|
"@aws-cdk/aws-ecs:arnFormatIncludesClusterName": true,
|
|
@@ -22,10 +22,10 @@ View the [architecture diagram](https://github.com/CityOfPhiladelphia/phila-ctl/
|
|
|
22
22
|
|
|
23
23
|
```bash
|
|
24
24
|
# Install dependencies
|
|
25
|
-
|
|
25
|
+
{{installCommand}}
|
|
26
26
|
|
|
27
27
|
# Build all packages
|
|
28
|
-
|
|
28
|
+
{{runScriptPrefix}} build
|
|
29
29
|
```
|
|
30
30
|
|
|
31
31
|
### Deployment
|
|
@@ -48,13 +48,13 @@ city deploy prod
|
|
|
48
48
|
|
|
49
49
|
```bash
|
|
50
50
|
# Build TypeScript
|
|
51
|
-
|
|
51
|
+
{{runScriptPrefix}} build
|
|
52
52
|
|
|
53
53
|
# View CDK diff before deploying
|
|
54
|
-
|
|
54
|
+
{{runScriptPrefix}} diff
|
|
55
55
|
|
|
56
56
|
# Synthesize CloudFormation template
|
|
57
|
-
|
|
57
|
+
{{runScriptPrefix}} synth
|
|
58
58
|
```
|
|
59
59
|
|
|
60
60
|
## Project Structure
|
|
@@ -205,7 +205,7 @@ This application creates:
|
|
|
205
205
|
To use Aurora Serverless v2 instead of provisioned RDS, edit `cdk/app.ts`:
|
|
206
206
|
|
|
207
207
|
```typescript
|
|
208
|
-
new LambdaPostgresApi(stack, '{{appName}}Api', {
|
|
208
|
+
new LambdaPostgresApi(stack as any, '{{appName}}Api', {
|
|
209
209
|
...context,
|
|
210
210
|
apiId: 'main',
|
|
211
211
|
runtime: 'nodejs20',
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
* by the CDK construct.
|
|
13
13
|
*/
|
|
14
14
|
|
|
15
|
-
import type { APIGWV1Payload } from '@phila/philaroute/dist/
|
|
15
|
+
import type { APIGWV1Payload } from '@phila/philaroute/dist/aws';
|
|
16
16
|
import type { RestAccumulator } from '@phila/philaroute/dist/types';
|
|
17
17
|
import { Router, http, validate } from '@phila/philaroute';
|
|
18
18
|
import { getPool } from '@phila/db-postgres';
|
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
"description": "Lambda function handler with PostgreSQL database access",
|
|
5
5
|
"private": true,
|
|
6
6
|
"scripts": {
|
|
7
|
-
"build": "
|
|
8
|
-
"watch": "
|
|
7
|
+
"build": "{{execCommand}} tsc",
|
|
8
|
+
"watch": "{{execCommand}} tsc -w"
|
|
9
9
|
},
|
|
10
10
|
"dependencies": {
|
|
11
11
|
"@phila/philaroute": "^1.0.12",
|
|
@@ -37,8 +37,8 @@ const stack = new Stack(app, '{{appName}}-' + environment, {
|
|
|
37
37
|
stackName: '{{appName}}-' + environment,
|
|
38
38
|
});
|
|
39
39
|
|
|
40
|
-
//
|
|
41
|
-
new LambdaPostgresApi(stack, '{{appName}}Api', {
|
|
40
|
+
// Scope as any so linked @phila/constructs resolves to a single Construct type at runtime.
|
|
41
|
+
new LambdaPostgresApi(stack as any, '{{appName}}Api', {
|
|
42
42
|
...context,
|
|
43
43
|
apiId: 'main',
|
|
44
44
|
runtime: 'nodejs20',
|
|
@@ -20,11 +20,11 @@ View the [architecture diagram](https://github.com/CityOfPhiladelphia/phila-ctl/
|
|
|
20
20
|
|
|
21
21
|
```bash
|
|
22
22
|
# Install dependencies
|
|
23
|
-
|
|
23
|
+
{{installCommand}}
|
|
24
24
|
|
|
25
25
|
# Set up frontend (replace placeholder with Nuxt)
|
|
26
26
|
cd frontend
|
|
27
|
-
|
|
27
|
+
{{execCommand}} nuxi@latest init .
|
|
28
28
|
# Configure nuxt.config.ts for SSG
|
|
29
29
|
```
|
|
30
30
|
|
|
@@ -37,8 +37,8 @@ const stack = new Stack(app, '{{appName}}-' + environment, {
|
|
|
37
37
|
stackName: '{{appName}}-' + environment,
|
|
38
38
|
});
|
|
39
39
|
|
|
40
|
-
//
|
|
41
|
-
new StaticSite(stack, '{{appName}}Site', {
|
|
40
|
+
// Scope as any so linked @phila/constructs resolves to a single Construct type at runtime.
|
|
41
|
+
new StaticSite(stack as any, '{{appName}}Site', {
|
|
42
42
|
...context,
|
|
43
43
|
assetDir: '../frontend/dist',
|
|
44
44
|
});
|
|
@@ -11,7 +11,7 @@ Replace this placeholder with a Nuxt project:
|
|
|
11
11
|
rm -rf frontend/*
|
|
12
12
|
|
|
13
13
|
# Create Nuxt project
|
|
14
|
-
|
|
14
|
+
{{execCommand}} nuxi@latest init frontend
|
|
15
15
|
|
|
16
16
|
# Configure for SSG in nuxt.config.ts:
|
|
17
17
|
# export default defineNuxtConfig({
|
|
@@ -26,14 +26,14 @@ npx nuxi@latest init frontend
|
|
|
26
26
|
|
|
27
27
|
```bash
|
|
28
28
|
cd frontend
|
|
29
|
-
|
|
30
|
-
|
|
29
|
+
{{installCommand}}
|
|
30
|
+
{{runScriptPrefix}} generate # Outputs to .output/public/
|
|
31
31
|
```
|
|
32
32
|
|
|
33
33
|
## Deploy
|
|
34
34
|
|
|
35
35
|
The `city ship --web` command will:
|
|
36
|
-
1. Run `
|
|
36
|
+
1. Run `{{runScriptPrefix}} build` in this directory
|
|
37
37
|
2. Sync `dist/` to the S3 bucket
|
|
38
38
|
3. Invalidate the CloudFront cache
|
|
39
39
|
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// ABOUTME: Placeholder build for static-site frontend. Creates dist/ with a minimal index.html.
|
|
3
|
+
// ABOUTME: Replace this frontend with a Nuxt project (see README.md); then use Nuxt's build instead.
|
|
4
|
+
|
|
5
|
+
const fs = require('fs');
|
|
6
|
+
const path = require('path');
|
|
7
|
+
|
|
8
|
+
const distDir = path.join(__dirname, 'dist');
|
|
9
|
+
const watch = process.argv.includes('--watch');
|
|
10
|
+
|
|
11
|
+
const indexHtml = `<!DOCTYPE html>
|
|
12
|
+
<html lang="en">
|
|
13
|
+
<head>
|
|
14
|
+
<meta charset="UTF-8" />
|
|
15
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
16
|
+
<title>Hello Philadelphia!</title>
|
|
17
|
+
</head>
|
|
18
|
+
<body>
|
|
19
|
+
<h1>Hello Philadelphia!</h1>
|
|
20
|
+
<p>Replace this placeholder frontend with your own application.</p>
|
|
21
|
+
</body>
|
|
22
|
+
</html>
|
|
23
|
+
`;
|
|
24
|
+
|
|
25
|
+
function build() {
|
|
26
|
+
if (!fs.existsSync(distDir)) {
|
|
27
|
+
fs.mkdirSync(distDir, { recursive: true });
|
|
28
|
+
}
|
|
29
|
+
fs.writeFileSync(path.join(distDir, 'index.html'), indexHtml, 'utf8');
|
|
30
|
+
console.log('Built dist/index.html');
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
build();
|
|
34
|
+
|
|
35
|
+
if (watch) {
|
|
36
|
+
fs.watch(__dirname, { recursive: false }, (eventType, filename) => {
|
|
37
|
+
if (filename && (filename.endsWith('.html') || filename.endsWith('.js'))) {
|
|
38
|
+
build();
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
console.log('Watching for changes...');
|
|
42
|
+
}
|
|
@@ -24,7 +24,7 @@ View the [architecture diagram](https://github.com/CityOfPhiladelphia/phila-ctl/
|
|
|
24
24
|
|
|
25
25
|
```bash
|
|
26
26
|
# Install frontend and CDK dependencies
|
|
27
|
-
|
|
27
|
+
{{installCommand}}
|
|
28
28
|
|
|
29
29
|
# Restore .NET dependencies
|
|
30
30
|
cd apps/api && dotnet restore && cd ../..
|
|
@@ -34,16 +34,16 @@ cd apps/api && dotnet restore && cd ../..
|
|
|
34
34
|
|
|
35
35
|
```bash
|
|
36
36
|
# Run frontend dev server
|
|
37
|
-
|
|
37
|
+
{{runScriptPrefix}} dev
|
|
38
38
|
|
|
39
39
|
# Run API locally
|
|
40
40
|
cd apps/api && dotnet run
|
|
41
41
|
|
|
42
42
|
# Build frontend for production
|
|
43
|
-
|
|
43
|
+
{{runScriptPrefix}} build:frontend
|
|
44
44
|
|
|
45
45
|
# Build API Docker image
|
|
46
|
-
|
|
46
|
+
{{runScriptPrefix}} build:api
|
|
47
47
|
```
|
|
48
48
|
|
|
49
49
|
### Deployment
|
|
@@ -39,14 +39,13 @@ const stack = new Stack(app, '{{appName}}-' + environment, {
|
|
|
39
39
|
stackName: '{{appName}}-' + environment,
|
|
40
40
|
});
|
|
41
41
|
|
|
42
|
-
//
|
|
43
|
-
new StaticSite(stack, '{{appName}}Site', {
|
|
42
|
+
// Scope as any so linked @phila/constructs resolves to a single Construct type at runtime.
|
|
43
|
+
new StaticSite(stack as any, '{{appName}}Site', {
|
|
44
44
|
...context,
|
|
45
45
|
assetDir: '../frontend/dist',
|
|
46
46
|
});
|
|
47
47
|
|
|
48
|
-
|
|
49
|
-
new EcsApi(stack, '{{appName}}Api', {
|
|
48
|
+
new EcsApi(stack as any, '{{appName}}Api', {
|
|
50
49
|
...context,
|
|
51
50
|
apiId: 'api',
|
|
52
51
|
image: ecs.ContainerImage.fromAsset(path.join(__dirname, '../apps/api')),
|
|
@@ -4,10 +4,10 @@
|
|
|
4
4
|
"description": "Web application with Nuxt frontend and .NET ECS containerized API backend",
|
|
5
5
|
"private": true,
|
|
6
6
|
"scripts": {
|
|
7
|
-
"build": "
|
|
8
|
-
"build:frontend": "cd frontend &&
|
|
7
|
+
"build": "{{runScriptPrefix}} build:frontend && {{runScriptPrefix}} build:api",
|
|
8
|
+
"build:frontend": "cd frontend && {{runScriptPrefix}} build",
|
|
9
9
|
"build:api": "cd apps/api && docker build -t {{appName}}-api .",
|
|
10
|
-
"dev": "cd frontend &&
|
|
10
|
+
"dev": "cd frontend && {{runScriptPrefix}} dev",
|
|
11
11
|
"test": "{{testCommand}}",
|
|
12
12
|
"synth": "cd cdk && cdk synth",
|
|
13
13
|
"deploy": "cd cdk && cdk deploy",
|
|
@@ -20,5 +20,8 @@
|
|
|
20
20
|
"devDependencies": {
|
|
21
21
|
"@types/node": "^20.10.0",
|
|
22
22
|
"typescript": "^5.3.0"
|
|
23
|
+
},
|
|
24
|
+
"overrides": {
|
|
25
|
+
"constructs": "10.4.4"
|
|
23
26
|
}
|
|
24
27
|
}
|