@elgato/cli 0.1.0-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json ADDED
@@ -0,0 +1,79 @@
1
+ {
2
+ "name": "@elgato/cli",
3
+ "version": "0.1.0-beta.0",
4
+ "description": "The official CLI for building Node.js Stream Deck plugins.",
5
+ "bin": {
6
+ "streamdeck": "bin/streamdeck.mjs",
7
+ "sd": "bin/streamdeck.mjs"
8
+ },
9
+ "files": [
10
+ "bin/streamdeck.mjs",
11
+ "template"
12
+ ],
13
+ "type": "module",
14
+ "engines": {
15
+ "node": "^20.1.0"
16
+ },
17
+ "scripts": {
18
+ "build": "rollup --config rollup.config.ts --configPlugin typescript",
19
+ "watch": "rollup --config rollup.config.ts --configPlugin typescript --watch",
20
+ "lint": "eslint . --ext .ts --max-warnings 0",
21
+ "lint:fix": "prettier --config .prettierrc \"./src/**/*.ts\" --write",
22
+ "preversion": "npm run build && npm run lint"
23
+ },
24
+ "repository": {
25
+ "type": "git",
26
+ "url": "git+https://github.com/elgatosf/cli.git"
27
+ },
28
+ "keywords": [
29
+ "elgato",
30
+ "stream-deck",
31
+ "plugin",
32
+ "cli",
33
+ "marketplace",
34
+ "maker"
35
+ ],
36
+ "author": {
37
+ "name": "Elgato",
38
+ "url": "https://www.elgato.com"
39
+ },
40
+ "license": "MIT",
41
+ "bugs": {
42
+ "url": "https://github.com/elgatosf/cli/issues"
43
+ },
44
+ "homepage": "https://github.com/elgatosf/cli#readme",
45
+ "devDependencies": {
46
+ "@rollup/plugin-commonjs": "^25.0.4",
47
+ "@rollup/plugin-json": "^6.0.0",
48
+ "@rollup/plugin-node-resolve": "^15.2.1",
49
+ "@rollup/plugin-terser": "^0.4.3",
50
+ "@rollup/plugin-typescript": "^11.1.4",
51
+ "@trivago/prettier-plugin-sort-imports": "^4.2.0",
52
+ "@tsconfig/node20": "^20.1.2",
53
+ "@types/ejs": "^3.1.3",
54
+ "@types/inquirer": "^9.0.3",
55
+ "@types/lodash": "^4.14.199",
56
+ "@types/node": "20.1.7",
57
+ "@typescript-eslint/eslint-plugin": "^6.7.3",
58
+ "@typescript-eslint/parser": "^6.7.3",
59
+ "ajv": "^8.12.0",
60
+ "chalk": "^5.3.0",
61
+ "commander": "^11.0.0",
62
+ "dotenv": "^16.3.1",
63
+ "ejs": "^3.1.9",
64
+ "eslint": "^8.50.0",
65
+ "eslint-config-prettier": "^9.0.0",
66
+ "eslint-plugin-jsdoc": "^46.8.2",
67
+ "eslint-plugin-prettier": "^5.0.0",
68
+ "find-process": "^1.4.7",
69
+ "inquirer": "^9.2.11",
70
+ "is-interactive": "^2.0.0",
71
+ "lodash": "^4.17.21",
72
+ "log-symbols": "^5.1.0",
73
+ "prettier": "^3.0.3",
74
+ "rage-edit": "^1.2.0",
75
+ "rollup": "^3.29.4",
76
+ "tslib": "^2.6.2",
77
+ "typescript": "^5.2.2"
78
+ }
79
+ }
@@ -0,0 +1,20 @@
1
+ {
2
+ // Use IntelliSense to learn about possible attributes.
3
+ // Hover to view descriptions of existing attributes.
4
+ // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5
+ "version": "0.2.0",
6
+ "configurations": [
7
+ {
8
+ "name": "Attach to Plugin",
9
+ "type": "node",
10
+ "request": "attach",
11
+ "processId": "${command:PickProcess}",
12
+ "outFiles": [
13
+ "${workspaceFolder}/bin/**/*.js"
14
+ ],
15
+ "resolveSourceMapLocations": [
16
+ "${workspaceFolder}/**"
17
+ ]
18
+ }
19
+ ]
20
+ }
@@ -0,0 +1,14 @@
1
+ {
2
+ /* Prefer tabs over spaces for accessibility */
3
+ "editor.insertSpaces": false,
4
+ "editor.detectIndentation": false,
5
+ /* Explorer */
6
+ "explorer.fileNesting.enabled": true,
7
+ "explorer.fileNesting.patterns": {
8
+ "*.js": "${capture}.js.map, ${capture}.min.js, ${capture}.d.ts",
9
+ "package.json": "package-lock.json, yarn.lock, pnpm-lock.yaml, rollup.config.mjs, tsconfig.json"
10
+ },
11
+ "files.exclude": {
12
+ "node_modules": true
13
+ }
14
+ }
@@ -0,0 +1,46 @@
1
+ {
2
+ "Name": <%- JSON.stringify(name) %>,
3
+ "Version": "0.1.0",
4
+ "Author": <%- JSON.stringify(author) %>,
5
+ "Actions": [
6
+ {
7
+ "Name": "Counter",
8
+ "UUID": "<%- uuid %>.increment",
9
+ "Icon": "imgs/actions/counter/icon",
10
+ "Tooltip": "Displays a count, which increments by one on press.",
11
+ "Controllers": [
12
+ "Keypad"
13
+ ],
14
+ "States": [
15
+ {
16
+ "Image": "imgs/actions/counter/key",
17
+ "TitleAlignment": "middle"
18
+ }
19
+ ]
20
+ }
21
+ ],
22
+ "Category": <%- JSON.stringify(name) %>,
23
+ "CategoryIcon": "imgs/plugin/category-icon",
24
+ "CodePath": "bin/plugin.js",
25
+ "Description": <%- JSON.stringify(description) %>,
26
+ "Icon": "imgs/plugin/marketplace",
27
+ "SDKVersion": 2,
28
+ "Software": {
29
+ "MinimumVersion": "6.3"
30
+ },
31
+ "OS": [
32
+ {
33
+ "Platform": "mac",
34
+ "MinimumVersion": "10.15"
35
+ },
36
+ {
37
+ "Platform": "windows",
38
+ "MinimumVersion": "10"
39
+ }
40
+ ],
41
+ "Nodejs": {
42
+ "Version": "20",
43
+ "Debug": "enabled"
44
+ },
45
+ "UUID": <%- JSON.stringify(uuid) %>
46
+ }
@@ -0,0 +1,20 @@
1
+ {
2
+ "scripts": {
3
+ "build": "rollup -c",
4
+ "watch": "rollup -c -w"
5
+ },
6
+ "devDependencies": {
7
+ "@rollup/plugin-commonjs": "^25.0.4",
8
+ "@rollup/plugin-node-resolve": "^15.2.1",
9
+ "@rollup/plugin-terser": "^0.4.3",
10
+ "@rollup/plugin-typescript": "11.1.2",
11
+ "@tsconfig/node20": "^20.1.2",
12
+ "@types/node": "^20.5.6",
13
+ "rollup": "^3.28.1",
14
+ "tslib": "^2.6.2",
15
+ "typescript": "^5.2.2"
16
+ },
17
+ "dependencies": {
18
+ "@elgato/streamdeck": <%- JSON.stringify(streamDeckPackage) %>
19
+ }
20
+ }
@@ -0,0 +1,71 @@
1
+ import commonjs from "@rollup/plugin-commonjs";
2
+ import nodeResolve from "@rollup/plugin-node-resolve";
3
+ import terser from "@rollup/plugin-terser";
4
+ import typescript from "@rollup/plugin-typescript";
5
+ import fs from "node:fs";
6
+ import path from "node:path";
7
+ import url from "node:url";
8
+
9
+ const __dirname = path.dirname(url.fileURLToPath(import.meta.url));
10
+
11
+ const isWatching = !!process.env.ROLLUP_WATCH;
12
+ const tsConfig = JSON.parse(fs.readFileSync(path.resolve(__dirname, "./tsconfig.json"), "utf8"));
13
+
14
+ prepareOutDir(tsConfig.compilerOptions.outDir);
15
+
16
+ /**
17
+ * @type {import('rollup').RollupOptions}
18
+ */
19
+ const config = {
20
+ input: "src/plugin.ts",
21
+ output: {
22
+ dir: tsConfig.compilerOptions.outDir,
23
+ format: "cjs",
24
+ sourcemap: isWatching,
25
+ sourcemapPathTransform: (relativeSourcePath, sourcemapPath) => {
26
+ return url.pathToFileURL(path.resolve(path.dirname(sourcemapPath), relativeSourcePath)).href;
27
+ }
28
+ },
29
+ plugins: [
30
+ typescript({
31
+ sourceMap: isWatching,
32
+ inlineSources: isWatching,
33
+ mapRoot: isWatching ? "./" : undefined
34
+ }),
35
+ commonjs({
36
+ sourceMap: false
37
+ }),
38
+ nodeResolve({
39
+ browser: false,
40
+ exportConditions: ["node"],
41
+ preferBuiltins: true
42
+ }),
43
+ !isWatching &&
44
+ terser({
45
+ format: {
46
+ comments: false
47
+ }
48
+ })
49
+ ]
50
+ };
51
+
52
+ export default config;
53
+
54
+ /**
55
+ * Validates the output directory is situated within the current working directory; upon passing validation, the directory is cleaned before build.
56
+ * @param {string} outDir
57
+ */
58
+ function prepareOutDir(outDir) {
59
+ if (outDir === undefined) {
60
+ throw new Error("outDir must be specified within the TypeScript config file.");
61
+ }
62
+
63
+ const relative = path.relative(__dirname, outDir);
64
+ if (relative && !relative.startsWith("..") && !path.isAbsolute(relative)) {
65
+ if (fs.existsSync(outDir)) {
66
+ fs.rmSync(outDir, { recursive: true });
67
+ }
68
+ } else {
69
+ throw new Error("outDir must be located within the current working directory. Please review the TypeScript config file.");
70
+ }
71
+ }
@@ -0,0 +1,39 @@
1
+ import { action, KeyDownEvent, SingletonAction, WillAppearEvent } from "@elgato/streamdeck";
2
+
3
+ /**
4
+ * An example action class that displays a count that increments by one each time the button is pressed.
5
+ */
6
+ @action({ UUID: "<%- uuid %>.increment" })
7
+ export class IncrementCounter extends SingletonAction<CounterSettings> {
8
+ /**
9
+ * The {@link SingletonAction.onWillAppear} event is useful for setting the visual representation of an action when it become visible. This could be due to the Stream Deck first
10
+ * starting up, or the user navigating between pages / folders etc.. There is also an inverse of this event in the form of {@link streamDeck.client.onWillDisappear}. In this example,
11
+ * we're setting the title to the "count" that is incremented in {@link IncrementCounter.onKeyDown}.
12
+ */
13
+ onWillAppear(ev: WillAppearEvent<CounterSettings>): void | Promise<void> {
14
+ return ev.action.setTitle(`${ev.payload.settings.count ?? 0}`);
15
+ }
16
+
17
+ /**
18
+ * Listens for the {@link SingletonAction.onKeyDown} event which is emitted by Stream Deck when an action is pressed. Stream Deck provides various events for tracking interaction
19
+ * with devices including key down/up, dial rotations, and device connectivity, etc. When triggered, {@link ev} object contains information about the event including any payloads
20
+ * and action information where applicable. In this example, our action will display a counter that increments by one each press. We track the current count on the action's persisted
21
+ * settings using `setSettings` and `getSettings`.
22
+ */
23
+ async onKeyDown(ev: KeyDownEvent<CounterSettings>): Promise<void> {
24
+ // Determine the current count from the settings.
25
+ let count = ev.payload.settings.count ?? 0;
26
+ count++;
27
+
28
+ // Update the current count in the action's settings, and change the title.
29
+ await ev.action.setSettings({ count });
30
+ await ev.action.setTitle(`${count}`);
31
+ }
32
+ }
33
+
34
+ /**
35
+ * Settings for {@link IncrementCounter}.
36
+ */
37
+ type CounterSettings = {
38
+ count: number;
39
+ };
@@ -0,0 +1,12 @@
1
+ import streamDeck, { LogLevel } from "@elgato/streamdeck";
2
+
3
+ import { IncrementCounter } from "./actions/increment-counter";
4
+
5
+ // We can enable "trace" logging so that all messages between the Stream Deck, and the plugin are recorded. When storing sensitive information
6
+ streamDeck.logger.setLevel(LogLevel.TRACE);
7
+
8
+ // Register the increment action.
9
+ streamDeck.actions.registerAction(new IncrementCounter());
10
+
11
+ // Finally, connect to the Stream Deck.
12
+ streamDeck.connect();
@@ -0,0 +1,14 @@
1
+ {
2
+ "extends": "@tsconfig/node20/tsconfig.json",
3
+ "compilerOptions": {
4
+ "module": "ESNext",
5
+ "moduleResolution": "Bundler",
6
+ "outDir": "<%- uuid %>.sdPlugin/bin"
7
+ },
8
+ "include": [
9
+ "src/**/*.ts"
10
+ ],
11
+ "exclude": [
12
+ "node_modules"
13
+ ]
14
+ }