@corva/create-app 0.87.0-rc.0 → 0.87.0-rc.2
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.
|
@@ -5,6 +5,7 @@ import { resolve } from 'node:path';
|
|
|
5
5
|
import { RELEASE } from '../../../constants/messages.js';
|
|
6
6
|
import { StepError } from '../../lib/step-error.js';
|
|
7
7
|
import { logger } from '../../../helpers/logger.js';
|
|
8
|
+
import { execSync } from 'node:child_process';
|
|
8
9
|
|
|
9
10
|
async function deleteAppPackage({ api, appId, appPkgVersion }) {
|
|
10
11
|
const appPackages = await api.getAppPackages(appId);
|
|
@@ -23,6 +24,37 @@ async function deleteAppPackage({ api, appId, appPkgVersion }) {
|
|
|
23
24
|
}
|
|
24
25
|
}
|
|
25
26
|
|
|
27
|
+
async function getGithubUsername() {
|
|
28
|
+
return process.env.githubUsername || null;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function getGitConfigUsername() {
|
|
32
|
+
try {
|
|
33
|
+
const username = execSync('git config user.name').toString().trim();
|
|
34
|
+
|
|
35
|
+
return username || null;
|
|
36
|
+
} catch (error) {
|
|
37
|
+
logger.log('Unable to fetch git config username:', error.message);
|
|
38
|
+
|
|
39
|
+
return null;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
async function promptForUsername() {
|
|
44
|
+
const readline = require('readline');
|
|
45
|
+
const rl = readline.createInterface({
|
|
46
|
+
input: process.stdin,
|
|
47
|
+
output: process.stdout,
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
return new Promise((resolve) => {
|
|
51
|
+
rl.question('Please enter your GitHub username: ', (answer) => {
|
|
52
|
+
rl.close();
|
|
53
|
+
resolve(answer);
|
|
54
|
+
});
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
|
|
26
58
|
export const UPLOAD_ZIP_TO_CORVA_STEP = {
|
|
27
59
|
message: RELEASE.uploadApp,
|
|
28
60
|
/**
|
|
@@ -36,6 +68,25 @@ export const UPLOAD_ZIP_TO_CORVA_STEP = {
|
|
|
36
68
|
|
|
37
69
|
form.append('package', createReadStream(resolve(dirName, zipFileName)), 'package.zip');
|
|
38
70
|
|
|
71
|
+
let githubUsername = await getGithubUsername();
|
|
72
|
+
|
|
73
|
+
if (!githubUsername) {
|
|
74
|
+
githubUsername = getGitConfigUsername();
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
if (!githubUsername) {
|
|
78
|
+
try {
|
|
79
|
+
githubUsername = await Promise.race([
|
|
80
|
+
promptForUsername(),
|
|
81
|
+
new Promise((_, reject) => setTimeout(() => reject(new Error('Prompt timed out')), 10000)),
|
|
82
|
+
]);
|
|
83
|
+
} catch (error) {
|
|
84
|
+
logger.log('Username prompt timed out or failed: ' + error.message);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
form.append('github_username', githubUsername);
|
|
89
|
+
|
|
39
90
|
const { id: packageId, isDeletedDueToLimit } = await api.uploadPackages(appKey, form);
|
|
40
91
|
|
|
41
92
|
if (isDeletedDueToLimit) {
|