@sdlcai/setup 0.1.0 → 0.2.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.
Files changed (3) hide show
  1. package/README.md +41 -39
  2. package/bin/cli.mjs +143 -127
  3. package/package.json +27 -27
package/README.md CHANGED
@@ -1,39 +1,41 @@
1
- # @sdlcai/setup
2
-
3
- One command to install private **Avanade** dev-tool assets — the AVA agents, mnemo, and future
4
- assets — with a secure GitHub browser login and an access gate.
5
-
6
- ```bash
7
- npx @sdlcai/setup ava-custom-agents
8
- npx @sdlcai/setup mnemo -- --local --scope user --project acme --yes
9
- ```
10
-
11
- ## What it does
12
- 1. **GitHub browser login** (via `gh` — passkey / 2FA).
13
- 2. **Verifies access** to the `Avanade-Region-ICEG` org (read-only pre-flight gate).
14
- 3. **Configures GitHub Packages auth** in your `~/.npmrc`.
15
- 4. **Runs the asset's own installer.**
16
-
17
- No OAuth App to register, no org-admin actions — `gh` is GitHub's own trusted CLI. The assets stay
18
- private on GitHub Packages; this launcher is just the public, one-command front door. The real
19
- security boundary remains each private package's own access control.
20
-
21
- ## Prerequisites
22
- - **Node.js ≥ 18**
23
- - **GitHub CLI (`gh`)** — https://cli.github.com (`winget install GitHub.cli` · `brew install gh`)
24
- - A GitHub account with access to **`Avanade-Region-ICEG`**.
25
-
26
- ## Assets
27
- | asset | installs |
28
- |---|---|
29
- | `ava-custom-agents` (alias `ava-agents`) | `@avanade/ava-agents install` |
30
- | `mnemo` | `@avanade/mnemo-setup` |
31
-
32
- Everything after the asset name is passed through to its installer (use `--` to separate).
33
- Add a new asset by adding one line to `ASSETS` in `bin/cli.mjs`.
34
-
35
- ## Publish (maintainer)
36
- ```bash
37
- npm login # the account that owns the @sdlcai org
38
- npm publish --access public # public launcher
39
- ```
1
+ # @sdlcai/setup
2
+
3
+ One command to install private **Avanade** dev-tool assets — the AVA agents, mnemo, and future
4
+ assets — with a secure GitHub browser login and an access gate.
5
+
6
+ ```bash
7
+ npm i -g @sdlcai/setup # once (public, no auth)
8
+ sdlcai ava-custom-agents
9
+ sdlcai mnemo -- --local --scope user --project acme --yes
10
+ # or, where npx is healthy: npx @sdlcai/setup ava-custom-agents
11
+ ```
12
+
13
+ ## What it does
14
+ 1. **GitHub browser login** (via `gh` — passkey / 2FA).
15
+ 2. **Verifies access** to the `Avanade-Region-ICEG` org (read-only pre-flight gate).
16
+ 3. **Configures GitHub Packages auth** in your `~/.npmrc`.
17
+ 4. **Runs the asset's own installer.**
18
+
19
+ No OAuth App to register, no org-admin actions — `gh` is GitHub's own trusted CLI. The assets stay
20
+ private on GitHub Packages; this launcher is just the public, one-command front door. The real
21
+ security boundary remains each private package's own access control.
22
+
23
+ ## Prerequisites
24
+ - **Node.js ≥ 18**
25
+ - **GitHub CLI (`gh`)** — https://cli.github.com (`winget install GitHub.cli` · `brew install gh`)
26
+ - A GitHub account with access to **`Avanade-Region-ICEG`**.
27
+
28
+ ## Assets
29
+ | asset | installs |
30
+ |---|---|
31
+ | `ava-custom-agents` (alias `ava-agents`) | `@avanade/ava-agents install` |
32
+ | `mnemo` | `@avanade/mnemo-setup` |
33
+
34
+ Everything after the asset name is passed through to its installer (use `--` to separate).
35
+ Add a new asset by adding one line to `ASSETS` in `bin/cli.mjs`.
36
+
37
+ ## Publish (maintainer)
38
+ ```bash
39
+ npm login # the account that owns the @sdlcai org
40
+ npm publish --access public # public launcher
41
+ ```
package/bin/cli.mjs CHANGED
@@ -1,127 +1,143 @@
1
- #!/usr/bin/env node
2
- /**
3
- * @sdlcai/setup — one-command bootstrap for private Avanade dev-tool assets.
4
- *
5
- * npx @sdlcai/setup <asset> [-- asset-args…]
6
- *
7
- * Flow: GitHub browser login (via `gh`) → verify Avanade-Region-ICEG membership →
8
- * configure GitHub Packages auth in ~/.npmrc → run the asset's own installer.
9
- * No OAuth App to register, no org-admin actions. `gh` is GitHub's own trusted CLI.
10
- */
11
- import { spawnSync } from 'node:child_process';
12
- import { readFileSync, writeFileSync, existsSync } from 'node:fs';
13
- import { homedir } from 'node:os';
14
- import { join } from 'node:path';
15
-
16
- const ORG = 'Avanade-Region-ICEG'; // membership gate
17
- const REGISTRY = 'https://npm.pkg.github.com'; // where the private assets live
18
- const SCOPE = '@avanade';
19
-
20
- // asset name -> private installer package + default args
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)' },
25
- };
26
-
27
- const WIN = process.platform === 'win32';
28
- const die = (m) => { console.error(`\n✖ ${m}`); process.exit(1); };
29
- const info = (m) => console.log(m);
30
- const run = (cmd, args, opts = {}) => spawnSync(cmd, args, { stdio: 'inherit', shell: WIN, ...opts });
31
- const out = (cmd, args) => { const r = spawnSync(cmd, args, { encoding: 'utf8', shell: WIN }); return r.status === 0 ? (r.stdout || '').trim() : null; };
32
- const ok = (cmd, args) => spawnSync(cmd, args, { encoding: 'utf8', shell: WIN }).status === 0;
33
-
34
- function ensureGh() {
35
- if (out('gh', ['--version'])) return;
36
- die('GitHub CLI (gh) is required for the secure browser login.\n' +
37
- ' Install it — https://cli.github.com — then re-run:\n' +
38
- ' Windows: winget install GitHub.cli\n' +
39
- ' macOS: brew install gh\n' +
40
- ' Linux: see https://github.com/cli/cli#installation');
41
- }
42
-
43
- function tokenScopes() {
44
- const r = spawnSync('gh', ['auth', 'status'], { encoding: 'utf8', shell: WIN });
45
- const m = `${r.stdout || ''}${r.stderr || ''}`.match(/Token scopes:([^\r\n]*)/i);
46
- return m ? m[1] : '';
47
- }
48
-
49
- function ensureAuth() {
50
- if (!ok('gh', ['auth', 'status'])) {
51
- info('→ GitHub login (a browser window will open — use your passkey / 2FA)…');
52
- if (run('gh', ['auth', 'login', '-h', 'github.com', '-p', 'https', '-w']).status !== 0) {
53
- die('GitHub login failed.');
54
- }
55
- }
56
- const need = ['read:org', 'read:packages'];
57
- const have = tokenScopes();
58
- if (!need.every((s) => have.includes(`'${s}'`))) {
59
- info('→ Granting permissions (read:org, read:packages) — authorize in the browser…');
60
- run('gh', ['auth', 'refresh', '-h', 'github.com', '-s', need.join(',')]);
61
- }
62
- const token = out('gh', ['auth', 'token']);
63
- if (!token) die('Could not obtain a GitHub token.');
64
- return token;
65
- }
66
-
67
- function gateOrg() {
68
- info(`→ Checking access to ${ORG}…`);
69
- if (!ok('gh', ['api', `user/memberships/orgs/${ORG}`])) {
70
- die(`Access denied: your GitHub account is not an active member of ${ORG}.\n` +
71
- ` Request access from your team, then re-run.`);
72
- }
73
- info(`✓ Access to ${ORG} confirmed.`);
74
- }
75
-
76
- function configureNpmAuth(token) {
77
- const rc = join(homedir(), '.npmrc');
78
- let lines = existsSync(rc) ? readFileSync(rc, 'utf8').split(/\r?\n/) : [];
79
- lines = lines.filter((l) => !l.startsWith(`${SCOPE}:registry=`) && !l.includes('//npm.pkg.github.com/:_authToken='));
80
- lines.push(`${SCOPE}:registry=${REGISTRY}`);
81
- lines.push(`//npm.pkg.github.com/:_authToken=${token}`);
82
- writeFileSync(rc, lines.filter(Boolean).join('\n') + '\n');
83
- info(`✓ Configured GitHub Packages auth (${rc}).`);
84
- }
85
-
86
- function help(exit) {
87
- console.log(
88
- `@sdlcai/setup — install a private Avanade dev-tool asset with one command.
89
-
90
- Usage:
91
- npx @sdlcai/setup <asset> [-- asset-args…]
92
-
93
- Assets:
94
- ${Object.keys(ASSETS).map((a) => ` ${a}`).join('\n')}
95
-
96
- It logs you into GitHub (browser + passkey/2FA), checks ${ORG} access,
97
- configures GitHub Packages auth, then runs the asset's installer.
98
-
99
- Examples:
100
- npx @sdlcai/setup ava-custom-agents
101
- npx @sdlcai/setup mnemo -- --local --scope user --project acme --yes`);
102
- process.exit(exit);
103
- }
104
-
105
- function main() {
106
- const argv = process.argv.slice(2);
107
- const asset = argv[0];
108
- if (!asset || asset === '-h' || asset === '--help') help(asset ? 0 : 1);
109
-
110
- const target = ASSETS[asset];
111
- if (!target) die(`Unknown asset "${asset}". Known: ${Object.keys(ASSETS).join(', ')}`);
112
-
113
- // everything after the asset (drop a leading "--" separator if present) is passed through
114
- const rest = argv.slice(1);
115
- const passthrough = rest[0] === '--' ? rest.slice(1) : rest;
116
-
117
- ensureGh();
118
- const token = ensureAuth();
119
- gateOrg();
120
- configureNpmAuth(token);
121
-
122
- info(`\n→ Installing ${target.label} (${target.pkg})…\n`);
123
- const r = run('npx', ['--yes', target.pkg, ...target.args, ...passthrough]);
124
- process.exit(r.status ?? 0);
125
- }
126
-
127
- main();
1
+ #!/usr/bin/env node
2
+ /**
3
+ * @sdlcai/setup — one-command bootstrap for private Avanade dev-tool assets.
4
+ *
5
+ * npx @sdlcai/setup <asset> [-- asset-args…]
6
+ *
7
+ * Flow: GitHub browser login (via `gh`) → verify Avanade-Region-ICEG membership →
8
+ * configure GitHub Packages auth in ~/.npmrc → run the asset's own installer.
9
+ * No OAuth App to register, no org-admin actions. `gh` is GitHub's own trusted CLI.
10
+ */
11
+ import { spawnSync } from 'node:child_process';
12
+ import { readFileSync, writeFileSync, existsSync } from 'node:fs';
13
+ import { homedir } from 'node:os';
14
+ import { join } from 'node:path';
15
+
16
+ const ORG = 'Avanade-Region-ICEG'; // membership gate
17
+ const REGISTRY = 'https://npm.pkg.github.com'; // where the private assets live
18
+ const SCOPE = '@avanade';
19
+
20
+ // asset name -> private installer package + default args
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)' },
25
+ };
26
+
27
+ const WIN = process.platform === 'win32';
28
+ const die = (m) => { console.error(`\n✖ ${m}`); process.exit(1); };
29
+ const info = (m) => console.log(m);
30
+ const run = (cmd, args, opts = {}) => spawnSync(cmd, args, { stdio: 'inherit', shell: WIN, ...opts });
31
+ const out = (cmd, args) => { const r = spawnSync(cmd, args, { encoding: 'utf8', shell: WIN }); return r.status === 0 ? (r.stdout || '').trim() : null; };
32
+ const ok = (cmd, args) => spawnSync(cmd, args, { encoding: 'utf8', shell: WIN }).status === 0;
33
+
34
+ function ensureGh() {
35
+ if (out('gh', ['--version'])) return;
36
+ info('→ GitHub CLI (gh) not found — attempting auto-install…');
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' +
53
+ ' Windows: winget install GitHub.cli\n' +
54
+ ' macOS: brew install gh\n' +
55
+ ' Linux: see https://github.com/cli/cli#installation');
56
+ }
57
+
58
+ function tokenScopes() {
59
+ const r = spawnSync('gh', ['auth', 'status'], { encoding: 'utf8', shell: WIN });
60
+ const m = `${r.stdout || ''}${r.stderr || ''}`.match(/Token scopes:([^\r\n]*)/i);
61
+ return m ? m[1] : '';
62
+ }
63
+
64
+ function ensureAuth() {
65
+ if (!ok('gh', ['auth', 'status'])) {
66
+ info('→ GitHub login (a browser window will open — use your passkey / 2FA)…');
67
+ if (run('gh', ['auth', 'login', '-h', 'github.com', '-p', 'https', '-w']).status !== 0) {
68
+ die('GitHub login failed.');
69
+ }
70
+ }
71
+ const need = ['read:org', 'read:packages'];
72
+ const have = tokenScopes();
73
+ if (!need.every((s) => have.includes(`'${s}'`))) {
74
+ info('→ Granting permissions (read:org, read:packages) — authorize in the browser…');
75
+ run('gh', ['auth', 'refresh', '-h', 'github.com', '-s', need.join(',')]);
76
+ }
77
+ const token = out('gh', ['auth', 'token']);
78
+ if (!token) die('Could not obtain a GitHub token.');
79
+ return token;
80
+ }
81
+
82
+ function gateOrg() {
83
+ info(`→ Checking access to ${ORG}…`);
84
+ if (!ok('gh', ['api', `user/memberships/orgs/${ORG}`])) {
85
+ die(`Access denied: your GitHub account is not an active member of ${ORG}.\n` +
86
+ ` Request access from your team, then re-run.`);
87
+ }
88
+ info(`✓ Access to ${ORG} confirmed.`);
89
+ }
90
+
91
+ function configureNpmAuth(token) {
92
+ const rc = join(homedir(), '.npmrc');
93
+ let lines = existsSync(rc) ? readFileSync(rc, 'utf8').split(/\r?\n/) : [];
94
+ lines = lines.filter((l) => !l.startsWith(`${SCOPE}:registry=`) && !l.includes('//npm.pkg.github.com/:_authToken='));
95
+ lines.push(`${SCOPE}:registry=${REGISTRY}`);
96
+ lines.push(`//npm.pkg.github.com/:_authToken=${token}`);
97
+ writeFileSync(rc, lines.filter(Boolean).join('\n') + '\n');
98
+ info(`✓ Configured GitHub Packages auth (${rc}).`);
99
+ }
100
+
101
+ function help(exit) {
102
+ console.log(
103
+ `@sdlcai/setup — install a private Avanade dev-tool asset with one command.
104
+
105
+ Usage:
106
+ sdlcai <asset> [-- asset-args…] (after: npm i -g @sdlcai/setup)
107
+ npx @sdlcai/setup <asset> [-- asset-args…] (alternative, where npx is healthy)
108
+
109
+ Assets:
110
+ ${Object.keys(ASSETS).map((a) => ` ${a}`).join('\n')}
111
+
112
+ It logs you into GitHub (browser + passkey/2FA), checks ${ORG} access,
113
+ configures GitHub Packages auth, then runs the asset's installer.
114
+
115
+ Examples:
116
+ sdlcai ava-custom-agents
117
+ sdlcai mnemo -- --local --scope user --project acme --yes`);
118
+ process.exit(exit);
119
+ }
120
+
121
+ function main() {
122
+ const argv = process.argv.slice(2);
123
+ const asset = argv[0];
124
+ if (!asset || asset === '-h' || asset === '--help') help(asset ? 0 : 1);
125
+
126
+ const target = ASSETS[asset];
127
+ if (!target) die(`Unknown asset "${asset}". Known: ${Object.keys(ASSETS).join(', ')}`);
128
+
129
+ // everything after the asset (drop a leading "--" separator if present) is passed through
130
+ const rest = argv.slice(1);
131
+ const passthrough = rest[0] === '--' ? rest.slice(1) : rest;
132
+
133
+ ensureGh();
134
+ const token = ensureAuth();
135
+ gateOrg();
136
+ configureNpmAuth(token);
137
+
138
+ info(`\n→ Installing ${target.label} (${target.pkg})…\n`);
139
+ const r = run('npx', ['--yes', target.pkg, ...target.args, ...passthrough]);
140
+ process.exit(r.status ?? 0);
141
+ }
142
+
143
+ main();
package/package.json CHANGED
@@ -1,27 +1,27 @@
1
- {
2
- "name": "@sdlcai/setup",
3
- "version": "0.1.0",
4
- "description": "One-command bootstrap for private Avanade dev-tool assets (AVA agents, mnemo, …): GitHub browser login + Avanade-Region-ICEG access gate + install.",
5
- "type": "module",
6
- "bin": {
7
- "setup": "bin/cli.mjs"
8
- },
9
- "files": [
10
- "bin"
11
- ],
12
- "engines": {
13
- "node": ">=18"
14
- },
15
- "keywords": [
16
- "sdlc",
17
- "avanade",
18
- "installer",
19
- "bootstrap",
20
- "ava-agents",
21
- "mnemo"
22
- ],
23
- "license": "MIT",
24
- "publishConfig": {
25
- "access": "public"
26
- }
27
- }
1
+ {
2
+ "name": "@sdlcai/setup",
3
+ "version": "0.2.1",
4
+ "description": "One-command bootstrap for private Avanade dev-tool assets (AVA agents, mnemo, …): GitHub browser login + Avanade-Region-ICEG access gate + install.",
5
+ "type": "module",
6
+ "bin": {
7
+ "sdlcai": "bin/cli.mjs"
8
+ },
9
+ "files": [
10
+ "bin"
11
+ ],
12
+ "engines": {
13
+ "node": ">=18"
14
+ },
15
+ "keywords": [
16
+ "sdlc",
17
+ "avanade",
18
+ "installer",
19
+ "bootstrap",
20
+ "ava-agents",
21
+ "mnemo"
22
+ ],
23
+ "license": "MIT",
24
+ "publishConfig": {
25
+ "access": "public"
26
+ }
27
+ }