@tomjs/create-app 0.12.0 → 0.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. package/dist/index.mjs +6 -7
  2. package/package.json +11 -11
  3. package/template-config/.husky/commit-msg +0 -4
  4. package/template-config/.husky/pre-commit +0 -4
  5. package/template-electron-react/.vscode/tasks.json +1 -1
  6. package/{template-vscode/.eslintrc.cjs → template-electron-react/_eslintrc.cjs} +1 -1
  7. package/template-electron-react/package.json +16 -16
  8. package/template-electron-vue/.vscode/tasks.json +1 -1
  9. package/{template-node/.eslintrc.cjs → template-electron-vue/_eslintrc.cjs} +1 -1
  10. package/template-electron-vue/package.json +17 -17
  11. package/{template-vscode-vue/.eslintrc.cjs → template-node/_eslintrc.cjs} +1 -1
  12. package/template-node/package.json +16 -16
  13. package/{template-electron-vue/.eslintrc.cjs → template-react/_eslintrc.cjs} +1 -1
  14. package/template-react/package.json +11 -11
  15. package/template-vscode/_eslintrc.cjs +7 -0
  16. package/template-vscode/package.json +10 -12
  17. package/template-vscode/src/index.ts +7 -8
  18. package/template-vscode-react/_eslintrc.cjs +7 -0
  19. package/template-vscode-react/extension/env.d.ts +1 -0
  20. package/template-vscode-react/extension/index.ts +8 -9
  21. package/template-vscode-react/extension/views/helper.ts +27 -0
  22. package/template-vscode-react/extension/views/panel.ts +48 -0
  23. package/template-vscode-react/package.json +15 -18
  24. package/template-vscode-react/src/utils/vscode.ts +0 -1
  25. package/template-vscode-react/tsconfig.node.json +1 -1
  26. package/template-vscode-vue/_eslintrc.cjs +7 -0
  27. package/template-vscode-vue/extension/env.d.ts +1 -0
  28. package/template-vscode-vue/extension/index.ts +8 -9
  29. package/template-vscode-vue/extension/views/helper.ts +27 -0
  30. package/template-vscode-vue/extension/views/panel.ts +48 -0
  31. package/template-vscode-vue/package.json +16 -19
  32. package/template-vscode-vue/src/utils/vscode.ts +0 -1
  33. package/template-vscode-vue/tsconfig.node.json +1 -1
  34. package/template-vue/_eslintrc.cjs +7 -0
  35. package/template-vue/package.json +12 -12
  36. package/template-config/.husky/common.sh +0 -9
  37. package/template-electron-react/.eslintrc.cjs +0 -7
  38. package/template-react/.eslintrc.cjs +0 -7
  39. package/template-vscode-react/.eslintrc.cjs +0 -7
  40. package/template-vscode-react/extension/panels/MainPanel.ts +0 -168
  41. package/template-vscode-vue/extension/panels/MainPanel.ts +0 -168
  42. package/template-vue/.eslintrc.cjs +0 -7
@@ -16,9 +16,7 @@
16
16
  "categories": [
17
17
  "Other"
18
18
  ],
19
- "activationEvents": [
20
- "onCommand:hello-world.showHelloWorld"
21
- ],
19
+ "activationEvents": [],
22
20
  "contributes": {
23
21
  "commands": [
24
22
  {
@@ -56,30 +54,29 @@
56
54
  "react-dom": "^18.2.0"
57
55
  },
58
56
  "devDependencies": {
59
- "@commitlint/cli": "^18.6.0",
60
- "@tomjs/commitlint": "^2.3.0",
61
- "@tomjs/eslint": "^1.4.0",
57
+ "@commitlint/cli": "^19.2.0",
58
+ "@tomjs/commitlint": "^3.0.0",
59
+ "@tomjs/eslint": "^2.0.1",
62
60
  "@tomjs/prettier": "^1.3.0",
63
61
  "@tomjs/stylelint": "^2.3.0",
64
62
  "@tomjs/tsconfig": "^1.4.0",
65
- "@tomjs/vite-plugin-vscode": "^1.5.0",
66
- "@tomjs/vscode-extension-webview": "^1.2.0",
67
- "@types/node": "^18.19.14",
68
- "@types/react": "^18.2.52",
69
- "@types/react-dom": "^18.2.18",
63
+ "@tomjs/vite-plugin-vscode": "^2.2.0",
64
+ "@types/node": "^18.19.24",
65
+ "@types/react": "^18.2.66",
66
+ "@types/react-dom": "^18.2.22",
70
67
  "@types/vscode": "^1.75.0",
71
- "@types/vscode-webview": "^1.57.4",
68
+ "@types/vscode-webview": "^1.57.5",
72
69
  "@vitejs/plugin-react-swc": "^3.6.0",
73
70
  "cross-env": "^7.0.3",
74
- "eslint": "^8.56.0",
75
- "husky": "^9.0.10",
76
- "lint-staged": "^15.2.1",
71
+ "eslint": "^8.57.0",
72
+ "husky": "^9.0.11",
73
+ "lint-staged": "^15.2.2",
77
74
  "npm-run-all": "^4.1.5",
78
- "prettier": "^3.2.4",
75
+ "prettier": "^3.2.5",
79
76
  "rimraf": "^5.0.5",
80
77
  "stylelint": "^16.2.1",
81
- "tsx": "^4.7.0",
78
+ "tsx": "^4.7.1",
82
79
  "typescript": "~5.3.3",
83
- "vite": "^5.0.12"
80
+ "vite": "^5.1.6"
84
81
  }
85
82
  }
@@ -13,7 +13,6 @@ class VSCodeAPIWrapper {
13
13
  private readonly vsCodeApi: WebviewApi<unknown> | undefined;
14
14
 
15
15
  constructor() {
16
- console.log(typeof acquireVsCodeApi);
17
16
  // Check if the acquireVsCodeApi function exists in the current development
18
17
  // context (i.e. VS Code development window or web browser)
19
18
  if (typeof acquireVsCodeApi === 'function') {
@@ -3,5 +3,5 @@
3
3
  "compilerOptions": {
4
4
  "composite": true
5
5
  },
6
- "include": ["extension", "scripts", "package.json", "vite.config.ts"]
6
+ "include": ["extension", "package.json", "vite.config.ts"]
7
7
  }
@@ -0,0 +1,7 @@
1
+ module.exports = {
2
+ env: {
3
+ node: true,
4
+ es6: true,
5
+ },
6
+ extends: [require.resolve('@tomjs/eslint/vue')],
7
+ };
@@ -0,0 +1 @@
1
+ /// <reference types="@tomjs/vite-plugin-vscode/env" />
@@ -1,14 +1,13 @@
1
- import { commands, ExtensionContext } from 'vscode';
2
- import { MainPanel } from './panels/MainPanel';
1
+ import type { ExtensionContext } from 'vscode';
2
+ import { commands } from 'vscode';
3
+ import { MainPanel } from './views/panel';
3
4
 
4
5
  export function activate(context: ExtensionContext) {
5
- // Create the show hello world command
6
- const showHelloWorldCommand = commands.registerCommand('hello-world.showHelloWorld', async () => {
7
- MainPanel.render(context.extensionUri);
8
- });
9
-
10
- // Add command to the extension context
11
- context.subscriptions.push(showHelloWorldCommand);
6
+ context.subscriptions.push(
7
+ commands.registerCommand('hello-world.showHelloWorld', async () => {
8
+ MainPanel.render(context.extensionUri);
9
+ }),
10
+ );
12
11
  }
13
12
 
14
13
  export function deactivate() {}
@@ -0,0 +1,27 @@
1
+ import type { Disposable, ExtensionContext, Webview } from 'vscode';
2
+ import { window } from 'vscode';
3
+
4
+ export class WebviewHelper {
5
+ public static setupHtml(webview: Webview, context: ExtensionContext) {
6
+ return process.env.VITE_DEV_SERVER_URL
7
+ ? __getWebviewHtml__(process.env.VITE_DEV_SERVER_URL)
8
+ : __getWebviewHtml__(webview, context);
9
+ }
10
+
11
+ public static setupWebviewHooks(webview: Webview, disposables: Disposable[]) {
12
+ webview.onDidReceiveMessage(
13
+ (message: any) => {
14
+ const command = message.command;
15
+ const text = message.text;
16
+ console.log(`command: ${command}`);
17
+ switch (command) {
18
+ case 'hello':
19
+ window.showInformationMessage(text);
20
+ return;
21
+ }
22
+ },
23
+ undefined,
24
+ disposables,
25
+ );
26
+ }
27
+ }
@@ -0,0 +1,48 @@
1
+ import type { Disposable, ExtensionContext, WebviewPanel } from 'vscode';
2
+ import { ViewColumn, window } from 'vscode';
3
+ import { WebviewHelper } from './helper';
4
+
5
+ export class MainPanel {
6
+ public static currentPanel: MainPanel | undefined;
7
+ private readonly _panel: WebviewPanel;
8
+ private _disposables: Disposable[] = [];
9
+
10
+ private constructor(panel: WebviewPanel, context: ExtensionContext) {
11
+ this._panel = panel;
12
+
13
+ this._panel.onDidDispose(() => this.dispose(), null, this._disposables);
14
+ this._panel.webview.html = WebviewHelper.setupHtml(this._panel.webview, context);
15
+
16
+ WebviewHelper.setupWebviewHooks(this._panel.webview, this._disposables);
17
+ }
18
+
19
+ public static render(context: ExtensionContext) {
20
+ if (MainPanel.currentPanel) {
21
+ MainPanel.currentPanel._panel.reveal(ViewColumn.One);
22
+ } else {
23
+ const panel = window.createWebviewPanel('showHelloWorld', 'Hello World', ViewColumn.One, {
24
+ enableScripts: true,
25
+ });
26
+
27
+ MainPanel.currentPanel = new MainPanel(panel, context);
28
+ }
29
+ }
30
+
31
+ /**
32
+ * Cleans up and disposes of webview resources when the webview panel is closed.
33
+ */
34
+ public dispose() {
35
+ MainPanel.currentPanel = undefined;
36
+
37
+ // Dispose of the current webview panel
38
+ this._panel.dispose();
39
+
40
+ // Dispose of all disposables (i.e. commands) for the current webview panel
41
+ while (this._disposables.length) {
42
+ const disposable = this._disposables.pop();
43
+ if (disposable) {
44
+ disposable.dispose();
45
+ }
46
+ }
47
+ }
48
+ }
@@ -16,9 +16,7 @@
16
16
  "categories": [
17
17
  "Other"
18
18
  ],
19
- "activationEvents": [
20
- "onCommand:hello-world.showHelloWorld"
21
- ],
19
+ "activationEvents": [],
22
20
  "contributes": {
23
21
  "commands": [
24
22
  {
@@ -52,32 +50,31 @@
52
50
  },
53
51
  "dependencies": {
54
52
  "@vscode/webview-ui-toolkit": "^1.4.0",
55
- "vue": "~3.3.13"
53
+ "vue": "^3.4.21"
56
54
  },
57
55
  "devDependencies": {
58
- "@commitlint/cli": "^18.6.0",
59
- "@tomjs/commitlint": "^2.3.0",
60
- "@tomjs/eslint": "^1.4.0",
56
+ "@commitlint/cli": "^19.2.0",
57
+ "@tomjs/commitlint": "^3.0.0",
58
+ "@tomjs/eslint": "^2.0.1",
61
59
  "@tomjs/prettier": "^1.3.0",
62
60
  "@tomjs/stylelint": "^2.3.0",
63
61
  "@tomjs/tsconfig": "^1.4.0",
64
- "@tomjs/vite-plugin-vscode": "^1.5.0",
65
- "@tomjs/vscode-extension-webview": "^1.2.0",
66
- "@types/node": "^18.19.14",
62
+ "@tomjs/vite-plugin-vscode": "^2.2.0",
63
+ "@types/node": "^18.19.24",
67
64
  "@types/vscode": "^1.75.0",
68
- "@types/vscode-webview": "^1.57.4",
69
- "@vitejs/plugin-vue": "^5.0.3",
65
+ "@types/vscode-webview": "^1.57.5",
66
+ "@vitejs/plugin-vue": "^5.0.4",
70
67
  "cross-env": "^7.0.3",
71
- "eslint": "^8.56.0",
72
- "husky": "^9.0.10",
73
- "lint-staged": "^15.2.1",
68
+ "eslint": "^8.57.0",
69
+ "husky": "^9.0.11",
70
+ "lint-staged": "^15.2.2",
74
71
  "npm-run-all": "^4.1.5",
75
- "prettier": "^3.2.4",
72
+ "prettier": "^3.2.5",
76
73
  "rimraf": "^5.0.5",
77
74
  "stylelint": "^16.2.1",
78
- "tsx": "^4.7.0",
75
+ "tsx": "^4.7.1",
79
76
  "typescript": "~5.3.3",
80
- "vite": "^5.0.12",
81
- "vue-tsc": "^1.8.27"
77
+ "vite": "^5.1.6",
78
+ "vue-tsc": "^2.0.6"
82
79
  }
83
80
  }
@@ -13,7 +13,6 @@ class VSCodeAPIWrapper {
13
13
  private readonly vsCodeApi: WebviewApi<unknown> | undefined;
14
14
 
15
15
  constructor() {
16
- console.log(typeof acquireVsCodeApi);
17
16
  // Check if the acquireVsCodeApi function exists in the current development
18
17
  // context (i.e. VS Code development window or web browser)
19
18
  if (typeof acquireVsCodeApi === 'function') {
@@ -3,5 +3,5 @@
3
3
  "compilerOptions": {
4
4
  "composite": true
5
5
  },
6
- "include": ["extension", "scripts", "package.json", "vite.config.ts"]
6
+ "include": ["extension", "package.json", "vite.config.ts"]
7
7
  }
@@ -0,0 +1,7 @@
1
+ module.exports = {
2
+ env: {
3
+ node: true,
4
+ es6: true,
5
+ },
6
+ extends: [require.resolve('@tomjs/eslint/vue')],
7
+ };
@@ -17,26 +17,26 @@
17
17
  "prepare": "husky"
18
18
  },
19
19
  "dependencies": {
20
- "vue": "~3.3.13"
20
+ "vue": "^3.4.21"
21
21
  },
22
22
  "devDependencies": {
23
- "@commitlint/cli": "^18.6.0",
24
- "@tomjs/commitlint": "^2.3.0",
25
- "@tomjs/eslint": "^1.4.0",
23
+ "@commitlint/cli": "^19.2.0",
24
+ "@tomjs/commitlint": "^3.0.0",
25
+ "@tomjs/eslint": "^2.0.1",
26
26
  "@tomjs/prettier": "^1.3.0",
27
27
  "@tomjs/stylelint": "^2.3.0",
28
28
  "@tomjs/tsconfig": "^1.4.0",
29
- "@types/node": "^18.19.14",
30
- "@vitejs/plugin-vue": "^5.0.3",
29
+ "@types/node": "^18.19.24",
30
+ "@vitejs/plugin-vue": "^5.0.4",
31
31
  "cross-env": "^7.0.3",
32
- "eslint": "^8.56.0",
33
- "husky": "^9.0.10",
34
- "lint-staged": "^15.2.1",
32
+ "eslint": "^8.57.0",
33
+ "husky": "^9.0.11",
34
+ "lint-staged": "^15.2.2",
35
35
  "npm-run-all": "^4.1.5",
36
- "prettier": "^3.2.4",
36
+ "prettier": "^3.2.5",
37
37
  "stylelint": "^16.2.1",
38
38
  "typescript": "~5.3.3",
39
- "vite": "^5.0.12",
40
- "vue-tsc": "^1.8.27"
39
+ "vite": "^5.1.6",
40
+ "vue-tsc": "^2.0.6"
41
41
  }
42
42
  }
@@ -1,9 +0,0 @@
1
- #!/bin/sh
2
- command_exists () {
3
- command -v "$1" >/dev/null 2>&1
4
- }
5
-
6
- # Workaround for Windows 10, Git Bash and Yarn
7
- if command_exists winpty && test -t 1; then
8
- exec < /dev/tty
9
- fi
@@ -1,7 +0,0 @@
1
- module.exports = {
2
- env: {
3
- node: true,
4
- es6: true,
5
- },
6
- extends: [require.resolve('@tomjs/eslint/react/typescript')],
7
- };
@@ -1,7 +0,0 @@
1
- module.exports = {
2
- env: {
3
- node: true,
4
- es6: true,
5
- },
6
- extends: [require.resolve('@tomjs/eslint/react/typescript')],
7
- };
@@ -1,7 +0,0 @@
1
- module.exports = {
2
- env: {
3
- node: true,
4
- es6: true,
5
- },
6
- extends: [require.resolve('@tomjs/eslint/react/typescript')],
7
- };
@@ -1,168 +0,0 @@
1
- import { Disposable, Uri, ViewColumn, Webview, WebviewPanel, window } from 'vscode';
2
-
3
- function uuid() {
4
- let text = '';
5
- const possible = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
6
- for (let i = 0; i < 32; i++) {
7
- text += possible.charAt(Math.floor(Math.random() * possible.length));
8
- }
9
- return text;
10
- }
11
-
12
- function getUri(webview: Webview, extensionUri: Uri, pathList: string[]) {
13
- return webview.asWebviewUri(Uri.joinPath(extensionUri, ...pathList));
14
- }
15
-
16
- /**
17
- * This class manages the state and behavior of Main webview panels.
18
- *
19
- * It contains all the data and methods for:
20
- *
21
- * - Creating and rendering Main webview panels
22
- * - Properly cleaning up and disposing of webview resources when the panel is closed
23
- * - Setting the HTML (and by proxy CSS/JavaScript) content of the webview panel
24
- * - Setting message listeners so data can be passed between the webview and extension
25
- */
26
- export class MainPanel {
27
- public static currentPanel: MainPanel | undefined;
28
- private readonly _panel: WebviewPanel;
29
- private _disposables: Disposable[] = [];
30
-
31
- /**
32
- * The MainPanel class private constructor (called only from the render method).
33
- *
34
- * @param panel A reference to the webview panel
35
- * @param extensionUri The URI of the directory containing the extension
36
- */
37
- private constructor(panel: WebviewPanel, extensionUri: Uri) {
38
- this._panel = panel;
39
-
40
- // Set an event listener to listen for when the panel is disposed (i.e. when the user closes
41
- // the panel or when the panel is closed programmatically)
42
- this._panel.onDidDispose(() => this.dispose(), null, this._disposables);
43
-
44
- // Set the HTML content for the webview panel
45
- this._panel.webview.html = this._getWebviewContent(this._panel.webview, extensionUri);
46
-
47
- // Set an event listener to listen for messages passed from the webview context
48
- this._setWebviewMessageListener(this._panel.webview);
49
- }
50
-
51
- /**
52
- * Renders the current webview panel if it exists otherwise a new webview panel
53
- * will be created and displayed.
54
- *
55
- * @param extensionUri The URI of the directory containing the extension.
56
- */
57
- public static render(extensionUri: Uri) {
58
- if (MainPanel.currentPanel) {
59
- // If the webview panel already exists reveal it
60
- MainPanel.currentPanel._panel.reveal(ViewColumn.One);
61
- } else {
62
- // If a webview panel does not already exist create and show a new one
63
- const panel = window.createWebviewPanel(
64
- // Panel view type
65
- 'showHelloWorld',
66
- // Panel title
67
- 'Hello World',
68
- // The editor column the panel should be displayed in
69
- ViewColumn.One,
70
- // Extra panel configurations
71
- {
72
- // Enable JavaScript in the webview
73
- enableScripts: true,
74
- // Restrict the webview to only load resources from the `dist/webview` directories
75
- localResourceRoots: [Uri.joinPath(extensionUri, 'dist/webview')],
76
- },
77
- );
78
-
79
- MainPanel.currentPanel = new MainPanel(panel, extensionUri);
80
- }
81
- }
82
-
83
- /**
84
- * Cleans up and disposes of webview resources when the webview panel is closed.
85
- */
86
- public dispose() {
87
- MainPanel.currentPanel = undefined;
88
-
89
- // Dispose of the current webview panel
90
- this._panel.dispose();
91
-
92
- // Dispose of all disposables (i.e. commands) for the current webview panel
93
- while (this._disposables.length) {
94
- const disposable = this._disposables.pop();
95
- if (disposable) {
96
- disposable.dispose();
97
- }
98
- }
99
- }
100
-
101
- /**
102
- * Defines and returns the HTML that should be rendered within the webview panel.
103
- *
104
- * @remarks This is also the place where references to the Vue webview build files
105
- * are created and inserted into the webview HTML.
106
- *
107
- * @param webview A reference to the extension webview
108
- * @param extensionUri The URI of the directory containing the extension
109
- * @returns A template string literal containing the HTML that should be
110
- * rendered within the webview panel
111
- */
112
- private _getWebviewContent(webview: Webview, extensionUri: Uri) {
113
- // The file from the vite build output
114
- const stylesUri = getUri(webview, extensionUri, ['dist', 'webview', 'assets', 'index.css']);
115
- const scriptUri = getUri(webview, extensionUri, ['dist', 'webview', 'assets', 'index.js']);
116
-
117
- const nonce = uuid();
118
-
119
- if (process.env.VITE_DEV_SERVER_URL) {
120
- return __getWebviewHtml__(process.env.VITE_DEV_SERVER_URL);
121
- }
122
-
123
- return /*html*/ `
124
- <!doctype html>
125
- <html lang="en">
126
- <head>
127
- <meta charset="UTF-8" />
128
- <meta name="viewport" content="width=device-width, initial-scale=1.0" />
129
- <meta http-equiv="Content-Security-Policy" content="default-src 'none'; style-src ${webview.cspSource}; script-src 'nonce-${nonce}';">
130
- <script type="module" crossorigin nonce="${nonce}" src="${scriptUri}"></script>
131
- <link rel="stylesheet" crossorigin href="${stylesUri}">
132
- <title>Hello World</title>
133
- </head>
134
- <body>
135
- <div id="app"></div>
136
- </body>
137
- </html>
138
- `;
139
- }
140
-
141
- /**
142
- * Sets up an event listener to listen for messages passed from the webview context and
143
- * executes code based on the message that is recieved.
144
- *
145
- * @param webview A reference to the extension webview
146
- * @param context A reference to the extension context
147
- */
148
- private _setWebviewMessageListener(webview: Webview) {
149
- webview.onDidReceiveMessage(
150
- (message: any) => {
151
- const command = message.command;
152
- const text = message.text;
153
- console.log(`command: ${command}`);
154
-
155
- switch (command) {
156
- case 'hello':
157
- // Code that should run in response to the hello message command
158
- window.showInformationMessage(text);
159
- return;
160
- // Add more switch case statements here as more webview message commands
161
- // are created within the webview context (i.e. inside media/main.js)
162
- }
163
- },
164
- undefined,
165
- this._disposables,
166
- );
167
- }
168
- }