@group107/create-wp107 2.1.1 → 2.2.0
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/bin/create-wp107.mjs +9 -3
- package/package.json +1 -1
package/bin/create-wp107.mjs
CHANGED
|
@@ -4,19 +4,21 @@ import { existsSync, realpathSync } from 'node:fs';
|
|
|
4
4
|
import { dirname, join } from 'node:path';
|
|
5
5
|
import { fileURLToPath } from 'node:url';
|
|
6
6
|
|
|
7
|
-
export const WP107_VERSION = '2.
|
|
7
|
+
export const WP107_VERSION = '2.2.0';
|
|
8
8
|
export const DEFAULT_SPEC = `git+https://github.com/Israel-IT/WP107.git#v${WP107_VERSION}`;
|
|
9
9
|
|
|
10
10
|
export function accessTarget(spec) {
|
|
11
11
|
if (/^(file:|\.|[A-Za-z]:[\\/])/.test(spec)) return null;
|
|
12
12
|
const [url, fragment] = spec.replace(/^git\+/, '').split('#');
|
|
13
|
+
if (url?.startsWith('-')) throw new Error(`WP107_PLATFORM_SPEC must not start with a dash: ${spec}`);
|
|
13
14
|
return url && fragment ? { url, ref: fragment.startsWith('v') ? `refs/tags/${fragment}` : fragment } : null;
|
|
14
15
|
}
|
|
15
16
|
|
|
16
17
|
export function checkAccess(spec, execute = spawnSync) {
|
|
17
18
|
const target = accessTarget(spec);
|
|
18
19
|
if (!target) return { ok: true, skipped: true };
|
|
19
|
-
|
|
20
|
+
// `--` ends the options: a URL or ref can never become one (`--upload-pack=…` runs a command).
|
|
21
|
+
const result = execute('git', ['ls-remote', '--exit-code', '--', target.url, target.ref], {
|
|
20
22
|
encoding: 'utf8', env: { ...process.env, GIT_TERMINAL_PROMPT: '0' }, windowsHide: true,
|
|
21
23
|
});
|
|
22
24
|
return { ok: result.status === 0, status: result.status, target };
|
|
@@ -34,7 +36,11 @@ export function launch(args, { env = process.env, execute = spawnSync, stderr =
|
|
|
34
36
|
const spec = env.WP107_PLATFORM_SPEC || DEFAULT_SPEC;
|
|
35
37
|
// The first run downloads the private release silently for a while; say what is happening.
|
|
36
38
|
if (stderr.isTTY) stderr.write(`WP107 ${WP107_VERSION}: preparing the installer…\n`);
|
|
37
|
-
|
|
39
|
+
let access;
|
|
40
|
+
try { access = checkAccess(spec, execute); } catch (error) {
|
|
41
|
+
console.error(`[create-wp107] ${error.message}`);
|
|
42
|
+
return 1;
|
|
43
|
+
}
|
|
38
44
|
if (!access.ok) {
|
|
39
45
|
console.error(`[create-wp107] Cannot read the private WP107 release ${access.target.ref}.\n` +
|
|
40
46
|
'Run `gh auth login` and `gh auth setup-git`, confirm Israel-IT/WP107 access, then retry.');
|