@regardio/dev 1.16.3 → 1.17.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/dist/bin/ship/production.js +11 -16
- package/dist/bin/ship/staging.js +2 -1
- package/package.json +1 -1
- package/src/bin/ship/production.ts +28 -34
- package/src/bin/ship/staging.ts +8 -1
|
@@ -31,9 +31,10 @@ if (!branchExists('production')) {
|
|
|
31
31
|
+ ' git checkout -b production && git push -u origin production');
|
|
32
32
|
process.exit(1);
|
|
33
33
|
}
|
|
34
|
-
|
|
34
|
+
git('pull', '--ff-only', 'origin', 'main');
|
|
35
|
+
const ahead = gitRead('log', 'origin/production..HEAD', '--oneline');
|
|
35
36
|
if (!ahead) {
|
|
36
|
-
console.error('
|
|
37
|
+
console.error('main is already in sync with production. Nothing to ship.');
|
|
37
38
|
process.exit(1);
|
|
38
39
|
}
|
|
39
40
|
console.log('\nCommits to be shipped to production:');
|
|
@@ -48,16 +49,12 @@ if (!confirm(`\nShip ${packageName} as a ${bumpType} release?`)) {
|
|
|
48
49
|
console.log('Aborted.');
|
|
49
50
|
process.exit(0);
|
|
50
51
|
}
|
|
51
|
-
console.log('\
|
|
52
|
-
git('checkout', 'staging');
|
|
53
|
-
git('pull', '--ff-only', 'origin', 'staging');
|
|
54
|
-
console.log('\nRunning quality checks on staging...');
|
|
52
|
+
console.log('\nRunning quality checks on main...');
|
|
55
53
|
try {
|
|
56
54
|
runQualityChecks();
|
|
57
55
|
}
|
|
58
56
|
catch {
|
|
59
|
-
console.error('\nQuality checks failed on
|
|
60
|
-
git('checkout', 'main');
|
|
57
|
+
console.error('\nQuality checks failed on main. Fix issues before shipping.');
|
|
61
58
|
process.exit(1);
|
|
62
59
|
}
|
|
63
60
|
console.log('✅ Quality checks passed');
|
|
@@ -86,19 +83,17 @@ catch {
|
|
|
86
83
|
}
|
|
87
84
|
git('add', '-A');
|
|
88
85
|
git('commit', '-m', `chore(release): ${packageName}@${newVersion}`, '-m', changeBody);
|
|
89
|
-
console.log('\nMerging
|
|
86
|
+
console.log('\nMerging main into production...');
|
|
90
87
|
git('checkout', 'production');
|
|
91
88
|
git('pull', '--ff-only', 'origin', 'production');
|
|
92
|
-
git('merge', '--ff-only', '
|
|
89
|
+
git('merge', '--ff-only', 'main');
|
|
93
90
|
git('push', 'origin', 'production');
|
|
94
|
-
console.log('\nSyncing
|
|
95
|
-
git('checkout', 'main');
|
|
96
|
-
git('pull', '--ff-only', 'origin', 'main');
|
|
97
|
-
git('merge', '--ff-only', 'production');
|
|
98
|
-
git('push', 'origin', 'main');
|
|
91
|
+
console.log('\nSyncing staging with production...');
|
|
99
92
|
git('checkout', 'staging');
|
|
100
|
-
git('
|
|
93
|
+
git('pull', '--ff-only', 'origin', 'staging');
|
|
94
|
+
git('merge', '--ff-only', 'production');
|
|
101
95
|
git('push', 'origin', 'staging');
|
|
102
96
|
git('checkout', 'main');
|
|
97
|
+
git('push', 'origin', 'main');
|
|
103
98
|
console.log(`\n✅ Shipped ${packageName}@${newVersion} to production`);
|
|
104
99
|
console.log('You are on main and ready to keep working.');
|
package/dist/bin/ship/staging.js
CHANGED
|
@@ -59,4 +59,5 @@ git('push', 'origin', 'staging');
|
|
|
59
59
|
git('checkout', 'main');
|
|
60
60
|
git('push', 'origin', 'main');
|
|
61
61
|
console.log('\n✅ Changes deployed to staging');
|
|
62
|
-
console.log('Run ship-production <patch|minor|major> when ready to
|
|
62
|
+
console.log('Run ship-production <patch|minor|major> when ready to ship to production.');
|
|
63
|
+
console.log('(Or ship directly from main to production without using ship-staging first.)');
|
package/package.json
CHANGED
|
@@ -1,26 +1,26 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
/**
|
|
3
|
-
* ship-production: Version and promote
|
|
3
|
+
* ship-production: Version and promote main to production following the GitLab workflow.
|
|
4
4
|
*
|
|
5
5
|
* Usage: ship-production <patch|minor|major>
|
|
6
6
|
*
|
|
7
7
|
* GitLab workflow:
|
|
8
|
-
*
|
|
8
|
+
* main → (version bump commit) → production → staging → main
|
|
9
9
|
*
|
|
10
10
|
* Versioning is intentionally deferred to this step so that version numbers
|
|
11
11
|
* only ever correspond to production-verified code.
|
|
12
12
|
*
|
|
13
13
|
* This script:
|
|
14
14
|
* 1. Ensures the current branch is main and the working tree is clean
|
|
15
|
-
* 2. Verifies
|
|
16
|
-
* 3. Runs quality checks on
|
|
15
|
+
* 2. Verifies main is ahead of production (there is something to ship)
|
|
16
|
+
* 3. Runs quality checks on main
|
|
17
17
|
* 4. Bumps the version in package.json
|
|
18
|
-
* 5. Collects change descriptions from git log between production and
|
|
18
|
+
* 5. Collects change descriptions from git log between production and main
|
|
19
19
|
* 6. Updates CHANGELOG.md
|
|
20
|
-
* 7. Commits the version bump on
|
|
21
|
-
* 8. Merges
|
|
22
|
-
* 9. Merges production
|
|
23
|
-
* 10.
|
|
20
|
+
* 7. Commits the version bump on main
|
|
21
|
+
* 8. Merges main into production (fast-forward) and pushes
|
|
22
|
+
* 9. Merges production into staging to keep it in sync
|
|
23
|
+
* 10. Merges production back into main to ensure consistency
|
|
24
24
|
* 11. Returns to main
|
|
25
25
|
*/
|
|
26
26
|
import { existsSync, readFileSync, writeFileSync } from 'node:fs';
|
|
@@ -85,11 +85,12 @@ if (!branchExists('production')) {
|
|
|
85
85
|
}
|
|
86
86
|
|
|
87
87
|
// ---------------------------------------------------------------------------
|
|
88
|
-
// Verify
|
|
88
|
+
// Verify main has commits not yet in production
|
|
89
89
|
// ---------------------------------------------------------------------------
|
|
90
|
-
|
|
90
|
+
git('pull', '--ff-only', 'origin', 'main');
|
|
91
|
+
const ahead = gitRead('log', 'origin/production..HEAD', '--oneline');
|
|
91
92
|
if (!ahead) {
|
|
92
|
-
console.error('
|
|
93
|
+
console.error('main is already in sync with production. Nothing to ship.');
|
|
93
94
|
process.exit(1);
|
|
94
95
|
}
|
|
95
96
|
|
|
@@ -114,24 +115,19 @@ if (!confirm(`\nShip ${packageName} as a ${bumpType} release?`)) {
|
|
|
114
115
|
}
|
|
115
116
|
|
|
116
117
|
// ---------------------------------------------------------------------------
|
|
117
|
-
// Quality checks on
|
|
118
|
+
// Quality checks on main
|
|
118
119
|
// ---------------------------------------------------------------------------
|
|
119
|
-
console.log('\
|
|
120
|
-
git('checkout', 'staging');
|
|
121
|
-
git('pull', '--ff-only', 'origin', 'staging');
|
|
122
|
-
|
|
123
|
-
console.log('\nRunning quality checks on staging...');
|
|
120
|
+
console.log('\nRunning quality checks on main...');
|
|
124
121
|
try {
|
|
125
122
|
runQualityChecks();
|
|
126
123
|
} catch {
|
|
127
|
-
console.error('\nQuality checks failed on
|
|
128
|
-
git('checkout', 'main');
|
|
124
|
+
console.error('\nQuality checks failed on main. Fix issues before shipping.');
|
|
129
125
|
process.exit(1);
|
|
130
126
|
}
|
|
131
127
|
console.log('✅ Quality checks passed');
|
|
132
128
|
|
|
133
129
|
// ---------------------------------------------------------------------------
|
|
134
|
-
// Read version from
|
|
130
|
+
// Read version from main package.json and bump
|
|
135
131
|
// ---------------------------------------------------------------------------
|
|
136
132
|
const packageJson = JSON.parse(readFileSync(packageJsonPath, 'utf-8')) as {
|
|
137
133
|
name: string;
|
|
@@ -180,36 +176,34 @@ try {
|
|
|
180
176
|
}
|
|
181
177
|
|
|
182
178
|
// ---------------------------------------------------------------------------
|
|
183
|
-
// Commit version bump on
|
|
179
|
+
// Commit version bump on main
|
|
184
180
|
// ---------------------------------------------------------------------------
|
|
185
181
|
git('add', '-A');
|
|
186
182
|
git('commit', '-m', `chore(release): ${packageName}@${newVersion}`, '-m', changeBody);
|
|
187
183
|
|
|
188
184
|
// ---------------------------------------------------------------------------
|
|
189
|
-
// Merge
|
|
185
|
+
// Merge main → production
|
|
190
186
|
// ---------------------------------------------------------------------------
|
|
191
|
-
console.log('\nMerging
|
|
187
|
+
console.log('\nMerging main into production...');
|
|
192
188
|
git('checkout', 'production');
|
|
193
189
|
git('pull', '--ff-only', 'origin', 'production');
|
|
194
|
-
git('merge', '--ff-only', '
|
|
190
|
+
git('merge', '--ff-only', 'main');
|
|
195
191
|
git('push', 'origin', 'production');
|
|
196
192
|
|
|
197
193
|
// ---------------------------------------------------------------------------
|
|
198
|
-
//
|
|
194
|
+
// Sync staging with production
|
|
199
195
|
// ---------------------------------------------------------------------------
|
|
200
|
-
console.log('\nSyncing
|
|
201
|
-
git('checkout', '
|
|
202
|
-
git('pull', '--ff-only', 'origin', '
|
|
196
|
+
console.log('\nSyncing staging with production...');
|
|
197
|
+
git('checkout', 'staging');
|
|
198
|
+
git('pull', '--ff-only', 'origin', 'staging');
|
|
203
199
|
git('merge', '--ff-only', 'production');
|
|
204
|
-
git('push', 'origin', '
|
|
200
|
+
git('push', 'origin', 'staging');
|
|
205
201
|
|
|
206
202
|
// ---------------------------------------------------------------------------
|
|
207
|
-
//
|
|
203
|
+
// Return to main and push
|
|
208
204
|
// ---------------------------------------------------------------------------
|
|
209
|
-
git('checkout', 'staging');
|
|
210
|
-
git('merge', '--ff-only', 'main');
|
|
211
|
-
git('push', 'origin', 'staging');
|
|
212
205
|
git('checkout', 'main');
|
|
206
|
+
git('push', 'origin', 'main');
|
|
213
207
|
|
|
214
208
|
console.log(`\n✅ Shipped ${packageName}@${newVersion} to production`);
|
|
215
209
|
console.log('You are on main and ready to keep working.');
|
package/src/bin/ship/staging.ts
CHANGED
|
@@ -7,6 +7,12 @@
|
|
|
7
7
|
* GitLab workflow:
|
|
8
8
|
* main → staging (staging deploy, no version bump yet)
|
|
9
9
|
*
|
|
10
|
+
* This script is OPTIONAL. You can ship directly to production using ship-production,
|
|
11
|
+
* which will automatically sync staging afterward.
|
|
12
|
+
*
|
|
13
|
+
* Use ship-staging when you want to test changes in a staging environment before
|
|
14
|
+
* shipping to production. Otherwise, skip this step and use ship-production directly.
|
|
15
|
+
*
|
|
10
16
|
* Versioning happens at ship time (ship-production), not here.
|
|
11
17
|
* This keeps version numbers reserved for production-verified code.
|
|
12
18
|
*
|
|
@@ -120,4 +126,5 @@ git('checkout', 'main');
|
|
|
120
126
|
git('push', 'origin', 'main');
|
|
121
127
|
|
|
122
128
|
console.log('\n✅ Changes deployed to staging');
|
|
123
|
-
console.log('Run ship-production <patch|minor|major> when ready to
|
|
129
|
+
console.log('Run ship-production <patch|minor|major> when ready to ship to production.');
|
|
130
|
+
console.log('(Or ship directly from main to production without using ship-staging first.)');
|