From 526380f20605f3a39778714ef8f4859b13d70224 Mon Sep 17 00:00:00 2001 From: Alexander Gilin Date: Thu, 21 Aug 2025 13:29:21 +0300 Subject: [PATCH 1/2] refactor: add `code-snippet` wrapper extension during transition period --- .gitignore | 7 ++- packages/backend/README.md | 21 +++++---- packages/wrapper/.nycrc.json | 10 +++++ packages/wrapper/.vscodeignore | 10 +++++ packages/wrapper/CHANGELOG.md | 4 ++ packages/wrapper/README.md | 3 ++ packages/wrapper/logo.png | Bin 0 -> 2623 bytes packages/wrapper/package.json | 57 ++++++++++++++++++++++++ packages/wrapper/src/extension.ts | 7 +++ packages/wrapper/test/extension.spec.ts | 26 +++++++++++ packages/wrapper/tsconfig.json | 15 +++++++ packages/wrapper/webpack.config.js | 42 +++++++++++++++++ tsconfig.json | 3 ++ 13 files changed, 193 insertions(+), 12 deletions(-) create mode 100644 packages/wrapper/.nycrc.json create mode 100644 packages/wrapper/.vscodeignore create mode 100644 packages/wrapper/CHANGELOG.md create mode 100644 packages/wrapper/README.md create mode 100644 packages/wrapper/logo.png create mode 100644 packages/wrapper/package.json create mode 100644 packages/wrapper/src/extension.ts create mode 100644 packages/wrapper/test/extension.spec.ts create mode 100644 packages/wrapper/tsconfig.json create mode 100644 packages/wrapper/webpack.config.js diff --git a/.gitignore b/.gitignore index 5af01e1..cedea92 100644 --- a/.gitignore +++ b/.gitignore @@ -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 \ No newline at end of file +examples/dummy-scripts/.vscode + +# macOS +.DS_Store + +yarn-error.log \ No newline at end of file diff --git a/packages/backend/README.md b/packages/backend/README.md index a7ec3c1..2760349 100644 --- a/packages/backend/README.md +++ b/packages/backend/README.md @@ -1,18 +1,17 @@ -# Code Snippet (Framework) VSCode Extension +# Code Snippet Framework 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 Framework. 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. \ No newline at end of file diff --git a/packages/wrapper/.nycrc.json b/packages/wrapper/.nycrc.json new file mode 100644 index 0000000..994596e --- /dev/null +++ b/packages/wrapper/.nycrc.json @@ -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 +} diff --git a/packages/wrapper/.vscodeignore b/packages/wrapper/.vscodeignore new file mode 100644 index 0000000..14905a8 --- /dev/null +++ b/packages/wrapper/.vscodeignore @@ -0,0 +1,10 @@ +** +!LICENSES +!.reuse +!LICENSE +!README.md +!package.json +!logo.png +!dist/media +!dist/*.js +!resources diff --git a/packages/wrapper/CHANGELOG.md b/packages/wrapper/CHANGELOG.md new file mode 100644 index 0000000..e4d87c4 --- /dev/null +++ b/packages/wrapper/CHANGELOG.md @@ -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. diff --git a/packages/wrapper/README.md b/packages/wrapper/README.md new file mode 100644 index 0000000..ff2e7fc --- /dev/null +++ b/packages/wrapper/README.md @@ -0,0 +1,3 @@ +# Code Snippet Wrapper VSCode Extension + +> **Deprecated:** Please use [saposs.ccode-snippet-framework](https://marketplace.visualstudio.com/items?itemName=saposs.ccode-snippet-framework) instead. \ No newline at end of file diff --git a/packages/wrapper/logo.png b/packages/wrapper/logo.png new file mode 100644 index 0000000000000000000000000000000000000000..131cf018ef8c0f30264dbbac0d06009d085ff09a GIT binary patch literal 2623 zcmaJ@`8yQ)7ycOA7_wv;jAe*WmO+fA#?aWZ%XVc;Sw~!zoy=ISwWKVeP_(Ekrb!56 z>>^VLLyBf9`<4n}=Ij0g-{*PHd7tyV=a={VaL&ncw6{D2lZF8R4q02_oDZ1rUqE>d zau??O-~n-5akexA&uKCX2L)GeoFN3`%ter{=15OIaXv+b>K`{LY1!F%a2#hQ z^bgj@bK`I>E)E$IS!2p$eg^$~Go)`RqOQ%jcxUDwsgLQsMx(Wnb;)xowSnKmUoeg5 zlHZ-$nl{$WMM6{lKcKp$&A-xVls+EGpwo9r9L#Q6+tF3s_8&ZR@|Pc756%s0?q$cL zH$T@6MN~5_Wd)wKY8S@E(Dy9VC{O^uekIy%^kr&bzO%vHkZzm*q07A)*ClR;<2CBFDq4GZ%KKlGKbPs!4i3FRDjJu>f07F#-Ptu+ znEIuJsIVdpv-Qcodyj5k_jM?lSvQqZBy8wC+UJX!|J2ZFFIRTaQhvsRmk|H*A=7{9 zmE4oAd5@fpMwN*r>RJSGs@&ilx!vlW}7PHoOAty_zM2riXejotALx-+*(| z>iJzlw5w!a)~mB#)Yez8BaUuf8{Zqydvf}g@}aG_Bkz(}g1djc2L`3*lIYPfQfKr#%y;Q+ zHKl*z(bXTbHO36=JeOl}6NgOvI5)BvAMI*QyFkoPDEXXysCyGAHI|sk8-_qhv&p*u{W;w++TDF?Ad~LMp{+6NVS-P{= zpIkcAPu{btourj=A$87@It{(^WKlVpMw|1Gi&>EiGg-{=^jS|Jg!!{RxopNr_tG3s zbK6+w99+Kdpi!sn17+VS$sxyRHe?IYDYcFUiGB-{Xf`U^N6dwIoMUf&w}sZuYWd`A zhS~di_O}1!xsHs^3Ob*$aOZ+<3w=#%nd+5}X{(%xh)oe1s%xwcPi3xL-Io!b+c}Fjmp0Ancw(L?F$`PEK^JSWqr@Ag!D1JC@}-qK50%t+ zY$$>2{)G2TYcNf+&4$XCb5-u5waipIt3W?znk)>0kXeLC%Q!$hycM|9WZ%gl&qRVp zu93F`k9;xYQTDL&mL(~iSqZvE=V(8CqNhT0`Jln zpX6^<8s1H^S7oC&TrRVLP-Q%8Qf)I>HWu<2&By7?1-=LFWpVn|M^vne*Ukv$=0$D1 z6L3w&Pd^&>4fyG6&();eW%vMUG{QA&i42yKZ^TZLa@PX4-3InebWdDbb>&fv-6?Av zs*0jS#cv&rR7^-L{b&-1qPFNSR$dv5%H1ewc~v;TW_yf<-TxNf!(SwT9t9b-7Xq$IO;k~% zCUOh-4j^OiSIfS0u<NvUaysp1orC~*Qe zZZ^giE5?@wfPaeN8-DA|0WJ%GG%iGAzPzo;D8%xCw?h*2p)4#mpuSdT?nRO zfT&fs5mAiL^R?D>@vxX^FbBBGCt4C9t*olJ4gvjezXB|Ym}sT|_>b#j8?k0LPe0-E zBZd>xkQt6JYD(JdJx6|O=V6HRK!M#=OQi$NTKS@AU!7)7iAAoA^sff}LBraodiXJZ z!j%o9AA?nw7^rzaWgQDa(UJ#2SoAP7OBuhjJK`K>d$21P;q0i@q-FKdmvGX|XrXAp z`JTUF@uqp-N=SPD+=(aRxt}BC!wY8hCKUpsF%)uBAMazGH9`2+AaijjFIq&HBb}^1 zLC;$a)MR(7Pu?o^*)Lg5z_nVHLgjQzw#?n_gt<)rA8;3_bT-G^;*h`wYy6*sClFYh L+vA>_`KA01MX { + 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; + }); +}); diff --git a/packages/wrapper/tsconfig.json b/packages/wrapper/tsconfig.json new file mode 100644 index 0000000..9f4d7a2 --- /dev/null +++ b/packages/wrapper/tsconfig.json @@ -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"] +} diff --git a/packages/wrapper/webpack.config.js b/packages/wrapper/webpack.config.js new file mode 100644 index 0000000..1f94be2 --- /dev/null +++ b/packages/wrapper/webpack.config.js @@ -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; diff --git a/tsconfig.json b/tsconfig.json index 37f2667..aa91d61 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -3,6 +3,9 @@ { "path": "./packages/backend" }, + { + "path": "./packages/wrapper" + }, { "path": "./packages/types" }, From 484b330fb532ac644290620a95a2ae59b47a8685 Mon Sep 17 00:00:00 2001 From: Alexander Gilin Date: Thu, 28 Aug 2025 11:23:18 +0300 Subject: [PATCH 2/2] chore: branding --- packages/backend/README.md | 4 ++-- packages/backend/package.json | 4 ++-- packages/wrapper/README.md | 2 +- packages/wrapper/package.json | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/backend/README.md b/packages/backend/README.md index 2760349..dc24d11 100644 --- a/packages/backend/README.md +++ b/packages/backend/README.md @@ -1,4 +1,4 @@ -# Code Snippet Framework VSCode Extension +# Code Snippet Tool VSCode Extension ## Preview @@ -6,7 +6,7 @@ ## Overview -This package is the VSCode extension for the Code Snippet Framework. It enables: +This package is the VSCode extension for the Code Snippet Tool. It enables: - 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. diff --git a/packages/backend/package.json b/packages/backend/package.json index 06c72b2..5793c6a 100644 --- a/packages/backend/package.json +++ b/packages/backend/package.json @@ -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.", diff --git a/packages/wrapper/README.md b/packages/wrapper/README.md index ff2e7fc..5d0da20 100644 --- a/packages/wrapper/README.md +++ b/packages/wrapper/README.md @@ -1,3 +1,3 @@ # Code Snippet Wrapper VSCode Extension -> **Deprecated:** Please use [saposs.ccode-snippet-framework](https://marketplace.visualstudio.com/items?itemName=saposs.ccode-snippet-framework) instead. \ No newline at end of file +> **Deprecated:** Please use [saposs.code-snippet-tool](https://marketplace.visualstudio.com/items?itemName=saposs.code-snippet-tool) instead. \ No newline at end of file diff --git a/packages/wrapper/package.json b/packages/wrapper/package.json index b784f52..1e9693f 100644 --- a/packages/wrapper/package.json +++ b/packages/wrapper/package.json @@ -37,7 +37,7 @@ }, "activationEvents": [], "extensionDependencies": [ - "saposs.code-snippet-framework" + "saposs.code-snippet-tool" ], "devDependencies": { "@types/sinon": "^10.0.11",