Skip to content

Commit

Permalink
VSC: Set up VSCE packaging pipeline (use 'make vscode_ext' in release)
Browse files Browse the repository at this point in the history
  • Loading branch information
kosude committed May 27, 2024
1 parent 83b9abb commit a5b6e1f
Show file tree
Hide file tree
Showing 7 changed files with 89 additions and 1,910 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,10 @@

build/
target/
dist/
*.vsix

node_modules/

# this file is generated on make because vsce requires a LICENSE file (misspelt), and is just a copy of LICENCE.
integration/vscode-ext/LICENSE
File renamed without changes.
31 changes: 24 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@ CARGO_TOML := $(SRC_DIR)/Cargo.toml

NPM := npm
NODE := node
VSCE := vsce

VSCODE_EXT_BUILD_DIR := $(BUILD_DIR)/integration/vscode-ext
VSCODE_EXT_PREFIX := $(SRC_DIR)/integration/vscode-ext
VSCODE_EXT_NPM_SCRIPT := build
VSCODE_EXT_NPM_SCRIPT := build:dev
VSCODE_EXT_DIST_DIR := $(VSCODE_EXT_PREFIX)/dist

# this ensures `all` is run by default despite not being the first target in the Makefile
.DEFAULT_GOAL := all
Expand All @@ -27,7 +28,6 @@ validate_cargo:
$(shell which $(CARGO)),\
$(info Cargo located at $(shell command -v $(CARGO))),\
$(error Cargo not found in PATH, but is required to build devinit))
@:

validate_npm:
$(if \
Expand All @@ -38,13 +38,20 @@ validate_npm:
$(shell which $(NODE)),\
$(info Node.js located at $(shell command -v $(NODE))),\
$(error Node.js not found in PATH, but is required to build the devinit VS Code extension))
@:

validate_vsce:
$(if \
$(shell which $(VSCE)),\
$(info vsce located at $(shell command -v $(VSCE))),\
$(error vsce not found in PATH, but is required to build the devinit VS Code extension))

# run with DEBUG=1 to use debug configuration

ifneq "$(DEBUG)" "1"
CARGOFLAGS += --release
VSCODE_EXT_NPM_SCRIPT = package
VSCODE_EXT_NPM_SCRIPT = build:prod

vscode_ext: | validate_vsce
endif

.PHONY: devinit vscode_ext
Expand Down Expand Up @@ -72,8 +79,18 @@ devinit: $(CARGO_TOML) | validate_cargo
# Bundle the VS Code extension
#

vscode_ext: | validate_npm
JS_BUILD_DIR=$(VSCODE_EXT_BUILD_DIR) $(NPM) run --prefix=$(VSCODE_EXT_PREFIX) $(VSCODE_EXT_NPM_SCRIPT)
$(VSCODE_EXT_PREFIX)/node_modules:
$(NPM) install --prefix=$(VSCODE_EXT_PREFIX)

vscode_ext: | validate_npm $(VSCODE_EXT_PREFIX)/node_modules
$(NPM) run $(VSCODE_EXT_NPM_SCRIPT) --prefix=$(VSCODE_EXT_PREFIX)

ifneq "$(DEBUG)" "1"
cp $(SRC_DIR)/LICENCE $(VSCODE_EXT_PREFIX)/LICENSE

cd $(VSCODE_EXT_PREFIX) && \
$(VSCE) package --out=$(VSCODE_EXT_DIST_DIR) --readme-path=$(SRC_DIR)/README.md
endif


#
Expand Down
9 changes: 9 additions & 0 deletions integration/vscode-ext/.vscodeignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
node_modules/
src/

**/*.map

package-lock.json
esbuild.mjs
tsconfig.json
.vscodeignore
4 changes: 1 addition & 3 deletions integration/vscode-ext/esbuild.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,9 @@

import esbuild from "esbuild";

const buildDir = process.env["JS_BUILD_DIR"];
const buildDir = "dist";
const isProd = process.env["NODE_ENV"] === "production";

console.log(buildDir)

const configBase = {
bundle: true,
minify: isProd,
Expand Down
Loading

0 comments on commit a5b6e1f

Please sign in to comment.