Skip to content

Commit

Permalink
Add lint script, workflow, and pre-commit hook
Browse files Browse the repository at this point in the history
Signed-off-by: Tyler Ohlsen <[email protected]>
  • Loading branch information
ohltyler committed Sep 5, 2023
1 parent eab9065 commit 7a76de1
Show file tree
Hide file tree
Showing 9 changed files with 210 additions and 9 deletions.
File renamed without changes.
File renamed without changes.
47 changes: 47 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: Linting workflow
on:
push:
branches:
- "*"
pull_request:
branches:
- "*"
env:
OPENSEARCH_DASHBOARDS_VERSION: 'main'
jobs:
run-lint:
name: Run lint script
if: github.repository == 'opensearch-project/opensearch-ai-flow-dashboards'
steps:
- name: Checkout OpenSearch Dashboards
uses: actions/checkout@v2
with:
repository: opensearch-project/OpenSearch-Dashboards
ref: ${{ env.OPENSEARCH_DASHBOARDS_VERSION }}
path: OpenSearch-Dashboards
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version-file: './OpenSearch-Dashboards/.nvmrc'
registry-url: 'https://registry.npmjs.org'
- name: Install Yarn
# Need to use bash to avoid having a windows/linux specific step
shell: bash
run: |
YARN_VERSION=$(node -p "require('./OpenSearch-Dashboards/package.json').engines.yarn")
echo "Installing yarn@$YARN_VERSION"
npm i -g yarn@$YARN_VERSION
- run: node -v
- run: yarn -v
- name: Checkout plugin
uses: actions/checkout@v2
with:
path: OpenSearch-Dashboards/plugins/opensearch-ai-flow-dashboards
- name: Bootstrap the plugin
run: |
cd OpenSearch-Dashboards/plugins/opensearch-ai-flow-dashboards
yarn osd bootstrap
- name: Run lint script
run: |
cd OpenSearch-Dashboards/plugins/opensearch-ai-flow-dashboards
yarn lint:es common/* public/* server/*
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,5 @@ coverage
offline-module-cache/v2/*
offline-module-cache/v1/*
target
._.DS_Store
._.DS_Store
.eslintcache
1 change: 1 addition & 0 deletions common/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*/

export const PLUGIN_ID = 'aiFlowDashboards';

export const BASE_NODE_API_PATH = '/api/ai_flow';
17 changes: 13 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,30 @@
"plugin_name": "aiFlowDashboards",
"plugin_zip_name": "ai-flow-dashboards"
},
"private": true,
"scripts": {
"plugin-helpers": "../../scripts/use_node ../../scripts/plugin_helpers",
"osd": "../../scripts/use_node ../../scripts/osd",
"opensearch": "node ../../scripts/opensearch",
"lint": "node ../../scripts/eslint .",
"opensearch": "../../scripts/use_node ../../scripts/opensearch",
"lint:es": "../../scripts/use_node ../../scripts/eslint",
"lint:es:precommit": "yarn lint:es common/* public/* server/*",
"build": "yarn plugin-helpers build && echo Renaming artifact to $npm_package_config_plugin_zip_name-$npm_package_config_plugin_version.zip && mv ./build/$npm_package_config_plugin_name*.zip ./build/$npm_package_config_plugin_zip_name-$npm_package_config_plugin_version.zip"
},
"repository": {
"type": "git",
"url": "https://github.com/opensearch-project/opensearch-ai-flow-dashboards.git"
},
"pre-commit": [
"lint:es:precommit"
],
"lint-staged": {
"*.{ts,tsx,js,jsx,json,css,md}": [
"prettier --write",
"git add"
]
},
"devDependencies": {},
"dependencies": {},
"devDependencies": {
"pre-commit": "^1.2.2"
},
"resolutions": {}
}
7 changes: 4 additions & 3 deletions public/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { Navigation, APP_PATH } from './utils';
import { Overview, UseCases, Workflows } from './pages';
import { CoreServicesConsumer } from './core_services';

// eslint-disable-next-line @typescript-eslint/no-empty-interface
interface Props extends RouteComponentProps {}

export const AiFlowDashboardsApp = (props: Props) => {
Expand Down Expand Up @@ -58,16 +59,16 @@ export const AiFlowDashboardsApp = (props: Props) => {
<Switch>
<Route
path={APP_PATH.USE_CASES}
render={(props: RouteComponentProps) => <UseCases />}
render={(routeProps: RouteComponentProps) => <UseCases />}
/>
<Route
path={APP_PATH.WORKFLOWS}
render={(props: RouteComponentProps) => <Workflows />}
render={(routeProps: RouteComponentProps) => <Workflows />}
/>
{/* Defaulting to Overview page */}
<Route
path={`${APP_PATH.HOME}`}
render={(props: RouteComponentProps) => <Overview />}
render={(routeProps: RouteComponentProps) => <Overview />}
/>
</Switch>
</EuiPageTemplate>
Expand Down
2 changes: 1 addition & 1 deletion public/render_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export const renderApp = (
<AiFlowDashboardsApp {...props} />
</CoreServicesContext.Provider>
)}
></Route>
/>
</Router>,
element
);
Expand Down
142 changes: 142 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,145 @@
# yarn lockfile v1


buffer-from@^1.0.0:
version "1.1.2"
resolved "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.2.tgz"
integrity sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==

concat-stream@^1.4.7:
version "1.6.2"
resolved "https://registry.npmjs.org/concat-stream/-/concat-stream-1.6.2.tgz"
integrity sha512-27HBghJxjiZtIk3Ycvn/4kbJk/1uZuJFfuPEns6LaEvpvG1f0hTea8lilrouyo9mVc2GWdcEZ8OLoGmSADlrCw==
dependencies:
buffer-from "^1.0.0"
inherits "^2.0.3"
readable-stream "^2.2.2"
typedarray "^0.0.6"

core-util-is@~1.0.0:
version "1.0.3"
resolved "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.3.tgz"
integrity sha512-ZQBvi1DcpJ4GDqanjucZ2Hj3wEO5pZDS89BWbkcrvdxksJorwUDDZamX9ldFkp9aw2lmBDLgkObEA4DWNJ9FYQ==

cross-spawn@^5.0.1:
version "5.1.0"
resolved "https://registry.npmjs.org/cross-spawn/-/cross-spawn-5.1.0.tgz"
integrity sha512-pTgQJ5KC0d2hcY8eyL1IzlBPYjTkyH72XRZPnLyKus2mBfNjQs3klqbJU2VILqZryAZUt9JOb3h/mWMy23/f5A==
dependencies:
lru-cache "^4.0.1"
shebang-command "^1.2.0"
which "^1.2.9"

inherits@^2.0.3, inherits@~2.0.3:
version "2.0.4"
resolved "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz"
integrity sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==

isarray@~1.0.0:
version "1.0.0"
resolved "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz"
integrity sha512-VLghIWNM6ELQzo7zwmcg0NmTVyWKYjvIeM83yjp0wRDTmUnrM678fQbcKBo6n2CJEF0szoG//ytg+TKla89ALQ==

isexe@^2.0.0:
version "2.0.0"
resolved "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz"
integrity sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==

lru-cache@^4.0.1:
version "4.1.5"
resolved "https://registry.npmjs.org/lru-cache/-/lru-cache-4.1.5.tgz"
integrity sha512-sWZlbEP2OsHNkXrMl5GYk/jKk70MBng6UU4YI/qGDYbgf6YbP4EvmqISbXCoJiRKs+1bSpFHVgQxvJ17F2li5g==
dependencies:
pseudomap "^1.0.2"
yallist "^2.1.2"

os-shim@^0.1.2:
version "0.1.3"
resolved "https://registry.npmjs.org/os-shim/-/os-shim-0.1.3.tgz"
integrity sha512-jd0cvB8qQ5uVt0lvCIexBaROw1KyKm5sbulg2fWOHjETisuCzWyt+eTZKEMs8v6HwzoGs8xik26jg7eCM6pS+A==

pre-commit@^1.2.2:
version "1.2.2"
resolved "https://registry.yarnpkg.com/pre-commit/-/pre-commit-1.2.2.tgz#dbcee0ee9de7235e57f79c56d7ce94641a69eec6"
integrity sha512-qokTiqxD6GjODy5ETAIgzsRgnBWWQHQH2ghy86PU7mIn/wuWeTwF3otyNQZxWBwVn8XNr8Tdzj/QfUXpH+gRZA==
dependencies:
cross-spawn "^5.0.1"
spawn-sync "^1.0.15"
which "1.2.x"

process-nextick-args@~2.0.0:
version "2.0.1"
resolved "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz"
integrity sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag==

pseudomap@^1.0.2:
version "1.0.2"
resolved "https://registry.npmjs.org/pseudomap/-/pseudomap-1.0.2.tgz"
integrity sha512-b/YwNhb8lk1Zz2+bXXpS/LK9OisiZZ1SNsSLxN1x2OXVEhW2Ckr/7mWE5vrC1ZTiJlD9g19jWszTmJsB+oEpFQ==

readable-stream@^2.2.2:
version "2.3.8"
resolved "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.8.tgz"
integrity sha512-8p0AUk4XODgIewSi0l8Epjs+EVnWiK7NoDIEGU0HhE7+ZyY8D1IMY7odu5lRrFXGg71L15KG8QrPmum45RTtdA==
dependencies:
core-util-is "~1.0.0"
inherits "~2.0.3"
isarray "~1.0.0"
process-nextick-args "~2.0.0"
safe-buffer "~5.1.1"
string_decoder "~1.1.1"
util-deprecate "~1.0.1"

safe-buffer@~5.1.0, safe-buffer@~5.1.1:
version "5.1.2"
resolved "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz"
integrity sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==

shebang-command@^1.2.0:
version "1.2.0"
resolved "https://registry.npmjs.org/shebang-command/-/shebang-command-1.2.0.tgz"
integrity sha512-EV3L1+UQWGor21OmnvojK36mhg+TyIKDh3iFBKBohr5xeXIhNBcx8oWdgkTEEQ+BEFFYdLRuqMfd5L84N1V5Vg==
dependencies:
shebang-regex "^1.0.0"

shebang-regex@^1.0.0:
version "1.0.0"
resolved "https://registry.npmjs.org/shebang-regex/-/shebang-regex-1.0.0.tgz"
integrity sha512-wpoSFAxys6b2a2wHZ1XpDSgD7N9iVjg29Ph9uV/uaP9Ex/KXlkTZTeddxDPSYQpgvzKLGJke2UU0AzoGCjNIvQ==

spawn-sync@^1.0.15:
version "1.0.15"
resolved "https://registry.npmjs.org/spawn-sync/-/spawn-sync-1.0.15.tgz"
integrity sha512-9DWBgrgYZzNghseho0JOuh+5fg9u6QWhAWa51QC7+U5rCheZ/j1DrEZnyE0RBBRqZ9uEXGPgSSM0nky6burpVw==
dependencies:
concat-stream "^1.4.7"
os-shim "^0.1.2"

string_decoder@~1.1.1:
version "1.1.1"
resolved "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz"
integrity sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==
dependencies:
safe-buffer "~5.1.0"

typedarray@^0.0.6:
version "0.0.6"
resolved "https://registry.npmjs.org/typedarray/-/typedarray-0.0.6.tgz"
integrity sha512-/aCDEGatGvZ2BIk+HmLf4ifCJFwvKFNb9/JeZPMulfgFracn9QFcAf5GO8B/mweUjSoblS5In0cWhqpfs/5PQA==

util-deprecate@~1.0.1:
version "1.0.2"
resolved "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz"
integrity sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==

[email protected], which@^1.2.9:
version "1.2.14"
resolved "https://registry.npmjs.org/which/-/which-1.2.14.tgz"
integrity sha512-16uPglFkRPzgiUXYMi1Jf8Z5EzN1iB4V0ZtMXcHZnwsBtQhhHeCqoWw7tsUY42hJGNDWtUsVLTjakIa5BgAxCw==
dependencies:
isexe "^2.0.0"

yallist@^2.1.2:
version "2.1.2"
resolved "https://registry.npmjs.org/yallist/-/yallist-2.1.2.tgz"
integrity sha512-ncTzHV7NvsQZkYe1DW7cbDLm0YpzHmZF5r/iyP3ZnQtMiJ+pjzisCiMNI+Sj+xQF5pXhSHxSB3uDbsBTzY/c2A==

0 comments on commit 7a76de1

Please sign in to comment.