From 775cf6c6582c65884a28327ebb52ca88cc9762d4 Mon Sep 17 00:00:00 2001 From: Jason Caldwell Date: Wed, 25 Jan 2023 09:35:59 -0500 Subject: [PATCH] Project update. [p][robotic] --- dev/.files/bin/includes/utilities.js | 24 +++++++++++++++++------- package-lock.json | 4 ++-- package.json | 6 ++++-- 3 files changed, 23 insertions(+), 11 deletions(-) diff --git a/dev/.files/bin/includes/utilities.js b/dev/.files/bin/includes/utilities.js index 890f1c7b..a18d1941 100755 --- a/dev/.files/bin/includes/utilities.js +++ b/dev/.files/bin/includes/utilities.js @@ -862,7 +862,12 @@ export default class u { } static async isNPMPkgRegistry(registry) { - return registry.replace(/\/+$/, '') === String(await u.spawn('npm', ['config', 'get', 'registry'], { quiet: true })).replace(/\/+$/, ''); + return ( + registry.replace(/\/+$/, '') === + String(await u.spawn('npm', ['config', 'get', 'registry'], { quiet: true })) + .trim() + .replace(/\/+$/, '') + ); } static async isNPMPkgPublishable(opts = { mode: 'prod' }) { @@ -922,20 +927,22 @@ export default class u { } log(chalk.gray('Configuring npmjs package using org-wide standards.')); - const alwaysOnRequiredTeams = { developers: 'read-write', owners: 'read-write', 'security-managers': 'read-only' }; // No exceptions. - let teams = Object.assign({}, _.get(pkg, 'config.c10n.&.npmjs.teams', _.get(pkg, 'config.c10n.&.github.teams', {})), alwaysOnRequiredTeams); - teams = Object.keys(teams).forEach((team) => (teams[team] = /^(?:read-write|push|maintain|admin)$/iu.test(teams[team]) ? 'read-write' : 'read-only')); const teamsToDelete = await u._npmjsOrgTeams(org); // Current list of organization’s teams. + const alwaysOnRequiredTeams = { developers: 'read-write', owners: 'read-write', 'security-managers': 'read-only' }; // No exceptions. + + const teams = Object.assign({}, _.get(pkg, 'config.c10n.&.npmjs.teams', _.get(pkg, 'config.c10n.&.github.teams', {})), alwaysOnRequiredTeams); + Object.keys(teams).forEach((team) => (teams[team] = /^(?:read-write|push|maintain|admin)$/iu.test(teams[team]) ? 'read-write' : 'read-only')); for (const [team, permission] of Object.entries(teams)) { delete teamsToDelete[team]; // Don't delete. + log(chalk.gray('Adding `' + team + '` team to npmjs package with `' + permission + '` permission.')); if (!opts.dryRun) { await u.spawn('npm', ['access', 'grant', permission, org + ':' + team], { quiet: true }); } } - for (const [team, teamData] of Object.entries(teamsToDelete)) { - log(chalk.gray('Deleting `' + team + '` (unused) with `' + teamData.permission + '` permission from npmjs package.')); + for (const [team] of Object.entries(teamsToDelete)) { + log(chalk.gray('Deleting `' + team + '` (unused) from npmjs package.')); if (!opts.dryRun) { await u.spawn('npm', ['access', 'revoke', org + ':' + team], { quiet: true }).catch(() => null); } @@ -970,7 +977,10 @@ export default class u { if (!(teams instanceof Array)) { throw new Error('u._npmjsOrgTeams: Failed to acquire list of NPM teams for `' + org + '` org.'); } - return teams.map((team) => team.replace(/^[^:]+:/u, '')); // Array of team slugs. + return teams.reduce((o, team) => { + o[team.replace(/^[^:]+:/u, '')] = team; + return o; // Object return. + }, {}); } /* diff --git a/package-lock.json b/package-lock.json index 8cf933db..1ba6b8de 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@clevercanyon/utilities", - "version": "1.0.67", + "version": "1.0.70", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@clevercanyon/utilities", - "version": "1.0.67", + "version": "1.0.70", "cpu": [ "x64", "arm64" diff --git a/package.json b/package.json index 276bdcd4..751b52e8 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,7 @@ "publishConfig": { "access": "restricted" }, - "version": "1.0.68", + "version": "1.0.71", "license": "GPL-3.0-or-later", "name": "@clevercanyon/utilities", "description": "Another great project by Clever Canyon.", @@ -135,7 +135,9 @@ }, "configVersion": "1.0.0" }, - "npmjs": {} + "npmjs": { + "configVersions": "1.0.0,1.0.0" + } } } }