Skip to content
Open
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
27 changes: 27 additions & 0 deletions Werkfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
let werk-vscode-version = shell "jq --raw-output .version werk-vscode/package.json"

build "werk-vscode/node_modules" {
from ["werk-vscode/package.json", "werk-vscode/package-lock.json"]
run ["npm --prefix werk-vscode install", "touch <out>"]
}
build "/werk-vscode/werk-{werk-vscode-version}.vsix" {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's missing here is running npm install.
I'd love to do

build "werk-vscode/node_modules" {
    from "werk-vscode/package-lock.json"
    run "npm --prefix werk-vscode install"
}

but that will be rebuilt every time because werk expects the node_modules to be in the target folder. I don't think it supports files in the workspace right now?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Limitations

Separate output directory: It is not possible to put output files next to input files, and files in the output directory are assumed to be generated by werk.

The question is, is this a "not implemented" limitation or "this fundamentally opposes the values of werk" limitation? I think it would be very useful to have but I can understand if you regard this as out of scope.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So a build recipe (currently) can't produce a directory, although that would be an amazing feature.

I think the --prefix flag to npm needs to point into werk's output dir, using a "<...>" interpolated variable. I would like to support the syntax run "npm --prefix <OUT_DIR>/node_modules install", but that requires a few features that are still in the pipeline.

Still, I wouldn't be too worried about integrating NPM with werk's outdatedness tracking, as long as npm gets the right flags. It would be fine (IMO) for something like this to be a task instead of a build recipe, if it can't be supported nicely.

Copy link
Collaborator Author

@jakobhellermann jakobhellermann Feb 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would like to support the syntax run "npm --prefix <OUT_DIR>/node_modules install", but that requires a few features that are still in the pipeline.

I think npm --prefix {OUT_DIR} would work but only if npm gets executed from the cwd of vscode-werk. I don't think that's possible right now, right?
But a

build "werk-vscode/node_modules" {
    from "werk-vscode/package-lock.json"
    cwd "werk-vscode"
    run "npm install --prefix {OUT_DIR}"
}

would probably not be too hard to add, and also useful because not every tool has a -f / --manifest-path / --prefix flag.

(I also tried run "sh -c 'cd werk-vscode && npm install'" but the quotes don't get parsed: &command_line = Absolute { path: "/usr/bin/sh" } "-c" "\'cd" "werk-vscode" "&&" "npm" "install\'")

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I want sh -c '...' to be supported, feel free to create an issue for it.

I'll much around with npm a bit and try to figure out what the best solution is here. I bet it's a useful thing that people will be looking for in the docs too.

from ["werk-vscode/node_modules", glob "werk-vscode/**/*"]
run "npm --prefix werk-vscode run package -- --out ../target/werk-vscode"
}
build "/book/book" {
run "mdbook build book --dest-dir book/book"
}

task vscode-install-extension {
let vsix = "/werk-vscode/werk-{werk-vscode-version}.vsix"
build vsix
run "code --install-extension <vsix>"
}

task cli-install {
run "cargo install --path werk-cli"
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Funnily, this will usually clobber the process doing it, which will always fail on Windows. Might be nice for completeness, still.

}

task mdbook-serve {
run "mdbook serve book"
}
2 changes: 2 additions & 0 deletions werk-vscode/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/node_modules
/*.vsix
4 changes: 0 additions & 4 deletions werk-vscode/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
# Change Log

All notable changes to the "werk" extension will be documented in this file.

Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how to structure this file.

## [Unreleased]

- Initial release
6 changes: 6 additions & 0 deletions werk-vscode/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
werk-vscode is dual-licensed under either

* MIT License ([LICENSE-MIT](../../LICENSE-MIT))
* Apache License, Version 2.0 ([LICENSE-APACHE](../../LICENSE-APACHE))

at your option.
1 change: 1 addition & 0 deletions werk-vscode/LICENSE-APACHE
1 change: 1 addition & 0 deletions werk-vscode/LICENSE-MIT
66 changes: 2 additions & 64 deletions werk-vscode/README.md
Original file line number Diff line number Diff line change
@@ -1,65 +1,3 @@
# werk README
# werk

This is the README for your extension "werk". After writing up a brief description, we recommend including the following sections.

## Features

Describe specific features of your extension including screenshots of your extension in action. Image paths are relative to this README file.

For example if there is an image subfolder under your extension project workspace:

\!\[feature X\]\(images/feature-x.png\)

> Tip: Many popular extensions utilize animations. This is an excellent way to show off your extension! We recommend short, focused animations that are easy to follow.

## Requirements

If you have any requirements or dependencies, add a section describing those and how to install and configure them.

## Extension Settings

Include if your extension adds any VS Code settings through the `contributes.configuration` extension point.

For example:

This extension contributes the following settings:

* `myExtension.enable`: Enable/disable this extension.
* `myExtension.thing`: Set to `blah` to do something.

## Known Issues

Calling out known issues can help limit users opening duplicate issues against your extension.

## Release Notes

Users appreciate release notes as you update your extension.

### 1.0.0

Initial release of ...

### 1.0.1

Fixed issue #.

### 1.1.0

Added features X, Y, and Z.

---

## Working with Markdown

You can author your README using Visual Studio Code. Here are some useful editor keyboard shortcuts:

* Split the editor (`Cmd+\` on macOS or `Ctrl+\` on Windows and Linux).
* Toggle preview (`Shift+Cmd+V` on macOS or `Shift+Ctrl+V` on Windows and Linux).
* Press `Ctrl+Space` (Windows, Linux, macOS) to see a list of Markdown snippets.

## For more information

* [Visual Studio Code's Markdown Support](http://code.visualstudio.com/docs/languages/markdown)
* [Markdown Syntax Reference](https://help.github.com/articles/markdown-basics/)

**Enjoy!**
Basic language support for [werk](https://github.com/simonask/werk), a simplistic command runner and build system.
Loading