Skip to content

Commit 4d8d514

Browse files
committed
Migrate core.ts
1 parent d0988b8 commit 4d8d514

File tree

21 files changed

+1005
-1358
lines changed

21 files changed

+1005
-1358
lines changed

Gulpfile.ts

Lines changed: 13 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -611,57 +611,23 @@ gulp.task("LKG", "Makes a new LKG out of the built js files", ["clean", "dontUse
611611
return runSequence("LKGInternal", "VerifyLKG");
612612
});
613613

614-
gulp.task("typemock", () => {
615-
const project = tsc.createProject("scripts/typemock/tsconfig.json", getCompilerSettings({}, /*useBuiltCompiler*/ false));
614+
function compilePrivatePackage(packageName) {
615+
const project = tsc.createProject(`scripts/${packageName}/tsconfig.json`, getCompilerSettings({}, /*useBuiltCompiler*/ false));
616616
return project.src()
617617
.pipe(sourcemaps.init())
618-
.pipe(newer("scripts/typemock/dist/index.js"))
618+
.pipe(newer(`scripts/${packageName}/dist/index.js`))
619619
.pipe(project())
620-
.pipe(sourcemaps.write(".", <any>{ sourceRoot: "../src", includeContent: false, destPath: "scripts/typemock/dist" }))
621-
.pipe(gulp.dest("scripts/typemock/dist"));
622-
});
623-
624-
gulp.task("vfs-core", () => {
625-
const project = tsc.createProject("scripts/vfs-core/tsconfig.json", getCompilerSettings({}, /*useBuiltCompiler*/ false));
626-
return project.src()
627-
.pipe(sourcemaps.init())
628-
.pipe(newer("scripts/vfs-core/dist/index.js"))
629-
.pipe(project())
630-
.pipe(sourcemaps.write(".", <any>{ sourceRoot: "../src", includeContent: false, destPath: "scripts/vfs-core/dist" }))
631-
.pipe(gulp.dest("scripts/vfs-core/dist"));
632-
});
633-
634-
gulp.task("vfs-errors", () => {
635-
const project = tsc.createProject("scripts/vfs-errors/tsconfig.json", getCompilerSettings({}, /*useBuiltCompiler*/ false));
636-
return project.src()
637-
.pipe(sourcemaps.init())
638-
.pipe(newer("scripts/vfs-errors/dist/index.js"))
639-
.pipe(project())
640-
.pipe(sourcemaps.write(".", <any>{ sourceRoot: "../src", includeContent: false, destPath: "scripts/vfs-errors/dist" }))
641-
.pipe(gulp.dest("scripts/vfs-errors/dist"));
642-
});
643-
644-
gulp.task("vfs-path", ["vfs-core", "vfs-errors"], () => {
645-
const project = tsc.createProject("scripts/vfs-path/tsconfig.json", getCompilerSettings({}, /*useBuiltCompiler*/ false));
646-
return project.src()
647-
.pipe(sourcemaps.init())
648-
.pipe(newer("scripts/vfs-path/dist/index.js"))
649-
.pipe(project())
650-
.pipe(sourcemaps.write(".", <any>{ sourceRoot: "../src", includeContent: false, destPath: "scripts/vfs-path/dist" }))
651-
.pipe(gulp.dest("scripts/vfs-path/dist"));
652-
});
653-
654-
gulp.task("vfs", ["vfs-core", "vfs-errors", "vfs-path"], () => {
655-
const project = tsc.createProject("scripts/vfs/tsconfig.json", getCompilerSettings({}, /*useBuiltCompiler*/ false));
656-
return project.src()
657-
.pipe(sourcemaps.init())
658-
.pipe(newer("scripts/vfs/dist/index.js"))
659-
.pipe(project())
660-
.pipe(sourcemaps.write(".", <any>{ sourceRoot: "../src", includeContent: false, destPath: "scripts/vfs/dist" }))
661-
.pipe(gulp.dest("scripts/vfs/dist"));
662-
});
620+
.pipe(sourcemaps.write(".", <any>{ sourceRoot: "../src", includeContent: false, destPath: `scripts/${packageName}/dist` }))
621+
.pipe(gulp.dest(`scripts/${packageName}/dist`));
622+
}
663623

664-
gulp.task("private-packages", ["typemock", "vfs"]);
624+
gulp.task("typemock", () => compilePrivatePackage("typemock"));
625+
gulp.task("vfs-core", () => compilePrivatePackage("vfs-core"));
626+
gulp.task("vfs-errors", () => compilePrivatePackage("vfs-errors"));
627+
gulp.task("vfs-path", ["vfs-core", "vfs-errors"], () => compilePrivatePackage("vfs-path"));
628+
gulp.task("vfs", ["vfs-core", "vfs-errors", "vfs-path", "typemock"], () => compilePrivatePackage("vfs"));
629+
gulp.task("harness-core", ["vfs-core"], () => compilePrivatePackage("harness-core"));
630+
gulp.task("private-packages", ["typemock", "vfs", "harness-core"]);
665631

666632
// Task to build the tests infrastructure using the built compiler
667633
const run = path.join(builtLocalDirectory, "run.js");

Jakefile.js

Lines changed: 21 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -803,72 +803,28 @@ task("LKG", ["clean", "release", "local"].concat(libraryTargets), function () {
803803
// Test directory
804804
directory(builtLocalDirectory);
805805

806-
task("typemock", function () {
807-
var startCompileTime = mark();
808-
execCompiler(/*useBuiltCompiler*/ false, ["-p", "scripts/typemock/tsconfig.json"], function (error) {
809-
if (error) {
810-
fail("Compilation unsuccessful.");
811-
}
812-
else {
813-
complete();
814-
}
815-
measure(startCompileTime);
816-
});
817-
}, { async: true });
818-
819-
task("vfs-core", function () {
820-
var startCompileTime = mark();
821-
execCompiler(/*useBuiltCompiler*/ false, ["-p", "scripts/vfs-core/tsconfig.json"], function (error) {
822-
if (error) {
823-
fail("Compilation unsuccessful.");
824-
}
825-
else {
826-
complete();
827-
}
828-
measure(startCompileTime);
829-
});
830-
}, { async: true });
831-
832-
task("vfs-errors", function () {
833-
var startCompileTime = mark();
834-
execCompiler(/*useBuiltCompiler*/ false, ["-p", "scripts/vfs-errors/tsconfig.json"], function (error) {
835-
if (error) {
836-
fail("Compilation unsuccessful.");
837-
}
838-
else {
839-
complete();
840-
}
841-
measure(startCompileTime);
842-
});
843-
}, { async: true });
844-
845-
task("vfs-path", ["vfs-core", "vfs-errors"], function () {
846-
var startCompileTime = mark();
847-
execCompiler(/*useBuiltCompiler*/ false, ["-p", "scripts/vfs-path/tsconfig.json"], function (error) {
848-
if (error) {
849-
fail("Compilation unsuccessful.");
850-
}
851-
else {
852-
complete();
853-
}
854-
measure(startCompileTime);
855-
});
856-
}, { async: true });
857-
858-
task("vfs", ["vfs-core", "vfs-errors", "vfs-path", "typemock"], function () {
859-
var startCompileTime = mark();
860-
execCompiler(/*useBuiltCompiler*/ false, ["-p", "scripts/vfs/tsconfig.json"], function (error) {
861-
if (error) {
862-
fail("Compilation unsuccessful.");
863-
}
864-
else {
865-
complete();
866-
}
867-
measure(startCompileTime);
868-
});
869-
}, { async: true });
806+
function privatePackage(packageName, prereqs) {
807+
task(packageName, prereqs, function () {
808+
var startCompileTime = mark();
809+
execCompiler(/*useBuiltCompiler*/ false, ["-p", `scripts/${packageName}/tsconfig.json`], function (error) {
810+
if (error) {
811+
fail("Compilation unsuccessful.");
812+
}
813+
else {
814+
complete();
815+
}
816+
measure(startCompileTime);
817+
});
818+
}, { async: true });
819+
}
870820

871-
task("private-packages", ["typemock", "vfs"]);
821+
privatePackage("typemock");
822+
privatePackage("vfs-core");
823+
privatePackage("vfs-errors");
824+
privatePackage("vfs-path", ["vfs-core", "vfs-errors"]);
825+
privatePackage("vfs", ["vfs-path", "typemock"]);
826+
privatePackage("harness-core", ["vfs-core"]);
827+
task("private-packages", ["typemock", "vfs", "harness-core"]);
872828

873829
// Task to build the tests infrastructure using the built compiler
874830
var run = path.join(builtLocalDirectory, "run.js");

jenkins.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
11
#!/usr/bin/env bash
2+
if [ "$1" = "6" ]; then
3+
echo "NodeJS v6 is no longer supported, build skipped.";
4+
exit;
5+
fi;
26

37
# Set up NVM
48
export NVM_DIR="/home/dotnet-bot/.nvm"
59
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh"
610

11+
712
nvm install $1
813

914
npm uninstall typescript --no-save

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
"@types/xml2js": "^0.4.0",
5454
"@typescript/vfs-path": "file:scripts/vfs-path",
5555
"@typescript/vfs": "file:scripts/vfs",
56+
"@typescript/harness-core": "file:scripts/harness-core",
5657
"browser-resolve": "^1.11.2",
5758
"browserify": "latest",
5859
"chai": "latest",

scripts/harness-core/gulpfile.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
const gulp = require("gulp");
2+
const sourcemaps = require("gulp-sourcemaps");
3+
const tsb = require("gulp-tsb");
4+
const del = require("del");
5+
6+
const project = tsb.create("tsconfig.json")
7+
8+
gulp.task("clean", () => del(["dist/**/*"]));
9+
10+
gulp.task("build", () => gulp.src(["src/**/*.ts"])
11+
.pipe(sourcemaps.init())
12+
.pipe(project())
13+
.pipe(sourcemaps.write(".", { sourceRoot: "../src", includeContent: false, destPath: "dist" }))
14+
.pipe(gulp.dest("dist")));
15+
16+
gulp.task("watch", () => gulp.watch(["src/**/*", "tsconfig.json"], ["build"]));
17+
18+
gulp.task("default", ["build"]);

scripts/harness-core/package.json

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"private": true,
3+
"name": "@typescript/harness-core",
4+
"version": "0.0.0",
5+
"description": "TypeScript test harness core",
6+
"main": "dist/index.js",
7+
"types": "dist/index.d.ts",
8+
"author": "Ron Buckton (ron.buckton@microsoft.com)",
9+
"license": "Apache-2.0",
10+
"dependencies": {
11+
"@typescript/vfs-core": "file:../vfs-core"
12+
},
13+
"devDependencies": {
14+
"@types/node": "^8.0.20",
15+
"@types/source-map-support": "^0.4.0",
16+
"del": "^2.0.2",
17+
"gulp": "^3.9.1",
18+
"gulp-sourcemaps": "^2.6.1",
19+
"gulp-tsb": "^2.0.5",
20+
"source-map-support": "^0.5.0",
21+
"typescript": "^2.6.1"
22+
}
23+
}

scripts/harness-core/src/crypto.ts

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
const H = new Uint32Array(5);
2+
const W = new Uint8Array(80);
3+
const B = new Uint8Array(64);
4+
const BLOCK_SIZE = 64;
5+
6+
export function sha1(message: string): string {
7+
let buffer = B;
8+
const textSize = message.length;
9+
const messageSize = textSize * 2;
10+
const finalBlockSize = messageSize % BLOCK_SIZE;
11+
const padSize = (finalBlockSize < BLOCK_SIZE - 8 - 1 ? BLOCK_SIZE : BLOCK_SIZE * 2) - finalBlockSize;
12+
const byteLength = messageSize + padSize;
13+
if (byteLength > BLOCK_SIZE) {
14+
buffer = new Uint8Array(byteLength);
15+
}
16+
17+
const bufferView = new DataView(buffer.buffer);
18+
for (let i = 0; i < textSize; ++i) {
19+
bufferView.setUint16(i * 2, message.charCodeAt(i));
20+
}
21+
22+
buffer[messageSize] = 0x80;
23+
bufferView.setUint32(byteLength - 4, messageSize * 8);
24+
H[0] = 0x67452301, H[1] = 0xefcdab89, H[2] = 0x98badcfe, H[3] = 0x10325476, H[4] = 0xc3d2e1f0;
25+
for (let offset = 0; offset < byteLength; offset += BLOCK_SIZE) {
26+
let a = H[0], b = H[1], c = H[2], d = H[3], e = H[4];
27+
for (let i = 0; i < 80; ++i) {
28+
if (i < 16) {
29+
const x = offset + i * 4;
30+
W[i] = buffer[x] << 24 | buffer[x + 1] << 16 | buffer[x + 2] << 8 | buffer[x + 3];
31+
}
32+
else {
33+
const x = W[i - 3] ^ W[i - 8] ^ W[i - 14] ^ W[i - 16];
34+
W[i] = (x << 1 | x >>> 31) >>> 0;
35+
}
36+
37+
let t = (a << 5 | a >>> 27) >>> 0 + e + W[i];
38+
if (i < 20) {
39+
t += ((b & c) | (~b & d)) + 0x5A827999;
40+
}
41+
else if (i < 40) {
42+
t += (b ^ c ^ d) + 0x6ED9EBA1;
43+
}
44+
else if (i < 60) {
45+
t += ((b & c) | (b & d) | (c & d)) + 0x8F1BBCDC;
46+
}
47+
else {
48+
t += (b ^ c ^ d) + 0xCA62C1D6;
49+
}
50+
51+
e = d, d = c, c = (b << 30 | b >>> 2) >>> 0, b = a, a = t;
52+
}
53+
54+
H[0] += a, H[1] += b, H[2] += c, H[3] += d, H[4] += e;
55+
}
56+
57+
for (let i = 0; i < 5; ++i) {
58+
bufferView.setUint32(i * 4, H[i]);
59+
}
60+
61+
let result = "";
62+
for (let i = 0; i < 20; ++i) {
63+
result += (buffer[i] < 16 ? "0" : "") + buffer[i].toString(16);
64+
}
65+
66+
return result;
67+
}

scripts/harness-core/src/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export * from "@typescript/vfs-core";
2+
export * from "./strings";
3+
export * from "./crypto";

0 commit comments

Comments
 (0)