Skip to content

Commit 05b8740

Browse files
committed
add script update version
1 parent 2b17ba8 commit 05b8740

File tree

7 files changed

+41
-20
lines changed

7 files changed

+41
-20
lines changed

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,4 +223,4 @@ For beta releases, ask folks to use the pre-release version installable from the
223223

224224
## Releasing the `@rescript/tools` package
225225

226-
The tools package is released by bumping the version in `tools/package.json` and `tools/bin/main/ml`, running `npm i` in the `tools/` folder, and then pushing those changes with the commit message `publish tools`.
226+
The tools package is released by bumping the version in `tools/package.json` and run `node scripts/updateVersion.js`, running `npm i` in the `tools/` folder, and then pushing those changes with the commit message `publish tools`.

analysis/bin/main.ml

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -145,13 +145,7 @@ let main () =
145145
~pos:(int_of_string line_start, int_of_string line_end)
146146
~maxLength ~debug
147147
| [_; "codeLens"; path] -> Commands.codeLens ~path ~debug
148-
| [_; "extractDocs"; path] ->
149-
150-
let () = match Sys.getenv_opt "FROM_COMPILER" with
151-
| Some("true") -> Cfg.isDocGenFromCompiler := true
152-
| _ -> () in
153-
154-
DocExtraction.extractDocs ~path ~debug
148+
| [_; "extractDocs"; path] -> DocExtraction.extractDocs ~path ~debug
155149
| [_; "codeAction"; path; startLine; startCol; endLine; endCol; currentFile]
156150
->
157151
Commands.codeAction ~path

scripts/updateVersion.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
//@ts-check
2+
// This file is used only in dev time
3+
// Bump version in package.json and this script will update version in ml file
4+
// and rescript.json
5+
6+
const fs = require("fs");
7+
const path = require("path");
8+
9+
const toolsPkgDir = path.join(__dirname, "..", "tools");
10+
11+
const { version } = JSON.parse(
12+
fs.readFileSync(path.join(toolsPkgDir, "package.json"), "utf8"),
13+
);
14+
15+
const rescriptJsonPath = path.join(toolsPkgDir, "rescript.json");
16+
17+
const rescriptJson = JSON.parse(fs.readFileSync(rescriptJsonPath, "utf8"));
18+
rescriptJson.version = version;
19+
fs.writeFileSync(rescriptJsonPath, JSON.stringify(rescriptJson, null, 2));
20+
21+
fs.writeFileSync(
22+
path.join(toolsPkgDir, "bin", "version.ml"),
23+
`let version = "${version}"`,
24+
);

tools/bin/main.ml

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
(* Update here and package.json *)
2-
let version = "0.1.1"
3-
42
let docHelp =
53
{|ReScript Tools
64

@@ -33,12 +31,20 @@ let logAndExit ~log ~code =
3331
in
3432
exit code
3533

34+
let version = Version.version
35+
3636
let main () =
3737
match Sys.argv |> Array.to_list |> List.tl with
3838
| "doc" :: rest -> (
3939
match rest with
4040
| ["-h"] | ["--help"] -> logAndExit ~log:docHelp ~code:`Ok
41-
| [path] -> Analysis.DocExtraction.extractDocs ~path ~debug:false
41+
| [path] -> (
42+
(* NOTE: Internal use to generate docs from compiler *)
43+
let () = match Sys.getenv_opt "FROM_COMPILER" with
44+
| Some("true") -> Analysis.Cfg.isDocGenFromCompiler := true
45+
| _ -> () in
46+
Analysis.DocExtraction.extractDocs ~path ~debug:false
47+
)
4248
| _ -> logAndExit ~log:docHelp ~code:`Error)
4349
| "reanalyze" :: _ ->
4450
let len = Array.length Sys.argv in

tools/bin/version.ml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
let version = "0.3.0"

tools/rescript.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@rescript/tools",
3-
"version": "0.2.0",
3+
"version": "0.3.0",
44
"sources": [
55
{
66
"dir": "src"
@@ -11,4 +11,4 @@
1111
"module": "commonjs",
1212
"in-source": true
1313
}
14-
}
14+
}

tools/src/cli.js

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,8 @@ const binPath = path.join(__dirname, "..", "binaries", platformArch, "rescript-t
1212

1313
const args = process.argv.slice(2);
1414

15-
const spawn = child_process.spawnSync(binPath, args);
15+
const spawn = child_process.spawnSync(binPath, args, { stdio: "inherit" });
1616

17-
if (spawn.status !== 0) {
18-
console.log(spawn.stderr.toString().trim());
19-
process.exit(spawn.status || 1);
20-
} else {
21-
console.log(spawn.stdout.toString().trim());
22-
process.exit(0)
17+
if (spawn.status != null) {
18+
process.exit(spawn.status)
2319
}

0 commit comments

Comments
 (0)