sitevision-cli 0.4.0-beta.0 → 0.4.0-beta.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/commands/dev.js
CHANGED
|
@@ -5,7 +5,8 @@ import { StatusIndicator } from '../components/StatusIndicator.js';
|
|
|
5
5
|
import { WebpackRunner } from '../utils/webpack-runner.js';
|
|
6
6
|
import { promptPassword, promptYesNo } from '../utils/password-prompt.js';
|
|
7
7
|
import { signApp, deployApp } from '../utils/sitevision-api.js';
|
|
8
|
-
import {
|
|
8
|
+
import { setDeployPassword } from '../utils/keychain.js';
|
|
9
|
+
import { resolveSigningPassword } from '../utils/signing-password.js';
|
|
9
10
|
import { copyStaticToBuild, createBuildZip, cleanBuild } from '../utils/zip.js';
|
|
10
11
|
import { isBundledApp, getAppType, getFullAppId, getZipPath, getSignedZipPath, } from '../utils/project-detection.js';
|
|
11
12
|
export function DevScreen({ projectRoot, manifest, devProperties, signed, signingCredentials, onBack, onRetryCredentials, }) {
|
|
@@ -268,25 +269,11 @@ export const devCommand = {
|
|
|
268
269
|
return;
|
|
269
270
|
}
|
|
270
271
|
const signingUsername = project.devProperties.signingUsername;
|
|
271
|
-
|
|
272
|
-
process.env['SITEVISION_SIGNING_PASSWORD'] ||
|
|
273
|
-
'';
|
|
274
|
-
let promptedManually = false;
|
|
275
|
-
if (!password) {
|
|
276
|
-
console.log('');
|
|
277
|
-
password = await promptPassword('Signing password (developer.sitevision.se): ');
|
|
278
|
-
promptedManually = true;
|
|
279
|
-
}
|
|
272
|
+
const password = await resolveSigningPassword(signingUsername);
|
|
280
273
|
if (!password) {
|
|
281
274
|
console.log('\x1b[31mError: Password is required for signed mode\x1b[0m');
|
|
282
275
|
return;
|
|
283
276
|
}
|
|
284
|
-
if (promptedManually) {
|
|
285
|
-
const remember = await promptYesNo('Save password to OS keychain? (y/N): ');
|
|
286
|
-
if (remember) {
|
|
287
|
-
setSigningPassword(signingUsername, password);
|
|
288
|
-
}
|
|
289
|
-
}
|
|
290
277
|
signingCredentials = {
|
|
291
278
|
username: signingUsername,
|
|
292
279
|
password,
|
package/dist/commands/sign.js
CHANGED
|
@@ -3,8 +3,7 @@ import React from 'react';
|
|
|
3
3
|
import { render, Box, Text, useInput } from 'ink';
|
|
4
4
|
import { StatusIndicator } from '../components/StatusIndicator.js';
|
|
5
5
|
import { signApp } from '../utils/sitevision-api.js';
|
|
6
|
-
import {
|
|
7
|
-
import { getSigningPassword, setSigningPassword } from '../utils/keychain.js';
|
|
6
|
+
import { resolveSigningPassword } from '../utils/signing-password.js';
|
|
8
7
|
import { getZipPath, getSignedZipPath } from '../utils/project-detection.js';
|
|
9
8
|
import { formatFileSize, getZipSize, zipExists } from '../utils/zip.js';
|
|
10
9
|
export function SignScreen({ projectRoot, manifest, devProperties, password, onBack, onRetryCredentials, }) {
|
|
@@ -84,26 +83,11 @@ export const signCommand = {
|
|
|
84
83
|
return;
|
|
85
84
|
}
|
|
86
85
|
const signingUsername = project.devProperties.signingUsername;
|
|
87
|
-
|
|
88
|
-
let password = getSigningPassword(signingUsername) ||
|
|
89
|
-
process.env['SITEVISION_SIGNING_PASSWORD'] ||
|
|
90
|
-
'';
|
|
91
|
-
let promptedManually = false;
|
|
92
|
-
if (!password) {
|
|
93
|
-
console.log('');
|
|
94
|
-
password = await promptPassword('Signing password (developer.sitevision.se): ');
|
|
95
|
-
promptedManually = true;
|
|
96
|
-
}
|
|
86
|
+
const password = await resolveSigningPassword(signingUsername);
|
|
97
87
|
if (!password) {
|
|
98
88
|
console.log('\x1b[31mError: Password is required\x1b[0m');
|
|
99
89
|
return;
|
|
100
90
|
}
|
|
101
|
-
if (promptedManually) {
|
|
102
|
-
const remember = await promptYesNo('Save password to OS keychain? (y/N): ');
|
|
103
|
-
if (remember) {
|
|
104
|
-
setSigningPassword(signingUsername, password);
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
91
|
const { waitUntilExit } = render(_jsx(SignScreen, { projectRoot: project.root, manifest: project.manifest, devProperties: project.devProperties, password: password }));
|
|
108
92
|
await waitUntilExit();
|
|
109
93
|
},
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Prompt for a yes/no answer. Returns true for y/Y
|
|
2
|
+
* Prompt for a yes/no answer. Returns true for y/Y.
|
|
3
|
+
* Pressing Enter (empty answer) returns `defaultYes` (default: false).
|
|
3
4
|
*/
|
|
4
|
-
export declare function promptYesNo(prompt: string): Promise<boolean>;
|
|
5
|
+
export declare function promptYesNo(prompt: string, defaultYes?: boolean): Promise<boolean>;
|
|
5
6
|
/**
|
|
6
7
|
* Prompt for password input with masked display
|
|
7
8
|
*/
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Prompt for a yes/no answer. Returns true for y/Y
|
|
2
|
+
* Prompt for a yes/no answer. Returns true for y/Y.
|
|
3
|
+
* Pressing Enter (empty answer) returns `defaultYes` (default: false).
|
|
3
4
|
*/
|
|
4
|
-
export function promptYesNo(prompt) {
|
|
5
|
+
export function promptYesNo(prompt, defaultYes = false) {
|
|
5
6
|
return new Promise(resolve => {
|
|
6
7
|
process.stdout.write(prompt);
|
|
7
8
|
const stdin = process.stdin;
|
|
@@ -14,9 +15,15 @@ export function promptYesNo(prompt) {
|
|
|
14
15
|
stdin.removeListener('data', onData);
|
|
15
16
|
stdin.pause();
|
|
16
17
|
process.stdout.write(`${char}\n`);
|
|
17
|
-
|
|
18
|
+
const charCode = char.charCodeAt(0);
|
|
19
|
+
if (charCode === 3) {
|
|
18
20
|
process.exit();
|
|
19
21
|
}
|
|
22
|
+
// Enter (CR/LF) or empty input → use the default
|
|
23
|
+
if (char === '' || charCode === 13 || charCode === 10) {
|
|
24
|
+
resolve(defaultYes);
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
20
27
|
resolve(char === 'y' || char === 'Y');
|
|
21
28
|
};
|
|
22
29
|
stdin.on('data', onData);
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Resolve the signing password for the given user.
|
|
3
|
+
*
|
|
4
|
+
* Priority:
|
|
5
|
+
* 1. `SITEVISION_SIGNING_PASSWORD` env var (non-interactive override, no prompts).
|
|
6
|
+
* 2. A password saved in the OS keychain — the user is asked whether to use it
|
|
7
|
+
* or set a new one. Choosing "new" optionally updates the saved password.
|
|
8
|
+
* 3. An interactive prompt — optionally saved to the keychain.
|
|
9
|
+
*
|
|
10
|
+
* Returns an empty string if no password could be obtained.
|
|
11
|
+
*/
|
|
12
|
+
export declare function resolveSigningPassword(signingUsername: string): Promise<string>;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { getSigningPassword, setSigningPassword } from './keychain.js';
|
|
2
|
+
import { promptPassword, promptYesNo } from './password-prompt.js';
|
|
3
|
+
const SIGNING_PROMPT = 'Signing password (developer.sitevision.se): ';
|
|
4
|
+
/**
|
|
5
|
+
* Resolve the signing password for the given user.
|
|
6
|
+
*
|
|
7
|
+
* Priority:
|
|
8
|
+
* 1. `SITEVISION_SIGNING_PASSWORD` env var (non-interactive override, no prompts).
|
|
9
|
+
* 2. A password saved in the OS keychain — the user is asked whether to use it
|
|
10
|
+
* or set a new one. Choosing "new" optionally updates the saved password.
|
|
11
|
+
* 3. An interactive prompt — optionally saved to the keychain.
|
|
12
|
+
*
|
|
13
|
+
* Returns an empty string if no password could be obtained.
|
|
14
|
+
*/
|
|
15
|
+
export async function resolveSigningPassword(signingUsername) {
|
|
16
|
+
const envPassword = process.env['SITEVISION_SIGNING_PASSWORD'];
|
|
17
|
+
if (envPassword)
|
|
18
|
+
return envPassword;
|
|
19
|
+
const stored = getSigningPassword(signingUsername);
|
|
20
|
+
if (stored) {
|
|
21
|
+
const useStored = await promptYesNo('Use saved signing password from keychain? (Y/n): ', true);
|
|
22
|
+
if (useStored)
|
|
23
|
+
return stored;
|
|
24
|
+
}
|
|
25
|
+
console.log('');
|
|
26
|
+
const password = await promptPassword(SIGNING_PROMPT);
|
|
27
|
+
if (!password)
|
|
28
|
+
return '';
|
|
29
|
+
const remember = await promptYesNo(stored
|
|
30
|
+
? 'Update saved password in OS keychain? (y/N): '
|
|
31
|
+
: 'Save password to OS keychain? (y/N): ');
|
|
32
|
+
if (remember) {
|
|
33
|
+
setSigningPassword(signingUsername, password);
|
|
34
|
+
}
|
|
35
|
+
return password;
|
|
36
|
+
}
|