Skip to content

Commit 88a675b

Browse files
authored
Release v0.0.1 (#5)
* Feat: Add 'Create Component' Feature * Update: Move 'create react component' menu to down of 'React Component Toolkit' menu * Refactor: Convert command addition to factory pattern * Feat: Create 'Create React Hook' menu * Add: Add 'create react hook' command * Feat: Add 'Create React HOC' menu * Feat: Add commands 'Create React Context' and 'Create React Provider' * Docs: Add README.md * Update: Add publisher's information
1 parent 9c5d789 commit 88a675b

28 files changed

+470
-1086
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ Thumbs.db
1414

1515
# VSCode settings
1616
.vscode/
17+
.vscode-test/
1718

1819
# Build artifacts
1920
*.vsix

.vscodeignore

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
11
.vscode/**
22
.vscode-test/**
3-
out/**
4-
node_modules/**
53
src/**
64
.gitignore
75
.yarnrc
8-
esbuild.js
96
vsc-extension-quickstart.md
107
**/tsconfig.json
118
**/eslint.config.mjs

LICENSE

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# License
2+
3+
Copyright (c) 2024 univdev
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, subject to the following conditions:
6+
7+
1. The original source code of the Software must be used without modification. Distribution of modified source code is prohibited.
8+
9+
2. Any output or derivative work produced using the Software may be freely used, modified, and distributed, including for commercial purposes.
10+
11+
3. The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
12+
13+
4. Commercial use of the unmodified Software requires a separate agreement with the copyright holder.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

README.md

Lines changed: 27 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,71 +1,48 @@
1-
# vscode-react-developer-toolkit README
1+
# VSCode React Developer Toolkit
22

3-
This is the README for your extension "vscode-react-developer-toolkit". After writing up a brief description, we recommend including the following sections.
3+
VSCode React Developer Toolkit is a powerful extension designed to enhance your React development workflow in Visual Studio Code. This toolkit provides a set of convenient commands to quickly create common React components and patterns, streamlining your development process and boosting productivity.
44

55
## Features
66

7-
Describe specific features of your extension including screenshots of your extension in action. Image paths are relative to this README file.
7+
The extension offers the following commands, accessible through the Explorer context menu under "React Developer Toolkit":
88

9-
For example if there is an image subfolder under your extension project workspace:
9+
- **Create React Component**: Quickly scaffold a new React component
10+
- **Create React Hook**: Generate a custom React hook
11+
- **Create React HOC**: Set up a Higher-Order Component
12+
- **Create React Context**: Create a new React Context
13+
- **Create React Provider**: Generate a React Provider component
1014

11-
\!\[feature X\]\(images/feature-x.png\)
15+
## Installation
1216

13-
> Tip: Many popular extensions utilize animations. This is an excellent way to show off your extension! We recommend short, focused animations that are easy to follow.
17+
1. Open Visual Studio Code
18+
2. Go to the Extensions view (Ctrl+Shift+X)
19+
3. Search for "VSCode React Developer Toolkit"
20+
4. Click Install
1421

15-
## Requirements
22+
## Usage
1623

17-
If you have any requirements or dependencies, add a section describing those and how to install and configure them.
24+
To use the React Developer Toolkit:
1825

19-
## Extension Settings
26+
1. Right-click on a folder in the Explorer view
27+
2. Navigate to the "React Developer Toolkit" submenu
28+
3. Select the desired command to create the corresponding React element
2029

21-
Include if your extension adds any VS Code settings through the `contributes.configuration` extension point.
30+
## Requirements
2231

23-
For example:
32+
- Visual Studio Code version 1.94.0 or higher
2433

25-
This extension contributes the following settings:
34+
## Extension Settings
2635

27-
* `myExtension.enable`: Enable/disable this extension.
28-
* `myExtension.thing`: Set to `blah` to do something.
36+
This extension doesn't add any VS Code settings.
2937

3038
## Known Issues
3139

32-
Calling out known issues can help limit users opening duplicate issues against your extension.
33-
34-
## Release Notes
35-
36-
Users appreciate release notes as you update your extension.
37-
38-
### 1.0.0
39-
40-
Initial release of ...
41-
42-
### 1.0.1
43-
44-
Fixed issue #.
45-
46-
### 1.1.0
47-
48-
Added features X, Y, and Z.
49-
50-
---
51-
52-
## Following extension guidelines
53-
54-
Ensure that you've read through the extensions guidelines and follow the best practices for creating your extension.
55-
56-
* [Extension Guidelines](https://code.visualstudio.com/api/references/extension-guidelines)
57-
58-
## Working with Markdown
59-
60-
You can author your README using Visual Studio Code. Here are some useful editor keyboard shortcuts:
40+
There are currently no known issues. If you encounter any problems, please report them on the GitHub repository.
6141

62-
* Split the editor (`Cmd+\` on macOS or `Ctrl+\` on Windows and Linux).
63-
* Toggle preview (`Shift+Cmd+V` on macOS or `Shift+Ctrl+V` on Windows and Linux).
64-
* Press `Ctrl+Space` (Windows, Linux, macOS) to see a list of Markdown snippets.
42+
## Contributing
6543

66-
## For more information
44+
Contributions are welcome! Please feel free to submit a Pull Request.
6745

68-
* [Visual Studio Code's Markdown Support](http://code.visualstudio.com/docs/languages/markdown)
69-
* [Markdown Syntax Reference](https://help.github.com/articles/markdown-basics/)
46+
## License
7047

71-
**Enjoy!**
48+
This extension is licensed under the [MIT License](LICENSE.md).

dist/extension.js

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
"use strict";var U=Object.create;var i=Object.defineProperty;var q=Object.getOwnPropertyDescriptor;var V=Object.getOwnPropertyNames;var W=Object.getPrototypeOf,A=Object.prototype.hasOwnProperty;var D=(t,e)=>{for(var o in e)i(t,o,{get:e[o],enumerable:!0})},l=(t,e,o,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of V(e))!A.call(t,s)&&s!==o&&i(t,s,{get:()=>e[s],enumerable:!(r=q(e,s))||r.enumerable});return t};var n=(t,e,o)=>(o=t!=null?U(W(t)):{},l(e||!t||!t.__esModule?i(o,"default",{value:t,enumerable:!0}):o,t)),z=t=>l(i({},"__esModule",{value:!0}),t);var K={};D(K,{activate:()=>J});module.exports=z(K);var c=n(require("vscode"));var h=n(require("vscode")),d=n(require("path")),a=n(require("fs"));var v=t=>`import { FC } from 'react';
2+
3+
export type I${t}Props = {
4+
5+
};
6+
7+
export const ${t}: FC<I${t}Props> = () => {
8+
return (
9+
10+
);
11+
};
12+
13+
export default ${t};
14+
`;var m=t=>`export * from './${t}';`;var y=t=>{if(t&&t.fsPath){let e=t.fsPath;h.window.showInputBox({prompt:"Enter React component name",placeHolder:"MyComponent"}).then(o=>{if(o){let r=d.join(e,o);a.mkdirSync(r);let s=v(o),x=m(o);a.writeFileSync(d.join(r,`${o}.tsx`),s),a.writeFileSync(d.join(r,"index.ts"),x)}})}};var C=n(require("vscode")),u=n(require("fs")),w=n(require("path"));var F=t=>`export const ${t} = () => {
15+
16+
};
17+
`;var P=t=>{let e=t.fsPath;C.window.showInputBox({prompt:"Enter React hook name",placeHolder:"MyHook (or useMyHook)"}).then(o=>{if(typeof o=="string"){let r=o;o.startsWith("use")===!1&&(r=`use${o}`),C.window.showInformationMessage(r);let s=F(r);u.writeFileSync(w.join(e,`${r}.ts`),s)}})};var H=n(require("vscode")),$=n(require("fs")),k=n(require("path"));var R=t=>`import { ComponentType } from 'react';
18+
19+
export type IComponentRequiredProps = {
20+
// Write required props.
21+
};
22+
23+
export function ${t}<P = IComponentRequiredProps>(Component: ComponentType<P>) {
24+
return function(props: P) {
25+
return (
26+
<Component { ...props as any } />
27+
);
28+
};
29+
};
30+
31+
export default ${t};
32+
`;var I=t=>{let e=t.fsPath;H.window.showInputBox({prompt:"Enter React hoc name",placeHolder:"withMyHOC"}).then(o=>{if(o){let r=R(o);$.writeFileSync(k.join(e,`${o}.hoc.tsx`),r)}})};var E=n(require("vscode")),p=n(require("fs")),f=n(require("path"));var g=t=>`import { FC } from "react";
33+
34+
export type ITestProviderProps = {
35+
// Enter provider props
36+
};
37+
38+
export const TestProvider: FC<ITestProviderProps> = () => {
39+
return (
40+
41+
);
42+
};
43+
44+
export default TestProvider;
45+
`;var j=t=>{let e=t.fsPath;E.window.showInputBox({prompt:"Enter React provider name",placeHolder:"MyProvider (Provider: use same name as context)"}).then(o=>{if(o){let r=`${o}.provider.tsx`,s=g(o),x=m(r);p.mkdirSync(f.join(e,o)),p.writeFileSync(f.join(e,o,r),s),p.writeFileSync(f.join(e,o,"index.ts"),x)}})};var M=n(require("vscode")),b=n(require("fs")),O=n(require("path"));var S=t=>`import { createContext } from "react";
46+
47+
export type I${t}ContextValue = {
48+
// Enter context props
49+
};
50+
51+
export const ${t}Context = createContext<I${t}ContextValue | undefined>(undefined);
52+
53+
export default ${t}Context;
54+
`;var T=t=>{let e=t.fsPath;M.window.showInputBox({prompt:"Enter React context name",placeHolder:"MyContext (A .context prefix is added to the filename.)"}).then(o=>{if(o){let r=S(o);b.writeFileSync(O.join(e,`${o}.context.ts`),r)}})};var B=t=>{G.forEach(e=>{t.subscriptions.push(e)})},G=[c.commands.registerCommand("vscode-react-developer-toolkit.createReactComponent",y),c.commands.registerCommand("vscode-react-developer-toolkit.createReactHOC",I),c.commands.registerCommand("vscode-react-developer-toolkit.createReactHook",P),c.commands.registerCommand("vscode-react-developer-toolkit.createReactProvider",j),c.commands.registerCommand("vscode-react-developer-toolkit.createReactContext",T)];function J(t){B(t)}0&&(module.exports={activate});

dist/extension.js.map

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

esbuild.js

Lines changed: 41 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,56 +1,54 @@
1-
const esbuild = require("esbuild");
1+
const esbuild = require('esbuild');
22

33
const production = process.argv.includes('--production');
44
const watch = process.argv.includes('--watch');
55

6+
async function main() {
7+
const ctx = await esbuild.context({
8+
entryPoints: ['src/extension.ts'],
9+
bundle: true,
10+
format: 'cjs',
11+
minify: production,
12+
sourcemap: !production,
13+
sourcesContent: false,
14+
platform: 'node',
15+
outfile: 'dist/extension.js',
16+
external: ['vscode'],
17+
logLevel: 'silent',
18+
plugins: [
19+
/* add to the end of plugins array */
20+
esbuildProblemMatcherPlugin
21+
]
22+
});
23+
if (watch) {
24+
await ctx.watch();
25+
} else {
26+
await ctx.rebuild();
27+
await ctx.dispose();
28+
}
29+
}
30+
631
/**
732
* @type {import('esbuild').Plugin}
833
*/
934
const esbuildProblemMatcherPlugin = {
10-
name: 'esbuild-problem-matcher',
35+
name: 'esbuild-problem-matcher',
1136

12-
setup(build) {
13-
build.onStart(() => {
14-
console.log('[watch] build started');
15-
});
16-
build.onEnd((result) => {
17-
result.errors.forEach(({ text, location }) => {
18-
console.error(`✘ [ERROR] ${text}`);
19-
console.error(` ${location.file}:${location.line}:${location.column}:`);
20-
});
21-
console.log('[watch] build finished');
22-
});
23-
},
37+
setup(build) {
38+
build.onStart(() => {
39+
console.log('[watch] build started');
40+
});
41+
build.onEnd(result => {
42+
result.errors.forEach(({ text, location }) => {
43+
console.error(`✘ [ERROR] ${text}`);
44+
console.error(` ${location.file}:${location.line}:${location.column}:`);
45+
});
46+
console.log('[watch] build finished');
47+
});
48+
}
2449
};
2550

26-
async function main() {
27-
const ctx = await esbuild.context({
28-
entryPoints: [
29-
'src/extension.ts'
30-
],
31-
bundle: true,
32-
format: 'cjs',
33-
minify: production,
34-
sourcemap: !production,
35-
sourcesContent: false,
36-
platform: 'node',
37-
outfile: 'dist/extension.js',
38-
external: ['vscode'],
39-
logLevel: 'silent',
40-
plugins: [
41-
/* add to the end of plugins array */
42-
esbuildProblemMatcherPlugin,
43-
],
44-
});
45-
if (watch) {
46-
await ctx.watch();
47-
} else {
48-
await ctx.rebuild();
49-
await ctx.dispose();
50-
}
51-
}
52-
5351
main().catch(e => {
54-
console.error(e);
55-
process.exit(1);
52+
console.error(e);
53+
process.exit(1);
5654
});

eslint.config.mjs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,11 @@ export default [{
1515
},
1616

1717
rules: {
18+
'curly': ['error', 'multi-line'],
1819
"@typescript-eslint/naming-convention": ["warn", {
1920
selector: "import",
2021
format: ["camelCase", "PascalCase"],
2122
}],
22-
23-
curly: "warn",
2423
eqeqeq: "warn",
2524
"no-throw-literal": "warn",
2625
semi: "warn",

images/icon.webp

142 KB
Binary file not shown.

0 commit comments

Comments
 (0)