Add Gulpfile.ts#9068
Conversation
|
@rbuckton can you take a look too? I think you know the most about gulp around here. |
|
I almost always C-c tests when they pass and start linting. And when I realise I'm building the wrong thing, etc. The rename trick probably isn't going to work. :( |
| var LKGDirectory = "lib/"; | ||
|
|
||
| var copyright = "CopyrightNotice.txt"; | ||
| var thirdParty = "ThirdPartyNoticeText.txt"; |
There was a problem hiding this comment.
I don't see this (yet) in the gulpfile.
There was a problem hiding this comment.
It was unused. I'll double check if its actually used in the Jakefile and that I forgot something.
There was a problem hiding this comment.
I double checked now that I am not on the bus. It's unused.
|
talk with @sandersn instead of deleting the JakeFile completely, may be we should keep the JakeFile for now and travis-CI to use Jake. In the team, we will start using gulp internally for a week or so before switch. Also @sandersn suggests that we should do this on Mon/Tue. instead of Friday. if we decide to merge so things won't break on weekend 😸 |
|
Have you considered using the |
|
@yuit Considering its build is still broken (workin' on it), I have no illusions about this is getting merged this weekend, lol. As for keeping around the Jakefile for awhile... 🤷. I guess we could. @rbuckton Yes! This is a thing I want to do! The only reason I didn't was because I wanted to start to replicating our Jakefile's functionality as closely as possible. (Maybe we wanted to keep on using our command-line interface? I dunno) |
|
@sandersn I should have a fix incoming for the terribad workaround - passing an empty array to the |
| }); | ||
| }); | ||
|
|
||
| gulp.task("generate-code-coverage", "Generates code coverage data via instanbul", ["tests"], (done) => { |
|
I vote that you undo the removal of the Jakefile and make sure Travis still works with jake, then merge this. We can test it over the next week or so and then switch Travis. |
|
@sandersn @rbuckton @yuit Updated! Kept the Jakefile for a transition period, as requested (and the package.json pointing at jake), and rewrote all the compilation tasks in the gulpfile to use |
|
|
||
| function exec(cmd: string, args: string[], complete: () => void = (() => {}), error: (e: any, status: number) => void = (() => {})) { | ||
| console.log(`${cmd} ${args.join(" ")}`); | ||
| const ex = cp.spawn(cmd, args); |
There was a problem hiding this comment.
consider:
const ex = cp.spawn(cmd, args, { stdio: "inherit" });Then you can drop the ex.stdout.pipe(process.stdout); and ex.stderr.pipe(process.stderr); lines.
There was a problem hiding this comment.
Also if you do:
const ex = cp.spawn(isWin ? "cmd" : "/bin/sh", [isWin ? "/c" : "-c", cmd, ...args], { stdio: "inherit", windowsVerbatimArguments: true });It will use the OS shell to launch the command, letting spawn leverage the PATH environment variable and automatically handle executables without appending .cmd, etc.
|
@rbuckton Updated to handle your comments and, now that |
|
Sourcemaps should now work in every context (browser, vscode); without using inline sources. |
| js.pipe(sourcemaps.write(".")) | ||
|
|
||
| return merge2([ | ||
| js.pipe(gIf(useDebugMode, insert.prepend(fs.readFileSync(copyright)))) |
There was a problem hiding this comment.
Can we make this less eager using lazypipe?
| .pipe(sourcemaps.init()) | ||
| .pipe(tsc(localCompilerProject)) | ||
| .pipe(gIf(useDebugMode, insert.prepend(fs.readFileSync(copyright)))) | ||
| .pipe(gIf(useDebugMode, prependCopyright())) |
There was a problem hiding this comment.
I played around with this and this still ends up eagerly calling fs.readFileSync.
Another option that does not use gulp-if/lazypipe would be:
import { PassThrough } from "stream";
...
return localCompilerProject.src()
.pipe(newer(builtLocalCompiler))
.pipe(sourcemaps.init())
.pipe(tsc(localCompilerProject))
.pipe(useDebugMode ? insert.prepend(fs.readFileSync(copyright)) : pass())
.pipe(sourcemaps.write("."))
.pipe(gulp.dest(builtLocalDirectory));
...
function pass() {
return new PassThrough({ objectMode: true });
}There was a problem hiding this comment.
Or why not just insert.prepend(useDebugMode ? fs.readFileSync(copyright) : ""), any avoid both of those dependencies?
| }); | ||
|
|
||
| const scriptsTsdJson = path.join(scriptsDirectory, "tsd.json"); | ||
| gulp.task("tsd-scripts", `Runs \`tsd --config ${scriptsTsdJson}\` install`, [], (done) => { |
| const nodeServerInFile = "tests/webTestServer.ts"; | ||
| gulp.task(nodeServerOutFile, false, [servicesFile], () => { | ||
| const settings: tsc.Settings = getCompilerSettings({}, /*useBuiltCompiler*/ true); | ||
| const settings: tsc.Settings = getCompilerSettings({module: "commonjs"}, /*useBuiltCompiler*/ true); |
There was a problem hiding this comment.
I'm not sure what whitespace you're complaining about, but whatever it is I guess it should be codified because our lint rules don't catch it.
There was a problem hiding this comment.
probably { module: "commonjs" } -- spaces after { and before}
There was a problem hiding this comment.
Yeah - this style is inconsistently enforced, I have instances both with and without spaces in the compiler. We need a lint rule for this, one way or the other, if people are going to display a preference.
There was a problem hiding this comment.
Additionally, is this supposed to be consistent with binding patterns and/or template strings? I'm internally consistent in the Gulpefile (no leading/trailing whitespace for any), but again, we're inconsistent within the compiler.
There was a problem hiding this comment.
I can't find it, so probably we should just have a discussion and vote on which linter rule we want to turn on. (Does TSLint have it? ESLint does -- object curly spacing)
There was a problem hiding this comment.
I don't see any tslint rules white would cover whitespace before/after curlys.
There was a problem hiding this comment.
I've written a rule to check which is the dominant style - by and large with whitespace is more prevalent in our codebase, so I assume the default should be with whitespace.
There was a problem hiding this comment.
I'm going to merge this without fixing these nits and the fix them when I merge the lint rule catching them, is that okay?
Last fall I always said I'd probably get around to doing this at some point.
I was frustrated earlier today by our Jake-based build, and I had always talked about how it'd be easier to work with as another task runner. So this evening I did just what I always said I would - I ported our Jakefile to a Gulpfile. Added bonus: It's now written in typescript! And there's a
gulp helpcommand!Gulp is orders of magnitude more popular than Jake nowadays, and sees much more active use - external contributors are more likely to have existing experiences with gulp. We can also continue moving parts of the build to in-memory streams for a bit more efficiency once this is done.
@DanielRosenwasser @sandersn @yuit You guys should definitely take a look.