feat: complete external module lifecycle SDK

This commit is contained in:
reaper
2026-08-14 20:50:08 -05:00
parent d3849acdd3
commit f42c722026
15 changed files with 239 additions and 56 deletions
+20
View File
@@ -0,0 +1,20 @@
'use strict'
/* eslint-disable @typescript-eslint/no-require-imports */
const { cpSync, existsSync, readFileSync, writeFileSync } = require('fs')
const { join, resolve } = require('path')
const id = String(process.argv[2] || '').toLowerCase()
if (!/^[a-z][a-z0-9-]{1,63}$/.test(id)) {
throw new Error('Usage: npm run module:new -- <module-id> [Display Name]')
}
const root = resolve(__dirname, '..')
const destination = join(root, 'packages', `aurora-module-${id}`)
if (existsSync(destination)) throw new Error(`Module already exists: ${destination}`)
cpSync(join(root, 'templates', 'aurora-module'), destination, { recursive: true })
const manifestPath = join(destination, 'manifest.json')
const manifest = JSON.parse(readFileSync(manifestPath, 'utf8'))
manifest.id = id
manifest.name = process.argv[3] || id.split('-').map((part) => part[0].toUpperCase() + part.slice(1)).join(' ')
writeFileSync(manifestPath, `${JSON.stringify(manifest, null, 2)}\n`)
process.stdout.write(`Created ${manifest.name} at ${destination}\n`)