Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: update and simplify create-plugin script #675

Merged
merged 1 commit into from
Jul 25, 2024
Merged
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
32 changes: 3 additions & 29 deletions scripts/create-plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ console.log('📦 initialising package')
execSync('npm init -y --scope @dotcom-tool-kit')

console.log('📥 installing dependencies')
execSync('npm install @dotcom-tool-kit/types')
execSync('npm install @dotcom-tool-kit/base')

console.log('🔣 adding metadata to package.json')

Expand Down Expand Up @@ -53,7 +53,7 @@ const tsconfig = {
},
references: [
{
path: '../../lib/types'
path: '../../lib/base'
}
],
include: ['src/**/*']
Expand All @@ -62,38 +62,12 @@ const tsconfig = {
fs.writeFileSync('tsconfig.json', JSON.stringify(tsconfig, null, 2))

console.log('📄 adding empty toolkit config')
fs.writeFileSync('.toolkitrc.yml', '')
fs.writeFileSync('.toolkitrc.yml', 'version: 2\n')

console.log('🔗 adding reference to root tsconfig')
const rootTsconfig = JSON.parse(fs.readFileSync('../../tsconfig.json'))
rootTsconfig.references.push({ path: directory })

fs.writeFileSync('../../tsconfig.json', JSON.stringify(rootTsconfig, null, 2))

console.log(`🏗 scaffolding task ${camelCaseName}`)
fs.mkdirSync('src/tasks', { recursive: true })

fs.writeFileSync(
`src/tasks/${name}.ts`,
`import { Task } from '@dotcom-tool-kit/types'

export default class ${camelCaseName} extends Task {
static description = ''

async run(): Promise<void> {

}
}`
)

fs.writeFileSync(
'src/index.ts',
`import ${camelCaseName} from './tasks/${name}'

export const tasks = [
${camelCaseName}
]
`
)

console.log('🌊 byeee~')