cistack 3.2.0 → 4.0.0

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.
@@ -13,7 +13,9 @@ class ReleaseGenerator {
13
13
  this.config = config; // full detected + merged stack config
14
14
  this.projectPath = projectPath;
15
15
  this.primaryLang = (config.languages && config.languages[0]) || { name: 'JavaScript', packageManager: 'npm', nodeVersion: '20' };
16
+ this.lockFiles = new Set(config.lockFiles || []);
16
17
  this.extraConfig = config._config || {}; // raw cistack.config.js
18
+ this.defaultBranch = config.defaultBranch || config.currentBranch || null;
17
19
  }
18
20
 
19
21
  generate() {
@@ -25,12 +27,12 @@ class ReleaseGenerator {
25
27
  const nodeVersion = lang.nodeVersion || '20';
26
28
 
27
29
  const runCmd = (script) =>
28
- pm === 'yarn' ? `yarn ${script}` : pm === 'pnpm' ? `pnpm ${script}` : `npm run ${script}`;
30
+ pm === 'yarn' ? `yarn run ${script}` : pm === 'pnpm' ? `pnpm run ${script}` : pm === 'bun' ? `bun run ${script}` : `npm run ${script}`;
29
31
 
30
32
  const installCmd =
31
- pm === 'npm' ? 'npm ci' :
32
- pm === 'yarn' ? 'yarn install --frozen-lockfile' :
33
- pm === 'pnpm' ? 'pnpm install --frozen-lockfile' :
33
+ pm === 'npm' ? (this.lockFiles.has('package-lock.json') ? 'npm ci' : 'npm install') :
34
+ pm === 'yarn' ? (this.lockFiles.has('yarn.lock') ? 'yarn install --frozen-lockfile' : 'yarn install') :
35
+ pm === 'pnpm' ? (this.lockFiles.has('pnpm-lock.yaml') ? 'pnpm install --frozen-lockfile' : 'pnpm install') :
34
36
  'bun install';
35
37
 
36
38
  // ── common setup steps ────────────────────────────────────────────────
@@ -41,13 +43,16 @@ class ReleaseGenerator {
41
43
  if (pm === 'pnpm') {
42
44
  setupSteps.push({ name: 'Install pnpm', uses: 'pnpm/action-setup@v3', with: { version: 'latest' } });
43
45
  }
46
+ if (pm === 'bun') {
47
+ setupSteps.push({ name: 'Set up Bun', uses: 'oven-sh/setup-bun@v2', with: { 'bun-version': 'latest' } });
48
+ }
44
49
 
45
50
  setupSteps.push({
46
51
  name: 'Set up Node.js',
47
52
  uses: 'actions/setup-node@v4',
48
53
  with: {
49
54
  'node-version': nodeVersion,
50
- cache: pm === 'yarn' ? 'yarn' : pm === 'pnpm' ? 'pnpm' : 'npm',
55
+ cache: pm === 'yarn' ? 'yarn' : pm === 'pnpm' ? 'pnpm' : pm === 'npm' ? 'npm' : undefined,
51
56
  ...(this.release.publishToNpm ? { 'registry-url': 'https://registry.npmjs.org' } : {}),
52
57
  },
53
58
  });
@@ -83,7 +88,7 @@ class ReleaseGenerator {
83
88
  name: 'Create Release PR or Publish',
84
89
  uses: 'changesets/action@v1',
85
90
  with: {
86
- publish: runCmd('release'),
91
+ publish: this.release.command || runCmd('release'),
87
92
  title: 'chore: version packages',
88
93
  commit: 'chore: version packages',
89
94
  },
@@ -139,7 +144,7 @@ class ReleaseGenerator {
139
144
  default: {
140
145
  releaseSteps.push({
141
146
  name: '🚀 Release',
142
- run: this.release.command || 'npm run release',
147
+ run: this.release.command || runCmd('release'),
143
148
  env: envVars,
144
149
  });
145
150
  }
@@ -149,7 +154,7 @@ class ReleaseGenerator {
149
154
  ? `# Required secrets: ${requiredSecrets.filter((s) => s !== 'GITHUB_TOKEN').join(', ')}\n# Add these at: Settings → Secrets and Variables → Actions\n\n`
150
155
  : '';
151
156
 
152
- const branches = (this.extraConfig.branches) || ['main', 'master'];
157
+ const branches = this._resolveBranches(['main', 'master']);
153
158
 
154
159
  const workflow = {
155
160
  name: 'Release',
@@ -166,8 +171,8 @@ class ReleaseGenerator {
166
171
  release: {
167
172
  name: `🏷️ Release (${tool})`,
168
173
  'runs-on': 'ubuntu-latest',
169
- // Only run on the default branch, not every push in a monorepo etc.
170
- if: "github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master'",
174
+ // Only run on the configured branches, not every push in a monorepo etc.
175
+ if: branches.map(b => `github.ref == 'refs/heads/${b}'`).join(' || '),
171
176
  steps: [...setupSteps, ...releaseSteps],
172
177
  },
173
178
  },
@@ -190,6 +195,16 @@ class ReleaseGenerator {
190
195
  raw,
191
196
  };
192
197
  }
198
+
199
+ _resolveBranches(fallback) {
200
+ if (Array.isArray(this.extraConfig.branches) && this.extraConfig.branches.length > 0) {
201
+ return [...new Set(this.extraConfig.branches)];
202
+ }
203
+ if (this.defaultBranch) {
204
+ return [this.defaultBranch];
205
+ }
206
+ return fallback;
207
+ }
193
208
  }
194
209
 
195
210
  module.exports = ReleaseGenerator;