Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/elazarcoh/vscode-extension-packagejson-generator
https://www.npmjs.com/package/vscode-extensions-json-generator
https://github.com/elazarcoh/vscode-extension-packagejson-generator
typescript vscode vscode-extension
Last synced: 4 months ago
JSON representation
https://www.npmjs.com/package/vscode-extensions-json-generator
- Host: GitHub
- URL: https://github.com/elazarcoh/vscode-extension-packagejson-generator
- Owner: elazarcoh
- License: mit
- Created: 2021-09-09T11:50:31.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2024-09-09T07:19:50.000Z (5 months ago)
- Last Synced: 2024-09-29T08:03:35.875Z (4 months ago)
- Topics: typescript, vscode, vscode-extension
- Language: TypeScript
- Homepage:
- Size: 1.07 MB
- Stars: 2
- Watchers: 3
- Forks: 1
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# VSCode-extensions package.json generator
## Usage
### In code
Define `Config` interface, and add documentation with annotations for additional data for the configuration
```ts
export interface Config {
/**
* @default true
* @description description of boolConfig
*/
boolConfig: boolean;/**
* @enumDescriptions [
"Foo description"
"Bar description"]
* @default "Bar"
* @description enumConfig description
*/
enumConfig: 'Foo' | 'Bar';
}
```### As cli tool
```bash
update-package-json ts2pjs 'vscode-extension-config.json'
```The input JSON file may look like this:
```json
{
"prefix": "myExt",
"configurations": [
{
"filePath": "./src/config.ts",
"name": "Config"
}
],
"targetFile": "package.json",
"tsconfig": "tsconfig.json"
}
```### As a Webpack plugin
```js
const {
VSCodeExtensionsPackageJsonGenerator,
} = require('vscode-extensions-json-generator/webpack');{
// ...
plugins: [
new VSCodeExtensionsPackageJsonGenerator('vscode-extension-config.json'),
];
}
```or with object as the config
```js
{
// ...
plugins: [
new VSCodeExtensionsPackageJsonGenerator({
prefix: 'myExt',
configurations: [
{
filePath: './src/config.ts',
name: 'Config',
},
],
targetFile: 'package.json',
tsconfig: 'tsconfig.json',
}),
];
}
```### Bonus - accessing configuration from code utility
```ts
import { configUtils } from 'vscode-extensions-json-generator/utils';export const getConfiguration =
configUtils.ConfigurationGetter('myExt');// use it to get configuration with auto-complete and automatically type inference
const e = getConfiguration('enumConfig');
```or as a class
```ts
import { configUtils } from 'vscode-extensions-json-generator/utils';export const configurations = new configUtils.VSCodeConfigurations('myExt');
// get
const e = configurations.get('enumConfig');// update
configurations.update('enumConfig', 'Foo');
```## Config options
```jsonc
{
"configurations": [
{
"filePath": "./src/config1.json",
"name": "Config1"
},
{
"filePath": "./src/config2.json",
"name": "Config2"
}
// ...
],
"prefix": "myExt",
// tags that aren't being used in json schema by default.
"tags": [
"markdownDescription",
"scope",
"patternErrorMessage",
"deprecationMessage",
"enumDescriptions",
"deprecated"
// ...
],
"targetFile": "package.json",
"tsconfig": "tsconfig.ts",
"sort": true
}
```## Convert from existing `package.json` to TypeScript interface
Use the cli tool with `pjs2ts`.
```bash
update-package-json pjs2ts 'package.json' -p conf --add-config-class
```Options:
```bash
Convert the package.json `contributes.configurations` to a TypeScript fileArguments:
inputFile input package.json file (default: "package.json")Options:
-p, --prefix [prefix] prefix for the configuration
-o, --output [outputFile] output file (default: "config.ts")
--add-config-class
--config-class-name [name] name of the configuration class (default: "Configuration")
-h, --help display help for command
```