diff --git a/scripts/hak/README.md b/scripts/hak/README.md index a5681d8b..bf254451 100644 --- a/scripts/hak/README.md +++ b/scripts/hak/README.md @@ -67,14 +67,14 @@ Hak is divided into lifecycle stages, in order: # hak.json -The scripts section contains scripts used for lifecycle stages that need them (fetch, fetchDeps, build). +The scripts section contains scripts used for lifecycle stages that need them (fetch, build). It also contains 'prune' and 'copy' which are globs of files to delete from the output module directory and copy over from the module build directory to the output module directory, respectively. # Shortcomings Hak doesn't know about dependencies between lifecycle stages, ie. it doesn't know that you need to -'fetch' and 'fetchDeps' before you can 'build', etc. You get to run each individually, and remember +'fetch' before you can 'build', etc. You get to run each individually, and remember the right order. There is also a _lot_ of duplication in the command execution: we should abstract away diff --git a/scripts/hak/check.ts b/scripts/hak/check.ts index 2936091a..2a7ce6e4 100644 --- a/scripts/hak/check.ts +++ b/scripts/hak/check.ts @@ -10,7 +10,5 @@ import type { DependencyInfo } from "./dep.js"; import type HakEnv from "./hakEnv.js"; export default async function check(hakEnv: HakEnv, moduleInfo: DependencyInfo): Promise { - if (moduleInfo.scripts.check) { - await moduleInfo.scripts.check(hakEnv, moduleInfo); - } + await moduleInfo.scripts.check?.(hakEnv, moduleInfo); } diff --git a/scripts/hak/copy.ts b/scripts/hak/copy.ts index 6fda80f9..607792e6 100644 --- a/scripts/hak/copy.ts +++ b/scripts/hak/copy.ts @@ -9,7 +9,6 @@ Please see LICENSE files in the repository root for full details. import path from "node:path"; import fsProm from "node:fs/promises"; import childProcess from "node:child_process"; -import { rimraf } from "rimraf"; import { glob } from "glob"; import { mkdirp } from "mkdirp"; @@ -17,20 +16,6 @@ import type HakEnv from "./hakEnv.js"; import type { DependencyInfo } from "./dep.js"; export default async function copy(hakEnv: HakEnv, moduleInfo: DependencyInfo): Promise { - if (moduleInfo.cfg.prune) { - console.log("Removing " + moduleInfo.cfg.prune + " from " + moduleInfo.moduleOutDir); - // rimraf doesn't have a 'cwd' option: it always uses process.cwd() - // (and if you set glob.cwd it just breaks because it can't find the files) - const oldCwd = process.cwd(); - try { - await mkdirp(moduleInfo.moduleOutDir); - process.chdir(moduleInfo.moduleOutDir); - await rimraf(moduleInfo.cfg.prune); - } finally { - process.chdir(oldCwd); - } - } - if (moduleInfo.cfg.copy) { // If there are multiple moduleBuildDirs, singular moduleBuildDir // is the same as moduleBuildDirs[0], so we're just listing the contents diff --git a/scripts/hak/fetchDeps.ts b/scripts/hak/fetchDeps.ts deleted file mode 100644 index 22dbfd5c..00000000 --- a/scripts/hak/fetchDeps.ts +++ /dev/null @@ -1,19 +0,0 @@ -/* -Copyright 2024 New Vector Ltd. -Copyright 2020 The Matrix.org Foundation C.I.C. - -SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only OR LicenseRef-Element-Commercial -Please see LICENSE files in the repository root for full details. -*/ - -import { mkdirp } from "mkdirp"; - -import type { DependencyInfo } from "./dep.js"; -import type HakEnv from "./hakEnv.js"; - -export default async function fetchDeps(hakEnv: HakEnv, moduleInfo: DependencyInfo): Promise { - await mkdirp(moduleInfo.moduleDotHakDir); - if (moduleInfo.scripts.fetchDeps) { - await moduleInfo.scripts.fetchDeps(hakEnv, moduleInfo); - } -} diff --git a/scripts/hak/index.ts b/scripts/hak/index.ts index 22d35731..b78d6474 100644 --- a/scripts/hak/index.ts +++ b/scripts/hak/index.ts @@ -19,7 +19,7 @@ import packageJson from "../../package.json"; const MODULECOMMANDS = ["check", "fetch", "link", "build", "copy", "clean"]; // Shortcuts for multiple commands at once (useful for building universal binaries -// because you can run the fetch/fetchDeps/build for each arch and then copy/link once) +// because you can run the fetch/build for each arch and then copy/link once) const METACOMMANDS: Record = { fetchandbuild: ["check", "fetch", "build"], copyandlink: ["copy", "link"],