@fy-stack/cli 0.0.142 → 0.0.144

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.
@@ -1 +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"}
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;;;EA4DlD"}
@@ -6,6 +6,7 @@ function getInfra(params) {
6
6
  const infraFile = `#!/usr/bin/env node
7
7
  const cdk = require("aws-cdk-lib");
8
8
  const { FullStackConstruct, AppType } = require("@fy-stack/fullstack-construct");
9
+ const { STSClient, GetCallerIdentityCommand } = require('@aws-sdk/client-sts');
9
10
 
10
11
  const env = {
11
12
  account: process.env.CDK_DEFAULT_ACCOUNT,
@@ -15,27 +16,40 @@ const env = {
15
16
  const environment = process.env.ENVIRONMENT
16
17
  if (!environment) throw new Error("ENVIRONMENT is required");
17
18
 
19
+ const appName = ${params.app}
20
+
18
21
  class AppStack extends cdk.Stack {
19
22
  constructor(scope, id, props) {
20
23
  super(scope, id, props);
21
24
 
22
- ${params.domain ? `const domainName = ${params.domain}` : ''}
25
+ ${params.domain
26
+ ? `const domainName = environment === 'production' ? ${params.domain} : \`\${environment}.${params.domain}\``
27
+ : ''}
23
28
 
24
29
  const app = new FullStackConstruct(this, "App", {
30
+ environment,
31
+ name: \${appName},
32
+ ownerArn: props.ownerArn,
25
33
  storage: { retainOnDelete: false },
26
34
  apps: {}
27
35
  });
28
-
29
- cdk.Tags.of(this).add("App", "${params.app}");
30
36
  }
31
37
  }
32
38
 
33
- const app = new cdk.App();
34
- new AppStack(
35
- app,
36
- "app",
37
- { env, stackName: \`${params.app}-\${process.env.ENVIRONMENT}\` }
38
- );`;
39
+ (async () => {
40
+ const sts = new STSClient();
41
+ const res = await sts.send(new GetCallerIdentityCommand());
42
+ if (!res.Arn) throw new Error('caller not found');
43
+
44
+ const app = new cdk.App();
45
+ const stackName = \`\${appName}-\${environment}\`;
46
+
47
+ new AppStack(app, stackName, {
48
+ env,
49
+ stackName,
50
+ ownerArn: res.Arn,
51
+ });
52
+ })();`;
39
53
  const cdkJsonFile = JSON.stringify((0, get_cdk_json_1.getCdkJson)({
40
54
  command: 'node infra.js',
41
55
  }), null, 2);
@@ -1 +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,iBA+JhD"}
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,iBAgKhD"}
@@ -141,10 +141,11 @@ async function initApp(props) {
141
141
  const packageJsonFile = JSON.parse(fs.readFileSync(path.join(workingDir, 'package.json'), "utf8"));
142
142
  packageJsonFile["devDependencies"] = {
143
143
  ...packageJsonFile["devDependencies"],
144
- "aws-cdk": "^2.174.1",
145
- "aws-cdk-lib": "^2.174.1",
144
+ "aws-cdk": "^2.1016.1",
145
+ "aws-cdk-lib": "^2.198.0",
146
+ "@aws-sdk/client-sts": "^3.799.0",
146
147
  "constructs": "^10.4.2",
147
- "@fy-stack/fullstack-construct": "^0.0.142"
148
+ "@fy-stack/fullstack-construct": "^0.0.144"
148
149
  };
149
150
  if (!fs.existsSync(cdkPath))
150
151
  fs.writeFileSync(cdkPath, cdkJsonFile);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fy-stack/cli",
3
- "version": "0.0.142",
3
+ "version": "0.0.144",
4
4
  "dependencies": {
5
5
  "@aws-sdk/client-iam": "^3.731.1",
6
6
  "@aws-sdk/client-sts": "^3.731.1",