Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Onboard to pre-release extensions #1412

Merged
merged 9 commits into from
May 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions .github/workflows/preview.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
workflow_dispatch:
inputs:
langserver:
description: "The terraform-ls version to use. If not specified will use version in package.json"
description: 'The terraform-ls version to use. If not specified will use version in package.json'
required: false
type: string

Expand Down Expand Up @@ -44,32 +44,32 @@ jobs:
- vsce_target: darwin-arm64
ls_target: darwin_arm64
npm_config_arch: arm64
runs-on: "ubuntu-latest"
runs-on: 'ubuntu-latest'
steps:
- name: Check out repository
uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # https://github.com/actions/checkout/releases/tag/v3.5.2
- name: Set preview in package.json
id: set-preview
run: |
./build/preview
./build/preview.sh
env:
LANGUAGE_SERVER_VERSION: ${{ github.event.inputs.langserver }}
- name: Setup Node
uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # https://github.com/actions/setup-node/releases/tag/v3.6.0
with:
node-version-file: ".nvmrc"
node-version-file: '.nvmrc'
- name: Install dependencies
run: npm ci
env:
npm_config_arch: ${{ matrix.npm_config_arch }}
ls_target: ${{ matrix.ls_target }}
- name: Package VSIX
run: npm run package -- --target=${{ matrix.vsce_target }}
run: npm run package -- --pre-release --target=${{ matrix.vsce_target }}
- name: Upload vsix as artifact
uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # https://github.com/actions/upload-artifact/releases/tag/v3.1.2
with:
name: ${{ matrix.vsce_target }}
path: "*.vsix"
path: '*.vsix'
- name: Check latest published version
shell: bash
run: |
Expand All @@ -84,6 +84,6 @@ jobs:
steps:
- uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a # https://github.com/actions/download-artifact/releases/tag/v3.0.2
- name: Publish Preview Extension
run: npx vsce publish --no-git-tag-version --packagePath $(find . -iname *.vsix)
run: npx vsce publish --pre-release --no-git-tag-version --packagePath $(find . -iname *.vsix)
env:
VSCE_PAT: ${{ secrets.VSCE_PAT }}
Binary file not shown.
13 changes: 0 additions & 13 deletions build/nightly.md

This file was deleted.

32 changes: 0 additions & 32 deletions build/preview

This file was deleted.

32 changes: 32 additions & 0 deletions build/preview.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/bin/bash
# Copyright (c) HashiCorp, Inc.
# SPDX-License-Identifier: MPL-2.0

set -eEuo pipefail

SCRIPT_RELATIVE_DIR=$(dirname "${BASH_SOURCE[0]}")
ROOT_RELATIVE_DIR=$(dirname "${SCRIPT_RELATIVE_DIR}")

cd $ROOT_RELATIVE_DIR

# Get current version info
VERSION=$(cat package.json | jq -r '.version') # e.g. 2.26.0
MAJOR=$(echo $VERSION | cut -d. -f1)
MINOR=$(echo $VERSION | cut -d. -f2)
# Build new version
#
# For the pre-release build, we keep the major and minor versions
# and add the timestamp of the last commit as a patch.
NEW_PATCH=`git log -1 --format=%cd --date="format:%Y%m%d%H"` # e.g. 2023050312
VER="$MAJOR.$MINOR.$NEW_PATCH"

# Update the language server version if passed via the workflow
if [ -z "${LANGUAGE_SERVER_VERSION:-}" ]; then
LANGUAGE_SERVER_VERSION="$(jq -r .langServer.version package.json)"
fi

# Update versions in package.json
(cat package.json | jq --arg VER $VER --arg LANGVER $LANGUAGE_SERVER_VERSION '
.version=$VER |
.langServer.version=$LANGVER
') > /tmp/package.json && mv /tmp/package.json package.json
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -669,8 +669,7 @@
"lint": "eslint src --ext ts",
"prettier": "prettier \"**/*.+(js|json|ts)\"",
"format": "npm run prettier -- --write",
"check-format": "npm run prettier -- --check",
"preview": "ts-node ./build/preview.ts"
"check-format": "npm run prettier -- --check"
},
"dependencies": {
"@vscode/extension-telemetry": "^0.4.9",
Expand Down
7 changes: 1 addition & 6 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import { ShowReferencesFeature } from './features/showReferences';
import { CustomSemanticTokens } from './features/semanticTokens';
import { ModuleProvidersFeature } from './features/moduleProviders';
import { ModuleCallsFeature } from './features/moduleCalls';
import { getInitializationOptions, migrateLegacySettings, previewExtensionPresent } from './settings';
import { getInitializationOptions, migrateLegacySettings } from './settings';
import { TerraformLSCommands } from './commands/terraformls';
import { TerraformCommands } from './commands/terraform';
import { TerraformVersionFeature } from './features/terraformVersion';
Expand All @@ -51,11 +51,6 @@ export async function activate(context: vscode.ExtensionContext): Promise<void>
reporter = new TelemetryReporter(context.extension.id, manifest.version, manifest.appInsightsKey);
context.subscriptions.push(reporter);

if (previewExtensionPresent(context.extension.id)) {
reporter.sendTelemetryEvent('previewExtensionPresentWithStable');
return undefined;
}

await migrateLegacySettings(context);

// always register commands needed to control terraform-ls
Expand Down
21 changes: 0 additions & 21 deletions src/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,24 +157,3 @@ export async function migrateLegacySettings(ctx: vscode.ExtensionContext) {
await deleteSetting('terraform-ls', 'experimentalFeatures');
await vscode.commands.executeCommand('workbench.action.reloadWindow');
}

export function previewExtensionPresent(currentExtensionID: string) {
const stable = vscode.extensions.getExtension('hashicorp.terraform');
const preview = vscode.extensions.getExtension('hashicorp.terraform-preview');

const msg = 'Please ensure only one is enabled or installed and reload this window';

if (currentExtensionID === 'hashicorp.terraform-preview') {
if (stable !== undefined) {
vscode.window.showErrorMessage('Terraform Preview cannot be used while Terraform Stable is also enabled.' + msg);
return true;
}
} else if (currentExtensionID === 'hashicorp.terraform') {
if (preview !== undefined) {
vscode.window.showErrorMessage('Terraform Stable cannot be used while Terraform Preview is also enabled.' + msg);
return true;
}
}

return false;
}