Skip to content

Commit

Permalink
Port the build system to Gulp
Browse files Browse the repository at this point in the history
  • Loading branch information
cedx committed Mar 29, 2024
1 parent 46b9518 commit 0fdb477
Show file tree
Hide file tree
Showing 9 changed files with 1,744 additions and 67 deletions.
3 changes: 2 additions & 1 deletion etc/eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -198,8 +198,9 @@ export default tsEslint.config(
}
},
{
files: ["test/**/*.js"],
files: ["gulpfile.js", "etc/*.js", "test/**/*.js"],
rules: {
"prefer-arrow-callback": "off",
"@typescript-eslint/explicit-function-return-type": "off",
"@typescript-eslint/explicit-module-boundary-types": "off",
"@typescript-eslint/no-floating-promises": "off"
Expand Down
57 changes: 57 additions & 0 deletions gulpfile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import {cp} from "node:fs/promises";
import {deleteAsync} from "del";
import {$} from "execa";
import gulp from "gulp";
import replace from "gulp-replace";
import pkg from "./package.json" with {type: "json"};

// Builds the project.
export async function build() {
return $`tsc --project src`;
}

// Deletes all generated files.
export function clean() {
return deleteAsync(["lib", "var/**/*"]);
}

// Builds the documentation.
export async function doc() {
await build();
await $`typedoc --options etc/typedoc.js`;
for (const file of ["CHANGELOG.md", "LICENSE.md"]) await cp(file, `docs/${file.toLowerCase()}`);
return cp("docs/favicon.ico", "docs/api/favicon.ico");
}

// Performs the static analysis of source code.
export async function lint() {
await build();
await $`tsc --project .`;
return $`eslint --config=etc/eslint.config.js gulpfile.js etc example src test`;
}

// Publishes the package.
export async function publish() {
for (const registry of ["https://registry.npmjs.org", "https://npm.pkg.github.com"]) await $`npm publish --registry=${registry}`;
for (const action of [["tag"], ["push", "origin"]]) await $`git ${action} v${pkg.version}`;
}

// Runs the test suite.
export async function test() {
await build();
return $`node --test --test-reporter=spec`;
}

// Updates the version number in the sources.
export function version() {
return gulp.src("src/client.ts")
.pipe(replace(/#version = "\d+(\.\d+){2}"/, `#version = "${pkg.version}"`))
.pipe(gulp.dest("src"));
}

// The default task.
export default gulp.series(
clean,
version,
build
);
Loading

0 comments on commit 0fdb477

Please sign in to comment.