@granite-js/forge-cli 0.1.0 → 0.1.1

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/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @granite-js/forge-cli
2
2
 
3
+ ## 0.1.1
4
+
5
+ ### Patch Changes
6
+
7
+ - d675415: Improve scaffolding to provide a better showcase UI
8
+ - 7f0afd4: Updated forge-cli to support reading AWS configuration files when available, instead of relying solely on environment variables.
9
+ - 10a5f3f: empty
10
+ - Updated dependencies [d675415]
11
+ - Updated dependencies [10a5f3f]
12
+ - @granite-js/deployment-manager@0.1.1
13
+ - @granite-js/cli@0.1.1
14
+
3
15
  ## 0.1.0
4
16
 
5
17
  ### Minor Changes
package/dist/index.js CHANGED
@@ -1,5 +1,7 @@
1
1
  import { Command } from "@commander-js/extra-typings";
2
2
  import path from "path";
3
+ import { fromNodeProviderChain } from "@aws-sdk/credential-providers";
4
+ import { loadSharedConfigFiles } from "@aws-sdk/shared-ini-file-loader";
3
5
  import * as p$3 from "@clack/prompts";
4
6
  import * as p$2 from "@clack/prompts";
5
7
  import * as p$1 from "@clack/prompts";
@@ -150,14 +152,19 @@ const envSchema = v.object({
150
152
  AWS_SECRET_ACCESS_KEY: v.string(),
151
153
  AWS_SESSION_TOKEN: v.optional(v.string())
152
154
  });
155
+ const awsCredentialsProvider = fromNodeProviderChain();
153
156
  function deploy() {
154
157
  return new Command("deploy").description("Deploy a Granite application").requiredOption("--bucket <BUCKET>", "AWS bucket").action(async (options) => {
155
- const config = await loadConfig();
158
+ const [config, awsCredentials, region] = await Promise.all([
159
+ loadConfig(),
160
+ awsCredentialsProvider(),
161
+ getRegion()
162
+ ]);
156
163
  const envResult = v.safeParse(envSchema, {
157
- AWS_REGION: process.env.AWS_REGION,
158
- AWS_ACCESS_KEY_ID: process.env.AWS_ACCESS_KEY_ID,
159
- AWS_SECRET_ACCESS_KEY: process.env.AWS_SECRET_ACCESS_KEY,
160
- AWS_SESSION_TOKEN: process.env.AWS_SESSION_TOKEN
164
+ AWS_REGION: region,
165
+ AWS_ACCESS_KEY_ID: awsCredentials.accessKeyId,
166
+ AWS_SECRET_ACCESS_KEY: awsCredentials.secretAccessKey,
167
+ AWS_SESSION_TOKEN: awsCredentials.sessionToken
161
168
  });
162
169
  if (!envResult.success) {
163
170
  const missingVars = envResult.issues.map((issue) => {
@@ -173,7 +180,7 @@ function deploy() {
173
180
  iosBundle: path.join(config.outdir, `bundle.ios.hbc`),
174
181
  androidBundle: path.join(config.outdir, `bundle.android.hbc`)
175
182
  }, { s3Client: new S3Client({
176
- region: envResult.output.AWS_REGION,
183
+ region,
177
184
  bucket: options.bucket,
178
185
  credentials: {
179
186
  accessKeyId: envResult.output.AWS_ACCESS_KEY_ID,
@@ -183,6 +190,18 @@ function deploy() {
183
190
  }) });
184
191
  });
185
192
  }
193
+ async function getRegion() {
194
+ const { configFile } = await loadSharedConfigFiles();
195
+ const envRegion = process.env.AWS_REGION;
196
+ if (envRegion != null) return envRegion;
197
+ const currentProfile = process.env.AWS_PROFILE;
198
+ if (currentProfile != null) {
199
+ const region = configFile?.[currentProfile]?.region;
200
+ if (region != null) return region;
201
+ }
202
+ const defaultRegion = configFile.default?.region;
203
+ return defaultRegion;
204
+ }
186
205
 
187
206
  //#endregion
188
207
  //#region src/helpers/command.ts
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@granite-js/forge-cli",
3
3
  "description": "A CLI tool for managing Granite applications",
4
4
  "type": "module",
5
- "version": "0.1.0",
5
+ "version": "0.1.1",
6
6
  "bin": {
7
7
  "granite-forge": "./bin/index.js"
8
8
  },
@@ -24,10 +24,12 @@
24
24
  "vitest": "^3.1.4"
25
25
  },
26
26
  "dependencies": {
27
+ "@aws-sdk/credential-providers": "^3.817.0",
28
+ "@aws-sdk/shared-ini-file-loader": "^3.374.0",
27
29
  "@clack/prompts": "^0.10.1",
28
30
  "@commander-js/extra-typings": "^14.0.0",
29
- "@granite-js/cli": "0.1.0",
30
- "@granite-js/deployment-manager": "0.1.0",
31
+ "@granite-js/cli": "0.1.1",
32
+ "@granite-js/deployment-manager": "0.1.1",
31
33
  "commander": "^14.0.0",
32
34
  "uuid": "^11.1.0",
33
35
  "valibot": "^1.1.0"