From a4e31ab918190cfefc2282073a3719a361af65f6 Mon Sep 17 00:00:00 2001 From: Gergely Varga Date: Tue, 31 Oct 2023 17:31:46 +0800 Subject: [PATCH] fix(galileo-cli): handle outdated aws creds error; fix eslint-staged --- .projen/tasks.json | 2 +- demo/api/generated/runtime/python/poetry.lock | 2 +- .../typescript/.projen/tasks.json | 2 +- demo/corpus/embeddings/poetry.lock | 4 ++-- demo/corpus/logic/.projen/tasks.json | 2 +- demo/infra/.projen/tasks.json | 2 +- demo/sample-dataset/.projen/tasks.json | 2 +- demo/website/.projen/tasks.json | 2 +- packages/galileo-cdk/.projen/tasks.json | 2 +- packages/galileo-cli/.projen/deps.json | 4 ++++ packages/galileo-cli/.projen/tasks.json | 6 +++--- packages/galileo-cli/bin/galileo-cli.ts | 11 +++++++++++ .../examples/csv-loader/parser-common.ts | 1 + packages/galileo-cli/package.json | 1 + packages/galileo-cli/tsconfig.dev.json | 4 ++-- packages/galileo-cli/tsconfig.json | 4 ++-- packages/galileo-sdk/.projen/tasks.json | 2 +- pnpm-lock.yaml | 19 +++++++------------ projenrc/framework/galileo-cli.ts | 5 +++-- projenrc/monorepo.ts | 2 +- 20 files changed, 46 insertions(+), 33 deletions(-) diff --git a/.projen/tasks.json b/.projen/tasks.json index f1b581b4..969108df 100644 --- a/.projen/tasks.json +++ b/.projen/tasks.json @@ -152,7 +152,7 @@ "description": "Run eslint against the staged files only", "steps": [ { - "exec": "eslint --fix --no-error-on-unmatched-pattern $(git diff --name-only --relative --staged HEAD . | grep -E '^(.*/)?(projenrc|bin|scripts)/.*.(ts|tsx)$' | xargs)" + "exec": "eslint --fix --no-error-on-unmatched-pattern $(git diff --name-only --relative --staged HEAD . | grep -E '^(projenrc|bin|scripts)/.*.(ts|tsx)$' | xargs)" } ] }, diff --git a/demo/api/generated/runtime/python/poetry.lock b/demo/api/generated/runtime/python/poetry.lock index 02b6b1af..c76b2309 100644 --- a/demo/api/generated/runtime/python/poetry.lock +++ b/demo/api/generated/runtime/python/poetry.lock @@ -1,4 +1,4 @@ -# This file is automatically @generated by Poetry 1.5.1 and should not be changed by hand. +# This file is automatically @generated by Poetry 1.6.1 and should not be changed by hand. [[package]] name = "aenum" diff --git a/demo/api/interceptors/typescript/.projen/tasks.json b/demo/api/interceptors/typescript/.projen/tasks.json index de2a6416..a13adaeb 100644 --- a/demo/api/interceptors/typescript/.projen/tasks.json +++ b/demo/api/interceptors/typescript/.projen/tasks.json @@ -49,7 +49,7 @@ "description": "Run eslint against the staged files only", "steps": [ { - "exec": "eslint --fix --no-error-on-unmatched-pattern $(git diff --name-only --relative --staged HEAD . | grep -E '^(.*/)?(src|test)/.*.(ts|tsx)$' | xargs)" + "exec": "eslint --fix --no-error-on-unmatched-pattern $(git diff --name-only --relative --staged HEAD . | grep -E '^(src|test)/.*.(ts|tsx)$' | xargs)" } ] }, diff --git a/demo/corpus/embeddings/poetry.lock b/demo/corpus/embeddings/poetry.lock index cb16608c..8de8926b 100644 --- a/demo/corpus/embeddings/poetry.lock +++ b/demo/corpus/embeddings/poetry.lock @@ -353,12 +353,12 @@ files = [ [[package]] name = "lit" -version = "17.0.3" +version = "17.0.4" description = "A Software Testing Tool" optional = false python-versions = "*" files = [ - {file = "lit-17.0.3.tar.gz", hash = "sha256:e6049032462be1e2928686cbd4a6cc5b3c545d83ecd078737fe79412c1f3fcc1"}, + {file = "lit-17.0.4.tar.gz", hash = "sha256:ee2e180128e770abc6aed3a02de2daf09d81b7d30225e315205d3599c311d304"}, ] [[package]] diff --git a/demo/corpus/logic/.projen/tasks.json b/demo/corpus/logic/.projen/tasks.json index cd8825eb..404da226 100644 --- a/demo/corpus/logic/.projen/tasks.json +++ b/demo/corpus/logic/.projen/tasks.json @@ -66,7 +66,7 @@ "description": "Run eslint against the staged files only", "steps": [ { - "exec": "eslint --fix --no-error-on-unmatched-pattern $(git diff --name-only --relative --staged HEAD . | grep -E '^(.*/)?(src|test)/.*.(ts|tsx)$' | xargs)" + "exec": "eslint --fix --no-error-on-unmatched-pattern $(git diff --name-only --relative --staged HEAD . | grep -E '^(src|test)/.*.(ts|tsx)$' | xargs)" } ] }, diff --git a/demo/infra/.projen/tasks.json b/demo/infra/.projen/tasks.json index d61d2b30..824fc8ba 100644 --- a/demo/infra/.projen/tasks.json +++ b/demo/infra/.projen/tasks.json @@ -85,7 +85,7 @@ "description": "Run eslint against the staged files only", "steps": [ { - "exec": "eslint --fix --no-error-on-unmatched-pattern $(git diff --name-only --relative --staged HEAD . | grep -E '^(.*/)?(src|test)/.*.(ts|tsx)$' | xargs)" + "exec": "eslint --fix --no-error-on-unmatched-pattern $(git diff --name-only --relative --staged HEAD . | grep -E '^(src|test)/.*.(ts|tsx)$' | xargs)" } ] }, diff --git a/demo/sample-dataset/.projen/tasks.json b/demo/sample-dataset/.projen/tasks.json index f6d9cd48..a35b4c71 100644 --- a/demo/sample-dataset/.projen/tasks.json +++ b/demo/sample-dataset/.projen/tasks.json @@ -49,7 +49,7 @@ "description": "Run eslint against the staged files only", "steps": [ { - "exec": "eslint --fix --no-error-on-unmatched-pattern $(git diff --name-only --relative --staged HEAD . | grep -E '^(.*/)?(src|test)/.*.(ts|tsx)$' | xargs)" + "exec": "eslint --fix --no-error-on-unmatched-pattern $(git diff --name-only --relative --staged HEAD . | grep -E '^(src|test)/.*.(ts|tsx)$' | xargs)" } ] }, diff --git a/demo/website/.projen/tasks.json b/demo/website/.projen/tasks.json index 076ce328..ab3ee798 100644 --- a/demo/website/.projen/tasks.json +++ b/demo/website/.projen/tasks.json @@ -62,7 +62,7 @@ "description": "Run eslint against the staged files only", "steps": [ { - "exec": "eslint --fix --no-error-on-unmatched-pattern $(git diff --name-only --relative --staged HEAD . | grep -E '^(.*/)?(src|test)/.*.(ts|tsx)$' | xargs)" + "exec": "eslint --fix --no-error-on-unmatched-pattern $(git diff --name-only --relative --staged HEAD . | grep -E '^(src|test)/.*.(ts|tsx)$' | xargs)" } ] }, diff --git a/packages/galileo-cdk/.projen/tasks.json b/packages/galileo-cdk/.projen/tasks.json index 5118ccb8..9621b5f4 100644 --- a/packages/galileo-cdk/.projen/tasks.json +++ b/packages/galileo-cdk/.projen/tasks.json @@ -192,7 +192,7 @@ "description": "Run eslint against the staged files only", "steps": [ { - "exec": "eslint --fix --no-error-on-unmatched-pattern $(git diff --name-only --relative --staged HEAD . | grep -E '^(.*/)?(src|test)/.*.(ts|tsx)$' | xargs)" + "exec": "eslint --fix --no-error-on-unmatched-pattern $(git diff --name-only --relative --staged HEAD . | grep -E '^(src|test)/.*.(ts|tsx)$' | xargs)" } ] }, diff --git a/packages/galileo-cli/.projen/deps.json b/packages/galileo-cli/.projen/deps.json index 55ed1e49..7eaa1195 100644 --- a/packages/galileo-cli/.projen/deps.json +++ b/packages/galileo-cli/.projen/deps.json @@ -198,6 +198,10 @@ "name": "@oclif/plugin-warn-if-update-available", "type": "runtime" }, + { + "name": "@smithy/property-provider", + "type": "runtime" + }, { "name": "chalk", "version": "^4", diff --git a/packages/galileo-cli/.projen/tasks.json b/packages/galileo-cli/.projen/tasks.json index 0a5740df..e877ac4d 100644 --- a/packages/galileo-cli/.projen/tasks.json +++ b/packages/galileo-cli/.projen/tasks.json @@ -37,7 +37,7 @@ "description": "Run eslint against the staged files only", "steps": [ { - "exec": "eslint --fix --no-error-on-unmatched-pattern $(git diff --name-only --relative --staged HEAD . | grep -E '^(.*/)?(src|test)/.*.(ts|tsx)$' | xargs)" + "exec": "eslint --fix --no-error-on-unmatched-pattern $(git diff --name-only --relative --staged HEAD . | grep -E '^(src|test)/.*.(ts|tsx)$' | xargs)" } ] }, @@ -118,13 +118,13 @@ "exec": "pnpm update npm-check-updates" }, { - "exec": "npm-check-updates --upgrade --target=minor --peer --dep=dev,peer,prod,optional --filter=@aws-sdk/types,@oclif/test,@types/chalk,@types/clear,@types/csv-parse,@types/execa,@types/jest,@types/jsonschema,@types/lodash,@types/node-localstorage,@types/node,@types/ora,@types/prompts,@typescript-eslint/eslint-plugin,@typescript-eslint/parser,eslint-config-prettier,eslint-import-resolver-node,eslint-import-resolver-typescript,eslint-plugin-header,eslint-plugin-import,eslint-plugin-prettier,eslint,jest,jest-junit,npm-check-updates,prettier,projen,ts-jest,ts-node,typescript,@aws-sdk/client-cognito-identity-provider,@aws-sdk/client-s3,@aws-sdk/client-sfn,@aws-sdk/client-ssm,@aws-sdk/client-sts,@aws-sdk/credential-providers,@aws-sdk/lib-storage,@oclif/core,@oclif/errors,@oclif/plugin-autocomplete,@oclif/plugin-commands,@oclif/plugin-help,@oclif/plugin-not-found,@oclif/plugin-plugins,@oclif/plugin-update,@oclif/plugin-warn-if-update-available,chalk,clear,csv-parse,execa,figlet,ink,jsonschema,lodash,node-localstorage,ora,prompts" + "exec": "npm-check-updates --upgrade --target=minor --peer --dep=dev,peer,prod,optional --filter=@aws-sdk/types,@oclif/test,@types/chalk,@types/clear,@types/csv-parse,@types/execa,@types/jest,@types/jsonschema,@types/lodash,@types/node-localstorage,@types/node,@types/ora,@types/prompts,@typescript-eslint/eslint-plugin,@typescript-eslint/parser,eslint-config-prettier,eslint-import-resolver-node,eslint-import-resolver-typescript,eslint-plugin-header,eslint-plugin-import,eslint-plugin-prettier,eslint,jest,jest-junit,npm-check-updates,prettier,projen,ts-jest,ts-node,typescript,@aws-sdk/client-cognito-identity-provider,@aws-sdk/client-s3,@aws-sdk/client-sfn,@aws-sdk/client-ssm,@aws-sdk/client-sts,@aws-sdk/credential-providers,@aws-sdk/lib-storage,@oclif/core,@oclif/errors,@oclif/plugin-autocomplete,@oclif/plugin-commands,@oclif/plugin-help,@oclif/plugin-not-found,@oclif/plugin-plugins,@oclif/plugin-update,@oclif/plugin-warn-if-update-available,@smithy/property-provider,chalk,clear,csv-parse,execa,figlet,ink,jsonschema,lodash,node-localstorage,ora,prompts" }, { "exec": "pnpm i --no-frozen-lockfile" }, { - "exec": "pnpm update @aws-sdk/types @oclif/test @types/chalk @types/clear @types/csv-parse @types/execa @types/jest @types/jsonschema @types/lodash @types/node-localstorage @types/node @types/ora @types/prompts @typescript-eslint/eslint-plugin @typescript-eslint/parser eslint-config-prettier eslint-import-resolver-node eslint-import-resolver-typescript eslint-plugin-header eslint-plugin-import eslint-plugin-prettier eslint jest jest-junit npm-check-updates prettier projen ts-jest ts-node typescript @aws-sdk/client-cognito-identity-provider @aws-sdk/client-s3 @aws-sdk/client-sfn @aws-sdk/client-ssm @aws-sdk/client-sts @aws-sdk/credential-providers @aws-sdk/lib-storage @oclif/core @oclif/errors @oclif/plugin-autocomplete @oclif/plugin-commands @oclif/plugin-help @oclif/plugin-not-found @oclif/plugin-plugins @oclif/plugin-update @oclif/plugin-warn-if-update-available chalk clear csv-parse execa figlet ink jsonschema lodash node-localstorage ora prompts" + "exec": "pnpm update @aws-sdk/types @oclif/test @types/chalk @types/clear @types/csv-parse @types/execa @types/jest @types/jsonschema @types/lodash @types/node-localstorage @types/node @types/ora @types/prompts @typescript-eslint/eslint-plugin @typescript-eslint/parser eslint-config-prettier eslint-import-resolver-node eslint-import-resolver-typescript eslint-plugin-header eslint-plugin-import eslint-plugin-prettier eslint jest jest-junit npm-check-updates prettier projen ts-jest ts-node typescript @aws-sdk/client-cognito-identity-provider @aws-sdk/client-s3 @aws-sdk/client-sfn @aws-sdk/client-ssm @aws-sdk/client-sts @aws-sdk/credential-providers @aws-sdk/lib-storage @oclif/core @oclif/errors @oclif/plugin-autocomplete @oclif/plugin-commands @oclif/plugin-help @oclif/plugin-not-found @oclif/plugin-plugins @oclif/plugin-update @oclif/plugin-warn-if-update-available @smithy/property-provider chalk clear csv-parse execa figlet ink jsonschema lodash node-localstorage ora prompts" }, { "exec": "npx projen" diff --git a/packages/galileo-cli/bin/galileo-cli.ts b/packages/galileo-cli/bin/galileo-cli.ts index 1a428bdf..a18d4bbd 100644 --- a/packages/galileo-cli/bin/galileo-cli.ts +++ b/packages/galileo-cli/bin/galileo-cli.ts @@ -2,6 +2,8 @@ PDX-License-Identifier: Apache-2.0 */ import * as path from "node:path"; import { run, flush, Errors } from "@oclif/core"; +import { CredentialsProviderError } from "@smithy/property-provider"; +import chalk from "chalk"; // https://oclif.io/docs/config process.env.XDG_DATA_HOME = path.join(__dirname, ".."); @@ -12,6 +14,15 @@ void (async () => { await run(); await flush(); } catch (err: any) { + // handle error when aws creds are outdated + if (err instanceof CredentialsProviderError) { + console.error( + chalk.redBright( + "\n\nSeems your AWS credentials are outdated. Please update them and try again.\n\n" + ) + ); + } + Errors.handle(err); } })(); diff --git a/packages/galileo-cli/examples/csv-loader/parser-common.ts b/packages/galileo-cli/examples/csv-loader/parser-common.ts index 179661be..8da8721e 100644 --- a/packages/galileo-cli/examples/csv-loader/parser-common.ts +++ b/packages/galileo-cli/examples/csv-loader/parser-common.ts @@ -49,5 +49,6 @@ export const parseCsv = (): DocumentMetadata => { return docMetadata; } catch (err) { console.log(JSON.stringify(err)); + throw err; } }; diff --git a/packages/galileo-cli/package.json b/packages/galileo-cli/package.json index 27fbb3bb..2ff8376e 100644 --- a/packages/galileo-cli/package.json +++ b/packages/galileo-cli/package.json @@ -73,6 +73,7 @@ "@oclif/plugin-plugins": "^3.8.3", "@oclif/plugin-update": "^3.2.4", "@oclif/plugin-warn-if-update-available": "^2.1.1", + "@smithy/property-provider": "^2.0.10", "chalk": "^4", "clear": "^0.1.0", "csv-parse": "^5.5.0", diff --git a/packages/galileo-cli/tsconfig.dev.json b/packages/galileo-cli/tsconfig.dev.json index b35d2188..5de55273 100644 --- a/packages/galileo-cli/tsconfig.dev.json +++ b/packages/galileo-cli/tsconfig.dev.json @@ -30,8 +30,8 @@ ".projenrc.js", "src/**/*.ts", "test/**/*.ts", - "src/**/*.ts", - "examples/**/*.ts" + "examples/**/*.ts", + "bin/*.ts" ], "exclude": [ "node_modules" diff --git a/packages/galileo-cli/tsconfig.json b/packages/galileo-cli/tsconfig.json index 69a585a7..549c931e 100644 --- a/packages/galileo-cli/tsconfig.json +++ b/packages/galileo-cli/tsconfig.json @@ -28,8 +28,8 @@ }, "include": [ "src/**/*.ts", - "src/**/*.ts", - "examples/**/*.ts" + "examples/**/*.ts", + "bin/*.ts" ], "exclude": [] } diff --git a/packages/galileo-sdk/.projen/tasks.json b/packages/galileo-sdk/.projen/tasks.json index 3c0c6760..c4a4105c 100644 --- a/packages/galileo-sdk/.projen/tasks.json +++ b/packages/galileo-sdk/.projen/tasks.json @@ -69,7 +69,7 @@ "description": "Run eslint against the staged files only", "steps": [ { - "exec": "eslint --fix --no-error-on-unmatched-pattern $(git diff --name-only --relative --staged HEAD . | grep -E '^(.*/)?(src|test)/.*.(ts|tsx)$' | xargs)" + "exec": "eslint --fix --no-error-on-unmatched-pattern $(git diff --name-only --relative --staged HEAD . | grep -E '^(src|test)/.*.(ts|tsx)$' | xargs)" } ] }, diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 8e223f94..59dede07 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -1197,6 +1197,9 @@ importers: '@oclif/plugin-warn-if-update-available': specifier: ^2.1.1 version: 2.1.1(@types/node@16.18.39)(typescript@5.2.2) + '@smithy/property-provider': + specifier: ^2.0.10 + version: 2.0.10 chalk: specifier: ^4 version: 4.1.2 @@ -2546,7 +2549,7 @@ packages: dependencies: '@aws-sdk/client-cognito-identity': 3.388.0 '@aws-sdk/types': 3.387.0 - '@smithy/property-provider': 2.0.7 + '@smithy/property-provider': 2.0.10 '@smithy/types': 2.3.4 tslib: 2.6.2 transitivePeerDependencies: @@ -8162,14 +8165,6 @@ packages: '@smithy/types': 2.3.4 tslib: 2.6.2 - /@smithy/property-provider@2.0.7: - resolution: {integrity: sha512-XT8Tl7YNxM8tCtGqy7v7DSf6PxyXaPE9cdA/Yj4dEw2b05V3RrPqsP+t5XJiZu0yIsQ7pdeYZWv2sSEWVjNeAg==} - engines: {node: '>=14.0.0'} - dependencies: - '@smithy/types': 2.3.4 - tslib: 2.6.2 - dev: false - /@smithy/protocol-http@1.2.0: resolution: {integrity: sha512-GfGfruksi3nXdFok5RhgtOnWe5f6BndzYfmEXISD+5gAGdayFGpjWu5pIqIweTudMtse20bGbc+7MFZXT1Tb8Q==} engines: {node: '>=14.0.0'} @@ -14057,7 +14052,7 @@ packages: dependencies: semver: 7.5.4 shelljs: 0.8.5 - typescript: 5.3.0-dev.20231025 + typescript: 5.3.0-dev.20231030 dev: true /drange@1.1.1: @@ -25430,8 +25425,8 @@ packages: engines: {node: '>=14.17'} hasBin: true - /typescript@5.3.0-dev.20231025: - resolution: {integrity: sha512-DW0GNkWzKHnI9lcYCVIw5SO5nzlaZ9iHAdcN7zCxt/OJsKg7s33xRtEa5nmPTIC5qvKzLLZboWWBJ+KRD9cKFw==} + /typescript@5.3.0-dev.20231030: + resolution: {integrity: sha512-azWrF0lAiu8cBHNr6yq3RDkU/DtQScvT48ea3Ngq6oXJ/GPO0n96wCFSRQA5UbZlVVf3fAAqsUfvOdohRbrPVg==} engines: {node: '>=14.17'} hasBin: true dev: true diff --git a/projenrc/framework/galileo-cli.ts b/projenrc/framework/galileo-cli.ts index ffbf56b4..2c7703cf 100644 --- a/projenrc/framework/galileo-cli.ts +++ b/projenrc/framework/galileo-cli.ts @@ -31,7 +31,7 @@ export class GalileoCli extends TypeScriptAppProject { outDir: undefined, target: "ES2022", }, - include: ["src/**/*.ts", "examples/**/*.ts"], + include: ["examples/**/*.ts", "bin/*.ts"], }; super({ @@ -44,8 +44,9 @@ export class GalileoCli extends TypeScriptAppProject { `@aws-sdk/client-sfn@^${VERSIONS.AWS_SDK}`, `@aws-sdk/client-ssm@^${VERSIONS.AWS_SDK}`, `@aws-sdk/client-sts@^${VERSIONS.AWS_SDK}`, - `@aws-sdk/lib-storage@^${VERSIONS.AWS_SDK}`, `@aws-sdk/credential-providers@^${VERSIONS.AWS_SDK}`, + `@aws-sdk/lib-storage@^${VERSIONS.AWS_SDK}`, + `@smithy/property-provider`, "@oclif/core", "@oclif/errors", "chalk@^4", diff --git a/projenrc/monorepo.ts b/projenrc/monorepo.ts index ec72fc49..5321ec43 100644 --- a/projenrc/monorepo.ts +++ b/projenrc/monorepo.ts @@ -288,7 +288,7 @@ export class MonorepoProject extends MonorepoTsProject { description: "Run eslint against the staged files only", steps: [ { - exec: `eslint --fix --no-error-on-unmatched-pattern $(git diff --name-only --relative --staged HEAD . | grep -E '^(.*/)?(${dirs.join( + exec: `eslint --fix --no-error-on-unmatched-pattern $(git diff --name-only --relative --staged HEAD . | grep -E '^(${dirs.join( "|" )})/.*\.(ts|tsx)$' | xargs)`, },