skuba 13.0.0-subpath-imports-20250722044721 → 13.0.0-subpath-imports-20251003044159
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 +1 -2
- package/config/tsconfig.json +2 -1
- package/jest/moduleNameMapper.js +3 -11
- package/lib/cli/build/assets.js +4 -8
- package/lib/cli/build/assets.js.map +2 -2
- package/lib/cli/build/esbuild.d.ts +2 -1
- package/lib/cli/build/esbuild.js +5 -4
- package/lib/cli/build/esbuild.js.map +2 -2
- package/lib/cli/build/index.js +9 -5
- package/lib/cli/build/index.js.map +2 -2
- package/lib/cli/build/tsc.d.ts +9 -2
- package/lib/cli/build/tsc.js +76 -40
- package/lib/cli/build/tsc.js.map +3 -3
- package/lib/cli/configure/analyseDependencies.d.ts +2 -2
- package/lib/cli/configure/analyseDependencies.js.map +1 -1
- package/lib/cli/configure/analysis/package.d.ts +1 -1
- package/lib/cli/configure/analysis/package.js +1 -1
- package/lib/cli/configure/analysis/package.js.map +2 -2
- package/lib/cli/configure/ensureTemplateCompletion.d.ts +2 -2
- package/lib/cli/configure/ensureTemplateCompletion.js.map +1 -1
- package/lib/cli/configure/getEntryPoint.d.ts +2 -2
- package/lib/cli/configure/getEntryPoint.js.map +1 -1
- package/lib/cli/configure/getProjectType.d.ts +2 -2
- package/lib/cli/configure/getProjectType.js.map +1 -1
- package/lib/cli/configure/processing/configFile.d.ts +1 -1
- package/lib/cli/configure/processing/configFile.js +48 -6
- package/lib/cli/configure/processing/configFile.js.map +2 -2
- package/lib/cli/configure/processing/package.js +8 -2
- package/lib/cli/configure/processing/package.js.map +2 -2
- package/lib/cli/init/getConfig.js +1 -1
- package/lib/cli/init/getConfig.js.map +2 -2
- package/lib/cli/init/git.js +1 -1
- package/lib/cli/init/git.js.map +2 -2
- package/lib/cli/init/index.js +4 -4
- package/lib/cli/init/index.js.map +3 -3
- package/lib/cli/lint/annotate/buildkite/eslint.js +1 -1
- package/lib/cli/lint/annotate/buildkite/eslint.js.map +2 -2
- package/lib/cli/lint/annotate/buildkite/index.js +1 -1
- package/lib/cli/lint/annotate/buildkite/index.js.map +2 -2
- package/lib/cli/lint/annotate/buildkite/internal.js +1 -1
- package/lib/cli/lint/annotate/buildkite/internal.js.map +2 -2
- package/lib/cli/lint/annotate/buildkite/prettier.js +1 -1
- package/lib/cli/lint/annotate/buildkite/prettier.js.map +2 -2
- package/lib/cli/lint/annotate/buildkite/tsc.js +1 -1
- package/lib/cli/lint/annotate/buildkite/tsc.js.map +2 -2
- package/lib/cli/lint/annotate/github/eslint.d.ts +1 -1
- package/lib/cli/lint/annotate/github/eslint.js.map +2 -2
- package/lib/cli/lint/annotate/github/index.js +3 -4
- package/lib/cli/lint/annotate/github/index.js.map +2 -2
- package/lib/cli/lint/annotate/github/internal.d.ts +1 -1
- package/lib/cli/lint/annotate/github/internal.js.map +2 -2
- package/lib/cli/lint/annotate/github/prettier.d.ts +1 -1
- package/lib/cli/lint/annotate/github/prettier.js.map +2 -2
- package/lib/cli/lint/annotate/github/tsc.d.ts +1 -1
- package/lib/cli/lint/annotate/github/tsc.js.map +2 -2
- package/lib/cli/lint/autofix.d.ts +1 -1
- package/lib/cli/lint/autofix.js +3 -3
- package/lib/cli/lint/autofix.js.map +2 -2
- package/lib/cli/lint/internal.js +1 -1
- package/lib/cli/lint/internal.js.map +2 -2
- package/lib/cli/lint/internalLints/patchRenovateConfig.js +3 -3
- package/lib/cli/lint/internalLints/patchRenovateConfig.js.map +2 -2
- package/lib/cli/lint/internalLints/refreshConfigFiles.js +5 -3
- package/lib/cli/lint/internalLints/refreshConfigFiles.js.map +2 -2
- package/lib/cli/lint/internalLints/upgrade/index.d.ts +2 -2
- package/lib/cli/lint/internalLints/upgrade/index.js.map +1 -1
- package/lib/{api/buildkite/md.js → cli/lint/internalLints/upgrade/patches/12.0.2/index.js} +13 -11
- package/lib/cli/lint/internalLints/upgrade/patches/12.0.2/index.js.map +7 -0
- package/lib/cli/lint/internalLints/upgrade/patches/12.0.2/unhandledRejections.d.ts +4 -0
- package/lib/cli/lint/internalLints/upgrade/patches/12.0.2/unhandledRejections.js +162 -0
- package/lib/cli/lint/internalLints/upgrade/patches/12.0.2/unhandledRejections.js.map +7 -0
- package/lib/cli/lint/internalLints/upgrade/patches/12.1.1/index.d.ts +2 -0
- package/lib/{api/net → cli/lint/internalLints/upgrade/patches/12.1.1}/index.js +12 -6
- package/lib/cli/lint/internalLints/upgrade/patches/12.1.1/index.js.map +7 -0
- package/lib/cli/lint/internalLints/upgrade/patches/12.1.1/patchJestSnapshots.d.ts +3 -0
- package/lib/cli/lint/internalLints/upgrade/patches/12.1.1/patchJestSnapshots.js +105 -0
- package/lib/cli/lint/internalLints/upgrade/patches/12.1.1/patchJestSnapshots.js.map +7 -0
- package/lib/cli/lint/internalLints/upgrade/patches/12.3.0/index.d.ts +2 -0
- package/lib/cli/lint/internalLints/upgrade/patches/12.3.0/index.js +40 -0
- package/lib/cli/lint/internalLints/upgrade/patches/12.3.0/index.js.map +7 -0
- package/lib/cli/lint/internalLints/upgrade/patches/12.3.0/patchApiTokenFromEnvironment.d.ts +3 -0
- package/lib/cli/lint/internalLints/upgrade/patches/12.3.0/patchApiTokenFromEnvironment.js +100 -0
- package/lib/cli/lint/internalLints/upgrade/patches/12.3.0/patchApiTokenFromEnvironment.js.map +7 -0
- package/lib/cli/lint/internalLints/upgrade/patches/12.3.0/patchDockerfileSyntaxDirective.d.ts +3 -0
- package/lib/cli/lint/internalLints/upgrade/patches/12.3.0/patchDockerfileSyntaxDirective.js +99 -0
- package/lib/cli/lint/internalLints/upgrade/patches/12.3.0/patchDockerfileSyntaxDirective.js.map +7 -0
- package/lib/cli/lint/internalLints/upgrade/patches/12.4.0/index.d.ts +2 -0
- package/lib/{api/buildkite → cli/lint/internalLints/upgrade/patches/12.4.0}/index.js +12 -9
- package/lib/cli/lint/internalLints/upgrade/patches/12.4.0/index.js.map +7 -0
- package/lib/cli/lint/internalLints/upgrade/patches/12.4.0/patchDockerfileCIVariable.d.ts +3 -0
- package/lib/cli/lint/internalLints/upgrade/patches/12.4.0/patchDockerfileCIVariable.js +101 -0
- package/lib/cli/lint/internalLints/upgrade/patches/12.4.0/patchDockerfileCIVariable.js.map +7 -0
- package/lib/cli/lint/internalLints/upgrade/patches/13.0.0/index.d.ts +2 -0
- package/lib/cli/lint/internalLints/upgrade/patches/{12.2.0 → 13.0.0}/index.js.map +1 -1
- package/lib/cli/lint/internalLints/upgrade/patches/13.0.0/rewriteSrcImports.d.ts +13 -0
- package/lib/cli/lint/internalLints/upgrade/patches/13.0.0/rewriteSrcImports.js +221 -0
- package/lib/cli/lint/internalLints/upgrade/patches/13.0.0/rewriteSrcImports.js.map +7 -0
- package/lib/cli/lint/internalLints/upgrade/patches/8.2.1/upgradeESLint.js +1 -1
- package/lib/cli/lint/internalLints/upgrade/patches/8.2.1/upgradeESLint.js.map +2 -2
- package/lib/cli/node/index.js +8 -2
- package/lib/cli/node/index.js.map +2 -2
- package/lib/cli/start/index.js +8 -2
- package/lib/cli/start/index.js.map +2 -2
- package/lib/cli/test/index.d.ts +1 -1
- package/lib/cli/test/index.js +18 -4
- package/lib/cli/test/index.js.map +2 -2
- package/lib/cli/test/reporters/github/annotations.d.ts +1 -1
- package/lib/cli/test/reporters/github/annotations.js.map +1 -1
- package/lib/cli/test/reporters/github/index.js +3 -4
- package/lib/cli/test/reporters/github/index.js.map +2 -2
- package/lib/index.d.ts +4 -4
- package/lib/index.js +4 -4
- package/lib/index.js.map +2 -2
- package/lib/utils/args.d.ts +2 -0
- package/lib/utils/args.js +5 -0
- package/lib/utils/args.js.map +2 -2
- package/lib/utils/dir.js +2 -2
- package/lib/utils/dir.js.map +3 -3
- package/lib/utils/manifest.d.ts +6 -2
- package/lib/utils/manifest.js +17 -8
- package/lib/utils/manifest.js.map +2 -2
- package/lib/utils/template.d.ts +1 -1
- package/package.json +21 -24
- package/template/base/_.prettierrc.js +1 -1
- package/template/base/_eslint.config.js +1 -1
- package/template/base/_pnpm-workspace.yaml +14 -3
- package/template/base/jest.config.ts +7 -12
- package/template/base/jest.setup.ts +1 -1
- package/template/express-rest-api/.buildkite/pipeline.yml +6 -0
- package/template/express-rest-api/.env +1 -1
- package/template/express-rest-api/.gantry/dev.yml +5 -1
- package/template/express-rest-api/.gantry/prod.yml +5 -1
- package/template/express-rest-api/Dockerfile +2 -2
- package/template/express-rest-api/Dockerfile.dev-deps +0 -2
- package/template/express-rest-api/README.md +5 -5
- package/template/express-rest-api/gantry.apply.yml +17 -1
- package/template/express-rest-api/package.json +11 -5
- package/template/express-rest-api/src/api/healthCheck.ts +2 -2
- package/template/express-rest-api/src/config.ts +7 -7
- package/template/express-rest-api/src/framework/logging.ts +11 -7
- package/template/express-rest-api/src/framework/metrics.ts +1 -1
- package/template/express-rest-api/src/listen.ts +6 -0
- package/template/express-rest-api/src/tracing.ts +56 -0
- package/template/greeter/Dockerfile +0 -2
- package/template/greeter/README.md +2 -2
- package/template/greeter/package.json +2 -2
- package/template/koa-rest-api/.buildkite/pipeline.yml +6 -0
- package/template/koa-rest-api/.env +1 -1
- package/template/koa-rest-api/.gantry/dev.yml +3 -3
- package/template/koa-rest-api/.gantry/prod.yml +3 -3
- package/template/koa-rest-api/Dockerfile +1 -1
- package/template/koa-rest-api/Dockerfile.dev-deps +0 -2
- package/template/koa-rest-api/README.md +6 -6
- package/template/koa-rest-api/gantry.apply.yml +15 -3
- package/template/koa-rest-api/package.json +13 -14
- package/template/koa-rest-api/src/api/healthCheck.ts +2 -2
- package/template/koa-rest-api/src/config.ts +7 -7
- package/template/koa-rest-api/src/framework/logging.ts +12 -8
- package/template/koa-rest-api/src/framework/metrics.ts +1 -1
- package/template/koa-rest-api/src/framework/server.test.ts +7 -8
- package/template/koa-rest-api/src/framework/server.ts +1 -4
- package/template/koa-rest-api/src/listen.ts +6 -0
- package/template/lambda-sqs-worker-cdk/.buildkite/pipeline.yml +6 -2
- package/template/lambda-sqs-worker-cdk/.env +1 -1
- package/template/lambda-sqs-worker-cdk/Dockerfile +0 -2
- package/template/lambda-sqs-worker-cdk/README.md +8 -8
- package/template/lambda-sqs-worker-cdk/infra/__snapshots__/appStack.test.ts.snap +54 -26
- package/template/lambda-sqs-worker-cdk/infra/appStack.test.ts +5 -22
- package/template/lambda-sqs-worker-cdk/infra/appStack.ts +16 -9
- package/template/lambda-sqs-worker-cdk/infra/config.ts +34 -20
- package/template/lambda-sqs-worker-cdk/infra/index.ts +1 -1
- package/template/lambda-sqs-worker-cdk/package.json +7 -9
- package/template/lambda-sqs-worker-cdk/src/app.test.ts +91 -51
- package/template/lambda-sqs-worker-cdk/src/app.ts +10 -9
- package/template/lambda-sqs-worker-cdk/src/config.ts +11 -16
- package/template/lambda-sqs-worker-cdk/src/framework/handler.test.ts +10 -5
- package/template/lambda-sqs-worker-cdk/src/framework/handler.ts +48 -24
- package/template/lambda-sqs-worker-cdk/src/framework/logging.ts +23 -11
- package/template/lambda-sqs-worker-cdk/src/framework/metrics.ts +1 -4
- package/template/lambda-sqs-worker-cdk/src/testing/handler.ts +4 -1
- package/template/oss-npm-package/.github/workflows/release.yml +7 -8
- package/template/oss-npm-package/.github/workflows/validate.yml +6 -6
- package/template/oss-npm-package/README.md +1 -1
- package/template/oss-npm-package/_package.json +0 -3
- package/template/oss-npm-package/skuba.template.js +1 -1
- package/lib/api/buildkite/annotate.d.ts +0 -28
- package/lib/api/buildkite/annotate.js +0 -62
- package/lib/api/buildkite/annotate.js.map +0 -7
- package/lib/api/buildkite/index.d.ts +0 -3
- package/lib/api/buildkite/index.js.map +0 -7
- package/lib/api/buildkite/md.d.ts +0 -6
- package/lib/api/buildkite/md.js.map +0 -7
- package/lib/api/git/commit.d.ts +0 -15
- package/lib/api/git/commit.js +0 -52
- package/lib/api/git/commit.js.map +0 -7
- package/lib/api/git/commitAllChanges.d.ts +0 -19
- package/lib/api/git/commitAllChanges.js +0 -83
- package/lib/api/git/commitAllChanges.js.map +0 -7
- package/lib/api/git/currentBranch.d.ts +0 -10
- package/lib/api/git/currentBranch.js +0 -59
- package/lib/api/git/currentBranch.js.map +0 -7
- package/lib/api/git/findRoot.d.ts +0 -9
- package/lib/api/git/findRoot.js +0 -52
- package/lib/api/git/findRoot.js.map +0 -7
- package/lib/api/git/getChangedFiles.d.ts +0 -20
- package/lib/api/git/getChangedFiles.js +0 -81
- package/lib/api/git/getChangedFiles.js.map +0 -7
- package/lib/api/git/index.d.ts +0 -12
- package/lib/api/git/index.js +0 -61
- package/lib/api/git/index.js.map +0 -7
- package/lib/api/git/isFileGitIgnored.d.ts +0 -4
- package/lib/api/git/isFileGitIgnored.js +0 -49
- package/lib/api/git/isFileGitIgnored.js.map +0 -7
- package/lib/api/git/log.d.ts +0 -19
- package/lib/api/git/log.js +0 -71
- package/lib/api/git/log.js.map +0 -7
- package/lib/api/git/pull.d.ts +0 -35
- package/lib/api/git/pull.js +0 -69
- package/lib/api/git/pull.js.map +0 -7
- package/lib/api/git/push.d.ts +0 -52
- package/lib/api/git/push.js +0 -70
- package/lib/api/git/push.js.map +0 -7
- package/lib/api/git/remote.d.ts +0 -20
- package/lib/api/git/remote.js +0 -73
- package/lib/api/git/remote.js.map +0 -7
- package/lib/api/git/reset.d.ts +0 -12
- package/lib/api/git/reset.js +0 -62
- package/lib/api/git/reset.js.map +0 -7
- package/lib/api/git/statusMatrix.d.ts +0 -7
- package/lib/api/git/statusMatrix.js +0 -47
- package/lib/api/git/statusMatrix.js.map +0 -7
- package/lib/api/github/checkRun.d.ts +0 -44
- package/lib/api/github/checkRun.js +0 -81
- package/lib/api/github/checkRun.js.map +0 -7
- package/lib/api/github/environment.d.ts +0 -17
- package/lib/api/github/environment.js +0 -48
- package/lib/api/github/environment.js.map +0 -7
- package/lib/api/github/index.d.ts +0 -7
- package/lib/api/github/index.js +0 -48
- package/lib/api/github/index.js.map +0 -7
- package/lib/api/github/issueComment.d.ts +0 -61
- package/lib/api/github/issueComment.js +0 -99
- package/lib/api/github/issueComment.js.map +0 -7
- package/lib/api/github/octokit.d.ts +0 -6
- package/lib/api/github/octokit.js +0 -42
- package/lib/api/github/octokit.js.map +0 -7
- package/lib/api/github/pullRequest.d.ts +0 -21
- package/lib/api/github/pullRequest.js +0 -69
- package/lib/api/github/pullRequest.js.map +0 -7
- package/lib/api/github/push.d.ts +0 -85
- package/lib/api/github/push.js +0 -166
- package/lib/api/github/push.js.map +0 -7
- package/lib/api/net/compose.d.ts +0 -4
- package/lib/api/net/compose.js +0 -51
- package/lib/api/net/compose.js.map +0 -7
- package/lib/api/net/index.d.ts +0 -1
- package/lib/api/net/index.js.map +0 -7
- package/lib/api/net/socket.d.ts +0 -5
- package/lib/api/net/socket.js +0 -68
- package/lib/api/net/socket.js.map +0 -7
- package/lib/api/net/waitFor.d.ts +0 -22
- package/lib/api/net/waitFor.js +0 -40
- package/lib/api/net/waitFor.js.map +0 -7
- package/lib/cli/lint/internalLints/upgrade/patches/12.2.0/rewriteSrcImports.d.ts +0 -6
- package/lib/cli/lint/internalLints/upgrade/patches/12.2.0/rewriteSrcImports.js +0 -104
- package/lib/cli/lint/internalLints/upgrade/patches/12.2.0/rewriteSrcImports.js.map +0 -7
- /package/lib/cli/lint/internalLints/upgrade/patches/{12.2.0 → 12.0.2}/index.d.ts +0 -0
- /package/lib/cli/lint/internalLints/upgrade/patches/{12.2.0 → 13.0.0}/index.js +0 -0
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __export = (target, all) => {
|
|
9
|
-
for (var name in all)
|
|
10
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
-
};
|
|
12
|
-
var __copyProps = (to, from, except, desc) => {
|
|
13
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
-
for (let key of __getOwnPropNames(from))
|
|
15
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
-
}
|
|
18
|
-
return to;
|
|
19
|
-
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
-
var pullRequest_exports = {};
|
|
30
|
-
__export(pullRequest_exports, {
|
|
31
|
-
getPullRequestNumber: () => getPullRequestNumber
|
|
32
|
-
});
|
|
33
|
-
module.exports = __toCommonJS(pullRequest_exports);
|
|
34
|
-
var Git = __toESM(require("../git/index.js"));
|
|
35
|
-
var import_environment = require("./environment.js");
|
|
36
|
-
var import_octokit = require("./octokit.js");
|
|
37
|
-
const getPullRequestNumber = async (params = {}) => {
|
|
38
|
-
const env = params.env ?? process.env;
|
|
39
|
-
const dir = process.cwd();
|
|
40
|
-
const number = Number(
|
|
41
|
-
env.BUILDKITE_PULL_REQUEST ?? env.GITHUB_REF?.replace(/^refs\/pull\/(\d+).*$/, "$1")
|
|
42
|
-
);
|
|
43
|
-
if (Number.isSafeInteger(number)) {
|
|
44
|
-
return number;
|
|
45
|
-
}
|
|
46
|
-
const client = params.client ?? await (0, import_octokit.createRestClient)({ auth: (0, import_environment.apiTokenFromEnvironment)() });
|
|
47
|
-
const [commitId, { owner, repo }] = await Promise.all([
|
|
48
|
-
Git.getHeadCommitId({ dir, env }),
|
|
49
|
-
Git.getOwnerAndRepo({ dir })
|
|
50
|
-
]);
|
|
51
|
-
const response = await client.repos.listPullRequestsAssociatedWithCommit({
|
|
52
|
-
commit_sha: commitId,
|
|
53
|
-
owner,
|
|
54
|
-
repo
|
|
55
|
-
});
|
|
56
|
-
const data = response.data.filter((pr) => pr.state === "open" && !pr.locked).sort((a, b) => b.updated_at.localeCompare(a.updated_at));
|
|
57
|
-
const pullRequestData = data[0];
|
|
58
|
-
if (!pullRequestData) {
|
|
59
|
-
throw new Error(
|
|
60
|
-
`Commit ${commitId} is not associated with an open GitHub pull request`
|
|
61
|
-
);
|
|
62
|
-
}
|
|
63
|
-
return pullRequestData.number;
|
|
64
|
-
};
|
|
65
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
66
|
-
0 && (module.exports = {
|
|
67
|
-
getPullRequestNumber
|
|
68
|
-
});
|
|
69
|
-
//# sourceMappingURL=pullRequest.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/api/github/pullRequest.ts"],
|
|
4
|
-
"sourcesContent": ["import type { Octokit } from '@octokit/rest' with { 'resolution-mode': 'import' };\n\nimport * as Git from '../git/index.js';\n\nimport { apiTokenFromEnvironment } from './environment.js';\nimport { createRestClient } from './octokit.js';\n\ninterface GetPullRequestParameters {\n /**\n * A preconstructed Octokit client to interact with GitHub's APIs.\n *\n * A `GITHUB_API_TOKEN` or `GITHUB_TOKEN` with write permissions must be\n * present on the environment if this is not provided.\n */\n client?: Octokit;\n\n env?: Record<string, string | undefined>;\n}\n\n/**\n * Gets the number of the current pull request.\n *\n * This tries to extract the pull request from common CI environment variables,\n * and falls back to querying the GitHub Repos API for the latest pull request\n * associated with the head commit. An error is thrown if there are no\n * associated pull requests, or if they are all closed or locked.\n */\nexport const getPullRequestNumber = async (\n params: GetPullRequestParameters = {},\n): Promise<number> => {\n const env = params.env ?? process.env;\n\n const dir = process.cwd();\n\n const number = Number(\n env.BUILDKITE_PULL_REQUEST ??\n env.GITHUB_REF?.replace(/^refs\\/pull\\/(\\d+).*$/, '$1'),\n );\n\n if (Number.isSafeInteger(number)) {\n return number;\n }\n\n const client =\n params.client ??\n (await createRestClient({ auth: apiTokenFromEnvironment() }));\n\n const [commitId, { owner, repo }] = await Promise.all([\n Git.getHeadCommitId({ dir, env }),\n Git.getOwnerAndRepo({ dir }),\n ]);\n\n const response = await client.repos.listPullRequestsAssociatedWithCommit({\n commit_sha: commitId,\n owner,\n repo,\n });\n\n const data = response.data\n .filter((pr) => pr.state === 'open' && !pr.locked)\n .sort((a, b) => b.updated_at.localeCompare(a.updated_at));\n\n const pullRequestData = data[0];\n if (!pullRequestData) {\n throw new Error(\n `Commit ${commitId} is not associated with an open GitHub pull request`,\n );\n }\n\n return pullRequestData.number;\n};\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,UAAqB;AAErB,yBAAwC;AACxC,qBAAiC;AAsB1B,MAAM,uBAAuB,OAClC,SAAmC,CAAC,MAChB;AACpB,QAAM,MAAM,OAAO,OAAO,QAAQ;AAElC,QAAM,MAAM,QAAQ,IAAI;AAExB,QAAM,SAAS;AAAA,IACb,IAAI,0BACF,IAAI,YAAY,QAAQ,yBAAyB,IAAI;AAAA,EACzD;AAEA,MAAI,OAAO,cAAc,MAAM,GAAG;AAChC,WAAO;AAAA,EACT;AAEA,QAAM,SACJ,OAAO,UACN,UAAM,iCAAiB,EAAE,UAAM,4CAAwB,EAAE,CAAC;AAE7D,QAAM,CAAC,UAAU,EAAE,OAAO,KAAK,CAAC,IAAI,MAAM,QAAQ,IAAI;AAAA,IACpD,IAAI,gBAAgB,EAAE,KAAK,IAAI,CAAC;AAAA,IAChC,IAAI,gBAAgB,EAAE,IAAI,CAAC;AAAA,EAC7B,CAAC;AAED,QAAM,WAAW,MAAM,OAAO,MAAM,qCAAqC;AAAA,IACvE,YAAY;AAAA,IACZ;AAAA,IACA;AAAA,EACF,CAAC;AAED,QAAM,OAAO,SAAS,KACnB,OAAO,CAAC,OAAO,GAAG,UAAU,UAAU,CAAC,GAAG,MAAM,EAChD,KAAK,CAAC,GAAG,MAAM,EAAE,WAAW,cAAc,EAAE,UAAU,CAAC;AAE1D,QAAM,kBAAkB,KAAK,CAAC;AAC9B,MAAI,CAAC,iBAAiB;AACpB,UAAM,IAAI;AAAA,MACR,UAAU,QAAQ;AAAA,IACpB;AAAA,EACF;AAEA,SAAO,gBAAgB;AACzB;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
package/lib/api/github/push.d.ts
DELETED
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
import * as Git from '../git/index.js';
|
|
2
|
-
interface UploadAllFileChangesParams {
|
|
3
|
-
dir: string;
|
|
4
|
-
/**
|
|
5
|
-
* The branch name
|
|
6
|
-
*/
|
|
7
|
-
branch: string;
|
|
8
|
-
/**
|
|
9
|
-
* The headline of the commit message
|
|
10
|
-
*/
|
|
11
|
-
messageHeadline: string;
|
|
12
|
-
/**
|
|
13
|
-
* File changes to exclude from the upload.
|
|
14
|
-
*
|
|
15
|
-
* Defaults to `[]` (no exclusions).
|
|
16
|
-
*/
|
|
17
|
-
ignore?: Git.ChangedFile[];
|
|
18
|
-
/**
|
|
19
|
-
* The body of the commit message
|
|
20
|
-
*/
|
|
21
|
-
messageBody?: string;
|
|
22
|
-
/**
|
|
23
|
-
* Updates the local Git repository to match the new remote branch state
|
|
24
|
-
*/
|
|
25
|
-
updateLocal?: boolean;
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* Retrieves all file changes from the local Git repository using
|
|
29
|
-
* `getChangedFiles`, then uploads the changes to a specified GitHub branch
|
|
30
|
-
* using `uploadFileChanges`.
|
|
31
|
-
*
|
|
32
|
-
* Returns the commit ID, or `undefined` if there are no changes to commit.
|
|
33
|
-
*
|
|
34
|
-
* The file changes will appear as verified commits on GitHub.
|
|
35
|
-
*
|
|
36
|
-
* This will not update the local Git repository unless `updateLocal` is
|
|
37
|
-
* specified.
|
|
38
|
-
*/
|
|
39
|
-
export declare const uploadAllFileChanges: ({ branch, dir, messageHeadline, ignore, messageBody, updateLocal, }: UploadAllFileChangesParams) => Promise<string | undefined>;
|
|
40
|
-
interface FileAddition {
|
|
41
|
-
contents: unknown;
|
|
42
|
-
path: string;
|
|
43
|
-
}
|
|
44
|
-
interface FileDeletion {
|
|
45
|
-
path: string;
|
|
46
|
-
}
|
|
47
|
-
export interface FileChanges {
|
|
48
|
-
additions: FileAddition[];
|
|
49
|
-
deletions: FileDeletion[];
|
|
50
|
-
}
|
|
51
|
-
/**
|
|
52
|
-
* Takes a list of `ChangedFiles`, reads them from the file system, and maps
|
|
53
|
-
* them to GitHub GraphQL `FileChanges`.
|
|
54
|
-
*
|
|
55
|
-
* https://docs.github.com/en/graphql/reference/input-objects#filechanges
|
|
56
|
-
*/
|
|
57
|
-
export declare const readFileChanges: (dir: string, changedFiles: Git.ChangedFile[]) => Promise<FileChanges>;
|
|
58
|
-
interface UploadFileChangesParams {
|
|
59
|
-
dir: string;
|
|
60
|
-
/**
|
|
61
|
-
* The branch name
|
|
62
|
-
*/
|
|
63
|
-
branch: string;
|
|
64
|
-
/**
|
|
65
|
-
* The headline of the commit message
|
|
66
|
-
*/
|
|
67
|
-
messageHeadline: string;
|
|
68
|
-
/**
|
|
69
|
-
* The body of the commit message
|
|
70
|
-
*/
|
|
71
|
-
messageBody?: string;
|
|
72
|
-
/**
|
|
73
|
-
* File additions and deletions
|
|
74
|
-
*/
|
|
75
|
-
fileChanges: FileChanges;
|
|
76
|
-
}
|
|
77
|
-
/**
|
|
78
|
-
* Uploads file changes from the local workspace to a specified GitHub branch.
|
|
79
|
-
*
|
|
80
|
-
* The file changes will appear as verified commits on GitHub.
|
|
81
|
-
*
|
|
82
|
-
* This will not update the local Git repository.
|
|
83
|
-
*/
|
|
84
|
-
export declare const uploadFileChanges: ({ dir, branch, messageHeadline, messageBody, fileChanges, }: UploadFileChangesParams) => Promise<string>;
|
|
85
|
-
export {};
|
package/lib/api/github/push.js
DELETED
|
@@ -1,166 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __export = (target, all) => {
|
|
9
|
-
for (var name in all)
|
|
10
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
-
};
|
|
12
|
-
var __copyProps = (to, from, except, desc) => {
|
|
13
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
-
for (let key of __getOwnPropNames(from))
|
|
15
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
-
}
|
|
18
|
-
return to;
|
|
19
|
-
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
-
var push_exports = {};
|
|
30
|
-
__export(push_exports, {
|
|
31
|
-
readFileChanges: () => readFileChanges,
|
|
32
|
-
uploadAllFileChanges: () => uploadAllFileChanges,
|
|
33
|
-
uploadFileChanges: () => uploadFileChanges
|
|
34
|
-
});
|
|
35
|
-
module.exports = __toCommonJS(push_exports);
|
|
36
|
-
var import_path = __toESM(require("path"));
|
|
37
|
-
var import_fs_extra = __toESM(require("fs-extra"));
|
|
38
|
-
var Git = __toESM(require("../git/index.js"));
|
|
39
|
-
var import_environment = require("./environment.js");
|
|
40
|
-
var import_octokit = require("./octokit.js");
|
|
41
|
-
const uploadAllFileChanges = async ({
|
|
42
|
-
branch,
|
|
43
|
-
dir,
|
|
44
|
-
messageHeadline,
|
|
45
|
-
ignore,
|
|
46
|
-
messageBody,
|
|
47
|
-
updateLocal = false
|
|
48
|
-
}) => {
|
|
49
|
-
const changedFiles = await Git.getChangedFiles({ dir, ignore });
|
|
50
|
-
if (!changedFiles.length) {
|
|
51
|
-
return;
|
|
52
|
-
}
|
|
53
|
-
const fileChanges = await readFileChanges(dir, changedFiles);
|
|
54
|
-
const commitId = await uploadFileChanges({
|
|
55
|
-
dir,
|
|
56
|
-
branch,
|
|
57
|
-
messageHeadline,
|
|
58
|
-
messageBody,
|
|
59
|
-
fileChanges
|
|
60
|
-
});
|
|
61
|
-
if (updateLocal) {
|
|
62
|
-
await Promise.all(
|
|
63
|
-
[...fileChanges.additions, ...fileChanges.deletions].map(
|
|
64
|
-
(file) => import_fs_extra.default.rm(file.path)
|
|
65
|
-
)
|
|
66
|
-
);
|
|
67
|
-
await Git.fastForwardBranch({
|
|
68
|
-
ref: branch,
|
|
69
|
-
auth: { type: "gitHubApp" },
|
|
70
|
-
dir
|
|
71
|
-
});
|
|
72
|
-
}
|
|
73
|
-
return commitId;
|
|
74
|
-
};
|
|
75
|
-
const readFileChanges = async (dir, changedFiles) => {
|
|
76
|
-
const { added, deleted } = changedFiles.reduce(
|
|
77
|
-
(files, changedFile) => {
|
|
78
|
-
const filePath = changedFile.path;
|
|
79
|
-
if (changedFile.state === "deleted") {
|
|
80
|
-
files.deleted.push(filePath);
|
|
81
|
-
} else {
|
|
82
|
-
files.added.push(filePath);
|
|
83
|
-
}
|
|
84
|
-
return files;
|
|
85
|
-
},
|
|
86
|
-
{ added: [], deleted: [] }
|
|
87
|
-
);
|
|
88
|
-
const gitRoot = await Git.findRoot({ dir });
|
|
89
|
-
const toRootPath = (filePath) => {
|
|
90
|
-
if (!gitRoot) {
|
|
91
|
-
return filePath;
|
|
92
|
-
}
|
|
93
|
-
return import_path.default.resolve(gitRoot, filePath);
|
|
94
|
-
};
|
|
95
|
-
const additions = await Promise.all(
|
|
96
|
-
added.map(async (filePath) => ({
|
|
97
|
-
path: filePath,
|
|
98
|
-
contents: await import_fs_extra.default.promises.readFile(toRootPath(filePath), {
|
|
99
|
-
encoding: "base64"
|
|
100
|
-
})
|
|
101
|
-
}))
|
|
102
|
-
);
|
|
103
|
-
const deletions = deleted.map((filePath) => ({
|
|
104
|
-
path: filePath
|
|
105
|
-
}));
|
|
106
|
-
return {
|
|
107
|
-
additions,
|
|
108
|
-
deletions
|
|
109
|
-
};
|
|
110
|
-
};
|
|
111
|
-
const uploadFileChanges = async ({
|
|
112
|
-
dir,
|
|
113
|
-
branch,
|
|
114
|
-
messageHeadline,
|
|
115
|
-
messageBody,
|
|
116
|
-
fileChanges
|
|
117
|
-
}) => {
|
|
118
|
-
const authToken = (0, import_environment.apiTokenFromEnvironment)();
|
|
119
|
-
if (!authToken) {
|
|
120
|
-
throw new Error(
|
|
121
|
-
"Could not read a GitHub API token from the environment. Please set GITHUB_API_TOKEN or GITHUB_TOKEN."
|
|
122
|
-
);
|
|
123
|
-
}
|
|
124
|
-
const [{ owner, repo }, headCommitId] = await Promise.all([
|
|
125
|
-
Git.getOwnerAndRepo({ dir }),
|
|
126
|
-
Git.getHeadCommitId({ dir })
|
|
127
|
-
]);
|
|
128
|
-
const input = {
|
|
129
|
-
branch: {
|
|
130
|
-
repositoryNameWithOwner: `${owner}/${repo}`,
|
|
131
|
-
branchName: branch
|
|
132
|
-
},
|
|
133
|
-
message: {
|
|
134
|
-
headline: messageHeadline,
|
|
135
|
-
body: messageBody
|
|
136
|
-
},
|
|
137
|
-
expectedHeadOid: headCommitId,
|
|
138
|
-
clientMutationId: "skuba",
|
|
139
|
-
fileChanges
|
|
140
|
-
};
|
|
141
|
-
const result = await (0, import_octokit.graphql)(
|
|
142
|
-
`
|
|
143
|
-
mutation Mutation($input: CreateCommitOnBranchInput!) {
|
|
144
|
-
createCommitOnBranch(input: $input) {
|
|
145
|
-
commit {
|
|
146
|
-
oid
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
`,
|
|
151
|
-
{
|
|
152
|
-
input,
|
|
153
|
-
headers: {
|
|
154
|
-
authorization: `Bearer ${authToken}`
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
);
|
|
158
|
-
return result.createCommitOnBranch.commit.oid;
|
|
159
|
-
};
|
|
160
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
161
|
-
0 && (module.exports = {
|
|
162
|
-
readFileChanges,
|
|
163
|
-
uploadAllFileChanges,
|
|
164
|
-
uploadFileChanges
|
|
165
|
-
});
|
|
166
|
-
//# sourceMappingURL=push.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/api/github/push.ts"],
|
|
4
|
-
"sourcesContent": ["import path from 'path';\n\nimport type { CreateCommitOnBranchInput } from '@octokit/graphql-schema';\nimport fs from 'fs-extra';\n\nimport * as Git from '../git/index.js';\n\nimport { apiTokenFromEnvironment } from './environment.js';\nimport { graphql } from './octokit.js';\n\ninterface CreateCommitResult {\n createCommitOnBranch: {\n commit: {\n oid: string;\n };\n };\n}\n\ninterface UploadAllFileChangesParams {\n dir: string;\n /**\n * The branch name\n */\n branch: string;\n /**\n * The headline of the commit message\n */\n messageHeadline: string;\n\n /**\n * File changes to exclude from the upload.\n *\n * Defaults to `[]` (no exclusions).\n */\n ignore?: Git.ChangedFile[];\n /**\n * The body of the commit message\n */\n messageBody?: string;\n /**\n * Updates the local Git repository to match the new remote branch state\n */\n updateLocal?: boolean;\n}\n\n/**\n * Retrieves all file changes from the local Git repository using\n * `getChangedFiles`, then uploads the changes to a specified GitHub branch\n * using `uploadFileChanges`.\n *\n * Returns the commit ID, or `undefined` if there are no changes to commit.\n *\n * The file changes will appear as verified commits on GitHub.\n *\n * This will not update the local Git repository unless `updateLocal` is\n * specified.\n */\nexport const uploadAllFileChanges = async ({\n branch,\n dir,\n messageHeadline,\n\n ignore,\n messageBody,\n updateLocal = false,\n}: UploadAllFileChangesParams): Promise<string | undefined> => {\n const changedFiles = await Git.getChangedFiles({ dir, ignore });\n\n if (!changedFiles.length) {\n return;\n }\n\n const fileChanges = await readFileChanges(dir, changedFiles);\n\n const commitId = await uploadFileChanges({\n dir,\n branch,\n messageHeadline,\n messageBody,\n fileChanges,\n });\n\n if (updateLocal) {\n await Promise.all(\n [...fileChanges.additions, ...fileChanges.deletions].map((file) =>\n fs.rm(file.path),\n ),\n );\n\n await Git.fastForwardBranch({\n ref: branch,\n auth: { type: 'gitHubApp' },\n dir,\n });\n }\n\n return commitId;\n};\n\ninterface FileAddition {\n contents: unknown;\n path: string;\n}\n\ninterface FileDeletion {\n path: string;\n}\n\nexport interface FileChanges {\n additions: FileAddition[];\n deletions: FileDeletion[];\n}\n\n/**\n * Takes a list of `ChangedFiles`, reads them from the file system, and maps\n * them to GitHub GraphQL `FileChanges`.\n *\n * https://docs.github.com/en/graphql/reference/input-objects#filechanges\n */\nexport const readFileChanges = async (\n dir: string,\n changedFiles: Git.ChangedFile[],\n): Promise<FileChanges> => {\n const { added, deleted } = changedFiles.reduce<{\n added: string[];\n deleted: string[];\n }>(\n (files, changedFile) => {\n const filePath = changedFile.path;\n if (changedFile.state === 'deleted') {\n files.deleted.push(filePath);\n } else {\n files.added.push(filePath);\n }\n\n return files;\n },\n { added: [], deleted: [] },\n );\n\n const gitRoot = await Git.findRoot({ dir });\n\n const toRootPath = (filePath: string) => {\n if (!gitRoot) {\n return filePath;\n }\n\n return path.resolve(gitRoot, filePath);\n };\n\n const additions: FileAddition[] = await Promise.all(\n added.map(async (filePath) => ({\n path: filePath,\n contents: await fs.promises.readFile(toRootPath(filePath), {\n encoding: 'base64',\n }),\n })),\n );\n\n const deletions: FileDeletion[] = deleted.map((filePath) => ({\n path: filePath,\n }));\n\n return {\n additions,\n deletions,\n };\n};\n\ninterface UploadFileChangesParams {\n dir: string;\n /**\n * The branch name\n */\n branch: string;\n /**\n * The headline of the commit message\n */\n messageHeadline: string;\n /**\n * The body of the commit message\n */\n messageBody?: string;\n /**\n * File additions and deletions\n */\n fileChanges: FileChanges;\n}\n\n/**\n * Uploads file changes from the local workspace to a specified GitHub branch.\n *\n * The file changes will appear as verified commits on GitHub.\n *\n * This will not update the local Git repository.\n */\nexport const uploadFileChanges = async ({\n dir,\n branch,\n messageHeadline,\n messageBody,\n fileChanges,\n}: UploadFileChangesParams): Promise<string> => {\n const authToken = apiTokenFromEnvironment();\n if (!authToken) {\n throw new Error(\n 'Could not read a GitHub API token from the environment. Please set GITHUB_API_TOKEN or GITHUB_TOKEN.',\n );\n }\n\n const [{ owner, repo }, headCommitId] = await Promise.all([\n Git.getOwnerAndRepo({ dir }),\n Git.getHeadCommitId({ dir }),\n ]);\n\n const input: CreateCommitOnBranchInput = {\n branch: {\n repositoryNameWithOwner: `${owner}/${repo}`,\n branchName: branch,\n },\n message: {\n headline: messageHeadline,\n body: messageBody,\n },\n expectedHeadOid: headCommitId,\n clientMutationId: 'skuba',\n fileChanges,\n };\n\n const result = await graphql<CreateCommitResult>(\n `\n mutation Mutation($input: CreateCommitOnBranchInput!) {\n createCommitOnBranch(input: $input) {\n commit {\n oid\n }\n }\n }\n `,\n {\n input,\n headers: {\n authorization: `Bearer ${authToken}`,\n },\n },\n );\n\n return result.createCommitOnBranch.commit.oid;\n};\n"],
|
|
5
|
-
"mappings": "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",
|
|
6
|
-
"names": ["fs", "path"]
|
|
7
|
-
}
|
package/lib/api/net/compose.d.ts
DELETED
package/lib/api/net/compose.js
DELETED
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var compose_exports = {};
|
|
20
|
-
__export(compose_exports, {
|
|
21
|
-
resolveComposeAddress: () => resolveComposeAddress
|
|
22
|
-
});
|
|
23
|
-
module.exports = __toCommonJS(compose_exports);
|
|
24
|
-
var import_exec = require("../../utils/exec.js");
|
|
25
|
-
const portStringToNumber = (portString) => {
|
|
26
|
-
const port = Number(portString);
|
|
27
|
-
if (!Number.isSafeInteger(port)) {
|
|
28
|
-
throw Error(`received non-integer port: '${portString}'`);
|
|
29
|
-
}
|
|
30
|
-
return port;
|
|
31
|
-
};
|
|
32
|
-
const resolveComposeAddress = async (privateHost, privatePort) => {
|
|
33
|
-
const exec = (0, import_exec.createExec)({ stdio: "pipe" });
|
|
34
|
-
const { stdout } = await exec(
|
|
35
|
-
"docker",
|
|
36
|
-
"compose",
|
|
37
|
-
"port",
|
|
38
|
-
privateHost,
|
|
39
|
-
String(privatePort)
|
|
40
|
-
);
|
|
41
|
-
const [host, portString] = stdout.trim().split(":");
|
|
42
|
-
if (!host || !portString) {
|
|
43
|
-
throw Error(`Docker Compose returned unrecognised address: '${stdout}'`);
|
|
44
|
-
}
|
|
45
|
-
return { host, port: portStringToNumber(portString) };
|
|
46
|
-
};
|
|
47
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
48
|
-
0 && (module.exports = {
|
|
49
|
-
resolveComposeAddress
|
|
50
|
-
});
|
|
51
|
-
//# sourceMappingURL=compose.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/api/net/compose.ts"],
|
|
4
|
-
"sourcesContent": ["import { createExec } from '../../utils/exec.js';\n\nconst portStringToNumber = (portString: string) => {\n const port = Number(portString);\n\n if (!Number.isSafeInteger(port)) {\n throw Error(`received non-integer port: '${portString}'`);\n }\n\n return port;\n};\n\nexport const resolveComposeAddress = async (\n privateHost: string,\n privatePort: number,\n) => {\n const exec = createExec({ stdio: 'pipe' });\n\n const { stdout } = await exec(\n 'docker',\n 'compose',\n 'port',\n privateHost,\n String(privatePort),\n );\n\n const [host, portString] = stdout.trim().split(':');\n\n if (!host || !portString) {\n throw Error(`Docker Compose returned unrecognised address: '${stdout}'`);\n }\n\n return { host, port: portStringToNumber(portString) };\n};\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAA2B;AAE3B,MAAM,qBAAqB,CAAC,eAAuB;AACjD,QAAM,OAAO,OAAO,UAAU;AAE9B,MAAI,CAAC,OAAO,cAAc,IAAI,GAAG;AAC/B,UAAM,MAAM,+BAA+B,UAAU,GAAG;AAAA,EAC1D;AAEA,SAAO;AACT;AAEO,MAAM,wBAAwB,OACnC,aACA,gBACG;AACH,QAAM,WAAO,wBAAW,EAAE,OAAO,OAAO,CAAC;AAEzC,QAAM,EAAE,OAAO,IAAI,MAAM;AAAA,IACvB;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,OAAO,WAAW;AAAA,EACpB;AAEA,QAAM,CAAC,MAAM,UAAU,IAAI,OAAO,KAAK,EAAE,MAAM,GAAG;AAElD,MAAI,CAAC,QAAQ,CAAC,YAAY;AACxB,UAAM,MAAM,kDAAkD,MAAM,GAAG;AAAA,EACzE;AAEA,SAAO,EAAE,MAAM,MAAM,mBAAmB,UAAU,EAAE;AACtD;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
package/lib/api/net/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { waitFor } from './waitFor.js';
|
package/lib/api/net/index.js.map
DELETED
package/lib/api/net/socket.d.ts
DELETED
package/lib/api/net/socket.js
DELETED
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __export = (target, all) => {
|
|
9
|
-
for (var name in all)
|
|
10
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
-
};
|
|
12
|
-
var __copyProps = (to, from, except, desc) => {
|
|
13
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
-
for (let key of __getOwnPropNames(from))
|
|
15
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
-
}
|
|
18
|
-
return to;
|
|
19
|
-
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
-
var socket_exports = {};
|
|
30
|
-
__export(socket_exports, {
|
|
31
|
-
pollSocket: () => pollSocket
|
|
32
|
-
});
|
|
33
|
-
module.exports = __toCommonJS(socket_exports);
|
|
34
|
-
var import_net = __toESM(require("net"));
|
|
35
|
-
const trySocket = async (host, port) => new Promise((resolve) => {
|
|
36
|
-
const socket = new import_net.default.Socket();
|
|
37
|
-
const onFailure = () => {
|
|
38
|
-
socket.destroy();
|
|
39
|
-
resolve(false);
|
|
40
|
-
};
|
|
41
|
-
const onSuccess = () => socket.end(() => resolve(true));
|
|
42
|
-
socket.connect(port, host, onSuccess).once("error", onFailure).once("timeout", onFailure).setTimeout(1e3);
|
|
43
|
-
});
|
|
44
|
-
const pollSocket = async (host, port, timeout) => new Promise((resolve, reject) => {
|
|
45
|
-
const callPort = async () => {
|
|
46
|
-
const success = await trySocket(host, port);
|
|
47
|
-
if (!success) {
|
|
48
|
-
return;
|
|
49
|
-
}
|
|
50
|
-
clearTimeout(intervalId);
|
|
51
|
-
clearTimeout(timeoutId);
|
|
52
|
-
resolve();
|
|
53
|
-
};
|
|
54
|
-
const intervalId = setInterval(() => {
|
|
55
|
-
callPort().catch(() => void 0);
|
|
56
|
-
}, 250);
|
|
57
|
-
const timeoutId = setTimeout(() => {
|
|
58
|
-
clearTimeout(intervalId);
|
|
59
|
-
clearTimeout(timeoutId);
|
|
60
|
-
reject(Error(`could not reach ${host}:${port} within ${timeout}ms`));
|
|
61
|
-
}, timeout);
|
|
62
|
-
callPort().catch(() => void 0);
|
|
63
|
-
});
|
|
64
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
65
|
-
0 && (module.exports = {
|
|
66
|
-
pollSocket
|
|
67
|
-
});
|
|
68
|
-
//# sourceMappingURL=socket.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/api/net/socket.ts"],
|
|
4
|
-
"sourcesContent": ["import net from 'net';\n\nexport interface SocketAddress {\n host: string;\n port: number;\n}\n\nconst trySocket = async (host: string, port: number) =>\n new Promise((resolve) => {\n const socket = new net.Socket();\n\n const onFailure = () => {\n socket.destroy();\n resolve(false);\n };\n\n const onSuccess = () => socket.end(() => resolve(true));\n\n socket\n .connect(port, host, onSuccess)\n .once('error', onFailure)\n .once('timeout', onFailure)\n .setTimeout(1_000);\n });\n\nexport const pollSocket = async (host: string, port: number, timeout: number) =>\n new Promise<void>((resolve, reject) => {\n const callPort = async () => {\n const success = await trySocket(host, port);\n\n if (!success) {\n return;\n }\n\n clearTimeout(intervalId);\n clearTimeout(timeoutId);\n\n resolve();\n };\n\n const intervalId = setInterval(() => {\n callPort().catch(() => undefined);\n }, 250);\n\n const timeoutId = setTimeout(() => {\n clearTimeout(intervalId);\n clearTimeout(timeoutId);\n\n reject(Error(`could not reach ${host}:${port} within ${timeout}ms`));\n }, timeout);\n\n callPort().catch(() => undefined);\n });\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,iBAAgB;AAOhB,MAAM,YAAY,OAAO,MAAc,SACrC,IAAI,QAAQ,CAAC,YAAY;AACvB,QAAM,SAAS,IAAI,WAAAA,QAAI,OAAO;AAE9B,QAAM,YAAY,MAAM;AACtB,WAAO,QAAQ;AACf,YAAQ,KAAK;AAAA,EACf;AAEA,QAAM,YAAY,MAAM,OAAO,IAAI,MAAM,QAAQ,IAAI,CAAC;AAEtD,SACG,QAAQ,MAAM,MAAM,SAAS,EAC7B,KAAK,SAAS,SAAS,EACvB,KAAK,WAAW,SAAS,EACzB,WAAW,GAAK;AACrB,CAAC;AAEI,MAAM,aAAa,OAAO,MAAc,MAAc,YAC3D,IAAI,QAAc,CAAC,SAAS,WAAW;AACrC,QAAM,WAAW,YAAY;AAC3B,UAAM,UAAU,MAAM,UAAU,MAAM,IAAI;AAE1C,QAAI,CAAC,SAAS;AACZ;AAAA,IACF;AAEA,iBAAa,UAAU;AACvB,iBAAa,SAAS;AAEtB,YAAQ;AAAA,EACV;AAEA,QAAM,aAAa,YAAY,MAAM;AACnC,aAAS,EAAE,MAAM,MAAM,MAAS;AAAA,EAClC,GAAG,GAAG;AAEN,QAAM,YAAY,WAAW,MAAM;AACjC,iBAAa,UAAU;AACvB,iBAAa,SAAS;AAEtB,WAAO,MAAM,mBAAmB,IAAI,IAAI,IAAI,WAAW,OAAO,IAAI,CAAC;AAAA,EACrE,GAAG,OAAO;AAEV,WAAS,EAAE,MAAM,MAAM,MAAS;AAClC,CAAC;",
|
|
6
|
-
"names": ["net"]
|
|
7
|
-
}
|
package/lib/api/net/waitFor.d.ts
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { type SocketAddress } from './socket.js';
|
|
2
|
-
/**
|
|
3
|
-
* Wait for a resource to start listening on a socket address.
|
|
4
|
-
*
|
|
5
|
-
* The socket is polled on an interval until it accepts a connection or the
|
|
6
|
-
* `timeout` is reached.
|
|
7
|
-
*/
|
|
8
|
-
export declare const waitFor: ({ host, port, resolveCompose, timeout, }: {
|
|
9
|
-
host?: string;
|
|
10
|
-
port: number;
|
|
11
|
-
/**
|
|
12
|
-
* Whether to treat the `host` and `port` arguments as a private Docker
|
|
13
|
-
* Compose network address and to resolve them to a public local address.
|
|
14
|
-
*
|
|
15
|
-
* This is typically:
|
|
16
|
-
*
|
|
17
|
-
* - Enabled locally, when the application is running directly on the machine
|
|
18
|
-
* - Disabled in CI, when running in a container on the Docker Compose network
|
|
19
|
-
*/
|
|
20
|
-
resolveCompose?: boolean;
|
|
21
|
-
timeout?: number;
|
|
22
|
-
}) => Promise<SocketAddress>;
|
package/lib/api/net/waitFor.js
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var waitFor_exports = {};
|
|
20
|
-
__export(waitFor_exports, {
|
|
21
|
-
waitFor: () => waitFor
|
|
22
|
-
});
|
|
23
|
-
module.exports = __toCommonJS(waitFor_exports);
|
|
24
|
-
var import_compose = require("./compose.js");
|
|
25
|
-
var import_socket = require("./socket.js");
|
|
26
|
-
const waitFor = async ({
|
|
27
|
-
host = "localhost",
|
|
28
|
-
port,
|
|
29
|
-
resolveCompose = false,
|
|
30
|
-
timeout = 15e3
|
|
31
|
-
}) => {
|
|
32
|
-
const resolvedAddress = resolveCompose ? await (0, import_compose.resolveComposeAddress)(host, port) : { host, port };
|
|
33
|
-
await (0, import_socket.pollSocket)(resolvedAddress.host, resolvedAddress.port, timeout);
|
|
34
|
-
return resolvedAddress;
|
|
35
|
-
};
|
|
36
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
37
|
-
0 && (module.exports = {
|
|
38
|
-
waitFor
|
|
39
|
-
});
|
|
40
|
-
//# sourceMappingURL=waitFor.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/api/net/waitFor.ts"],
|
|
4
|
-
"sourcesContent": ["import { resolveComposeAddress } from './compose.js';\nimport { type SocketAddress, pollSocket } from './socket.js';\n\n/**\n * Wait for a resource to start listening on a socket address.\n *\n * The socket is polled on an interval until it accepts a connection or the\n * `timeout` is reached.\n */\nexport const waitFor = async ({\n host = 'localhost',\n port,\n resolveCompose = false,\n timeout = 15_000,\n}: {\n host?: string;\n\n port: number;\n\n /**\n * Whether to treat the `host` and `port` arguments as a private Docker\n * Compose network address and to resolve them to a public local address.\n *\n * This is typically:\n *\n * - Enabled locally, when the application is running directly on the machine\n * - Disabled in CI, when running in a container on the Docker Compose network\n */\n resolveCompose?: boolean;\n\n timeout?: number;\n}): Promise<SocketAddress> => {\n const resolvedAddress = resolveCompose\n ? await resolveComposeAddress(host, port)\n : { host, port };\n\n await pollSocket(resolvedAddress.host, resolvedAddress.port, timeout);\n\n return resolvedAddress;\n};\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qBAAsC;AACtC,oBAA+C;AAQxC,MAAM,UAAU,OAAO;AAAA,EAC5B,OAAO;AAAA,EACP;AAAA,EACA,iBAAiB;AAAA,EACjB,UAAU;AACZ,MAiB8B;AAC5B,QAAM,kBAAkB,iBACpB,UAAM,sCAAsB,MAAM,IAAI,IACtC,EAAE,MAAM,KAAK;AAEjB,YAAM,0BAAW,gBAAgB,MAAM,gBAAgB,MAAM,OAAO;AAEpE,SAAO;AACT;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import type { PatchFunction } from '../../index.js';
|
|
2
|
-
export declare const hasSkubaDiveRegisterImportRegex: RegExp;
|
|
3
|
-
export declare const hasSrcImportRegex: RegExp;
|
|
4
|
-
export declare const replaceSrcImport: (contents: string) => string;
|
|
5
|
-
export declare const tryRewriteSrcImports: PatchFunction;
|
|
6
|
-
export declare const rewriteSrcImports: PatchFunction;
|