@newlandnpt/pep-cli 0.9.0-rc.1 → 0.9.0-rc.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 +12 -0
- package/dist/pep.cjs +72 -22
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -77,6 +77,18 @@ pep setup --skip-skills # only sign in and configure Maven
|
|
|
77
77
|
pep setup group/sub -p # a different group, into THIS project
|
|
78
78
|
```
|
|
79
79
|
|
|
80
|
+
`--issuer`, `--client-id` and `--resource` work here exactly as on `pep auth login`, for pointing a
|
|
81
|
+
run at another deployment:
|
|
82
|
+
|
|
83
|
+
```powershell
|
|
84
|
+
pep setup --issuer https://pep-dev.example --client-id <that deployment's id>
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
⚠ Both are needed for a non-production deployment: the client ID is baked in for production and does
|
|
88
|
+
not fork per environment, so production's ID gets `unauthorized_client` elsewhere. If you are already
|
|
89
|
+
signed in to a different deployment, `pep setup` signs in again rather than silently using the one
|
|
90
|
+
you are signed in to — and since there is a single stored sign-in, that replaces it.
|
|
91
|
+
|
|
80
92
|
The integration guide **group** is baked in at build time (currently `distribution/skills`). Passing
|
|
81
93
|
one overrides it **for that run only** — it is deliberately not remembered, unlike `--docs-url`.
|
|
82
94
|
Where each repository installs *is* remembered, in the local ledger, so `pep skills update` later
|
package/dist/pep.cjs
CHANGED
|
@@ -1174,17 +1174,27 @@ Repositories you installed earlier that have since left the group are reported,
|
|
|
1174
1174
|
never deleted. \`pep skills remove <repo>\` drops one for good.
|
|
1175
1175
|
|
|
1176
1176
|
The group is baked into this build and is not remembered between runs: pass one
|
|
1177
|
-
to install from a different group, just for this run
|
|
1177
|
+
to install from a different group, just for this run.
|
|
1178
|
+
|
|
1179
|
+
--issuer, --client-id and --resource are passed to step 1, exactly as on
|
|
1180
|
+
\`pep auth login\`, and are not remembered either. If you are already signed in to
|
|
1181
|
+
a different deployment, setup signs in again rather than silently using the one
|
|
1182
|
+
you are signed in to. There is a single stored sign-in, so signing in elsewhere
|
|
1183
|
+
replaces it \u2014 run \`pep auth login\` to go back.`,
|
|
1178
1184
|
flags: [
|
|
1179
|
-
"--skip-skills
|
|
1180
|
-
"--skip-nexus
|
|
1185
|
+
"--skip-skills Skip the integration guide step",
|
|
1186
|
+
"--skip-nexus Skip the Maven credential step (not needed outside Android)",
|
|
1181
1187
|
PROJECT_FLAG,
|
|
1182
|
-
"--dir <path>
|
|
1188
|
+
"--dir <path> Install skills into this directory instead",
|
|
1189
|
+
`--issuer <url> PEP server for this run (default: ${DEFAULT_ISSUER})`,
|
|
1190
|
+
"--client-id <id> Registered OAuth client for this run",
|
|
1191
|
+
"--resource <uri> Token audience; repeat for multiple resources"
|
|
1183
1192
|
],
|
|
1184
1193
|
examples: [
|
|
1185
1194
|
"pep setup",
|
|
1186
1195
|
"pep setup --skip-nexus",
|
|
1187
|
-
`pep setup ${DEFAULT_SKILLS_GROUP} -p
|
|
1196
|
+
`pep setup ${DEFAULT_SKILLS_GROUP} -p`,
|
|
1197
|
+
"pep setup --issuer https://pep-dev.example --client-id <that deployment's id>"
|
|
1188
1198
|
]
|
|
1189
1199
|
}
|
|
1190
1200
|
};
|
|
@@ -1800,6 +1810,10 @@ function accountOf(user) {
|
|
|
1800
1810
|
function messageOf(error) {
|
|
1801
1811
|
return error instanceof Error ? error.message : String(error);
|
|
1802
1812
|
}
|
|
1813
|
+
function sameIssuer(a, b) {
|
|
1814
|
+
const trim = (one) => one.trim().replace(/\/+$/, "").toLowerCase();
|
|
1815
|
+
return trim(a) === trim(b);
|
|
1816
|
+
}
|
|
1803
1817
|
function driftedFromGroup(installedSources, groupRepos, group) {
|
|
1804
1818
|
const present = new Set(groupRepos.map((one) => one.trim().toLowerCase()));
|
|
1805
1819
|
return installedSources.filter((key) => {
|
|
@@ -1820,6 +1834,13 @@ async function installGroup(dependencies, remote) {
|
|
|
1820
1834
|
if (repos.length === 0) {
|
|
1821
1835
|
dependencies.onProgress(` ${group} lists no repositories \u2014 nothing to install.`);
|
|
1822
1836
|
}
|
|
1837
|
+
const drifted = driftedFromGroup(dependencies.installedSources, repos, group);
|
|
1838
|
+
if (drifted.length > 0) {
|
|
1839
|
+
dependencies.onProgress(` \u26A0 On your list but no longer in ${group}:`);
|
|
1840
|
+
for (const source of drifted) dependencies.onProgress(` ${source}`);
|
|
1841
|
+
dependencies.onProgress(" Nothing was deleted. If one of them blocks an install below,");
|
|
1842
|
+
dependencies.onProgress(" `pep skills remove <repo>` drops it for good.");
|
|
1843
|
+
}
|
|
1823
1844
|
const installed = [];
|
|
1824
1845
|
const failed = [];
|
|
1825
1846
|
for (const [index, source] of repos.entries()) {
|
|
@@ -1832,23 +1853,32 @@ async function installGroup(dependencies, remote) {
|
|
|
1832
1853
|
dependencies.onProgress(` \u2717 ${source}: ${message}`);
|
|
1833
1854
|
}
|
|
1834
1855
|
}
|
|
1835
|
-
return {
|
|
1836
|
-
status: "installed",
|
|
1837
|
-
group,
|
|
1838
|
-
installed,
|
|
1839
|
-
failed,
|
|
1840
|
-
drifted: driftedFromGroup(dependencies.installedSources, repos, group)
|
|
1841
|
-
};
|
|
1856
|
+
return { status: "installed", group, installed, failed, drifted };
|
|
1842
1857
|
}
|
|
1843
1858
|
async function runSetup(dependencies) {
|
|
1844
1859
|
dependencies.onProgress("\u2460 Signing in to PEP\u2026");
|
|
1845
1860
|
let login;
|
|
1846
1861
|
let signedIn;
|
|
1847
1862
|
try {
|
|
1848
|
-
|
|
1863
|
+
const current = await dependencies.auth.status();
|
|
1864
|
+
if (dependencies.requestedIssuer === void 0 || sameIssuer(current.authorization.issuer, dependencies.requestedIssuer)) {
|
|
1865
|
+
signedIn = current;
|
|
1866
|
+
} else {
|
|
1867
|
+
dependencies.onProgress(
|
|
1868
|
+
` Signed in to ${current.authorization.issuer}, but --issuer names ${dependencies.requestedIssuer} \u2014 signing in again.`
|
|
1869
|
+
);
|
|
1870
|
+
}
|
|
1871
|
+
} catch {
|
|
1872
|
+
}
|
|
1873
|
+
if (signedIn !== void 0) {
|
|
1849
1874
|
login = { alreadySignedIn: true, account: accountOf(signedIn.user) };
|
|
1850
1875
|
dependencies.onProgress(` Already signed in as ${login.account} \u2014 skipped.`);
|
|
1851
|
-
|
|
1876
|
+
if (dependencies.loginOptionsGiven) {
|
|
1877
|
+
dependencies.onProgress(
|
|
1878
|
+
" (reused the stored sign-in; --client-id / --resource apply only to a fresh one)"
|
|
1879
|
+
);
|
|
1880
|
+
}
|
|
1881
|
+
} else {
|
|
1852
1882
|
const config = await dependencies.loginConfig();
|
|
1853
1883
|
dependencies.onProgress(" Opening your browser to sign in\u2026");
|
|
1854
1884
|
await dependencies.auth.login(config, dependencies.onAuthorizationUrl);
|
|
@@ -1895,7 +1925,7 @@ function setupFailureSummary(report) {
|
|
|
1895
1925
|
}
|
|
1896
1926
|
|
|
1897
1927
|
// src/cli.ts
|
|
1898
|
-
var VERSION = false ? "0.0.0-dev" : "0.9.0-rc.
|
|
1928
|
+
var VERSION = false ? "0.0.0-dev" : "0.9.0-rc.3";
|
|
1899
1929
|
var SKILLS_ADD_DEPRECATION = "\u26A0 `pep skills add` will be removed in a future release.";
|
|
1900
1930
|
function reportUpdate(result) {
|
|
1901
1931
|
const conflicts = () => {
|
|
@@ -1975,6 +2005,19 @@ async function loginConfig(args, store = fileConfigStore()) {
|
|
|
1975
2005
|
...saved?.docsUrl !== void 0 ? { docsUrl: saved.docsUrl } : {}
|
|
1976
2006
|
};
|
|
1977
2007
|
}
|
|
2008
|
+
function takeLoginOptions(args) {
|
|
2009
|
+
const out = [];
|
|
2010
|
+
const issuer = option(args, "--issuer");
|
|
2011
|
+
if (issuer !== void 0) out.push("--issuer", normalizeIssuer(issuer));
|
|
2012
|
+
const clientId = option(args, "--client-id");
|
|
2013
|
+
if (clientId !== void 0) out.push("--client-id", clientId);
|
|
2014
|
+
for (const resource of repeatedOption(args, "--resource")) out.push("--resource", resource);
|
|
2015
|
+
return out;
|
|
2016
|
+
}
|
|
2017
|
+
function issuerOf(loginOptions) {
|
|
2018
|
+
const at = loginOptions.indexOf("--issuer");
|
|
2019
|
+
return at === -1 ? void 0 : loginOptions[at + 1];
|
|
2020
|
+
}
|
|
1978
2021
|
function parseSkillsArgs(command, args, cwd) {
|
|
1979
2022
|
const local = command === "list" || command === "remove";
|
|
1980
2023
|
const explicitDirectory = local ? void 0 : option(args, "--dir");
|
|
@@ -2066,12 +2109,14 @@ function reportSetup(report) {
|
|
|
2066
2109
|
console.error(` \u2717 ${source}: ${message}`);
|
|
2067
2110
|
}
|
|
2068
2111
|
if (skills.drifted.length > 0) {
|
|
2069
|
-
|
|
2070
|
-
|
|
2071
|
-
|
|
2072
|
-
|
|
2073
|
-
|
|
2074
|
-
console.error(" `pep skills
|
|
2112
|
+
const n = skills.drifted.length;
|
|
2113
|
+
console.error(
|
|
2114
|
+
`
|
|
2115
|
+
\u26A0 ${n} ${n === 1 ? "repository" : "repositories"} on your list ${n === 1 ? "is" : "are"} no longer in ${skills.group} (listed above).`
|
|
2116
|
+
);
|
|
2117
|
+
console.error(" Nothing was deleted. `pep skills update` will report 404 for each of them");
|
|
2118
|
+
console.error(" (which reads exactly like a typo, but is not). `pep skills remove <repo>`");
|
|
2119
|
+
console.error(" drops one for good.");
|
|
2075
2120
|
}
|
|
2076
2121
|
}
|
|
2077
2122
|
if (report.nexus.status === "skipped") {
|
|
@@ -2098,6 +2143,7 @@ async function main() {
|
|
|
2098
2143
|
if (group === "setup") {
|
|
2099
2144
|
const skipNexus = flag(args, "--skip-nexus");
|
|
2100
2145
|
const skipSkills = flag(args, "--skip-skills");
|
|
2146
|
+
const loginOptions = takeLoginOptions(args);
|
|
2101
2147
|
const { requested, chosenTarget } = parseSkillsArgs("setup", args);
|
|
2102
2148
|
const skillsGroup = requested ?? DEFAULT_SKILLS_GROUP;
|
|
2103
2149
|
const { configStore: configStore2, auth: auth2 } = createCliServices();
|
|
@@ -2105,7 +2151,11 @@ async function main() {
|
|
|
2105
2151
|
const state = await stateStore.read();
|
|
2106
2152
|
const report = await runSetup({
|
|
2107
2153
|
auth: auth2,
|
|
2108
|
-
|
|
2154
|
+
// ⚠ 传 `loginOptions` 而不是 `args`:后者到这里**恒为空**(`parseSkillsArgs` 要么抛、
|
|
2155
|
+
// 要么把剩下的吃干净),传它等于永远只用构建期默认值。
|
|
2156
|
+
loginConfig: () => loginConfig([...loginOptions], configStore2),
|
|
2157
|
+
...issuerOf(loginOptions) !== void 0 ? { requestedIssuer: issuerOf(loginOptions) } : {},
|
|
2158
|
+
loginOptionsGiven: loginOptions.length > 0,
|
|
2109
2159
|
group: skillsGroup,
|
|
2110
2160
|
skipSkills,
|
|
2111
2161
|
listGroupRepos: (remote) => listGroupRepos({ ...remote, group: skillsGroup }),
|