virmator 4.3.0 → 4.3.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.
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
export declare function askQuestion(questionToAsk: string, timeoutMs?: number): Promise<string>;
|
|
2
|
-
export declare function askQuestionUntilConditionMet({ questionToAsk, conditionCallback, invalidInputMessage, tryCountMax, }: {
|
|
2
|
+
export declare function askQuestionUntilConditionMet({ questionToAsk, conditionCallback, invalidInputMessage, tryCountMax, timeoutMs, }: {
|
|
3
3
|
questionToAsk: string;
|
|
4
4
|
conditionCallback: (response: string) => boolean | Promise<boolean>;
|
|
5
5
|
invalidInputMessage: string;
|
|
6
6
|
tryCountMax?: number;
|
|
7
|
+
/** Set to 0 to disable the timeout */
|
|
8
|
+
timeoutMs?: number;
|
|
7
9
|
}): Promise<string>;
|
package/dist/augments/console.js
CHANGED
|
@@ -8,23 +8,28 @@ async function askQuestion(questionToAsk, timeoutMs = 60000) {
|
|
|
8
8
|
output: process.stdout,
|
|
9
9
|
});
|
|
10
10
|
return new Promise((resolve, reject) => {
|
|
11
|
+
const timeoutId = timeoutMs
|
|
12
|
+
? setTimeout(() => {
|
|
13
|
+
cliInterface.close();
|
|
14
|
+
reject(`Took too long to response (over "${timeoutMs / 1000}" seconds)`);
|
|
15
|
+
}, timeoutMs)
|
|
16
|
+
: undefined;
|
|
11
17
|
cliInterface.question(questionToAsk + ' ', (response) => {
|
|
18
|
+
if (timeoutId != undefined) {
|
|
19
|
+
clearTimeout(timeoutId);
|
|
20
|
+
}
|
|
12
21
|
cliInterface.close();
|
|
13
22
|
resolve(response);
|
|
14
23
|
});
|
|
15
|
-
setTimeout(() => {
|
|
16
|
-
cliInterface.close();
|
|
17
|
-
reject(`Took too long to response (over "${timeoutMs / 1000}" seconds)`);
|
|
18
|
-
}, timeoutMs);
|
|
19
24
|
});
|
|
20
25
|
}
|
|
21
26
|
exports.askQuestion = askQuestion;
|
|
22
|
-
async function askQuestionUntilConditionMet({ questionToAsk, conditionCallback, invalidInputMessage, tryCountMax = 5, }) {
|
|
27
|
+
async function askQuestionUntilConditionMet({ questionToAsk, conditionCallback, invalidInputMessage, tryCountMax = 5, timeoutMs = 60000, }) {
|
|
23
28
|
let wasConditionMet = false;
|
|
24
29
|
let retryCount = 0;
|
|
25
30
|
let response = '';
|
|
26
31
|
while (!wasConditionMet && retryCount <= tryCountMax) {
|
|
27
|
-
response = (await askQuestion(questionToAsk)).trim();
|
|
32
|
+
response = (await askQuestion(questionToAsk, timeoutMs)).trim();
|
|
28
33
|
wasConditionMet = await conditionCallback(response);
|
|
29
34
|
if (!wasConditionMet) {
|
|
30
35
|
console.error(invalidInputMessage);
|
|
@@ -41,7 +41,7 @@ exports.publishCommandDefinition = (0, define_command_1.defineCommand)({
|
|
|
41
41
|
throw new Error(`git changes detected in "${packageJsonPath}". Cannot run publish command with changes, commit them first.`);
|
|
42
42
|
}
|
|
43
43
|
const workspaceDirs = getWorkspaceDirs(packageJson, packageJsonPath);
|
|
44
|
-
if (await isCurrentVersionPublished(packageJson)) {
|
|
44
|
+
if (await isCurrentVersionPublished(packageJson, workspaceDirs)) {
|
|
45
45
|
await bumpPackageVersion(packageJson, packageJsonPath, workspaceDirs);
|
|
46
46
|
}
|
|
47
47
|
await updateWorkspaceVersions(packageJsonPath, workspaceDirs);
|
|
@@ -106,8 +106,15 @@ async function publishPackages(workspaceDirPaths, packageJsonPath) {
|
|
|
106
106
|
});
|
|
107
107
|
}
|
|
108
108
|
}
|
|
109
|
-
async function isCurrentVersionPublished(packageJson) {
|
|
110
|
-
const
|
|
109
|
+
async function isCurrentVersionPublished(packageJson, workspaceDirs) {
|
|
110
|
+
const arePublished = await Promise.all(workspaceDirs.map(async (workspaceDirPath) => {
|
|
111
|
+
const workspacePackageJson = await (0, npm_1.readPackageJson)((0, path_1.join)(workspaceDirPath, 'package.json'));
|
|
112
|
+
return await isPublished(workspacePackageJson);
|
|
113
|
+
}));
|
|
114
|
+
return arePublished.some((entry) => entry) || (await isPublished(packageJson));
|
|
115
|
+
}
|
|
116
|
+
async function isPublished({ name, version }) {
|
|
117
|
+
const output = await (0, node_only_1.runShellCommand)(`npm show ${name}@${version}`);
|
|
111
118
|
return output.exitCode === 0;
|
|
112
119
|
}
|
|
113
120
|
// this is just used to ensure we have every release type
|
|
@@ -129,6 +136,7 @@ async function bumpPackageVersion(packageJson, packageJsonPath, workspaceDirPath
|
|
|
129
136
|
},
|
|
130
137
|
invalidInputMessage: `Invalid release type. Expected ${(0, augment_vir_1.joinWithFinalConjunction)(releaseTypeOptions, 'or')}.`,
|
|
131
138
|
questionToAsk: releaseTypeMessage,
|
|
139
|
+
timeoutMs: 0,
|
|
132
140
|
}));
|
|
133
141
|
const newVersion = (0, semver_1.inc)(packageJson.version, releaseType);
|
|
134
142
|
if (!newVersion) {
|