storymaps 1.4.1 → 1.4.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.
- package/lib/commands/init.js +2 -2
- package/lib/util/prompt.js +8 -3
- package/package.json +1 -1
package/lib/commands/init.js
CHANGED
|
@@ -7,6 +7,7 @@ import { resolve } from 'node:path';
|
|
|
7
7
|
import { confirm } from '@inquirer/prompts';
|
|
8
8
|
import chalk from 'chalk';
|
|
9
9
|
import { getMap, postMap } from '../util/api.js';
|
|
10
|
+
import { siteToBaseUrl } from '../util/identity.js';
|
|
10
11
|
import { writeEtag } from '../util/file.js';
|
|
11
12
|
|
|
12
13
|
export function template(site) {
|
|
@@ -72,8 +73,7 @@ export async function initCommand(opts) {
|
|
|
72
73
|
}
|
|
73
74
|
|
|
74
75
|
const site = opts.site || 'storymaps.io';
|
|
75
|
-
const baseUrl = site
|
|
76
|
-
: `https://${site}`;
|
|
76
|
+
const baseUrl = siteToBaseUrl(site);
|
|
77
77
|
|
|
78
78
|
let output = template(site);
|
|
79
79
|
let id = null;
|
package/lib/util/prompt.js
CHANGED
|
@@ -56,15 +56,20 @@ export async function guard({ message, force, stopMessage }) {
|
|
|
56
56
|
|
|
57
57
|
// A password, hashed: from STORYMAPS_PASSWORD when allowed and set, or typed in a terminal.
|
|
58
58
|
// confirmTwice asks again, for setting a new password. Throws a StopError when neither is possible.
|
|
59
|
+
// A new password, set with confirmTwice, needs at least 4 characters, the same as in the app
|
|
60
|
+
const MIN_PASSWORD_LENGTH = 4;
|
|
61
|
+
const tooShort = () => new StopError(`Use a password of at least ${MIN_PASSWORD_LENGTH} characters, the same as in the app.`);
|
|
62
|
+
|
|
59
63
|
export async function askPassword({ allowEnv = true, confirmTwice = false, noPasswordMessage } = {}) {
|
|
60
|
-
if (allowEnv) {
|
|
61
|
-
|
|
62
|
-
|
|
64
|
+
if (allowEnv && process.env[PASSWORD_ENV]) {
|
|
65
|
+
if (confirmTwice && process.env[PASSWORD_ENV].length < MIN_PASSWORD_LENGTH) throw tooShort();
|
|
66
|
+
return envPasswordHash();
|
|
63
67
|
}
|
|
64
68
|
if (!isInteractive()) {
|
|
65
69
|
throw new StopError(noPasswordMessage || `This needs a password, and there's no terminal to type it in. Set ${PASSWORD_ENV} for this command.`);
|
|
66
70
|
}
|
|
67
71
|
const pw = await password({ message: 'Password:', theme: THEME });
|
|
72
|
+
if (confirmTwice && pw.length < MIN_PASSWORD_LENGTH) throw tooShort();
|
|
68
73
|
if (confirmTwice) {
|
|
69
74
|
const again = await password({ message: 'Confirm password:', theme: THEME });
|
|
70
75
|
if (pw !== again) throw new StopError('Passwords do not match.');
|