diff --git a/package.json b/package.json index f103b2c..e294c86 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,10 @@ "c8": "./dist/index.js" }, "exports": { - "./runtime": "./dist/runtime.js" + "./runtime": { + "types": "./dist/runtime.d.ts", + "default": "./dist/runtime.js" + } }, "files": [ "dist", diff --git a/src/commands/plugins.ts b/src/commands/plugins.ts index 6cdf974..55c68ee 100644 --- a/src/commands/plugins.ts +++ b/src/commands/plugins.ts @@ -678,8 +678,8 @@ export async function initPlugin(pluginName?: string): Promise { agents ); - // Create .gitignore - writeFileSync(join(pluginDir, '.gitignore'), getTemplate('.gitignore')); + // Create .gitignore (stored as 'gitignore' to survive npm publish) + writeFileSync(join(pluginDir, '.gitignore'), getTemplate('gitignore')); logger.success('Plugin scaffolding created successfully!'); const nextSteps = renderTemplate('init-plugin-next-steps.txt', templateVars); diff --git a/src/templates/.gitignore b/src/templates/gitignore similarity index 100% rename from src/templates/.gitignore rename to src/templates/gitignore diff --git a/src/templates/package.json b/src/templates/package.json index a7caea5..743cb59 100644 --- a/src/templates/package.json +++ b/src/templates/package.json @@ -16,7 +16,8 @@ "watch": "tsc --watch" }, "devDependencies": { - "typescript": "^5.0.0", - "@types/node": "^22.0.0" + "@camunda8/cli": "*", + "@types/node": "^22.0.0", + "typescript": "^5.0.0" } } diff --git a/src/templates/tsconfig.json b/src/templates/tsconfig.json index 7ae8065..83da9f7 100644 --- a/src/templates/tsconfig.json +++ b/src/templates/tsconfig.json @@ -1,8 +1,8 @@ { "compilerOptions": { "target": "ES2022", - "module": "ES2022", - "moduleResolution": "node", + "module": "NodeNext", + "moduleResolution": "NodeNext", "outDir": "dist", "rootDir": "./src", "strict": true, diff --git a/tests/integration/plugin-lifecycle.test.ts b/tests/integration/plugin-lifecycle.test.ts index a77ef34..a9f5cdb 100644 --- a/tests/integration/plugin-lifecycle.test.ts +++ b/tests/integration/plugin-lifecycle.test.ts @@ -296,6 +296,44 @@ describe('Plugin Lifecycle Integration Tests', () => { } } }); + + test('init plugin should scaffold all required files', () => { + const name = 'test-init-files'; + const dir = join(process.cwd(), `c8ctl-${name}`); + + if (existsSync(dir)) { + rmSync(dir, { recursive: true, force: true }); + } + + try { + const output = execSync(`node src/index.ts init plugin ${name}`, { + cwd: process.cwd(), + encoding: 'utf-8', + timeout: 5000, + }); + + assert.ok(output.includes('Plugin scaffolding created successfully'), + 'Init command should succeed'); + + const expectedFiles = [ + 'package.json', + 'tsconfig.json', + 'c8ctl-plugin.js', + 'README.md', + 'AGENTS.md', + '.gitignore', + join('src', 'c8ctl-plugin.ts'), + ]; + + for (const file of expectedFiles) { + assert.ok(existsSync(join(dir, file)), `${file} should exist after init`); + } + } finally { + if (existsSync(dir)) { + rmSync(dir, { recursive: true, force: true }); + } + } + }); test('should complete full plugin lifecycle with init, build, load, execute, and help', async () => { const scaffoldPluginName = 'test-scaffold';