diff --git a/.eslintrc.json b/.eslintrc.json index f9b22b7..87b1c0b 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -10,11 +10,10 @@ ], "rules": { "@typescript-eslint/naming-convention": "warn", - "@typescript-eslint/semi": "warn", "curly": "warn", "eqeqeq": "warn", "no-throw-literal": "warn", - "semi": "off" + "semi": "warn" }, "ignorePatterns": [ "out", diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index cb24d5c..1ce389a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,41 +1,92 @@ name: CI + on: push: branches: - "**" tags: - "v*" + pull_request: + workflow_dispatch: + +permissions: + contents: read + +concurrency: + group: ci-${{ github.ref }} + cancel-in-progress: ${{ !startsWith(github.ref, 'refs/tags/') }} jobs: build: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 - - uses: actions/setup-node@v3 + - name: Check out repository + uses: actions/checkout@v6 + - name: Set up Node.js + uses: actions/setup-node@v6 with: - node-version: 18 - - run: yarn install --frozen-lockfile - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - run: npx vsce package --out vscode-splunk-soar.vsix - - uses: actions/upload-artifact@v3 + node-version-file: .nvmrc + cache: yarn + cache-dependency-path: yarn.lock + - name: Enable Corepack + run: corepack enable + - name: Verify Yarn lockfile registries + run: | + if grep 'resolved "https://' yarn.lock docs/yarn.lock | grep -v 'resolved "https://registry.yarnpkg.com/'; then + echo "All Yarn dependencies must resolve from registry.yarnpkg.com." + exit 1 + fi + - name: Install dependencies + run: yarn install --frozen-lockfile --registry https://registry.yarnpkg.com + - name: Lint + run: yarn lint + - name: Audit dependencies + run: yarn audit --registry https://registry.yarnpkg.com + - name: Build VSIX + run: yarn vsce package --out vscode-splunk-soar.vsix + - name: Upload VSIX + uses: actions/upload-artifact@v7 with: - name: vscode-splunk-soar.vsix - path: "*.vsix" + name: vscode-splunk-soar-vsix + path: vscode-splunk-soar.vsix + if-no-files-found: error + retention-days: 7 publish: runs-on: ubuntu-latest needs: build - if: success() && startsWith( github.ref, 'refs/tags/') + if: startsWith(github.ref, 'refs/tags/v') + permissions: + contents: write steps: - - uses: actions/download-artifact@v3 + - name: Check out repository + uses: actions/checkout@v6 + - name: Set up Node.js + uses: actions/setup-node@v6 + with: + node-version-file: .nvmrc + cache: yarn + cache-dependency-path: yarn.lock + - name: Enable Corepack + run: corepack enable + - name: Verify Yarn lockfile registries + run: | + if grep 'resolved "https://' yarn.lock docs/yarn.lock | grep -v 'resolved "https://registry.yarnpkg.com/'; then + echo "All Yarn dependencies must resolve from registry.yarnpkg.com." + exit 1 + fi + - name: Install dependencies + run: yarn install --frozen-lockfile --registry https://registry.yarnpkg.com + - name: Download VSIX + uses: actions/download-artifact@v8 with: - name: vscode-splunk-soar.vsix - - uses: ncipollo/release-action@v1 + name: vscode-splunk-soar-vsix + - name: Create GitHub release + uses: ncipollo/release-action@v1 with: - artifacts: "*.vsix" + artifacts: vscode-splunk-soar.vsix token: ${{ secrets.GITHUB_TOKEN }} - - - run: npx vsce publish --packagePath $(find . -type f -iname '*.vsix') + - name: Publish to Visual Studio Marketplace + run: yarn vsce publish --packagePath vscode-splunk-soar.vsix env: VSCE_PAT: ${{ secrets.VSCE_PAT }} diff --git a/.github/workflows/docs_deploy.yml b/.github/workflows/docs_deploy.yml index 14907d1..7d7141d 100644 --- a/.github/workflows/docs_deploy.yml +++ b/.github/workflows/docs_deploy.yml @@ -1,43 +1,53 @@ name: Deploy to GitHub Pages on: + workflow_dispatch: push: paths: - "docs/**" + - ".github/workflows/docs_deploy.yml" branches: - main +permissions: + contents: write + +concurrency: + group: docs-${{ github.ref }} + cancel-in-progress: true + jobs: deploy: name: Deploy to GitHub Pages runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - uses: actions/setup-node@v3 + - name: Check out repository + uses: actions/checkout@v6 + - name: Set up Node.js + uses: actions/setup-node@v6 with: - node-version: 18 + node-version-file: .nvmrc cache: yarn + cache-dependency-path: docs/yarn.lock + - name: Enable Corepack + run: corepack enable + - name: Verify Yarn lockfile registries + run: | + if grep 'resolved "https://' yarn.lock docs/yarn.lock | grep -v 'resolved "https://registry.yarnpkg.com/'; then + echo "All Yarn dependencies must resolve from registry.yarnpkg.com." + exit 1 + fi - name: Install dependencies working-directory: docs - run: yarn install --frozen-lockfile + run: yarn install --frozen-lockfile --registry https://registry.yarnpkg.com - name: Build website working-directory: docs run: yarn build - # Popular action to deploy to GitHub Pages: - # Docs: https://github.com/peaceiris/actions-gh-pages#%EF%B8%8F-docusaurus - name: Deploy to GitHub Pages - uses: peaceiris/actions-gh-pages@v3 + uses: peaceiris/actions-gh-pages@v4 with: github_token: ${{ secrets.GITHUB_TOKEN }} - # Build output to publish to the `gh-pages` branch: publish_dir: ./docs/build - # The following lines assign commit authorship to the official - # GH-Actions bot for deploys to `gh-pages` branch: - # https://github.com/actions/checkout/issues/13#issuecomment-724415212 - # The GH actions bot is used by default if you didn't specify the two fields. - # You can swap them out with your own user credentials. user_name: github-actions[bot] user_email: 41898282+github-actions[bot]@users.noreply.github.com - - diff --git a/.nvmrc b/.nvmrc new file mode 100644 index 0000000..91d5f6f --- /dev/null +++ b/.nvmrc @@ -0,0 +1 @@ +22.18.0 diff --git a/.vscode/extensions.json b/.vscode/extensions.json index 57dbdae..c0a2258 100644 --- a/.vscode/extensions.json +++ b/.vscode/extensions.json @@ -1,5 +1,5 @@ { // See http://go.microsoft.com/fwlink/?LinkId=827846 // for the documentation about the extensions.json format - "recommendations": ["dbaeumer.vscode-eslint", "amodio.tsl-problem-matcher"] + "recommendations": ["dbaeumer.vscode-eslint"] } diff --git a/.vscode/launch.json b/.vscode/launch.json index 343ee6f..135612e 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -17,20 +17,6 @@ "${workspaceFolder}/dist/**/*.js" ], "preLaunchTask": "${defaultBuildTask}" - }, - { - "name": "Extension Tests", - "type": "extensionHost", - "request": "launch", - "args": [ - "--extensionDevelopmentPath=${workspaceFolder}", - "--extensionTestsPath=${workspaceFolder}/out/test/suite/index" - ], - "outFiles": [ - "${workspaceFolder}/out/**/*.js", - "${workspaceFolder}/dist/**/*.js" - ], - "preLaunchTask": "tasks: watch-tests" } ] } diff --git a/.vscode/settings.json b/.vscode/settings.json index ce34750..c8164ee 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -8,7 +8,7 @@ "out": true, // set this to false to include "out" folder in search results "dist": true // set this to false to include "dist" folder in search results }, - // Turn off tsc task auto detection since we have the necessary tasks as npm scripts + // Turn off tsc task auto detection since we have the necessary Yarn scripts "typescript.tsc.autoDetect": "off", "git.mergeEditor": true -} \ No newline at end of file +} diff --git a/.vscode/tasks.json b/.vscode/tasks.json index 2acd96d..40d111f 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -4,11 +4,12 @@ "version": "2.0.0", "tasks": [ { - "type": "npm", - "script": "watch", + "label": "yarn: watch", + "type": "shell", + "command": "yarn", + "args": ["watch"], "problemMatcher": [ - "$ts-webpack-watch", - "$tslint-webpack-watch" + "$ts-webpack-watch" ], "isBackground": true, "presentation": { @@ -19,25 +20,6 @@ "kind": "build", "isDefault": true } - }, - { - "type": "npm", - "script": "watch-tests", - "problemMatcher": "$tsc-watch", - "isBackground": true, - "presentation": { - "reveal": "never", - "group": "watchers" - }, - "group": "build" - }, - { - "label": "tasks: watch-tests", - "dependsOn": [ - "npm: watch", - "npm: watch-tests" - ], - "problemMatcher": [] } ] -} \ No newline at end of file +} diff --git a/.vscodeignore b/.vscodeignore index ab31306..872dea1 100644 --- a/.vscodeignore +++ b/.vscodeignore @@ -11,4 +11,7 @@ vsc-extension-quickstart.md **/.eslintrc.json **/*.map **/*.ts -docs/** \ No newline at end of file +docs/** +.github/** +.nvmrc +audits/** diff --git a/.yarnrc b/.yarnrc index f757a6a..62bfdde 100644 --- a/.yarnrc +++ b/.yarnrc @@ -1 +1 @@ ---ignore-engines true \ No newline at end of file +--registry "https://registry.yarnpkg.com" diff --git a/README.md b/README.md index 9293442..1238961 100644 --- a/README.md +++ b/README.md @@ -113,6 +113,92 @@ Execution logs can be displayed by: * right-clicking on a run listed under the Playbook Runs View * clicking on "Logs" +## Development + +### Prerequisites + +- VS Code 1.101 or newer +- Node.js 22.18.0 (the repository includes an `.nvmrc`) +- Yarn 1.22.22 + +This repository uses Yarn exclusively. Do not use npm to install or update dependencies; the root extension and the documentation site each have their own `yarn.lock`. + +### Set up the repository + +```bash +git clone https://github.com/splunk/vscode-extension-splunk-soar.git +cd vscode-extension-splunk-soar +nvm use +yarn install --frozen-lockfile +code . +``` + +If the requested Node.js version is not installed yet, run `nvm install` before `nvm use`. + +### Inner development loop + +1. Open **Run and Debug** in VS Code and start the **Run Extension** configuration, or press `F5`. +2. The default `yarn: watch` task starts webpack in watch mode and opens an Extension Development Host window with a temporary VS Code profile. +3. Exercise the change in the Extension Development Host. Open the Splunk SOAR view or invoke a contributed command to activate the extension. +4. After changing extension or webview source code, wait for webpack to finish rebuilding, then run **Developer: Reload Window** in the Extension Development Host to load the new bundles. +5. Set breakpoints in `src/` and inspect extension-host output in the Debug Console. Webview code is bundled from `app/src/` into `app/build/`. + +The temporary profile does not inherit environments configured in your regular VS Code profile. If a change requires a SOAR connection, configure a non-production SOAR environment inside the Extension Development Host. + +### Local checks + +Run these before opening a pull request: + +```bash +# Type-check the extension without emitting JavaScript +yarn check-types + +# Lint extension and webview sources +yarn lint + +# Create development bundles once, without watch mode +yarn compile + +# Create optimized production bundles +yarn package + +# Build the same VSIX artifact produced by CI +yarn vsce package --out vscode-splunk-soar.vsix +``` + +The current lint configuration reports an existing warning backlog but should complete with zero errors. Webpack also reports bundle-size recommendations for the webviews; these warnings do not fail the build. + +There is currently no automated extension-host test suite. The required verification is type-checking, linting, production bundling, and exercising the affected workflow in the Extension Development Host. + +### Updating dependencies + +Run dependency commands from the directory whose manifest is being updated: + +```bash +# Runtime dependency +yarn add + +# Development dependency +yarn add --dev + +# Remove a dependency +yarn remove +``` + +Commit both the affected `package.json` and its `yarn.lock`. Verify the resulting graph with `yarn install --frozen-lockfile` and `yarn audit`. + +### Documentation site + +The Docusaurus site is an independent Yarn project under `docs/`: + +```bash +cd docs +yarn install --frozen-lockfile +yarn start +``` + +The development server is available at [http://localhost:3000](http://localhost:3000). Run `yarn build` from `docs/` to verify a production documentation build. + ## Documentation The documentation is located on https://splunk.github.io/vscode-extension-splunk-soar/ and hosted via Github Pages. diff --git a/app/build/appwizard.js b/app/build/appwizard.js index e90fe63..d23fdac 100644 --- a/app/build/appwizard.js +++ b/app/build/appwizard.js @@ -1,1481 +1,3420 @@ /*! For license information please see appwizard.js.LICENSE.txt */ -(()=>{"use strict";var e={4448:(e,t,n)=>{var i=n(7294),r=n(3840);function o(e){for(var t="https://reactjs.org/docs/error-decoder.html?invariant="+e,n=1;n