Skip to content

Commit

Permalink
fix(create)!: update types and arguments passed to run (#889)
Browse files Browse the repository at this point in the history
  • Loading branch information
marcusrbrown authored Jan 23, 2025
1 parent 144f363 commit 50ab1d2
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 30 deletions.
6 changes: 6 additions & 0 deletions .changeset/hot-goats-confess.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@bfra.me/create": minor
---

Update types and call to `run`.

19 changes: 11 additions & 8 deletions packages/create/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,17 @@ export async function createPackage(options: CreatePackageOptions) {
// Create target directory
await fs.mkdir(targetDir, {recursive: true})

await run(targetDir, {
templates: [
{
name: 'default',
// Point to the template directory
url: `${templateDir}`,
},
],
await run({
projectPath: targetDir,
config: {
templates: [
{
name: 'default',
// Point to the template directory
url: `${templateDir}`,
},
],
},
})

console.log(`Package created successfully.`)

Check warning on line 34 in packages/create/src/index.ts

View workflow job for this annotation

GitHub Actions / CI

Unexpected console statement. Only these console methods are allowed: warn, error
Expand Down
2 changes: 1 addition & 1 deletion packages/create/src/types.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type {run} from '@sxzz/create'
import type {Prettify} from 'ts-essentials'

export type Config = Prettify<NonNullable<Parameters<typeof run>[1]>>
export type Config = Prettify<NonNullable<Parameters<typeof run>[0]>>

export interface CreatePackageOptions {
template?: string
Expand Down
51 changes: 30 additions & 21 deletions packages/create/test/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,16 @@ describe('createPackage', () => {
expect(fs.mkdir).toHaveBeenCalledWith('/test/output', {recursive: true})

// Verify run was called with correct arguments
expect(run).toHaveBeenCalledWith('/test/output', {
templates: [
{
name: 'default',
url: expect.stringContaining('/templates/default'),
},
],
expect(run).toHaveBeenCalledWith({
config: {
templates: [
{
name: 'default',
url: expect.stringContaining('/templates/default'),
},
],
},
projectPath: '/test/output',
})
})

Expand All @@ -54,13 +57,16 @@ describe('createPackage', () => {
await createPackage(options)

expect(fs.mkdir).toHaveBeenCalledWith('/test/output', {recursive: true})
expect(run).toHaveBeenCalledWith('/test/output', {
templates: [
{
name: 'default',
url: expect.stringContaining('/templates/custom'),
},
],
expect(run).toHaveBeenCalledWith({
config: {
templates: [
{
name: 'default',
url: expect.stringContaining('/templates/custom'),
},
],
},
projectPath: '/test/output',
})
})

Expand All @@ -71,13 +77,16 @@ describe('createPackage', () => {
await createPackage(options)

expect(fs.mkdir).toHaveBeenCalledWith(cwd, {recursive: true})
expect(run).toHaveBeenCalledWith(cwd, {
templates: [
{
name: 'default',
url: expect.stringContaining('/templates/default'),
},
],
expect(run).toHaveBeenCalledWith({
config: {
templates: [
{
name: 'default',
url: expect.stringContaining('/templates/default'),
},
],
},
projectPath: cwd,
})
})

Expand Down

0 comments on commit 50ab1d2

Please sign in to comment.