Skip to content

Commit

Permalink
feat: Only update extension files on version update [release] (#26)
Browse files Browse the repository at this point in the history
  • Loading branch information
harrydowning committed Jul 6, 2024
1 parent df77f69 commit c847800
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 24 deletions.
10 changes: 9 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p

## [Unreleased]

## [0.3.3] - 2024-07-06

### Changed

- Only update extension files on version update
- Doc formatting and links

## [0.3.2] - 2024-07-06

### Fixed
Expand Down Expand Up @@ -60,7 +67,8 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p

- Highlighting support for 40 languages in YAML block-scalars

[unreleased]: https://github.com/harrydowning/yaml-embedded-languages/compare/v0.3.2...HEAD
[unreleased]: https://github.com/harrydowning/yaml-embedded-languages/compare/v0.3.3...HEAD
[0.3.3]: https://github.com/harrydowning/yaml-embedded-languages/compare/v0.3.2...v0.3.3
[0.3.2]: https://github.com/harrydowning/yaml-embedded-languages/compare/v0.3.1...v0.3.2
[0.3.1]: https://github.com/harrydowning/yaml-embedded-languages/compare/v0.3.0...v0.3.1
[0.3.0]: https://github.com/harrydowning/yaml-embedded-languages/compare/v0.2.0...v0.3.0
Expand Down
8 changes: 4 additions & 4 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,20 @@

Thank you for taking an interest in contributing to this project. All contributions are welcome. Please find below the suggested contribution, development, and release workflows.

## Contribution Workflow [#](#contribution-workflow- "Contribution Workflow")
## Contribution Workflow

- Raise/find an [issue](https://github.com/harrydowning/yaml-embedded-languages/issues) to fix
- Fork the repository
- Implement changes (see [development workflow](#development-workflow-))
- Implement changes (see [development workflow](#development-workflow))
- Create pull request

## Development Workflow [#](#development-workflow- "Development Workflow")
## Development Workflow

- Implement changes, ensuring any to `package.json` or `syntaxes/injection.json` are reflected in `extension.js`
- Run `node extension.js -dev` to update `package.json` and `syntaxes/injection.json`
- Use F5 within Vs Code to test the extension

## Release Workflow [#](#release-workflow- "Release Workflow")
## Release Workflow

- Update `VERSION` in `extension.js` and run `node extension.js -dev`
- Update `CHANGELOG.md`
Expand Down
31 changes: 19 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,23 @@
<div align="center">

# YAML Embedded Languages

![GitHub](https://img.shields.io/github/license/harrydowning/yaml-embedded-languages?color=forest) ![Visual Studio Marketplace Version (including pre-releases)](https://img.shields.io/visual-studio-marketplace/v/harrydowning.yaml-embedded-languages?color=red) ![Visual Studio Marketplace Downloads](https://img.shields.io/visual-studio-marketplace/d/harrydowning.yaml-embedded-languages?color=rebeccapurple)
![GitHub License](https://img.shields.io/github/license/harrydowning/yaml-embedded-languages?style=for-the-badge)
![Visual Studio Marketplace Version](https://img.shields.io/visual-studio-marketplace/v/harrydowning.yaml-embedded-languages?style=for-the-badge)
![Visual Studio Marketplace Downloads](https://img.shields.io/visual-studio-marketplace/d/harrydowning.yaml-embedded-languages?style=for-the-badge&color=rebeccapurple)

</div>

## Features [#](#features- 'Features')
## Features

Syntax highlighting within YAML block-scalars for [40+ built-in languages](#built-in-languages- 'Built-In Languages') and the ability to add highlighting for any other language with the [yaml-embedded-languages.include](#extension-settings- 'Extension Settings') configuration setting.
Syntax highlighting within YAML block-scalars for [40+ built-in languages](#built-in-languages "Built-In Languages") and the ability to add highlighting for any other language with the [yaml-embedded-languages.include](#extension-settings "Extension Settings") configuration setting.

![Example yaml file showing syntax highlighting](https://raw.githubusercontent.com/harrydowning/yaml-embedded-languages/master/images/example.png)

### Built-In Languages [#](#built-in-languages- 'Built-In Languages')
### Built-In Languages

The following list shows all valid identifiers for the built-in languages:

- c
- clojure
- coffee
Expand Down Expand Up @@ -52,25 +60,24 @@ The following list shows all valid identifiers for the built-in languages:
- xml
- yaml (Yes, YAML within YAML!)

## Requirements [#](#requirements- 'Requirements')
## Requirements

None

## Extension Settings [#](#extension-settings- 'Extension Settings')
## Extension Settings

| Name | Description |
| ---- | ----------- |
| Name | Description |
| --------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `yaml-embedded-languages.include` | Allows the user to include their own languages by providing an object where each key defines the language identifier with regex and the corresponding value specifies the language TextMate `scopeName`. This can be used to add any other language, which could be from another extension. This also allows the user to override any language identifiers currently used for the built-in languages. |

## Known Issues [#](#known-issues- 'Known Issues')
## Known Issues

See [Issues](https://github.com/harrydowning/yaml-embedded-languages/issues)


## Contribution Notes [#](#contribution-notes- 'Contribution Notes')
## Contribution Notes

See [CONTRIBUTING](CONTRIBUTING.md)

## Release Notes [#](#release-notes- 'Release Notes')
## Release Notes

See [CHANGELOG](CHANGELOG.md)
17 changes: 13 additions & 4 deletions extension.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,16 @@ const vscode = DEV_MODE ? null : require("vscode");
const fs = require("fs");

const NAME = "yaml-embedded-languages";
const VERSION = "0.3.2";
const VERSION = "0.3.3";
const DISPLAY_NAME = "YAML Embedded Languages";
const PUBLISHER = "harrydowning";
const INJECTION_PATH = "./syntaxes/injection.json";
const SCOPE_NAME = `${NAME}.injection`;
const SUB_INCLUDE_CONFIG = "include";
const INCLUDE_CONFIG = `${NAME}.${SUB_INCLUDE_CONFIG}`;
const LANGUAGE_SCOPE_PREFIX = "meta.embedded.inline";
const REPOSITORY_SUFFIX = "block-scalar";
const GLOBAL_STATE_VERSION = "version";

const LANGUAGES = {
c: "source.c",
Expand Down Expand Up @@ -75,7 +77,7 @@ const getPackageJson = (languages) => ({
displayName: DISPLAY_NAME,
description: "Support for syntax highlighting within YAML block-scalars.",
icon: "images/icon.png",
publisher: "harrydowning",
publisher: PUBLISHER,
author: {
name: "Harry Downing",
email: "harry.downing17@gmail.com",
Expand Down Expand Up @@ -131,7 +133,7 @@ const getPatterns = (languages) => {
};

const getRepository = (languages) => {
entries = Object.entries(languages);
const entries = Object.entries(languages);
return Object.fromEntries(
entries.map(([name, scopeName]) => [
`${name}-${REPOSITORY_SUFFIX}`,
Expand Down Expand Up @@ -231,7 +233,14 @@ const updateExtension = () => {
};

const activate = (context) => {
updateExtension();
const extension = vscode.extensions.getExtension(`${PUBLISHER}.${NAME}`);
const currentVersion = extension.packageJSON.version;
const previousVersion = context.globalState.get(GLOBAL_STATE_VERSION);

if (previousVersion !== currentVersion) {
updateExtension();
context.globalState.update(GLOBAL_STATE_VERSION, currentVersion);
}

let disposable = vscode.workspace.onDidChangeConfiguration((event) => {
if (event.affectsConfiguration(INCLUDE_CONFIG)) {
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "yaml-embedded-languages",
"version": "0.3.2",
"version": "0.3.3",
"displayName": "YAML Embedded Languages",
"description": "Support for syntax highlighting within YAML block-scalars.",
"icon": "images/icon.png",
Expand Down

0 comments on commit c847800

Please sign in to comment.