Skip to content

Commit

Permalink
Restore the Gulp build system
Browse files Browse the repository at this point in the history
  • Loading branch information
cedx committed Nov 13, 2024
1 parent b3ceef8 commit 5b85405
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 54 deletions.
1 change: 0 additions & 1 deletion Cakefile

This file was deleted.

2 changes: 1 addition & 1 deletion etc/rollup.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export default {
file: "bin/setup_hashlink.js"
},
plugins: [
resolve(),
resolve({preferBuiltins: true}),
commonjs({sourceMap: false}),
terser({compress: true, format: {comments: false}, mangle: true})
]
Expand Down
59 changes: 59 additions & 0 deletions gulpfile.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
import gulp from "gulp"
import {spawn} from "node:child_process"
import {readdir, readFile, rm, writeFile} from "node:fs/promises"
import {join} from "node:path"
import {env} from "node:process"

# Builds the project.
export build = ->
await npx "coffee", "--compile", "--no-header", "--output", "lib", "src"

# Deletes all generated files.
export clean = ->
await rm join("lib", file) for file from await readdir "lib" when not file.endsWith ".d.ts"
await rm join("var", file), recursive: yes for file from await readdir "var" when file isnt ".gitkeep"

# Packages the project.
export dist = ->
env.NODE_ENV = "production"
await build()
await npx "rollup", "--config=etc/rollup.js"
await run "git", "update-index", "--chmod=+x", "bin/setup_hashlink.js"

# Performs the static analysis of source code.
export lint = ->
await npx "coffeelint", "--file=etc/coffeelint.json", "gulpfile.coffee", "src", "test"

# Publishes the package.
export publish = ->
{default: {version}} = await import("./package.json", with: {type: "json"})
await run "gulp"
await run "npm", "publish", "--registry=#{registry}" for registry from ["https://registry.npmjs.org", "https://npm.pkg.github.com"]
await run "git", action..., "v#{version}" for action from [["tag"], ["push", "origin"]]

# Runs the test suite.
export test = ->
env.NODE_ENV = "test"
await npx "coffee", "--compile", "--map", "--no-header", "--output", "lib", "src", "test"
await run "node", "--enable-source-maps", "--test", "--test-reporter=spec", "lib/**/*_test.js"

# Updates the version number in the sources.
export version = ->
file = "README.md"
{default: {version}} = await import("./package.json", with: {type: "json"})
await writeFile file, (await readFile file, "utf8").replace /action\/v\d+(\.\d+){2}/, "action/v#{version}"

# Watches for file changes.
export watch = ->
await npx "coffee", "--compile", "--no-header", "--output", "lib", "--watch", "src", "test"

# The default task.
export default gulp.series clean, dist, version

# Executes a command from a local package.
npx = (command, args...) -> run "npm", "exec", "--", command, ...args

# Spawns a new process using the specified command.
run = (command, args...) -> new Promise (resolve, reject) ->
spawn command, args, shell: on, stdio: "inherit"
.on "close", (code) -> if code then reject(Error [command, args...].join(" ")) else resolve()
52 changes: 0 additions & 52 deletions src/cakefile.coffee

This file was deleted.

0 comments on commit 5b85405

Please sign in to comment.