From fc8355398b9deb747aa159ae9b1840b6a24c972c Mon Sep 17 00:00:00 2001 From: Enzo Bonato Date: Mon, 8 Jul 2024 14:10:27 -0400 Subject: [PATCH 1/3] Setup repository --- .editorconfig | 10 + .gitattributes | 4 + .github/ISSUE_TEMPLATE/bug.yml | 48 ++++ .github/ISSUE_TEMPLATE/config.yml | 1 + .github/ISSUE_TEMPLATE/task.yml | 48 ++++ .github/ISSUE_TEMPLATE/technical-story.yml | 36 +++ .github/ISSUE_TEMPLATE/user-story.yml | 53 ++++ .github/workflows/assigned-issue.yml | 237 ++++++++++++++++++ .github/workflows/cd.yml | 29 +++ .github/workflows/ci.yml | 162 ++++++++++++ .github/workflows/publish-core.yml | 42 ++++ .github/workflows/publish-extension.yml | 72 ++++++ .../workflows/publish-targeted-extension.yml | 99 ++++++++ .gitignore | 21 ++ .prettierrc.json | 10 + .vscode/extensions.json | 5 + .vscode/launch.json | 32 +++ .vscode/settings.json | 14 ++ .vscode/tasks.json | 20 ++ package.json | 25 ++ pnpm-lock.yaml | 75 ++++++ pnpm-workspace.yaml | 5 + scripts/copy-front.js | 20 ++ scripts/copy-servers.js | 37 +++ turbo.json | 36 +++ vscode/.eslintrc.json | 30 +++ vscode/.npmrc | 1 + vscode/.vscode-test.mjs | 5 + vscode/.vscode/extensions.json | 5 + vscode/.vscode/launch.json | 21 ++ vscode/.vscode/settings.json | 13 + vscode/.vscode/tasks.json | 40 +++ vscode/.vscodeignore | 14 ++ vscode/CHANGELOG.md | 9 + vscode/README.md | 71 ++++++ vscode/package.json | 47 ++++ vscode/src/extension.ts | 26 ++ vscode/src/test/extension.test.ts | 15 ++ vscode/tsconfig.json | 16 ++ vscode/vsc-extension-quickstart.md | 48 ++++ vscode/webpack.config.js | 48 ++++ 41 files changed, 1550 insertions(+) create mode 100644 .editorconfig create mode 100644 .gitattributes create mode 100644 .github/ISSUE_TEMPLATE/bug.yml create mode 100644 .github/ISSUE_TEMPLATE/config.yml create mode 100644 .github/ISSUE_TEMPLATE/task.yml create mode 100644 .github/ISSUE_TEMPLATE/technical-story.yml create mode 100644 .github/ISSUE_TEMPLATE/user-story.yml create mode 100644 .github/workflows/assigned-issue.yml create mode 100644 .github/workflows/cd.yml create mode 100644 .github/workflows/ci.yml create mode 100644 .github/workflows/publish-core.yml create mode 100644 .github/workflows/publish-extension.yml create mode 100644 .github/workflows/publish-targeted-extension.yml create mode 100644 .gitignore create mode 100644 .prettierrc.json create mode 100644 .vscode/extensions.json create mode 100644 .vscode/launch.json create mode 100644 .vscode/settings.json create mode 100644 .vscode/tasks.json create mode 100644 package.json create mode 100644 pnpm-lock.yaml create mode 100644 pnpm-workspace.yaml create mode 100644 scripts/copy-front.js create mode 100644 scripts/copy-servers.js create mode 100644 turbo.json create mode 100644 vscode/.eslintrc.json create mode 100644 vscode/.npmrc create mode 100644 vscode/.vscode-test.mjs create mode 100644 vscode/.vscode/extensions.json create mode 100644 vscode/.vscode/launch.json create mode 100644 vscode/.vscode/settings.json create mode 100644 vscode/.vscode/tasks.json create mode 100644 vscode/.vscodeignore create mode 100644 vscode/CHANGELOG.md create mode 100644 vscode/README.md create mode 100644 vscode/package.json create mode 100644 vscode/src/extension.ts create mode 100644 vscode/src/test/extension.test.ts create mode 100644 vscode/tsconfig.json create mode 100644 vscode/vsc-extension-quickstart.md create mode 100644 vscode/webpack.config.js diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..1ed453a --- /dev/null +++ b/.editorconfig @@ -0,0 +1,10 @@ +root = true + +[*] +end_of_line = lf +insert_final_newline = true + +[*.{js,json,yml}] +charset = utf-8 +indent_style = space +indent_size = 2 diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..af3ad12 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,4 @@ +/.yarn/** linguist-vendored +/.yarn/releases/* binary +/.yarn/plugins/**/* binary +/.pnp.* binary linguist-generated diff --git a/.github/ISSUE_TEMPLATE/bug.yml b/.github/ISSUE_TEMPLATE/bug.yml new file mode 100644 index 0000000..5743723 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug.yml @@ -0,0 +1,48 @@ +name: Bug Issue +description: Bug report +title: "" +labels: [bug] +body: + - type: input + id: title + attributes: + label: Title + description: A short title for the bug. + validations: + required: true + - type: textarea + id: description + attributes: + label: Description + description: Describe the observed behavior + validations: + required: true + + - type: textarea + id: expected + attributes: + label: Expected behavior + description: Describe how the tool should behave when encountering this context + validations: + required: true + + - type: textarea + id: reproduce + attributes: + label: Steps to reproduce + description: Describe the step to follow to reproduce the bug + value: | + - [ ] 1. + - [ ] 2. + - [ ] 3. + validations: + required: false + + - type: checkboxes + id: terms + attributes: + label: Code of Conduct + description: By submitting this issue, you agree to follow our [Code of Conduct](https://example.com) + options: + - label: I agree to follow this project's Code of Conduct + required: true \ No newline at end of file diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml new file mode 100644 index 0000000..ec4bb38 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -0,0 +1 @@ +blank_issues_enabled: false \ No newline at end of file diff --git a/.github/ISSUE_TEMPLATE/task.yml b/.github/ISSUE_TEMPLATE/task.yml new file mode 100644 index 0000000..2864ad0 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/task.yml @@ -0,0 +1,48 @@ +name: Task Issue +description: Describes a small task (MAKE SURE TO LINK to a corresponding 'User story','Technical story' or parent 'task' issue). +title: "<title>" +labels: [task] +body: + - type: input + id: title + attributes: + label: Title + description: A short title for the task. + validations: + required: true + - type: textarea + id: description + attributes: + label: Description + description: Describe the task, what should be done? / Keep it brief and simple. + validations: + required: true + + - type: textarea + id: DoD + attributes: + label: Definition of done + description: Is this task a heavy task with sub tasks? Describe the tasks here. + value: | + - [ ] 1. + - [ ] 2. + - [ ] 3. + validations: + required: false + + - type: textarea + id: qa + attributes: + label: QA + description: Describe how this task will be tested. + validations: + required: true + + - type: checkboxes + id: terms + attributes: + label: Code of Conduct + description: By submitting this issue, you agree to follow our [Code of Conduct](https://example.com) + options: + - label: I agree to follow this project's Code of Conduct + required: true \ No newline at end of file diff --git a/.github/ISSUE_TEMPLATE/technical-story.yml b/.github/ISSUE_TEMPLATE/technical-story.yml new file mode 100644 index 0000000..32733a0 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/technical-story.yml @@ -0,0 +1,36 @@ +name: Technical Story +description: Describes a technical story. +title: "<title>" +labels: [technical story] +body: + + - type: textarea + id: description + attributes: + label: Description + description: Describe the technical chore to achieve. / Keep it brief and simple. + placeholder: What is the benefits for the developers? Why is this story revelant? + validations: + required: true + + - type: textarea + id: DoD + attributes: + label: Definition of Done + description: Describe step by step what should be done at the end. + placeholder: Each checkboxes will later correspond to 'Task Issues'. + value: | + - [ ] 1. + - [ ] 2. + - [ ] 3. + validations: + required: true + + - type: checkboxes + id: terms + attributes: + label: Code of Conduct + description: By submitting this issue, you agree to follow our [Code of Conduct](https://example.com) + options: + - label: I agree to follow this project's Code of Conduct + required: true \ No newline at end of file diff --git a/.github/ISSUE_TEMPLATE/user-story.yml b/.github/ISSUE_TEMPLATE/user-story.yml new file mode 100644 index 0000000..5fdc2cf --- /dev/null +++ b/.github/ISSUE_TEMPLATE/user-story.yml @@ -0,0 +1,53 @@ +name: User Story +description: Describes a user story. +title: "<title>" +labels: [user story] +body: + - type: textarea + id: description + attributes: + label: Description + description: Describe the user flow. / Keep it brief and simple. + placeholder: What is the user supposed te be able to do? Why is this story revelant? + validations: + required: true + + - type: input + id: who + attributes: + label: As + description: Which kind of people will be concerned by this story? + placeholder: ex. Smart Contract Developer + validations: + required: true + + - type: input + id: what + attributes: + label: I want to + description: As the target of this user story, what would I be able to do. + placeholder: ex. make something with outcome + validations: + required: true + + - type: textarea + id: DoD + attributes: + label: Definition of Done + description: Describe step by step what should be done at the end. + placeholder: Each checkboxes will later correspond to 'Task Issues'. + value: | + - [ ] 1. + - [ ] 2. + - [ ] 3. + validations: + required: true + + - type: checkboxes + id: terms + attributes: + label: Code of Conduct + description: By submitting this issue, you agree to follow our [Code of Conduct](https://example.com) + options: + - label: I agree to follow this project's Code of Conduct + required: true \ No newline at end of file diff --git a/.github/workflows/assigned-issue.yml b/.github/workflows/assigned-issue.yml new file mode 100644 index 0000000..e8d95ce --- /dev/null +++ b/.github/workflows/assigned-issue.yml @@ -0,0 +1,237 @@ +name: Create Branches and PRs on assign + +permissions: + contents: write + issues: write + pull-requests: write + repository-projects: write + statuses: write + +on: + issues: + types: [assigned] + +jobs: + generate-branchs-path: + outputs: + payloads: ${{ steps.generate-branches.outputs.result }} + runs-on: ubuntu-latest + steps: + - uses: actions/github-script@v7 + name: Get parent issues + id: get-parent-issues + with: + script: | + let _issueTrakedTemplate = ` + trackedInIssues(first: 1) { + nodes { + title + number + labels(first: 20) { + nodes { + name + } + } + #CHILD + } + }`; + + function createTrackedIssuesReq(recurse) { + let query = `query Nodes($number: Int!, $repo: String!, $organization: String!) { + organization(login: $organization) { + repository(name: $repo) { + issue(number: $number) { + title + number + labels(first: 20) { + nodes { + name + } + } + #CHILD + } + } + } + }`; + + do { + query = query.replace("#CHILD", _issueTrakedTemplate) + } while (recurse--); + + return query.replace("#CHILD", ""); + } + + let query = createTrackedIssuesReq(6); + console.log("query", query) + + const variables = { + number: parseInt(${{ github.event.issue.number }}, 10), + repo: "${{ github.event.repository.name }}", + organization: "${{ github.event.repository.owner.login }}" + } + const result = await github.graphql(query, variables); + console.log(JSON.stringify(result)) + + return result.organization.repository.issue; + + + - uses: actions/github-script@v7 + name: Build ancestor array + id: build-ancestor-array + with: + script: | + const ancestors = [] + const node = ${{ steps.get-parent-issues.outputs.result }} + let current = node?.trackedInIssues?.nodes[0] + + for (; current; current = current?.trackedInIssues?.nodes[0]) { + ancestors.push(current) + } + ancestors.reverse() + console.log(ancestors) + return ancestors + + - name: get branch prefix + id: get-branch-prefix + uses: actions/github-script@v7 + with: + script: | + const ancestors = JSON.parse(${{ toJson(steps.build-ancestor-array.outputs.result) }}); + console.error(ancestors) + const issueLabels = JSON.parse(`${{ toJson(github.event.issue.labels) }}`); + console.error(issueLabels) + const labels = ancestors.length > 0 ? ancestors[0].labels.nodes : issueLabels; + console.error(labels) + const isUserStory = labels.some((label) => label.name === "user story") + console.error(isUserStory) + const isBug = labels.some((label) => label.name === "bug") + console.error(isBug) + const isTask = labels.some((label) => label.name === "task") + console.error(isTask) + const isTechnicalStory = labels.some((label) => label.name === "technical story") + console.error(isTechnicalStory) + + if (isUserStory && !isTechnicalStory) { + console.error('feat/') + return 'feat/' + } else if (isTechnicalStory) { + console.error('chore/') + return 'chore/' + } else if (isBug) { + console.error('bug/') + return 'bug/' + } else if (isTask) { + console.error('task/') + return '' + } else { + console.error('No type found') + throw new Error("No type found") + } + + - name: generate branches + id: generate-branches + uses: actions/github-script@v7 + with: + script: | + function _sanitizeBranchName(title) { + return title.replace(/[^a-zA-Z0-9-]/g, '-').replace(/-{2,}/g, "-").replace(/-+$/, "").toLowerCase() + } + + const ancestors = JSON.parse(`${{ steps.build-ancestor-array.outputs.result }}`) + const rootBranchPrefix = ${{ steps.get-branch-prefix.outputs.result }} + const firstIssueNumber = ancestors.length > 0 ? ancestors[0].number : ${{ github.event.issue.number }} + const firstBranchName = rootBranchPrefix + + firstIssueNumber.toString() + + '-' + + _sanitizeBranchName(ancestors.length > 0 ? ancestors[0].title : "${{ github.event.issue.title }}") + + '-staging' + + const payloads = [ + { + baseBranch: 'dev', + headBranch: firstBranchName, + prTitle: `${firstIssueNumber} - ${ancestors.length > 0 ? ancestors[0].title : "${{ github.event.issue.title }}"}`, + issueNumber: firstIssueNumber + } + ] + + ancestors.slice(1).forEach((issue, index) => { + payloads.push({ + baseBranch: payloads[index].headBranch, + headBranch: payloads[index].headBranch.replace(/-staging$/, '') + + '/' + + issue.number.toString() + + '-' + + _sanitizeBranchName(issue.title) + + '-staging', + prTitle: `${issue.number} - ${issue.title}`, + issueNumber: issue.number + }) + }) + + if (ancestors.length > 0) { + payloads.push({ + baseBranch: payloads[payloads.length - 1].headBranch, + headBranch: payloads[payloads.length - 1].headBranch.replace(/-staging$/, '') + + '/' + + (${{ github.event.issue.number }}).toString() + + '-' + + _sanitizeBranchName("${{ github.event.issue.title }}") + + '-staging', + prTitle: `${{ github.event.issue.number }} - ${{ github.event.issue.title }}`, + issueNumber: ${{ github.event.issue.number }} + }) + } + + return payloads + + + + create-branch-and-draft: + runs-on: ubuntu-latest + needs: generate-branchs-path + strategy: + matrix: + payload: ${{ fromJson(needs.generate-branchs-path.outputs.payloads) }} + max-parallel: 1 + steps: + + - uses: actions/checkout@v3 + + - name: Check if branch exists + id: check-branch-exists + continue-on-error: true + # should check if branch exists and set branchExists=true if it does, otherwise branchExists=false + run: | + git fetch --all + git checkout ${{ matrix.payload.headBranch }} + echo "branchExists=true" >> $GITHUB_OUTPUT + echo "Branch exists" + + - name: Generate UUID + id: generate-uuid + run: | + echo "uuid=$(cat /proc/sys/kernel/random/uuid | sed 's/[-]//g' | head -c 20)" >> $GITHUB_OUTPUT + + + - name: Create branch + id: create-branch + # if branch does not exist, create it + if: steps.check-branch-exists.outputs.branchExists != 'true' + run: | + git checkout ${{ matrix.payload.baseBranch }} + git checkout -b ${{ matrix.payload.headBranch }} + git config --global user.email "ci@astrodevslabs.io" && git config --global user.name "Astrodevs CI" + echo "${{ env.REMOVE_UUID }}" > remove-me-${{ env.REMOVE_UUID }}.txt + git add remove-me-${{ env.REMOVE_UUID }}.txt + git commit -m "chore: create branch ${{ matrix.payload.headBranch }}" + git push origin ${{ matrix.payload.headBranch }} + env: + REMOVE_UUID: ${{ steps.generate-uuid.outputs.uuid }} + + - name: Create pull request + continue-on-error: true + env: + GH_TOKEN: ${{ github.token }} + run: | + gh pr create --title "${{ matrix.payload.prTitle }}" --body "Solves #${{ matrix.payload.issueNumber }}" --base ${{matrix.payload.baseBranch }} --head ${{matrix.payload.headBranch }} --repo ${{ github.event.repository.full_name }} --draft \ No newline at end of file diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml new file mode 100644 index 0000000..f895067 --- /dev/null +++ b/.github/workflows/cd.yml @@ -0,0 +1,29 @@ +name: CD + +on: + workflow_dispatch: + inputs: + version: + description: 'Version of the extension' + required: true + default: 'latest' + pre-release: + description: 'Publish as a pre-release' + required: false + default: false + type: boolean + +jobs: + build-and-publish-core: + uses: ./.github/workflows/publish-core.yml + secrets: + CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} + VSCE_PAT: ${{ secrets.VSCE_PAT }} + publish-extension: + uses: ./.github/workflows/publish-extension.yml + with: + version: ${{ github.event.inputs.version }} + pre-release: ${{ github.event.inputs.pre-release }} + secrets: + CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} + VSCE_PAT: ${{ secrets.VSCE_PAT }} \ No newline at end of file diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..c0209ef --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,162 @@ +name: CI +on: + pull_request: + workflow_dispatch: + +jobs: + build: + strategy: + fail-fast: false + matrix: + include: + - os: windows-latest + target: x86_64-pc-windows-msvc + code-target: win32-x64 + - os: windows-latest + target: i686-pc-windows-msvc + - os: windows-latest + target: aarch64-pc-windows-msvc + code-target: win32-arm64 + - os: ubuntu-20.04 + target: x86_64-unknown-linux-gnu + code-target: linux-x64 + - os: macos-11 + target: x86_64-apple-darwin + code-target: darwin-x64 + - os: macos-11 + target: aarch64-apple-darwin + code-target: darwin-arm64 + runs-on: ${{ matrix.os }} + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + fetch-depth: 0 + fetch-tags: true + + - name: Setup rust + if: ${{ matrix.target }} + uses: actions-rs/toolchain@v1 + with: + toolchain: stable + target: ${{ matrix.target }} + override: true + + - uses: actions/setup-node@v4 + + - uses: pnpm/action-setup@v3 + with: + version: latest + + - name: Install dependencies + run: pnpm install + + - name: build + run: | + pnpm run build + + test: + needs: build + strategy: + fail-fast: false + matrix: + include: + - os: windows-latest + target: x86_64-pc-windows-msvc + code-target: win32-x64 + - os: windows-latest + target: i686-pc-windows-msvc + - os: windows-latest + target: aarch64-pc-windows-msvc + code-target: win32-arm64 + - os: ubuntu-20.04 + target: x86_64-unknown-linux-gnu + code-target: linux-x64 + - os: macos-11 + target: x86_64-apple-darwin + code-target: darwin-x64 + - os: macos-11 + target: aarch64-apple-darwin + code-target: darwin-arm64 + runs-on: ${{ matrix.os }} + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + fetch-depth: 0 + fetch-tags: true + + - name: Setup rust + if: ${{ matrix.target }} + uses: actions-rs/toolchain@v1 + with: + toolchain: stable + target: ${{ matrix.target }} + override: true + + - uses: actions/setup-node@v4 + + - uses: pnpm/action-setup@v3 + with: + version: latest + + - name: Install dependencies + run: pnpm install + + - name: test + run: | + pnpm run test + + lint: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + fetch-depth: 0 + fetch-tags: true + + - name: Setup rust + uses: actions-rs/toolchain@v1 + with: + toolchain: stable + override: true + + - uses: pnpm/action-setup@v3 + with: + version: latest + + - name: Install dependencies + run: | + pnpm install + + - name: Format + run: | + pnpm run lint:check + + format: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + fetch-depth: 0 + fetch-tags: true + + - name: Setup rust + uses: actions-rs/toolchain@v1 + with: + toolchain: stable + override: true + + - uses: pnpm/action-setup@v3 + with: + version: latest + + - name: Install dependencies + run: | + pnpm install + + - name: Format + run: | + pnpm run format:check \ No newline at end of file diff --git a/.github/workflows/publish-core.yml b/.github/workflows/publish-core.yml new file mode 100644 index 0000000..3a8e8c7 --- /dev/null +++ b/.github/workflows/publish-core.yml @@ -0,0 +1,42 @@ +name: Publish core + +on: + workflow_dispatch: + workflow_call: + secrets: + CARGO_REGISTRY_TOKEN: + required: true + VSCE_PAT: + required: true + +jobs: + build-and-publish-core: + name: Build and Publish Core + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Setup rust + uses: actions-rs/toolchain@v1 + with: + toolchain: stable + override: true + + - uses: actions/setup-node@v4 + + - uses: pnpm/action-setup@v3 + with: + version: latest + + - name: Install dependencies + run: pnpm install + + - name: build + run: | + pnpm run publish + env: + CARGO_REGISTRY_TOKEN: ${{ inputs.CARGO_REGISTRY_TOKEN || secrets.CARGO_REGISTRY_TOKEN }} + VSCE_PAT: ${{ inputs.VSCE_PAT || secrets.VSCE_PAT }} + + diff --git a/.github/workflows/publish-extension.yml b/.github/workflows/publish-extension.yml new file mode 100644 index 0000000..6854fec --- /dev/null +++ b/.github/workflows/publish-extension.yml @@ -0,0 +1,72 @@ +name: Publish extension + +on: + workflow_call: + inputs: + version: + description: 'Version of the extension' + required: true + type: string + pre-release: + description: 'Publish as a pre-release' + required: false + default: false + type: boolean + secrets: + CARGO_REGISTRY_TOKEN: + required: true + VSCE_PAT: + required: true + + workflow_dispatch: + inputs: + version: + description: 'Version of the extension' + required: true + pre-release: + description: 'Publish as a pre-release' + required: false + default: false + type: boolean + +jobs: + publish: + strategy: + fail-fast: false + matrix: + include: + - os: windows-latest + target: x86_64-pc-windows-msvc + code-target: win32-x64 + #- os: windows-latest + # target: i686-pc-windows-msvc + # code-target: win32-ia32 + - os: windows-latest + target: aarch64-pc-windows-msvc + code-target: win32-arm64 + - os: ubuntu-20.04 + target: x86_64-unknown-linux-gnu + code-target: linux-x64 + #container: ubuntu:18.04 + #- os: ubuntu-20.04 + # target: aarch64-unknown-linux-gnu + # code-target: linux-arm64 + #- os: ubuntu-20.04 + # target: arm-unknown-linux-gnueabihf + # code-target: linux-armhf + - os: macos-11 + target: x86_64-apple-darwin + code-target: darwin-x64 + - os: macos-11 + target: aarch64-apple-darwin + code-target: darwin-arm64 + uses: ./.github/workflows/publish-targeted-extension.yml + with: + os: ${{ matrix.os }} + target: ${{ matrix.target }} + code-target: ${{ matrix.code-target }} + version: ${{ inputs.version }} + pre-release: ${{ inputs.pre-release }} + secrets: + CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} + VSCE_PAT: ${{ secrets.VSCE_PAT }} \ No newline at end of file diff --git a/.github/workflows/publish-targeted-extension.yml b/.github/workflows/publish-targeted-extension.yml new file mode 100644 index 0000000..2071a9e --- /dev/null +++ b/.github/workflows/publish-targeted-extension.yml @@ -0,0 +1,99 @@ +name: Publish targeted extension + +on: + workflow_call: + inputs: + os: + required: true + type: string + description: | + The operating system to run the publish on. + target: + required: true + type: string + description: | + The rust target to build with to publish. + code-target: + required: true + type: string + description: | + The vscode target to publish to. + version: + required: true + type: string + description: | + The version to publish. + pre-release: + required: false + type: boolean + description: | + Whether to publish as a pre-release. + secrets: + CARGO_REGISTRY_TOKEN: + required: true + VSCE_PAT: + required: true + workflow_dispatch: + inputs: + os: + required: true + type: string + description: | + The operating system to run the publish on. + target: + required: true + type: string + description: | + The rust target to build with to publish. + code-target: + required: true + type: string + description: | + The vscode target to publish to. + version: + required: true + type: string + description: | + The version to publish. + pre-release: + required: false + type: boolean + description: | + Whether to publish as a pre-release. + +jobs: + publish: + runs-on: ${{ inputs.os }} + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + fetch-depth: 0 + fetch-tags: true + + - name: Setup rust + if: ${{ inputs.target }} + uses: actions-rs/toolchain@v1 + with: + toolchain: stable + target: ${{ inputs.target }} + override: true + + - uses: actions/setup-node@v4 + + - uses: pnpm/action-setup@v3 + with: + version: latest + + - name: Install dependencies + run: pnpm install + + - name: Build + run: pnpm run build + + - name: Publish + run: pnpm run publish:extension -- --no-update-package-json ${{ inputs.pre-release && '--pre-release' || '' }} ${{ inputs.version }} --target ${{ inputs.code-target }} + env: + VSCE_PAT: ${{ secrets.VSCE_PAT }} + CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} + \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..74413a3 --- /dev/null +++ b/.gitignore @@ -0,0 +1,21 @@ +.yarn/* +!.yarn/patches +!.yarn/plugins +!.yarn/releases +!.yarn/sdks +!.yarn/versions + +# Swap the comments on the following lines if you wish to use zero-installs +# In that case, don't forget to run `yarn config set enableGlobalCache false`! +# Documentation here: https://yarnpkg.com/features/caching#zero-installs + +#!.yarn/cache +.pnp.* + +.turbo + +**/node_modules + +**/target + +.idea \ No newline at end of file diff --git a/.prettierrc.json b/.prettierrc.json new file mode 100644 index 0000000..2f8b425 --- /dev/null +++ b/.prettierrc.json @@ -0,0 +1,10 @@ +{ + "semi": true, + "trailingComma": "all", + "singleQuote": true, + "printWidth": 120, + "tabWidth": 2, + "bracketSpacing": true, + "parser": "typescript", + "endOfLine": "auto" +} \ No newline at end of file diff --git a/.vscode/extensions.json b/.vscode/extensions.json new file mode 100644 index 0000000..dd01eb3 --- /dev/null +++ b/.vscode/extensions.json @@ -0,0 +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", "ms-vscode.extension-test-runner"] +} diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..eb86462 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,32 @@ +// A launch configuration that compiles the extension and then opens it inside a new window +// Use IntelliSense to learn about possible attributes. +// Hover to view descriptions of existing attributes. +// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 +{ + "version": "0.2.0", + "configurations": [ + { + "name": "Run Extension", + "type": "extensionHost", + "request": "launch", + "args": [ + "--extensionDevelopmentPath=${workspaceFolder}/vscode" + ], + "outFiles": [ + "${workspaceFolder}/vscode/dist/**/*.js" + ], + }, + { + "name": "Run Extension (with build)", + "type": "extensionHost", + "request": "launch", + "args": [ + "--extensionDevelopmentPath=${workspaceFolder}/vscode" + ], + "outFiles": [ + "${workspaceFolder}/vscode/dist/**/*.js" + ], + "preLaunchTask": "${defaultBuildTask}" + } + ] +} diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..2a79b77 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,14 @@ +// Place your settings in this file to overwrite default and user settings. +{ + "files.exclude": { + "out": false, // set this to true to hide the "out" folder with the compiled JS files + "dist": false // set this to true to hide the "dist" folder with the compiled JS files + }, + "search.exclude": { + "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 + "typescript.tsc.autoDetect": "off", + "npm.packageManager": "pnpm" +} diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 0000000..57b6ab8 --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,20 @@ +// See https://go.microsoft.com/fwlink/?LinkId=733558 +// for the documentation about the tasks.json format +{ + "version": "2.0.0", + "tasks": [ + { + "type": "npm", + "script": "build:extension", + "problemMatcher": [], + "presentation": { + "reveal": "never", + "group": "watchers" + }, + "group": { + "kind": "build", + "isDefault": true + } + } + ] +} diff --git a/package.json b/package.json new file mode 100644 index 0000000..3fa495f --- /dev/null +++ b/package.json @@ -0,0 +1,25 @@ +{ + "name": "osmium-vyper", + "private": true, + "workspaces": [ + "libs/*", + "servers/*", + "vscode", + "sidebar" + ], + "devDependencies": { + "turbo": "^1.13.3" + }, + "scripts": { + "build": "turbo build && node ./scripts/copy-servers.js && node ./scripts/copy-front.js", + "build:extension": "turbo build:extension && node ./scripts/copy-servers.js && node ./scripts/copy-front.js", + "publish": "turbo publish", + "publish:check": "turbo publish:check", + "publish:extension": "turbo publish:extension", + "test": "turbo test", + "format": "turbo format", + "format:check": "turbo format:check", + "lint": "turbo lint", + "lint:check": "turbo lint:check" + } +} diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml new file mode 100644 index 0000000..b5ffacc --- /dev/null +++ b/pnpm-lock.yaml @@ -0,0 +1,75 @@ +lockfileVersion: '6.0' + +settings: + autoInstallPeers: true + excludeLinksFromLockfile: false + +importers: + + .: + devDependencies: + turbo: + specifier: ^1.13.3 + version: 1.13.4 + +packages: + + /turbo-darwin-64@1.13.4: + resolution: {integrity: sha512-A0eKd73R7CGnRinTiS7txkMElg+R5rKFp9HV7baDiEL4xTG1FIg/56Vm7A5RVgg8UNgG2qNnrfatJtb+dRmNdw==} + cpu: [x64] + os: [darwin] + requiresBuild: true + dev: true + optional: true + + /turbo-darwin-arm64@1.13.4: + resolution: {integrity: sha512-eG769Q0NF6/Vyjsr3mKCnkG/eW6dKMBZk6dxWOdrHfrg6QgfkBUk0WUUujzdtVPiUIvsh4l46vQrNVd9EOtbyA==} + cpu: [arm64] + os: [darwin] + requiresBuild: true + dev: true + optional: true + + /turbo-linux-64@1.13.4: + resolution: {integrity: sha512-Bq0JphDeNw3XEi+Xb/e4xoKhs1DHN7OoLVUbTIQz+gazYjigVZvtwCvgrZI7eW9Xo1eOXM2zw2u1DGLLUfmGkQ==} + cpu: [x64] + os: [linux] + requiresBuild: true + dev: true + optional: true + + /turbo-linux-arm64@1.13.4: + resolution: {integrity: sha512-BJcXw1DDiHO/okYbaNdcWN6szjXyHWx9d460v6fCHY65G8CyqGU3y2uUTPK89o8lq/b2C8NK0yZD+Vp0f9VoIg==} + cpu: [arm64] + os: [linux] + requiresBuild: true + dev: true + optional: true + + /turbo-windows-64@1.13.4: + resolution: {integrity: sha512-OFFhXHOFLN7A78vD/dlVuuSSVEB3s9ZBj18Tm1hk3aW1HTWTuAw0ReN6ZNlVObZUHvGy8d57OAGGxf2bT3etQw==} + cpu: [x64] + os: [win32] + requiresBuild: true + dev: true + optional: true + + /turbo-windows-arm64@1.13.4: + resolution: {integrity: sha512-u5A+VOKHswJJmJ8o8rcilBfU5U3Y1TTAfP9wX8bFh8teYF1ghP0EhtMRLjhtp6RPa+XCxHHVA2CiC3gbh5eg5g==} + cpu: [arm64] + os: [win32] + requiresBuild: true + dev: true + optional: true + + /turbo@1.13.4: + resolution: {integrity: sha512-1q7+9UJABuBAHrcC4Sxp5lOqYS5mvxRrwa33wpIyM18hlOCpRD/fTJNxZ0vhbMcJmz15o9kkVm743mPn7p6jpQ==} + hasBin: true + optionalDependencies: + turbo-darwin-64: 1.13.4 + turbo-darwin-arm64: 1.13.4 + turbo-linux-64: 1.13.4 + turbo-linux-arm64: 1.13.4 + turbo-windows-64: 1.13.4 + turbo-windows-arm64: 1.13.4 + dev: true diff --git a/pnpm-workspace.yaml b/pnpm-workspace.yaml new file mode 100644 index 0000000..99987bc --- /dev/null +++ b/pnpm-workspace.yaml @@ -0,0 +1,5 @@ +packages: + - "libs/*" + - "servers/*" + - "vscode" + - "sidebar" diff --git a/scripts/copy-front.js b/scripts/copy-front.js new file mode 100644 index 0000000..1a356c0 --- /dev/null +++ b/scripts/copy-front.js @@ -0,0 +1,20 @@ +const fs = require('fs'); + +const outputFolder = __dirname + '/../vscode/dist'; + +fs.readdir(`sidebar/dist`, { withFileTypes: true }, (err, entries) => { + if (err) { + console.error(err); + return; + } + const files = entries.filter((file) => file.isFile()).map((file) => file.name); + + files.forEach((file) => { + console.log('Copying front file to vscode/dist', file); + fs.copyFile(`sidebar/dist/${file}`, `${outputFolder}/${file}`, (err) => { + if (err) { + console.error(err); + } + }); + }); +}); diff --git a/scripts/copy-servers.js b/scripts/copy-servers.js new file mode 100644 index 0000000..bf27ac8 --- /dev/null +++ b/scripts/copy-servers.js @@ -0,0 +1,37 @@ +const fs = require('fs'); + +const outputFolder = __dirname + '/../vscode/dist'; + +fs.readdir('servers', { withFileTypes: true }, (err, dirs) => { + if (err) { + console.error(err); + return; + } + const servers = dirs.filter((file) => file.isDirectory()).map((file) => file.name); + servers.forEach((serverDir) => { + fs.readdir(`servers/${serverDir}/target`, { withFileTypes: true }, (err, entries) => { + const directories = entries.filter((directory) => directory.isDirectory()).map((directory) => directory.name); + const targetDirectories = directories.filter((directory) => directory == 'release' || directory == 'debug'); + const typeDir = targetDirectories.find((dir) => dir == 'release') || targetDirectories[0]; + // list server binaries in target directory + fs.readdir(`servers/${serverDir}/target/${typeDir}`, { withFileTypes: true }, (err, entries) => { + if (err) { + console.error(err); + return; + } + const files = entries.filter((file) => file.isFile()).map((file) => file.name); + const serverBinary = files.filter((file) => file.endsWith('-server') || file.endsWith('-server.exe')); + console.log('Copying server binary to vscode/dist', serverBinary); + fs.copyFile( + `servers/${serverDir}/target/${typeDir}/${serverBinary}`, + `${outputFolder}/${serverBinary}`, + (err) => { + if (err) { + console.error(err); + } + }, + ); + }); + }); + }); +}); diff --git a/turbo.json b/turbo.json new file mode 100644 index 0000000..8620764 --- /dev/null +++ b/turbo.json @@ -0,0 +1,36 @@ +{ + "$schema": "https://turbo.build/schema.json", + "pipeline": { + "build": { + "inputs": ["src/**"], + "outputs": ["target/**", "dist/**"], + "cache": false + }, + "build:extension": { + "inputs": ["src/**"], + "outputs": ["target/**", "dist/**"], + "cache": false + }, + "build:extension": { + "outputs": ["dist/**", "target/**"], + "cache": false + }, + "lint": {}, + "lint:check": {}, + "format": {}, + "format:check": {}, + "test": { + "dependsOn": ["^build"], + "cache": false + }, + "publish:check": { + "dependsOn": ["^build", "^publish:check"] + }, + "publish": { + "dependsOn": ["^build", "^publish"] + }, + "publish:extension": { + "dependsOn": ["^build", "^publish:extension"] + } + } +} \ No newline at end of file diff --git a/vscode/.eslintrc.json b/vscode/.eslintrc.json new file mode 100644 index 0000000..86c86f3 --- /dev/null +++ b/vscode/.eslintrc.json @@ -0,0 +1,30 @@ +{ + "root": true, + "parser": "@typescript-eslint/parser", + "parserOptions": { + "ecmaVersion": 6, + "sourceType": "module" + }, + "plugins": [ + "@typescript-eslint" + ], + "rules": { + "@typescript-eslint/naming-convention": [ + "warn", + { + "selector": "import", + "format": [ "camelCase", "PascalCase" ] + } + ], + "@typescript-eslint/semi": "warn", + "curly": "warn", + "eqeqeq": "warn", + "no-throw-literal": "warn", + "semi": "off" + }, + "ignorePatterns": [ + "out", + "dist", + "**/*.d.ts" + ] +} \ No newline at end of file diff --git a/vscode/.npmrc b/vscode/.npmrc new file mode 100644 index 0000000..37d1b60 --- /dev/null +++ b/vscode/.npmrc @@ -0,0 +1 @@ +enable-pre-post-scripts = true \ No newline at end of file diff --git a/vscode/.vscode-test.mjs b/vscode/.vscode-test.mjs new file mode 100644 index 0000000..b62ba25 --- /dev/null +++ b/vscode/.vscode-test.mjs @@ -0,0 +1,5 @@ +import { defineConfig } from '@vscode/test-cli'; + +export default defineConfig({ + files: 'out/test/**/*.test.js', +}); diff --git a/vscode/.vscode/extensions.json b/vscode/.vscode/extensions.json new file mode 100644 index 0000000..dd01eb3 --- /dev/null +++ b/vscode/.vscode/extensions.json @@ -0,0 +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", "ms-vscode.extension-test-runner"] +} diff --git a/vscode/.vscode/launch.json b/vscode/.vscode/launch.json new file mode 100644 index 0000000..c42edc0 --- /dev/null +++ b/vscode/.vscode/launch.json @@ -0,0 +1,21 @@ +// A launch configuration that compiles the extension and then opens it inside a new window +// Use IntelliSense to learn about possible attributes. +// Hover to view descriptions of existing attributes. +// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 +{ + "version": "0.2.0", + "configurations": [ + { + "name": "Run Extension", + "type": "extensionHost", + "request": "launch", + "args": [ + "--extensionDevelopmentPath=${workspaceFolder}" + ], + "outFiles": [ + "${workspaceFolder}/dist/**/*.js" + ], + "preLaunchTask": "${defaultBuildTask}" + } + ] +} diff --git a/vscode/.vscode/settings.json b/vscode/.vscode/settings.json new file mode 100644 index 0000000..16a5c02 --- /dev/null +++ b/vscode/.vscode/settings.json @@ -0,0 +1,13 @@ +// Place your settings in this file to overwrite default and user settings. +{ + "files.exclude": { + "out": false, // set this to true to hide the "out" folder with the compiled JS files + "dist": false // set this to true to hide the "dist" folder with the compiled JS files + }, + "search.exclude": { + "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 + "typescript.tsc.autoDetect": "off" +} diff --git a/vscode/.vscode/tasks.json b/vscode/.vscode/tasks.json new file mode 100644 index 0000000..c2ab68a --- /dev/null +++ b/vscode/.vscode/tasks.json @@ -0,0 +1,40 @@ +// See https://go.microsoft.com/fwlink/?LinkId=733558 +// for the documentation about the tasks.json format +{ + "version": "2.0.0", + "tasks": [ + { + "type": "npm", + "script": "watch", + "problemMatcher": "$ts-webpack-watch", + "isBackground": true, + "presentation": { + "reveal": "never", + "group": "watchers" + }, + "group": { + "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": [] + } + ] +} diff --git a/vscode/.vscodeignore b/vscode/.vscodeignore new file mode 100644 index 0000000..a4b3966 --- /dev/null +++ b/vscode/.vscodeignore @@ -0,0 +1,14 @@ +.vscode/** +.vscode-test/** +out/** +node_modules/** +src/** +.gitignore +.yarnrc +webpack.config.js +vsc-extension-quickstart.md +**/tsconfig.json +**/.eslintrc.json +**/*.map +**/*.ts +**/.vscode-test.* diff --git a/vscode/CHANGELOG.md b/vscode/CHANGELOG.md new file mode 100644 index 0000000..6112e01 --- /dev/null +++ b/vscode/CHANGELOG.md @@ -0,0 +1,9 @@ +# Change Log + +All notable changes to the "osmium-vyper" extension will be documented in this file. + +Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how to structure this file. + +## [Unreleased] + +- Initial release \ No newline at end of file diff --git a/vscode/README.md b/vscode/README.md new file mode 100644 index 0000000..a2902c3 --- /dev/null +++ b/vscode/README.md @@ -0,0 +1,71 @@ +# osmium-vyper README + +This is the README for your extension "osmium-vyper". After writing up a brief description, we recommend including the following sections. + +## Features + +Describe specific features of your extension including screenshots of your extension in action. Image paths are relative to this README file. + +For example if there is an image subfolder under your extension project workspace: + +\!\[feature X\]\(images/feature-x.png\) + +> Tip: Many popular extensions utilize animations. This is an excellent way to show off your extension! We recommend short, focused animations that are easy to follow. + +## Requirements + +If you have any requirements or dependencies, add a section describing those and how to install and configure them. + +## Extension Settings + +Include if your extension adds any VS Code settings through the `contributes.configuration` extension point. + +For example: + +This extension contributes the following settings: + +* `myExtension.enable`: Enable/disable this extension. +* `myExtension.thing`: Set to `blah` to do something. + +## Known Issues + +Calling out known issues can help limit users opening duplicate issues against your extension. + +## Release Notes + +Users appreciate release notes as you update your extension. + +### 1.0.0 + +Initial release of ... + +### 1.0.1 + +Fixed issue #. + +### 1.1.0 + +Added features X, Y, and Z. + +--- + +## Following extension guidelines + +Ensure that you've read through the extensions guidelines and follow the best practices for creating your extension. + +* [Extension Guidelines](https://code.visualstudio.com/api/references/extension-guidelines) + +## Working with Markdown + +You can author your README using Visual Studio Code. Here are some useful editor keyboard shortcuts: + +* Split the editor (`Cmd+\` on macOS or `Ctrl+\` on Windows and Linux). +* Toggle preview (`Shift+Cmd+V` on macOS or `Shift+Ctrl+V` on Windows and Linux). +* Press `Ctrl+Space` (Windows, Linux, macOS) to see a list of Markdown snippets. + +## For more information + +* [Visual Studio Code's Markdown Support](http://code.visualstudio.com/docs/languages/markdown) +* [Markdown Syntax Reference](https://help.github.com/articles/markdown-basics/) + +**Enjoy!** diff --git a/vscode/package.json b/vscode/package.json new file mode 100644 index 0000000..5062a5c --- /dev/null +++ b/vscode/package.json @@ -0,0 +1,47 @@ +{ + "name": "osmium-vyper", + "displayName": "osmium-vyper", + "description": "Osmium toolchain for vyper", + "version": "0.0.1", + "engines": { + "vscode": "^1.91.0" + }, + "categories": [ + "Other" + ], + "activationEvents": [], + "main": "./dist/extension.js", + "contributes": { + "commands": [ + { + "command": "osmium-vyper.helloWorld", + "title": "Hello World" + } + ] + }, + "scripts": { + "vscode:prepublish": "pnpm run package", + "compile": "webpack", + "watch": "webpack --watch", + "package": "webpack --mode production --devtool hidden-source-map", + "compile-tests": "tsc -p . --outDir out", + "watch-tests": "tsc -p . -w --outDir out", + "pretest": "pnpm run compile-tests && pnpm run compile && pnpm run lint", + "lint": "eslint src --ext ts", + "test": "vscode-test" + }, + "devDependencies": { + "@types/vscode": "^1.91.0", + "@types/mocha": "^10.0.7", + "@types/node": "20.x", + "@typescript-eslint/eslint-plugin": "^7.14.1", + "@typescript-eslint/parser": "^7.11.0", + "eslint": "^8.57.0", + "typescript": "^5.4.5", + "ts-loader": "^9.5.1", + "webpack": "^5.92.1", + "webpack-cli": "^5.1.4", + "@vscode/test-cli": "^0.0.9", + "@vscode/test-electron": "^2.4.0" + } +} diff --git a/vscode/src/extension.ts b/vscode/src/extension.ts new file mode 100644 index 0000000..f4507b5 --- /dev/null +++ b/vscode/src/extension.ts @@ -0,0 +1,26 @@ +// The module 'vscode' contains the VS Code extensibility API +// Import the module and reference it with the alias vscode in your code below +import * as vscode from 'vscode'; + +// This method is called when your extension is activated +// Your extension is activated the very first time the command is executed +export function activate(context: vscode.ExtensionContext) { + + // Use the console to output diagnostic information (console.log) and errors (console.error) + // This line of code will only be executed once when your extension is activated + console.log('Congratulations, your extension "osmium-vyper" is now active!'); + + // The command has been defined in the package.json file + // Now provide the implementation of the command with registerCommand + // The commandId parameter must match the command field in package.json + const disposable = vscode.commands.registerCommand('osmium-vyper.helloWorld', () => { + // The code you place here will be executed every time your command is executed + // Display a message box to the user + vscode.window.showInformationMessage('Hello World from osmium-vyper!'); + }); + + context.subscriptions.push(disposable); +} + +// This method is called when your extension is deactivated +export function deactivate() {} diff --git a/vscode/src/test/extension.test.ts b/vscode/src/test/extension.test.ts new file mode 100644 index 0000000..4ca0ab4 --- /dev/null +++ b/vscode/src/test/extension.test.ts @@ -0,0 +1,15 @@ +import * as assert from 'assert'; + +// You can import and use all API from the 'vscode' module +// as well as import your extension to test it +import * as vscode from 'vscode'; +// import * as myExtension from '../../extension'; + +suite('Extension Test Suite', () => { + vscode.window.showInformationMessage('Start all tests.'); + + test('Sample test', () => { + assert.strictEqual(-1, [1, 2, 3].indexOf(5)); + assert.strictEqual(-1, [1, 2, 3].indexOf(0)); + }); +}); diff --git a/vscode/tsconfig.json b/vscode/tsconfig.json new file mode 100644 index 0000000..8a79f20 --- /dev/null +++ b/vscode/tsconfig.json @@ -0,0 +1,16 @@ +{ + "compilerOptions": { + "module": "Node16", + "target": "ES2022", + "lib": [ + "ES2022" + ], + "sourceMap": true, + "rootDir": "src", + "strict": true /* enable all strict type-checking options */ + /* Additional Checks */ + // "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */ + // "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */ + // "noUnusedParameters": true, /* Report errors on unused parameters. */ + } +} diff --git a/vscode/vsc-extension-quickstart.md b/vscode/vsc-extension-quickstart.md new file mode 100644 index 0000000..f518bb8 --- /dev/null +++ b/vscode/vsc-extension-quickstart.md @@ -0,0 +1,48 @@ +# Welcome to your VS Code Extension + +## What's in the folder + +* This folder contains all of the files necessary for your extension. +* `package.json` - this is the manifest file in which you declare your extension and command. + * The sample plugin registers a command and defines its title and command name. With this information VS Code can show the command in the command palette. It doesn’t yet need to load the plugin. +* `src/extension.ts` - this is the main file where you will provide the implementation of your command. + * The file exports one function, `activate`, which is called the very first time your extension is activated (in this case by executing the command). Inside the `activate` function we call `registerCommand`. + * We pass the function containing the implementation of the command as the second parameter to `registerCommand`. + +## Setup + +* install the recommended extensions (amodio.tsl-problem-matcher, ms-vscode.extension-test-runner, and dbaeumer.vscode-eslint) + + +## Get up and running straight away + +* Press `F5` to open a new window with your extension loaded. +* Run your command from the command palette by pressing (`Ctrl+Shift+P` or `Cmd+Shift+P` on Mac) and typing `Hello World`. +* Set breakpoints in your code inside `src/extension.ts` to debug your extension. +* Find output from your extension in the debug console. + +## Make changes + +* You can relaunch the extension from the debug toolbar after changing code in `src/extension.ts`. +* You can also reload (`Ctrl+R` or `Cmd+R` on Mac) the VS Code window with your extension to load your changes. + + +## Explore the API + +* You can open the full set of our API when you open the file `node_modules/@types/vscode/index.d.ts`. + +## Run tests + +* Install the [Extension Test Runner](https://marketplace.visualstudio.com/items?itemName=ms-vscode.extension-test-runner) +* Run the "watch" task via the **Tasks: Run Task** command. Make sure this is running, or tests might not be discovered. +* Open the Testing view from the activity bar and click the Run Test" button, or use the hotkey `Ctrl/Cmd + ; A` +* See the output of the test result in the Test Results view. +* Make changes to `src/test/extension.test.ts` or create new test files inside the `test` folder. + * The provided test runner will only consider files matching the name pattern `**.test.ts`. + * You can create folders inside the `test` folder to structure your tests any way you want. + +## Go further + +* Reduce the extension size and improve the startup time by [bundling your extension](https://code.visualstudio.com/api/working-with-extensions/bundling-extension). +* [Publish your extension](https://code.visualstudio.com/api/working-with-extensions/publishing-extension) on the VS Code extension marketplace. +* Automate builds by setting up [Continuous Integration](https://code.visualstudio.com/api/working-with-extensions/continuous-integration). diff --git a/vscode/webpack.config.js b/vscode/webpack.config.js new file mode 100644 index 0000000..37d7024 --- /dev/null +++ b/vscode/webpack.config.js @@ -0,0 +1,48 @@ +//@ts-check + +'use strict'; + +const path = require('path'); + +//@ts-check +/** @typedef {import('webpack').Configuration} WebpackConfig **/ + +/** @type WebpackConfig */ +const extensionConfig = { + target: 'node', // VS Code extensions run in a Node.js-context πŸ“– -> https://webpack.js.org/configuration/node/ + mode: 'none', // this leaves the source code as close as possible to the original (when packaging we set this to 'production') + + entry: './src/extension.ts', // the entry point of this extension, πŸ“– -> https://webpack.js.org/configuration/entry-context/ + output: { + // the bundle is stored in the 'dist' folder (check package.json), πŸ“– -> https://webpack.js.org/configuration/output/ + path: path.resolve(__dirname, 'dist'), + filename: 'extension.js', + libraryTarget: 'commonjs2' + }, + externals: { + vscode: 'commonjs vscode' // the vscode-module is created on-the-fly and must be excluded. Add other modules that cannot be webpack'ed, πŸ“– -> https://webpack.js.org/configuration/externals/ + // modules added here also need to be added in the .vscodeignore file + }, + resolve: { + // support reading TypeScript and JavaScript files, πŸ“– -> https://github.com/TypeStrong/ts-loader + extensions: ['.ts', '.js'] + }, + module: { + rules: [ + { + test: /\.ts$/, + exclude: /node_modules/, + use: [ + { + loader: 'ts-loader' + } + ] + } + ] + }, + devtool: 'nosources-source-map', + infrastructureLogging: { + level: "log", // enables logging required for problem matchers + }, +}; +module.exports = [ extensionConfig ]; \ No newline at end of file From b80f87c93a44203cc80c288f0b370a6430236de7 Mon Sep 17 00:00:00 2001 From: Enzo Bonato <enzo.bonato@epitech.eu> Date: Wed, 10 Jul 2024 17:38:41 -0400 Subject: [PATCH 2/3] feat: Add script in vscode/package.json --- vscode/package.json | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/vscode/package.json b/vscode/package.json index 5062a5c..8199456 100644 --- a/vscode/package.json +++ b/vscode/package.json @@ -43,5 +43,22 @@ "webpack-cli": "^5.1.4", "@vscode/test-cli": "^0.0.9", "@vscode/test-electron": "^2.4.0" + }, + "scripts": { + "vscode:prepublish": "npm run package", + "compile": "webpack", + "watch": "webpack --watch", + "package": "webpack --mode production --devtool hidden-source-map", + "compile-tests": "tsc -p . --outDir out", + "watch-tests": "tsc -p . -w --outDir out", + "pretest": "npm run compile-tests && npm run compile && npm run lint", + "build": "webpack", + "build:extension": "webpack", + "lint": "eslint src --ext ts --fix", + "lint:check": "eslint src --ext ts", + "format": "prettier --write src/**/*.ts ", + "format:check": "prettier src/**/*.ts", + "test:ui": "vscode-test", + "publish:extension": "webpack --mode production --devtool hidden-source-map && vsce publish --no-dependencies" } } From 2627bc80460a87cb2eb3d5abe4090421fc87f613 Mon Sep 17 00:00:00 2001 From: Enzo Bonato <enzo.bonato@epitech.eu> Date: Thu, 11 Jul 2024 16:47:31 -0400 Subject: [PATCH 3/3] feat: change version of macos in workflows --- .github/workflows/ci.yml | 8 ++++---- .github/workflows/publish-extension.yml | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c0209ef..adfa50c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -20,10 +20,10 @@ jobs: - os: ubuntu-20.04 target: x86_64-unknown-linux-gnu code-target: linux-x64 - - os: macos-11 + - os: macos-13 target: x86_64-apple-darwin code-target: darwin-x64 - - os: macos-11 + - os: macos-13 target: aarch64-apple-darwin code-target: darwin-arm64 runs-on: ${{ matrix.os }} @@ -72,10 +72,10 @@ jobs: - os: ubuntu-20.04 target: x86_64-unknown-linux-gnu code-target: linux-x64 - - os: macos-11 + - os: macos-13 target: x86_64-apple-darwin code-target: darwin-x64 - - os: macos-11 + - os: macos-13 target: aarch64-apple-darwin code-target: darwin-arm64 runs-on: ${{ matrix.os }} diff --git a/.github/workflows/publish-extension.yml b/.github/workflows/publish-extension.yml index 6854fec..91d9df4 100644 --- a/.github/workflows/publish-extension.yml +++ b/.github/workflows/publish-extension.yml @@ -54,10 +54,10 @@ jobs: #- os: ubuntu-20.04 # target: arm-unknown-linux-gnueabihf # code-target: linux-armhf - - os: macos-11 + - os: macos-13 target: x86_64-apple-darwin code-target: darwin-x64 - - os: macos-11 + - os: macos-13 target: aarch64-apple-darwin code-target: darwin-arm64 uses: ./.github/workflows/publish-targeted-extension.yml