Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add back typescript version number and add Deno.version object. #1788

Merged
merged 7 commits into from
Feb 18, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ ts_sources = [
"js/workers.ts",
"js/write_file.ts",
"js/performance.ts",
"js/version.ts",
"tsconfig.json",

# Listing package.json and yarn.lock as sources ensures the bundle is rebuilt
Expand Down
1 change: 1 addition & 0 deletions js/deno.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ export { metrics, Metrics } from "./metrics";
export { resources } from "./resources";
export { run, RunOptions, Process, ProcessStatus } from "./process";
export { inspect } from "./console";
export { version } from "./version";
export const args: string[] = [];

// TODO Don't expose Console nor stringifyArgs.
Expand Down
10 changes: 6 additions & 4 deletions js/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import * as os from "./os";
import { libdeno } from "./libdeno";
import { args } from "./deno";
import { replLoop } from "./repl";
import { setVersions } from "./version";

// builtin modules
import * as deno from "./deno";
Expand All @@ -24,12 +25,13 @@ export default function denoMain() {
libdeno.builtinModules["deno"] = deno;
Object.freeze(libdeno.builtinModules);

setVersions(startResMsg.denoVersion()!, startResMsg.v8Version()!);

// handle `--version`
if (startResMsg.versionFlag()) {
console.log("deno:", startResMsg.denoVersion());
console.log("v8:", startResMsg.v8Version());
// TODO figure out a way to restore functionality
// console.log("typescript:", version);
console.log("deno:", deno.version.deno);
console.log("v8:", deno.version.v8);
console.log("typescript:", deno.version.typescript);
os.exit(0);
}

Expand Down
1 change: 1 addition & 0 deletions js/unit_tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ import "./url_test.ts";
import "./url_search_params_test.ts";
import "./write_file_test.ts";
import "./performance_test.ts";
import "./version_test.ts";

import "../website/app_test.js";

Expand Down
23 changes: 23 additions & 0 deletions js/version.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
interface Version {
deno: string;
v8: string;
typescript: string;
}

export const version: Version = {
deno: "",
v8: "",
typescript: "TS_VERSION" // This string will be replaced by rollup
};

/**
* Sets the deno and v8 versions and freezes the version object.
Copy link
Contributor

Choose a reason for hiding this comment

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

I would set this to @internal so it doesn't get leaked to the runtime type library.

* @internal
*/
export function setVersions(denoVersion: string, v8Version: string): void {
version.deno = denoVersion;
version.v8 = v8Version;

Object.freeze(version);
}
8 changes: 8 additions & 0 deletions js/version_test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { test, assert } from "./test_util.ts";

test(function version() {
const pattern = /^\d+\.\d+\.\d+$/;
assert(pattern.test(Deno.version.deno));
assert(pattern.test(Deno.version.v8));
assert(pattern.test(Deno.version.typescript));
});
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"rollup-plugin-commonjs": "^9.1.3",
"rollup-plugin-node-globals": "^1.2.1",
"rollup-plugin-node-resolve": "^3.3.0",
"rollup-plugin-replace": "^2.1.0",
"rollup-plugin-string": "^2.0.2",
"rollup-plugin-typescript2": "^0.16.1",
"rollup-pluginutils": "^2.3.0",
Expand Down
6 changes: 6 additions & 0 deletions rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import globals from "rollup-plugin-node-globals";
import nodeResolve from "rollup-plugin-node-resolve";
import typescriptPlugin from "rollup-plugin-typescript2";
import { createFilter } from "rollup-pluginutils";
import replace from "rollup-plugin-replace";
import typescript from "typescript";
import MagicString from "magic-string";

Expand Down Expand Up @@ -225,6 +226,11 @@ export default function makeConfig(commandOptions) {
include: [platformPath]
}),

// replace strings
replace({
TS_VERSION: typescript.version
}),

// would prefer to use `rollup-plugin-virtual` to inject the empty module, but there
// is an issue with `rollup-plugin-commonjs` which causes errors when using the
// virtual plugin (see: rollup/rollup-plugin-commonjs#315), this means we have to use
Expand Down
2 changes: 1 addition & 1 deletion third_party
Submodule third_party updated 26 files
+5 −13 node_modules/.yarn-integrity
+35 −0 node_modules/rollup-plugin-replace/CHANGELOG.md
+105 −0 node_modules/rollup-plugin-replace/README.md
+91 −0 node_modules/rollup-plugin-replace/dist/rollup-plugin-replace.cjs.js
+87 −0 node_modules/rollup-plugin-replace/dist/rollup-plugin-replace.es.js
+374 −0 node_modules/rollup-plugin-replace/node_modules/magic-string/CHANGELOG.md
+7 −0 node_modules/rollup-plugin-replace/node_modules/magic-string/LICENSE
+259 −0 node_modules/rollup-plugin-replace/node_modules/magic-string/README.md
+1,298 −0 node_modules/rollup-plugin-replace/node_modules/magic-string/dist/magic-string.cjs.js
+1 −0 node_modules/rollup-plugin-replace/node_modules/magic-string/dist/magic-string.cjs.js.map
+1,294 −0 node_modules/rollup-plugin-replace/node_modules/magic-string/dist/magic-string.es.js
+1 −0 node_modules/rollup-plugin-replace/node_modules/magic-string/dist/magic-string.es.js.map
+1,354 −0 node_modules/rollup-plugin-replace/node_modules/magic-string/dist/magic-string.umd.js
+1 −0 node_modules/rollup-plugin-replace/node_modules/magic-string/dist/magic-string.umd.js.map
+106 −0 node_modules/rollup-plugin-replace/node_modules/magic-string/index.d.ts
+48 −0 node_modules/rollup-plugin-replace/node_modules/magic-string/package.json
+53 −0 node_modules/rollup-plugin-replace/package.json
+83 −0 node_modules/rollup-plugin-replace/src/index.js
+48 −0 node_modules/sourcemap-codec/CHANGELOG.md
+21 −0 node_modules/sourcemap-codec/LICENSE
+63 −0 node_modules/sourcemap-codec/README.md
+129 −0 node_modules/sourcemap-codec/dist/sourcemap-codec.es.js
+140 −0 node_modules/sourcemap-codec/dist/sourcemap-codec.umd.js
+5 −0 node_modules/sourcemap-codec/dist/types/sourcemap-codec.d.ts
+52 −0 node_modules/sourcemap-codec/package.json
+22 −4 yarn.lock