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

Declare support for Terraform Stacks #1773

Merged
merged 6 commits into from
Jun 18, 2024
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
6 changes: 6 additions & 0 deletions .changes/unreleased/ENHANCEMENTS-20240611-152455.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
kind: ENHANCEMENTS
body: Declare support for Terraform Stack files
time: 2024-06-11T15:24:55.009488-04:00
custom:
Issue: "1773"
Repository: vscode-terraform
42 changes: 24 additions & 18 deletions build/downloader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,38 +108,44 @@ async function downloadLanguageServer(platform: string, architecture: string, ex
});
}

async function downloadFile(url: string, installPath: string) {
if (process.env.downloader_log === 'true') {
console.log(`Downloading: ${url}`);
}

const buffer = await fileFromUrl(url);
fs.writeFileSync(installPath, buffer);
if (process.env.downloader_log === 'true') {
console.log(`Download completed: ${installPath}`);
}
}

async function downloadSyntax(info: ExtensionInfo) {
const release = `v${info.syntaxVersion}`;

const productName = info.name.replace('-preview', '');
const fileName = `${productName}.tmGrammar.json`;

const cwd = path.resolve(__dirname);
const buildDir = path.basename(cwd);
const repoDir = cwd.replace(buildDir, '');
const installPath = path.join(repoDir, 'syntaxes');

const fpath = path.join(installPath, fileName);
if (fs.existsSync(fpath)) {
if (fs.existsSync(installPath)) {
dbanck marked this conversation as resolved.
Show resolved Hide resolved
if (process.env.downloader_log === 'true') {
console.log(`Syntax path exists at ${fpath}. Exiting`);
console.log(`Syntax path exists at ${installPath}. Removing`);
}
return;
fs.rmSync(installPath, { recursive: true });
}

fs.mkdirSync(installPath);

const url = `https://github.com/hashicorp/syntax/releases/download/${release}/${fileName}`;
if (process.env.downloader_log === 'true') {
console.log(`Downloading: ${url}`);
}
// const content = await got({ url }).text();
// fs.writeFileSync(fpath, content);
const buffer = await fileFromUrl(url);
fs.writeFileSync(fpath, buffer);
if (process.env.downloader_log === 'true') {
console.log(`Download completed: ${fpath}`);
}
const productName = info.name.replace('-preview', '');
const terraformSyntaxFile = `${productName}.tmGrammar.json`;
const hclSyntaxFile = `hcl.tmGrammar.json`;

let url = `https://github.com/hashicorp/syntax/releases/download/${release}/${terraformSyntaxFile}`;
await downloadFile(url, path.join(installPath, terraformSyntaxFile));

url = `https://github.com/hashicorp/syntax/releases/download/${release}/${hclSyntaxFile}`;
await downloadFile(url, path.join(installPath, hclSyntaxFile));
}

async function run(platform: string, architecture: string) {
Expand Down
30 changes: 30 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,26 @@
],
"configuration": "./language-configuration.json"
},
{
"id": "terraform-stack",
"aliases": [
"Terraform Stack"
],
"extensions": [
".tfstack.hcl"
],
"configuration": "./language-configuration.json"
},
{
"id": "terraform-deploy",
"aliases": [
"Terraform Deployment"
],
"extensions": [
".tfdeploy.hcl"
],
"configuration": "./language-configuration.json"
},
{
"id": "json",
"extensions": [
Expand All @@ -92,6 +112,16 @@
"language": "terraform-vars",
"scopeName": "source.hcl.terraform",
"path": "./syntaxes/terraform.tmGrammar.json"
},
{
"language": "terraform-stack",
"scopeName": "source.hcl",
"path": "./syntaxes/hcl.tmGrammar.json"
},
{
"language": "terraform-deploy",
"scopeName": "source.hcl",
"path": "./syntaxes/hcl.tmGrammar.json"
}
],
"semanticTokenTypes": [
Expand Down
Loading