pruff-skills 1.5.2 → 1.5.4
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.mjs +68 -6
- package/package.json +1 -1
package/dist/cli.mjs
CHANGED
|
@@ -7587,6 +7587,10 @@ main()
|
|
|
7587
7587
|
.finally(() => process.exit(0));
|
|
7588
7588
|
`;
|
|
7589
7589
|
const TENANT_CONFIG_PATH = join("scripts", "tenant", "tenant.config.ts");
|
|
7590
|
+
const TENANT_TYPES_PATH = join("scripts", "tenant", "types.ts");
|
|
7591
|
+
function tenantAdminSupportsSuperAdmin(typesSource) {
|
|
7592
|
+
return /\bsuperAdmin\??\s*:/.test(typesSource);
|
|
7593
|
+
}
|
|
7590
7594
|
function renderTenantConfig(v) {
|
|
7591
7595
|
return `import { CompanyType } from './consts';
|
|
7592
7596
|
import { TenantScriptConfig } from './types';
|
|
@@ -7598,8 +7602,7 @@ const config: TenantScriptConfig = {
|
|
|
7598
7602
|
companyTypes: [CompanyType.Intelligence],
|
|
7599
7603
|
admin: {
|
|
7600
7604
|
email: ${JSON.stringify(v.adminEmail)},
|
|
7601
|
-
password: ${JSON.stringify(v.adminPassword)},
|
|
7602
|
-
superAdmin: true,
|
|
7605
|
+
password: ${JSON.stringify(v.adminPassword)},${v.superAdmin ? "\n superAdmin: true," : ""}
|
|
7603
7606
|
},
|
|
7604
7607
|
additionalUsers: [],
|
|
7605
7608
|
configurationFlags: [],
|
|
@@ -7876,7 +7879,9 @@ async function preflight() {
|
|
|
7876
7879
|
M.success("git · node · npm present");
|
|
7877
7880
|
if (!ensureGh()) return false;
|
|
7878
7881
|
if (!await ensureGitHubAuth()) return false;
|
|
7879
|
-
|
|
7882
|
+
if (!ensureGitCredentialHelper()) return false;
|
|
7883
|
+
ensurePackagesScope();
|
|
7884
|
+
return true;
|
|
7880
7885
|
}
|
|
7881
7886
|
function ensureGh() {
|
|
7882
7887
|
if (has("gh")) return true;
|
|
@@ -7954,6 +7959,62 @@ function ensureGitCredentialHelper() {
|
|
|
7954
7959
|
M.error(`git has no credential helper for github.com, so cloning the private Pruff repos will fail.\n Run ${import_picocolors.default.cyan("gh auth setup-git")} (or ${import_picocolors.default.cyan("gh auth login -h github.com -p https -w")} and answer yes to "Authenticate Git with your GitHub credentials?"), then re-run.`);
|
|
7955
7960
|
return false;
|
|
7956
7961
|
}
|
|
7962
|
+
function ghTokenScopes(statusOutput) {
|
|
7963
|
+
const line = statusOutput.split("\n").find((l) => l.includes("Token scopes:"));
|
|
7964
|
+
if (!line) return null;
|
|
7965
|
+
return (line.split("Token scopes:")[1] ?? "").split(",").map((scope) => scope.trim().replace(/^'|'$/g, "")).filter((scope) => scope !== "");
|
|
7966
|
+
}
|
|
7967
|
+
function hasPackagesScope(scopes) {
|
|
7968
|
+
if (scopes === null) return true;
|
|
7969
|
+
return scopes.includes("read:packages") || scopes.includes("write:packages");
|
|
7970
|
+
}
|
|
7971
|
+
function ghAuthStatusOutput() {
|
|
7972
|
+
const r = spawnSync("gh", [
|
|
7973
|
+
"auth",
|
|
7974
|
+
"status",
|
|
7975
|
+
"-h",
|
|
7976
|
+
"github.com"
|
|
7977
|
+
], { encoding: "utf-8" });
|
|
7978
|
+
return `${r.stdout ?? ""}\n${r.stderr ?? ""}`;
|
|
7979
|
+
}
|
|
7980
|
+
function ensurePackagesScope() {
|
|
7981
|
+
if (hasPackagesScope(ghTokenScopes(ghAuthStatusOutput()))) {
|
|
7982
|
+
M.success("GitHub Packages access (read:packages)");
|
|
7983
|
+
return;
|
|
7984
|
+
}
|
|
7985
|
+
const refresh = "gh auth refresh -h github.com -s read:packages";
|
|
7986
|
+
if (process.stdout.isTTY) {
|
|
7987
|
+
M.info("Granting read:packages to the gh token (private @pruff-tech packages)…");
|
|
7988
|
+
run("gh", [
|
|
7989
|
+
"auth",
|
|
7990
|
+
"refresh",
|
|
7991
|
+
"-h",
|
|
7992
|
+
"github.com",
|
|
7993
|
+
"-s",
|
|
7994
|
+
"read:packages"
|
|
7995
|
+
]);
|
|
7996
|
+
if (hasPackagesScope(ghTokenScopes(ghAuthStatusOutput()))) {
|
|
7997
|
+
M.success("GitHub Packages access (read:packages)");
|
|
7998
|
+
return;
|
|
7999
|
+
}
|
|
8000
|
+
}
|
|
8001
|
+
note("gh token lacks read:packages — dependency installs will 401.");
|
|
8002
|
+
M.warn(`The gh token is missing ${import_picocolors.default.cyan("read:packages")}, so installing the private @pruff-tech packages will fail with 401.\n Run ${import_picocolors.default.cyan(refresh)}, then re-run.`);
|
|
8003
|
+
}
|
|
8004
|
+
function packagesAuthEnv() {
|
|
8005
|
+
if (process.env.NODE_AUTH_TOKEN) return void 0;
|
|
8006
|
+
const { ok, out } = capture("gh", [
|
|
8007
|
+
"auth",
|
|
8008
|
+
"token",
|
|
8009
|
+
"-h",
|
|
8010
|
+
"github.com"
|
|
8011
|
+
]);
|
|
8012
|
+
return ok && out !== "" ? { NODE_AUTH_TOKEN: out } : void 0;
|
|
8013
|
+
}
|
|
8014
|
+
function serverSupportsSuperAdmin(serverPath) {
|
|
8015
|
+
const typesPath = join(serverPath, TENANT_TYPES_PATH);
|
|
8016
|
+
return existsSync(typesPath) && tenantAdminSupportsSuperAdmin(readFileSync(typesPath, "utf-8"));
|
|
8017
|
+
}
|
|
7957
8018
|
function has(cmd) {
|
|
7958
8019
|
return spawnSync("command", ["-v", cmd], {
|
|
7959
8020
|
shell: true,
|
|
@@ -8114,13 +8175,13 @@ function installDeps(repo, workspace) {
|
|
|
8114
8175
|
}
|
|
8115
8176
|
const s = Y();
|
|
8116
8177
|
s.start(`Installing ${name} dependencies (${installCmd})…`);
|
|
8117
|
-
const ok = run(installCmd, installArgs, target);
|
|
8178
|
+
const ok = run(installCmd, installArgs, target, packagesAuthEnv());
|
|
8118
8179
|
if (ok && existsSync(join(target, "node_modules"))) s.stop(`${name} dependencies installed`);
|
|
8119
8180
|
else {
|
|
8120
8181
|
s.stop(import_picocolors.default.yellow(`${name} dependency install failed`));
|
|
8121
8182
|
note(`${name} dependencies failed to install.`);
|
|
8122
8183
|
if (ok) M.warn(`${installCmd} exited 0 but ${name}/node_modules is missing — install likely no-opped.`);
|
|
8123
|
-
M.warn(`Run manually: ${import_picocolors.default.dim(`cd ${name} && ${installCmd} ${installArgs.join(" ")}`)}`);
|
|
8184
|
+
M.warn(`Run manually: ${import_picocolors.default.dim(`cd ${name} && NODE_AUTH_TOKEN=$(gh auth token) ${installCmd} ${installArgs.join(" ")}`)}\n A 401 from npm.pkg.github.com means the gh token lacks read:packages: ${import_picocolors.default.dim("gh auth refresh -h github.com -s read:packages")}`);
|
|
8124
8185
|
}
|
|
8125
8186
|
}
|
|
8126
8187
|
function writeWorkspaceClaudeMd(workspace) {
|
|
@@ -8571,7 +8632,8 @@ function setupLocalDatabase(serverPath, env) {
|
|
|
8571
8632
|
taxIdentifier: env.CLIENT_RUT ?? "",
|
|
8572
8633
|
companyName: env.CLIENT_NAME ?? clientId,
|
|
8573
8634
|
adminEmail,
|
|
8574
|
-
adminPassword
|
|
8635
|
+
adminPassword,
|
|
8636
|
+
superAdmin: serverSupportsSuperAdmin(serverPath)
|
|
8575
8637
|
}), () => server.exec(SERVER_SCRIPT.createTenant));
|
|
8576
8638
|
s.stop(tenantCreated ? `Tenant "${clientId}" provisioned` : import_picocolors.default.yellow("Tenant provisioning failed"));
|
|
8577
8639
|
if (!tenantCreated) {
|