@fy-stack/cli 0.0.131

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 (32) hide show
  1. package/README.md +7 -0
  2. package/dist/assets/get-cdk-json.d.ts +72 -0
  3. package/dist/assets/get-cdk-json.d.ts.map +1 -0
  4. package/dist/assets/get-cdk-json.js +79 -0
  5. package/dist/assets/get-infra.js.d.ts +9 -0
  6. package/dist/assets/get-infra.js.d.ts.map +1 -0
  7. package/dist/assets/get-infra.js.js +38 -0
  8. package/dist/commands/assets/get-cdk-json.d.ts +72 -0
  9. package/dist/commands/assets/get-cdk-json.d.ts.map +1 -0
  10. package/dist/commands/assets/get-cdk-json.js +80 -0
  11. package/dist/commands/assets/get-infra.js.d.ts +10 -0
  12. package/dist/commands/assets/get-infra.js.d.ts.map +1 -0
  13. package/dist/commands/assets/get-infra.js.js +43 -0
  14. package/dist/commands/assets/get-yaml-file.d.ts +8 -0
  15. package/dist/commands/assets/get-yaml-file.d.ts.map +1 -0
  16. package/dist/commands/assets/get-yaml-file.js +48 -0
  17. package/dist/commands/github-aws-construct.d.ts +12 -0
  18. package/dist/commands/github-aws-construct.d.ts.map +1 -0
  19. package/dist/commands/github-aws-construct.js +29 -0
  20. package/dist/commands/github-aws-stack.d.ts +13 -0
  21. package/dist/commands/github-aws-stack.d.ts.map +1 -0
  22. package/dist/commands/github-aws-stack.js +28 -0
  23. package/dist/commands/init-app.d.ts +3 -0
  24. package/dist/commands/init-app.d.ts.map +1 -0
  25. package/dist/commands/init-app.js +150 -0
  26. package/dist/commands/types.d.ts +6 -0
  27. package/dist/commands/types.d.ts.map +1 -0
  28. package/dist/commands/types.js +2 -0
  29. package/dist/index.d.ts +3 -0
  30. package/dist/index.d.ts.map +1 -0
  31. package/dist/index.js +31 -0
  32. package/package.json +24 -0
package/README.md ADDED
@@ -0,0 +1,7 @@
1
+ # cli
2
+
3
+ This library was generated with [Nx](https://nx.dev).
4
+
5
+ ## Building
6
+
7
+ Run `nx build cli` to build the library.
@@ -0,0 +1,72 @@
1
+ type GetCdkJsonParams = {
2
+ command: string;
3
+ include?: string[];
4
+ exclude?: string[];
5
+ };
6
+ export declare function getCdkJson(params: GetCdkJsonParams): {
7
+ app: string;
8
+ watch: {
9
+ include: string[];
10
+ exclude: string[];
11
+ };
12
+ context: {
13
+ "@aws-cdk/aws-lambda:recognizeLayerVersion": boolean;
14
+ "@aws-cdk/core:checkSecretUsage": boolean;
15
+ "@aws-cdk/core:target-partitions": string[];
16
+ "@aws-cdk-containers/ecs-service-extensions:enableDefaultLogDriver": boolean;
17
+ "@aws-cdk/aws-ec2:uniqueImdsv2TemplateName": boolean;
18
+ "@aws-cdk/aws-ecs:arnFormatIncludesClusterName": boolean;
19
+ "@aws-cdk/aws-iam:minimizePolicies": boolean;
20
+ "@aws-cdk/core:validateSnapshotRemovalPolicy": boolean;
21
+ "@aws-cdk/aws-codepipeline:crossAccountKeyAliasStackSafeResourceName": boolean;
22
+ "@aws-cdk/aws-s3:createDefaultLoggingPolicy": boolean;
23
+ "@aws-cdk/aws-sns-subscriptions:restrictSqsDescryption": boolean;
24
+ "@aws-cdk/aws-apigateway:disableCloudWatchRole": boolean;
25
+ "@aws-cdk/core:enablePartitionLiterals": boolean;
26
+ "@aws-cdk/aws-events:eventsTargetQueueSameAccount": boolean;
27
+ "@aws-cdk/aws-ecs:disableExplicitDeploymentControllerForCircuitBreaker": boolean;
28
+ "@aws-cdk/aws-iam:importedRoleStackSafeDefaultPolicyName": boolean;
29
+ "@aws-cdk/aws-s3:serverAccessLogsUseBucketPolicy": boolean;
30
+ "@aws-cdk/aws-route53-patters:useCertificate": boolean;
31
+ "@aws-cdk/customresources:installLatestAwsSdkDefault": boolean;
32
+ "@aws-cdk/aws-rds:databaseProxyUniqueResourceName": boolean;
33
+ "@aws-cdk/aws-codedeploy:removeAlarmsFromDeploymentGroup": boolean;
34
+ "@aws-cdk/aws-apigateway:authorizerChangeDeploymentLogicalId": boolean;
35
+ "@aws-cdk/aws-ec2:launchTemplateDefaultUserData": boolean;
36
+ "@aws-cdk/aws-secretsmanager:useAttachedSecretResourcePolicyForSecretTargetAttachments": boolean;
37
+ "@aws-cdk/aws-redshift:columnId": boolean;
38
+ "@aws-cdk/aws-stepfunctions-tasks:enableEmrServicePolicyV2": boolean;
39
+ "@aws-cdk/aws-ec2:restrictDefaultSecurityGroup": boolean;
40
+ "@aws-cdk/aws-apigateway:requestValidatorUniqueId": boolean;
41
+ "@aws-cdk/aws-kms:aliasNameRef": boolean;
42
+ "@aws-cdk/aws-autoscaling:generateLaunchTemplateInsteadOfLaunchConfig": boolean;
43
+ "@aws-cdk/core:includePrefixInUniqueNameGeneration": boolean;
44
+ "@aws-cdk/aws-efs:denyAnonymousAccess": boolean;
45
+ "@aws-cdk/aws-opensearchservice:enableOpensearchMultiAzWithStandby": boolean;
46
+ "@aws-cdk/aws-lambda-nodejs:useLatestRuntimeVersion": boolean;
47
+ "@aws-cdk/aws-efs:mountTargetOrderInsensitiveLogicalId": boolean;
48
+ "@aws-cdk/aws-rds:auroraClusterChangeScopeOfInstanceParameterGroupWithEachParameters": boolean;
49
+ "@aws-cdk/aws-appsync:useArnForSourceApiAssociationIdentifier": boolean;
50
+ "@aws-cdk/aws-rds:preventRenderingDeprecatedCredentials": boolean;
51
+ "@aws-cdk/aws-codepipeline-actions:useNewDefaultBranchForCodeCommitSource": boolean;
52
+ "@aws-cdk/aws-cloudwatch-actions:changeLambdaPermissionLogicalIdForLambdaAction": boolean;
53
+ "@aws-cdk/aws-codepipeline:crossAccountKeysDefaultValueToFalse": boolean;
54
+ "@aws-cdk/aws-codepipeline:defaultPipelineTypeToV2": boolean;
55
+ "@aws-cdk/aws-kms:reduceCrossAccountRegionPolicyScope": boolean;
56
+ "@aws-cdk/aws-eks:nodegroupNameAttribute": boolean;
57
+ "@aws-cdk/aws-ec2:ebsDefaultGp3Volume": boolean;
58
+ "@aws-cdk/aws-ecs:removeDefaultDeploymentAlarm": boolean;
59
+ "@aws-cdk/custom-resources:logApiResponseDataPropertyTrueDefault": boolean;
60
+ "@aws-cdk/aws-s3:keepNotificationInImportedBucket": boolean;
61
+ "@aws-cdk/aws-ecs:reduceEc2FargateCloudWatchPermissions": boolean;
62
+ "@aws-cdk/aws-dynamodb:resourcePolicyPerReplica": boolean;
63
+ "@aws-cdk/aws-ec2:ec2SumTImeoutEnabled": boolean;
64
+ "@aws-cdk/aws-appsync:appSyncGraphQLAPIScopeLambdaPermission": boolean;
65
+ "@aws-cdk/aws-rds:setCorrectValueForDatabaseInstanceReadReplicaInstanceResourceId": boolean;
66
+ "@aws-cdk/core:cfnIncludeRejectComplexResourceUpdateCreatePolicyIntrinsics": boolean;
67
+ "@aws-cdk/aws-lambda-nodejs:sdkV3ExcludeSmithyPackages": boolean;
68
+ "@aws-cdk/aws-stepfunctions-tasks:fixRunEcsTaskPolicy": boolean;
69
+ };
70
+ };
71
+ export {};
72
+ //# sourceMappingURL=get-cdk-json.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-cdk-json.d.ts","sourceRoot":"","sources":["../../src/assets/get-cdk-json.ts"],"names":[],"mappings":"AAAA,KAAK,gBAAgB,GAAG;IACtB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;CACpB,CAAA;AAED,wBAAgB,UAAU,CAAC,MAAM,EAAE,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA4ElD"}
@@ -0,0 +1,79 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getCdkJson = getCdkJson;
4
+ function getCdkJson(params) {
5
+ return {
6
+ "app": params.command,
7
+ "watch": {
8
+ "include": params.include ?? ["**"],
9
+ "exclude": params.exclude ?? [
10
+ "README.md",
11
+ "cdk*.json",
12
+ "package*.json",
13
+ "yarn.lock",
14
+ "node_modules",
15
+ ]
16
+ },
17
+ "context": {
18
+ "@aws-cdk/aws-lambda:recognizeLayerVersion": true,
19
+ "@aws-cdk/core:checkSecretUsage": true,
20
+ "@aws-cdk/core:target-partitions": [
21
+ "aws",
22
+ "aws-cn"
23
+ ],
24
+ "@aws-cdk-containers/ecs-service-extensions:enableDefaultLogDriver": true,
25
+ "@aws-cdk/aws-ec2:uniqueImdsv2TemplateName": true,
26
+ "@aws-cdk/aws-ecs:arnFormatIncludesClusterName": true,
27
+ "@aws-cdk/aws-iam:minimizePolicies": true,
28
+ "@aws-cdk/core:validateSnapshotRemovalPolicy": true,
29
+ "@aws-cdk/aws-codepipeline:crossAccountKeyAliasStackSafeResourceName": true,
30
+ "@aws-cdk/aws-s3:createDefaultLoggingPolicy": true,
31
+ "@aws-cdk/aws-sns-subscriptions:restrictSqsDescryption": true,
32
+ "@aws-cdk/aws-apigateway:disableCloudWatchRole": true,
33
+ "@aws-cdk/core:enablePartitionLiterals": true,
34
+ "@aws-cdk/aws-events:eventsTargetQueueSameAccount": true,
35
+ "@aws-cdk/aws-ecs:disableExplicitDeploymentControllerForCircuitBreaker": true,
36
+ "@aws-cdk/aws-iam:importedRoleStackSafeDefaultPolicyName": true,
37
+ "@aws-cdk/aws-s3:serverAccessLogsUseBucketPolicy": true,
38
+ "@aws-cdk/aws-route53-patters:useCertificate": true,
39
+ "@aws-cdk/customresources:installLatestAwsSdkDefault": false,
40
+ "@aws-cdk/aws-rds:databaseProxyUniqueResourceName": true,
41
+ "@aws-cdk/aws-codedeploy:removeAlarmsFromDeploymentGroup": true,
42
+ "@aws-cdk/aws-apigateway:authorizerChangeDeploymentLogicalId": true,
43
+ "@aws-cdk/aws-ec2:launchTemplateDefaultUserData": true,
44
+ "@aws-cdk/aws-secretsmanager:useAttachedSecretResourcePolicyForSecretTargetAttachments": true,
45
+ "@aws-cdk/aws-redshift:columnId": true,
46
+ "@aws-cdk/aws-stepfunctions-tasks:enableEmrServicePolicyV2": true,
47
+ "@aws-cdk/aws-ec2:restrictDefaultSecurityGroup": true,
48
+ "@aws-cdk/aws-apigateway:requestValidatorUniqueId": true,
49
+ "@aws-cdk/aws-kms:aliasNameRef": true,
50
+ "@aws-cdk/aws-autoscaling:generateLaunchTemplateInsteadOfLaunchConfig": true,
51
+ "@aws-cdk/core:includePrefixInUniqueNameGeneration": true,
52
+ "@aws-cdk/aws-efs:denyAnonymousAccess": true,
53
+ "@aws-cdk/aws-opensearchservice:enableOpensearchMultiAzWithStandby": true,
54
+ "@aws-cdk/aws-lambda-nodejs:useLatestRuntimeVersion": true,
55
+ "@aws-cdk/aws-efs:mountTargetOrderInsensitiveLogicalId": true,
56
+ "@aws-cdk/aws-rds:auroraClusterChangeScopeOfInstanceParameterGroupWithEachParameters": true,
57
+ "@aws-cdk/aws-appsync:useArnForSourceApiAssociationIdentifier": true,
58
+ "@aws-cdk/aws-rds:preventRenderingDeprecatedCredentials": true,
59
+ "@aws-cdk/aws-codepipeline-actions:useNewDefaultBranchForCodeCommitSource": true,
60
+ "@aws-cdk/aws-cloudwatch-actions:changeLambdaPermissionLogicalIdForLambdaAction": true,
61
+ "@aws-cdk/aws-codepipeline:crossAccountKeysDefaultValueToFalse": true,
62
+ "@aws-cdk/aws-codepipeline:defaultPipelineTypeToV2": true,
63
+ "@aws-cdk/aws-kms:reduceCrossAccountRegionPolicyScope": true,
64
+ "@aws-cdk/aws-eks:nodegroupNameAttribute": true,
65
+ "@aws-cdk/aws-ec2:ebsDefaultGp3Volume": true,
66
+ "@aws-cdk/aws-ecs:removeDefaultDeploymentAlarm": true,
67
+ "@aws-cdk/custom-resources:logApiResponseDataPropertyTrueDefault": false,
68
+ "@aws-cdk/aws-s3:keepNotificationInImportedBucket": false,
69
+ "@aws-cdk/aws-ecs:reduceEc2FargateCloudWatchPermissions": true,
70
+ "@aws-cdk/aws-dynamodb:resourcePolicyPerReplica": true,
71
+ "@aws-cdk/aws-ec2:ec2SumTImeoutEnabled": true,
72
+ "@aws-cdk/aws-appsync:appSyncGraphQLAPIScopeLambdaPermission": true,
73
+ "@aws-cdk/aws-rds:setCorrectValueForDatabaseInstanceReadReplicaInstanceResourceId": true,
74
+ "@aws-cdk/core:cfnIncludeRejectComplexResourceUpdateCreatePolicyIntrinsics": true,
75
+ "@aws-cdk/aws-lambda-nodejs:sdkV3ExcludeSmithyPackages": true,
76
+ "@aws-cdk/aws-stepfunctions-tasks:fixRunEcsTaskPolicy": true
77
+ }
78
+ };
79
+ }
@@ -0,0 +1,9 @@
1
+ type GetInfraFileParams = {
2
+ app: string;
3
+ };
4
+ export declare function getInfra(params: GetInfraFileParams): {
5
+ infraFile: string;
6
+ cdkJsonFile: string;
7
+ };
8
+ export {};
9
+ //# sourceMappingURL=get-infra.js.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-infra.js.d.ts","sourceRoot":"","sources":["../../src/assets/get-infra.js.ts"],"names":[],"mappings":"AAEA,KAAK,kBAAkB,GAAG;IACxB,GAAG,EAAE,MAAM,CAAC;CACb,CAAC;AAEF,wBAAgB,QAAQ,CAAC,MAAM,EAAE,kBAAkB;;;EAoClD"}
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getInfra = getInfra;
4
+ const get_cdk_json_1 = require("./get-cdk-json");
5
+ function getInfra(params) {
6
+ const infraFile = `#!/usr/bin/env node
7
+ const cdk = require("aws-cdk-lib");
8
+ const { FullStackConstruct, AppType } = require("@fy-stack/fullstack-construct");
9
+
10
+ const env = {
11
+ account: process.env.CDK_DEFAULT_ACCOUNT,
12
+ region: process.env.CDK_DEFAULT_REGION,
13
+ };
14
+
15
+ class AppStack extends cdk.Stack {
16
+ constructor(scope, id, props) {
17
+ super(scope, id, props);
18
+
19
+ const app = new FullStackConstruct(this, "App", {
20
+ storage: { retainOnDelete: false, },
21
+ apps: {},
22
+ });
23
+
24
+ cdk.Tags.of(this).add("App", "${params.app}");
25
+ }
26
+ }
27
+
28
+ const app = new cdk.App();
29
+ new AppStack(
30
+ app,
31
+ "app",
32
+ { env, stackName: "<generate-stack-name>" }
33
+ );`;
34
+ const cdkJsonFile = JSON.stringify((0, get_cdk_json_1.getCdkJson)({
35
+ command: 'node infra.js',
36
+ }), null, 2);
37
+ return { infraFile, cdkJsonFile };
38
+ }
@@ -0,0 +1,72 @@
1
+ type GetCdkJsonParams = {
2
+ command: string;
3
+ include?: string[];
4
+ exclude?: string[];
5
+ };
6
+ export declare function getCdkJson(params: GetCdkJsonParams): {
7
+ app: string;
8
+ watch: {
9
+ include: string[];
10
+ exclude: string[];
11
+ };
12
+ context: {
13
+ "@aws-cdk/aws-lambda:recognizeLayerVersion": boolean;
14
+ "@aws-cdk/core:checkSecretUsage": boolean;
15
+ "@aws-cdk/core:target-partitions": string[];
16
+ "@aws-cdk-containers/ecs-service-extensions:enableDefaultLogDriver": boolean;
17
+ "@aws-cdk/aws-ec2:uniqueImdsv2TemplateName": boolean;
18
+ "@aws-cdk/aws-ecs:arnFormatIncludesClusterName": boolean;
19
+ "@aws-cdk/aws-iam:minimizePolicies": boolean;
20
+ "@aws-cdk/core:validateSnapshotRemovalPolicy": boolean;
21
+ "@aws-cdk/aws-codepipeline:crossAccountKeyAliasStackSafeResourceName": boolean;
22
+ "@aws-cdk/aws-s3:createDefaultLoggingPolicy": boolean;
23
+ "@aws-cdk/aws-sns-subscriptions:restrictSqsDescryption": boolean;
24
+ "@aws-cdk/aws-apigateway:disableCloudWatchRole": boolean;
25
+ "@aws-cdk/core:enablePartitionLiterals": boolean;
26
+ "@aws-cdk/aws-events:eventsTargetQueueSameAccount": boolean;
27
+ "@aws-cdk/aws-ecs:disableExplicitDeploymentControllerForCircuitBreaker": boolean;
28
+ "@aws-cdk/aws-iam:importedRoleStackSafeDefaultPolicyName": boolean;
29
+ "@aws-cdk/aws-s3:serverAccessLogsUseBucketPolicy": boolean;
30
+ "@aws-cdk/aws-route53-patters:useCertificate": boolean;
31
+ "@aws-cdk/customresources:installLatestAwsSdkDefault": boolean;
32
+ "@aws-cdk/aws-rds:databaseProxyUniqueResourceName": boolean;
33
+ "@aws-cdk/aws-codedeploy:removeAlarmsFromDeploymentGroup": boolean;
34
+ "@aws-cdk/aws-apigateway:authorizerChangeDeploymentLogicalId": boolean;
35
+ "@aws-cdk/aws-ec2:launchTemplateDefaultUserData": boolean;
36
+ "@aws-cdk/aws-secretsmanager:useAttachedSecretResourcePolicyForSecretTargetAttachments": boolean;
37
+ "@aws-cdk/aws-redshift:columnId": boolean;
38
+ "@aws-cdk/aws-stepfunctions-tasks:enableEmrServicePolicyV2": boolean;
39
+ "@aws-cdk/aws-ec2:restrictDefaultSecurityGroup": boolean;
40
+ "@aws-cdk/aws-apigateway:requestValidatorUniqueId": boolean;
41
+ "@aws-cdk/aws-kms:aliasNameRef": boolean;
42
+ "@aws-cdk/aws-autoscaling:generateLaunchTemplateInsteadOfLaunchConfig": boolean;
43
+ "@aws-cdk/core:includePrefixInUniqueNameGeneration": boolean;
44
+ "@aws-cdk/aws-efs:denyAnonymousAccess": boolean;
45
+ "@aws-cdk/aws-opensearchservice:enableOpensearchMultiAzWithStandby": boolean;
46
+ "@aws-cdk/aws-lambda-nodejs:useLatestRuntimeVersion": boolean;
47
+ "@aws-cdk/aws-efs:mountTargetOrderInsensitiveLogicalId": boolean;
48
+ "@aws-cdk/aws-rds:auroraClusterChangeScopeOfInstanceParameterGroupWithEachParameters": boolean;
49
+ "@aws-cdk/aws-appsync:useArnForSourceApiAssociationIdentifier": boolean;
50
+ "@aws-cdk/aws-rds:preventRenderingDeprecatedCredentials": boolean;
51
+ "@aws-cdk/aws-codepipeline-actions:useNewDefaultBranchForCodeCommitSource": boolean;
52
+ "@aws-cdk/aws-cloudwatch-actions:changeLambdaPermissionLogicalIdForLambdaAction": boolean;
53
+ "@aws-cdk/aws-codepipeline:crossAccountKeysDefaultValueToFalse": boolean;
54
+ "@aws-cdk/aws-codepipeline:defaultPipelineTypeToV2": boolean;
55
+ "@aws-cdk/aws-kms:reduceCrossAccountRegionPolicyScope": boolean;
56
+ "@aws-cdk/aws-eks:nodegroupNameAttribute": boolean;
57
+ "@aws-cdk/aws-ec2:ebsDefaultGp3Volume": boolean;
58
+ "@aws-cdk/aws-ecs:removeDefaultDeploymentAlarm": boolean;
59
+ "@aws-cdk/custom-resources:logApiResponseDataPropertyTrueDefault": boolean;
60
+ "@aws-cdk/aws-s3:keepNotificationInImportedBucket": boolean;
61
+ "@aws-cdk/aws-ecs:reduceEc2FargateCloudWatchPermissions": boolean;
62
+ "@aws-cdk/aws-dynamodb:resourcePolicyPerReplica": boolean;
63
+ "@aws-cdk/aws-ec2:ec2SumTImeoutEnabled": boolean;
64
+ "@aws-cdk/aws-appsync:appSyncGraphQLAPIScopeLambdaPermission": boolean;
65
+ "@aws-cdk/aws-rds:setCorrectValueForDatabaseInstanceReadReplicaInstanceResourceId": boolean;
66
+ "@aws-cdk/core:cfnIncludeRejectComplexResourceUpdateCreatePolicyIntrinsics": boolean;
67
+ "@aws-cdk/aws-lambda-nodejs:sdkV3ExcludeSmithyPackages": boolean;
68
+ "@aws-cdk/aws-stepfunctions-tasks:fixRunEcsTaskPolicy": boolean;
69
+ };
70
+ };
71
+ export {};
72
+ //# sourceMappingURL=get-cdk-json.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-cdk-json.d.ts","sourceRoot":"","sources":["../../../src/commands/assets/get-cdk-json.ts"],"names":[],"mappings":"AAAA,KAAK,gBAAgB,GAAG;IACtB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;CACpB,CAAA;AAED,wBAAgB,UAAU,CAAC,MAAM,EAAE,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA6ElD"}
@@ -0,0 +1,80 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getCdkJson = getCdkJson;
4
+ function getCdkJson(params) {
5
+ return {
6
+ "app": params.command,
7
+ "watch": {
8
+ "include": params.include ?? ["**"],
9
+ "exclude": params.exclude ?? [
10
+ "README.md",
11
+ "cdk*.json",
12
+ "jest.config.js",
13
+ "package*.json",
14
+ "yarn.lock",
15
+ "node_modules",
16
+ ]
17
+ },
18
+ "context": {
19
+ "@aws-cdk/aws-lambda:recognizeLayerVersion": true,
20
+ "@aws-cdk/core:checkSecretUsage": true,
21
+ "@aws-cdk/core:target-partitions": [
22
+ "aws",
23
+ "aws-cn"
24
+ ],
25
+ "@aws-cdk-containers/ecs-service-extensions:enableDefaultLogDriver": true,
26
+ "@aws-cdk/aws-ec2:uniqueImdsv2TemplateName": true,
27
+ "@aws-cdk/aws-ecs:arnFormatIncludesClusterName": true,
28
+ "@aws-cdk/aws-iam:minimizePolicies": true,
29
+ "@aws-cdk/core:validateSnapshotRemovalPolicy": true,
30
+ "@aws-cdk/aws-codepipeline:crossAccountKeyAliasStackSafeResourceName": true,
31
+ "@aws-cdk/aws-s3:createDefaultLoggingPolicy": true,
32
+ "@aws-cdk/aws-sns-subscriptions:restrictSqsDescryption": true,
33
+ "@aws-cdk/aws-apigateway:disableCloudWatchRole": true,
34
+ "@aws-cdk/core:enablePartitionLiterals": true,
35
+ "@aws-cdk/aws-events:eventsTargetQueueSameAccount": true,
36
+ "@aws-cdk/aws-ecs:disableExplicitDeploymentControllerForCircuitBreaker": true,
37
+ "@aws-cdk/aws-iam:importedRoleStackSafeDefaultPolicyName": true,
38
+ "@aws-cdk/aws-s3:serverAccessLogsUseBucketPolicy": true,
39
+ "@aws-cdk/aws-route53-patters:useCertificate": true,
40
+ "@aws-cdk/customresources:installLatestAwsSdkDefault": false,
41
+ "@aws-cdk/aws-rds:databaseProxyUniqueResourceName": true,
42
+ "@aws-cdk/aws-codedeploy:removeAlarmsFromDeploymentGroup": true,
43
+ "@aws-cdk/aws-apigateway:authorizerChangeDeploymentLogicalId": true,
44
+ "@aws-cdk/aws-ec2:launchTemplateDefaultUserData": true,
45
+ "@aws-cdk/aws-secretsmanager:useAttachedSecretResourcePolicyForSecretTargetAttachments": true,
46
+ "@aws-cdk/aws-redshift:columnId": true,
47
+ "@aws-cdk/aws-stepfunctions-tasks:enableEmrServicePolicyV2": true,
48
+ "@aws-cdk/aws-ec2:restrictDefaultSecurityGroup": true,
49
+ "@aws-cdk/aws-apigateway:requestValidatorUniqueId": true,
50
+ "@aws-cdk/aws-kms:aliasNameRef": true,
51
+ "@aws-cdk/aws-autoscaling:generateLaunchTemplateInsteadOfLaunchConfig": true,
52
+ "@aws-cdk/core:includePrefixInUniqueNameGeneration": true,
53
+ "@aws-cdk/aws-efs:denyAnonymousAccess": true,
54
+ "@aws-cdk/aws-opensearchservice:enableOpensearchMultiAzWithStandby": true,
55
+ "@aws-cdk/aws-lambda-nodejs:useLatestRuntimeVersion": true,
56
+ "@aws-cdk/aws-efs:mountTargetOrderInsensitiveLogicalId": true,
57
+ "@aws-cdk/aws-rds:auroraClusterChangeScopeOfInstanceParameterGroupWithEachParameters": true,
58
+ "@aws-cdk/aws-appsync:useArnForSourceApiAssociationIdentifier": true,
59
+ "@aws-cdk/aws-rds:preventRenderingDeprecatedCredentials": true,
60
+ "@aws-cdk/aws-codepipeline-actions:useNewDefaultBranchForCodeCommitSource": true,
61
+ "@aws-cdk/aws-cloudwatch-actions:changeLambdaPermissionLogicalIdForLambdaAction": true,
62
+ "@aws-cdk/aws-codepipeline:crossAccountKeysDefaultValueToFalse": true,
63
+ "@aws-cdk/aws-codepipeline:defaultPipelineTypeToV2": true,
64
+ "@aws-cdk/aws-kms:reduceCrossAccountRegionPolicyScope": true,
65
+ "@aws-cdk/aws-eks:nodegroupNameAttribute": true,
66
+ "@aws-cdk/aws-ec2:ebsDefaultGp3Volume": true,
67
+ "@aws-cdk/aws-ecs:removeDefaultDeploymentAlarm": true,
68
+ "@aws-cdk/custom-resources:logApiResponseDataPropertyTrueDefault": false,
69
+ "@aws-cdk/aws-s3:keepNotificationInImportedBucket": false,
70
+ "@aws-cdk/aws-ecs:reduceEc2FargateCloudWatchPermissions": true,
71
+ "@aws-cdk/aws-dynamodb:resourcePolicyPerReplica": true,
72
+ "@aws-cdk/aws-ec2:ec2SumTImeoutEnabled": true,
73
+ "@aws-cdk/aws-appsync:appSyncGraphQLAPIScopeLambdaPermission": true,
74
+ "@aws-cdk/aws-rds:setCorrectValueForDatabaseInstanceReadReplicaInstanceResourceId": true,
75
+ "@aws-cdk/core:cfnIncludeRejectComplexResourceUpdateCreatePolicyIntrinsics": true,
76
+ "@aws-cdk/aws-lambda-nodejs:sdkV3ExcludeSmithyPackages": true,
77
+ "@aws-cdk/aws-stepfunctions-tasks:fixRunEcsTaskPolicy": true
78
+ }
79
+ };
80
+ }
@@ -0,0 +1,10 @@
1
+ type GetInfraFileParams = {
2
+ app: string;
3
+ domain?: string;
4
+ };
5
+ export declare function getInfra(params: GetInfraFileParams): {
6
+ infraFile: string;
7
+ cdkJsonFile: string;
8
+ };
9
+ export {};
10
+ //# sourceMappingURL=get-infra.js.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-infra.js.d.ts","sourceRoot":"","sources":["../../../src/commands/assets/get-infra.js.ts"],"names":[],"mappings":"AAEA,KAAK,kBAAkB,GAAG;IACxB,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,wBAAgB,QAAQ,CAAC,MAAM,EAAE,kBAAkB;;;EAyClD"}
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getInfra = getInfra;
4
+ const get_cdk_json_1 = require("./get-cdk-json");
5
+ function getInfra(params) {
6
+ const infraFile = `#!/usr/bin/env node
7
+ const cdk = require("aws-cdk-lib");
8
+ const { FullStackConstruct, AppType } = require("@fy-stack/fullstack-construct");
9
+
10
+ const env = {
11
+ account: process.env.CDK_DEFAULT_ACCOUNT,
12
+ region: process.env.CDK_DEFAULT_REGION
13
+ };
14
+
15
+ const environment = process.env.ENVIRONMENT
16
+ if (!environment) throw new Error("ENVIRONMENT is required");
17
+
18
+ class AppStack extends cdk.Stack {
19
+ constructor(scope, id, props) {
20
+ super(scope, id, props);
21
+
22
+ ${params.domain ? `const domainName = ${params.domain}` : ''}
23
+
24
+ const app = new FullStackConstruct(this, "App", {
25
+ storage: { retainOnDelete: false },
26
+ apps: {}
27
+ });
28
+
29
+ cdk.Tags.of(this).add("App", "${params.app}");
30
+ }
31
+ }
32
+
33
+ const app = new cdk.App();
34
+ new AppStack(
35
+ app,
36
+ "app",
37
+ { env, stackName: \`${params.app}-\${process.env.ENVIRONMENT}\` }
38
+ );`;
39
+ const cdkJsonFile = JSON.stringify((0, get_cdk_json_1.getCdkJson)({
40
+ command: 'node infra.js',
41
+ }), null, 2);
42
+ return { infraFile, cdkJsonFile };
43
+ }
@@ -0,0 +1,8 @@
1
+ type GetYamlFileProps = {
2
+ app: string;
3
+ roleArn: string;
4
+ region: string;
5
+ };
6
+ export declare function getYAMLFile(props: GetYamlFileProps): string;
7
+ export {};
8
+ //# sourceMappingURL=get-yaml-file.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-yaml-file.d.ts","sourceRoot":"","sources":["../../../src/commands/assets/get-yaml-file.ts"],"names":[],"mappings":"AAAA,KAAK,gBAAgB,GAAG;IACtB,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,wBAAgB,WAAW,CAAC,KAAK,EAAE,gBAAgB,UA4ClD"}
@@ -0,0 +1,48 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getYAMLFile = getYAMLFile;
4
+ function getYAMLFile(props) {
5
+ return `# Run on push to branch
6
+ name: Build and Deploy
7
+
8
+ on:
9
+ push:
10
+ branches:
11
+ - main
12
+ # add additional branch names if needed
13
+
14
+ permissions:
15
+ id-token: write
16
+ contents: read
17
+
18
+ jobs:
19
+ deploy:
20
+ environment: \${{ (github.ref_name == 'main' && 'production') }}
21
+ env:
22
+ STACK_NAME: \${{ format('${props.app}-{0}', (github.head_ref || github.ref_name)) }}
23
+ ENVIRONMENT: \${{ (github.ref_name == 'main' && 'production') || github.ref_name }}
24
+
25
+ runs-on: ubuntu-latest
26
+ steps:
27
+ - name: Checkout code
28
+ uses: actions/checkout@v4
29
+
30
+ # setup aws credentials using aws role and region
31
+ - name: Configure AWS Credentials
32
+ uses: aws-actions/configure-aws-credentials@v4
33
+ with:
34
+ role-skip-session-tagging: true
35
+ role-to-assume: ${props.roleArn}
36
+ aws-region: ${props.region}
37
+
38
+ - name: Set up Node.js
39
+ uses: actions/setup-node@v4
40
+ with:
41
+ node-version: 18
42
+
43
+ - name: Install dependencies
44
+ run: npm ci
45
+
46
+ - name: Deploy Apps
47
+ run: npx cdk deploy --require-approval never`;
48
+ }
@@ -0,0 +1,12 @@
1
+ import { Construct } from 'constructs';
2
+ type GithubAwsConstructProps = {
3
+ /**
4
+ * Github repo name e.t.c. GitHubOrg/GitHubRepo:ref:refs/heads/GitHubBranch
5
+ * */
6
+ repo: string;
7
+ };
8
+ export declare class GithubAwsConstruct extends Construct {
9
+ constructor(scope: Construct, id: string, props: GithubAwsConstructProps);
10
+ }
11
+ export {};
12
+ //# sourceMappingURL=github-aws-construct.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"github-aws-construct.d.ts","sourceRoot":"","sources":["../../src/commands/github-aws-construct.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAGvC,KAAK,uBAAuB,GAAG;IAC7B;;SAEK;IACL,IAAI,EAAE,MAAM,CAAA;CACb,CAAA;AAED,qBAAa,kBAAmB,SAAQ,SAAS;gBAEnC,KAAK,EAAE,SAAS,EAAE,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,uBAAuB;CA0BzE"}
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.GithubAwsConstruct = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const iam = tslib_1.__importStar(require("aws-cdk-lib/aws-iam"));
6
+ const constructs_1 = require("constructs");
7
+ const aws_cdk_lib_1 = require("aws-cdk-lib");
8
+ class GithubAwsConstruct extends constructs_1.Construct {
9
+ constructor(scope, id, props) {
10
+ super(scope, id);
11
+ const provider = new iam.OpenIdConnectProvider(this, 'GithubProvider', {
12
+ url: 'https://token.actions.githubusercontent.com',
13
+ clientIds: ['sts.amazonaws.com']
14
+ });
15
+ const role = new iam.Role(this, 'GithubRole', {
16
+ assumedBy: new iam.FederatedPrincipal(provider.openIdConnectProviderArn, {
17
+ StringEquals: {
18
+ "token.actions.githubusercontent.com:aud": "sts.amazonaws.com",
19
+ "token.actions.githubusercontent.com:sub": `repo:${props.repo}`
20
+ }
21
+ }, "sts:AssumeRoleWithWebIdentity"),
22
+ });
23
+ new aws_cdk_lib_1.CfnOutput(this, 'RoleArn', {
24
+ key: 'roleArn',
25
+ value: role.roleArn
26
+ });
27
+ }
28
+ }
29
+ exports.GithubAwsConstruct = GithubAwsConstruct;
@@ -0,0 +1,13 @@
1
+ import { Construct } from 'constructs';
2
+ import { Stack, StackProps } from 'aws-cdk-lib';
3
+ type GithubAwsConstructProps = StackProps & {
4
+ /**
5
+ * Github repo name e.t.c. GitHubOrg/GitHubRepo:ref:refs/heads/GitHubBranch
6
+ * */
7
+ repo: string;
8
+ };
9
+ export declare class GithubAwsStack extends Stack {
10
+ constructor(scope: Construct, id: string, props: GithubAwsConstructProps);
11
+ }
12
+ export {};
13
+ //# sourceMappingURL=github-aws-stack.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"github-aws-stack.d.ts","sourceRoot":"","sources":["../../src/commands/github-aws-stack.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACvC,OAAO,EAAa,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAE3D,KAAK,uBAAuB,GAAG,UAAU,GAAG;IAC1C;;SAEK;IACL,IAAI,EAAE,MAAM,CAAA;CACb,CAAA;AAED,qBAAa,cAAe,SAAQ,KAAK;gBAE3B,KAAK,EAAE,SAAS,EAAE,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,uBAAuB;CA0BzE"}
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.GithubAwsStack = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const iam = tslib_1.__importStar(require("aws-cdk-lib/aws-iam"));
6
+ const aws_cdk_lib_1 = require("aws-cdk-lib");
7
+ class GithubAwsStack extends aws_cdk_lib_1.Stack {
8
+ constructor(scope, id, props) {
9
+ super(scope, id, props);
10
+ const provider = new iam.OpenIdConnectProvider(this, 'GithubProvider', {
11
+ url: 'https://token.actions.githubusercontent.com',
12
+ clientIds: ['sts.amazonaws.com']
13
+ });
14
+ const role = new iam.Role(this, 'GithubRole', {
15
+ assumedBy: new iam.FederatedPrincipal(provider.openIdConnectProviderArn, {
16
+ StringEquals: {
17
+ "token.actions.githubusercontent.com:aud": "sts.amazonaws.com",
18
+ "token.actions.githubusercontent.com:sub": `repo:${props.repo}`
19
+ }
20
+ }, "sts:AssumeRoleWithWebIdentity"),
21
+ });
22
+ new aws_cdk_lib_1.CfnOutput(this, 'RoleArn', {
23
+ key: 'roleArn',
24
+ value: role.roleArn
25
+ });
26
+ }
27
+ }
28
+ exports.GithubAwsStack = GithubAwsStack;
@@ -0,0 +1,3 @@
1
+ import { InitAppProps } from './types';
2
+ export declare function initApp(props: InitAppProps): Promise<void>;
3
+ //# sourceMappingURL=init-app.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"init-app.d.ts","sourceRoot":"","sources":["../../src/commands/init-app.ts"],"names":[],"mappings":"AAuBA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAavC,wBAAsB,OAAO,CAAC,KAAK,EAAE,YAAY,iBA4JhD"}
@@ -0,0 +1,150 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.initApp = initApp;
4
+ const tslib_1 = require("tslib");
5
+ const fs = tslib_1.__importStar(require("node:fs"));
6
+ const path = tslib_1.__importStar(require("node:path"));
7
+ const client_iam_1 = require("@aws-sdk/client-iam");
8
+ const client_sts_1 = require("@aws-sdk/client-sts");
9
+ const get_infra_js_1 = require("./assets/get-infra.js");
10
+ const get_yaml_file_1 = require("./assets/get-yaml-file");
11
+ const iamClient = new client_iam_1.IAMClient();
12
+ async function attachManagedPolicies(roleName, attachedPolices) {
13
+ for (const policy of attachedPolices ?? []) {
14
+ await iamClient.send(new client_iam_1.AttachRolePolicyCommand({
15
+ PolicyArn: policy.PolicyArn,
16
+ RoleName: roleName
17
+ }));
18
+ }
19
+ }
20
+ async function initApp(props) {
21
+ const stsClient = new client_sts_1.STSClient();
22
+ const user = await stsClient.send(new client_sts_1.GetCallerIdentityCommand());
23
+ const username = user.Arn?.split("/").pop();
24
+ if (!username)
25
+ throw new Error("username not found");
26
+ const isRoot = username.endsWith(":root");
27
+ const workingDir = process.cwd();
28
+ if (props.githubRepo) {
29
+ const githubFolderPath = path.join(workingDir, '.github/workflows/');
30
+ if (!fs.existsSync(githubFolderPath))
31
+ fs.mkdirSync(githubFolderPath, { recursive: true });
32
+ const deployYamlPath = path.join(githubFolderPath, "fy-stack.deploy.yml");
33
+ if (fs.existsSync(deployYamlPath))
34
+ throw new Error("fy-stack.deploy.yml already exists");
35
+ const existingRes = await iamClient.send(new client_iam_1.ListOpenIDConnectProvidersCommand());
36
+ let idProviderArn;
37
+ const providerUrl = 'token.actions.githubusercontent.com';
38
+ for (const i in existingRes.OpenIDConnectProviderList ?? []) {
39
+ const provider = await iamClient.send(new client_iam_1.GetOpenIDConnectProviderCommand({
40
+ OpenIDConnectProviderArn: existingRes.OpenIDConnectProviderList?.[i].Arn
41
+ }));
42
+ if (provider.Url === providerUrl) {
43
+ idProviderArn = existingRes.OpenIDConnectProviderList?.[i].Arn;
44
+ break;
45
+ }
46
+ }
47
+ if (!idProviderArn) {
48
+ const idProviderRes = await iamClient.send(new client_iam_1.CreateOpenIDConnectProviderCommand({
49
+ Url: providerUrl,
50
+ ClientIDList: ['sts.amazonaws.com']
51
+ }));
52
+ if (!idProviderRes.OpenIDConnectProviderArn)
53
+ throw new Error('unable to Github open id provider');
54
+ idProviderArn = idProviderRes.OpenIDConnectProviderArn;
55
+ }
56
+ const roleRes = await iamClient.send(new client_iam_1.CreateRoleCommand({
57
+ RoleName: `${props.app}GithubRole`,
58
+ AssumeRolePolicyDocument: JSON.stringify({
59
+ Version: "2012-10-17",
60
+ Statement: [{
61
+ Effect: "Allow",
62
+ Principal: { Federated: idProviderArn },
63
+ Action: "sts:AssumeRoleWithWebIdentity",
64
+ Condition: {
65
+ StringEquals: { "token.actions.githubusercontent.com:aud": "sts.amazonaws.com" },
66
+ StringLike: { "token.actions.githubusercontent.com:sub": `repo:${props.githubRepo}:*` }
67
+ }
68
+ }]
69
+ }),
70
+ }));
71
+ if (!roleRes.Role?.Arn || !roleRes.Role.RoleName)
72
+ throw new Error('unable to Github role');
73
+ const roleName = roleRes.Role.RoleName;
74
+ if (isRoot) {
75
+ await iamClient.send(new client_iam_1.AttachRolePolicyCommand({
76
+ PolicyArn: 'arn:aws:iam::aws:policy/AdministratorAccess',
77
+ RoleName: roleRes.Role.RoleName
78
+ }));
79
+ }
80
+ else {
81
+ // attach managed polices
82
+ const attachedPolices = await iamClient.send(new client_iam_1.ListAttachedUserPoliciesCommand({
83
+ UserName: username
84
+ }));
85
+ await attachManagedPolicies(roleName, attachedPolices.AttachedPolicies);
86
+ // attach inline polices
87
+ const inlinePolices = await iamClient.send(new client_iam_1.ListUserPoliciesCommand({
88
+ UserName: username
89
+ }));
90
+ for (const policyName of inlinePolices.PolicyNames ?? []) {
91
+ const policyDocument = await iamClient.send(new client_iam_1.GetUserPolicyCommand({ UserName: username, PolicyName: policyName }));
92
+ await iamClient.send(new client_iam_1.PutRolePolicyCommand({
93
+ PolicyName: policyName,
94
+ PolicyDocument: policyDocument.PolicyDocument,
95
+ RoleName: roleRes.Role.RoleName
96
+ }));
97
+ }
98
+ const groups = await iamClient.send(new client_iam_1.ListGroupsForUserCommand({
99
+ UserName: username
100
+ }));
101
+ for (const group of groups.Groups ?? []) {
102
+ // attach managed polices
103
+ const attachedPolices = await iamClient.send(new client_iam_1.ListAttachedGroupPoliciesCommand({
104
+ GroupName: group.GroupName
105
+ }));
106
+ await attachManagedPolicies(roleName, attachedPolices.AttachedPolicies);
107
+ // attach inline polices
108
+ const inlinePolices = await iamClient.send(new client_iam_1.ListGroupPoliciesCommand({
109
+ GroupName: group.GroupName
110
+ }));
111
+ for (const policyName of inlinePolices.PolicyNames ?? []) {
112
+ const policyDocument = await iamClient.send(new client_iam_1.GetUserPolicyCommand({ UserName: username, PolicyName: policyName }));
113
+ await iamClient.send(new client_iam_1.PutRolePolicyCommand({
114
+ PolicyName: policyName,
115
+ PolicyDocument: policyDocument.PolicyDocument,
116
+ RoleName: roleRes.Role.RoleName
117
+ }));
118
+ }
119
+ }
120
+ }
121
+ const yamlFile = (0, get_yaml_file_1.getYAMLFile)({ ...props, roleArn: roleRes.Role.Arn, region: await stsClient.config.region() });
122
+ fs.writeFileSync(deployYamlPath, yamlFile);
123
+ }
124
+ const { infraFile, cdkJsonFile } = (0, get_infra_js_1.getInfra)({
125
+ app: props.app,
126
+ domain: props.domainName
127
+ ? `process.env.ENVIRONMENT === "production" ? "${props.domainName}" : \`\${process.env.ENVIRONMENT}.${props.domainName}\``
128
+ : undefined
129
+ });
130
+ const packageJsonPath = path.join(workingDir, 'package.json');
131
+ const infraPath = path.join(workingDir, 'infra.js');
132
+ const cdkPath = path.join(workingDir, 'cdk.json');
133
+ if (!fs.existsSync(packageJsonPath))
134
+ throw new Error('unable to find package.json file');
135
+ if (fs.existsSync(infraPath))
136
+ throw new Error('infra.js file already exists');
137
+ const packageJsonFile = JSON.parse(fs.readFileSync(path.join(workingDir, 'package.json'), "utf8"));
138
+ packageJsonFile["devDependencies"] = {
139
+ ...packageJsonFile["devDependencies"],
140
+ "aws-cdk": "^2.174.1",
141
+ "aws-cdk-lib": "^2.174.1",
142
+ "constructs": "^10.4.2",
143
+ "@fy-stack/fullstack-construct": "^0.0.131"
144
+ };
145
+ if (!fs.existsSync(cdkPath))
146
+ fs.writeFileSync(cdkPath, cdkJsonFile);
147
+ fs.writeFileSync(packageJsonPath, JSON.stringify(packageJsonFile, null, 2));
148
+ fs.writeFileSync(infraPath, infraFile);
149
+ console.log("App initialized, run npm install to complete");
150
+ }
@@ -0,0 +1,6 @@
1
+ export type InitAppProps = {
2
+ app: string;
3
+ githubRepo?: string;
4
+ domainName?: string;
5
+ };
6
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/commands/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,YAAY,GAAG;IACzB,GAAG,EAAE,MAAM,CAAA;IACX,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,UAAU,CAAC,EAAE,MAAM,CAAA;CACpB,CAAA"}
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ export {};
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":""}
package/dist/index.js ADDED
@@ -0,0 +1,31 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ const prompts_1 = require("@inquirer/prompts");
5
+ const commander_1 = require("commander");
6
+ const init_app_1 = require("./commands/init-app");
7
+ commander_1.program
8
+ .name('fy-stack') // The command users will type
9
+ .version('1.0.0')
10
+ .description('My awesome CLI app')
11
+ .action(() => {
12
+ console.log('Hello from my CLI app!');
13
+ });
14
+ commander_1.program
15
+ .command("init")
16
+ .description("Initialize application infrastructure")
17
+ .requiredOption("-a --app <string>", "Application name")
18
+ .action(async (params) => {
19
+ let githubRepo;
20
+ const setupGitHub = await (0, prompts_1.confirm)({ message: "Setup github deployment", default: true });
21
+ if (setupGitHub) {
22
+ githubRepo = await (0, prompts_1.input)({
23
+ message: "Enter repository full name (e.g. Org/repository)",
24
+ required: true,
25
+ validate: (v) => v.length > 0,
26
+ });
27
+ }
28
+ const domainName = await (0, prompts_1.input)({ message: "Enter domain name (leave blank if none)", required: false });
29
+ return (0, init_app_1.initApp)({ ...params, githubRepo, domainName });
30
+ });
31
+ commander_1.program.parse();
package/package.json ADDED
@@ -0,0 +1,24 @@
1
+ {
2
+ "name": "@fy-stack/cli",
3
+ "version": "0.0.131",
4
+ "dependencies": {
5
+ "@aws-sdk/client-iam": "^3.731.1",
6
+ "@aws-sdk/client-sts": "^3.731.1",
7
+ "@inquirer/prompts": "^7.2.3",
8
+ "commander": "^13.0.0",
9
+ "tslib": "^2.3.0"
10
+ },
11
+ "type": "commonjs",
12
+ "main": "./dist/index.js",
13
+ "typings": "./dist/index.d.ts",
14
+ "files": [
15
+ "dist",
16
+ "!**/*.tsbuildinfo"
17
+ ],
18
+ "nx": {
19
+ "name": "cli"
20
+ },
21
+ "bin": {
22
+ "fy-stack": "./dist/index.js"
23
+ }
24
+ }