@sdlcai/setup 0.2.1 → 0.3.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/README.md +2 -2
- package/bin/cli.mjs +11 -26
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -28,8 +28,8 @@ security boundary remains each private package's own access control.
|
|
|
28
28
|
## Assets
|
|
29
29
|
| asset | installs |
|
|
30
30
|
|---|---|
|
|
31
|
-
| `ava-custom-agents` (alias `ava-agents`) | `@avanade/ava-agents install` |
|
|
32
|
-
| `mnemo` | `@avanade/mnemo-setup` |
|
|
31
|
+
| `ava-custom-agents` (alias `ava-agents`) | `@avanade-region-iceg/ava-agents install` |
|
|
32
|
+
| `mnemo` | `@avanade-region-iceg/mnemo-setup` |
|
|
33
33
|
|
|
34
34
|
Everything after the asset name is passed through to its installer (use `--` to separate).
|
|
35
35
|
Add a new asset by adding one line to `ASSETS` in `bin/cli.mjs`.
|
package/bin/cli.mjs
CHANGED
|
@@ -15,13 +15,13 @@ import { join } from 'node:path';
|
|
|
15
15
|
|
|
16
16
|
const ORG = 'Avanade-Region-ICEG'; // membership gate
|
|
17
17
|
const REGISTRY = 'https://npm.pkg.github.com'; // where the private assets live
|
|
18
|
-
const SCOPE = '@avanade';
|
|
18
|
+
const SCOPE = '@avanade-region-iceg';
|
|
19
19
|
|
|
20
20
|
// asset name -> private installer package + default args
|
|
21
21
|
const ASSETS = {
|
|
22
|
-
'ava-custom-agents': { pkg: '@avanade/ava-agents', args: ['install'], label: 'AVA custom agents' },
|
|
23
|
-
'ava-agents': { pkg: '@avanade/ava-agents', args: ['install'], label: 'AVA custom agents' },
|
|
24
|
-
'mnemo': { pkg: '@avanade/mnemo-setup', args: [], label: 'mnemo (memory)' },
|
|
22
|
+
'ava-custom-agents': { pkg: '@avanade-region-iceg/ava-agents', args: ['install'], label: 'AVA custom agents' },
|
|
23
|
+
'ava-agents': { pkg: '@avanade-region-iceg/ava-agents', args: ['install'], label: 'AVA custom agents' },
|
|
24
|
+
'mnemo': { pkg: '@avanade-region-iceg/mnemo-setup', args: [], label: 'mnemo (memory)' },
|
|
25
25
|
};
|
|
26
26
|
|
|
27
27
|
const WIN = process.platform === 'win32';
|
|
@@ -33,36 +33,21 @@ const ok = (cmd, args) => spawnSync(cmd, args, { encoding: 'utf8', shell: WIN })
|
|
|
33
33
|
|
|
34
34
|
function ensureGh() {
|
|
35
35
|
if (out('gh', ['--version'])) return;
|
|
36
|
-
|
|
37
|
-
let attempted = false;
|
|
38
|
-
if (WIN) {
|
|
39
|
-
attempted = true;
|
|
40
|
-
run('winget', ['install', '--id', 'GitHub.cli', '-e',
|
|
41
|
-
'--accept-package-agreements', '--accept-source-agreements']);
|
|
42
|
-
} else if (process.platform === 'darwin') {
|
|
43
|
-
attempted = true;
|
|
44
|
-
run('brew', ['install', 'gh']);
|
|
45
|
-
}
|
|
46
|
-
if (out('gh', ['--version'])) { info('✓ gh installed.'); return; }
|
|
47
|
-
if (attempted) {
|
|
48
|
-
die('gh was installed but is not yet in PATH.\n' +
|
|
49
|
-
' Close this terminal, reopen it, and re-run the command.');
|
|
50
|
-
}
|
|
51
|
-
die('GitHub CLI (gh) is required for the secure browser login.\n' +
|
|
52
|
-
' Install it — https://cli.github.com — then re-run:\n' +
|
|
36
|
+
die('GitHub CLI (gh) is required — install it first, then re-run:\n' +
|
|
53
37
|
' Windows: winget install GitHub.cli\n' +
|
|
54
38
|
' macOS: brew install gh\n' +
|
|
55
|
-
' Linux: see https://github.com/cli/cli#installation'
|
|
39
|
+
' Linux: see https://github.com/cli/cli#installation\n' +
|
|
40
|
+
' https://cli.github.com');
|
|
56
41
|
}
|
|
57
42
|
|
|
58
43
|
function tokenScopes() {
|
|
59
|
-
const r = spawnSync('gh', ['auth', 'status'], { encoding: 'utf8', shell: WIN });
|
|
44
|
+
const r = spawnSync('gh', ['auth', 'status', '-h', 'github.com'], { encoding: 'utf8', shell: WIN });
|
|
60
45
|
const m = `${r.stdout || ''}${r.stderr || ''}`.match(/Token scopes:([^\r\n]*)/i);
|
|
61
46
|
return m ? m[1] : '';
|
|
62
47
|
}
|
|
63
48
|
|
|
64
49
|
function ensureAuth() {
|
|
65
|
-
if (!ok('gh', ['auth', 'status'])) {
|
|
50
|
+
if (!ok('gh', ['auth', 'status', '-h', 'github.com'])) {
|
|
66
51
|
info('→ GitHub login (a browser window will open — use your passkey / 2FA)…');
|
|
67
52
|
if (run('gh', ['auth', 'login', '-h', 'github.com', '-p', 'https', '-w']).status !== 0) {
|
|
68
53
|
die('GitHub login failed.');
|
|
@@ -74,14 +59,14 @@ function ensureAuth() {
|
|
|
74
59
|
info('→ Granting permissions (read:org, read:packages) — authorize in the browser…');
|
|
75
60
|
run('gh', ['auth', 'refresh', '-h', 'github.com', '-s', need.join(',')]);
|
|
76
61
|
}
|
|
77
|
-
const token = out('gh', ['auth', 'token']);
|
|
62
|
+
const token = out('gh', ['auth', 'token', '-h', 'github.com']);
|
|
78
63
|
if (!token) die('Could not obtain a GitHub token.');
|
|
79
64
|
return token;
|
|
80
65
|
}
|
|
81
66
|
|
|
82
67
|
function gateOrg() {
|
|
83
68
|
info(`→ Checking access to ${ORG}…`);
|
|
84
|
-
if (!ok('gh', ['api', `user/memberships/orgs/${ORG}`])) {
|
|
69
|
+
if (!ok('gh', ['api', '--hostname', 'github.com', `user/memberships/orgs/${ORG}`])) {
|
|
85
70
|
die(`Access denied: your GitHub account is not an active member of ${ORG}.\n` +
|
|
86
71
|
` Request access from your team, then re-run.`);
|
|
87
72
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sdlcai/setup",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.1",
|
|
4
4
|
"description": "One-command bootstrap for private Avanade dev-tool assets (AVA agents, mnemo, …): GitHub browser login + Avanade-Region-ICEG access gate + install.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|