mirror of
https://github.com/Myriad-Dreamin/tinymist.git
synced 2025-11-20 11:55:34 +00:00
feat: add install vscode command (#2135)
Some checks are pending
tinymist::auto_tag / auto-tag (push) Waiting to run
tinymist::ci / Duplicate Actions Detection (push) Waiting to run
tinymist::ci / Check Clippy, Formatting, Completion, Documentation, and Tests (Linux) (push) Waiting to run
tinymist::ci / Check Minimum Rust version and Tests (Windows) (push) Waiting to run
tinymist::ci / prepare-build (push) Waiting to run
tinymist::ci / announce (push) Blocked by required conditions
tinymist::ci / build (push) Blocked by required conditions
tinymist::gh_pages / build-gh-pages (push) Waiting to run
Some checks are pending
tinymist::auto_tag / auto-tag (push) Waiting to run
tinymist::ci / Duplicate Actions Detection (push) Waiting to run
tinymist::ci / Check Clippy, Formatting, Completion, Documentation, and Tests (Linux) (push) Waiting to run
tinymist::ci / Check Minimum Rust version and Tests (Windows) (push) Waiting to run
tinymist::ci / prepare-build (push) Waiting to run
tinymist::ci / announce (push) Blocked by required conditions
tinymist::ci / build (push) Blocked by required conditions
tinymist::gh_pages / build-gh-pages (push) Waiting to run
This commit is contained in:
parent
34bc516466
commit
d2a747372f
3 changed files with 47 additions and 46 deletions
|
|
@ -17,6 +17,8 @@
|
||||||
"fmt": "cargo fmt --all && npx prettier --write tools/**/*.{js,mjs,cjs,ts,mts,cts} editors/vscode/**/*.{js,mjs,cjs,ts,mts,cts}",
|
"fmt": "cargo fmt --all && npx prettier --write tools/**/*.{js,mjs,cjs,ts,mts,cts} editors/vscode/**/*.{js,mjs,cjs,ts,mts,cts}",
|
||||||
"fmt:check": "cargo fmt --check --all && prettier --check tools/**/*.{js,mjs,cjs,ts,mts,cts} editors/vscode/**/*.{js,mjs,cjs,ts,mts,cts}",
|
"fmt:check": "cargo fmt --check --all && prettier --check tools/**/*.{js,mjs,cjs,ts,mts,cts} editors/vscode/**/*.{js,mjs,cjs,ts,mts,cts}",
|
||||||
"prelaunch:vscode": "node scripts/build.mjs prelaunch:vscode",
|
"prelaunch:vscode": "node scripts/build.mjs prelaunch:vscode",
|
||||||
|
"prelaunch:vscode-release": "node scripts/build.mjs prelaunch:vscode-release",
|
||||||
|
"install:vscode": "node scripts/build.mjs install:vscode",
|
||||||
"build:lsp:debug": "node scripts/build.mjs build:lsp:debug",
|
"build:lsp:debug": "node scripts/build.mjs build:lsp:debug",
|
||||||
"build:editor-tools": "node scripts/build.mjs build:editor-tools",
|
"build:editor-tools": "node scripts/build.mjs build:editor-tools",
|
||||||
"build:preview": "node scripts/build.mjs build:preview",
|
"build:preview": "node scripts/build.mjs build:preview",
|
||||||
|
|
|
||||||
|
|
@ -1,43 +1,25 @@
|
||||||
import * as build from "./builders.mjs";
|
import * as build from "./builders.mjs";
|
||||||
|
|
||||||
if (process.argv.includes("build:l10n")) {
|
const kind = process.argv[2];
|
||||||
await build.buildL10n();
|
const vector = {
|
||||||
}
|
"build:l10n": build.buildL10n,
|
||||||
|
"build:syntax": build.buildSyntax,
|
||||||
|
"build:preview": build.buildPreview,
|
||||||
|
"build:editor-tools": build.buildEditorTools,
|
||||||
|
"build:vscode:web": build.buildTinymistVscodeWeb,
|
||||||
|
"build:vscode:system": build.buildTinymistVscodeSystem,
|
||||||
|
"build:lsp:debug": () => build.buildLspBinary("debug"),
|
||||||
|
"prelaunch:vscode": () => build.prelaunchVscode("debug"),
|
||||||
|
"prelaunch:vscode-release": () => build.prelaunchVscode("release"),
|
||||||
|
"install:vscode": () => build.installVscode("release"),
|
||||||
|
"build:web:base": build.buildWebLspBinaryBase,
|
||||||
|
"build:web": build.buildTinymistVscodeWeb,
|
||||||
|
};
|
||||||
|
|
||||||
if (process.argv.includes("build:syntax")) {
|
const fn = vector[kind];
|
||||||
await build.buildSyntax();
|
if (fn) {
|
||||||
|
await fn();
|
||||||
|
} else {
|
||||||
|
console.error(`Unknown command: ${kind}`);
|
||||||
|
process.exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (process.argv.includes("build:preview")) {
|
|
||||||
await build.buildPreview();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (process.argv.includes("build:editor-tools")) {
|
|
||||||
await build.buildEditorTools();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (process.argv.includes("build:vscode:web")) {
|
|
||||||
await build.buildTinymistVscodeWeb();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (process.argv.includes("build:vscode:system")) {
|
|
||||||
await build.buildTinymistVscodeSystem();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (process.argv.includes("build:lsp:debug")) {
|
|
||||||
await build.buildDebugLspBinary();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (process.argv.includes("prelaunch:vscode")) {
|
|
||||||
await build.prelaunchVscode();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (process.argv.includes("build:web:base")) {
|
|
||||||
await build.buildWebLspBinaryBase();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (process.argv.includes("build:web")) {
|
|
||||||
await build.buildTinymistVscodeWeb();
|
|
||||||
}
|
|
||||||
|
|
||||||
// build:editor-tools
|
|
||||||
|
|
|
||||||
|
|
@ -127,6 +127,8 @@ export async function checkVersion() {
|
||||||
`Version mismatch: ${cargoVersion} (in Cargo.toml) !== ${pkgVersion} (in package.json)`,
|
`Version mismatch: ${cargoVersion} (in Cargo.toml) !== ${pkgVersion} (in package.json)`,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return { cargoVersion, pkgVersion };
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function buildTinymistVscodeWebBase() {
|
export async function buildTinymistVscodeWebBase() {
|
||||||
|
|
@ -157,8 +159,8 @@ export async function buildTinymistVscodeSystem() {
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function buildDebugLspBinary() {
|
export async function buildLspBinary(kind) {
|
||||||
await spawnAsync("lsp:debug", "cargo build -p tinymist-cli --color=always", {
|
await spawnAsync(`lsp:${kind}`, `cargo build -p tinymist-cli --color=always --profile=${kind}`, {
|
||||||
env: {
|
env: {
|
||||||
...process.env,
|
...process.env,
|
||||||
FORCE_COLOR: "1",
|
FORCE_COLOR: "1",
|
||||||
|
|
@ -169,10 +171,10 @@ export async function buildDebugLspBinary() {
|
||||||
|
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
fs.copyFile(
|
fs.copyFile(
|
||||||
path.resolve(cwd, `target/debug/${binName}`),
|
path.resolve(cwd, `target/${kind}/${binName}`),
|
||||||
path.resolve(vscodeDir, `out/${binName}`),
|
path.resolve(vscodeDir, `out/${binName}`),
|
||||||
),
|
),
|
||||||
process.platform === "win32"
|
process.platform === "win32" && kind === "debug"
|
||||||
? [
|
? [
|
||||||
fs.copyFile(
|
fs.copyFile(
|
||||||
path.resolve(cwd, `target/debug/tinymist.pdb`),
|
path.resolve(cwd, `target/debug/tinymist.pdb`),
|
||||||
|
|
@ -183,8 +185,23 @@ export async function buildDebugLspBinary() {
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function prelaunchVscode() {
|
export async function prelaunchVscode(kind) {
|
||||||
await Promise.all([buildTinymistVscodeSystem(), buildDebugLspBinary()]);
|
await Promise.all([buildTinymistVscodeSystem(), buildLspBinary(kind)]);
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function installVscode(kind) {
|
||||||
|
const [{ pkgVersion }, ..._rest] = await Promise.all([
|
||||||
|
checkVersion(),
|
||||||
|
buildTinymistVscodeSystem(),
|
||||||
|
buildLspBinary(kind),
|
||||||
|
]);
|
||||||
|
await spawnAsync("package:vscode", "cd editors/vscode && yarn package");
|
||||||
|
|
||||||
|
// install code
|
||||||
|
await spawnAsync(
|
||||||
|
"install:vscode",
|
||||||
|
`cd editors/vscode && code --install-extension tinymist-${pkgVersion}.vsix`,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function buildWebLspBinaryBase() {
|
export async function buildWebLspBinaryBase() {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue