storymaps 1.4.2 → 1.4.3
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/README.md +1 -1
- package/bin/storymaps.js +2 -2
- package/lib/util/identity.js +8 -4
- package/lib/util/project.js +9 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -455,7 +455,7 @@ npm test
|
|
|
455
455
|
|
|
456
456
|
`npm test` runs the unit tests in `test/unit` with Node's built-in test runner (Node 22 or later). They cover the YAML format, the API client, the change summary, and how a target resolves to a map, with no server needed. CI runs them on Node 22 and 24 for every push to `main` and every pull request.
|
|
457
457
|
|
|
458
|
-
To try a change against a local storymaps.io server, run the CLI from the repo, for example `node bin/storymaps.js pull localhost/<map-id>`.
|
|
458
|
+
To try a change against a local storymaps.io server, run the CLI from the repo, for example `node bin/storymaps.js pull localhost:3000/<map-id>`.
|
|
459
459
|
|
|
460
460
|
### Releasing
|
|
461
461
|
|
package/bin/storymaps.js
CHANGED
|
@@ -36,7 +36,7 @@ const DIR_HELP = 'the project folder (default: storymaps)';
|
|
|
36
36
|
program
|
|
37
37
|
.command('init')
|
|
38
38
|
.description('Create a new storymap.yml in the current directory')
|
|
39
|
-
.option('-s, --site <site>', 'target site (e.g.
|
|
39
|
+
.option('-s, --site <site>', 'target site (e.g. storymaps.io, localhost:3000 or http://192.168.0.20:8080)')
|
|
40
40
|
.action(initCommand);
|
|
41
41
|
|
|
42
42
|
program
|
|
@@ -158,7 +158,7 @@ project
|
|
|
158
158
|
.argument('[files...]', 'map files to start the project from; they are left as they are')
|
|
159
159
|
.option('--name <name>', 'the project name (default: Untitled project)')
|
|
160
160
|
.option('--dir <folder>', DIR_HELP)
|
|
161
|
-
.option('-s, --site <site>', 'target site (e.g.
|
|
161
|
+
.option('-s, --site <site>', 'target site (e.g. storymaps.io, localhost:3000 or http://192.168.0.20:8080)')
|
|
162
162
|
.action(projectInitCommand);
|
|
163
163
|
|
|
164
164
|
project
|
package/lib/util/identity.js
CHANGED
|
@@ -8,9 +8,12 @@ const DEFAULT_SITE = 'storymaps.io';
|
|
|
8
8
|
|
|
9
9
|
function siteToBaseUrl(site) {
|
|
10
10
|
if (!site) return `https://${DEFAULT_SITE}`;
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
// Written out in full, such as http://localhost:80, it's used as it is
|
|
12
|
+
if (/^https?:\/\//i.test(site)) return new URL(site).origin;
|
|
13
|
+
// A server on this computer always names its port, such as localhost:3000, so no port is
|
|
14
|
+
// ever assumed
|
|
15
|
+
if (/^(localhost|127\.0\.0\.1)$/.test(site)) throw new Error(`The site ${site} needs its port, such as ${site}:3000.`);
|
|
16
|
+
if (/^(localhost|127\.0\.0\.1):\d+$/.test(site)) return `http://${site}`;
|
|
14
17
|
return `https://${site}`;
|
|
15
18
|
}
|
|
16
19
|
|
|
@@ -25,7 +28,8 @@ function parseLink(arg) {
|
|
|
25
28
|
}
|
|
26
29
|
if (arg.includes('/') && !/\.(ya?ml|json)$/i.test(arg)) {
|
|
27
30
|
const url = new URL(`https://${arg}`);
|
|
28
|
-
|
|
31
|
+
// The host keeps its port, such as localhost:3312/abc12345
|
|
32
|
+
return { url, baseUrl: siteToBaseUrl(url.host) };
|
|
29
33
|
}
|
|
30
34
|
return null;
|
|
31
35
|
}
|
package/lib/util/project.js
CHANGED
|
@@ -127,10 +127,17 @@ export function setSiteKey(content, site) {
|
|
|
127
127
|
return `site: ${site}\n${content}`;
|
|
128
128
|
}
|
|
129
129
|
|
|
130
|
-
// The site a server's address stands for in a map file, such as storymaps.io or
|
|
130
|
+
// The site a server's address stands for in a map file. The short form, such as storymaps.io or
|
|
131
|
+
// localhost:3000, is used only where it reads back as the same address: https for a server on the
|
|
132
|
+
// web, http with its port for one on this computer. Anything else is written out in full, such as
|
|
133
|
+
// http://localhost:80 or https://localhost:8443, so no protocol or port is ever guessed.
|
|
131
134
|
export const siteOfBaseUrl = (baseUrl) => {
|
|
132
135
|
const url = new URL(baseUrl);
|
|
133
|
-
|
|
136
|
+
const local = /^(localhost|127\.0\.0\.1)$/.test(url.hostname);
|
|
137
|
+
const port = url.port || (url.protocol === 'https:' ? '443' : '80');
|
|
138
|
+
if (!local && url.protocol === 'https:') return url.host;
|
|
139
|
+
if (local && url.protocol === 'http:' && url.port) return url.host;
|
|
140
|
+
return `${url.protocol}//${url.hostname}:${port}`;
|
|
134
141
|
};
|
|
135
142
|
|
|
136
143
|
// Sets locked: true or false in a map file after the CLI locks or unlocks its map, so the file
|