0
Fork 0
mirror of https://github.com/logto-io/logto.git synced 2025-01-06 20:40:08 -05:00

chore: add exception for connector template

This commit is contained in:
Gao Sun 2024-03-19 15:19:41 +08:00
parent 57d97a4df8
commit 5d692e30a9
No known key found for this signature in database
GPG key ID: 13EBE123E4773688
2 changed files with 23 additions and 1 deletions

View file

@ -25,6 +25,7 @@
"dev": "tsc -p tsconfig.build.json --watch --preserveWatchOutput --incremental",
"lint": "eslint --ext .ts src",
"lint:report": "pnpm lint --format json --output-file report.json",
"test:only": "NODE_OPTIONS=--experimental-vm-modules jest",
"test": "vitest src",
"test:ci": "pnpm run test --silent --coverage",
"prepublishOnly": "pnpm build"

View file

@ -15,6 +15,13 @@ const templateJson = Object.fromEntries(
);
const templateKeys = Object.keys(templateJson);
/**
* An object that contains exceptions for scripts that are allowed to be different from the template.
*
* This is useful when we transiting from Jest to Vitest, as they have different scripts.
*/
const scriptExceptions = { 'connector-azuread': ['test', 'test:ci'] };
const sync = async () => {
const packagesDirectory = './';
const packages = await fs.readdir(packagesDirectory);
@ -42,9 +49,23 @@ const sync = async () => {
);
}
const scriptOverrides = scriptExceptions[packageName]
? Object.fromEntries(
scriptExceptions[packageName].map((key) => [key, current.scripts[key]])
)
: {};
await fs.writeFile(
packageJsonPath,
JSON.stringify({ ...current, ...templateJson }, undefined, 2) + '\n'
JSON.stringify(
{
...current,
...templateJson,
scripts: { ...templateJson.scripts, ...scriptOverrides },
},
undefined,
2
) + '\n'
);
// Copy preset