From 5e395d381c204bab50ebe4d421d822a590120238 Mon Sep 17 00:00:00 2001 From: Waqas Ibrahim Date: Thu, 31 Aug 2023 00:57:10 +0500 Subject: [PATCH 1/2] fix yarn installation --- src/commands/create.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/commands/create.ts b/src/commands/create.ts index e3e196a..04b24e8 100644 --- a/src/commands/create.ts +++ b/src/commands/create.ts @@ -194,7 +194,7 @@ export default class CreateCommand implements CliCommand { spinner.succeed('Boilerplate generated'); spinner.start('Installing node modules...'); - await execAsync(`${pm} i`, { cwd: base }); + await execAsync(`${pm} install`, { cwd: base }); spinner.succeed('Node modules installed'); spinner.start('Building the project...'); From a9bb335b4887013662cbaf9de7373d650dde3c65 Mon Sep 17 00:00:00 2001 From: Waqas Ibrahim Date: Sun, 17 Sep 2023 16:56:51 +0500 Subject: [PATCH 2/2] fixes for macos --- src/commands/create.ts | 16 +++++++++------- src/commands/dev.ts | 6 ------ src/commands/link.ts | 15 +++++---------- src/util.ts | 2 +- 4 files changed, 15 insertions(+), 24 deletions(-) diff --git a/src/commands/create.ts b/src/commands/create.ts index 04b24e8..b7874c0 100644 --- a/src/commands/create.ts +++ b/src/commands/create.ts @@ -100,13 +100,15 @@ export default class CreateCommand implements CliCommand { return console.log(logSymbols.error, 'Directory not empty'); } - await fs.mkdir(base + 'plugin/icons', { recursive: true }); - await fs.ensureDir(base + 'plugin/pi'); + const pluginDir = join(base, `${choices.uuid}.sdPlugin`); + + await fs.mkdir(`${pluginDir}/icons`, { recursive: true }); + await fs.ensureDir(`${pluginDir}/pi`); await fs.ensureDir(base + 'src/actions'); await fs.copy( join(__dirname, '../../boilerplate/plugin/pi'), - join(base, 'plugin/pi'), + pluginDir, { recursive: true } @@ -121,12 +123,12 @@ export default class CreateCommand implements CliCommand { join(__dirname, '../../boilerplate/plugin/pi/index.html') ); await fs.writeFile( - base + '/plugin/pi/index.html', + `${pluginDir}/pi/index.html`, Mustache.render(templatePi.toString(), choices) ); await fs.writeFile( - base + '/plugin/manifest.json', + `${pluginDir}/manifest.json`, JSON.stringify( createManifest({ name: choices.name, @@ -143,7 +145,7 @@ export default class CreateCommand implements CliCommand { await fs.copy( join(__dirname, '../../boilerplate/plugin/icons'), - join(base, 'plugin/icons'), + `${pluginDir}/icons`, { recursive: true } @@ -202,7 +204,7 @@ export default class CreateCommand implements CliCommand { spinner.stop(); await new LinkCommand().execute({ - cwd: join(base, 'plugin') + cwd: join(process.cwd(), pluginDir), }); console.log('\n', logSymbols.success, 'Project created', '\n'); diff --git a/src/commands/dev.ts b/src/commands/dev.ts index fcc326d..b352e40 100644 --- a/src/commands/dev.ts +++ b/src/commands/dev.ts @@ -67,12 +67,6 @@ export default class DevCommand implements CliCommand { let cwd = process.cwd(); let manifest = await parseManifest(cwd); - if (!manifest) { - // allows command's execution in the main project directory - cwd = join(cwd, 'plugin'); - manifest = await parseManifest(cwd); - } - if (manifest) { await this.downloadDebugPlugin(); diff --git a/src/commands/link.ts b/src/commands/link.ts index ab0124f..147ec42 100644 --- a/src/commands/link.ts +++ b/src/commands/link.ts @@ -2,8 +2,7 @@ import { CliCommand } from '../interfaces.js'; import { CommandLineOptions, OptionDefinition } from 'command-line-args'; import { checkApplicationInPath, getUUID, parseManifest, reloadStreamDeckApplication } from '../util.js'; import { join } from 'node:path'; -import symlinkDir from 'symlink-dir'; -import { lstatSync, rmdirSync } from 'node:fs'; +import { lstatSync, symlinkSync, unlinkSync } from 'node:fs'; import { PluginPath } from '../constant.js'; import logSymbols from 'log-symbols'; @@ -25,12 +24,6 @@ export default class LinkCommand implements CliCommand { let manifest = await parseManifest(cwd); - if (!manifest) { - // allows command's execution in the main project directory - cwd = join(cwd, 'plugin'); - manifest = await parseManifest(cwd); - } - if (manifest) { const uuid = getUUID(manifest); const pluginDirectory = join(PluginPath, uuid + '.sdPlugin'); @@ -49,7 +42,7 @@ export default class LinkCommand implements CliCommand { } if (stats.isSymbolicLink()) { - rmdirSync(pluginDirectory); + unlinkSync(pluginDirectory); console.log(logSymbols.success, 'Plugin unlinked'); await reloadStreamDeckApplication(uuid); } else { @@ -62,10 +55,12 @@ export default class LinkCommand implements CliCommand { return console.log(logSymbols.error, 'Plugin already linked'); } - await symlinkDir(cwd, pluginDirectory); + symlinkSync(cwd, pluginDirectory, 'dir'); console.log(logSymbols.success, 'Plugin linked'); await reloadStreamDeckApplication(uuid); } + } else { + console.log(logSymbols.error, 'No manifest file found in current directory.'); } } diff --git a/src/util.ts b/src/util.ts index 077f3a7..304e6bb 100644 --- a/src/util.ts +++ b/src/util.ts @@ -25,7 +25,7 @@ export const parseManifest = async ( ): Promise => { try { return await fs.readJSON( - join(cwd, nested ? 'plugin' : '', 'manifest.json') + join(cwd, 'manifest.json') ); } catch (e) { if (!nested) {