Skip to content

Commit

Permalink
Merge pull request #675 from Financial-Times/create-plugin-fixes
Browse files Browse the repository at this point in the history
build: update and simplify create-plugin script
  • Loading branch information
apaleslimghost authored and ivomurrell committed Sep 5, 2024
2 parents 007728c + 3c9e454 commit 373de92
Showing 1 changed file with 3 additions and 29 deletions.
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~')

0 comments on commit 373de92

Please sign in to comment.