-
-
Notifications
You must be signed in to change notification settings - Fork 5
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
Showing
7 changed files
with
71 additions
and
64 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 |
---|---|---|
|
@@ -13,5 +13,7 @@ | |
.github | ||
.changeset | ||
|
||
*.hbs | ||
|
||
# Files | ||
pnpm-lock.yaml |
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,3 +1,3 @@ | ||
packages: | ||
- turbo | ||
- 'packages/*' | ||
- turbo | ||
- 'packages/*' |
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 |
---|---|---|
|
@@ -3,4 +3,4 @@ | |
"allowJs": true | ||
}, | ||
"extends": "./tsconfig.base.json" | ||
} | ||
} |
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,43 +1,47 @@ | ||
import {kebabCase} from 'lodash'; | ||
import type {PlopTypes} from '@turbo/gen'; | ||
import { kebabCase } from 'lodash'; | ||
import type { PlopTypes } from '@turbo/gen'; | ||
import * as path from 'node:path'; | ||
import * as fs from 'node:fs/promises'; | ||
|
||
export default (plop: PlopTypes.NodePlopAPI, {destBasePath}: PlopTypes.PlopCfg) => { | ||
export default (plop: PlopTypes.NodePlopAPI, { destBasePath }: PlopTypes.PlopCfg) => { | ||
plop.setGenerator('vite-plugin', { | ||
description: 'Generate a new Vite plugin', | ||
prompts: [ | ||
{ | ||
name: 'name', | ||
message: 'Plugin Name:', | ||
validate: async (name) => { | ||
const packageJsonPath = path.join( | ||
destBasePath, | ||
'packages', | ||
kebabCase(name), | ||
'package.json' | ||
); | ||
|
||
plop.setGenerator('vite-plugin', { | ||
description: 'Generate a new Vite plugin', | ||
prompts: [ | ||
{ | ||
name: 'name', | ||
message: 'Plugin Name:', | ||
validate: async (name) => { | ||
const packageJsonPath = path.join(destBasePath, 'packages', kebabCase(name), 'package.json'); | ||
try { | ||
await fs.lstat(packageJsonPath); | ||
|
||
try { | ||
await fs.lstat(packageJsonPath); | ||
|
||
return `Package ${name} already exists`; | ||
} catch { | ||
return true; | ||
} | ||
} | ||
}, | ||
{ | ||
name: 'description', | ||
message: 'Description:', | ||
filter: desc => desc || undefined, | ||
transformer: desc => desc || '<empty>', | ||
}, | ||
], | ||
actions: [ | ||
{ | ||
type: 'addMany', | ||
destination: '{{ turbo.paths.root }}/packages/{{ name }}', | ||
templateFiles: `${__dirname}/templates/**/*`, | ||
base: `${__dirname}/templates`, | ||
verbose: true, | ||
} | ||
], | ||
}); | ||
} | ||
return `Package ${name} already exists`; | ||
} catch { | ||
return true; | ||
} | ||
}, | ||
}, | ||
{ | ||
name: 'description', | ||
message: 'Description:', | ||
filter: (desc) => desc || undefined, | ||
transformer: (desc) => desc || '<empty>', | ||
}, | ||
], | ||
actions: [ | ||
{ | ||
type: 'addMany', | ||
destination: '{{ turbo.paths.root }}/packages/{{ name }}', | ||
templateFiles: `${__dirname}/templates/**/*`, | ||
base: `${__dirname}/templates`, | ||
verbose: true, | ||
}, | ||
], | ||
}); | ||
}; |
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,14 +1,17 @@ | ||
import type { PlopTypes } from "@turbo/gen"; | ||
import type { PlopTypes } from '@turbo/gen'; | ||
|
||
Object.assign(console, new console.Console({ | ||
stdout: process.stdout, | ||
stderr: process.stderr, | ||
inspectOptions: { | ||
colors: true, | ||
depth: 4, | ||
}, | ||
})); | ||
Object.assign( | ||
console, | ||
new console.Console({ | ||
stdout: process.stdout, | ||
stderr: process.stderr, | ||
inspectOptions: { | ||
colors: true, | ||
depth: 4, | ||
}, | ||
}) | ||
); | ||
|
||
export default function generator(plop: PlopTypes.NodePlopAPI): void { | ||
plop.load('./app/index.ts'); | ||
plop.load('./app/index.ts'); | ||
} |