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 5 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
4 changes: 2 additions & 2 deletions .github/workflows/preview.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ jobs:
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:
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 }}
13 changes: 0 additions & 13 deletions build/nightly.md

This file was deleted.

32 changes: 15 additions & 17 deletions build/preview
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,24 @@ ROOT_RELATIVE_DIR=$(dirname "${SCRIPT_RELATIVE_DIR}")

cd $ROOT_RELATIVE_DIR

# get current version info
VERSION=`git log -1 --format=%cd --date="format:%Y.%-m.%-d%H"`
# 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

# Get existing name & description
DISPLAY_NAME="$(jq -r .displayName package.json) (Preview)"
DESCRIPTION="$(jq -r .description package.json) (Preview)"

# set preview info in package.json
(cat package.json | jq --arg VER $VERSION --arg LANGVER $LANGUAGE_SERVER_VERSION --arg NAME "$DISPLAY_NAME" --arg DESC "$DESCRIPTION" '
# Update versions in package.json
(cat package.json | jq --arg VER $VER --arg LANGVER $LANGUAGE_SERVER_VERSION '
.version=$VER |
.langServer.version=$LANGVER |
.preview=true |
.name="terraform-preview" |
.icon="assets/icons/terraform_logo_mark_dark_universal.png" |
radeksimko marked this conversation as resolved.
Show resolved Hide resolved
.displayName=$NAME |
.description=$DESC
.langServer.version=$LANGVER
') > /tmp/package.json && mv /tmp/package.json package.json

# prepend preview info to README.md
sed '/^# Terraform Extension for Visual Studio Code$/d' README.md | cat build/nightly.md - > /tmp/rdme && mv /tmp/rdme README.md
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;
}