@pleaseai/ask 0.1.0 → 0.1.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/dist/agents.d.ts +2 -0
- package/dist/agents.d.ts.map +1 -0
- package/dist/agents.js +73 -0
- package/dist/agents.js.map +1 -0
- package/dist/concurrency.d.ts +12 -0
- package/dist/concurrency.d.ts.map +1 -0
- package/dist/concurrency.js +33 -0
- package/dist/concurrency.js.map +1 -0
- package/dist/config.d.ts +8 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +28 -0
- package/dist/config.js.map +1 -0
- package/dist/ignore-files.d.ts +59 -0
- package/dist/ignore-files.d.ts.map +1 -0
- package/dist/ignore-files.js +205 -0
- package/dist/ignore-files.js.map +1 -0
- package/dist/index.d.ts +76 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +485 -0
- package/dist/index.js.map +1 -0
- package/dist/io.d.ts +55 -0
- package/dist/io.d.ts.map +1 -0
- package/dist/io.js +159 -0
- package/dist/io.js.map +1 -0
- package/dist/manifest/index.d.ts +26 -0
- package/dist/manifest/index.d.ts.map +1 -0
- package/dist/manifest/index.js +25 -0
- package/dist/manifest/index.js.map +1 -0
- package/dist/manifest/npm.d.ts +18 -0
- package/dist/manifest/npm.d.ts.map +1 -0
- package/dist/manifest/npm.js +155 -0
- package/dist/manifest/npm.js.map +1 -0
- package/dist/markers.d.ts +34 -0
- package/dist/markers.d.ts.map +1 -0
- package/dist/markers.js +82 -0
- package/dist/markers.js.map +1 -0
- package/dist/migrate-legacy.d.ts +24 -0
- package/dist/migrate-legacy.d.ts.map +1 -0
- package/dist/migrate-legacy.js +85 -0
- package/dist/migrate-legacy.js.map +1 -0
- package/dist/registry.d.ts +71 -0
- package/dist/registry.d.ts.map +1 -0
- package/dist/registry.js +201 -0
- package/dist/registry.js.map +1 -0
- package/dist/resolvers/index.d.ts +32 -0
- package/dist/resolvers/index.d.ts.map +1 -0
- package/dist/resolvers/index.js +17 -0
- package/dist/resolvers/index.js.map +1 -0
- package/dist/resolvers/maven.d.ts +33 -0
- package/dist/resolvers/maven.d.ts.map +1 -0
- package/dist/resolvers/maven.js +187 -0
- package/dist/resolvers/maven.js.map +1 -0
- package/dist/resolvers/npm.d.ts +13 -0
- package/dist/resolvers/npm.d.ts.map +1 -0
- package/dist/resolvers/npm.js +67 -0
- package/dist/resolvers/npm.js.map +1 -0
- package/dist/resolvers/pub.d.ts +13 -0
- package/dist/resolvers/pub.d.ts.map +1 -0
- package/dist/resolvers/pub.js +50 -0
- package/dist/resolvers/pub.js.map +1 -0
- package/dist/resolvers/pypi.d.ts +12 -0
- package/dist/resolvers/pypi.d.ts.map +1 -0
- package/dist/resolvers/pypi.js +60 -0
- package/dist/resolvers/pypi.js.map +1 -0
- package/dist/resolvers/utils.d.ts +15 -0
- package/dist/resolvers/utils.d.ts.map +1 -0
- package/dist/resolvers/utils.js +26 -0
- package/dist/resolvers/utils.js.map +1 -0
- package/dist/schemas.d.ts +490 -0
- package/dist/schemas.d.ts.map +1 -0
- package/dist/schemas.js +91 -0
- package/dist/schemas.js.map +1 -0
- package/dist/skill.d.ts +4 -0
- package/dist/skill.d.ts.map +1 -0
- package/dist/skill.js +53 -0
- package/dist/skill.js.map +1 -0
- package/dist/sources/github.d.ts +14 -0
- package/dist/sources/github.d.ts.map +1 -0
- package/dist/sources/github.js +114 -0
- package/dist/sources/github.js.map +1 -0
- package/dist/sources/index.d.ts +41 -0
- package/dist/sources/index.d.ts.map +1 -0
- package/dist/sources/index.js +14 -0
- package/dist/sources/index.js.map +1 -0
- package/dist/sources/llms-txt.d.ts +5 -0
- package/dist/sources/llms-txt.d.ts.map +1 -0
- package/dist/sources/llms-txt.js +33 -0
- package/dist/sources/llms-txt.js.map +1 -0
- package/dist/sources/npm.d.ts +14 -0
- package/dist/sources/npm.d.ts.map +1 -0
- package/dist/sources/npm.js +113 -0
- package/dist/sources/npm.js.map +1 -0
- package/dist/sources/web.d.ts +13 -0
- package/dist/sources/web.d.ts.map +1 -0
- package/dist/sources/web.js +143 -0
- package/dist/sources/web.js.map +1 -0
- package/dist/storage.d.ts +11 -0
- package/dist/storage.d.ts.map +1 -0
- package/dist/storage.js +76 -0
- package/dist/storage.js.map +1 -0
- package/package.json +9 -8
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { consola } from 'consola';
|
|
2
|
+
import { maxSatisfying, validRange } from 'semver';
|
|
3
|
+
import { parseRepoUrl } from './utils.js';
|
|
4
|
+
const RE_SEMVER_RANGE_CHARS = /[~^>=<|]/g;
|
|
5
|
+
/**
|
|
6
|
+
* Resolve an npm package to a GitHub repo + git tag.
|
|
7
|
+
*
|
|
8
|
+
* 1. Fetch `https://registry.npmjs.org/<name>`
|
|
9
|
+
* 2. Resolve version: dist-tag → exact, semver range → best match, exact → passthrough
|
|
10
|
+
* 3. Extract `repository.url` → `owner/repo`
|
|
11
|
+
* 4. Return `v{version}` as the git ref
|
|
12
|
+
*/
|
|
13
|
+
export class NpmResolver {
|
|
14
|
+
async resolve(name, version) {
|
|
15
|
+
const url = `https://registry.npmjs.org/${name}`;
|
|
16
|
+
const response = await fetch(url);
|
|
17
|
+
if (!response.ok) {
|
|
18
|
+
throw new Error(`npm registry returned ${response.status} for ${name}`);
|
|
19
|
+
}
|
|
20
|
+
const meta = await response.json();
|
|
21
|
+
const distTags = meta['dist-tags'] ?? {};
|
|
22
|
+
const allVersions = meta.versions ? Object.keys(meta.versions) : [];
|
|
23
|
+
// Resolve version: dist-tag → semver range → exact
|
|
24
|
+
let resolvedVersion;
|
|
25
|
+
if (distTags[version]) {
|
|
26
|
+
// dist-tag (e.g. 'latest', 'canary')
|
|
27
|
+
resolvedVersion = distTags[version];
|
|
28
|
+
}
|
|
29
|
+
else if (validRange(version) && version !== version.replace(RE_SEMVER_RANGE_CHARS, '')) {
|
|
30
|
+
// Semver range (e.g. '^15', '~3.22', '>=18.0.0')
|
|
31
|
+
const best = maxSatisfying(allVersions, version);
|
|
32
|
+
if (!best) {
|
|
33
|
+
throw new Error(`No version matching '${version}' found for npm package '${name}'. `
|
|
34
|
+
+ `Available dist-tags: ${Object.keys(distTags).join(', ')}`);
|
|
35
|
+
}
|
|
36
|
+
resolvedVersion = best;
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
// Exact version string
|
|
40
|
+
resolvedVersion = version;
|
|
41
|
+
}
|
|
42
|
+
// Verify the resolved version exists
|
|
43
|
+
if (allVersions.length > 0 && !allVersions.includes(resolvedVersion)) {
|
|
44
|
+
throw new Error(`Version '${resolvedVersion}' not found for npm package '${name}'. `
|
|
45
|
+
+ `Available dist-tags: ${Object.keys(distTags).join(', ')}`);
|
|
46
|
+
}
|
|
47
|
+
// Extract repository URL
|
|
48
|
+
const repoField = meta.repository;
|
|
49
|
+
const repoUrl = typeof repoField === 'string'
|
|
50
|
+
? repoField
|
|
51
|
+
: repoField?.url;
|
|
52
|
+
const repo = parseRepoUrl(repoUrl);
|
|
53
|
+
if (!repo) {
|
|
54
|
+
throw new Error(`Cannot resolve GitHub repository for npm package '${name}'. `
|
|
55
|
+
+ `The 'repository' field is missing or not a GitHub URL. `
|
|
56
|
+
+ `Use 'owner/repo' format instead: ask docs add owner/repo`);
|
|
57
|
+
}
|
|
58
|
+
consola.debug(`npm: ${name}@${version} → ${repo}@${resolvedVersion}`);
|
|
59
|
+
return {
|
|
60
|
+
repo,
|
|
61
|
+
ref: `v${resolvedVersion}`,
|
|
62
|
+
fallbackRefs: [resolvedVersion],
|
|
63
|
+
resolvedVersion,
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
//# sourceMappingURL=npm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"npm.js","sourceRoot":"","sources":["../../src/resolvers/npm.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AACjC,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,QAAQ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Fetch `https://pub.dev/api/packages/<name>`
|
|
6
|
+
* 2. If version is explicit, verify it exists
|
|
7
|
+
* 3. Extract `latest.pubspec.repository` → `owner/repo`
|
|
8
|
+
* 4. Use the version as the git ref
|
|
9
|
+
*/
|
|
10
|
+
export declare class PubResolver implements EcosystemResolver {
|
|
11
|
+
resolve(name: string, version: string): Promise<ResolveResult>;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=pub.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pub.d.ts","sourceRoot":"","sources":["../../src/resolvers/pub.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA;AAkBlE;;;;;;;GAOG;AACH,qBAAa,WAAY,YAAW,iBAAiB;IAC7C,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC;CA8CrE"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { consola } from 'consola';
|
|
2
|
+
import { parseRepoUrl } from './utils.js';
|
|
3
|
+
/**
|
|
4
|
+
* Resolve a pub.dev package to a GitHub repo + git tag.
|
|
5
|
+
*
|
|
6
|
+
* 1. Fetch `https://pub.dev/api/packages/<name>`
|
|
7
|
+
* 2. If version is explicit, verify it exists
|
|
8
|
+
* 3. Extract `latest.pubspec.repository` → `owner/repo`
|
|
9
|
+
* 4. Use the version as the git ref
|
|
10
|
+
*/
|
|
11
|
+
export class PubResolver {
|
|
12
|
+
async resolve(name, version) {
|
|
13
|
+
const url = `https://pub.dev/api/packages/${name}`;
|
|
14
|
+
const response = await fetch(url);
|
|
15
|
+
if (!response.ok) {
|
|
16
|
+
throw new Error(`pub.dev returned ${response.status} for ${name}`);
|
|
17
|
+
}
|
|
18
|
+
const meta = await response.json();
|
|
19
|
+
const latestVersion = meta.latest.version;
|
|
20
|
+
let resolvedVersion;
|
|
21
|
+
if (version === 'latest') {
|
|
22
|
+
resolvedVersion = latestVersion;
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
// Verify the requested version exists
|
|
26
|
+
const allVersions = meta.versions?.map(v => v.version) ?? [];
|
|
27
|
+
if (allVersions.length > 0 && !allVersions.includes(version)) {
|
|
28
|
+
throw new Error(`Version '${version}' not found for pub package '${name}'. `
|
|
29
|
+
+ `Latest version: ${latestVersion}`);
|
|
30
|
+
}
|
|
31
|
+
resolvedVersion = version;
|
|
32
|
+
}
|
|
33
|
+
// Extract repository URL
|
|
34
|
+
const repoUrl = meta.latest.pubspec.repository ?? meta.latest.pubspec.homepage;
|
|
35
|
+
const repo = parseRepoUrl(repoUrl);
|
|
36
|
+
if (!repo) {
|
|
37
|
+
throw new Error(`Cannot resolve GitHub repository for pub package '${name}'. `
|
|
38
|
+
+ `The 'repository' field is missing or not a GitHub URL. `
|
|
39
|
+
+ `Use 'owner/repo' format instead: ask docs add owner/repo`);
|
|
40
|
+
}
|
|
41
|
+
consola.debug(`pub: ${name}@${version} → ${repo}@${resolvedVersion}`);
|
|
42
|
+
return {
|
|
43
|
+
repo,
|
|
44
|
+
ref: resolvedVersion,
|
|
45
|
+
fallbackRefs: [`v${resolvedVersion}`],
|
|
46
|
+
resolvedVersion,
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=pub.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pub.js","sourceRoot":"","sources":["../../src/resolvers/pub.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AACjC,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AAgBzC;;;;;;;GAOG;AACH,MAAM,OAAO,WAAW;IACtB,KAAK,CAAC,OAAO,CAAC,IAAY,EAAE,OAAe;QACzC,MAAM,GAAG,GAAG,gCAAgC,IAAI,EAAE,CAAA;QAClD,MAAM,QAAQ,GA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AAI,IAAI,eAAe,EAAE,CAAC,CAAA;QAErE,OAAO;YACL,IAAI;YACJ,GAAG,EAAE,eAAe;YACpB,YAAY,EAAE,CAAC,IAAI,eAAe,EAAE,CAAC;YACrC,eAAe;SAChB,CAAA;IACH,CAAC;CACF"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { EcosystemResolver, ResolveResult } from './index.js';
|
|
2
|
+
/**
|
|
3
|
+
* Resolve a PyPI package to a GitHub repo + git tag.
|
|
4
|
+
*
|
|
5
|
+
* 1. Fetch `https://pypi.org/pypi/<name>/json` (or `<name>/<version>/json`)
|
|
6
|
+
* 2. Extract `info.project_urls` → find a GitHub URL
|
|
7
|
+
* 3. Use the PyPI version as the git ref
|
|
8
|
+
*/
|
|
9
|
+
export declare class PypiResolver implements EcosystemResolver {
|
|
10
|
+
resolve(name: string, version: string): Promise<ResolveResult>;
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=pypi.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pypi.d.ts","sourceRoot":"","sources":["../../src/resolvers/pypi.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA;AAyBlE;;;;;;GAMG;AACH,qBAAa,YAAa,YAAW,iBAAiB;IAC9C,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC;CAiDrE"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { consola } from 'consola';
|
|
2
|
+
import { parseRepoUrl } from './utils.js';
|
|
3
|
+
/** Keys under `project_urls` most likely to contain a source-code link. */
|
|
4
|
+
const SOURCE_URL_KEYS = [
|
|
5
|
+
'Source',
|
|
6
|
+
'Source Code',
|
|
7
|
+
'Repository',
|
|
8
|
+
'GitHub',
|
|
9
|
+
'Code',
|
|
10
|
+
'Homepage',
|
|
11
|
+
];
|
|
12
|
+
/**
|
|
13
|
+
* Resolve a PyPI package to a GitHub repo + git tag.
|
|
14
|
+
*
|
|
15
|
+
* 1. Fetch `https://pypi.org/pypi/<name>/json` (or `<name>/<version>/json`)
|
|
16
|
+
* 2. Extract `info.project_urls` → find a GitHub URL
|
|
17
|
+
* 3. Use the PyPI version as the git ref
|
|
18
|
+
*/
|
|
19
|
+
export class PypiResolver {
|
|
20
|
+
async resolve(name, version) {
|
|
21
|
+
const isExplicit = version !== 'latest';
|
|
22
|
+
const url = isExplicit
|
|
23
|
+
? `https://pypi.org/pypi/${name}/${version}/json`
|
|
24
|
+
: `https://pypi.org/pypi/${name}/json`;
|
|
25
|
+
const response = await fetch(url);
|
|
26
|
+
if (!response.ok) {
|
|
27
|
+
throw new Error(`PyPI returned ${response.status} for ${name}${isExplicit ? `@${version}` : ''}`);
|
|
28
|
+
}
|
|
29
|
+
const meta = await response.json();
|
|
30
|
+
const resolvedVersion = meta.info.version;
|
|
31
|
+
// Find GitHub URL from project_urls
|
|
32
|
+
const projectUrls = meta.info.project_urls ?? {};
|
|
33
|
+
let repoUrl = null;
|
|
34
|
+
for (const key of SOURCE_URL_KEYS) {
|
|
35
|
+
const candidate = projectUrls[key];
|
|
36
|
+
if (candidate && candidate.includes('github.com')) {
|
|
37
|
+
repoUrl = candidate;
|
|
38
|
+
break;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
// Fall back to home_page
|
|
42
|
+
if (!repoUrl && meta.info.home_page?.includes('github.com')) {
|
|
43
|
+
repoUrl = meta.info.home_page;
|
|
44
|
+
}
|
|
45
|
+
const repo = parseRepoUrl(repoUrl);
|
|
46
|
+
if (!repo) {
|
|
47
|
+
throw new Error(`Cannot resolve GitHub repository for PyPI package '${name}'. `
|
|
48
|
+
+ `The 'project_urls' field does not contain a GitHub URL. `
|
|
49
|
+
+ `Use 'owner/repo' format instead: ask docs add owner/repo`);
|
|
50
|
+
}
|
|
51
|
+
consola.debug(`pypi: ${name}@${version} → ${repo}@${resolvedVersion}`);
|
|
52
|
+
return {
|
|
53
|
+
repo,
|
|
54
|
+
ref: `v${resolvedVersion}`,
|
|
55
|
+
fallbackRefs: [resolvedVersion],
|
|
56
|
+
resolvedVersion,
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
//# sourceMappingURL=pypi.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pypi.js","sourceRoot":"","sources":["../../src/resolvers/pypi.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AACjC,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AAazC,2EAA2E;AAC3E,MAAM,eAAe,GAAG;IACtB,QAAQ;IACR,aAAa;IACb,YAAY;IACZ,QAAQ;IACR,MAAM;IACN,UAAU;CACX,CAAA;AAED;;;;;;GAMG;AACH,MAAM,OAAO,YAAY;IACvB,KAAK,CAAC,OAAO,CAAC,IAAY,EAAE,OAAe;QACzC,MAAM,UAAU,GAAG,OAAO,KAAK,QAAQ,CAAA;QACvC,MAAM,GAAG,GAAG,UAAU;YACpB,CAAC,CAAC,yBAAyB,IAAI,IAAI,OAAO,OAAO;YACjD,CAAC,CAAC,yBAAyB,IAAI,OAAO,CAAA;QAExC,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,GAAG,CAAC,CAAA;QACjC,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;YACjB,MAAM,IAAI,KAAK,CAAC,iBAAiB,QAAQ,CAAC,MAAM,QAAQ,IAAI,GAAG,UAAU,CAAC,CAAC,CAAC,IAAI,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAA;QACnG,CAAC;QAED,MAAM,IAAI,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAqB,CAAA;QACrD,MAAM,eAAe,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,CAAA;QAEzC,oCAAoC;QACpC,MAAM,WAAW,GAAG,IAAI,CAAC,IAAI,CAAC,YAAY,IAAI,EAAE,CAAA;QAChD,IAAI,OAAO,GAAkB,IAAI,CAAA;QAEjC,KAAK,MAAM,GAAG,IAAI,eAAe,EAAE,CAAC;YAClC,MAAM,SAAS,GAAG,WAAW,CAAC,GAAG,CAAC,CAAA;YAClC,IAAI,SAAS,IAAI,SAAS,CAAC,QAAQ,CAAC,YAAY,CAAC,EAAE,CAAC;gBAClD,OAAO,GAAG,SAAS,CAAA;gBACnB,MAAK;YACP,CAAC;QACH,CAAC;QAED,yBAAyB;QACzB,IAAI,CAAC,OAAO,IAAI,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,QAAQ,CAAC,YAAY,CAAC,EAAE,CAAC;YAC5D,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,SAAS,CAAA;QAC/B,CAAC;QAED,MAAM,IAAI,GAAG,YAAY,CAAC,OAAO,CAAC,CAAA;QAClC,IAAI,CAAC,IAAI,EAAE,CAAC;YACV,MAAM,IAAI,KAAK,CACb,sDAAsD,IAAI,KAAK;kBAC7D,0DAA0D;kBAC1D,0DAA0D,CAC7D,CAAA;QACH,CAAC;QAED,OAAO,CAAC,KAAK,CAAC,SAAS,IAAI,IAAI,OAAO,MAAM,IAAI,IAAI,eAAe,EAAE,CAAC,CAAA;QAEtE,OAAO;YACL,IAAI;YACJ,GAAG,EAAE,IAAI,eAAe,EAAE;YAC1B,YAAY,EAAE,CAAC,eAAe,CAAC;YAC/B,eAAe;SAChB,CAAA;IACH,CAAC;CACF"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Parse a repository URL into `owner/repo` form.
|
|
3
|
+
*
|
|
4
|
+
* Handles common formats:
|
|
5
|
+
* - `git+https://github.com/owner/repo.git`
|
|
6
|
+
* - `https://github.com/owner/repo`
|
|
7
|
+
* - `git://github.com/owner/repo.git`
|
|
8
|
+
* - `ssh://git@github.com/owner/repo.git`
|
|
9
|
+
* - `github.com/owner/repo`
|
|
10
|
+
* - URLs with extra path segments (`/tree/main`, etc.)
|
|
11
|
+
*
|
|
12
|
+
* Returns `null` for non-GitHub URLs, empty strings, or undefined.
|
|
13
|
+
*/
|
|
14
|
+
export declare function parseRepoUrl(url: string | undefined | null): string | null;
|
|
15
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/resolvers/utils.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;;GAYG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,GAAG,MAAM,GAAG,IAAI,CAW1E"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
const RE_GITHUB_URL = /github\.com[/:]([^/]+)\/([^/#?\s]+)/;
|
|
2
|
+
const RE_DOT_GIT = /\.git$/;
|
|
3
|
+
/**
|
|
4
|
+
* Parse a repository URL into `owner/repo` form.
|
|
5
|
+
*
|
|
6
|
+
* Handles common formats:
|
|
7
|
+
* - `git+https://github.com/owner/repo.git`
|
|
8
|
+
* - `https://github.com/owner/repo`
|
|
9
|
+
* - `git://github.com/owner/repo.git`
|
|
10
|
+
* - `ssh://git@github.com/owner/repo.git`
|
|
11
|
+
* - `github.com/owner/repo`
|
|
12
|
+
* - URLs with extra path segments (`/tree/main`, etc.)
|
|
13
|
+
*
|
|
14
|
+
* Returns `null` for non-GitHub URLs, empty strings, or undefined.
|
|
15
|
+
*/
|
|
16
|
+
export function parseRepoUrl(url) {
|
|
17
|
+
if (!url)
|
|
18
|
+
return null;
|
|
19
|
+
const match = RE_GITHUB_URL.exec(url);
|
|
20
|
+
if (!match)
|
|
21
|
+
return null;
|
|
22
|
+
const owner = match[1];
|
|
23
|
+
const repo = match[2].replace(RE_DOT_GIT, '');
|
|
24
|
+
return `${owner}/${repo}`;
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/resolvers/utils.ts"],"names":[],"mappings":"AAAA,MAAM,aAAa,GAAG,qCAAqC,CAAA;AAC3D,MAAM,UAAU,GAAG,QAAQ,CAAA;AAE3B;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,YAAY,CAAC,GAA8B;IACzD,IAAI,CAAC,GAAG;QACN,OAAO,IAAI,CAAA;IAEb,MAAM,KAAK,GAAG,aAAa,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;IACrC,IAAI,CAAC,KAAK;QACR,OAAO,IAAI,CAAA;IAEb,MAAM,KAAK,GAAG,KAAK,CAAC,CAAC,CAAC,CAAA;IACtB,MAAM,IAAI,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC,CAAA;IAC7C,OAAO,GAAG,KAAK,IAAI,IAAI,EAAE,CAAA;AAC3B,CAAC"}
|