diff --git a/CHANGELOG.md b/CHANGELOG.md index 9addd57..824df3e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/src/commands/create.ts b/src/commands/create.ts index 5024811..5f8cca6 100644 --- a/src/commands/create.ts +++ b/src/commands/create.ts @@ -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"; @@ -246,10 +247,16 @@ async function renderTemplate(destination: string, pluginInfo: PluginInfo): Prom async function finalize(destination: string, pluginInfo: PluginInfo): Promise { 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, + }); } /** diff --git a/src/commands/restart.ts b/src/commands/restart.ts index 52fe535..1e1660d 100644 --- a/src/commands/restart.ts +++ b/src/commands/restart.ts @@ -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(async ({ uuid }, output) => { - output.spin(`Restarting ${uuid}`); +export const restart = command( + 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}. @@ -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; };