Skip to content

Commit 75137a9

Browse files
authored
Remove JS SDK installation step (#930)
1 parent d8ebad3 commit 75137a9

File tree

6 files changed

+0
-147
lines changed

6 files changed

+0
-147
lines changed

src/Sentry/Laravel/Console/PublishCommand.php

Lines changed: 0 additions & 122 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,8 @@
55
use Exception;
66
use Illuminate\Console\Command;
77
use Illuminate\Support\Str;
8-
use RuntimeException;
98
use Sentry\Dsn;
109
use Sentry\Laravel\ServiceProvider;
11-
use Symfony\Component\Process\Process;
1210

1311
class PublishCommand extends Command
1412
{
@@ -90,9 +88,6 @@ public function handle(): int
9088
if (!$this->setEnvValues($env)) {
9189
return 1;
9290
}
93-
if ($this->confirm('Do you want to install one of our JavaScript SDKs?', !$this->option('without-javascript-sdk'))) {
94-
$this->installJavaScriptSdk();
95-
}
9691

9792
return 0;
9893
}
@@ -165,121 +160,4 @@ private function askForDsnInput(): string
165160
}
166161
}
167162
}
168-
169-
private function installJavaScriptSdk(): void
170-
{
171-
$framework = $this->choice(
172-
'Which frontend framework are you using?',
173-
[
174-
self::SDK_CHOICE_BROWSER,
175-
self::SDK_CHOICE_VUE,
176-
self::SDK_CHOICE_REACT,
177-
self::SDK_CHOICE_ANGULAR,
178-
self::SDK_CHOICE_SVELTE,
179-
],
180-
self::SDK_CHOICE_BROWSER
181-
);
182-
183-
$snippet = '';
184-
185-
switch ($framework) {
186-
case self::SDK_CHOICE_BROWSER:
187-
$this->updateNodePackages(function ($packages) {
188-
return [
189-
'@sentry/browser' => '^7.40.0',
190-
] + $packages;
191-
});
192-
$snippet = file_get_contents(__DIR__ . '/../../../../stubs/sentry-javascript/browser.js');
193-
break;
194-
case self::SDK_CHOICE_VUE:
195-
$this->updateNodePackages(function ($packages) {
196-
return [
197-
'@sentry/vue' => '^7.40.0',
198-
] + $packages;
199-
});
200-
$snippet = file_get_contents(__DIR__ . '/../../../../stubs/sentry-javascript/vue.js');
201-
break;
202-
case self::SDK_CHOICE_REACT:
203-
$this->updateNodePackages(function ($packages) {
204-
return [
205-
'@sentry/react' => '^7.40.0',
206-
] + $packages;
207-
});
208-
$snippet = file_get_contents(__DIR__ . '/../../../../stubs/sentry-javascript/react.js');
209-
break;
210-
case self::SDK_CHOICE_ANGULAR:
211-
$this->updateNodePackages(function ($packages) {
212-
return [
213-
'@sentry/angular' => '^7.40.0',
214-
] + $packages;
215-
});
216-
$snippet = file_get_contents(__DIR__ . '/../../../../stubs/sentry-javascript/angular.js');
217-
break;
218-
case self::SDK_CHOICE_SVELTE:
219-
$this->updateNodePackages(function ($packages) {
220-
return [
221-
'@sentry/svelte' => '^7.40.0',
222-
] + $packages;
223-
});
224-
$snippet = file_get_contents(__DIR__ . '/../../../../stubs/sentry-javascript/svelte.js');
225-
break;
226-
}
227-
228-
$env['VITE_SENTRY_DSN_PUBLIC'] ='"${SENTRY_LARAVEL_DSN}"';
229-
$this->setEnvValues($env);
230-
231-
if (file_exists(base_path('pnpm-lock.yaml'))) {
232-
$this->runCommands(['pnpm install']);
233-
} elseif (file_exists(base_path('yarn.lock'))) {
234-
$this->runCommands(['yarn install']);
235-
} else {
236-
$this->runCommands(['npm install']);
237-
}
238-
239-
$this->newLine();
240-
$this->components->info('Sentry JavaScript SDK installed successfully.');
241-
$this->line('Put the following snippet into your JavaScript entry file:');
242-
$this->newLine();
243-
$this->line('<bg=blue>' . $snippet . '</>');
244-
$this->newLine();
245-
$this->line('For the best Sentry experience, we recommend you to set up dedicated projects for your Laravel and JavaScript applications.');
246-
}
247-
248-
private function updateNodePackages(callable $callback)
249-
{
250-
if (! file_exists(base_path('package.json'))) {
251-
return;
252-
}
253-
254-
$packages = json_decode(file_get_contents(base_path('package.json')), true);
255-
256-
$packages['dependencies'] = $callback(
257-
array_key_exists('dependencies', $packages) ? $packages['dependencies'] : [],
258-
'dependencies'
259-
);
260-
261-
ksort($packages['dependencies']);
262-
263-
file_put_contents(
264-
base_path('package.json'),
265-
json_encode($packages, JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT).PHP_EOL
266-
);
267-
}
268-
269-
private function runCommands($commands)
270-
{
271-
$process = Process::fromShellCommandline(implode(' && ', $commands), null, null, null, null);
272-
273-
if ('\\' !== DIRECTORY_SEPARATOR && file_exists('/dev/tty') && is_readable('/dev/tty')) {
274-
try {
275-
$process->setTty(true);
276-
} catch (RuntimeException $e) {
277-
$this->output->writeln(' <bg=yellow;fg=black> WARN </> '.$e->getMessage().PHP_EOL);
278-
}
279-
}
280-
281-
$process->run(function ($type, $line) {
282-
$this->output->write(' '.$line);
283-
});
284-
}
285163
}

stubs/sentry-javascript/angular.js

Lines changed: 0 additions & 5 deletions
This file was deleted.

stubs/sentry-javascript/browser.js

Lines changed: 0 additions & 5 deletions
This file was deleted.

stubs/sentry-javascript/react.js

Lines changed: 0 additions & 5 deletions
This file was deleted.

stubs/sentry-javascript/svelte.js

Lines changed: 0 additions & 5 deletions
This file was deleted.

stubs/sentry-javascript/vue.js

Lines changed: 0 additions & 5 deletions
This file was deleted.

0 commit comments

Comments
 (0)