Skip to content
Closed
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
2 changes: 2 additions & 0 deletions src/Console/InstallCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ class InstallCommand extends Command implements PromptsForMissingInput
{--ssr : Indicates if Inertia SSR support should be installed}
{--typescript : Indicates if TypeScript is preferred for the Inertia stack}
{--eslint : Indicates if ESLint with Prettier should be installed}
{--all : Indicates if All the followings (--dark, --ssr, --typescript, --eslint) should be installed}
{--composer=global : Absolute path to the Composer binary which should be used to install packages}';

/**
Expand Down Expand Up @@ -406,6 +407,7 @@ protected function afterPromptingForMissingArguments(InputInterface $input, Outp
'ssr' => 'Inertia SSR',
'typescript' => 'TypeScript',
'eslint' => 'ESLint with Prettier',
'all' => 'All the followings (Dark mode, Inertia SSR, TypeScript, ESLint with prettier)',
],
hint: 'Use the space bar to select options.'
))->each(fn ($option) => $input->setOption($option, true));
Expand Down
38 changes: 19 additions & 19 deletions src/Console/InstallsInertiaStacks.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ protected function installInertiaVueStack()
] + $packages;
});

if ($this->option('typescript')) {
if ($this->option('typescript') || $this->option('all')) {
$this->updateNodePackages(function ($packages) {
return [
'typescript' => '^5.6.3',
Expand All @@ -41,7 +41,7 @@ protected function installInertiaVueStack()
});
}

if ($this->option('eslint')) {
if ($this->option('eslint') || $this->option('all')) {
$this->updateNodePackages(function ($packages) {
return [
'eslint' => '^8.57.0',
Expand All @@ -54,7 +54,7 @@ protected function installInertiaVueStack()
] + $packages;
});

if ($this->option('typescript')) {
if ($this->option('typescript') || $this->option('all')) {
$this->updateNodePackages(function ($packages) {
return [
'@vue/eslint-config-typescript' => '^13.0.0',
Expand Down Expand Up @@ -111,7 +111,7 @@ protected function installInertiaVueStack()
(new Filesystem)->ensureDirectoryExists(resource_path('js/Layouts'));
(new Filesystem)->ensureDirectoryExists(resource_path('js/Pages'));

if ($this->option('typescript')) {
if ($this->option('typescript') || $this->option('all')) {
(new Filesystem)->copyDirectory(__DIR__.'/../../stubs/inertia-vue-ts/resources/js/Components', resource_path('js/Components'));
(new Filesystem)->copyDirectory(__DIR__.'/../../stubs/inertia-vue-ts/resources/js/Layouts', resource_path('js/Layouts'));
(new Filesystem)->copyDirectory(__DIR__.'/../../stubs/inertia-vue-ts/resources/js/Pages', resource_path('js/Pages'));
Expand All @@ -122,7 +122,7 @@ protected function installInertiaVueStack()
(new Filesystem)->copyDirectory(__DIR__.'/../../stubs/inertia-vue/resources/js/Pages', resource_path('js/Pages'));
}

if (! $this->option('dark')) {
if (! $this->option('dark') || $this->option('all')) {
$this->removeDarkClasses((new Finder)
->in(resource_path('js'))
->name('*.vue')
Expand All @@ -135,7 +135,7 @@ protected function installInertiaVueStack()
return 1;
}

if ($this->option('pest')) {
if ($this->option('pest') || $this->option('all')) {
(new Filesystem)->copyDirectory(__DIR__.'/../../stubs/inertia-common/pest-tests/Feature', base_path('tests/Feature'));
} else {
(new Filesystem)->copyDirectory(__DIR__.'/../../stubs/inertia-common/tests/Feature', base_path('tests/Feature'));
Expand All @@ -151,7 +151,7 @@ protected function installInertiaVueStack()
copy(__DIR__.'/../../stubs/inertia-common/tailwind.config.js', base_path('tailwind.config.js'));
copy(__DIR__.'/../../stubs/inertia-vue/vite.config.js', base_path('vite.config.js'));

if ($this->option('typescript')) {
if ($this->option('typescript') || $this->option('all')) {
copy(__DIR__.'/../../stubs/inertia-vue-ts/tsconfig.json', base_path('tsconfig.json'));
copy(__DIR__.'/../../stubs/inertia-vue-ts/resources/js/app.ts', resource_path('js/app.ts'));

Expand All @@ -171,7 +171,7 @@ protected function installInertiaVueStack()
copy(__DIR__.'/../../stubs/inertia-vue/resources/js/app.js', resource_path('js/app.js'));
}

if ($this->option('ssr')) {
if ($this->option('ssr') || $this->option('all')) {
$this->installInertiaVueSsrStack();
}

Expand Down Expand Up @@ -204,7 +204,7 @@ protected function installInertiaVueSsrStack()
] + $packages;
});

if ($this->option('typescript')) {
if ($this->option('typescript') || $this->option('all')) {
copy(__DIR__.'/../../stubs/inertia-vue-ts/resources/js/ssr.ts', resource_path('js/ssr.ts'));
$this->replaceInFile("input: 'resources/js/app.ts',", "input: 'resources/js/app.ts',".PHP_EOL." ssr: 'resources/js/ssr.ts',", base_path('vite.config.js'));
} else {
Expand Down Expand Up @@ -245,7 +245,7 @@ protected function installInertiaReactStack()
] + $packages;
});

if ($this->option('typescript')) {
if ($this->option('typescript') || $this->option('all')) {
$this->updateNodePackages(function ($packages) {
return [
'@types/node' => '^18.13.0',
Expand All @@ -256,7 +256,7 @@ protected function installInertiaReactStack()
});
}

if ($this->option('eslint')) {
if ($this->option('eslint') || $this->option('all')) {
$this->updateNodePackages(function ($packages) {
return [
'eslint' => '^8.57.0',
Expand All @@ -270,7 +270,7 @@ protected function installInertiaReactStack()
] + $packages;
});

if ($this->option('typescript')) {
if ($this->option('typescript') || $this->option('all')) {
$this->updateNodePackages(function ($packages) {
return [
'@typescript-eslint/eslint-plugin' => '^7.16.0',
Expand Down Expand Up @@ -328,7 +328,7 @@ protected function installInertiaReactStack()
(new Filesystem)->ensureDirectoryExists(resource_path('js/Layouts'));
(new Filesystem)->ensureDirectoryExists(resource_path('js/Pages'));

if ($this->option('typescript')) {
if ($this->option('typescript') || $this->option('all')) {
(new Filesystem)->copyDirectory(__DIR__.'/../../stubs/inertia-react-ts/resources/js/Components', resource_path('js/Components'));
(new Filesystem)->copyDirectory(__DIR__.'/../../stubs/inertia-react-ts/resources/js/Layouts', resource_path('js/Layouts'));
(new Filesystem)->copyDirectory(__DIR__.'/../../stubs/inertia-react-ts/resources/js/Pages', resource_path('js/Pages'));
Expand All @@ -339,7 +339,7 @@ protected function installInertiaReactStack()
(new Filesystem)->copyDirectory(__DIR__.'/../../stubs/inertia-react/resources/js/Pages', resource_path('js/Pages'));
}

if (! $this->option('dark')) {
if (! $this->option('dark') || $this->option('all')) {
$this->removeDarkClasses((new Finder)
->in(resource_path('js'))
->name(['*.jsx', '*.tsx'])
Expand All @@ -352,7 +352,7 @@ protected function installInertiaReactStack()
return 1;
}

if ($this->option('pest')) {
if ($this->option('pest') || $this->option('all')) {
(new Filesystem)->copyDirectory(__DIR__.'/../../stubs/inertia-common/pest-tests/Feature', base_path('tests/Feature'));
} else {
(new Filesystem)->copyDirectory(__DIR__.'/../../stubs/inertia-common/tests/Feature', base_path('tests/Feature'));
Expand All @@ -368,7 +368,7 @@ protected function installInertiaReactStack()
copy(__DIR__.'/../../stubs/inertia-common/tailwind.config.js', base_path('tailwind.config.js'));
copy(__DIR__.'/../../stubs/inertia-react/vite.config.js', base_path('vite.config.js'));

if ($this->option('typescript')) {
if ($this->option('typescript') || $this->option('all')) {
copy(__DIR__.'/../../stubs/inertia-react-ts/tsconfig.json', base_path('tsconfig.json'));
copy(__DIR__.'/../../stubs/inertia-react-ts/resources/js/app.tsx', resource_path('js/app.tsx'));

Expand All @@ -391,7 +391,7 @@ protected function installInertiaReactStack()
unlink(resource_path('js/app.js'));
}

if ($this->option('ssr')) {
if ($this->option('ssr') || $this->option('all')) {
$this->installInertiaReactSsrStack();
}

Expand Down Expand Up @@ -420,7 +420,7 @@ protected function installInertiaReactStack()
*/
protected function installInertiaReactSsrStack()
{
if ($this->option('typescript')) {
if ($this->option('typescript') || $this->option('all')) {
copy(__DIR__.'/../../stubs/inertia-react-ts/resources/js/ssr.tsx', resource_path('js/ssr.tsx'));
$this->replaceInFile("input: 'resources/js/app.tsx',", "input: 'resources/js/app.tsx',".PHP_EOL." ssr: 'resources/js/ssr.tsx',", base_path('vite.config.js'));
$this->configureReactHydrateRootForSsr(resource_path('js/app.tsx'));
Expand Down Expand Up @@ -508,7 +508,7 @@ protected function configureZiggyForSsr()
app_path('Http/Middleware/HandleInertiaRequests.php')
);

if ($this->option('typescript')) {
if ($this->option('typescript') || $this->option('all')) {
$this->replaceInFile(
<<<'EOT'
export interface User {
Expand Down