@ankhorage/repository 0.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/CHANGELOG.md +43 -0
- package/LICENSE +21 -0
- package/README.md +53 -0
- package/dist/cli/commands/connect/definitions/ConnectCommandOptions.d.ts +8 -0
- package/dist/cli/commands/connect/definitions/ConnectCommandOptions.d.ts.map +1 -0
- package/dist/cli/commands/connect/definitions/ConnectCommandOptions.js +2 -0
- package/dist/cli/commands/connect/definitions/ConnectCommandOptions.js.map +1 -0
- package/dist/cli/commands/connect/parseConnectCommandOptions.d.ts +4 -0
- package/dist/cli/commands/connect/parseConnectCommandOptions.d.ts.map +1 -0
- package/dist/cli/commands/connect/parseConnectCommandOptions.js +38 -0
- package/dist/cli/commands/connect/parseConnectCommandOptions.js.map +1 -0
- package/dist/cli/commands/connect/runConnectCommandAsync.d.ts +10 -0
- package/dist/cli/commands/connect/runConnectCommandAsync.d.ts.map +1 -0
- package/dist/cli/commands/connect/runConnectCommandAsync.js +29 -0
- package/dist/cli/commands/connect/runConnectCommandAsync.js.map +1 -0
- package/dist/cli/index.d.ts +5 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +5 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/cli/provider/createRepositoryRuntimeProvider.d.ts +25 -0
- package/dist/cli/provider/createRepositoryRuntimeProvider.d.ts.map +1 -0
- package/dist/cli/provider/createRepositoryRuntimeProvider.js +20 -0
- package/dist/cli/provider/createRepositoryRuntimeProvider.js.map +1 -0
- package/dist/cli/provider/createRepositoryRuntimeProvider.test.d.ts +2 -0
- package/dist/cli/provider/createRepositoryRuntimeProvider.test.d.ts.map +1 -0
- package/dist/cli/provider/createRepositoryRuntimeProvider.test.js +12 -0
- package/dist/cli/provider/createRepositoryRuntimeProvider.test.js.map +1 -0
- package/dist/connection/adapters/createLocalProjectSnapshotReader.d.ts +4 -0
- package/dist/connection/adapters/createLocalProjectSnapshotReader.d.ts.map +1 -0
- package/dist/connection/adapters/createLocalProjectSnapshotReader.js +123 -0
- package/dist/connection/adapters/createLocalProjectSnapshotReader.js.map +1 -0
- package/dist/connection/adapters/createLocalRepositoryManifestStore.d.ts +4 -0
- package/dist/connection/adapters/createLocalRepositoryManifestStore.d.ts.map +1 -0
- package/dist/connection/adapters/createLocalRepositoryManifestStore.js +75 -0
- package/dist/connection/adapters/createLocalRepositoryManifestStore.js.map +1 -0
- package/dist/connection/adapters/createLocalRepositoryManifestStore.test.d.ts +2 -0
- package/dist/connection/adapters/createLocalRepositoryManifestStore.test.d.ts.map +1 -0
- package/dist/connection/adapters/createLocalRepositoryManifestStore.test.js +25 -0
- package/dist/connection/adapters/createLocalRepositoryManifestStore.test.js.map +1 -0
- package/dist/connection/definitions/ProjectSnapshot.d.ts +8 -0
- package/dist/connection/definitions/ProjectSnapshot.d.ts.map +1 -0
- package/dist/connection/definitions/ProjectSnapshot.js +2 -0
- package/dist/connection/definitions/ProjectSnapshot.js.map +1 -0
- package/dist/connection/definitions/ProjectSnapshotEntry.d.ts +10 -0
- package/dist/connection/definitions/ProjectSnapshotEntry.d.ts.map +1 -0
- package/dist/connection/definitions/ProjectSnapshotEntry.js +2 -0
- package/dist/connection/definitions/ProjectSnapshotEntry.js.map +1 -0
- package/dist/connection/definitions/RepositoryConnectionOptions.d.ts +8 -0
- package/dist/connection/definitions/RepositoryConnectionOptions.d.ts.map +1 -0
- package/dist/connection/definitions/RepositoryConnectionOptions.js +2 -0
- package/dist/connection/definitions/RepositoryConnectionOptions.js.map +1 -0
- package/dist/connection/definitions/RepositoryConnectionResult.d.ts +17 -0
- package/dist/connection/definitions/RepositoryConnectionResult.d.ts.map +1 -0
- package/dist/connection/definitions/RepositoryConnectionResult.js +2 -0
- package/dist/connection/definitions/RepositoryConnectionResult.js.map +1 -0
- package/dist/connection/ports/ProjectSnapshotReader.d.ts +6 -0
- package/dist/connection/ports/ProjectSnapshotReader.d.ts.map +1 -0
- package/dist/connection/ports/ProjectSnapshotReader.js +2 -0
- package/dist/connection/ports/ProjectSnapshotReader.js.map +1 -0
- package/dist/connection/ports/RepositoryManifestStore.d.ts +6 -0
- package/dist/connection/ports/RepositoryManifestStore.d.ts.map +1 -0
- package/dist/connection/ports/RepositoryManifestStore.js +2 -0
- package/dist/connection/ports/RepositoryManifestStore.js.map +1 -0
- package/dist/connection/services/connectRepositoryAsync.d.ts +5 -0
- package/dist/connection/services/connectRepositoryAsync.d.ts.map +1 -0
- package/dist/connection/services/connectRepositoryAsync.js +55 -0
- package/dist/connection/services/connectRepositoryAsync.js.map +1 -0
- package/dist/connection/services/connectRepositoryAsync.test.d.ts +2 -0
- package/dist/connection/services/connectRepositoryAsync.test.d.ts.map +1 -0
- package/dist/connection/services/connectRepositoryAsync.test.js +27 -0
- package/dist/connection/services/connectRepositoryAsync.test.js.map +1 -0
- package/dist/connection/utils/getProjectSnapshotPaths.d.ts +5 -0
- package/dist/connection/utils/getProjectSnapshotPaths.d.ts.map +1 -0
- package/dist/connection/utils/getProjectSnapshotPaths.js +5 -0
- package/dist/connection/utils/getProjectSnapshotPaths.js.map +1 -0
- package/dist/github/index.d.ts +5 -0
- package/dist/github/index.d.ts.map +1 -0
- package/dist/github/index.js +2 -0
- package/dist/github/index.js.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -0
- package/dist/index.test.d.ts +2 -0
- package/dist/index.test.d.ts.map +1 -0
- package/dist/index.test.js +35 -0
- package/dist/index.test.js.map +1 -0
- package/dist/metadata/index.d.ts +12 -0
- package/dist/metadata/index.d.ts.map +1 -0
- package/dist/metadata/index.js +12 -0
- package/dist/metadata/index.js.map +1 -0
- package/dist/metadata/repositoryPackageMetadata.d.ts +13 -0
- package/dist/metadata/repositoryPackageMetadata.d.ts.map +1 -0
- package/dist/metadata/repositoryPackageMetadata.js +14 -0
- package/dist/metadata/repositoryPackageMetadata.js.map +1 -0
- package/dist/providers/github/adapters/createGhCliRepositoryGateway.d.ts +13 -0
- package/dist/providers/github/adapters/createGhCliRepositoryGateway.d.ts.map +1 -0
- package/dist/providers/github/adapters/createGhCliRepositoryGateway.js +228 -0
- package/dist/providers/github/adapters/createGhCliRepositoryGateway.js.map +1 -0
- package/dist/providers/github/adapters/ghCliJson.d.ts +22 -0
- package/dist/providers/github/adapters/ghCliJson.d.ts.map +1 -0
- package/dist/providers/github/adapters/ghCliJson.js +44 -0
- package/dist/providers/github/adapters/ghCliJson.js.map +1 -0
- package/dist/providers/github/definitions/GitHubRepositoryConnectionOptions.d.ts +16 -0
- package/dist/providers/github/definitions/GitHubRepositoryConnectionOptions.d.ts.map +1 -0
- package/dist/providers/github/definitions/GitHubRepositoryConnectionOptions.js +2 -0
- package/dist/providers/github/definitions/GitHubRepositoryConnectionOptions.js.map +1 -0
- package/dist/providers/github/definitions/GitHubRepositoryConnectionResult.d.ts +23 -0
- package/dist/providers/github/definitions/GitHubRepositoryConnectionResult.d.ts.map +1 -0
- package/dist/providers/github/definitions/GitHubRepositoryConnectionResult.js +2 -0
- package/dist/providers/github/definitions/GitHubRepositoryConnectionResult.js.map +1 -0
- package/dist/providers/github/definitions/GitHubRepositoryVisibility.d.ts +2 -0
- package/dist/providers/github/definitions/GitHubRepositoryVisibility.d.ts.map +1 -0
- package/dist/providers/github/definitions/GitHubRepositoryVisibility.js +2 -0
- package/dist/providers/github/definitions/GitHubRepositoryVisibility.js.map +1 -0
- package/dist/providers/github/definitions/index.d.ts +3 -0
- package/dist/providers/github/definitions/index.d.ts.map +1 -0
- package/dist/providers/github/definitions/index.js +2 -0
- package/dist/providers/github/definitions/index.js.map +1 -0
- package/dist/providers/github/ports/GitHubRepositoryGateway.d.ts +42 -0
- package/dist/providers/github/ports/GitHubRepositoryGateway.d.ts.map +1 -0
- package/dist/providers/github/ports/GitHubRepositoryGateway.js +2 -0
- package/dist/providers/github/ports/GitHubRepositoryGateway.js.map +1 -0
- package/dist/providers/github/services/connectGitHubRepositoryAsync.d.ts +5 -0
- package/dist/providers/github/services/connectGitHubRepositoryAsync.d.ts.map +1 -0
- package/dist/providers/github/services/connectGitHubRepositoryAsync.js +70 -0
- package/dist/providers/github/services/connectGitHubRepositoryAsync.js.map +1 -0
- package/dist/providers/github/services/inspectGitHubRepositoryPreflightAsync.d.ts +21 -0
- package/dist/providers/github/services/inspectGitHubRepositoryPreflightAsync.d.ts.map +1 -0
- package/dist/providers/github/services/inspectGitHubRepositoryPreflightAsync.js +72 -0
- package/dist/providers/github/services/inspectGitHubRepositoryPreflightAsync.js.map +1 -0
- package/dist/providers/github/services/publishGitHubProjectSnapshotAsync.d.ts +8 -0
- package/dist/providers/github/services/publishGitHubProjectSnapshotAsync.d.ts.map +1 -0
- package/dist/providers/github/services/publishGitHubProjectSnapshotAsync.js +12 -0
- package/dist/providers/github/services/publishGitHubProjectSnapshotAsync.js.map +1 -0
- package/dist/readme-usage.d.ts +2 -0
- package/dist/readme-usage.d.ts.map +1 -0
- package/dist/readme-usage.js +32 -0
- package/dist/readme-usage.js.map +1 -0
- package/package.json +89 -0
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { basename, resolve } from 'node:path';
|
|
2
|
+
/** Inspect all local and remote state before allowing a repository mutation. */
|
|
3
|
+
export async function inspectGitHubRepositoryPreflightAsync(options, gateway, snapshotReader, manifestStore) {
|
|
4
|
+
const projectPath = options.projectPath ?? process.cwd();
|
|
5
|
+
await gateway.assertAvailableAsync();
|
|
6
|
+
await gateway.assertAuthenticatedAsync();
|
|
7
|
+
const manifest = await manifestStore.readConfigAsync(projectPath);
|
|
8
|
+
const owner = options.owner ?? (await gateway.getAuthenticatedOwnerAsync());
|
|
9
|
+
const name = options.name ?? manifest?.name ?? getDefaultRepositoryName(projectPath);
|
|
10
|
+
validateName(owner, name);
|
|
11
|
+
const visibility = options.visibility ?? 'private';
|
|
12
|
+
const identity = {
|
|
13
|
+
owner,
|
|
14
|
+
name,
|
|
15
|
+
url: `https://github.com/${owner}/${name}`,
|
|
16
|
+
defaultBranch: 'main',
|
|
17
|
+
};
|
|
18
|
+
if (manifest && !matchesIdentity(manifest, identity)) {
|
|
19
|
+
throw new PreflightError('conflict', 'repository-mismatch', 'Local repository manifest does not match the requested target.');
|
|
20
|
+
}
|
|
21
|
+
const prospectiveManifest = { provider: 'github', ...identity };
|
|
22
|
+
const snapshot = await snapshotReader.readAsync(projectPath, prospectiveManifest);
|
|
23
|
+
const target = { ...identity, visibility };
|
|
24
|
+
const remote = await gateway.inspectRepositoryAsync(target);
|
|
25
|
+
validateRemoteState(remote, manifest, identity, visibility);
|
|
26
|
+
return { target, identity, manifest, snapshot, remote };
|
|
27
|
+
}
|
|
28
|
+
export class PreflightError extends Error {
|
|
29
|
+
kind;
|
|
30
|
+
code;
|
|
31
|
+
constructor(kind, code, message) {
|
|
32
|
+
super(message);
|
|
33
|
+
this.name = 'PreflightError';
|
|
34
|
+
this.kind = kind;
|
|
35
|
+
this.code = code;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
/** Validate GitHub owner and repository names without invoking the provider. */
|
|
39
|
+
function validateName(owner, name) {
|
|
40
|
+
if (!/^[A-Za-z0-9](?:[A-Za-z0-9-]{0,98}[A-Za-z0-9])?$/u.test(owner)) {
|
|
41
|
+
throw new PreflightError('conflict', 'invalid-owner', 'GitHub owner is invalid.');
|
|
42
|
+
}
|
|
43
|
+
if (!/^[A-Za-z0-9._-]{1,100}$/u.test(name) || name === '.' || name === '..') {
|
|
44
|
+
throw new PreflightError('conflict', 'invalid-name', 'GitHub repository name is invalid.');
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
/** Compare only the canonical identity fields persisted in the repository manifest. */
|
|
48
|
+
function matchesIdentity(repository, identity) {
|
|
49
|
+
return (repository?.provider === 'github' &&
|
|
50
|
+
repository.owner === identity.owner &&
|
|
51
|
+
repository.name === identity.name &&
|
|
52
|
+
repository.url === identity.url);
|
|
53
|
+
}
|
|
54
|
+
/** Reject remote state that cannot be safely resumed or connected. */
|
|
55
|
+
function validateRemoteState(remote, manifest, identity, visibility) {
|
|
56
|
+
if (remote.exists && !manifest) {
|
|
57
|
+
throw new PreflightError('conflict', 'local-manifest-missing', 'An existing repository cannot be adopted without a matching local manifest.');
|
|
58
|
+
}
|
|
59
|
+
if (remote.exists && remote.visibility !== undefined && remote.visibility !== visibility) {
|
|
60
|
+
throw new PreflightError('conflict', 'visibility-mismatch', 'The existing repository has different visibility.');
|
|
61
|
+
}
|
|
62
|
+
if (remote.exists && remote.mainManifest !== undefined) {
|
|
63
|
+
if (!matchesIdentity(remote.mainManifest, identity)) {
|
|
64
|
+
throw new PreflightError('conflict', 'remote-manifest-mismatch', 'The remote repository manifest points to another repository.');
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
/** Derive a stable repository name for projects without a repository manifest. */
|
|
69
|
+
function getDefaultRepositoryName(projectPath) {
|
|
70
|
+
return basename(resolve(projectPath));
|
|
71
|
+
}
|
|
72
|
+
//# sourceMappingURL=inspectGitHubRepositoryPreflightAsync.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inspectGitHubRepositoryPreflightAsync.js","sourceRoot":"","sources":["../../../../src/providers/github/services/inspectGitHubRepositoryPreflightAsync.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAyB9C,gFAAgF;AAChF,MAAM,CAAC,KAAK,UAAU,qCAAqC,CACzD,OAA0C,EAC1C,OAAgC,EAChC,cAAqC,EACrC,aAAsC;IAEtC,MAAM,WAAW,GAAG,OAAO,CAAC,WAAW,IAAI,OAAO,CAAC,GAAG,EAAE,CAAC;IACzD,MAAM,OAAO,CAAC,oBAAoB,EAAE,CAAC;IACrC,MAAM,OAAO,CAAC,wBAAwB,EAAE,CAAC;IACzC,MAAM,QAAQ,GAAG,MAAM,aAAa,CAAC,eAAe,CAAC,WAAW,CAAC,CAAC;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AAU,EAAE,CAAC;QACzF,MAAM,IAAI,cAAc,CACtB,UAAU,EACV,qBAAqB,EACrB,mDAAmD,CACpD,CAAC;IACJ,CAAC;IACD,IAAI,MAAM,CAAC,MAAM,IAAI,MAAM,CAAC,YAAY,KAAK,SAAS,EAAE,CAAC;QACvD,IAAI,CAAC,eAAe,CAAC,MAAM,CAAC,YAAY,EAAE,QAAQ,CAAC,EAAE,CAAC;YACpD,MAAM,IAAI,cAAc,CACtB,UAAU,EACV,0BAA0B,EAC1B,8DAA8D,CAC/D,CAAC;QACJ,CAAC;IACH,CAAC;AACH,CAAC;AAED,kFAAkF;AAClF,SAAS,wBAAwB,CAAC,WAAmB;IACnD,OAAO,QAAQ,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC;AACxC,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { ProjectSnapshot } from '../../../connection/definitions/ProjectSnapshot.js';
|
|
2
|
+
import type { GitHubRepositoryGateway, GitHubRepositoryTarget } from '../ports/GitHubRepositoryGateway.js';
|
|
3
|
+
export interface GitHubSnapshotPublication {
|
|
4
|
+
readonly commitSha: string;
|
|
5
|
+
}
|
|
6
|
+
/** Publish a complete snapshot through bootstrap, one app commit, and verified cleanup. */
|
|
7
|
+
export declare function publishGitHubProjectSnapshotAsync(gateway: GitHubRepositoryGateway, target: GitHubRepositoryTarget, snapshot: ProjectSnapshot, existingBootstrapCommitSha?: string): Promise<GitHubSnapshotPublication>;
|
|
8
|
+
//# sourceMappingURL=publishGitHubProjectSnapshotAsync.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"publishGitHubProjectSnapshotAsync.d.ts","sourceRoot":"","sources":["../../../../src/providers/github/services/publishGitHubProjectSnapshotAsync.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oDAAoD,CAAC;AAC1F,OAAO,KAAK,EAEV,uBAAuB,EACvB,sBAAsB,EACvB,MAAM,qCAAqC,CAAC;AAE7C,MAAM,WAAW,yBAAyB;IACxC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;CAC5B;AAED,2FAA2F;AAC3F,wBAAsB,iCAAiC,CACrD,OAAO,EAAE,uBAAuB,EAChC,MAAM,EAAE,sBAAsB,EAC9B,QAAQ,EAAE,eAAe,EACzB,0BAA0B,CAAC,EAAE,MAAM,GAClC,OAAO,CAAC,yBAAyB,CAAC,CASpC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/** Publish a complete snapshot through bootstrap, one app commit, and verified cleanup. */
|
|
2
|
+
export async function publishGitHubProjectSnapshotAsync(gateway, target, snapshot, existingBootstrapCommitSha) {
|
|
3
|
+
const bootstrap = existingBootstrapCommitSha
|
|
4
|
+
? { branch: 'ankh-bootstrap', commitSha: existingBootstrapCommitSha }
|
|
5
|
+
: await gateway.initializeBootstrapAsync(target);
|
|
6
|
+
const published = await gateway.publishSnapshotAsync(target, snapshot, bootstrap.commitSha);
|
|
7
|
+
await gateway.verifyPublishedSnapshotAsync(target, snapshot, published.commitSha);
|
|
8
|
+
await gateway.setDefaultBranchAsync(target);
|
|
9
|
+
await gateway.deleteBootstrapAsync(target, bootstrap);
|
|
10
|
+
return { commitSha: published.commitSha };
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=publishGitHubProjectSnapshotAsync.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"publishGitHubProjectSnapshotAsync.js","sourceRoot":"","sources":["../../../../src/providers/github/services/publishGitHubProjectSnapshotAsync.ts"],"names":[],"mappings":"AAWA,2FAA2F;AAC3F,MAAM,CAAC,KAAK,UAAU,iCAAiC,CACrD,OAAgC,EAChC,MAA8B,EAC9B,QAAyB,EACzB,0BAAmC;IAEnC,MAAM,SAAS,GAAoB,0BAA0B;QAC3D,CAAC,CAAC,EAAE,MAAM,EAAE,gBAAgB,EAAE,SAAS,EAAE,0BAA0B,EAAE;QACrE,CAAC,CAAC,MAAM,OAAO,CAAC,wBAAwB,CAAC,MAAM,CAAC,CAAC;IACnD,MAAM,SAAS,GAAG,MAAM,OAAO,CAAC,oBAAoB,CAAC,MAAM,EAAE,QAAQ,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IAC5F,MAAM,OAAO,CAAC,4BAA4B,CAAC,MAAM,EAAE,QAAQ,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IAClF,MAAM,OAAO,CAAC,qBAAqB,CAAC,MAAM,CAAC,CAAC;IAC5C,MAAM,OAAO,CAAC,oBAAoB,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;IACtD,OAAO,EAAE,SAAS,EAAE,SAAS,CAAC,SAAS,EAAE,CAAC;AAC5C,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"readme-usage.d.ts","sourceRoot":"","sources":["../src/readme-usage.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/***
|
|
2
|
+
* Connect a project folder to its source repository
|
|
3
|
+
*
|
|
4
|
+
* `@ankhorage/repository` consumes only the project's `RepositoryManifest` slice and delegates
|
|
5
|
+
* GitHub operations to the local authenticated `gh` adapter. It creates a missing repository,
|
|
6
|
+
* publishes the project snapshot to `main`, stores only the repository slice in
|
|
7
|
+
* `.ankhorage/repository.json`, and refuses unrelated existing repositories.
|
|
8
|
+
*
|
|
9
|
+
* See [`examples/basic-usage.ts`](../examples/basic-usage.ts) for a complete programmatic example.
|
|
10
|
+
*
|
|
11
|
+
* @usage
|
|
12
|
+
*/
|
|
13
|
+
import { connectRepositoryAsync } from '@ankhorage/repository';
|
|
14
|
+
const result = await connectRepositoryAsync({
|
|
15
|
+
projectPath: './my-project',
|
|
16
|
+
repository: {
|
|
17
|
+
provider: 'github',
|
|
18
|
+
owner: 'ankhorage',
|
|
19
|
+
name: 'my-project',
|
|
20
|
+
url: 'https://github.com/ankhorage/my-project',
|
|
21
|
+
defaultBranch: 'main',
|
|
22
|
+
},
|
|
23
|
+
visibility: 'private',
|
|
24
|
+
});
|
|
25
|
+
if (result.status === 'conflict' || result.status === 'recoverable-failure') {
|
|
26
|
+
console.error(`${result.status}: ${result.message}`);
|
|
27
|
+
process.exitCode = 1;
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
console.log(JSON.stringify(result));
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=readme-usage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"readme-usage.js","sourceRoot":"","sources":["../src/readme-usage.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AAE/D,MAAM,MAAM,GAAG,MAAM,sBAAsB,CAAC;IAC1C,WAAW,EAAE,cAAc;IAC3B,UAAU,EAAE;QACV,QAAQ,EAAE,QAAQ;QAClB,KAAK,EAAE,WAAW;QAClB,IAAI,EAAE,YAAY;QAClB,GAAG,EAAE,yCAAyC;QAC9C,aAAa,EAAE,MAAM;KACtB;IACD,UAAU,EAAE,SAAS;CACtB,CAAC,CAAC;AAEH,IAAI,MAAM,CAAC,MAAM,KAAK,UAAU,IAAI,MAAM,CAAC,MAAM,KAAK,qBAAqB,EAAE,CAAC;IAC5E,OAAO,CAAC,KAAK,CAAC,GAAG,MAAM,CAAC,MAAM,KAAK,MAAM,CAAC,OAAO,EAAE,CAAC,CAAC;IACrD,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;AACvB,CAAC;KAAM,CAAC;IACN,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC;AACtC,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@ankhorage/repository",
|
|
3
|
+
"version": "0.4.0",
|
|
4
|
+
"description": "Standalone repository capability for connecting and managing an app project's source repository.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"sideEffects": false,
|
|
8
|
+
"homepage": "https://github.com/ankhorage/repository#readme",
|
|
9
|
+
"bugs": {
|
|
10
|
+
"url": "https://github.com/ankhorage/repository/issues"
|
|
11
|
+
},
|
|
12
|
+
"repository": {
|
|
13
|
+
"type": "git",
|
|
14
|
+
"url": "git+https://github.com/ankhorage/repository.git"
|
|
15
|
+
},
|
|
16
|
+
"keywords": [
|
|
17
|
+
"ankhorage",
|
|
18
|
+
"repository",
|
|
19
|
+
"github",
|
|
20
|
+
"git",
|
|
21
|
+
"cli",
|
|
22
|
+
"automation",
|
|
23
|
+
"typescript",
|
|
24
|
+
"bun"
|
|
25
|
+
],
|
|
26
|
+
"main": "./dist/index.js",
|
|
27
|
+
"types": "./dist/index.d.ts",
|
|
28
|
+
"files": [
|
|
29
|
+
"dist",
|
|
30
|
+
"README.md",
|
|
31
|
+
"CHANGELOG.md",
|
|
32
|
+
"LICENSE"
|
|
33
|
+
],
|
|
34
|
+
"exports": {
|
|
35
|
+
".": {
|
|
36
|
+
"types": "./dist/index.d.ts",
|
|
37
|
+
"default": "./dist/index.js"
|
|
38
|
+
},
|
|
39
|
+
"./github": {
|
|
40
|
+
"types": "./dist/github/index.d.ts",
|
|
41
|
+
"default": "./dist/github/index.js"
|
|
42
|
+
},
|
|
43
|
+
"./metadata": {
|
|
44
|
+
"types": "./dist/metadata/index.d.ts",
|
|
45
|
+
"default": "./dist/metadata/index.js"
|
|
46
|
+
},
|
|
47
|
+
"./cli": {
|
|
48
|
+
"types": "./dist/cli/index.d.ts",
|
|
49
|
+
"default": "./dist/cli/index.js"
|
|
50
|
+
},
|
|
51
|
+
"./package.json": "./package.json"
|
|
52
|
+
},
|
|
53
|
+
"ankh": {
|
|
54
|
+
"category": "repository",
|
|
55
|
+
"provider": "./dist/cli/index.js",
|
|
56
|
+
"capabilities": [
|
|
57
|
+
"repository.connect"
|
|
58
|
+
]
|
|
59
|
+
},
|
|
60
|
+
"publishConfig": {
|
|
61
|
+
"access": "public"
|
|
62
|
+
},
|
|
63
|
+
"scripts": {
|
|
64
|
+
"build": "rm -rf dist tsconfig.tsbuildinfo && bun x tsc -p tsconfig.json",
|
|
65
|
+
"changeset": "ankhorage-changeset",
|
|
66
|
+
"changeset:status": "ankhorage-changeset status --since=origin/main",
|
|
67
|
+
"docs": "paradox",
|
|
68
|
+
"test": "bun test src",
|
|
69
|
+
"typecheck": "bun x tsc --noEmit -p tsconfig.json",
|
|
70
|
+
"version-packages": "ankhorage-changeset version",
|
|
71
|
+
"lint": "ankhorage-eslint . --max-warnings=0",
|
|
72
|
+
"lint:fix": "ankhorage-eslint . --fix --max-warnings=0",
|
|
73
|
+
"format": "ankhorage-prettier --write .",
|
|
74
|
+
"format:check": "ankhorage-prettier --check .",
|
|
75
|
+
"knip:check": "ankhorage-knip"
|
|
76
|
+
},
|
|
77
|
+
"devDependencies": {
|
|
78
|
+
"@ankhorage/devtools": "^1.10.10",
|
|
79
|
+
"@ankhorage/paradox": "^0.1.24",
|
|
80
|
+
"@types/bun": "^1.4.0",
|
|
81
|
+
"@types/node": "^24.13.3",
|
|
82
|
+
"typescript": "~6.0.3"
|
|
83
|
+
},
|
|
84
|
+
"packageManager": "bun@1.4.0",
|
|
85
|
+
"dependencies": {
|
|
86
|
+
"@ankhorage/contracts": "^10.0.0",
|
|
87
|
+
"ignore": "^7.0.8"
|
|
88
|
+
}
|
|
89
|
+
}
|