-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Stephen Hanson
committed
Oct 29, 2023
1 parent
8fb926a
commit 76744a4
Showing
13 changed files
with
101 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { vi } from 'vitest'; | ||
|
||
export const spawnSync = vi.fn(); | ||
export const execSync = vi.fn(); | ||
export const exec = vi.fn(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export default { | ||
chdir: vi.fn(), | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { confirm } from '@inquirer/prompts'; | ||
import { vol } from 'memfs'; | ||
import { Mock, afterEach, test, vi } from 'vitest'; | ||
import print from '../../util/print'; | ||
import { createApp } from '../createApp'; | ||
|
||
vi.mock('@inquirer/prompts', () => ({ | ||
confirm: vi.fn(), | ||
})); | ||
vi.mock('../../util/addDependency'); | ||
vi.mock('../../util/print', () => ({ | ||
// __esModule: true, | ||
default: vi.fn(), | ||
})); | ||
|
||
afterEach(() => { | ||
vol.reset(); | ||
(print as Mock).mockReset(); | ||
}); | ||
|
||
test("doesn't error", async () => { | ||
(confirm as Mock).mockResolvedValueOnce(true); | ||
vi.spyOn(process, 'chdir').mockImplementation(() => { | ||
const json = { | ||
'package.json': '{ "dependencies": {}, "devDependencies": {} }', | ||
}; | ||
vol.fromJSON(json, './'); | ||
}); | ||
await createApp('MyApp'); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,20 @@ | ||
import chalk from 'chalk'; | ||
import { log } from 'console'; | ||
import fs from 'fs-extra'; | ||
import path from 'path'; | ||
import { URL, fileURLToPath } from 'url'; | ||
import print from '../util/print'; | ||
|
||
const dirname = fileURLToPath(new URL('.', import.meta.url)); | ||
|
||
export default async function createScaffold() { | ||
console.log(chalk.bold('👖 Creating directory structure')); | ||
console.log(` | ||
print(chalk.bold('👖 Creating directory structure')); | ||
print(` | ||
src/ | ||
components/ | ||
util/ | ||
hooks/ | ||
test/ | ||
`); | ||
fs.copySync(path.join(dirname, 'templates', 'scaffold', 'src'), './src'); | ||
log('✅ Created directories'); | ||
print('✅ Created directories'); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import { test } from 'vitest'; | ||
import printWelcome from './printWelcome'; | ||
|
||
test('sdf', () => { | ||
printWelcome(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import chalk from 'chalk'; | ||
import print from '../print'; | ||
|
||
export default function printWelcome() { | ||
print(chalk.bold('\n\n\t👖 thoughtbelt 👖\n')); | ||
print( | ||
'Perform project setup and redundant tasks\n without your pants falling down!\n\n', | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { vi } from 'vitest'; | ||
|
||
vi.mock('child_process'); | ||
vi.mock('fs-extra'); | ||
vi.mock('../../util/print', () => ({ | ||
// __esModule: true, | ||
default: vi.fn(), | ||
})); |