Skip to content

Commit

Permalink
refactor!: Major rewrite, switching to ECMAScript instead of CJS.
Browse files Browse the repository at this point in the history
Implements #942
  • Loading branch information
Göran Sander committed Jan 28, 2024
1 parent 3f42d02 commit 25f0ab2
Show file tree
Hide file tree
Showing 84 changed files with 971 additions and 1,400 deletions.
17 changes: 14 additions & 3 deletions .eslintrc.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,28 @@
env:
es6: true
es2021: true
# es6: true
es2023: true
node: true
# commonjs: false
extends:
- airbnb-base
# - eslint:recommended
- prettier
parserOptions:
ecmaVersion: 12
ecmaVersion: 2023
sourceType: module
requireConfigFile: false
babelOptions:
plugins:
- '@babel/plugin-syntax-import-assertions'
parser: '@babel/eslint-parser'
rules:
prettier/prettier: error
import/no-unresolved: 2
import/no-commonjs: 2
import/extensions: [2, "ignorePackages"]
plugins:
- prettier
- import
globals:
beforeAll: readonly
afterAll: readonly
Expand Down
823 changes: 262 additions & 561 deletions package-lock.json

Large diffs are not rendered by default.

17 changes: 13 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,19 @@
"version": "9.4.0",
"description": "Superpowers for Qlik Sense. Task scheduling, key-value store, advanced alerting and more.",
"scripts": {
"test": "jest",
"test": "node --experimental-vm-modules node_modules/jest/bin/jest.js",
"test2": "node_modules/jshint/bin/jshint butler.js",
"format1": "npm run format",
"format": "npm run format:prettier",
"format:prettier": "npx prettier --config .prettierrc \"./**/*.{ts,css,less,js}\" --write",
"butler": "node src/butler.js",
"lint": "npx eslint src/**/*.js"
"lint": "npx eslint ./src/**/*.js"
},
"jest": {
"transform": {},
"setupFiles": [
"./src/test/env.js"
]
},
"repository": {
"type": "git",
Expand All @@ -36,7 +42,8 @@
"files": [
"butler.js"
],
"main": "butler.js",
"type": "module",
"exports": "./butler.js",
"directories": {
"lib": "lib",
"test": "test"
Expand All @@ -63,7 +70,6 @@
"eslint": "^8.55.0",
"eslint-config-airbnb-base": "^15.0.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-import": "^2.29.0",
"eslint-plugin-prettier": "^5.0.1",
"express-handlebars": "^7.0.7",
"fastify": "^4.24.3",
Expand Down Expand Up @@ -101,6 +107,9 @@
"xstate": "^4.38.3"
},
"devDependencies": {
"@babel/eslint-parser": "^7.23.9",
"@babel/plugin-syntax-import-assertions": "^7.23.3",
"eslint-plugin-import": "^2.29.1",
"jest": "^29.7.0",
"prettier": "^3.1.1",
"snyk": "^1.1260.0"
Expand Down
4 changes: 1 addition & 3 deletions src/api/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,4 @@ const apiGetAPIEndpointsEnabled = {
},
};

module.exports = {
apiGetAPIEndpointsEnabled,
};
export default apiGetAPIEndpointsEnabled;
9 changes: 2 additions & 7 deletions src/api/base_conversion.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const apiGetBase62ToBase16 = {
export const apiGetBase62ToBase16 = {
schema: {
description: 'Converts strings from base62 to base16.',
summary: 'Converts strings from base62 to base16.',
Expand Down Expand Up @@ -55,7 +55,7 @@ const apiGetBase62ToBase16 = {
},
};

const apiGetBase16ToBase62 = {
export const apiGetBase16ToBase62 = {
schema: {
description: 'Converts strings from base16 to base62.',
summary: 'Converts strings from base16 to base62.',
Expand Down Expand Up @@ -116,8 +116,3 @@ const apiGetBase16ToBase62 = {
},
},
};

module.exports = {
apiGetBase62ToBase16,
apiGetBase16ToBase62,
};
4 changes: 1 addition & 3 deletions src/api/butler_ping.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,4 @@ const apiGetButlerPing = {
},
};

module.exports = {
apiGetButlerPing,
};
export default apiGetButlerPing;
18 changes: 5 additions & 13 deletions src/api/disk_utils.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const apiFileCopy = {
export const apiFileCopy = {
schema: {
description:
"Copying of files is only posttible between pre-approved directories.\nDefining approved source and destination directories is done in Butler's config file.\n\nIf the source directory contains subdirectories, these will be copied too.",
Expand Down Expand Up @@ -97,7 +97,7 @@ const apiFileCopy = {
},
};

const apiFileMove = {
export const apiFileMove = {
schema: {
description:
"Moving of files is only posttible between pre-approved directories.\nDefining approved source and destination directories is done in Butler's config file.\n\nIf the source directory contains subdirectories, these will be moved too.",
Expand Down Expand Up @@ -181,7 +181,7 @@ const apiFileMove = {
},
};

const apiFileDelete = {
export const apiFileDelete = {
schema: {
description:
"It is only possible to delete files in pre-approved directories, or subdirectories thereof.\nDefining approved directories is done in Butler's config file.",
Expand Down Expand Up @@ -239,7 +239,7 @@ const apiFileDelete = {
},
};

const apiCreateDir = {
export const apiCreateDir = {
schema: {
description:
"If the directory already exists nothing will happen.\nIf permissions don't allow a directory to be created, or if the path is invalid, an error will be returned.",
Expand Down Expand Up @@ -292,7 +292,7 @@ const apiCreateDir = {
},
};

const apiCreateDirQvd = {
export const apiCreateDirQvd = {
schema: {
description: "Creates a directory in QVD directory (which is defined in Butler's config file).",
summary: 'Creates a directory in designated QVD directory.',
Expand Down Expand Up @@ -343,11 +343,3 @@ const apiCreateDirQvd = {
},
},
};

module.exports = {
apiFileCopy,
apiFileMove,
apiFileDelete,
apiCreateDir,
apiCreateDirQvd,
};
24 changes: 7 additions & 17 deletions src/api/key_value_store.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const apiGetAllNamespaces = {
export const apiGetAllNamespaces = {
schema: {
description: '',
summary: 'List all currently defined namespaces.',
Expand Down Expand Up @@ -26,7 +26,7 @@ const apiGetAllNamespaces = {
},
};

const apiGetKVPair = {
export const apiGetKVPair = {
schema: {
description: '',
summary: 'Get the value associated with a key, in a specific namespace.',
Expand Down Expand Up @@ -99,7 +99,7 @@ const apiGetKVPair = {
},
};

const apiGetKVExists = {
export const apiGetKVExists = {
schema: {
description: 'Returns true if the specified key exists, otherwise false.',
summary: 'Checks if a key exists in a namespace.',
Expand Down Expand Up @@ -181,7 +181,7 @@ const apiGetKVExists = {
},
};

const apiPostKVPair = {
export const apiPostKVPair = {
schema: {
description:
'If the specified key already exists it will be overwritten.\n\nIf the posted data has a TTL, it will start counting when the post occur.\nI.e. if a previouly posted key also had a TTL, it will be replace with the most recent TTL.',
Expand Down Expand Up @@ -270,7 +270,7 @@ const apiPostKVPair = {
},
};

const apiDeleteKVPair = {
export const apiDeleteKVPair = {
schema: {
description: '',
summary: 'Delete a key-value pair in a specific namespace.',
Expand Down Expand Up @@ -322,7 +322,7 @@ const apiDeleteKVPair = {
},
};

const apiDeleteNamespace = {
export const apiDeleteNamespace = {
schema: {
description: '',
summary: 'Delete a namespace and all key-value pairs in it.',
Expand Down Expand Up @@ -368,7 +368,7 @@ const apiDeleteNamespace = {
},
};

const apiGetKeysInNamespace = {
export const apiGetKeysInNamespace = {
schema: {
description: '',
summary: 'Retrieve a list of all keys present in the specified namespace.',
Expand Down Expand Up @@ -438,13 +438,3 @@ const apiGetKeysInNamespace = {
},
},
};

module.exports = {
apiGetAllNamespaces,
apiGetKVPair,
apiGetKVExists,
apiPostKVPair,
apiDeleteKVPair,
apiDeleteNamespace,
apiGetKeysInNamespace,
};
4 changes: 1 addition & 3 deletions src/api/mqtt_publish_message.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,4 @@ const apiPutMqttMessage = {
},
};

module.exports = {
apiPutMqttMessage,
};
export default apiPutMqttMessage;
4 changes: 1 addition & 3 deletions src/api/newrelic_event.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,4 @@ const apiPostNewRelicEvent = {
},
};

module.exports = {
apiPostNewRelicEvent,
};
export default apiPostNewRelicEvent;
4 changes: 1 addition & 3 deletions src/api/newrelic_metric.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,4 @@ const apiPostNewRelicMetric = {
},
};

module.exports = {
apiPostNewRelicMetric,
};
export default apiPostNewRelicMetric;
27 changes: 8 additions & 19 deletions src/api/scheduler.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const apiGETSchedules = {
export const apiGETSchedules = {
schema: {
summary: 'Get all information available for existing schedule(s).',
description:
Expand Down Expand Up @@ -101,7 +101,7 @@ const apiGETSchedules = {
},
};

const apiPOSTSchedules = {
export const apiPOSTSchedules = {
schema: {
summary: 'Create a new schedule.',
description: '',
Expand Down Expand Up @@ -224,7 +224,7 @@ const apiPOSTSchedules = {
},
};

const apiDELETESchedules = {
export const apiDELETESchedules = {
schema: {
summary: 'Delete a schedule.',
description: '',
Expand Down Expand Up @@ -270,7 +270,7 @@ const apiDELETESchedules = {
},
};

const apiPUTSchedulesStart = {
export const apiPUTSchedulesStart = {
schema: {
summary: 'Start a schedule.',
description: "Start a schedule, i.e. have the scheduler run the associated reload task according to the schedule's cron settings.",
Expand Down Expand Up @@ -369,7 +369,7 @@ const apiPUTSchedulesStart = {
},
};

const apiPUTSchedulesStop = {
export const apiPUTSchedulesStop = {
schema: {
summary: 'Stop a schedule.',
description: 'Stop a schedule, i.e. tell the scheduler to no longer execute the schedule according to its cron settings.',
Expand Down Expand Up @@ -468,7 +468,7 @@ const apiPUTSchedulesStop = {
},
};

const apiPUTSchedulesStartAll = {
export const apiPUTSchedulesStartAll = {
schema: {
summary: 'Start all schedules.',
description:
Expand Down Expand Up @@ -544,7 +544,7 @@ const apiPUTSchedulesStartAll = {
},
};

const apiPUTSchedulesStopAll = {
export const apiPUTSchedulesStopAll = {
schema: {
summary: 'Stop all schedules.',
description: 'Stop all schedules, i.e. tell the scheduler to no longer execute any schedule according to its cron settings.',
Expand Down Expand Up @@ -619,7 +619,7 @@ const apiPUTSchedulesStopAll = {
},
};

const apiGETSchedulerStatus = {
export const apiGETSchedulerStatus = {
schema: {
summary: 'Get scheduler status.',
description:
Expand Down Expand Up @@ -647,14 +647,3 @@ const apiGETSchedulerStatus = {
},
},
};

module.exports = {
apiGETSchedules,
apiPOSTSchedules,
apiDELETESchedules,
apiPUTSchedulesStart,
apiPUTSchedulesStartAll,
apiPUTSchedulesStop,
apiPUTSchedulesStopAll,
apiGETSchedulerStatus,
};
4 changes: 1 addition & 3 deletions src/api/sense_app.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,4 @@ const apiPutAppReload = {
},
};

module.exports = {
apiPutAppReload,
};
export default apiPutAppReload;
9 changes: 2 additions & 7 deletions src/api/sense_app_dump.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const apiGetSenseAppDump = {
export const apiGetSenseAppDump = {
schema: {
summary: 'Dump a Sense app to JSON.',
description: 'Does the same thing as `/v4/app/:appId/dump`',
Expand Down Expand Up @@ -72,7 +72,7 @@ const apiGetSenseAppDump = {
},
};

const apiGetAppDump = {
export const apiGetAppDump = {
schema: {
summary: 'Dump a Sense app to JSON.',
description: 'Does the same thing as `/v4/senseappdump/:appId`',
Expand Down Expand Up @@ -145,8 +145,3 @@ const apiGetAppDump = {
},
},
};

module.exports = {
apiGetSenseAppDump,
apiGetAppDump,
};
Loading

0 comments on commit 25f0ab2

Please sign in to comment.