Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@

# Change Log

## 1.4.0

### ♻️ Update

- Update `create` command to show newly created plugins within Stream Deck.

## 1.3.0

### ♻️ Update
Expand Down
9 changes: 8 additions & 1 deletion src/commands/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { generatePluginId, getPlugins, isValidPluginId } from "../stream-deck";
import { invalidCharacters, isExecutable, isSafeBaseName, relative } from "../system/path";
import { setDeveloperMode } from "./dev";
import { link } from "./link";
import { restart } from "./restart";

const TEMPLATE_PLUGIN_UUID = "com.elgato.template";

Expand Down Expand Up @@ -246,10 +247,16 @@ async function renderTemplate(destination: string, pluginInfo: PluginInfo): Prom
async function finalize(destination: string, pluginInfo: PluginInfo): Promise<void> {
createTemplateRenderer(destination, pluginInfo, { isPreBuild: false }).copy("rollup.config.mjs.ejs");

link({
await link({
path: path.join(destination, `${pluginInfo.uuid}.sdPlugin`),
quiet: true,
});

await restart({
uuid: pluginInfo.uuid,
noStart: true,
quiet: true,
});
}

/**
Expand Down
44 changes: 29 additions & 15 deletions src/commands/restart.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,33 @@ import { isPluginInstalled, isStreamDeckRunning } from "../stream-deck";
/**
* Restarts the first plugin that matches the given {@link RestartOptions.uuid}.
*/
export const restart = command<RestartOptions>(async ({ uuid }, output) => {
output.spin(`Restarting ${uuid}`);
export const restart = command<RestartOptions>(
async ({ uuid, noStart }, output) => {
output.spin(`Restarting ${uuid}`);

// Check we have a plugin installed that matches the uuid.
if (!isPluginInstalled(uuid)) {
return output.error("Restarting failed").log(`Plugin not found: ${uuid}`).exit(1);
}
// Check we have a plugin installed that matches the uuid.
if (!isPluginInstalled(uuid)) {
return output.error("Restarting failed").log(`Plugin not found: ${uuid}`).exit(1);
}

// When Stream Deck isn't running, start it.
if (!(await isStreamDeckRunning())) {
await runUrl(`streamdeck://plugins/restart/${uuid}`);
return output.info("Stream Deck is not running. Starting Stream Deck.").exit();
}
// When Stream Deck isn't running, start it.
if (!(await isStreamDeckRunning())) {
if (noStart) {
return;
}

await runUrl(`streamdeck://plugins/restart/${uuid}`);
return output.info("Stream Deck is not running. Starting Stream Deck.").exit();
}

// Restart the plugin.
await runUrl(`streamdeck://plugins/restart/${uuid}`);
output.success(`Restarted ${chalk.green(uuid)}`);
});
// Restart the plugin.
await runUrl(`streamdeck://plugins/restart/${uuid}`);
output.success(`Restarted ${chalk.green(uuid)}`);
},
{
noStart: false,
},
);

/**
* Options available to {@link restart}.
Expand All @@ -34,4 +43,9 @@ type RestartOptions = {
* Identifies the plugin.
*/
uuid: string;

/**
* Determines whether Stream Deck should start if it is not already running.
*/
noStart?: boolean;
};