deploy-vir 0.2.9 → 0.3.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.
- package/dist/git.js +41 -52
- package/package.json +20 -18
- package/src/git.ts +54 -65
package/dist/git.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { assert, assertWrap, check } from '@augment-vir/assert';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { log, logColors } from '@augment-vir/common';
|
|
3
|
+
import { confirm } from '@inquirer/prompts';
|
|
4
4
|
import { KnownError } from './known.error.js';
|
|
5
5
|
/**
|
|
6
6
|
* Find the git remote's name, or create a new one.
|
|
@@ -54,56 +54,45 @@ export async function pushDeploy(git, { deployName, fromBranch, toBranch }, remo
|
|
|
54
54
|
if (!commitsAhead.length) {
|
|
55
55
|
throw new KnownError('No commit diff: nothing to deploy!');
|
|
56
56
|
}
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
}
|
|
70
|
-
catch (error) {
|
|
71
|
-
log.error(`Push failed: ${extractErrorMessage(error)}`);
|
|
72
|
-
/** Get commits that are on {@link toBranch} but not on {@link fromBranch}. */
|
|
73
|
-
const commitsBehind = (await git.log([
|
|
74
|
-
`${remoteName}/${fromBranch}..${remoteName}/${toBranch}`,
|
|
75
|
-
])).all;
|
|
76
|
-
if (commitsBehind.length > 0) {
|
|
77
|
-
log.info(`\nOnly on ${logColors.bold}${fromBranch}${logColors.reset}:`);
|
|
78
|
-
commitsAhead.forEach((commit, index) => {
|
|
79
|
-
log.faint(` ${index + 1}. ${commit.hash.slice(0, 7)} (${commit.author_name}) - ${commit.message}`);
|
|
80
|
-
});
|
|
81
|
-
log.info(`\nOnly on ${logColors.bold}${toBranch}${logColors.reset}:`);
|
|
82
|
-
commitsBehind.forEach((commit, index) => {
|
|
83
|
-
log.faint(` ${index + 1}. ${commit.hash.slice(0, 7)} (${commit.author_name}) - ${commit.message}`);
|
|
84
|
-
});
|
|
85
|
-
}
|
|
86
|
-
const shouldForcePush = await askQuestion(`\nDo you want to force push ${logColors.bold}${fromBranch}${logColors.reset} to ${logColors.bold}${toBranch}${logColors.reset}?\n\n${logColors.warning}This will overwrite the commits only on ${logColors.bold}${toBranch}${logColors.normalWeight}.${logColors.reset} (y/N): `, {
|
|
87
|
-
timeout: {
|
|
88
|
-
hours: 2,
|
|
89
|
-
},
|
|
57
|
+
/** Get commits that are on {@link toBranch} but not on {@link fromBranch}. */
|
|
58
|
+
const commitsBehind = (await git.log([
|
|
59
|
+
`${remoteName}/${fromBranch}..${remoteName}/${toBranch}`,
|
|
60
|
+
])).all;
|
|
61
|
+
const requiresForcePush = commitsBehind.length > 0;
|
|
62
|
+
log.info(`\n${requiresForcePush ? 'Only on' : 'Releasing from'} ${logColors.bold}${fromBranch}${logColors.reset}:`);
|
|
63
|
+
commitsAhead.forEach((commit, index) => {
|
|
64
|
+
log.faint(` ${index + 1}. ${commit.hash.slice(0, 7)} (${commit.author_name}) - ${commit.message}`);
|
|
65
|
+
});
|
|
66
|
+
if (requiresForcePush) {
|
|
67
|
+
log.info(`\nOnly on ${logColors.bold}${toBranch}${logColors.reset}:`);
|
|
68
|
+
commitsBehind.forEach((commit, index) => {
|
|
69
|
+
log.faint(` ${index + 1}. ${commit.hash.slice(0, 7)} (${commit.author_name}) - ${commit.message}`);
|
|
90
70
|
});
|
|
91
|
-
if (shouldForcePush.toLowerCase() === 'y' || shouldForcePush.toLowerCase() === 'yes') {
|
|
92
|
-
await git.push(remoteName, pushString, ['--force']);
|
|
93
|
-
log.warning(`Force pushed ${logColors.bold}${fromBranch}${logColors.reset} to ${logColors.bold}${toBranch}${logColors.reset}.`);
|
|
94
|
-
}
|
|
95
|
-
else {
|
|
96
|
-
throw new KnownError(`Deploy aborted.`);
|
|
97
|
-
}
|
|
98
|
-
return {
|
|
99
|
-
deployCommits: {
|
|
100
|
-
deployedCommits: commitsAhead,
|
|
101
|
-
overwrittenCommits: commitsBehind,
|
|
102
|
-
},
|
|
103
|
-
branchStatus: {
|
|
104
|
-
before: beforeCommit,
|
|
105
|
-
after: afterCommit,
|
|
106
|
-
},
|
|
107
|
-
};
|
|
108
71
|
}
|
|
72
|
+
const shouldPush = await confirm({
|
|
73
|
+
message: requiresForcePush
|
|
74
|
+
? `\n${logColors.warning}Do you want to force push ${logColors.bold}${fromBranch}${logColors.normalWeight} to ${logColors.bold}${toBranch}${logColors.normalWeight}?\n\nThis will overwrite the commits only on ${logColors.bold}${toBranch}${logColors.normalWeight}.${logColors.reset}?`
|
|
75
|
+
: 'Ready to deploy?',
|
|
76
|
+
default: false,
|
|
77
|
+
});
|
|
78
|
+
if (!shouldPush) {
|
|
79
|
+
throw new KnownError(`Deploy aborted.`);
|
|
80
|
+
}
|
|
81
|
+
if (requiresForcePush) {
|
|
82
|
+
await git.push(remoteName, pushString, ['--force']);
|
|
83
|
+
log.warning(`Force pushed ${logColors.bold}${fromBranch}${logColors.normalWeight} to ${logColors.bold}${toBranch}${logColors.reset}.`);
|
|
84
|
+
}
|
|
85
|
+
else {
|
|
86
|
+
await git.push(remoteName, pushString);
|
|
87
|
+
}
|
|
88
|
+
return {
|
|
89
|
+
deployCommits: {
|
|
90
|
+
deployedCommits: commitsAhead,
|
|
91
|
+
overwrittenCommits: commitsBehind,
|
|
92
|
+
},
|
|
93
|
+
branchStatus: {
|
|
94
|
+
before: beforeCommit,
|
|
95
|
+
after: afterCommit,
|
|
96
|
+
},
|
|
97
|
+
};
|
|
109
98
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "deploy-vir",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "Deploy a branch to another branch with notifications.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"deploy",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"format": "virmator format",
|
|
33
33
|
"lint": "virmator lint fix",
|
|
34
34
|
"publish": "virmator publish npm run test:all",
|
|
35
|
-
"test:all": "npm run compile &&
|
|
35
|
+
"test:all": "npm run compile && runstorm --names spelling,format,docs,deps,lint \"npm run test:spelling\" \"npm run test:format\" \"npm run test:docs\" \"npm run test:deps\" \"npm run test:lint\"",
|
|
36
36
|
"test:deps": "virmator deps check",
|
|
37
37
|
"test:docs": "virmator docs check",
|
|
38
38
|
"test:format": "virmator format check",
|
|
@@ -41,36 +41,37 @@
|
|
|
41
41
|
"test:update": "npm run test update"
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"@augment-vir/assert": "^31.
|
|
45
|
-
"@augment-vir/common": "^31.
|
|
46
|
-
"@augment-vir/node": "^31.
|
|
47
|
-
"@
|
|
44
|
+
"@augment-vir/assert": "^31.33.0",
|
|
45
|
+
"@augment-vir/common": "^31.33.0",
|
|
46
|
+
"@augment-vir/node": "^31.33.0",
|
|
47
|
+
"@inquirer/prompts": "^7.8.4",
|
|
48
|
+
"@slack/web-api": "^7.10.0",
|
|
48
49
|
"simple-git": "^3.28.0",
|
|
49
|
-
"tsx": "^4.20.
|
|
50
|
-
"url-vir": "^2.1.
|
|
50
|
+
"tsx": "^4.20.5",
|
|
51
|
+
"url-vir": "^2.1.4"
|
|
51
52
|
},
|
|
52
53
|
"devDependencies": {
|
|
53
54
|
"@eslint/eslintrc": "^3.3.1",
|
|
54
|
-
"@eslint/js": "^9.
|
|
55
|
+
"@eslint/js": "^9.34.0",
|
|
55
56
|
"@stylistic/eslint-plugin": "^5.2.3",
|
|
56
57
|
"@stylistic/eslint-plugin-ts": "^4.4.1",
|
|
57
|
-
"@types/node": "^24.
|
|
58
|
-
"@typescript-eslint/eslint-plugin": "^8.
|
|
58
|
+
"@types/node": "^24.3.0",
|
|
59
|
+
"@typescript-eslint/eslint-plugin": "^8.41.0",
|
|
59
60
|
"cspell": "^9.2.0",
|
|
60
61
|
"dependency-cruiser": "^17.0.1",
|
|
61
62
|
"esbuild": "^0.25.9",
|
|
62
|
-
"eslint": "^9.
|
|
63
|
+
"eslint": "^9.34.0",
|
|
63
64
|
"eslint-config-prettier": "^10.1.8",
|
|
64
|
-
"eslint-plugin-jsdoc": "^54.
|
|
65
|
+
"eslint-plugin-jsdoc": "^54.1.1",
|
|
65
66
|
"eslint-plugin-monorepo-cop": "^1.0.2",
|
|
66
67
|
"eslint-plugin-playwright": "^2.2.2",
|
|
67
68
|
"eslint-plugin-prettier": "^5.5.4",
|
|
68
69
|
"eslint-plugin-require-extensions": "^0.1.3",
|
|
69
|
-
"eslint-plugin-sonarjs": "^3.0.
|
|
70
|
+
"eslint-plugin-sonarjs": "^3.0.5",
|
|
70
71
|
"eslint-plugin-unicorn": "^57.0.0",
|
|
71
72
|
"istanbul-smart-text-reporter": "^1.1.5",
|
|
72
73
|
"markdown-code-example-inserter": "^3.0.3",
|
|
73
|
-
"npm-check-updates": "^18.0.
|
|
74
|
+
"npm-check-updates": "^18.0.3",
|
|
74
75
|
"prettier": "~3.3.3",
|
|
75
76
|
"prettier-plugin-interpolated-html-tags": "^2.0.1",
|
|
76
77
|
"prettier-plugin-jsdoc": "^1.3.3",
|
|
@@ -79,10 +80,11 @@
|
|
|
79
80
|
"prettier-plugin-packagejson": "^2.5.19",
|
|
80
81
|
"prettier-plugin-sort-json": "^4.1.1",
|
|
81
82
|
"prettier-plugin-toml": "^2.0.6",
|
|
82
|
-
"
|
|
83
|
+
"runstorm": "^0.6.1",
|
|
84
|
+
"typedoc": "^0.28.11",
|
|
83
85
|
"typescript": "^5.9.2",
|
|
84
|
-
"typescript-eslint": "^8.
|
|
85
|
-
"virmator": "^
|
|
86
|
+
"typescript-eslint": "^8.41.0",
|
|
87
|
+
"virmator": "^14.0.1"
|
|
86
88
|
},
|
|
87
89
|
"engines": {
|
|
88
90
|
"node": ">=22"
|
package/src/git.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {assert, assertWrap, check} from '@augment-vir/assert';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import {log, logColors} from '@augment-vir/common';
|
|
3
|
+
import {confirm} from '@inquirer/prompts';
|
|
4
4
|
import {type DefaultLogFields, type ListLogLine, type SimpleGit} from 'simple-git';
|
|
5
5
|
import {type DeployVirBranchConfig, type DeployVirRepoConfig} from './config.js';
|
|
6
6
|
import {KnownError} from './known.error.js';
|
|
@@ -134,72 +134,61 @@ export async function pushDeploy(
|
|
|
134
134
|
throw new KnownError('No commit diff: nothing to deploy!');
|
|
135
135
|
}
|
|
136
136
|
|
|
137
|
-
|
|
138
|
-
|
|
137
|
+
/** Get commits that are on {@link toBranch} but not on {@link fromBranch}. */
|
|
138
|
+
const commitsBehind = (
|
|
139
|
+
await git.log([
|
|
140
|
+
`${remoteName}/${fromBranch}..${remoteName}/${toBranch}`,
|
|
141
|
+
])
|
|
142
|
+
).all;
|
|
139
143
|
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
},
|
|
149
|
-
};
|
|
150
|
-
} catch (error) {
|
|
151
|
-
log.error(`Push failed: ${extractErrorMessage(error)}`);
|
|
152
|
-
|
|
153
|
-
/** Get commits that are on {@link toBranch} but not on {@link fromBranch}. */
|
|
154
|
-
const commitsBehind = (
|
|
155
|
-
await git.log([
|
|
156
|
-
`${remoteName}/${fromBranch}..${remoteName}/${toBranch}`,
|
|
157
|
-
])
|
|
158
|
-
).all;
|
|
159
|
-
|
|
160
|
-
if (commitsBehind.length > 0) {
|
|
161
|
-
log.info(`\nOnly on ${logColors.bold}${fromBranch}${logColors.reset}:`);
|
|
162
|
-
commitsAhead.forEach((commit, index) => {
|
|
163
|
-
log.faint(
|
|
164
|
-
` ${index + 1}. ${commit.hash.slice(0, 7)} (${commit.author_name}) - ${commit.message}`,
|
|
165
|
-
);
|
|
166
|
-
});
|
|
167
|
-
|
|
168
|
-
log.info(`\nOnly on ${logColors.bold}${toBranch}${logColors.reset}:`);
|
|
169
|
-
commitsBehind.forEach((commit, index) => {
|
|
170
|
-
log.faint(
|
|
171
|
-
` ${index + 1}. ${commit.hash.slice(0, 7)} (${commit.author_name}) - ${commit.message}`,
|
|
172
|
-
);
|
|
173
|
-
});
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
const shouldForcePush = await askQuestion(
|
|
177
|
-
`\nDo you want to force push ${logColors.bold}${fromBranch}${logColors.reset} to ${logColors.bold}${toBranch}${logColors.reset}?\n\n${logColors.warning}This will overwrite the commits only on ${logColors.bold}${toBranch}${logColors.normalWeight}.${logColors.reset} (y/N): `,
|
|
178
|
-
{
|
|
179
|
-
timeout: {
|
|
180
|
-
hours: 2,
|
|
181
|
-
},
|
|
182
|
-
},
|
|
144
|
+
const requiresForcePush = commitsBehind.length > 0;
|
|
145
|
+
|
|
146
|
+
log.info(
|
|
147
|
+
`\n${requiresForcePush ? 'Only on' : 'Releasing from'} ${logColors.bold}${fromBranch}${logColors.reset}:`,
|
|
148
|
+
);
|
|
149
|
+
commitsAhead.forEach((commit, index) => {
|
|
150
|
+
log.faint(
|
|
151
|
+
` ${index + 1}. ${commit.hash.slice(0, 7)} (${commit.author_name}) - ${commit.message}`,
|
|
183
152
|
);
|
|
153
|
+
});
|
|
184
154
|
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
155
|
+
if (requiresForcePush) {
|
|
156
|
+
log.info(`\nOnly on ${logColors.bold}${toBranch}${logColors.reset}:`);
|
|
157
|
+
commitsBehind.forEach((commit, index) => {
|
|
158
|
+
log.faint(
|
|
159
|
+
` ${index + 1}. ${commit.hash.slice(0, 7)} (${commit.author_name}) - ${commit.message}`,
|
|
189
160
|
);
|
|
190
|
-
}
|
|
191
|
-
throw new KnownError(`Deploy aborted.`);
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
return {
|
|
195
|
-
deployCommits: {
|
|
196
|
-
deployedCommits: commitsAhead,
|
|
197
|
-
overwrittenCommits: commitsBehind,
|
|
198
|
-
},
|
|
199
|
-
branchStatus: {
|
|
200
|
-
before: beforeCommit,
|
|
201
|
-
after: afterCommit,
|
|
202
|
-
},
|
|
203
|
-
};
|
|
161
|
+
});
|
|
204
162
|
}
|
|
163
|
+
|
|
164
|
+
const shouldPush = await confirm({
|
|
165
|
+
message: requiresForcePush
|
|
166
|
+
? `\n${logColors.warning}Do you want to force push ${logColors.bold}${fromBranch}${logColors.normalWeight} to ${logColors.bold}${toBranch}${logColors.normalWeight}?\n\nThis will overwrite the commits only on ${logColors.bold}${toBranch}${logColors.normalWeight}.${logColors.reset}?`
|
|
167
|
+
: 'Ready to deploy?',
|
|
168
|
+
default: false,
|
|
169
|
+
});
|
|
170
|
+
|
|
171
|
+
if (!shouldPush) {
|
|
172
|
+
throw new KnownError(`Deploy aborted.`);
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
if (requiresForcePush) {
|
|
176
|
+
await git.push(remoteName, pushString, ['--force']);
|
|
177
|
+
log.warning(
|
|
178
|
+
`Force pushed ${logColors.bold}${fromBranch}${logColors.normalWeight} to ${logColors.bold}${toBranch}${logColors.reset}.`,
|
|
179
|
+
);
|
|
180
|
+
} else {
|
|
181
|
+
await git.push(remoteName, pushString);
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
return {
|
|
185
|
+
deployCommits: {
|
|
186
|
+
deployedCommits: commitsAhead,
|
|
187
|
+
overwrittenCommits: commitsBehind,
|
|
188
|
+
},
|
|
189
|
+
branchStatus: {
|
|
190
|
+
before: beforeCommit,
|
|
191
|
+
after: afterCommit,
|
|
192
|
+
},
|
|
193
|
+
};
|
|
205
194
|
}
|