Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ If you prefer not to use Tailwind CSS:
1. Remove the demo pages in `src/routes/demo/`
2. Replace the Tailwind import in `src/styles.css` with your own styles
3. Remove `tailwindcss()` from the plugins array in `vite.config.ts`
4. Uninstall the packages: `<%= getPackageManagerAddScript('@tailwindcss/vite tailwindcss', true) %>`
4. Uninstall the packages: `<%= getPackageManagerRemoveScript('@tailwindcss/vite tailwindcss') %>`
<% if (addOnEnabled.biome || addOnEnabled.eslint) { %>
## Linting & Formatting
<% if (addOnEnabled.biome) { %>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ If you prefer not to use Tailwind CSS:
1. Remove the demo pages in `src/routes/demo/`
2. Replace the Tailwind import in `src/styles.css` with your own styles
3. Remove `tailwindcss()` from the plugins array in `vite.config.ts`
4. Uninstall the packages: `<%= getPackageManagerAddScript('@tailwindcss/vite tailwindcss', true) %>`
4. Uninstall the packages: `<%= getPackageManagerRemoveScript('@tailwindcss/vite tailwindcss') %>`

<% for(const addon of addOns.filter(addon => addon.readme)) { %>
<%- addon.readmeIsEjs ? renderTemplate(addon.readme) : addon.readme %>
Expand Down
20 changes: 20 additions & 0 deletions packages/create/src/package-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,26 @@ export function getPackageManagerInstallCommand(
}
}

export function getPackageManagerUninstallCommand(
packagerManager: PackageManager,
pkg: string,
) {
switch (packagerManager) {
case 'yarn':
case 'pnpm':
case 'bun':
return {
command: packagerManager,
args: ['remove', pkg],
}
default:
return {
command: packagerManager,
args: ['uninstall', pkg],
}
}
}

export function packageManagerInstall(
environment: Environment,
cwd: string,
Expand Down
7 changes: 7 additions & 0 deletions packages/create/src/template-file.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
getPackageManagerExecuteCommand,
getPackageManagerInstallCommand,
getPackageManagerScriptCommand,
getPackageManagerUninstallCommand,
} from './package-manager.js'
import { relativePath } from './file-helpers.js'

Expand Down Expand Up @@ -60,6 +61,11 @@ export function createTemplateFile(environment: Environment, options: Options) {
),
)
}
function getPackageManagerRemoveScript(packageName: string) {
return formatCommand(
getPackageManagerUninstallCommand(options.packageManager, packageName),
)
}
function getPackageManagerRunScript(
scriptName: string,
args: Array<string> = [],
Expand Down Expand Up @@ -145,6 +151,7 @@ export function createTemplateFile(environment: Environment, options: Options) {
routes,

getPackageManagerAddScript,
getPackageManagerRemoveScript,
getPackageManagerRunScript,
getPackageManagerExecuteScript,

Expand Down
29 changes: 29 additions & 0 deletions packages/create/tests/package-manager.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
getPackageManagerExecuteCommand,
getPackageManagerInstallCommand,
getPackageManagerScriptCommand,
getPackageManagerUninstallCommand,
translateExecuteCommand,
} from '../src/package-manager.js'
import { formatCommand } from '../src/utils.js'
Expand Down Expand Up @@ -154,6 +155,34 @@ describe('getPackageManagerInstallCommand', () => {
})
})

describe('getPackageManagerUninstallCommand', () => {
it('yarn uninstall radix-ui', () => {
expect(
formatCommand(getPackageManagerUninstallCommand('yarn', 'radix-ui')),
).toBe('yarn remove radix-ui')
})
it('pnpm uninstall radix-ui', () => {
expect(
formatCommand(getPackageManagerUninstallCommand('pnpm', 'radix-ui')),
).toBe('pnpm remove radix-ui')
})
it('bun uninstall radix-ui', () => {
expect(
formatCommand(getPackageManagerUninstallCommand('bun', 'radix-ui')),
).toBe('bun remove radix-ui')
})
it('deno uninstall radix-ui', () => {
expect(
formatCommand(getPackageManagerUninstallCommand('deno', 'radix-ui')),
).toBe('deno uninstall radix-ui')
})
it('npm uninstall radix-ui', () => {
expect(
formatCommand(getPackageManagerUninstallCommand('npm', 'radix-ui')),
).toBe('npm uninstall radix-ui')
})
})

describe('translateExecuteCommand', () => {
it('should translate npx to bunx for bun', () => {
expect(
Expand Down
5 changes: 5 additions & 0 deletions packages/create/tests/template-file.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,10 @@ describe('createTemplateFile', () => {
'foo-dev.txt.ejs',
"<%= getPackageManagerAddScript('foo', true) %>",
)
await templateFile(
'remove-foo.txt.ejs',
"<%= getPackageManagerRemoveScript('foo') %>",
)
await templateFile(
'run-dev.txt.ejs',
"<%= getPackageManagerRunScript('dev') %>",
Expand All @@ -173,6 +177,7 @@ describe('createTemplateFile', () => {

expect(output.files['/test/foo.txt']).toEqual('pnpm add foo')
expect(output.files['/test/foo-dev.txt']).toEqual('pnpm add foo --dev')
expect(output.files['/test/remove-foo.txt']).toEqual('pnpm remove foo')
expect(output.files['/test/run-dev.txt']).toEqual('pnpm dev')
})

Expand Down