@x-ror/ruby-templates 0.0.0-stage → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 x_ror
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,15 @@
1
- # Temporary Holding Version
1
+ # ruby-templates
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ A whitespace-only formatter and the structure checks for ERB, Haml and Slim templates, from the [Ruby Templates](https://github.com/x-ror/vscode-ruby-templates) VS Code extension's language server.
4
+
5
+ ```sh
6
+ npm install --save-dev @x-ror/ruby-templates
7
+ npx ruby-templates check app/views
8
+ npx ruby-templates format --check app/views
9
+ npx ruby-templates format --write app/views
10
+ npx ruby-templates format --stdin-filepath app/views/users/show.html.erb < show.html.erb
11
+ ```
12
+
13
+ The formatter changes only indentation, trailing whitespace, blank lines, the final newline and line endings, and leaves a file it is in doubt about unchanged, saying why on stderr. The only setting is the indentation width, from `.editorconfig` (`indent_size`, default 2); see [the settings](https://github.com/x-ror/vscode-ruby-templates/blob/main/docs/FORMATTER_CONFIG.md). Exit codes: 0 ok, 1 diagnostics or files that would change, 2 usage or I/O error.
14
+
15
+ The binary comes from a per-platform package (Linux x64/arm64, Windows x64) installed as an optional dependency; `RUBY_TEMPLATES_BINARY` points the wrapper at another build.
@@ -0,0 +1,41 @@
1
+ #!/usr/bin/env node
2
+ // Runs the `ruby-templates` binary from the package built for this platform (`<name>-<platform>-<arch>`), which npm
3
+ // installs through optionalDependencies.
4
+ import { spawnSync } from "child_process";
5
+ import fs from "fs";
6
+ import path from "path";
7
+ import { createRequire } from "module";
8
+
9
+ const require = createRequire(import.meta.url);
10
+ const { name, optionalDependencies } = JSON.parse(
11
+ fs.readFileSync(path.join(import.meta.dirname, "..", "package.json"), "utf8"),
12
+ );
13
+ const exe =
14
+ process.platform === "win32" ? "ruby-templates.exe" : "ruby-templates";
15
+
16
+ function binary() {
17
+ if (process.env.RUBY_TEMPLATES_BINARY)
18
+ return process.env.RUBY_TEMPLATES_BINARY;
19
+ const platformPackage = `${name}-${process.platform}-${process.arch}`;
20
+ try {
21
+ const manifest = require.resolve(`${platformPackage}/package.json`);
22
+ return path.join(path.dirname(manifest), "bin", exe);
23
+ } catch {
24
+ const why =
25
+ platformPackage in optionalDependencies
26
+ ? `${platformPackage} is not installed; reinstall without --omit=optional`
27
+ : `no prebuilt binary is published for ${process.platform}-${process.arch}`;
28
+ console.error(`ruby-templates: ${why}, or set RUBY_TEMPLATES_BINARY.`);
29
+ process.exit(2);
30
+ }
31
+ }
32
+
33
+ const { status, signal, error } = spawnSync(binary(), process.argv.slice(2), {
34
+ stdio: "inherit",
35
+ });
36
+ if (error) {
37
+ console.error(`ruby-templates: ${error.message}`);
38
+ process.exit(2);
39
+ }
40
+ if (signal) process.kill(process.pid, signal);
41
+ process.exit(status ?? 2);
package/package.json CHANGED
@@ -1,6 +1,32 @@
1
1
  {
2
2
  "name": "@x-ror/ruby-templates",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.2.0",
4
+ "description": "Whitespace-only formatter and checks for ERB, Haml and Slim templates",
5
+ "license": "MIT",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+https://github.com/x-ror/vscode-ruby-templates.git"
9
+ },
10
+ "keywords": [
11
+ "erb",
12
+ "haml",
13
+ "slim",
14
+ "rails",
15
+ "formatter"
16
+ ],
17
+ "type": "module",
18
+ "bin": {
19
+ "ruby-templates": "bin/ruby-templates.js"
20
+ },
21
+ "files": [
22
+ "bin"
23
+ ],
24
+ "engines": {
25
+ "node": ">=20.11"
26
+ },
27
+ "optionalDependencies": {
28
+ "@x-ror/ruby-templates-linux-x64": "0.2.0",
29
+ "@x-ror/ruby-templates-linux-arm64": "0.2.0",
30
+ "@x-ror/ruby-templates-win32-x64": "0.2.0"
31
+ }
32
+ }