mirror of
https://github.com/tauri-apps/tauri-vscode.git
synced 2026-01-31 00:35:18 +01:00
chore: remove unused code, update deps and use node18 in CI (#244)
This commit is contained in:
@@ -1,16 +0,0 @@
|
|||||||
{
|
|
||||||
"root": true,
|
|
||||||
"parser": "@typescript-eslint/parser",
|
|
||||||
"parserOptions": {
|
|
||||||
"ecmaVersion": 6,
|
|
||||||
"sourceType": "module"
|
|
||||||
},
|
|
||||||
"plugins": ["@typescript-eslint"],
|
|
||||||
"rules": {
|
|
||||||
"@typescript-eslint/semi": "warn",
|
|
||||||
"curly": "warn",
|
|
||||||
"eqeqeq": "warn",
|
|
||||||
"no-throw-literal": "warn",
|
|
||||||
"semi": "off"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
2
.github/workflows/covector-status.yml
vendored
2
.github/workflows/covector-status.yml
vendored
@@ -10,7 +10,7 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
- name: covector status
|
- name: covector status
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
- name: git config
|
- name: git config
|
||||||
|
|||||||
6
.github/workflows/publish.yml
vendored
6
.github/workflows/publish.yml
vendored
@@ -13,7 +13,11 @@ jobs:
|
|||||||
publish:
|
publish:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v4
|
||||||
|
- uses: actions/setup-node@v3
|
||||||
|
with:
|
||||||
|
node-version: 18
|
||||||
|
cache: 'yarn'
|
||||||
- run: yarn
|
- run: yarn
|
||||||
- name: Publish to Open VSX Registry
|
- name: Publish to Open VSX Registry
|
||||||
uses: HaaLeo/publish-vscode-extension@v1
|
uses: HaaLeo/publish-vscode-extension@v1
|
||||||
|
|||||||
8
.github/workflows/test.yml
vendored
8
.github/workflows/test.yml
vendored
@@ -14,11 +14,11 @@ jobs:
|
|||||||
|
|
||||||
runs-on: ${{ matrix.platform }}
|
runs-on: ${{ matrix.platform }}
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v4
|
||||||
- name: setup node
|
- uses: actions/setup-node@v3
|
||||||
uses: actions/setup-node@v1
|
|
||||||
with:
|
with:
|
||||||
node-version: 14
|
node-version: 18
|
||||||
|
cache: 'yarn'
|
||||||
- name: install dependencies
|
- name: install dependencies
|
||||||
run: yarn
|
run: yarn
|
||||||
- name: compile extension
|
- name: compile extension
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
{
|
{
|
||||||
"trailingComma": "es5",
|
"singleQuote": true,
|
||||||
"tabWidth": 2,
|
"semi": false,
|
||||||
"semi": true,
|
"trailingComma": "none"
|
||||||
"singleQuote": true
|
|
||||||
}
|
}
|
||||||
|
|||||||
8
.vscode/extensions.json
vendored
8
.vscode/extensions.json
vendored
@@ -1,8 +0,0 @@
|
|||||||
// Copyright 2020-2022 Tauri Programme within The Commons Conservancy
|
|
||||||
// SPDX-License-Identifier: Apache-2.0
|
|
||||||
// SPDX-License-Identifier: MIT
|
|
||||||
{
|
|
||||||
// See http://go.microsoft.com/fwlink/?LinkId=827846
|
|
||||||
// for the documentation about the extensions.json format
|
|
||||||
"recommendations": ["dbaeumer.vscode-eslint"]
|
|
||||||
}
|
|
||||||
17
.vscode/launch.json
vendored
17
.vscode/launch.json
vendored
@@ -14,24 +14,9 @@
|
|||||||
"type": "extensionHost",
|
"type": "extensionHost",
|
||||||
"request": "launch",
|
"request": "launch",
|
||||||
"runtimeExecutable": "${execPath}",
|
"runtimeExecutable": "${execPath}",
|
||||||
"args": [
|
"args": ["--extensionDevelopmentPath=${workspaceFolder}"],
|
||||||
"--extensionDevelopmentPath=${workspaceFolder}",
|
|
||||||
"--disable-extensions"
|
|
||||||
],
|
|
||||||
"outFiles": ["${workspaceFolder}/out/**/*.js"],
|
"outFiles": ["${workspaceFolder}/out/**/*.js"],
|
||||||
"preLaunchTask": "${defaultBuildTask}"
|
"preLaunchTask": "${defaultBuildTask}"
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Extension Tests",
|
|
||||||
"type": "extensionHost",
|
|
||||||
"request": "launch",
|
|
||||||
"runtimeExecutable": "${execPath}",
|
|
||||||
"args": [
|
|
||||||
"--extensionDevelopmentPath=${workspaceFolder}",
|
|
||||||
"--extensionTestsPath=${workspaceFolder}/out/test/suite/index"
|
|
||||||
],
|
|
||||||
"outFiles": ["${workspaceFolder}/out/test/**/*.js"],
|
|
||||||
"preLaunchTask": "${defaultBuildTask}"
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
16
.vscode/settings.json
vendored
16
.vscode/settings.json
vendored
@@ -1,16 +0,0 @@
|
|||||||
// Copyright 2020-2022 Tauri Programme within The Commons Conservancy
|
|
||||||
// SPDX-License-Identifier: Apache-2.0
|
|
||||||
// SPDX-License-Identifier: MIT
|
|
||||||
//
|
|
||||||
// Place your settings in this file to overwrite default and user settings.
|
|
||||||
{
|
|
||||||
"files.exclude": {
|
|
||||||
"out": false // set this to true to hide the "out" folder with the compiled JS files
|
|
||||||
},
|
|
||||||
"search.exclude": {
|
|
||||||
"out": true // set this to false to include "out" folder in search results
|
|
||||||
},
|
|
||||||
// Turn off tsc task auto detection since we have the necessary tasks as npm scripts
|
|
||||||
"typescript.tsc.autoDetect": "off",
|
|
||||||
"npm.runInTerminal": false
|
|
||||||
}
|
|
||||||
@@ -9,6 +9,5 @@ src/**
|
|||||||
.gitignore
|
.gitignore
|
||||||
vsc-extension-quickstart.md
|
vsc-extension-quickstart.md
|
||||||
**/tsconfig.json
|
**/tsconfig.json
|
||||||
**/.eslintrc.json
|
|
||||||
**/*.map
|
**/*.map
|
||||||
**/*.ts
|
**/*.ts
|
||||||
|
|||||||
71
package.json
71
package.json
@@ -2,6 +2,7 @@
|
|||||||
"name": "tauri-vscode",
|
"name": "tauri-vscode",
|
||||||
"publisher": "tauri-apps",
|
"publisher": "tauri-apps",
|
||||||
"displayName": "Tauri",
|
"displayName": "Tauri",
|
||||||
|
"version": "0.2.6",
|
||||||
"description": "Enhances the experience of Tauri apps development",
|
"description": "Enhances the experience of Tauri apps development",
|
||||||
"license": "MIT OR Apache-2.0",
|
"license": "MIT OR Apache-2.0",
|
||||||
"icon": "assets/icon.png",
|
"icon": "assets/icon.png",
|
||||||
@@ -13,28 +14,28 @@
|
|||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/tauri-apps/tauri-vscode.git"
|
"url": "https://github.com/tauri-apps/tauri-vscode.git"
|
||||||
},
|
},
|
||||||
"version": "0.2.6",
|
|
||||||
"engines": {
|
"engines": {
|
||||||
"vscode": "^1.66.0"
|
"vscode": "^1.75.0"
|
||||||
},
|
},
|
||||||
"categories": [
|
"categories": [
|
||||||
"Other",
|
"Snippets",
|
||||||
"Snippets"
|
"Linters",
|
||||||
|
"Other"
|
||||||
],
|
],
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"tauri",
|
"tauri",
|
||||||
"desktop",
|
"desktop",
|
||||||
|
"gui",
|
||||||
"development",
|
"development",
|
||||||
"rust"
|
"rust",
|
||||||
|
"javascript",
|
||||||
|
"framework"
|
||||||
],
|
],
|
||||||
"activationEvents": [
|
"activationEvents": [
|
||||||
"workspaceContains:**/tauri.conf.json",
|
"workspaceContains:**/tauri.conf.json",
|
||||||
"onCommand:tauri.init",
|
"workspaceContains:**/tauri.*.conf.json",
|
||||||
"onCommand:tauri.deps-install",
|
"workspaceContains:**/tauri.conf.json5",
|
||||||
"onCommand:tauri.deps-update",
|
"workspaceContains:**/tauri.*.conf.json5",
|
||||||
"onCommand:tauri.dev",
|
|
||||||
"onCommand:tauri.build",
|
|
||||||
"onCommand:tauri.build-debug",
|
|
||||||
"onFileSystem:tauri"
|
"onFileSystem:tauri"
|
||||||
],
|
],
|
||||||
"main": "./out/extension.js",
|
"main": "./out/extension.js",
|
||||||
@@ -56,16 +57,6 @@
|
|||||||
"title": "Init",
|
"title": "Init",
|
||||||
"category": "Tauri"
|
"category": "Tauri"
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"command": "tauri.deps-install",
|
|
||||||
"title": "Install Missing Dependencies",
|
|
||||||
"category": "Tauri"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"command": "tauri.deps-update",
|
|
||||||
"title": "Update Dependencies",
|
|
||||||
"category": "Tauri"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"command": "tauri.dev",
|
"command": "tauri.dev",
|
||||||
"title": "Dev",
|
"title": "Dev",
|
||||||
@@ -86,43 +77,25 @@
|
|||||||
{
|
{
|
||||||
"language": "rust",
|
"language": "rust",
|
||||||
"path": "./snippets/rust.json"
|
"path": "./snippets/rust.json"
|
||||||
},
|
|
||||||
{
|
|
||||||
"language": "markdown",
|
|
||||||
"path": "./snippets/markdown.json"
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"vscode:prepublish": "yarn run compile",
|
"vscode:prepublish": "yarn run compile",
|
||||||
"compile": "tsc -p ./",
|
"compile": "tsc -p ./",
|
||||||
"lint": "eslint src --ext ts",
|
|
||||||
"format": "prettier ./**/*.{json,ts,js} -w --ignore-path .gitignore",
|
|
||||||
"watch": "tsc -watch -p ./",
|
"watch": "tsc -watch -p ./",
|
||||||
"pretest": "yarn run compile && yarn run lint",
|
"format": "prettier ./**/*.{json,ts,js} -w --ignore-path .gitignore"
|
||||||
"test": "node ./out/test/runTest.js"
|
|
||||||
},
|
|
||||||
"devDependencies": {
|
|
||||||
"@types/glob": "8.0.1",
|
|
||||||
"@types/mocha": "10.0.1",
|
|
||||||
"@types/node": "16.18.16",
|
|
||||||
"@types/vscode": "1.66.0",
|
|
||||||
"@typescript-eslint/eslint-plugin": "5.51.0",
|
|
||||||
"@typescript-eslint/parser": "5.51.0",
|
|
||||||
"@vscode/test-electron": "2.1.5",
|
|
||||||
"eslint": "8.33.0",
|
|
||||||
"mocha": "10.2.0",
|
|
||||||
"prettier": "2.8.6",
|
|
||||||
"typescript": "4.9.5"
|
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@types/semver": "^7.3.12",
|
"axios": "1.6.8",
|
||||||
"axios": "^1.0.0",
|
"glob": "10.3.12",
|
||||||
"glob": "8.1.0",
|
"run-in-terminal": "0.0.3",
|
||||||
"run-in-terminal": "^0.0.3",
|
"strip-ansi": "6.0.1"
|
||||||
"strip-ansi": "^6.0.1"
|
|
||||||
},
|
},
|
||||||
"resolutions": {
|
"devDependencies": {
|
||||||
"brace-expansion": "^2.0.1"
|
"@types/node": "18.11.9",
|
||||||
|
"@types/vscode": "1.75.0",
|
||||||
|
"prettier": "3.2.5",
|
||||||
|
"typescript": "5.4.5"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,12 +0,0 @@
|
|||||||
{
|
|
||||||
"Create a covector change file": {
|
|
||||||
"prefix": ["covector", "---"],
|
|
||||||
"body": [
|
|
||||||
"---",
|
|
||||||
"\"${3:$WORKSPACE_NAME}\": \"${1|patch,minor,major|}\"",
|
|
||||||
"---",
|
|
||||||
"",
|
|
||||||
"$2"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
341
src/extension.ts
341
src/extension.ts
@@ -2,48 +2,47 @@
|
|||||||
// SPDX-License-Identifier: Apache-2.0
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
// SPDX-License-Identifier: MIT
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
import * as vscode from 'vscode';
|
import * as vscode from 'vscode'
|
||||||
import { exec, execSync, ChildProcess } from 'child_process';
|
import { exec, execSync, ChildProcess } from 'child_process'
|
||||||
import { runInTerminal } from 'run-in-terminal';
|
import { runInTerminal } from 'run-in-terminal'
|
||||||
import { join } from 'path';
|
import { join } from 'path'
|
||||||
import { existsSync, readFileSync } from 'fs';
|
import { existsSync, readFileSync } from 'fs'
|
||||||
import axios from 'axios';
|
import axios from 'axios'
|
||||||
|
|
||||||
import stripAnsi = require('strip-ansi');
|
const stripAnsi = require('strip-ansi')
|
||||||
|
const glob = require('glob')
|
||||||
const glob = require('glob');
|
const path = require('path')
|
||||||
const path = require('path');
|
const fs = require('fs')
|
||||||
const fs = require('fs');
|
|
||||||
|
|
||||||
interface Process {
|
interface Process {
|
||||||
process: ChildProcess;
|
process: ChildProcess
|
||||||
cmd: string;
|
cmd: string
|
||||||
}
|
}
|
||||||
|
|
||||||
let outputChannel: vscode.OutputChannel;
|
let outputChannel: vscode.OutputChannel
|
||||||
let terminal: vscode.Terminal | null = null;
|
let terminal: vscode.Terminal | null = null
|
||||||
const runningProcesses: Map<number, Process> = new Map();
|
const runningProcesses: Map<number, Process> = new Map()
|
||||||
|
|
||||||
// this method is called when your extension is activated
|
// this method is called when your extension is activated
|
||||||
// your extension is activated the very first time the command is executed
|
// your extension is activated the very first time the command is executed
|
||||||
export function activate(context: vscode.ExtensionContext) {
|
export function activate(context: vscode.ExtensionContext) {
|
||||||
registerCommands(context);
|
registerCommands(context)
|
||||||
registerSchemasHandler(context);
|
registerSchemasHandler(context)
|
||||||
|
|
||||||
outputChannel = vscode.window.createOutputChannel('tauri');
|
outputChannel = vscode.window.createOutputChannel('tauri')
|
||||||
context.subscriptions.push(outputChannel);
|
context.subscriptions.push(outputChannel)
|
||||||
|
|
||||||
vscode.window.onDidCloseTerminal((closedTerminal) => {
|
vscode.window.onDidCloseTerminal((closedTerminal) => {
|
||||||
if (terminal === closedTerminal) {
|
if (terminal === closedTerminal) {
|
||||||
terminal = null;
|
terminal = null
|
||||||
}
|
}
|
||||||
});
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// this method is called when your extension is deactivated
|
// this method is called when your extension is deactivated
|
||||||
export function deactivate() {
|
export function deactivate() {
|
||||||
if (terminal) {
|
if (terminal) {
|
||||||
terminal.dispose();
|
terminal.dispose()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -53,15 +52,15 @@ function registerCommands(context: vscode.ExtensionContext) {
|
|||||||
vscode.commands.registerCommand('tauri.dev', runTauriDev),
|
vscode.commands.registerCommand('tauri.dev', runTauriDev),
|
||||||
vscode.commands.registerCommand('tauri.build', runTauriBuild),
|
vscode.commands.registerCommand('tauri.build', runTauriBuild),
|
||||||
vscode.commands.registerCommand('tauri.build-debug', runTauriBuildDebug)
|
vscode.commands.registerCommand('tauri.build-debug', runTauriBuildDebug)
|
||||||
);
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
function registerSchemasHandler(context: vscode.ExtensionContext) {
|
function registerSchemasHandler(context: vscode.ExtensionContext) {
|
||||||
vscode.workspace.registerTextDocumentContentProvider(
|
vscode.workspace.registerTextDocumentContentProvider(
|
||||||
'tauri',
|
'tauri',
|
||||||
new (class implements vscode.TextDocumentContentProvider {
|
new (class implements vscode.TextDocumentContentProvider {
|
||||||
onDidChangeEmitter = new vscode.EventEmitter<vscode.Uri>();
|
onDidChangeEmitter = new vscode.EventEmitter<vscode.Uri>()
|
||||||
onDidChange = this.onDidChangeEmitter.event;
|
onDidChange = this.onDidChangeEmitter.event
|
||||||
|
|
||||||
async provideTextDocumentContent(uri: vscode.Uri): Promise<string> {
|
async provideTextDocumentContent(uri: vscode.Uri): Promise<string> {
|
||||||
if (uri.authority === 'schemas' && uri.path === '/config.json') {
|
if (uri.authority === 'schemas' && uri.path === '/config.json') {
|
||||||
@@ -70,38 +69,38 @@ function registerSchemasHandler(context: vscode.ExtensionContext) {
|
|||||||
await vscode.workspace.findFiles(
|
await vscode.workspace.findFiles(
|
||||||
'**/node_modules/@tauri-apps/cli/schema.json'
|
'**/node_modules/@tauri-apps/cli/schema.json'
|
||||||
)
|
)
|
||||||
)[0];
|
)[0]
|
||||||
if (schemaFile) return readFileSync(schemaFile.fsPath, 'utf-8');
|
if (schemaFile) return readFileSync(schemaFile.fsPath, 'utf-8')
|
||||||
|
|
||||||
async function getSchemaFromRelease(version: string) {
|
async function getSchemaFromRelease(version: string) {
|
||||||
const res = await axios.get(
|
const res = await axios.get(
|
||||||
`https://github.com/tauri-apps/tauri/releases/download/tauri-build-v${version}/schema.json`
|
`https://github.com/tauri-apps/tauri/releases/download/tauri-build-v${version}/schema.json`
|
||||||
);
|
)
|
||||||
return res.status == 200 ? JSON.stringify(res.data) : null;
|
return res.status == 200 ? JSON.stringify(res.data) : null
|
||||||
}
|
}
|
||||||
|
|
||||||
// get schema form github release based on tauri-build version in Cargo.lock
|
// get schema form github release based on tauri-build version in Cargo.lock
|
||||||
const cargoLockPath = (
|
const cargoLockPath = (
|
||||||
await vscode.workspace.findFiles('**/Cargo.lock')
|
await vscode.workspace.findFiles('**/Cargo.lock')
|
||||||
)[0];
|
)[0]
|
||||||
if (cargoLockPath) {
|
if (cargoLockPath) {
|
||||||
const cargoLock = readFileSync(cargoLockPath.fsPath, 'utf-8');
|
const cargoLock = readFileSync(cargoLockPath.fsPath, 'utf-8')
|
||||||
const matches =
|
const matches =
|
||||||
/\[\[package\]\]\nname = "tauri-build"\nversion = "(.*)"/g.exec(
|
/\[\[package\]\]\nname = "tauri-build"\nversion = "(.*)"/g.exec(
|
||||||
cargoLock
|
cargoLock
|
||||||
);
|
)
|
||||||
if (matches && matches[1]) {
|
if (matches && matches[1]) {
|
||||||
const schema = await getSchemaFromRelease(matches[1]);
|
const schema = await getSchemaFromRelease(matches[1])
|
||||||
if (schema) return schema;
|
if (schema) return schema
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// get schema form github release based on tauri-build version in Cargo.toml
|
// get schema form github release based on tauri-build version in Cargo.toml
|
||||||
const cargoTomlPath = (
|
const cargoTomlPath = (
|
||||||
await vscode.workspace.findFiles('**/Cargo.toml')
|
await vscode.workspace.findFiles('**/Cargo.toml')
|
||||||
)[0];
|
)[0]
|
||||||
if (cargoTomlPath) {
|
if (cargoTomlPath) {
|
||||||
const cargoToml = readFileSync(cargoTomlPath.fsPath, 'utf-8');
|
const cargoToml = readFileSync(cargoTomlPath.fsPath, 'utf-8')
|
||||||
|
|
||||||
for (const regex of [
|
for (const regex of [
|
||||||
// specifying a dependency in Cargo.toml can be done in 4 ways
|
// specifying a dependency in Cargo.toml can be done in 4 ways
|
||||||
@@ -118,12 +117,12 @@ function registerSchemasHandler(context: vscode.ExtensionContext) {
|
|||||||
// 4th,
|
// 4th,
|
||||||
// [dependencies.tauri-build]
|
// [dependencies.tauri-build]
|
||||||
// \n version = "1.0.2"
|
// \n version = "1.0.2"
|
||||||
/\[.*tauri-build\][\s\S.]*version = "(.*)"\n/g,
|
/\[.*tauri-build\][\s\S.]*version = "(.*)"\n/g
|
||||||
]) {
|
]) {
|
||||||
const matches = regex.exec(cargoToml);
|
const matches = regex.exec(cargoToml)
|
||||||
if (matches && matches[1]) {
|
if (matches && matches[1]) {
|
||||||
const schema = await getSchemaFromRelease(matches[1]);
|
const schema = await getSchemaFromRelease(matches[1])
|
||||||
if (schema) return schema;
|
if (schema) return schema
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -131,167 +130,167 @@ function registerSchemasHandler(context: vscode.ExtensionContext) {
|
|||||||
// fallback to latest release
|
// fallback to latest release
|
||||||
let res = await axios.get(
|
let res = await axios.get(
|
||||||
`https://api.github.com/repos/tauri-apps/tauri/releases`
|
`https://api.github.com/repos/tauri-apps/tauri/releases`
|
||||||
);
|
)
|
||||||
let tag_name = (res.data as Array<{ tag_name: string }>).find((e) =>
|
let tag_name = (res.data as Array<{ tag_name: string }>).find((e) =>
|
||||||
e.tag_name.startsWith('tauri-build-v')
|
e.tag_name.startsWith('tauri-build-v')
|
||||||
)?.tag_name;
|
)?.tag_name
|
||||||
if (tag_name) {
|
if (tag_name) {
|
||||||
const matches =
|
const matches =
|
||||||
/((\d|x|\*)+\.(\d|x|\*)+\.(\d|x|\*)+(-[a-zA-Z-0-9]*(.[0-9]+))*)/g.exec(
|
/((\d|x|\*)+\.(\d|x|\*)+\.(\d|x|\*)+(-[a-zA-Z-0-9]*(.[0-9]+))*)/g.exec(
|
||||||
tag_name
|
tag_name
|
||||||
);
|
)
|
||||||
if (matches && matches[1]) {
|
if (matches && matches[1]) {
|
||||||
const schema = await getSchemaFromRelease(matches[1]);
|
const schema = await getSchemaFromRelease(matches[1])
|
||||||
if (schema) return schema;
|
if (schema) return schema
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return '';
|
return ''
|
||||||
}
|
}
|
||||||
})()
|
})()
|
||||||
);
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
function runTauriInit(): void {
|
function runTauriInit(): void {
|
||||||
__pickProjectAndRunTauriScript(
|
__pickProjectAndRunTauriScript(
|
||||||
(projectPath) => {
|
(projectPath) => {
|
||||||
let installCommand: string;
|
let installCommand: string
|
||||||
let onInstall = () => {};
|
let onInstall = () => {}
|
||||||
if (__isVueCliApp(projectPath)) {
|
if (__isVueCliApp(projectPath)) {
|
||||||
installCommand = 'vue add tauri';
|
installCommand = 'vue add tauri'
|
||||||
} else if (__isNodeProject(projectPath)) {
|
} else if (__isNodeProject(projectPath)) {
|
||||||
installCommand = __usePnpm(projectPath)
|
installCommand = __usePnpm(projectPath)
|
||||||
? 'pnpm add -D @tauri-apps/cli'
|
? 'pnpm add -D @tauri-apps/cli'
|
||||||
: __useYarn(projectPath)
|
: __useYarn(projectPath)
|
||||||
? 'yarn add @tauri-apps/cli --dev'
|
? 'yarn add @tauri-apps/cli --dev'
|
||||||
: `${__getNpmBin()} install @tauri-apps/cli --save-dev`;
|
: `${__getNpmBin()} install @tauri-apps/cli --save-dev`
|
||||||
onInstall = () => {
|
onInstall = () => {
|
||||||
const packageJson = JSON.parse(
|
const packageJson = JSON.parse(
|
||||||
fs.readFileSync(`${projectPath}/package.json`)
|
fs.readFileSync(`${projectPath}/package.json`)
|
||||||
);
|
)
|
||||||
if (!packageJson.scripts) {
|
if (!packageJson.scripts) {
|
||||||
packageJson.scripts = {};
|
packageJson.scripts = {}
|
||||||
}
|
}
|
||||||
if (!packageJson.scripts['tauri']) {
|
if (!packageJson.scripts['tauri']) {
|
||||||
packageJson.scripts['tauri'] = 'tauri';
|
packageJson.scripts['tauri'] = 'tauri'
|
||||||
fs.writeFileSync(
|
fs.writeFileSync(
|
||||||
`${projectPath}/package.json`,
|
`${projectPath}/package.json`,
|
||||||
JSON.stringify(packageJson, null, 4)
|
JSON.stringify(packageJson, null, 4)
|
||||||
);
|
)
|
||||||
}
|
}
|
||||||
__runTauriScript(['init'], {
|
__runTauriScript(['init'], {
|
||||||
cwd: projectPath,
|
cwd: projectPath,
|
||||||
noOutputWindow: true,
|
noOutputWindow: true
|
||||||
});
|
})
|
||||||
};
|
}
|
||||||
} else {
|
} else {
|
||||||
installCommand = 'cargo install tauri-cli';
|
installCommand = 'cargo install tauri-cli'
|
||||||
}
|
}
|
||||||
|
|
||||||
const [command, ...args] = installCommand.split(' ');
|
const [command, ...args] = installCommand.split(' ')
|
||||||
__runScript(command, args, {
|
__runScript(command, args, {
|
||||||
cwd: projectPath,
|
cwd: projectPath,
|
||||||
noOutputWindow: command === 'vue',
|
noOutputWindow: command === 'vue'
|
||||||
}).then(onInstall);
|
}).then(onInstall)
|
||||||
},
|
},
|
||||||
() => {
|
() => {
|
||||||
const paths = __getNpmProjectsPaths();
|
const paths = __getNpmProjectsPaths()
|
||||||
return paths.filter((p) => {
|
return paths.filter((p) => {
|
||||||
return fs.existsSync(path.join(p, 'src-tauri'));
|
return fs.existsSync(path.join(p, 'src-tauri'))
|
||||||
});
|
})
|
||||||
}
|
}
|
||||||
);
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
function runTauriDev(): void {
|
function runTauriDev(): void {
|
||||||
__pickProjectAndRunTauriScript((projectPath) =>
|
__pickProjectAndRunTauriScript((projectPath) =>
|
||||||
__runTauriScript(['dev'], { cwd: projectPath })
|
__runTauriScript(['dev'], { cwd: projectPath })
|
||||||
);
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
function runTauriBuild(): void {
|
function runTauriBuild(): void {
|
||||||
__pickProjectAndRunTauriScript((projectPath) =>
|
__pickProjectAndRunTauriScript((projectPath) =>
|
||||||
__runTauriScript(['build'], { cwd: projectPath })
|
__runTauriScript(['build'], { cwd: projectPath })
|
||||||
);
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
function runTauriBuildDebug(): void {
|
function runTauriBuildDebug(): void {
|
||||||
__pickProjectAndRunTauriScript((projectPath) =>
|
__pickProjectAndRunTauriScript((projectPath) =>
|
||||||
__runTauriScript(['build', '--debug'], { cwd: projectPath })
|
__runTauriScript(['build', '--debug'], { cwd: projectPath })
|
||||||
);
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
function __isVueCliApp(cwd: string): boolean {
|
function __isVueCliApp(cwd: string): boolean {
|
||||||
const packageJson = __getPackageJson(cwd);
|
const packageJson = __getPackageJson(cwd)
|
||||||
return '@vue/cli-service' in (packageJson?.devDependencies ?? {});
|
return '@vue/cli-service' in (packageJson?.devDependencies ?? {})
|
||||||
}
|
}
|
||||||
|
|
||||||
function __isNodeProject(cwd: string): boolean {
|
function __isNodeProject(cwd: string): boolean {
|
||||||
return existsSync(join(cwd, 'package.json'));
|
return existsSync(join(cwd, 'package.json'))
|
||||||
}
|
}
|
||||||
|
|
||||||
interface PackageJson {
|
interface PackageJson {
|
||||||
dependencies: {
|
dependencies: {
|
||||||
[name: string]: any;
|
[name: string]: any
|
||||||
};
|
}
|
||||||
devDependencies: {
|
devDependencies: {
|
||||||
[name: string]: any;
|
[name: string]: any
|
||||||
};
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function __getPackageJson(path: string): PackageJson | null {
|
function __getPackageJson(path: string): PackageJson | null {
|
||||||
const packagePath = join(path, 'package.json');
|
const packagePath = join(path, 'package.json')
|
||||||
if (existsSync(packagePath)) {
|
if (existsSync(packagePath)) {
|
||||||
const packageStr = readFileSync(packagePath).toString();
|
const packageStr = readFileSync(packagePath).toString()
|
||||||
return JSON.parse(packageStr) as PackageJson;
|
return JSON.parse(packageStr) as PackageJson
|
||||||
} else {
|
} else {
|
||||||
return null;
|
return null
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function __getNpmProjectsPaths(): string[] {
|
function __getNpmProjectsPaths(): string[] {
|
||||||
const folders = vscode.workspace.workspaceFolders;
|
const folders = vscode.workspace.workspaceFolders
|
||||||
if (!folders) {
|
if (!folders) {
|
||||||
return [];
|
return []
|
||||||
}
|
}
|
||||||
|
|
||||||
const paths = [];
|
const paths = []
|
||||||
for (const folder of folders) {
|
for (const folder of folders) {
|
||||||
const npmProjectRoots: string[] = glob
|
const npmProjectRoots: string[] = glob
|
||||||
.sync(folder.uri.fsPath.split('\\').join('/') + '/**/package.json')
|
.sync(folder.uri.fsPath.split('\\').join('/') + '/**/package.json')
|
||||||
.map((p: string) => path.dirname(p));
|
.map((p: string) => path.dirname(p))
|
||||||
paths.push(...npmProjectRoots.filter((p) => !p.includes('node_modules')));
|
paths.push(...npmProjectRoots.filter((p) => !p.includes('node_modules')))
|
||||||
}
|
}
|
||||||
|
|
||||||
if (paths.length === 0) {
|
if (paths.length === 0) {
|
||||||
return folders.map((f) => f.uri.fsPath);
|
return folders.map((f) => f.uri.fsPath)
|
||||||
}
|
}
|
||||||
|
|
||||||
return paths;
|
return paths
|
||||||
}
|
}
|
||||||
|
|
||||||
function __getTauriProjectsPaths(): string[] {
|
function __getTauriProjectsPaths(): string[] {
|
||||||
const folders = vscode.workspace.workspaceFolders;
|
const folders = vscode.workspace.workspaceFolders
|
||||||
if (!folders) {
|
if (!folders) {
|
||||||
return [];
|
return []
|
||||||
}
|
}
|
||||||
|
|
||||||
const paths = [];
|
const paths = []
|
||||||
for (const folder of folders) {
|
for (const folder of folders) {
|
||||||
const tauriProjectRoots: string[] = glob
|
const tauriProjectRoots: string[] = glob
|
||||||
.sync(folder.uri.fsPath.split('\\').join('/') + '/**/src-tauri')
|
.sync(folder.uri.fsPath.split('\\').join('/') + '/**/src-tauri')
|
||||||
.map((p: string) => path.dirname(p));
|
.map((p: string) => path.dirname(p))
|
||||||
paths.push(...tauriProjectRoots.filter((p) => !p.includes('node_modules')));
|
paths.push(...tauriProjectRoots.filter((p) => !p.includes('node_modules')))
|
||||||
}
|
}
|
||||||
return paths;
|
return paths
|
||||||
}
|
}
|
||||||
|
|
||||||
function __isMultiRoot(): boolean {
|
function __isMultiRoot(): boolean {
|
||||||
if (vscode.workspace.workspaceFolders) {
|
if (vscode.workspace.workspaceFolders) {
|
||||||
return vscode.workspace.workspaceFolders.length > 1;
|
return vscode.workspace.workspaceFolders.length > 1
|
||||||
}
|
}
|
||||||
return false;
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
function __runCommandInTerminal(
|
function __runCommandInTerminal(
|
||||||
@@ -304,14 +303,14 @@ function __runCommandInTerminal(
|
|||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
process.on('exit', (code) => {
|
process.on('exit', (code) => {
|
||||||
if (code) {
|
if (code) {
|
||||||
reject();
|
reject()
|
||||||
} else {
|
} else {
|
||||||
resolve();
|
resolve()
|
||||||
}
|
}
|
||||||
});
|
})
|
||||||
});
|
})
|
||||||
}
|
}
|
||||||
);
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
function __runCommandInIntegratedTerminal(
|
function __runCommandInIntegratedTerminal(
|
||||||
@@ -320,17 +319,17 @@ function __runCommandInIntegratedTerminal(
|
|||||||
cwd: string | undefined
|
cwd: string | undefined
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
if (!terminal) {
|
if (!terminal) {
|
||||||
terminal = vscode.window.createTerminal('tauri');
|
terminal = vscode.window.createTerminal('tauri')
|
||||||
}
|
}
|
||||||
|
|
||||||
terminal.show();
|
terminal.show()
|
||||||
if (cwd) {
|
if (cwd) {
|
||||||
// Replace single backslash with double backslash.
|
// Replace single backslash with double backslash.
|
||||||
const textCwd = cwd.replace(/\\/g, '\\\\');
|
const textCwd = cwd.replace(/\\/g, '\\\\')
|
||||||
terminal.sendText(['cd', `"${textCwd}"`].join(' '));
|
terminal.sendText(['cd', `"${textCwd}"`].join(' '))
|
||||||
}
|
}
|
||||||
terminal.sendText(command + ' ' + args.join(' '));
|
terminal.sendText(command + ' ' + args.join(' '))
|
||||||
return Promise.resolve();
|
return Promise.resolve()
|
||||||
}
|
}
|
||||||
|
|
||||||
function __runCommandInOutputWindow(
|
function __runCommandInOutputWindow(
|
||||||
@@ -339,135 +338,135 @@ function __runCommandInOutputWindow(
|
|||||||
cwd: string | undefined
|
cwd: string | undefined
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
const cmd = command + ' ' + args.join(' ');
|
const cmd = command + ' ' + args.join(' ')
|
||||||
const p = exec(cmd, { cwd, env: process.env });
|
const p = exec(cmd, { cwd, env: process.env })
|
||||||
|
|
||||||
if (p.pid === undefined) {
|
if (p.pid === undefined) {
|
||||||
return reject();
|
return reject()
|
||||||
}
|
}
|
||||||
|
|
||||||
runningProcesses.set(p.pid, { process: p, cmd: cmd });
|
runningProcesses.set(p.pid, { process: p, cmd: cmd })
|
||||||
|
|
||||||
p.stderr?.on('data', (data: string) => {
|
p.stderr?.on('data', (data: string) => {
|
||||||
outputChannel.append(stripAnsi(data));
|
outputChannel.append(stripAnsi(data))
|
||||||
});
|
})
|
||||||
p.stdout?.on('data', (data: string) => {
|
p.stdout?.on('data', (data: string) => {
|
||||||
outputChannel.append(stripAnsi(data));
|
outputChannel.append(stripAnsi(data))
|
||||||
});
|
})
|
||||||
p.on('exit', (_code: number, signal: string) => {
|
p.on('exit', (_code: number, signal: string) => {
|
||||||
runningProcesses.delete(p.pid!);
|
runningProcesses.delete(p.pid!)
|
||||||
|
|
||||||
if (signal === 'SIGTERM') {
|
if (signal === 'SIGTERM') {
|
||||||
outputChannel.appendLine('Successfully killed process');
|
outputChannel.appendLine('Successfully killed process')
|
||||||
outputChannel.appendLine('-----------------------');
|
outputChannel.appendLine('-----------------------')
|
||||||
outputChannel.appendLine('');
|
outputChannel.appendLine('')
|
||||||
reject();
|
reject()
|
||||||
} else {
|
} else {
|
||||||
outputChannel.appendLine('-----------------------');
|
outputChannel.appendLine('-----------------------')
|
||||||
outputChannel.appendLine('');
|
outputChannel.appendLine('')
|
||||||
resolve();
|
resolve()
|
||||||
}
|
}
|
||||||
});
|
})
|
||||||
|
|
||||||
outputChannel.show(true);
|
outputChannel.show(true)
|
||||||
});
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
interface TauriProject {
|
interface TauriProject {
|
||||||
label: string;
|
label: string
|
||||||
projectPath: string;
|
projectPath: string
|
||||||
}
|
}
|
||||||
|
|
||||||
function __useTerminal() {
|
function __useTerminal() {
|
||||||
return vscode.workspace.getConfiguration('npm')['runInTerminal'];
|
return vscode.workspace.getConfiguration('npm')['runInTerminal']
|
||||||
}
|
}
|
||||||
|
|
||||||
function __usePnpm(projectPath: string) {
|
function __usePnpm(projectPath: string) {
|
||||||
return fs.existsSync(path.join(projectPath, 'pnpm-lock.yaml'));
|
return fs.existsSync(path.join(projectPath, 'pnpm-lock.yaml'))
|
||||||
}
|
}
|
||||||
|
|
||||||
function __useYarn(projectPath: string) {
|
function __useYarn(projectPath: string) {
|
||||||
return fs.existsSync(path.join(projectPath, 'yarn.lock'));
|
return fs.existsSync(path.join(projectPath, 'yarn.lock'))
|
||||||
}
|
}
|
||||||
|
|
||||||
function __useNpm(projectPath: string) {
|
function __useNpm(projectPath: string) {
|
||||||
return fs.existsSync(path.join(projectPath, 'package-lock.json'));
|
return fs.existsSync(path.join(projectPath, 'package-lock.json'))
|
||||||
}
|
}
|
||||||
|
|
||||||
function __useCargo() {
|
function __useCargo() {
|
||||||
try {
|
try {
|
||||||
execSync('cargo tauri --version', { windowsHide: true });
|
execSync('cargo tauri --version', { windowsHide: true })
|
||||||
return true;
|
return true
|
||||||
} catch {
|
} catch {
|
||||||
return false;
|
return false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function __getNpmBin() {
|
function __getNpmBin() {
|
||||||
return vscode.workspace.getConfiguration('npm')['bin'] || 'npm';
|
return vscode.workspace.getConfiguration('npm')['bin'] || 'npm'
|
||||||
}
|
}
|
||||||
|
|
||||||
function __getNpmCommand() {
|
function __getNpmCommand() {
|
||||||
return __getNpmBin() + ' run';
|
return __getNpmBin() + ' run'
|
||||||
}
|
}
|
||||||
|
|
||||||
function __getPackageManagerCommand(projectPath: string): string | null {
|
function __getPackageManagerCommand(projectPath: string): string | null {
|
||||||
const m = __usePnpm(projectPath)
|
const m = __usePnpm(projectPath)
|
||||||
? 'pnpm'
|
? 'pnpm'
|
||||||
: __useYarn(projectPath)
|
: __useYarn(projectPath)
|
||||||
? 'yarn'
|
? 'yarn'
|
||||||
: __useNpm(projectPath)
|
: __useNpm(projectPath)
|
||||||
? __getNpmCommand()
|
? __getNpmCommand()
|
||||||
: __useCargo()
|
: __useCargo()
|
||||||
? 'cargo'
|
? 'cargo'
|
||||||
: null;
|
: null
|
||||||
|
|
||||||
if (!m) {
|
if (!m) {
|
||||||
vscode.window.showErrorMessage(
|
vscode.window.showErrorMessage(
|
||||||
"Couldn't detect package manager for current project. Try running Tauri: Init Command"
|
"Couldn't detect package manager for current project. Try running Tauri: Init Command"
|
||||||
);
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
return m;
|
return m
|
||||||
}
|
}
|
||||||
|
|
||||||
interface RunOptions {
|
interface RunOptions {
|
||||||
noOutputWindow?: boolean;
|
noOutputWindow?: boolean
|
||||||
cwd: string;
|
cwd: string
|
||||||
}
|
}
|
||||||
|
|
||||||
function __runScript(command: string, args: string[], options: RunOptions) {
|
function __runScript(command: string, args: string[], options: RunOptions) {
|
||||||
vscode.window.showInformationMessage(
|
vscode.window.showInformationMessage(
|
||||||
`Running \`${command} ${args.join(' ')}\` in ${options.cwd}`
|
`Running \`${command} ${args.join(' ')}\` in ${options.cwd}`
|
||||||
);
|
)
|
||||||
|
|
||||||
return vscode.workspace.saveAll().then(() => {
|
return vscode.workspace.saveAll().then(() => {
|
||||||
if (__useTerminal() || options.noOutputWindow) {
|
if (__useTerminal() || options.noOutputWindow) {
|
||||||
if (typeof vscode.window.createTerminal === 'function') {
|
if (typeof vscode.window.createTerminal === 'function') {
|
||||||
return __runCommandInIntegratedTerminal(command, args, options.cwd);
|
return __runCommandInIntegratedTerminal(command, args, options.cwd)
|
||||||
} else {
|
} else {
|
||||||
return __runCommandInTerminal(command, args, options.cwd);
|
return __runCommandInTerminal(command, args, options.cwd)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
outputChannel.clear();
|
outputChannel.clear()
|
||||||
return __runCommandInOutputWindow(command, args, options.cwd);
|
return __runCommandInOutputWindow(command, args, options.cwd)
|
||||||
}
|
}
|
||||||
});
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
function __runTauriScript(args: string[], options: RunOptions): void {
|
function __runTauriScript(args: string[], options: RunOptions): void {
|
||||||
const command = __getPackageManagerCommand(options.cwd);
|
const command = __getPackageManagerCommand(options.cwd)
|
||||||
if (!command) return;
|
if (!command) return
|
||||||
|
|
||||||
if (__isVueCliApp(options.cwd)) {
|
if (__isVueCliApp(options.cwd)) {
|
||||||
const [cmd, ...cmgArgs] = args;
|
const [cmd, ...cmgArgs] = args
|
||||||
__runScript(
|
__runScript(
|
||||||
command,
|
command,
|
||||||
[`tauri:${cmd === 'dev' ? 'serve' : cmd}`, ...cmgArgs],
|
[`tauri:${cmd === 'dev' ? 'serve' : cmd}`, ...cmgArgs],
|
||||||
options
|
options
|
||||||
);
|
)
|
||||||
} else {
|
} else {
|
||||||
__runScript(command, ['tauri', ...args], options);
|
__runScript(command, ['tauri', ...args], options)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -475,36 +474,36 @@ function __pickProjectAndRunTauriScript(
|
|||||||
runner: (projectPath: string) => void,
|
runner: (projectPath: string) => void,
|
||||||
getProjectPathsFn = __getTauriProjectsPaths
|
getProjectPathsFn = __getTauriProjectsPaths
|
||||||
): void {
|
): void {
|
||||||
const tauriProjectsPaths = getProjectPathsFn();
|
const tauriProjectsPaths = getProjectPathsFn()
|
||||||
const projectList: TauriProject[] = [];
|
const projectList: TauriProject[] = []
|
||||||
|
|
||||||
for (const p of tauriProjectsPaths) {
|
for (const p of tauriProjectsPaths) {
|
||||||
let label = path.basename(p);
|
let label = path.basename(p)
|
||||||
if (__isMultiRoot()) {
|
if (__isMultiRoot()) {
|
||||||
const root = vscode.workspace.getWorkspaceFolder(vscode.Uri.file(p));
|
const root = vscode.workspace.getWorkspaceFolder(vscode.Uri.file(p))
|
||||||
if (root && root.name !== label) {
|
if (root && root.name !== label) {
|
||||||
label = `${root.name}: ${label}`;
|
label = `${root.name}: ${label}`
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
projectList.push({
|
projectList.push({
|
||||||
label,
|
label,
|
||||||
projectPath: p,
|
projectPath: p
|
||||||
});
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
if (projectList.length === 0) {
|
if (projectList.length === 0) {
|
||||||
vscode.window.showErrorMessage('Tauri project not found');
|
vscode.window.showErrorMessage('Tauri project not found')
|
||||||
return;
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if (projectList.length === 1) {
|
if (projectList.length === 1) {
|
||||||
runner(projectList[0].projectPath);
|
runner(projectList[0].projectPath)
|
||||||
} else {
|
} else {
|
||||||
vscode.window.showQuickPick(projectList).then((project) => {
|
vscode.window.showQuickPick(projectList).then((project) => {
|
||||||
if (project) {
|
if (project) {
|
||||||
runner(project.projectPath);
|
runner(project.projectPath)
|
||||||
}
|
}
|
||||||
});
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,27 +0,0 @@
|
|||||||
// Copyright 2020-2022 Tauri Programme within The Commons Conservancy
|
|
||||||
// SPDX-License-Identifier: Apache-2.0
|
|
||||||
// SPDX-License-Identifier: MIT
|
|
||||||
|
|
||||||
import * as path from 'path';
|
|
||||||
|
|
||||||
import { runTests } from '@vscode/test-electron';
|
|
||||||
|
|
||||||
async function main() {
|
|
||||||
try {
|
|
||||||
// The folder containing the Extension Manifest package.json
|
|
||||||
// Passed to `--extensionDevelopmentPath`
|
|
||||||
const extensionDevelopmentPath = path.resolve(__dirname, '../../');
|
|
||||||
|
|
||||||
// The path to test runner
|
|
||||||
// Passed to --extensionTestsPath
|
|
||||||
const extensionTestsPath = path.resolve(__dirname, './suite/index');
|
|
||||||
|
|
||||||
// Download VS Code, unzip it and run the integration test
|
|
||||||
await runTests({ extensionDevelopmentPath, extensionTestsPath });
|
|
||||||
} catch (err) {
|
|
||||||
console.error('Failed to run tests');
|
|
||||||
process.exit(1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
main();
|
|
||||||
@@ -1,21 +0,0 @@
|
|||||||
// Copyright 2020-2022 Tauri Programme within The Commons Conservancy
|
|
||||||
// SPDX-License-Identifier: Apache-2.0
|
|
||||||
// SPDX-License-Identifier: MIT
|
|
||||||
|
|
||||||
import * as assert from 'assert';
|
|
||||||
|
|
||||||
// You can import and use all API from the 'vscode' module
|
|
||||||
// as well as import your extension to test it
|
|
||||||
import * as vscode from 'vscode';
|
|
||||||
// import * as myExtension from '../../extension';
|
|
||||||
|
|
||||||
suite('Extension Test Suite', () => {
|
|
||||||
vscode.window.showInformationMessage('Start all tests.');
|
|
||||||
|
|
||||||
test('Sample test', () => {
|
|
||||||
vscode.window.showInformationMessage(
|
|
||||||
JSON.stringify(vscode.workspace.workspaceFolders)
|
|
||||||
);
|
|
||||||
setTimeout(() => {}, 2000);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
@@ -1,42 +0,0 @@
|
|||||||
// Copyright 2020-2022 Tauri Programme within The Commons Conservancy
|
|
||||||
// SPDX-License-Identifier: Apache-2.0
|
|
||||||
// SPDX-License-Identifier: MIT
|
|
||||||
|
|
||||||
import * as path from 'path';
|
|
||||||
import * as Mocha from 'mocha';
|
|
||||||
import * as glob from 'glob';
|
|
||||||
|
|
||||||
export function run(): Promise<void> {
|
|
||||||
// Create the mocha test
|
|
||||||
const mocha = new Mocha({
|
|
||||||
ui: 'tdd',
|
|
||||||
color: true,
|
|
||||||
});
|
|
||||||
|
|
||||||
const testsRoot = path.resolve(__dirname, '..');
|
|
||||||
|
|
||||||
return new Promise((c, e) => {
|
|
||||||
glob('**/**.test.js', { cwd: testsRoot }, (err, files) => {
|
|
||||||
if (err) {
|
|
||||||
return e(err);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Add files to the test suite
|
|
||||||
files.forEach((f) => mocha.addFile(path.resolve(testsRoot, f)));
|
|
||||||
|
|
||||||
try {
|
|
||||||
// Run the mocha test
|
|
||||||
mocha.run((failures) => {
|
|
||||||
if (failures > 0) {
|
|
||||||
e(new Error(`${failures} tests failed.`));
|
|
||||||
} else {
|
|
||||||
c();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} catch (err) {
|
|
||||||
console.error(err);
|
|
||||||
e(err);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
@@ -1,19 +1,14 @@
|
|||||||
// Copyright 2020-2022 Tauri Programme within The Commons Conservancy
|
|
||||||
// SPDX-License-Identifier: Apache-2.0
|
|
||||||
// SPDX-License-Identifier: MIT
|
|
||||||
{
|
{
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"module": "commonjs",
|
"module": "commonjs",
|
||||||
"target": "es6",
|
"target": "es2020",
|
||||||
|
"lib": ["es2020"],
|
||||||
"outDir": "out",
|
"outDir": "out",
|
||||||
"lib": ["es6"],
|
|
||||||
"sourceMap": true,
|
"sourceMap": true,
|
||||||
"rootDir": "src",
|
"skipLibCheck": true,
|
||||||
"strict": true /* enable all strict type-checking options */
|
"allowJs": false,
|
||||||
/* Additional Checks */
|
"strict": true,
|
||||||
// "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
|
"rootDir": "src"
|
||||||
// "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
|
|
||||||
// "noUnusedParameters": true, /* Report errors on unused parameters. */
|
|
||||||
},
|
},
|
||||||
"exclude": ["node_modules", ".vscode-test"]
|
"exclude": ["node_modules", ".vscode-test"]
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user