Skip to content
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
7 changes: 6 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,9 @@ lerna-debug.log
packages/backend/dummy/main.js

# this folder should be initially empty when running the contributor snippet example.
examples/dummy-scripts/.vscode
examples/dummy-scripts/.vscode

# macOS
.DS_Store

yarn-error.log
21 changes: 10 additions & 11 deletions packages/backend/README.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
# Code Snippet (Framework) VSCode Extension
# Code Snippet Tool VSCode Extension

## Preview

![form gui screenshot](./resources/preview.png)
![Form GUI Screenshot](./resources/preview.png)

## Description
## Overview

This component is the VSCode extension part of the VSCode Code Snippet Framework.
It is responsible for:
This package is the VSCode extension for the Code Snippet Tool. It enables:

- Loading code snippets contributions (plugins) (e.g [vscode-snippet-contrib](../../examples)).
- Rendering the code snippet form GUI to display relevant questions to the end user:
- inside a [VSCode webview](https://code.visualstudio.com/api/extension-guides/webview).
- Note that the form GUI is developed, in a separate [sub-package](../frontend).
- Bridging between the frontend GUI and the contributions/plugins, e.g:
- Loading code snippet contributions (plugins) for extensibility.
- Rendering a dynamic code snippet form GUI in a [VSCode webview](https://code.visualstudio.com/api/extension-guides/webview) to present relevant questions to users. The form GUI is developed as a separate sub-package.
- Bridging between the frontend GUI and snippet contributions/plugins, including:
- Invoking custom validation logic.
- Sending the "answers" of the end user back to the contribution/plugin.
- Sending user-provided answers back to the respective contribution/plugin.

This architecture supports interactive, extensible code snippet generation in VSCode, combining custom logic with a modern user interface.
4 changes: 2 additions & 2 deletions packages/backend/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "code-snippet-framework",
"displayName": "Code Snippet",
"name": "code-snippet-tool",
"displayName": "Code Snippet Tool",
"version": "2.0.0",
"private": true,
"description": "A VSCode extension that provides a simple way to add code snippets.",
Expand Down
10 changes: 10 additions & 0 deletions packages/wrapper/.nycrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"require": ["ts-node/register/transpile-only"],
"include": ["src/**/*.ts"],
"reporter": ["lcov", "text"],
"extension": [".ts"],
"all": true,
"temp-dir": "./reports/.nyc_output",
"report-dir": "./reports/coverage",
"check-coverage": true
}
10 changes: 10 additions & 0 deletions packages/wrapper/.vscodeignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
**
!LICENSES
!.reuse
!LICENSE
!README.md
!package.json
!logo.png
!dist/media
!dist/*.js
!resources
4 changes: 4 additions & 0 deletions packages/wrapper/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Change Log

All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
3 changes: 3 additions & 0 deletions packages/wrapper/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Code Snippet Wrapper VSCode Extension

> **Deprecated:** Please use [saposs.code-snippet-tool](https://marketplace.visualstudio.com/items?itemName=saposs.code-snippet-tool) instead.
Binary file added packages/wrapper/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
57 changes: 57 additions & 0 deletions packages/wrapper/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
{
"name": "code-snippet",
"displayName": "Code Snippet wrapper",
"version": "2.0.0",
"private": true,
"description": "A VSCode extension that provides a simple way to add code snippets.",
"categories": [
"Other"
],
"keywords": [
"code",
"snippet",
"snipping ",
"tool",
"sap"
],
"bugs": {
"url": "https://github.com/SAP/code-snippet/issues"
},
"repository": {
"type": "git",
"url": "https://github.com/SAP/code-snippet.git"
},
"license": "Apache 2.0",
"publisher": "SAPOSS",
"main": "./dist/extension",
"scripts": {
"bundle": "webpack --mode production",
"bundle-dev": "webpack --mode development --watch",
"ci": "npm-run-all clean compile coverage bundle package coverage coverage:copy",
"clean": "rimraf ./dist ./coverage *.vsix",
"compile": "tsc -p ./",
"coverage": "nyc mocha -p tsconfig.json --recursive test/**/*.spec.ts",
"coverage:copy": "shx mkdir -p ../../coverage && shx cp -u ./reports/coverage/lcov.info ../../coverage/lcov_backend.info",
"package": "vsce package --yarn .",
"test": "mocha -p tsconfig.json --recursive test/**/*.spec.ts"
},
"activationEvents": [],
"extensionDependencies": [
"saposs.code-snippet-tool"
],
"devDependencies": {
"@types/sinon": "^10.0.11",
"copy-webpack-plugin": "^5.0.5",
"sinon": "^9.2.1",
"string-replace-loader": "^2.1.1",
"ts-loader": "^8.0.14",
"ts-node": "^9.1.1",
"vsce": "^1.73.0",
"webpack": "^5.89.0",
"webpack-cli": "5.1.4"
},
"engines": {
"vscode": "^1.44.2"
},
"icon": "logo.png"
}
7 changes: 7 additions & 0 deletions packages/wrapper/src/extension.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export function activate(): void {
console.log("Extension activated");
}

export function deactivate(): void {
console.log("Extension deactivated");
}
26 changes: 26 additions & 0 deletions packages/wrapper/test/extension.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { expect } from "chai";
import * as sinon from "sinon";

import * as extension from "../src/extension";

describe("extension unit test", () => {
let sandbox: any;

before(() => {
sandbox = sinon.createSandbox();
});

after(() => {
sandbox.restore();
});

describe("activate", () => {
it("activation", () => {
expect(extension.activate()).to.be.undefined;
});
});

it("deactivate", () => {
expect(extension.deactivate()).to.be.undefined;
});
});
15 changes: 15 additions & 0 deletions packages/wrapper/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"rootDir": ".",
"resolveJsonModule": true,
"esModuleInterop": true,
"outDir": "out",
"baseUrl": ".",
// Less strict options due to legacy code - BEGIN
"noImplicitAny": false,
"strictNullChecks": false
// Less strict options due to legacy code - END
},
"include": ["src/**/*", "test/**/*", "test"]
}
42 changes: 42 additions & 0 deletions packages/wrapper/webpack.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
"use strict";

const path = require("path");

const config = {
target: "node", // vscode extensions run in a Node.js-context 📖 -> https://webpack.js.org/configuration/node/
node: { global: true },
entry: ["./src/extension.ts"], // the entry point of this extension, 📖 -> https://webpack.js.org/configuration/entry-context/
devtool: "source-map",
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",
devtoolModuleFilenameTemplate: "../[resource-path]",
},
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/
},
resolve: {
extensions: [".ts", ".js"],
alias: {},
},
module: {
rules: [
{
test: /\.ts$/,
exclude: /node_modules/,
use: [
{
loader: "ts-loader",
options: {},
},
],
},
],
},
optimization: {},
plugins: [],
};

module.exports = config;
3 changes: 3 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
{
"path": "./packages/backend"
},
{
"path": "./packages/wrapper"
},
{
"path": "./packages/types"
},
Expand Down
Loading