Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 46 additions & 29 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,33 +1,50 @@
{
"extends": [
"@kontent-ai"
],

"overrides": [
{
"files": ["src/**/*.ts"],
"excludedFiles": ["src/log.ts"],
"rules": {
"no-restricted-syntax": [
"error",
{
"selector": "MemberExpression[object.name='console'][property.name=/^(log|warn|error|info|trace)$/]",
"message": "Don't log into the console directly. Use one of the functions from the log.ts file (logInfo, logWarning, logError) to ensure provided --logLevel is respected."
},
{
"selector": "CallExpression[callee.name='createManagementClient']",
"message": "Use the createClient function from src/utils/client.ts instead."
},
{
"selector": "NewExpression[callee.name='ManagementClient']",
"message": "Use the createClient function from src/utils/client.ts instead."
}
]
}
}
],

"parser": "@typescript-eslint/parser",
"parserOptions": {
"project": ["tsconfig.json", "tsconfig.tests.jsonc", "tsconfig.configs.jsonc"]
"project": ["./tsconfig.json", "./tsconfig.tests.jsonc"],
"ecmaFeatures": {
"jsx": true
},
"sourceType": "module"
},
"settings": {
"react": {
"version": "detect"
}
},
"plugins": ["@typescript-eslint"],
"extends": ["eslint:recommended", "plugin:@typescript-eslint/eslint-recommended"],
"rules": {
"no-loop-func": "off",
"no-unused-vars": "off",
"@typescript-eslint/no-unused-vars": "error",
"@typescript-eslint/no-loop-func": "error",
"@typescript-eslint/no-redundant-type-constituents": "error",
"@typescript-eslint/no-unnecessary-boolean-literal-compare": "error",
"@typescript-eslint/no-unnecessary-qualifier": "error",
"@typescript-eslint/no-unnecessary-condition": "error",
"@typescript-eslint/prefer-includes": "error",
"@typescript-eslint/prefer-return-this-type": "error",
"@typescript-eslint/prefer-string-starts-ends-with": "error",
"@typescript-eslint/prefer-for-of": "error",
"@typescript-eslint/prefer-function-type": "error",
"@typescript-eslint/prefer-optional-chain": "error",
"@typescript-eslint/prefer-reduce-type-parameter": "error",
"@typescript-eslint/prefer-ts-expect-error": "error",
"no-restricted-syntax": [
"error",
{
"selector": "MemberExpression[object.name='console'][property.name=/^(log|warn|error|info|trace)$/]",
"message": "Don't log into the console directly. Use one of the functions from the log.ts file (logInfo, logWarning, logError) to ensure provided --logLevel is respected."
},
{
"selector": "CallExpression[callee.name='createManagementClient']",
"message": "Use the createClient function from src/utils/client.ts instead."
},
{
"selector": "NewExpression[callee.name='ManagementClient']",
"message": "Use the createClient function from src/utils/client.ts instead."
}
]
}
}
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ jobs:
with:
node-version-file: ".nvmrc"
- run: npm ci
- run: npm run fmt:check
- run: npm run lint
- run: npm run biome:ci
- run: npm run eslint
- run: npm run build
4 changes: 4 additions & 0 deletions biome.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"$schema": "./node_modules/@biomejs/biome/configuration_schema.json",
"extends": ["@kontent-ai/biome-config/base"]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JiriLojda I would also add schema link for intellisense within the config:

"$schema": "./node_modules/@biomejs/biome/configuration_schema.json",

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, I'll add it

}
13 changes: 0 additions & 13 deletions dprint.json

This file was deleted.

51 changes: 40 additions & 11 deletions exportTestEnvironments.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,23 @@
import dotenv from 'dotenv';
import * as childProcess from "child_process";
import minimist from 'minimist';
import * as childProcess from "node:child_process";
import dotenv from "dotenv";
import minimist from "minimist";

dotenv.config();

const resolveParams = (params) => {
const { i, s, t } = params;

return !i && !s && !t ? { i: true, s: true, t: true } : { i, s, t };
}
return !(i || s || t) ? { i: true, s: true, t: true } : { i, s, t };
};

const { i, s, t } = resolveParams(minimist(process.argv.slice(2)));

const { API_KEY, SYNC_SOURCE_TEST_ENVIRONMENT_ID, SYNC_TARGET_TEST_ENVIRONMENT_ID, EXPORT_IMPORT_TEST_DATA_ENVIRONMENT_ID } = process.env;
const {
API_KEY,
SYNC_SOURCE_TEST_ENVIRONMENT_ID,
SYNC_TARGET_TEST_ENVIRONMENT_ID,
EXPORT_IMPORT_TEST_DATA_ENVIRONMENT_ID,
} = process.env;

if (!EXPORT_IMPORT_TEST_DATA_ENVIRONMENT_ID) {
throw new Error("EXPORT_IMPORT_TEST_DATA_ENVIRONMENT_ID environment variable is not defined.");
Expand Down Expand Up @@ -45,16 +50,40 @@ const runCommand = (command, props) => {
};
const syncSourcePath = "tests/integration/sync/data/sync_test_source.zip";
const syncTargetPath = "tests/integration/sync/data/sync_test_target.zip";
const restorePath = "tests/integration/backupRestore/data/backup.zip"
const restorePath = "tests/integration/backupRestore/data/backup.zip";

const syncSourceBackupCommand = `environment backup -e=${SYNC_SOURCE_TEST_ENVIRONMENT_ID} -f=${syncSourcePath} -k=${API_KEY}`;
const syncTargetBackupCommand = `environment backup -e=${SYNC_TARGET_TEST_ENVIRONMENT_ID} -f=${syncTargetPath} -k=${API_KEY}`;
const restoreBackupCommand = `environment backup -e=${EXPORT_IMPORT_TEST_DATA_ENVIRONMENT_ID} -f=${restorePath} -k=${API_KEY}`;

const exportCommands = [
...s ? [runCommand(syncSourceBackupCommand, { title: "Sync Source Template test environment", environmentId: SYNC_SOURCE_TEST_ENVIRONMENT_ID, path: syncSourcePath })] : [],
...t ? [runCommand(syncTargetBackupCommand, { title: "Sync Target Template test environment", environmentId: SYNC_TARGET_TEST_ENVIRONMENT_ID, path: syncTargetPath })] : [],
...i ? [runCommand(restoreBackupCommand, { title: "Restore Backup test environment", environmentId: EXPORT_IMPORT_TEST_DATA_ENVIRONMENT_ID, path: restorePath })] : []
]
...(s
? [
runCommand(syncSourceBackupCommand, {
title: "Sync Source Template test environment",
environmentId: SYNC_SOURCE_TEST_ENVIRONMENT_ID,
path: syncSourcePath,
}),
]
: []),
...(t
? [
runCommand(syncTargetBackupCommand, {
title: "Sync Target Template test environment",
environmentId: SYNC_TARGET_TEST_ENVIRONMENT_ID,
path: syncTargetPath,
}),
]
: []),
...(i
? [
runCommand(restoreBackupCommand, {
title: "Restore Backup test environment",
environmentId: EXPORT_IMPORT_TEST_DATA_ENVIRONMENT_ID,
path: restorePath,
}),
]
: []),
];

await Promise.all(exportCommands);
Loading