@serverlessinbox/artifact-tools 0.0.7
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 +55 -0
- package/README.md +57 -0
- package/dist/build-artifacts.d.ts +33 -0
- package/dist/build-artifacts.d.ts.map +1 -0
- package/dist/build-artifacts.js +131 -0
- package/dist/build-artifacts.js.map +1 -0
- package/dist/cli-entry.d.ts +2 -0
- package/dist/cli-entry.d.ts.map +1 -0
- package/dist/cli-entry.js +5 -0
- package/dist/cli-entry.js.map +1 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +21 -0
- package/dist/cli.js.map +1 -0
- package/dist/commands/build-artifacts-cmd.d.ts +9 -0
- package/dist/commands/build-artifacts-cmd.d.ts.map +1 -0
- package/dist/commands/build-artifacts-cmd.js +78 -0
- package/dist/commands/build-artifacts-cmd.js.map +1 -0
- package/dist/commands/bundle-js-zip.d.ts +12 -0
- package/dist/commands/bundle-js-zip.d.ts.map +1 -0
- package/dist/commands/bundle-js-zip.js +112 -0
- package/dist/commands/bundle-js-zip.js.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +10 -0
- package/dist/index.js.map +1 -0
- package/dist/s3-artifact-plugin.d.ts +33 -0
- package/dist/s3-artifact-plugin.d.ts.map +1 -0
- package/dist/s3-artifact-plugin.js +121 -0
- package/dist/s3-artifact-plugin.js.map +1 -0
- package/dist/uploader.d.ts +12 -0
- package/dist/uploader.d.ts.map +1 -0
- package/dist/uploader.js +94 -0
- package/dist/uploader.js.map +1 -0
- package/dist/utils/common.d.ts +5 -0
- package/dist/utils/common.d.ts.map +1 -0
- package/dist/utils/common.js +15 -0
- package/dist/utils/common.js.map +1 -0
- package/package.json +35 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
|
|
2
|
+
# Changelog
|
|
3
|
+
|
|
4
|
+
All notable changes to this project will be documented in this file
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
## [0.0.7](https://github.com/serverlessinbox/gitversion-plugin-s3/compare/v0.0.6...v0.0.7) (Sat Jun 06 2026)
|
|
8
|
+
|
|
9
|
+
### feat
|
|
10
|
+
|
|
11
|
+
* temporatry publish in first job ([a11debb](https://github.com/serverlessinbox/gitversion-plugin-s3/commit/a11debb35eb5499da5e0b8f1b97ff11bb3840be3))
|
|
12
|
+
|
|
13
|
+
* temp publish pipeline ([a891ef3](https://github.com/serverlessinbox/gitversion-plugin-s3/commit/a891ef311ce50a0491164de82cef966afaeb4976))
|
|
14
|
+
|
|
15
|
+
* Plugin config from package ([0ba8cb6](https://github.com/serverlessinbox/gitversion-plugin-s3/commit/0ba8cb67a2dd20da75b70aed38b193620d9833af))
|
|
16
|
+
|
|
17
|
+
* Also tag rights ([a45cbc4](https://github.com/serverlessinbox/gitversion-plugin-s3/commit/a45cbc4b7b7178108cebc37e0a026de9a81acb00))
|
|
18
|
+
|
|
19
|
+
## [0.0.5](https://github.com/serverlessinbox/gitversion-plugin-s3/compare/v0.0.4...v0.0.5) (Tue Jun 02 2026)
|
|
20
|
+
|
|
21
|
+
### feat
|
|
22
|
+
|
|
23
|
+
* Added version files and extracted logic for other packages ([2670f73](https://github.com/serverlessinbox/gitversion-plugin-s3/commit/2670f73795d6ed99a43690b2543c5ffdd65e58d0))
|
|
24
|
+
|
|
25
|
+
## [0.0.4](https://github.com/serverlessinbox/gitversion-plugin-s3/compare/v0.0.3...v0.0.4) (Mon Jun 01 2026)
|
|
26
|
+
|
|
27
|
+
### feat
|
|
28
|
+
|
|
29
|
+
* Added package name ([571daf0](https://github.com/serverlessinbox/gitversion-plugin-s3/commit/571daf0dbcb1d96d85a1717fd447236c9a72c635))
|
|
30
|
+
|
|
31
|
+
### fix
|
|
32
|
+
|
|
33
|
+
* Fixed tsc errors ([5324aa7](https://github.com/serverlessinbox/gitversion-plugin-s3/commit/5324aa7cca46fd955009e3f70c7654841d12c1bb))
|
|
34
|
+
|
|
35
|
+
* Added bump ([4d7a092](https://github.com/serverlessinbox/gitversion-plugin-s3/commit/4d7a092a01434faec09b3f98cee450f855156fe8))
|
|
36
|
+
|
|
37
|
+
* Publish config ([c7c33d3](https://github.com/serverlessinbox/gitversion-plugin-s3/commit/c7c33d3afdfc8c6277a1fcc278f573d8fd9587bb))
|
|
38
|
+
|
|
39
|
+
## [0.0.3](https://github.com/serverlessinbox/gitversion-plugin-s3/compare/v0.0.2...v0.0.3) (Tue May 26 2026)
|
|
40
|
+
|
|
41
|
+
### fix
|
|
42
|
+
|
|
43
|
+
* Esmodule to commonjs ([dbcb135](https://github.com/serverlessinbox/gitversion-plugin-s3/commit/dbcb1352bdc36842a201f40b94c1b76c3c53da7a))
|
|
44
|
+
|
|
45
|
+
## [0.0.2](https://github.com/serverlessinbox/gitversion-plugin-s3/compare/v0.0.1...v0.0.2) (Tue May 26 2026)
|
|
46
|
+
|
|
47
|
+
### feat
|
|
48
|
+
|
|
49
|
+
* Added readme ([c5aca4a](https://github.com/serverlessinbox/gitversion-plugin-s3/commit/c5aca4ad3b3c7aad0166fd4fc47de1912398914b))
|
|
50
|
+
|
|
51
|
+
## [0.0.1](https://github.com/serverlessinbox/gitversion-plugin-s3/compare/v0.0.0...v0.0.1) (Tue May 26 2026)
|
|
52
|
+
|
|
53
|
+
### feat
|
|
54
|
+
|
|
55
|
+
* full plugin ([1f96479](https://github.com/serverlessinbox/gitversion-plugin-s3/commit/1f96479e4cb3a8ec7af646a93e75202bb9a21204))
|
package/README.md
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
# @serverlessinbox/gitversion-plugin-s3
|
|
2
|
+
|
|
3
|
+
A [`@jwpkg/gitversion`](https://github.com/jwpkg/gitversion) `IPlugin`/`IPackManager` that stages pre-built Lambda zips and uploads them to S3 on release.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
yarn add --dev @serverlessinbox/gitversion-plugin-s3
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
Add the plugin to your `.gitversion.cjs` config:
|
|
14
|
+
|
|
15
|
+
```js
|
|
16
|
+
const { defineConfig } = require('@jwpkg/gitversion');
|
|
17
|
+
const { S3ArtifactPlugin } = require('@serverlessinbox/gitversion-plugin-s3');
|
|
18
|
+
|
|
19
|
+
module.exports = defineConfig({
|
|
20
|
+
plugins: [
|
|
21
|
+
new S3ArtifactPlugin({
|
|
22
|
+
bucketName: 'my-artifacts-bucket',
|
|
23
|
+
basePath: 'packages/my-lambdas',
|
|
24
|
+
}),
|
|
25
|
+
],
|
|
26
|
+
});
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## Configuration
|
|
30
|
+
|
|
31
|
+
The `S3ArtifactPlugin` constructor accepts a `S3ArtifactPluginProps` object with the following options:
|
|
32
|
+
|
|
33
|
+
| Option | Type | Required | Default | Description |
|
|
34
|
+
|--------|------|----------|---------|-------------|
|
|
35
|
+
| `bucketName` | `string` | Yes | — | S3 bucket where artifacts will be uploaded. |
|
|
36
|
+
| `basePath` | `string` | Yes | — | Base path prefix used in the S3 key template. |
|
|
37
|
+
| `artifactsDir` | `string` | No | `'dist/release'` | Local directory containing pre-built `.zip` files to stage. |
|
|
38
|
+
| `fileNameTemplate` | `string` | No | `'{basePath}/v{version}/lambdas/{filename}'` | Template for S3 object keys. Supports `{basePath}`, `{version}`, and `{filename}` variables. |
|
|
39
|
+
|
|
40
|
+
## How It Works
|
|
41
|
+
|
|
42
|
+
During the `pack` phase, all `.zip` files from `artifactsDir` are copied into the gitversion staging folder. During the `publish` phase, each staged zip is uploaded to S3 using the resolved key template (with variables replaced from the release context).
|
|
43
|
+
|
|
44
|
+
## AWS Credentials
|
|
45
|
+
|
|
46
|
+
The plugin uses `S3Client({})` from the AWS SDK, which sources credentials from the environment in the following order:
|
|
47
|
+
|
|
48
|
+
- Environment variables (`AWS_ACCESS_KEY_ID`, `AWS_SECRET_ACCESS_KEY`)
|
|
49
|
+
- IAM role (if running on EC2, ECS, Lambda, or other AWS services)
|
|
50
|
+
- Credential files (e.g., `~/.aws/credentials`)
|
|
51
|
+
- SSO profile
|
|
52
|
+
|
|
53
|
+
Ensure your deployment environment has appropriate S3 write permissions to the configured bucket.
|
|
54
|
+
|
|
55
|
+
## License
|
|
56
|
+
|
|
57
|
+
Apache-2.0
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
export interface S3ArtifactEntry {
|
|
2
|
+
/** Path to source file or directory. Absolute or relative to workspace.cwd. */
|
|
3
|
+
source: string;
|
|
4
|
+
/** S3 object name for the output (e.g. 'lambdas/edge-deployer.zip', 'template.json'). */
|
|
5
|
+
objectName: string;
|
|
6
|
+
/** Overrides workspace-level bucketName for this artifact. */
|
|
7
|
+
bucketName?: string;
|
|
8
|
+
/** Overrides workspace-level basePath for this artifact. */
|
|
9
|
+
basePath?: string;
|
|
10
|
+
/** AWS region for the S3 client used to upload this artifact. Defaults to SDK default. */
|
|
11
|
+
region?: string;
|
|
12
|
+
/** Bundle type. 'js-zip' bundles a TS/JS entrypoint via esbuild into a zip containing index.js. */
|
|
13
|
+
bundleType?: 'js-zip';
|
|
14
|
+
}
|
|
15
|
+
export interface S3WorkspaceConfig {
|
|
16
|
+
/** Default S3 bucket for all artifacts in this workspace. */
|
|
17
|
+
bucketName: string;
|
|
18
|
+
/** Default S3 base path (e.g. 'packages/mailbox-cdk'). */
|
|
19
|
+
basePath: string;
|
|
20
|
+
/** Artifacts to stage and publish. */
|
|
21
|
+
artifacts: S3ArtifactEntry[];
|
|
22
|
+
}
|
|
23
|
+
export interface ArtifactBuildResult {
|
|
24
|
+
outputFiles: string[];
|
|
25
|
+
routingMap: Map<string, {
|
|
26
|
+
bucketName: string;
|
|
27
|
+
basePath: string;
|
|
28
|
+
region?: string;
|
|
29
|
+
objectName: string;
|
|
30
|
+
}>;
|
|
31
|
+
}
|
|
32
|
+
export declare function buildArtifacts(workspaceCwd: string, outputFolder: string, configOverride?: S3WorkspaceConfig): Promise<ArtifactBuildResult>;
|
|
33
|
+
//# sourceMappingURL=build-artifacts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"build-artifacts.d.ts","sourceRoot":"","sources":["../src/build-artifacts.ts"],"names":[],"mappings":"AAOA,MAAM,WAAW,eAAe;IAC9B,+EAA+E;IAC/E,MAAM,EAAE,MAAM,CAAC;IACf,yFAAyF;IACzF,UAAU,EAAE,MAAM,CAAC;IACnB,8DAA8D;IAC9D,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,4DAA4D;IAC5D,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,0FAA0F;IAC1F,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,mGAAmG;IACnG,UAAU,CAAC,EAAE,QAAQ,CAAC;CACvB;AAED,MAAM,WAAW,iBAAiB;IAChC,6DAA6D;IAC7D,UAAU,EAAE,MAAM,CAAC;IACnB,0DAA0D;IAC1D,QAAQ,EAAE,MAAM,CAAC;IACjB,sCAAsC;IACtC,SAAS,EAAE,eAAe,EAAE,CAAC;CAC9B;AAED,MAAM,WAAW,mBAAmB;IAClC,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,UAAU,EAAE,GAAG,CAAC,MAAM,EAAE;QAAE,UAAU,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CACxG;AAoED,wBAAsB,cAAc,CAClC,YAAY,EAAE,MAAM,EACpB,YAAY,EAAE,MAAM,EACpB,cAAc,CAAC,EAAE,iBAAiB,GACjC,OAAO,CAAC,mBAAmB,CAAC,CAqC9B"}
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.buildArtifacts = buildArtifacts;
|
|
37
|
+
const fs = __importStar(require("fs/promises"));
|
|
38
|
+
const fssync = __importStar(require("fs"));
|
|
39
|
+
const os = __importStar(require("os"));
|
|
40
|
+
const path = __importStar(require("path"));
|
|
41
|
+
const esbuild = __importStar(require("esbuild"));
|
|
42
|
+
const common_1 = require("./utils/common");
|
|
43
|
+
async function bundleJsZip(entryPoint, outZip) {
|
|
44
|
+
const tmpDir = fssync.mkdtempSync(path.join(os.tmpdir(), 'mailbox-tools-bundle-'));
|
|
45
|
+
try {
|
|
46
|
+
const outJs = path.join(tmpDir, 'index.js');
|
|
47
|
+
await esbuild.build({
|
|
48
|
+
entryPoints: [entryPoint],
|
|
49
|
+
outfile: outJs,
|
|
50
|
+
platform: 'node',
|
|
51
|
+
target: 'node18',
|
|
52
|
+
format: 'cjs',
|
|
53
|
+
bundle: true,
|
|
54
|
+
sourcemap: false,
|
|
55
|
+
minify: true,
|
|
56
|
+
external: ['aws-sdk'],
|
|
57
|
+
});
|
|
58
|
+
// Zip contains a single file `index.js` at the archive root.
|
|
59
|
+
// `-j` strips directory paths, ensuring the root layout.
|
|
60
|
+
(0, common_1.run)('zip', ['-j', outZip, outJs]);
|
|
61
|
+
}
|
|
62
|
+
finally {
|
|
63
|
+
fssync.rmSync(tmpDir, { recursive: true, force: true });
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
async function buildEntry(entry, workspaceCwd, outputFolder, config) {
|
|
67
|
+
const resolved = path.isAbsolute(entry.source)
|
|
68
|
+
? entry.source
|
|
69
|
+
: path.join(workspaceCwd, entry.source);
|
|
70
|
+
const outputBasename = path.basename(entry.objectName);
|
|
71
|
+
const outPath = path.join(outputFolder, outputBasename);
|
|
72
|
+
if (entry.bundleType === 'js-zip') {
|
|
73
|
+
await bundleJsZip(resolved, outPath);
|
|
74
|
+
}
|
|
75
|
+
else {
|
|
76
|
+
let isDirectory = false;
|
|
77
|
+
try {
|
|
78
|
+
isDirectory = fssync.statSync(resolved).isDirectory();
|
|
79
|
+
}
|
|
80
|
+
catch {
|
|
81
|
+
throw new Error(`[s3-artifact] Source not found: ${resolved}`);
|
|
82
|
+
}
|
|
83
|
+
if (isDirectory) {
|
|
84
|
+
(0, common_1.run)('zip', ['-j', '-r', outPath, resolved]);
|
|
85
|
+
}
|
|
86
|
+
else {
|
|
87
|
+
await fs.copyFile(resolved, outPath);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
return {
|
|
91
|
+
basename: outputBasename,
|
|
92
|
+
routing: {
|
|
93
|
+
bucketName: entry.bucketName ?? config.bucketName,
|
|
94
|
+
basePath: entry.basePath ?? config.basePath,
|
|
95
|
+
region: entry.region,
|
|
96
|
+
objectName: entry.objectName,
|
|
97
|
+
},
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
async function buildArtifacts(workspaceCwd, outputFolder, configOverride) {
|
|
101
|
+
const empty = { outputFiles: [], routingMap: new Map() };
|
|
102
|
+
let config;
|
|
103
|
+
if (configOverride !== undefined) {
|
|
104
|
+
config = configOverride;
|
|
105
|
+
}
|
|
106
|
+
else {
|
|
107
|
+
try {
|
|
108
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
109
|
+
config = require(path.join(workspaceCwd, 'artifacts.cjs'));
|
|
110
|
+
}
|
|
111
|
+
catch (err) {
|
|
112
|
+
const nodeErr = err;
|
|
113
|
+
if (nodeErr.code === 'MODULE_NOT_FOUND') {
|
|
114
|
+
return empty;
|
|
115
|
+
}
|
|
116
|
+
throw err;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
if (!Array.isArray(config.artifacts)) {
|
|
120
|
+
return empty;
|
|
121
|
+
}
|
|
122
|
+
const results = await Promise.all(config.artifacts.map(entry => buildEntry(entry, workspaceCwd, outputFolder, config)));
|
|
123
|
+
const routingMap = new Map();
|
|
124
|
+
const outputFiles = [];
|
|
125
|
+
for (const result of results) {
|
|
126
|
+
outputFiles.push(result.basename);
|
|
127
|
+
routingMap.set(result.basename, result.routing);
|
|
128
|
+
}
|
|
129
|
+
return { outputFiles, routingMap };
|
|
130
|
+
}
|
|
131
|
+
//# sourceMappingURL=build-artifacts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"build-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1
|
+
{"version":3,"file":"cli-entry.d.ts","sourceRoot":"","sources":["../src/cli-entry.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli-entry.js","sourceRoot":"","sources":["../src/cli-entry.ts"],"names":[],"mappings":";;AAAA,+BAA+B;AAC/B,IAAA,YAAM,EAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC"}
|
package/dist/cli.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"AAIA,wBAAsB,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,iBAgB1C"}
|
package/dist/cli.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.runCli = runCli;
|
|
4
|
+
const clipanion_1 = require("clipanion");
|
|
5
|
+
const bundle_js_zip_1 = require("./commands/bundle-js-zip");
|
|
6
|
+
const build_artifacts_cmd_1 = require("./commands/build-artifacts-cmd");
|
|
7
|
+
async function runCli(argv) {
|
|
8
|
+
const cli = new clipanion_1.Cli({
|
|
9
|
+
binaryLabel: 'artifact-tools',
|
|
10
|
+
binaryName: 'artifact-tools',
|
|
11
|
+
binaryVersion: process.env.npm_package_version ?? '0.0.0-local',
|
|
12
|
+
});
|
|
13
|
+
cli.register(clipanion_1.Builtins.HelpCommand);
|
|
14
|
+
cli.register(clipanion_1.Builtins.VersionCommand);
|
|
15
|
+
cli.register(bundle_js_zip_1.BundleJsZipCommand);
|
|
16
|
+
cli.register(build_artifacts_cmd_1.BuildArtifactsCommand);
|
|
17
|
+
// Yarn scripts may inject a standalone `--` when forwarding args.
|
|
18
|
+
const normalizedArgv = argv.filter((a) => a !== '--');
|
|
19
|
+
await cli.runExit(normalizedArgv, clipanion_1.Cli.defaultContext);
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=cli.js.map
|
package/dist/cli.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";;AAIA,wBAgBC;AApBD,yCAA0C;AAC1C,4DAA8D;AAC9D,wEAAuE;AAEhE,KAAK,UAAU,MAAM,CAAC,IAAc;IACzC,MAAM,GAAG,GAAG,IAAI,eAAG,CAAC;QAClB,WAAW,EAAE,gBAAgB;QAC7B,UAAU,EAAE,gBAAgB;QAC5B,aAAa,EAAE,OAAO,CAAC,GAAG,CAAC,mBAAmB,IAAI,aAAa;KAChE,CAAC,CAAC;IAEH,GAAG,CAAC,QAAQ,CAAC,oBAAQ,CAAC,WAAW,CAAC,CAAC;IACnC,GAAG,CAAC,QAAQ,CAAC,oBAAQ,CAAC,cAAc,CAAC,CAAC;IAEtC,GAAG,CAAC,QAAQ,CAAC,kCAAkB,CAAC,CAAC;IACjC,GAAG,CAAC,QAAQ,CAAC,2CAAqB,CAAC,CAAC;IAEpC,kEAAkE;IAClE,MAAM,cAAc,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC;IACtD,MAAM,GAAG,CAAC,OAAO,CAAC,cAAc,EAAE,eAAG,CAAC,cAAc,CAAC,CAAC;AACxD,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Command } from 'clipanion';
|
|
2
|
+
export declare class BuildArtifactsCommand extends Command {
|
|
3
|
+
static paths: string[][];
|
|
4
|
+
static usage: import("clipanion").Usage;
|
|
5
|
+
cwd: string | undefined;
|
|
6
|
+
output: string | undefined;
|
|
7
|
+
execute(): Promise<number>;
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=build-artifacts-cmd.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"build-artifacts-cmd.d.ts","sourceRoot":"","sources":["../../src/commands/build-artifacts-cmd.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAU,MAAM,WAAW,CAAC;AAI5C,qBAAa,qBAAsB,SAAQ,OAAO;IAChD,OAAgB,KAAK,aAAe;IAEpC,OAAgB,KAAK,4BAMlB;IAEH,GAAG,qBAEA;IAEH,MAAM,qBAEH;IAEG,OAAO,IAAI,OAAO,CAAC,MAAM,CAAC;CAoBjC"}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.BuildArtifactsCommand = void 0;
|
|
37
|
+
const clipanion_1 = require("clipanion");
|
|
38
|
+
const path = __importStar(require("path"));
|
|
39
|
+
const build_artifacts_1 = require("../build-artifacts");
|
|
40
|
+
class BuildArtifactsCommand extends clipanion_1.Command {
|
|
41
|
+
constructor() {
|
|
42
|
+
super(...arguments);
|
|
43
|
+
this.cwd = clipanion_1.Option.String('--cwd', {
|
|
44
|
+
description: 'Workspace directory containing artifacts.cjs. Defaults to process.cwd().',
|
|
45
|
+
});
|
|
46
|
+
this.output = clipanion_1.Option.String('--output', {
|
|
47
|
+
description: 'Output folder for built artifacts. Defaults to gitversion.out/artifacts.',
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
async execute() {
|
|
51
|
+
const workspaceCwd = this.cwd ?? process.cwd();
|
|
52
|
+
const outputFolder = this.output
|
|
53
|
+
? path.isAbsolute(this.output)
|
|
54
|
+
? this.output
|
|
55
|
+
: path.join(process.cwd(), this.output)
|
|
56
|
+
: path.join(process.cwd(), 'gitversion.out', 'artifacts');
|
|
57
|
+
const result = await (0, build_artifacts_1.buildArtifacts)(workspaceCwd, outputFolder);
|
|
58
|
+
if (result.outputFiles.length === 0) {
|
|
59
|
+
this.context.stdout.write(`No artifacts found (no artifacts.cjs in ${workspaceCwd})\n`);
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
for (const file of result.outputFiles) {
|
|
63
|
+
this.context.stdout.write(`${file}\n`);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
return 0;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
exports.BuildArtifactsCommand = BuildArtifactsCommand;
|
|
70
|
+
BuildArtifactsCommand.paths = [['build']];
|
|
71
|
+
BuildArtifactsCommand.usage = clipanion_1.Command.Usage({
|
|
72
|
+
description: 'Build artifacts defined in artifacts.cjs and place them in the output folder.',
|
|
73
|
+
examples: [
|
|
74
|
+
['Build artifacts in current directory', '$0 build'],
|
|
75
|
+
['Build artifacts from a specific workspace', '$0 build --cwd packages/mailbox --output dist/artifacts'],
|
|
76
|
+
],
|
|
77
|
+
});
|
|
78
|
+
//# sourceMappingURL=build-artifacts-cmd.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"build-artifacts-cmd.js","sourceRoot":"","sources":["../../src/commands/build-artifacts-cmd.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,yCAA4C;AAC5C,2CAA6B;AAC7B,wDAAoD;AAEpD,MAAa,qBAAsB,SAAQ,mBAAO;IAAlD;;QAWE,QAAG,GAAG,kBAAM,CAAC,MAAM,CAAC,OAAO,EAAE;YAC3B,WAAW,EAAE,0EAA0E;SACxF,CAAC,CAAC;QAEH,WAAM,GAAG,kBAAM,CAAC,MAAM,CAAC,UAAU,EAAE;YACjC,WAAW,EAAE,0EAA0E;SACxF,CAAC,CAAC;IAsBL,CAAC;IApBC,KAAK,CAAC,OAAO;QACX,MAAM,YAAY,GAAG,IAAI,CAAC,GAAG,IAAI,OAAO,CAAC,GAAG,EAAE,CAAC;QAC/C,MAAM,YAAY,GAAG,IAAI,CAAC,MAAM;YAC9B,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC;gBAC5B,CAAC,CAAC,IAAI,CAAC,MAAM;gBACb,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,IAAI,CAAC,MAAM,CAAC;YACzC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,gBAAgB,EAAE,WAAW,CAAC,CAAC;QAE5D,MAAM,MAAM,GAAG,MAAM,IAAA,gCAAc,EAAC,YAAY,EAAE,YAAY,CAAC,CAAC;QAEhE,IAAI,MAAM,CAAC,WAAW,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACpC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,2CAA2C,YAAY,KAAK,CAAC,CAAC;QAC1F,CAAC;aAAM,CAAC;YACN,KAAK,MAAM,IAAI,IAAI,MAAM,CAAC,WAAW,EAAE,CAAC;gBACtC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,IAAI,IAAI,CAAC,CAAC;YACzC,CAAC;QACH,CAAC;QAED,OAAO,CAAC,CAAC;IACX,CAAC;;AAtCH,sDAuCC;AAtCiB,2BAAK,GAAG,CAAC,CAAC,OAAO,CAAC,CAAC,AAAd,CAAe;AAEpB,2BAAK,GAAG,mBAAO,CAAC,KAAK,CAAC;IACpC,WAAW,EAAE,+EAA+E;IAC5F,QAAQ,EAAE;QACR,CAAC,sCAAsC,EAAE,UAAU,CAAC;QACpD,CAAC,2CAA2C,EAAE,yDAAyD,CAAC;KACzG;CACF,CAAC,AANmB,CAMlB"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Command } from 'clipanion';
|
|
2
|
+
export declare class BundleJsZipCommand extends Command {
|
|
3
|
+
static paths: string[][];
|
|
4
|
+
static usage: import("clipanion").Usage;
|
|
5
|
+
entry: string;
|
|
6
|
+
out: string;
|
|
7
|
+
target: string;
|
|
8
|
+
minify: boolean;
|
|
9
|
+
external: string;
|
|
10
|
+
execute(): Promise<number>;
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=bundle-js-zip.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bundle-js-zip.d.ts","sourceRoot":"","sources":["../../src/commands/bundle-js-zip.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,OAAO,EAAU,MAAM,WAAW,CAAC;AAQ5C,qBAAa,kBAAmB,SAAQ,OAAO;IAC7C,OAAgB,KAAK,aAA0B;IAE/C,OAAgB,KAAK,4BAMlB;IAEH,KAAK,SAGF;IAEH,GAAG,SAGA;IAEH,MAAM,SAEH;IAEH,MAAM,UAEH;IAEH,QAAQ,SAEL;IAEG,OAAO,IAAI,OAAO,CAAC,MAAM,CAAC;CAuCjC"}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.BundleJsZipCommand = void 0;
|
|
37
|
+
const fs = __importStar(require("fs"));
|
|
38
|
+
const path = __importStar(require("path"));
|
|
39
|
+
const os = __importStar(require("os"));
|
|
40
|
+
const esbuild = __importStar(require("esbuild"));
|
|
41
|
+
const clipanion_1 = require("clipanion");
|
|
42
|
+
const common_1 = require("../utils/common");
|
|
43
|
+
function ensureParentDirExists(filePath) {
|
|
44
|
+
const parent = path.dirname(filePath);
|
|
45
|
+
fs.mkdirSync(parent, { recursive: true });
|
|
46
|
+
}
|
|
47
|
+
class BundleJsZipCommand extends clipanion_1.Command {
|
|
48
|
+
constructor() {
|
|
49
|
+
super(...arguments);
|
|
50
|
+
this.entry = clipanion_1.Option.String('--entry', {
|
|
51
|
+
required: true,
|
|
52
|
+
description: 'Entry file (.ts/.js). Can be absolute or relative to CWD.',
|
|
53
|
+
});
|
|
54
|
+
this.out = clipanion_1.Option.String('--out', {
|
|
55
|
+
required: true,
|
|
56
|
+
description: 'Output zip path.',
|
|
57
|
+
});
|
|
58
|
+
this.target = clipanion_1.Option.String('--target', 'node18', {
|
|
59
|
+
description: 'esbuild target (e.g. node18, node20).',
|
|
60
|
+
});
|
|
61
|
+
this.minify = clipanion_1.Option.Boolean('--minify', true, {
|
|
62
|
+
description: 'Minify output bundle.',
|
|
63
|
+
});
|
|
64
|
+
this.external = clipanion_1.Option.String('--external', 'aws-sdk', {
|
|
65
|
+
description: 'Comma-separated esbuild externals. Default: aws-sdk',
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
async execute() {
|
|
69
|
+
const entryPath = path.isAbsolute(this.entry) ? this.entry : path.join(process.cwd(), this.entry);
|
|
70
|
+
if (!fs.existsSync(entryPath) || !fs.statSync(entryPath).isFile()) {
|
|
71
|
+
throw new Error(`Entry file not found: ${entryPath}`);
|
|
72
|
+
}
|
|
73
|
+
const outZip = path.isAbsolute(this.out) ? this.out : path.join(process.cwd(), this.out);
|
|
74
|
+
ensureParentDirExists(outZip);
|
|
75
|
+
const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'mailbox-tools-bundle-'));
|
|
76
|
+
try {
|
|
77
|
+
const outJs = path.join(tmpDir, 'index.js');
|
|
78
|
+
const externals = this.external
|
|
79
|
+
.split(',')
|
|
80
|
+
.map((s) => s.trim())
|
|
81
|
+
.filter((s) => s.length > 0);
|
|
82
|
+
await esbuild.build({
|
|
83
|
+
entryPoints: [entryPath],
|
|
84
|
+
outfile: outJs,
|
|
85
|
+
platform: 'node',
|
|
86
|
+
target: this.target,
|
|
87
|
+
format: 'cjs',
|
|
88
|
+
bundle: true,
|
|
89
|
+
sourcemap: false,
|
|
90
|
+
minify: this.minify,
|
|
91
|
+
external: externals,
|
|
92
|
+
});
|
|
93
|
+
// Zip contains a single file `index.js` at the archive root.
|
|
94
|
+
// `-j` strips directory paths, ensuring the root layout.
|
|
95
|
+
(0, common_1.run)('zip', ['-j', outZip, outJs]);
|
|
96
|
+
return 0;
|
|
97
|
+
}
|
|
98
|
+
finally {
|
|
99
|
+
fs.rmSync(tmpDir, { recursive: true, force: true });
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
exports.BundleJsZipCommand = BundleJsZipCommand;
|
|
104
|
+
BundleJsZipCommand.paths = [['bundle', 'js-zip']];
|
|
105
|
+
BundleJsZipCommand.usage = clipanion_1.Command.Usage({
|
|
106
|
+
description: 'Bundle a JS/TS entrypoint into a zip containing a single index.js at the root.',
|
|
107
|
+
examples: [
|
|
108
|
+
['Bundle a Lambda-like zip', '$0 bundle js-zip --entry src/handler.ts --out dist/handler.zip'],
|
|
109
|
+
['Bundle with explicit target', '$0 bundle js-zip --entry src/handler.ts --out dist/handler.zip --target node18'],
|
|
110
|
+
],
|
|
111
|
+
});
|
|
112
|
+
//# sourceMappingURL=bundle-js-zip.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bundle-js-zip.js","sourceRoot":"","sources":["../../src/commands/bundle-js-zip.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uCAAyB;AACzB,2CAA6B;AAC7B,uCAAyB;AACzB,iDAAmC;AACnC,yCAA4C;AAC5C,4CAAsC;AAEtC,SAAS,qBAAqB,CAAC,QAAgB;IAC7C,MAAM,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;IACtC,EAAE,CAAC,SAAS,CAAC,MAAM,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;AAC5C,CAAC;AAED,MAAa,kBAAmB,SAAQ,mBAAO;IAA/C;;QAWE,UAAK,GAAG,kBAAM,CAAC,MAAM,CAAC,SAAS,EAAE;YAC/B,QAAQ,EAAE,IAAI;YACd,WAAW,EAAE,2DAA2D;SACzE,CAAC,CAAC;QAEH,QAAG,GAAG,kBAAM,CAAC,MAAM,CAAC,OAAO,EAAE;YAC3B,QAAQ,EAAE,IAAI;YACd,WAAW,EAAE,kBAAkB;SAChC,CAAC,CAAC;QAEH,WAAM,GAAG,kBAAM,CAAC,MAAM,CAAC,UAAU,EAAE,QAAQ,EAAE;YAC3C,WAAW,EAAE,uCAAuC;SACrD,CAAC,CAAC;QAEH,WAAM,GAAG,kBAAM,CAAC,OAAO,CAAC,UAAU,EAAE,IAAI,EAAE;YACxC,WAAW,EAAE,uBAAuB;SACrC,CAAC,CAAC;QAEH,aAAQ,GAAG,kBAAM,CAAC,MAAM,CAAC,YAAY,EAAE,SAAS,EAAE;YAChD,WAAW,EAAE,qDAAqD;SACnE,CAAC,CAAC;IAyCL,CAAC;IAvCC,KAAK,CAAC,OAAO;QACX,MAAM,SAAS,GAAG,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E,MAAM;gBAChB,MAAM,EAAE,IAAI,CAAC,MAAM;gBACnB,MAAM,EAAE,KAAK;gBACb,MAAM,EAAE,IAAI;gBACZ,SAAS,EAAE,KAAK;gBAChB,MAAM,EAAE,IAAI,CAAC,MAAM;gBACnB,QAAQ,EAAE,SAAS;aACpB,CAAC,CAAC;YAEH,6DAA6D;YAC7D,yDAAyD;YACzD,IAAA,YAAG,EAAC,KAAK,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC,CAAC;YAElC,OAAO,CAAC,CAAC;QACX,CAAC;gBAAS,CAAC;YACT,EAAE,CAAC,MAAM,CAAC,MAAM,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;QACtD,CAAC;IACH,CAAC;;AAvEH,gDAwEC;AAvEiB,wBAAK,GAAG,CAAC,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC,AAAzB,CAA0B;AAE/B,wBAAK,GAAG,mBAAO,CAAC,KAAK,CAAC;IACpC,WAAW,EAAE,gFAAgF;IAC7F,QAAQ,EAAE;QACR,CAAC,0BAA0B,EAAE,gEAAgE,CAAC;QAC9F,CAAC,6BAA6B,EAAE,gFAAgF,CAAC;KAClH;CACF,CAAC,AANmB,CAMlB"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { S3ArtifactPlugin } from './s3-artifact-plugin';
|
|
2
|
+
export { S3Uploader } from './uploader';
|
|
3
|
+
export type { S3WorkspaceConfig, S3ArtifactEntry } from './s3-artifact-plugin';
|
|
4
|
+
export { buildArtifacts } from './build-artifacts';
|
|
5
|
+
export type { ArtifactBuildResult } from './build-artifacts';
|
|
6
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AACxC,YAAY,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAC/E,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,YAAY,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.buildArtifacts = exports.S3Uploader = exports.S3ArtifactPlugin = void 0;
|
|
4
|
+
var s3_artifact_plugin_1 = require("./s3-artifact-plugin");
|
|
5
|
+
Object.defineProperty(exports, "S3ArtifactPlugin", { enumerable: true, get: function () { return s3_artifact_plugin_1.S3ArtifactPlugin; } });
|
|
6
|
+
var uploader_1 = require("./uploader");
|
|
7
|
+
Object.defineProperty(exports, "S3Uploader", { enumerable: true, get: function () { return uploader_1.S3Uploader; } });
|
|
8
|
+
var build_artifacts_1 = require("./build-artifacts");
|
|
9
|
+
Object.defineProperty(exports, "buildArtifacts", { enumerable: true, get: function () { return build_artifacts_1.buildArtifacts; } });
|
|
10
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,2DAAwD;AAA/C,sHAAA,gBAAgB,OAAA;AACzB,uCAAwC;AAA/B,sGAAA,UAAU,OAAA;AAEnB,qDAAmD;AAA1C,iHAAA,cAAc,OAAA"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { IPlugin, IPackManager, IWorkspace, PackedPackage } from '@jwpkg/gitversion';
|
|
2
|
+
export interface S3ArtifactEntry {
|
|
3
|
+
/** Path to source file or directory. Absolute or relative to workspace.cwd. */
|
|
4
|
+
source: string;
|
|
5
|
+
/** S3 object name for the output (e.g. 'lambdas/edge-deployer.zip', 'template.json'). */
|
|
6
|
+
objectName: string;
|
|
7
|
+
/** Overrides workspace-level bucketName for this artifact. */
|
|
8
|
+
bucketName?: string;
|
|
9
|
+
/** Overrides workspace-level basePath for this artifact. */
|
|
10
|
+
basePath?: string;
|
|
11
|
+
/** AWS region for the S3 client used to upload this artifact. Defaults to SDK default. */
|
|
12
|
+
region?: string;
|
|
13
|
+
}
|
|
14
|
+
export interface S3WorkspaceConfig {
|
|
15
|
+
/** Default S3 bucket for all artifacts in this workspace. */
|
|
16
|
+
bucketName: string;
|
|
17
|
+
/** Default S3 base path (e.g. 'packages/mailbox-cdk'). */
|
|
18
|
+
basePath: string;
|
|
19
|
+
/** Artifacts to stage and publish. */
|
|
20
|
+
artifacts: S3ArtifactEntry[];
|
|
21
|
+
}
|
|
22
|
+
declare class S3ArtifactPlugin implements IPlugin, IPackManager {
|
|
23
|
+
readonly ident = "s3-artifact";
|
|
24
|
+
readonly name = "S3 artifact plugin";
|
|
25
|
+
private readonly uploader;
|
|
26
|
+
private readonly artifactMap;
|
|
27
|
+
constructor();
|
|
28
|
+
get packManager(): IPackManager;
|
|
29
|
+
pack(workspace: IWorkspace, outputFolder: string): Promise<string[] | null>;
|
|
30
|
+
publish(packedPackage: PackedPackage, fileName: string, releaseTag: string, dryRun: boolean): Promise<void>;
|
|
31
|
+
}
|
|
32
|
+
export { S3ArtifactPlugin };
|
|
33
|
+
//# sourceMappingURL=s3-artifact-plugin.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"s3-artifact-plugin.d.ts","sourceRoot":"","sources":["../src/s3-artifact-plugin.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAI1F,MAAM,WAAW,eAAe;IAC9B,+EAA+E;IAC/E,MAAM,EAAE,MAAM,CAAC;IACf,yFAAyF;IACzF,UAAU,EAAE,MAAM,CAAC;IACnB,8DAA8D;IAC9D,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,4DAA4D;IAC5D,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,0FAA0F;IAC1F,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,iBAAiB;IAChC,6DAA6D;IAC7D,UAAU,EAAE,MAAM,CAAC;IACnB,0DAA0D;IAC1D,QAAQ,EAAE,MAAM,CAAC;IACjB,sCAAsC;IACtC,SAAS,EAAE,eAAe,EAAE,CAAC;CAC9B;AASD,cAAM,gBAAiB,YAAW,OAAO,EAAE,YAAY;IACrD,QAAQ,CAAC,KAAK,iBAAiB;IAC/B,QAAQ,CAAC,IAAI,wBAAwB;IAErC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAa;IACtC,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAuC;;IAMnE,IAAI,WAAW,IAAI,YAAY,CAE9B;IAEK,IAAI,CAAC,SAAS,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,GAAG,IAAI,CAAC;IAuD3E,OAAO,CAAC,aAAa,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;CAwBlH;AAED,OAAO,EAAE,gBAAgB,EAAE,CAAC"}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.S3ArtifactPlugin = void 0;
|
|
37
|
+
const fs = __importStar(require("fs/promises"));
|
|
38
|
+
const fssync = __importStar(require("fs"));
|
|
39
|
+
const path = __importStar(require("path"));
|
|
40
|
+
const uploader_1 = require("./uploader");
|
|
41
|
+
const common_1 = require("./utils/common");
|
|
42
|
+
class S3ArtifactPlugin {
|
|
43
|
+
constructor() {
|
|
44
|
+
this.ident = 's3-artifact';
|
|
45
|
+
this.name = 'S3 artifact plugin';
|
|
46
|
+
this.artifactMap = new Map();
|
|
47
|
+
this.uploader = new uploader_1.S3Uploader();
|
|
48
|
+
}
|
|
49
|
+
get packManager() {
|
|
50
|
+
return this;
|
|
51
|
+
}
|
|
52
|
+
async pack(workspace, outputFolder) {
|
|
53
|
+
let config;
|
|
54
|
+
try {
|
|
55
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
56
|
+
config = require(path.join(workspace.cwd, 'gitversion-s3.cjs'));
|
|
57
|
+
}
|
|
58
|
+
catch (err) {
|
|
59
|
+
const nodeErr = err;
|
|
60
|
+
if (nodeErr.code !== 'MODULE_NOT_FOUND') {
|
|
61
|
+
throw err;
|
|
62
|
+
}
|
|
63
|
+
// No config file for this workspace — skip silently
|
|
64
|
+
return null;
|
|
65
|
+
}
|
|
66
|
+
if (!Array.isArray(config.artifacts)) {
|
|
67
|
+
return null;
|
|
68
|
+
}
|
|
69
|
+
const outputFiles = [];
|
|
70
|
+
for (const entry of config.artifacts) {
|
|
71
|
+
const resolved = path.isAbsolute(entry.source)
|
|
72
|
+
? entry.source
|
|
73
|
+
: path.join(workspace.cwd, entry.source);
|
|
74
|
+
const outputBasename = path.basename(entry.objectName);
|
|
75
|
+
const outPath = path.join(outputFolder, outputBasename);
|
|
76
|
+
let isDirectory = false;
|
|
77
|
+
try {
|
|
78
|
+
isDirectory = fssync.statSync(resolved).isDirectory();
|
|
79
|
+
}
|
|
80
|
+
catch {
|
|
81
|
+
throw new Error(`[s3-artifact] Source not found: ${resolved}`);
|
|
82
|
+
}
|
|
83
|
+
if (isDirectory) {
|
|
84
|
+
(0, common_1.run)('zip', ['-r', outPath, '.'], { cwd: resolved });
|
|
85
|
+
}
|
|
86
|
+
else {
|
|
87
|
+
await fs.copyFile(resolved, outPath);
|
|
88
|
+
}
|
|
89
|
+
this.artifactMap.set(outputBasename, {
|
|
90
|
+
bucketName: entry.bucketName ?? config.bucketName,
|
|
91
|
+
basePath: entry.basePath ?? config.basePath,
|
|
92
|
+
region: entry.region,
|
|
93
|
+
objectName: entry.objectName,
|
|
94
|
+
});
|
|
95
|
+
outputFiles.push(outputBasename);
|
|
96
|
+
}
|
|
97
|
+
console.log(`[s3-artifact] Staged ${outputFiles.length} artifact(s) from ${workspace.cwd}/gitversion-s3.cjs`);
|
|
98
|
+
return outputFiles;
|
|
99
|
+
}
|
|
100
|
+
async publish(packedPackage, fileName, releaseTag, dryRun) {
|
|
101
|
+
const version = packedPackage.version;
|
|
102
|
+
const basename = path.basename(fileName);
|
|
103
|
+
const mapEntry = this.artifactMap.get(basename);
|
|
104
|
+
if (mapEntry === undefined) {
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
const { bucketName, basePath, region, objectName } = mapEntry;
|
|
108
|
+
const key = `${basePath}/v${version}/${objectName}`;
|
|
109
|
+
const uploader = new uploader_1.S3Uploader({ region });
|
|
110
|
+
if (dryRun) {
|
|
111
|
+
console.log(`[s3-artifact] [dry-run] Would upload ${basename} → s3://${bucketName}/${key}`);
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
console.log(`[s3-artifact] Uploading ${basename} → s3://${bucketName}/${key}`);
|
|
115
|
+
await uploader.upload(bucketName, key, fileName);
|
|
116
|
+
console.log(`[s3-artifact] Upload complete: s3://${bucketName}/${key}`);
|
|
117
|
+
await uploader.writeVersionPointers(bucketName, basePath, version);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
exports.S3ArtifactPlugin = S3ArtifactPlugin;
|
|
121
|
+
//# sourceMappingURL=s3-artifact-plugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"s3-artifact-plugin.js","sourceRoot":"","sources":["../src/s3-artifact-plugin.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,gDAAkC;AAClC,2CAA6B;AAC7B,2CAA6B;AAE7B,yCAAwC;AACxC,2CAAqC;AA+BrC,MAAM,gBAAgB;IAOpB;QANS,UAAK,GAAG,aAAa,CAAC;QACtB,SAAI,GAAG,oBAAoB,CAAC;QAGpB,gBAAW,GAAG,IAAI,GAAG,EAA4B,CAAC;QAGjE,IAAI,CAAC,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AAQ,EAAE,MAAM,EAAE,UAAU,EAAE,GAAG,QAAQ,CAAC;QAC9D,MAAM,GAAG,GAAG,GAAG,QAAQ,KAAK,OAAO,IAAI,UAAU,EAAE,CAAC;QACpD,MAAM,QAAQ,GAAG,IAAI,qBAAU,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC;QAE5C,IAAI,MAAM,EAAE,CAAC;YACX,OAAO,CAAC,GAAG,CAAC,wCAAwC,QAAQ,WAAW,UAAU,IAAI,GAAG,EAAE,CAAC,CAAC;YAC5F,OAAO;QACT,CAAC;QAED,OAAO,CAAC,GAAG,CAAC,2BAA2B,QAAQ,WAAW,UAAU,IAAI,GAAG,EAAE,CAAC,CAAC;QAC/E,MAAM,QAAQ,CAAC,MAAM,CAAC,UAAU,EAAE,GAAG,EAAE,QAAQ,CAAC,CAAC;QACjD,OAAO,CAAC,GAAG,CAAC,uCAAuC,UAAU,IAAI,GAAG,EAAE,CAAC,CAAC;QAExE,MAAM,QAAQ,CAAC,oBAAoB,CAAC,UAAU,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC;IACrE,CAAC;CACF;AAEQ,4CAAgB"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export declare class S3Uploader {
|
|
2
|
+
private readonly client;
|
|
3
|
+
constructor(config?: {
|
|
4
|
+
region?: string;
|
|
5
|
+
});
|
|
6
|
+
upload(bucket: string, key: string, filePath: string): Promise<void>;
|
|
7
|
+
uploadChannel(bucket: string, basePath: string, channel: string, objectName: string, filePath: string): Promise<void>;
|
|
8
|
+
uploadJson(bucket: string, key: string, data: unknown): Promise<void>;
|
|
9
|
+
readJson(bucket: string, key: string): Promise<unknown>;
|
|
10
|
+
writeVersionPointers(bucket: string, basePath: string, version: string): Promise<void>;
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=uploader.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"uploader.d.ts","sourceRoot":"","sources":["../src/uploader.ts"],"names":[],"mappings":"AAIA,qBAAa,UAAU;IACrB,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAW;gBAEtB,MAAM,CAAC,EAAE;QAAE,MAAM,CAAC,EAAE,MAAM,CAAA;KAAE;IAIlC,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IASpE,aAAa,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAKrH,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;IASrE,QAAQ,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAYvD,oBAAoB,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAa7F"}
|
package/dist/uploader.js
ADDED
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.S3Uploader = void 0;
|
|
40
|
+
const fs = __importStar(require("fs/promises"));
|
|
41
|
+
const client_s3_1 = require("@aws-sdk/client-s3");
|
|
42
|
+
const semver_1 = __importDefault(require("semver"));
|
|
43
|
+
class S3Uploader {
|
|
44
|
+
constructor(config) {
|
|
45
|
+
this.client = new client_s3_1.S3Client({ region: config?.region });
|
|
46
|
+
}
|
|
47
|
+
async upload(bucket, key, filePath) {
|
|
48
|
+
const body = await fs.readFile(filePath);
|
|
49
|
+
await this.client.send(new client_s3_1.PutObjectCommand({
|
|
50
|
+
Bucket: bucket,
|
|
51
|
+
Key: key,
|
|
52
|
+
Body: body,
|
|
53
|
+
}));
|
|
54
|
+
}
|
|
55
|
+
async uploadChannel(bucket, basePath, channel, objectName, filePath) {
|
|
56
|
+
const key = `${basePath}/channels/${channel}/${objectName}`;
|
|
57
|
+
await this.upload(bucket, key, filePath);
|
|
58
|
+
}
|
|
59
|
+
async uploadJson(bucket, key, data) {
|
|
60
|
+
await this.client.send(new client_s3_1.PutObjectCommand({
|
|
61
|
+
Bucket: bucket,
|
|
62
|
+
Key: key,
|
|
63
|
+
Body: JSON.stringify(data),
|
|
64
|
+
ContentType: 'application/json',
|
|
65
|
+
}));
|
|
66
|
+
}
|
|
67
|
+
async readJson(bucket, key) {
|
|
68
|
+
const response = await this.client.send(new client_s3_1.GetObjectCommand({
|
|
69
|
+
Bucket: bucket,
|
|
70
|
+
Key: key,
|
|
71
|
+
}));
|
|
72
|
+
const body = await response.Body?.transformToString();
|
|
73
|
+
if (body === undefined) {
|
|
74
|
+
throw new Error(`S3 object s3://${bucket}/${key} has no body`);
|
|
75
|
+
}
|
|
76
|
+
return JSON.parse(body);
|
|
77
|
+
}
|
|
78
|
+
async writeVersionPointers(bucket, basePath, version) {
|
|
79
|
+
const parsed = semver_1.default.parse(version);
|
|
80
|
+
if (!parsed)
|
|
81
|
+
return;
|
|
82
|
+
const { major, minor } = parsed;
|
|
83
|
+
const pointer = { version, publishedAt: new Date().toISOString() };
|
|
84
|
+
for (const track of [
|
|
85
|
+
'latest-stable',
|
|
86
|
+
`v${major}/latest-stable`,
|
|
87
|
+
`v${major}.${minor}/latest-stable`,
|
|
88
|
+
]) {
|
|
89
|
+
await this.uploadJson(bucket, `${basePath}/${track}.json`, pointer);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
exports.S3Uploader = S3Uploader;
|
|
94
|
+
//# sourceMappingURL=uploader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"uploader.js","sourceRoot":"","sources":["../src/uploader.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;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
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.run = run;
|
|
4
|
+
const child_process_1 = require("child_process");
|
|
5
|
+
function run(cmd, args, opts) {
|
|
6
|
+
const res = (0, child_process_1.spawnSync)(cmd, args, {
|
|
7
|
+
stdio: 'inherit',
|
|
8
|
+
cwd: opts?.cwd,
|
|
9
|
+
env: process.env,
|
|
10
|
+
});
|
|
11
|
+
if (res.status !== 0) {
|
|
12
|
+
throw new Error(`Command failed: ${cmd} ${args.join(' ')}`);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=common.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"common.js","sourceRoot":"","sources":["../../src/utils/common.ts"],"names":[],"mappings":";;AAMA,kBASC;AAfD,iDAA0C;AAM1C,SAAgB,GAAG,CAAC,GAAW,EAAE,IAAc,EAAE,IAAiB;IACjE,MAAM,GAAG,GAAG,IAAA,yBAAS,EAAC,GAAG,EAAE,IAAI,EAAE;QAChC,KAAK,EAAE,SAAS;QAChB,GAAG,EAAE,IAAI,EAAE,GAAG;QACd,GAAG,EAAE,OAAO,CAAC,GAAG;KAChB,CAAC,CAAC;IACH,IAAI,GAAG,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACtB,MAAM,IAAI,KAAK,CAAC,mBAAmB,GAAG,IAAI,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IAC7D,CAAC;AACF,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@serverlessinbox/artifact-tools",
|
|
3
|
+
"version": "0.0.7",
|
|
4
|
+
"description": "gitversion IPackManager plugin: stage pre-built Lambda zips and upload to S3",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"bin": "dist/cli-entry.js",
|
|
8
|
+
"files": [
|
|
9
|
+
"dist"
|
|
10
|
+
],
|
|
11
|
+
"scripts": {
|
|
12
|
+
"build": "tsc --noEmit false",
|
|
13
|
+
"prepublishOnly": "yarn build"
|
|
14
|
+
},
|
|
15
|
+
"publishConfig": {
|
|
16
|
+
"access": "public"
|
|
17
|
+
},
|
|
18
|
+
"packageManager": "yarn@4.15.0",
|
|
19
|
+
"license": "Apache-2.0",
|
|
20
|
+
"dependencies": {
|
|
21
|
+
"@aws-sdk/client-s3": "^3",
|
|
22
|
+
"clipanion": "^3.2.1",
|
|
23
|
+
"esbuild": "^0.27.1",
|
|
24
|
+
"semver": "^7.8.1"
|
|
25
|
+
},
|
|
26
|
+
"devDependencies": {
|
|
27
|
+
"@jwpkg/gitversion": "^1.3.3",
|
|
28
|
+
"@types/node": "^20",
|
|
29
|
+
"@types/semver": "^7.7.1",
|
|
30
|
+
"typescript": "^5"
|
|
31
|
+
},
|
|
32
|
+
"peerDependencies": {
|
|
33
|
+
"@jwpkg/gitversion": "^1"
|
|
34
|
+
}
|
|
35
|
+
}
|