Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Starting to yeet the template files out of the vsce. #1442

Merged
merged 13 commits into from
Dec 31, 2023
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
2 changes: 2 additions & 0 deletions tools/vscode-extension/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ The panel will have the ability to install the tools on the most popular platfor

### Changelog

- 0.3.0
- Overhauled template system.
- 0.2.8
- Adding main page button to update submodules.
- Creating categories for templates.
Expand Down
1 change: 1 addition & 0 deletions tools/vscode-extension/extension.js
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,7 @@ PSXDevPanel.viewType = 'psxDev'
exports.activate = (context) => {
tools.setExtensionUri(context.extensionUri)
tools.setGlobalStorageUri(context.globalStorageUri)
templates.setExtensionUri(context.extensionUri)
pcsxRedux.setGlobalStorageUri(context.globalStorageUri)
globalStorageUri = context.globalStorageUri

Expand Down
11 changes: 8 additions & 3 deletions tools/vscode-extension/media/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,85 +72,90 @@
const hr2 = document.createElement('hr')
templatesDiv.appendChild(hr2)
const intro = document.createElement('h3')
intro.textContent = 'Fill in your project details above, then select a template category below, and finally select a template to create a new project.'
intro.textContent =
'Fill in your project details above, then select a template category below, and finally select a template to create a new project. If the create button is disabled, you need to install the required tools first.'
templatesDiv.appendChild(intro)
const categories = {}
for (const [key, template] of Object.entries(templates)) {
if (!categories[template.category]) {
categories[template.category] = []
}
categories[template.category].push(key)
}
const panels = document.createElement('vscode-panels')
for (const [category, templateKeys] of Object.entries(categories)) {
const panelTab = document.createElement('vscode-panel-tab')
panelTab.textContent = category
panels.appendChild(panelTab)
}
for (const [category, templateKeys] of Object.entries(categories)) {
const panel = document.createElement('vscode-panel-view')
for (const key of templateKeys) {
const template = templates[key]
const templateDiv = document.createElement('div')
templateDiv.className = 'template'
const templateName = document.createElement('h3')
templateName.textContent = template.name
templateDiv.appendChild(templateName)
const templateDescription = document.createElement('p')
templateDescription.textContent = template.description
templateDiv.appendChild(templateDescription)
const templateDocumentation =
document.createElement('vscode-button')
templateDocumentation.textContent = 'Documentation'
templateDocumentation.appearance = 'secondary'
if (template.url) {
templateDocumentation.addEventListener('click', () => {
vscode.postMessage({ command: 'openUrl', url: template.url })
})
} else {
templateDocumentation.disabled = true
}
templateDiv.appendChild(templateDocumentation)
const spaceTextNode0 = document.createTextNode(' ')
templateDiv.appendChild(spaceTextNode0)
const templateExamples = document.createElement('vscode-button')
templateExamples.textContent = 'Examples'
templateExamples.appearance = 'secondary'
if (template.examples) {
templateExamples.addEventListener('click', () => {
vscode.postMessage({
command: 'openUrl',
url: template.examples
})
})
} else {
templateExamples.disabled = true
}
templateDiv.appendChild(templateExamples)
const spaceTextNode1 = document.createTextNode(' ')
templateDiv.appendChild(spaceTextNode1)
const templateInstallRequiredTools =
document.createElement('vscode-button')
templateInstallRequiredTools.textContent = 'Install required tools'
templateInstallRequiredTools.textContent =
'Install required tools'
templateInstallRequiredTools.appearance = 'secondary'
templateInstallRequiredTools.addEventListener('click', () => {
vscode.postMessage({
command: 'installTools',
tools: template.requiredTools
})
})
templateDiv.appendChild(templateInstallRequiredTools)
const spaceTextNode2 = document.createTextNode(' ')
templateDiv.appendChild(spaceTextNode2)
const templateInstallRecommendedTools =
document.createElement('vscode-button')
templateInstallRecommendedTools.textContent =
'Install recommended tools'
templateInstallRecommendedTools.appearance = 'secondary'
templateInstallRecommendedTools.addEventListener('click', () => {
vscode.postMessage({
command: 'installTools',
tools: [...template.recommendedTools, ...template.requiredTools]
tools: [
...template.recommendedTools,
...template.requiredTools
]

Check notice on line 158 in tools/vscode-extension/media/main.js

View check run for this annotation

CodeScene Delta Analysis / CodeScene Cloud Delta Analysis (main)

✅ No longer an issue: Complex Method

'message' is no longer above the threshold for cyclomatic complexity

Check notice on line 158 in tools/vscode-extension/media/main.js

View check run for this annotation

CodeScene Delta Analysis / CodeScene Cloud Delta Analysis (main)

✅ No longer an issue: Bumpy Road Ahead

'message' is no longer above the threshold for logical blocks with deeply nested code

Check notice on line 158 in tools/vscode-extension/media/main.js

View check run for this annotation

CodeScene Delta Analysis / CodeScene Cloud Delta Analysis (main)

✅ No longer an issue: Deep, Nested Complexity

'message' is no longer above the threshold for nested complexity depth
})
})
templateDiv.appendChild(templateInstallRecommendedTools)
Expand Down
3 changes: 2 additions & 1 deletion tools/vscode-extension/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "psx-dev",
"displayName": "PSX.Dev",
"description": "PlayStation 1 development made easy",
"version": "0.2.8",
"version": "0.3.0",
"engines": {
"vscode": "^1.75.0"
},
Expand Down Expand Up @@ -107,6 +107,7 @@
"dmg": "^0.1.0",
"fs-extra": "^11.1.0",
"JSONStream": "^1.3.5",
"mustache": "^4.2.0",
"open-file-explorer": "^1.0.2",
"simple-git": "^3.16.1",
"unzipper": "^0.10.11",
Expand Down
6 changes: 3 additions & 3 deletions tools/vscode-extension/pcsx-redux.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ const updateInfo = {

let globalStorageUri

function isSupported() {
function isSupported () {
let supported = false
if (process.arch === 'x64') supported = true
if (process.platform === 'darwin' && process.arch === 'arm64') {
Expand All @@ -55,7 +55,7 @@ function isSupported() {
return supported
}

function binaryPath() {
function binaryPath () {
switch (process.platform) {
case 'win32':
return vscode.Uri.joinPath(
Expand All @@ -79,7 +79,7 @@ function binaryPath() {
}
}

function checkLocalFile(filename) {
function checkLocalFile (filename) {
return new Promise((resolve) => {
fs.access(filename, fs.constants.F_OK, (err) => {
resolve(!err)
Expand Down
Loading
Loading