Compare commits
3 Commits
hydrators-
...
f352ae44e1
| Author | SHA1 | Date | |
|---|---|---|---|
| f352ae44e1 | |||
| 341db4f821 | |||
| eabec3816b |
66
backend/check-deps.ts
Normal file
66
backend/check-deps.ts
Normal file
@@ -0,0 +1,66 @@
|
|||||||
|
import { readFileSync } from "node:fs";
|
||||||
|
import { dirname, join } from "node:path";
|
||||||
|
import { fileURLToPath } from "node:url";
|
||||||
|
|
||||||
|
const __dirname = dirname(fileURLToPath(import.meta.url));
|
||||||
|
|
||||||
|
interface PackageJson {
|
||||||
|
dependencies?: Record<string, string>;
|
||||||
|
devDependencies?: Record<string, string>;
|
||||||
|
}
|
||||||
|
|
||||||
|
function readPackageJson(path: string): PackageJson {
|
||||||
|
const content = readFileSync(path, "utf-8");
|
||||||
|
return JSON.parse(content);
|
||||||
|
}
|
||||||
|
|
||||||
|
function getAllDependencyNames(pkg: PackageJson): Set<string> {
|
||||||
|
const names = new Set<string>();
|
||||||
|
for (const name of Object.keys(pkg.dependencies ?? {})) {
|
||||||
|
names.add(name);
|
||||||
|
}
|
||||||
|
for (const name of Object.keys(pkg.devDependencies ?? {})) {
|
||||||
|
names.add(name);
|
||||||
|
}
|
||||||
|
return names;
|
||||||
|
}
|
||||||
|
|
||||||
|
const diachronPkgPath = join(__dirname, "diachron", "package.json");
|
||||||
|
const backendPkgPath = join(__dirname, "package.json");
|
||||||
|
|
||||||
|
const diachronPkg = readPackageJson(diachronPkgPath);
|
||||||
|
const backendPkg = readPackageJson(backendPkgPath);
|
||||||
|
|
||||||
|
const diachronDeps = getAllDependencyNames(diachronPkg);
|
||||||
|
const backendDeps = getAllDependencyNames(backendPkg);
|
||||||
|
|
||||||
|
const duplicates: string[] = [];
|
||||||
|
|
||||||
|
for (const dep of diachronDeps) {
|
||||||
|
if (backendDeps.has(dep)) {
|
||||||
|
duplicates.push(dep);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (duplicates.length > 0) {
|
||||||
|
console.error("Error: Duplicate dependencies found.");
|
||||||
|
console.error("");
|
||||||
|
console.error(
|
||||||
|
"The following dependencies exist in both backend/package.json and backend/diachron/package.json:",
|
||||||
|
);
|
||||||
|
console.error("");
|
||||||
|
for (const dep of duplicates.sort()) {
|
||||||
|
console.error(` - ${dep}`);
|
||||||
|
}
|
||||||
|
console.error("");
|
||||||
|
console.error(
|
||||||
|
"Dependencies in backend/diachron/package.json are provided by the framework",
|
||||||
|
);
|
||||||
|
console.error(
|
||||||
|
"and must not be duplicated in backend/package.json. Remove them from",
|
||||||
|
);
|
||||||
|
console.error("backend/package.json to fix this error.");
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log("No duplicate dependencies found.");
|
||||||
@@ -11,4 +11,5 @@ out_dir="$check_dir/out"
|
|||||||
source "$check_dir"/../diachron/shims/common
|
source "$check_dir"/../diachron/shims/common
|
||||||
source "$check_dir"/../diachron/shims/node.common
|
source "$check_dir"/../diachron/shims/node.common
|
||||||
|
|
||||||
|
$ROOT/cmd tsx "$check_dir/check-deps.ts"
|
||||||
$ROOT/cmd pnpm tsc --outDir "$out_dir"
|
$ROOT/cmd pnpm tsc --outDir "$out_dir"
|
||||||
|
|||||||
@@ -10,5 +10,5 @@
|
|||||||
"types": ["node"],
|
"types": ["node"],
|
||||||
"outDir": "out"
|
"outDir": "out"
|
||||||
},
|
},
|
||||||
"exclude": ["**/*.spec.ts", "**/*.test.ts"]
|
"exclude": ["**/*.spec.ts", "**/*.test.ts", "check-deps.ts"]
|
||||||
}
|
}
|
||||||
|
|||||||
11
diachron/common.d/check-deps
Executable file
11
diachron/common.d/check-deps
Executable file
@@ -0,0 +1,11 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -eu
|
||||||
|
|
||||||
|
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||||
|
|
||||||
|
ROOT="$DIR/../.."
|
||||||
|
|
||||||
|
cd "$ROOT/backend"
|
||||||
|
|
||||||
|
"$ROOT/cmd" tsx check-deps.ts "$@"
|
||||||
1
diachron/develop.d/check-deps
Symbolic link
1
diachron/develop.d/check-deps
Symbolic link
@@ -0,0 +1 @@
|
|||||||
|
../common.d/check-deps
|
||||||
1
diachron/mgmt.d/check-deps
Symbolic link
1
diachron/mgmt.d/check-deps
Symbolic link
@@ -0,0 +1 @@
|
|||||||
|
../common.d/check-deps
|
||||||
38
upgrade.sh
Normal file
38
upgrade.sh
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
# shellcheck disable=SC2002
|
||||||
|
|
||||||
|
set -eu
|
||||||
|
set -o pipefail
|
||||||
|
IFS=$'\n\t'
|
||||||
|
|
||||||
|
# print useful message on failure
|
||||||
|
trap 's=$?; echo >&2 "$0: Error on line "$LINENO": $BASH_COMMAND"; exit $s' ERR
|
||||||
|
|
||||||
|
# shellcheck disable=SC2034
|
||||||
|
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||||
|
|
||||||
|
cd "$DIR"
|
||||||
|
|
||||||
|
# - Check if the file .diachron-version exists; save its value in a variable
|
||||||
|
# named old_diachron_version
|
||||||
|
|
||||||
|
# - Check if the repository is dirty; if there are any files that git knows
|
||||||
|
# about that have been changed but not committed, abort with a message
|
||||||
|
|
||||||
|
# - Get the current commit and store it in a variable
|
||||||
|
|
||||||
|
# - Perform a two checkouts of
|
||||||
|
# https://gitea.philologue.net/philologue/diachron, each in its own
|
||||||
|
# temporary directory. We'll call one "old" and one "new"
|
||||||
|
|
||||||
|
# - In old, check out $old_diachron_version; in our working application
|
||||||
|
# directory, delete all of the files in file-list using git rm
|
||||||
|
|
||||||
|
# - In new, check out whatever was passed as argv[1]
|
||||||
|
|
||||||
|
# - Copy all of the files in file-list to the working application and stage
|
||||||
|
# them with git add
|
||||||
|
|
||||||
|
# - Commit
|
||||||
|
|
||||||
|
# - Should we run sync.sh or should we advise the user to run sync.sh?
|
||||||
Reference in New Issue
Block a user