@quadient/skillshare 1.3.0 → 1.4.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/README.md +11 -0
- package/dist/index.js +75 -0
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -148,6 +148,17 @@ export SKILLSHARE_TOKEN="<personal-access-token>"
|
|
|
148
148
|
npx @quadient/skillshare whoami
|
|
149
149
|
```
|
|
150
150
|
|
|
151
|
+
Register the production or local SkillShare host as a generic OAuth provider in Git Credential
|
|
152
|
+
Manager 2.0.931 or newer:
|
|
153
|
+
|
|
154
|
+
```bash
|
|
155
|
+
skillshare git configure
|
|
156
|
+
skillshare git configure local
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
Remove only the URL-scoped SkillShare registration with `skillshare git unconfigure [local]`.
|
|
160
|
+
The first Git clone opens the browser login; no SkillShare personal access token needs to be created.
|
|
161
|
+
|
|
151
162
|
Update recorded installs to the latest versions:
|
|
152
163
|
|
|
153
164
|
```bash
|
package/dist/index.js
CHANGED
|
@@ -81,6 +81,8 @@ Commands:
|
|
|
81
81
|
pages list
|
|
82
82
|
pages show <slug>
|
|
83
83
|
pages upload <directory> [--slug <slug>]
|
|
84
|
+
git configure [local]
|
|
85
|
+
git unconfigure [local]
|
|
84
86
|
|
|
85
87
|
Options:
|
|
86
88
|
--token <token> Bearer token for API requests (overrides SKILLSHARE_TOKEN)
|
|
@@ -106,6 +108,19 @@ async function main() {
|
|
|
106
108
|
await logoutSession();
|
|
107
109
|
return;
|
|
108
110
|
}
|
|
111
|
+
case 'git': {
|
|
112
|
+
const action = options.positionals[0];
|
|
113
|
+
const baseUrl = options.positionals[1] === 'local' ? LOCAL_URL : PROD_URL;
|
|
114
|
+
if (action === 'configure') {
|
|
115
|
+
await configureGitCredentialManager(baseUrl);
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
if (action === 'unconfigure') {
|
|
119
|
+
await unconfigureGitCredentialManager(baseUrl);
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
throw new Error('git requires "configure [local]" or "unconfigure [local]".');
|
|
123
|
+
}
|
|
109
124
|
case 'whoami':
|
|
110
125
|
case 'list':
|
|
111
126
|
case 'show':
|
|
@@ -1328,6 +1343,66 @@ async function login(baseUrl) {
|
|
|
1328
1343
|
});
|
|
1329
1344
|
console.log(`Logged in as ${response.user.displayName} (${baseUrl})`);
|
|
1330
1345
|
}
|
|
1346
|
+
const GCM_MINIMUM_VERSION = [2, 0, 931];
|
|
1347
|
+
async function configureGitCredentialManager(baseUrl) {
|
|
1348
|
+
baseUrl = normalizeBaseUrl(baseUrl);
|
|
1349
|
+
const versionResult = await runProcess('git', ['credential-manager', '--version'], { allowFailure: true });
|
|
1350
|
+
const version = parseVersion(`${versionResult.stdout} ${versionResult.stderr}`);
|
|
1351
|
+
if (versionResult.exitCode !== 0 || !version || compareVersions(version, GCM_MINIMUM_VERSION) < 0) {
|
|
1352
|
+
throw new Error('Git Credential Manager 2.0.931 or newer is required. Install or update GCM, then run this command again.');
|
|
1353
|
+
}
|
|
1354
|
+
await runProcess('git', ['credential-manager', 'configure']);
|
|
1355
|
+
const prefix = `credential.${baseUrl}`;
|
|
1356
|
+
const settings = [
|
|
1357
|
+
[`${prefix}.provider`, 'generic'],
|
|
1358
|
+
[`${prefix}.oauthClientId`, 'skillshare-gcm'],
|
|
1359
|
+
[`${prefix}.oauthRedirectUri`, 'http://127.0.0.1'],
|
|
1360
|
+
[`${prefix}.oauthAuthorizeEndpoint`, '/api/git/oauth/authorize'],
|
|
1361
|
+
[`${prefix}.oauthTokenEndpoint`, '/api/git/oauth/token'],
|
|
1362
|
+
[`${prefix}.oauthScopes`, 'git.read'],
|
|
1363
|
+
[`${prefix}.oauthDefaultUserName`, 'skillshare'],
|
|
1364
|
+
[`${prefix}.oauthUseClientAuthHeader`, 'false'],
|
|
1365
|
+
[`${prefix}.useHttpPath`, 'false'],
|
|
1366
|
+
];
|
|
1367
|
+
for (const [key, value] of settings) {
|
|
1368
|
+
await runProcess('git', ['config', '--global', '--replace-all', key, value]);
|
|
1369
|
+
}
|
|
1370
|
+
console.log(`Registered ${baseUrl} in Git Credential Manager ${formatVersion(version)}.`);
|
|
1371
|
+
}
|
|
1372
|
+
async function unconfigureGitCredentialManager(baseUrl) {
|
|
1373
|
+
baseUrl = normalizeBaseUrl(baseUrl);
|
|
1374
|
+
const prefix = `credential.${baseUrl}`;
|
|
1375
|
+
for (const key of [
|
|
1376
|
+
'provider',
|
|
1377
|
+
'oauthClientId',
|
|
1378
|
+
'oauthRedirectUri',
|
|
1379
|
+
'oauthAuthorizeEndpoint',
|
|
1380
|
+
'oauthTokenEndpoint',
|
|
1381
|
+
'oauthScopes',
|
|
1382
|
+
'oauthDefaultUserName',
|
|
1383
|
+
'oauthUseClientAuthHeader',
|
|
1384
|
+
'useHttpPath',
|
|
1385
|
+
]) {
|
|
1386
|
+
await runProcess('git', ['config', '--global', '--unset-all', `${prefix}.${key}`], { allowFailure: true });
|
|
1387
|
+
}
|
|
1388
|
+
console.log(`Removed the Git Credential Manager registration for ${baseUrl}.`);
|
|
1389
|
+
}
|
|
1390
|
+
function parseVersion(value) {
|
|
1391
|
+
const match = value.match(/(?:^|\s)(\d+)\.(\d+)\.(\d+)(?:\D|$)/);
|
|
1392
|
+
return match ? [Number(match[1]), Number(match[2]), Number(match[3])] : null;
|
|
1393
|
+
}
|
|
1394
|
+
function compareVersions(left, right) {
|
|
1395
|
+
for (let index = 0; index < Math.max(left.length, right.length); index += 1) {
|
|
1396
|
+
const difference = (left[index] ?? 0) - (right[index] ?? 0);
|
|
1397
|
+
if (difference !== 0) {
|
|
1398
|
+
return difference;
|
|
1399
|
+
}
|
|
1400
|
+
}
|
|
1401
|
+
return 0;
|
|
1402
|
+
}
|
|
1403
|
+
function formatVersion(version) {
|
|
1404
|
+
return version.join('.');
|
|
1405
|
+
}
|
|
1331
1406
|
async function parseOptions(args) {
|
|
1332
1407
|
const booleanFlags = new Set(['dry-run']);
|
|
1333
1408
|
const flags = {};
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@quadient/skillshare",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.0",
|
|
4
4
|
"description": "Skillshare CLI for installing and publishing Quadient skills",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
7
|
-
"skillshare": "
|
|
7
|
+
"skillshare": "bin/skillshare"
|
|
8
8
|
},
|
|
9
9
|
"files": [
|
|
10
10
|
"bin",
|