@mnci/cli 4.7.1 → 4.8.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/dist/cli.js +48 -0
- package/dist/cli.js.map +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -4718,6 +4718,53 @@ function checkNpmrc(workspaceRoot, registry, scope) {
|
|
|
4718
4718
|
remedy: "run `mnci upgrade`"
|
|
4719
4719
|
};
|
|
4720
4720
|
}
|
|
4721
|
+
function checkNpmrcCredentialResolves(workspaceRoot, environment = process.env) {
|
|
4722
|
+
const npmrcPath = (0, import_node_path19.join)(workspaceRoot, ".npmrc");
|
|
4723
|
+
if (!fileExists(npmrcPath)) {
|
|
4724
|
+
return void 0;
|
|
4725
|
+
}
|
|
4726
|
+
const npmrc = (0, import_node_fs12.readFileSync)(npmrcPath, "utf8");
|
|
4727
|
+
const credentials = npmrc.split("\n").filter((line) => !line.trimStart().startsWith(";") && !line.trimStart().startsWith("#")).filter((line) => /(?:_authToken|_password|_auth)\s*=/u.test(line));
|
|
4728
|
+
const referenced = [
|
|
4729
|
+
...new Set(
|
|
4730
|
+
credentials.flatMap(
|
|
4731
|
+
(line) => Array.from(line.matchAll(/\$\{(\w+)\}/gu), (match) => match[1])
|
|
4732
|
+
)
|
|
4733
|
+
)
|
|
4734
|
+
];
|
|
4735
|
+
if (referenced.length === 0) {
|
|
4736
|
+
return void 0;
|
|
4737
|
+
}
|
|
4738
|
+
const unset = referenced.filter((name) => (environment[name] ?? "") === "");
|
|
4739
|
+
if (unset.length === 0) {
|
|
4740
|
+
return npmjsCredentialShape(credentials, environment);
|
|
4741
|
+
}
|
|
4742
|
+
return {
|
|
4743
|
+
check: "npm credentials in this workspace resolve to something",
|
|
4744
|
+
ok: false,
|
|
4745
|
+
detail: `.npmrc authenticates with \${${unset.join("}, ${")}}, which ${unset.length > 1 ? "are" : "is"} unset here \u2014 and a project .npmrc beats your user one, so npm will send an EMPTY token from this directory rather than the one \`npm login\` wrote. Writes are then refused as a 404 on the PUT, which reads like a missing package`,
|
|
4746
|
+
remedy: "nothing, for installing or building \u2014 this only affects authenticated commands. To publish or deprecate by hand, run it from outside this workspace, or export a real token first. If it still fails there, `npm whoami` \u2014 an expired token gives the same 404"
|
|
4747
|
+
};
|
|
4748
|
+
}
|
|
4749
|
+
var NPM_TOKEN_PREFIX = "npm_";
|
|
4750
|
+
var LEGACY_NPM_TOKEN = /^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/iu;
|
|
4751
|
+
function npmjsCredentialShape(credentials, environment) {
|
|
4752
|
+
const line = credentials.find((entry) => entry.includes("//registry.npmjs.org/:_authToken="));
|
|
4753
|
+
const variable = line === void 0 ? void 0 : /\$\{(\w+)\}/u.exec(line)?.[1];
|
|
4754
|
+
if (variable === void 0) {
|
|
4755
|
+
return void 0;
|
|
4756
|
+
}
|
|
4757
|
+
const value = environment[variable] ?? "";
|
|
4758
|
+
if (value.startsWith(NPM_TOKEN_PREFIX) || LEGACY_NPM_TOKEN.test(value)) {
|
|
4759
|
+
return void 0;
|
|
4760
|
+
}
|
|
4761
|
+
return {
|
|
4762
|
+
check: "the credential bound for npmjs.org looks like an npm token",
|
|
4763
|
+
ok: false,
|
|
4764
|
+
detail: `\${${variable}} is set (${value.length} characters) but does not start with '${NPM_TOKEN_PREFIX}' and is not a legacy UUID token, so it is probably a credential for somewhere else \u2014 '${variable}' is a generic name that other tooling also sets, and inside this workspace it is sent to the PUBLIC registry. A write then fails as a 404 on the PUT, which reads like a missing package`,
|
|
4765
|
+
remedy: `\`npm whoami\` to confirm \u2014 it is the only thing that separates a wrong token from an expired one. Then unset \`${variable}\` for local work, or set it to a real npm token`
|
|
4766
|
+
};
|
|
4767
|
+
}
|
|
4721
4768
|
function checkVersionActions(workspaceRoot) {
|
|
4722
4769
|
const candidates = [
|
|
4723
4770
|
...(0, import_node_fs12.globSync)("packages/*/pubspec.yaml", { cwd: workspaceRoot }),
|
|
@@ -4902,6 +4949,7 @@ function collectFindings(workspaceRoot) {
|
|
|
4902
4949
|
checkEslintPlugin(nxJson),
|
|
4903
4950
|
checkResolvedEslint(workspaceRoot),
|
|
4904
4951
|
checkNpmrc(workspaceRoot, nxJson.mnci?.registry, nxJson.mnci?.scope),
|
|
4952
|
+
checkNpmrcCredentialResolves(workspaceRoot),
|
|
4905
4953
|
checkNoRootRuntimeDependencies(workspaceRoot),
|
|
4906
4954
|
...checkRollupSourceMaps(workspaceRoot),
|
|
4907
4955
|
...checkDeclarationSpecifiers(workspaceRoot),
|