create-agentic-pdlc 3.0.0 → 3.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/tests/cli.test.js CHANGED
@@ -1,5 +1,9 @@
1
1
  const { describe, it } = require('node:test');
2
2
  const assert = require('node:assert/strict');
3
+ const os = require('os');
4
+ const fs = require('fs');
5
+ const path = require('path');
6
+ const crypto = require('crypto');
3
7
 
4
8
  const { resolveMode } = require('../bin/cli.js');
5
9
 
@@ -30,3 +34,85 @@ describe('buildFullClaudeContent', () => {
30
34
  assert.ok(result.includes('## Extra'));
31
35
  });
32
36
  });
37
+
38
+ describe('setActionsVariable', () => {
39
+ it('calls PATCH first', () => {
40
+ const calls = [];
41
+ const execFn = (cmd, args, _opts) => { calls.push([...args]); };
42
+ const { setActionsVariable } = require('../bin/cli.js');
43
+ setActionsVariable('owner/repo', 'PROJECT_ID', 'PVT_abc', execFn);
44
+ assert.equal(calls.length, 1);
45
+ assert.ok(calls[0].includes('--method'));
46
+ assert.ok(calls[0].includes('PATCH'));
47
+ assert.ok(calls[0].some(a => a.includes('PROJECT_ID')));
48
+ assert.ok(calls[0].some(a => a.includes('PVT_abc')));
49
+ });
50
+
51
+ it('falls back to POST on 404', () => {
52
+ const calls = [];
53
+ let callCount = 0;
54
+ const execFn = (cmd, args, _opts) => {
55
+ calls.push([...args]);
56
+ callCount++;
57
+ if (callCount === 1) {
58
+ const err = new Error('Not Found');
59
+ err.stderr = Buffer.from('Not Found');
60
+ throw err;
61
+ }
62
+ };
63
+ const { setActionsVariable } = require('../bin/cli.js');
64
+ setActionsVariable('owner/repo', 'PROJECT_ID', 'PVT_abc', execFn);
65
+ assert.equal(calls.length, 2);
66
+ assert.ok(calls[0].includes('PATCH'));
67
+ assert.ok(calls[0].some(a => a.includes('PVT_abc')));
68
+ assert.ok(calls[1].includes('POST'));
69
+ assert.ok(calls[1].some(a => a.includes('PVT_abc')));
70
+ });
71
+
72
+ it('throws on 403', () => {
73
+ const execFn = () => {
74
+ const err = new Error('Forbidden');
75
+ err.stderr = Buffer.from('Forbidden');
76
+ throw err;
77
+ };
78
+ const { setActionsVariable } = require('../bin/cli.js');
79
+ assert.throws(
80
+ () => setActionsVariable('owner/repo', 'PROJECT_ID', 'PVT_abc', execFn),
81
+ /Forbidden/
82
+ );
83
+ });
84
+ });
85
+
86
+ describe('scaffoldLiteTemplates', () => {
87
+ it('copies CLAUDE.md and AGENTS.md but excludes .github/workflows', () => {
88
+ const { scaffoldLiteTemplates } = require('../bin/cli.js');
89
+ const src = path.join(__dirname, '..');
90
+ const tmp = path.join(os.tmpdir(), `pdlc-lite-${crypto.randomBytes(4).toString('hex')}`);
91
+ try {
92
+ scaffoldLiteTemplates(src, tmp);
93
+ const base = path.join(tmp, '.agentic-pdlc', 'templates');
94
+ assert.ok(fs.existsSync(path.join(base, 'CLAUDE.md')), 'CLAUDE.md should exist');
95
+ assert.ok(fs.existsSync(path.join(base, 'AGENTS.md')), 'AGENTS.md should exist');
96
+ assert.ok(!fs.existsSync(path.join(base, '.github', 'workflows')), '.github/workflows must not exist in lite');
97
+ } finally {
98
+ fs.rmSync(tmp, { recursive: true, force: true });
99
+ }
100
+ });
101
+ });
102
+
103
+ describe('scaffoldFullTemplates', () => {
104
+ it('copies .github/workflows with at least one yml file', () => {
105
+ const { scaffoldFullTemplates } = require('../bin/cli.js');
106
+ const src = path.join(__dirname, '..');
107
+ const tmp = path.join(os.tmpdir(), `pdlc-full-${crypto.randomBytes(4).toString('hex')}`);
108
+ try {
109
+ scaffoldFullTemplates(src, tmp, null, null, {}, 'owner', 'repo');
110
+ const wfDir = path.join(tmp, '.agentic-pdlc', 'templates', '.github', 'workflows');
111
+ assert.ok(fs.existsSync(wfDir), '.github/workflows should exist in full');
112
+ const ymls = fs.readdirSync(wfDir).filter(f => f.endsWith('.yml'));
113
+ assert.ok(ymls.length > 0, 'should contain at least one .yml file');
114
+ } finally {
115
+ fs.rmSync(tmp, { recursive: true, force: true });
116
+ }
117
+ });
118
+ });