@forge/cli-shared 9.3.0-next.2 → 9.3.0-next.20

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 CHANGED
@@ -1,5 +1,126 @@
1
1
  # @forge/cli-shared
2
2
 
3
+ ## 9.3.0-next.20
4
+
5
+ ### Patch Changes
6
+
7
+ - cddef39: Rename 'package' resource property to 'bundler' to align with property for backend bundling
8
+ - Updated dependencies [cddef39]
9
+ - @forge/manifest@13.3.0-next.11
10
+
11
+ ## 9.3.0-next.19
12
+
13
+ ### Minor Changes
14
+
15
+ - 342098d: Implement server-side linter logic to prevent accidental major app version deployments
16
+
17
+ ## 9.3.0-next.18
18
+
19
+ ### Patch Changes
20
+
21
+ - Updated dependencies [4404f62]
22
+ - @forge/manifest@13.3.0-next.10
23
+
24
+ ## 9.3.0-next.17
25
+
26
+ ### Patch Changes
27
+
28
+ - 8d20095: bump adm-zip to v0.6.0
29
+
30
+ ## 9.3.0-next.16
31
+
32
+ ### Patch Changes
33
+
34
+ - 905d8c5: Design changes, hint to module add and a spinner when loading
35
+
36
+ ## 9.3.0-next.15
37
+
38
+ ### Minor Changes
39
+
40
+ - 52e074e: Global App integration + Trigger / Action modules
41
+
42
+ ## 9.3.0-next.14
43
+
44
+ ### Patch Changes
45
+
46
+ - c8105d8: Remind the user to authenticate to the container registry after creating a new container
47
+ - 3e8de63: add `manifest render` command
48
+ - Updated dependencies [3e8de63]
49
+ - @forge/manifest@13.3.0-next.9
50
+
51
+ ## 9.3.0-next.13
52
+
53
+ ### Minor Changes
54
+
55
+ - 8a9e608: Pull the Forge tunnel proxy-sidecar image from the Portable Registry, falling back to ECR if the initial pull fails
56
+
57
+ ## 9.3.0-next.12
58
+
59
+ ### Patch Changes
60
+
61
+ - Updated dependencies [4b90a07]
62
+ - @forge/manifest@13.3.0-next.8
63
+
64
+ ## 9.3.0-next.11
65
+
66
+ ### Minor Changes
67
+
68
+ - 18b920d: Update feature gate name
69
+
70
+ ## 9.3.0-next.10
71
+
72
+ ### Minor Changes
73
+
74
+ - bc2d278: Display deeplinks to installed modules after a successful `forge install`
75
+
76
+ ## 9.3.0-next.9
77
+
78
+ ### Minor Changes
79
+
80
+ - a36d70b: Implement manual bundler
81
+
82
+ ## 9.3.0-next.8
83
+
84
+ ### Patch Changes
85
+
86
+ - Updated dependencies [89ccb1e]
87
+ - @forge/manifest@13.3.0-next.7
88
+
89
+ ## 9.3.0-next.7
90
+
91
+ ### Patch Changes
92
+
93
+ - e7bfe5e: Removing installationTarget
94
+ - Updated dependencies [e7bfe5e]
95
+ - @forge/manifest@13.3.0-next.6
96
+
97
+ ## 9.3.0-next.6
98
+
99
+ ### Patch Changes
100
+
101
+ - 0949833: Update `tmp` to 0.2.7 to remediate vulnerability
102
+
103
+ ## 9.3.0-next.5
104
+
105
+ ### Patch Changes
106
+
107
+ - Updated dependencies [d1610cc]
108
+ - @forge/manifest@13.3.0-next.5
109
+
110
+ ## 9.3.0-next.4
111
+
112
+ ### Patch Changes
113
+
114
+ - Updated dependencies [c3a0f20]
115
+ - @forge/manifest@13.3.0-next.4
116
+
117
+ ## 9.3.0-next.3
118
+
119
+ ### Patch Changes
120
+
121
+ - Updated dependencies [498fda5]
122
+ - @forge/manifest@13.3.0-next.3
123
+
3
124
  ## 9.3.0-next.2
4
125
 
5
126
  ### Patch Changes
@@ -1,4 +1,3 @@
1
- import { InstallationTarget } from '../graphql';
2
1
  import { StatsigService } from '../service';
3
2
  import { PackageInstaller } from './package-installer';
4
3
  import { CreateAppClientInput, RegisterAppCommand, RegisterAppResult } from './register-app';
@@ -7,7 +6,6 @@ export interface CreateAppCommandInput extends CreateAppClientInput {
7
6
  template: string;
8
7
  directory: string;
9
8
  requiredProduct?: string;
10
- installationTarget?: InstallationTarget;
11
9
  }
12
10
  export declare class NoTemplatesError extends Error {
13
11
  constructor();
@@ -23,7 +21,7 @@ export declare class CreateAppCommand {
23
21
  private readonly packageInstaller;
24
22
  private readonly statsig;
25
23
  constructor(templater: Templater, registerAppCommand: RegisterAppCommand, packageInstaller: PackageInstaller, statsig: StatsigService);
26
- execute({ name, description, template, directory, requiredProduct, installationTarget, developerSpaceId, billingConsent, appFeatures }: CreateAppCommandInput): Promise<CreateAppCommandResult>;
24
+ execute({ name, description, template, directory, requiredProduct, developerSpaceId, billingConsent, appFeatures }: CreateAppCommandInput): Promise<CreateAppCommandResult>;
27
25
  getAvailableTemplates(): Promise<string[]>;
28
26
  filterAvailableProducts<T extends string>(products: T[], teamworkGraph: T, crossContext: T): Promise<T[]>;
29
27
  }
@@ -1 +1 @@
1
- {"version":3,"file":"create-an-app.d.ts","sourceRoot":"","sources":["../../src/apps/create-an-app.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAChD,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAE5C,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,EAAE,oBAAoB,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAC7F,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACvC,MAAM,WAAW,qBAAsB,SAAQ,oBAAoB;IACjE,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,kBAAkB,CAAC,EAAE,kBAAkB,CAAC;CACzC;AAED,qBAAa,gBAAiB,SAAQ,KAAK;;CAI1C;AAED,MAAM,MAAM,sBAAsB,GAAG,iBAAiB,GAAG;IACvD,SAAS,EAAE;QACT,QAAQ,EAAE,MAAM,CAAC;KAClB,CAAC;CACH,CAAC;AAEF,qBAAa,gBAAgB;IAEzB,OAAO,CAAC,QAAQ,CAAC,SAAS;IAC1B,OAAO,CAAC,QAAQ,CAAC,kBAAkB;IACnC,OAAO,CAAC,QAAQ,CAAC,gBAAgB;IACj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,QAAQ,CAAC,kBAAkB;IACnC,OAAO,CAAC,QAAQ,CAAC,gBAAgB;IACjC,OAAO,CAAC,QAAQ,CAAC,OAAO;gBAHP,SAAS,EAAE,SAAS,EACpB,kBAAkB,EAAE,kBAAkB,EACtC,gBAAgB,EAAE,gBAAgB,EAClC,OAAO,EAAE,cAAc;IAG7B,OAAO,CAAC,EACnB,IAAI,EACJ,WAAW,EACX,QAAQ,EACR,SAAS,EACT,eAAe,EACf,gBAAgB,EAChB,cAAc,EACd,WAAW,EACZ,EAAE,qBAAqB,GAAG,OAAO,CAAC,sBAAsB,CAAC;IAuB7C,qBAAqB,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;IAS1C,uBAAuB,CAAC,CAAC,SAAS,MAAM,EACnD,QAAQ,EAAE,CAAC,EAAE,EACb,aAAa,EAAE,CAAC,EAChB,YAAY,EAAE,CAAC,GACd,OAAO,CAAC,CAAC,EAAE,CAAC;CAchB"}
@@ -19,7 +19,7 @@ class CreateAppCommand {
19
19
  this.packageInstaller = packageInstaller;
20
20
  this.statsig = statsig;
21
21
  }
22
- async execute({ name, description, template, directory, requiredProduct, installationTarget, developerSpaceId, billingConsent, appFeatures }) {
22
+ async execute({ name, description, template, directory, requiredProduct, developerSpaceId, billingConsent, appFeatures }) {
23
23
  await this.templater.downloadAndExtract(template, directory);
24
24
  const result = await this.registerAppCommand.registerApp({
25
25
  name,
@@ -29,8 +29,7 @@ class CreateAppCommand {
29
29
  ...(appFeatures && { appFeatures })
30
30
  }, directory, {
31
31
  shouldPrependAppName: true,
32
- requiredProduct,
33
- installationTarget
32
+ requiredProduct
34
33
  });
35
34
  await this.packageInstaller.install(directory);
36
35
  return {
@@ -1,5 +1,5 @@
1
1
  import { ConfigFile, ConfigSectionReader, ConfigSectionWriter, NO_VALIDATION_TYPE } from '../config';
2
- import { CreateAppInput, InstallationTarget } from '../graphql';
2
+ import { CreateAppInput } from '../graphql';
3
3
  import { Logger } from '../ui';
4
4
  import { AppDetails } from './app-config';
5
5
  export interface CreateAppClientInput {
@@ -35,10 +35,9 @@ export declare class RegisterAppCommand {
35
35
  execute(input: CreateAppClientInput, { shouldPrependAppName }?: {
36
36
  shouldPrependAppName?: boolean | undefined;
37
37
  }): Promise<RegisterAppResult>;
38
- registerApp(input: CreateAppClientInput, directory: string, { shouldPrependAppName, requiredProduct, installationTarget }: {
38
+ registerApp(input: CreateAppClientInput, directory: string, { shouldPrependAppName, requiredProduct }: {
39
39
  shouldPrependAppName: boolean;
40
40
  requiredProduct?: string;
41
- installationTarget?: InstallationTarget;
42
41
  }): Promise<CreateAppResult>;
43
42
  }
44
43
  //# sourceMappingURL=register-app.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"register-app.d.ts","sourceRoot":"","sources":["../../src/apps/register-app.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,mBAAmB,EAAE,mBAAmB,EAAqB,kBAAkB,EAAE,MAAM,WAAW,CAAC;AAExH,OAAO,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAChE,OAAO,EAAE,MAAM,EAAQ,MAAM,OAAO,CAAC;AACrC,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C,MAAM,WAAW,oBAAoB;IACnC,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,WAAW,CAAC,EAAE,cAAc,CAAC,aAAa,CAAC,CAAC;CAC7C;AAED,MAAM,WAAW,eAAe;IAC9B,EAAE,EAAE,MAAM,CAAC;IACX,YAAY,EAAE;QACZ,GAAG,EAAE,MAAM,CAAC;KACb,EAAE,CAAC;CACL;AAED,MAAM,WAAW,eAAe;IAC9B,SAAS,CAAC,KAAK,EAAE,oBAAoB,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC;CAClE;AAED,MAAM,MAAM,iBA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QAC9B,eAAe,CAAC,EAAE,MAAM,CAAC;KAC1B,GACA,OAAO,CAAC,eAAe,CAAC;CAuC5B"}
@@ -24,7 +24,7 @@ class RegisterAppCommand {
24
24
  environments: result.environments.map((env) => env.key)
25
25
  };
26
26
  }
27
- async registerApp(input, directory, { shouldPrependAppName, requiredProduct, installationTarget }) {
27
+ async registerApp(input, directory, { shouldPrependAppName, requiredProduct }) {
28
28
  this.logger.info(ui_1.Text.create.taskRegister);
29
29
  const result = await this.appClient.createApp(input);
30
30
  await (0, file_system_1.inDirectory)(directory, async () => {
@@ -38,7 +38,6 @@ class RegisterAppCommand {
38
38
  const section = await this.appConfigReader.readConfigSection();
39
39
  let newAppDetails = {
40
40
  id: result.id,
41
- ...(installationTarget && { installationTarget }),
42
41
  ...(requiredProduct && {
43
42
  compatibility: {
44
43
  [requiredProduct]: {
@@ -15,6 +15,6 @@ const isHostedResourceModule = (module) => {
15
15
  };
16
16
  exports.isHostedResourceModule = isHostedResourceModule;
17
17
  const shouldBundleResource = (resource) => {
18
- return resource.resourceType === 'nativeUI' && !resource.package;
18
+ return resource.resourceType === 'nativeUI' && !resource.bundler;
19
19
  };
20
20
  exports.shouldBundleResource = shouldBundleResource;
@@ -0,0 +1,40 @@
1
+ import { UserError } from '../shared';
2
+ import { Logger } from '../ui';
3
+ export declare abstract class Archiver {
4
+ abstract addContent(fileName: string, contents: Buffer): void;
5
+ abstract addFrom(fileName: string, filePath: string): void;
6
+ abstract finalise(): Promise<string>;
7
+ addMany(entries: Map<string, string | Buffer>): void;
8
+ }
9
+ export declare class ArchiverError extends UserError {
10
+ }
11
+ export declare class ZipArchiver extends Archiver {
12
+ private readonly archive;
13
+ private readonly logger;
14
+ private tempFile;
15
+ private resolves;
16
+ private rejects;
17
+ private constructor();
18
+ static create(logger: Logger): Promise<ZipArchiver>;
19
+ addContent(fileName: string, contents: Buffer): void;
20
+ addFrom(fileName: string, filePath: string): void;
21
+ finalise(): Promise<string>;
22
+ onWarning(cb: (err: Error) => void): void;
23
+ private onArchiveError;
24
+ private onClose;
25
+ }
26
+ export declare class DirectoryArchiver extends Archiver {
27
+ private readonly target;
28
+ constructor(target: string);
29
+ addContent(fileName: string, contents: Buffer): void;
30
+ addFrom(fileName: string, filePath: string): void;
31
+ finalise(): Promise<string>;
32
+ }
33
+ export declare class MultiArchiver extends Archiver {
34
+ private readonly archivers;
35
+ constructor(archivers: Archiver[]);
36
+ addContent(fileName: string, contents: Buffer): void;
37
+ addFrom(fileName: string, filePath: string): void;
38
+ finalise(): Promise<string>;
39
+ }
40
+ //# sourceMappingURL=archiver.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"archiver.d.ts","sourceRoot":"","sources":["../../src/file-system/archiver.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAE/B,8BAAsB,QAAQ;aACZ,UAAU,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI;aAKpD,OAAO,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI;aACjD,QAAQ,IAAI,OAAO,CAAC,MAAM,CAAC;IAMpC,OAAO,CAAC,OAAO,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,GAAG,IAAI;CAS5D;AAED,qBAAa,aAAc,SAAQ,SAAS;CAAG;AA4B/C,qBAAa,WAAY,SAAQ,QAAQ;IAMrC,OAAO,CAAC,QAAQ,CAAC,OAAO;IACxB,OAAO,CAAC,QAAQ,CAAC,MAAM;IANzB,OAAO,CAAC,QAAQ,CAAqC;IACrD,OAAO,CAAC,QAAQ,CAAsC;IACtD,OAAO,CAAC,OAAO,CAAmC;IAElD,OAAO;WAaa,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC;IAKzD,UAAU,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI;IAMpD,OAAO,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI;IAUjD,QAAQ,IAAI,OAAO,CAAC,MAAM,CAAC;IAS3B,SAAS,CAAC,EAAE,EAAE,CAAC,GAAG,EAAE,KAAK,KAAK,IAAI;IAIzC,OAAO,CAAC,cAAc,CAKpB;IAEF,OAAO,CAAC,OAAO,CAIb;CACH;AAED,qBAAa,iBAAkB,SAAQ,QAAQ;IACjC,OAAO,CAAC,QAAQ,CAAC,MAAM;gBAAN,MAAM,EAAE,MAAM;IAIpC,UAAU,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI;IAWpD,OAAO,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI;IAU3C,QAAQ,IAAI,OAAO,CAAC,MAAM,CAAC;CAGzC;AAED,qBAAa,aAAc,SAAQ,QAAQ;IAC7B,OAAO,CAAC,QAAQ,CAAC,SAAS;gBAAT,SAAS,EAAE,QAAQ,EAAE;IAI3C,UAAU,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI;IAMpD,OAAO,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI;IAM3C,QAAQ,IAAI,OAAO,CAAC,MAAM,CAAC;CAIzC"}
@@ -0,0 +1,148 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MultiArchiver = exports.DirectoryArchiver = exports.ZipArchiver = exports.ArchiverError = exports.Archiver = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const fs_1 = require("fs");
6
+ const path_1 = tslib_1.__importDefault(require("path"));
7
+ const tmp_1 = tslib_1.__importDefault(require("tmp"));
8
+ const shared_1 = require("../shared");
9
+ class Archiver {
10
+ addMany(entries) {
11
+ for (const [name, output] of entries) {
12
+ if (Buffer.isBuffer(output)) {
13
+ this.addContent(name, output);
14
+ }
15
+ else {
16
+ this.addFrom(name, output);
17
+ }
18
+ }
19
+ }
20
+ }
21
+ exports.Archiver = Archiver;
22
+ class ArchiverError extends shared_1.UserError {
23
+ }
24
+ exports.ArchiverError = ArchiverError;
25
+ const invalidArchivePathMessage = (fileName) => `Invalid archive path "${fileName}"`;
26
+ const archiveContentAddedMessage = (fileName) => `Added archive content "${fileName}"`;
27
+ const archiveFileAddedMessage = (fileName, filePath) => `Added archive file "${fileName}" from "${filePath}"`;
28
+ function validateArchivePath(fileName) {
29
+ if (!fileName) {
30
+ return;
31
+ }
32
+ const normalizedPath = path_1.default.posix.normalize(fileName.replace(/\\/g, '/'));
33
+ if (path_1.default.posix.isAbsolute(normalizedPath) || normalizedPath === '..' || normalizedPath.startsWith('../')) {
34
+ throw new ArchiverError(invalidArchivePathMessage(fileName));
35
+ }
36
+ }
37
+ class ZipArchiver extends Archiver {
38
+ archive;
39
+ logger;
40
+ tempFile = tmp_1.default.fileSync({ postfix: '.zip' });
41
+ resolves = [];
42
+ rejects = [];
43
+ constructor(archive, logger) {
44
+ super();
45
+ this.archive = archive;
46
+ this.logger = logger;
47
+ const output = (0, fs_1.createWriteStream)(this.tempFile.name);
48
+ this.archive.pipe(output);
49
+ output.on('close', this.onClose);
50
+ this.archive.on('warning', this.onArchiveError);
51
+ this.archive.on('error', this.onArchiveError);
52
+ }
53
+ static async create(logger) {
54
+ const { ZipArchive } = await Promise.resolve().then(() => tslib_1.__importStar(require('archiver')));
55
+ return new ZipArchiver(new ZipArchive(), logger);
56
+ }
57
+ addContent(fileName, contents) {
58
+ validateArchivePath(fileName);
59
+ this.archive.append(contents, { name: fileName });
60
+ this.logger.debug(archiveContentAddedMessage(fileName));
61
+ }
62
+ addFrom(fileName, filePath) {
63
+ validateArchivePath(fileName);
64
+ if ((0, fs_1.statSync)(filePath).isDirectory()) {
65
+ this.archive.directory(filePath, fileName || false);
66
+ }
67
+ else {
68
+ this.archive.file(filePath, { name: fileName });
69
+ }
70
+ this.logger.debug(archiveFileAddedMessage(fileName, filePath));
71
+ }
72
+ finalise() {
73
+ return new Promise((resolve, reject) => {
74
+ this.resolves.push(resolve);
75
+ this.rejects.push(reject);
76
+ this.archive.finalize();
77
+ });
78
+ }
79
+ onWarning(cb) {
80
+ this.archive.on('warning', cb);
81
+ }
82
+ onArchiveError = (err) => {
83
+ const error = new ArchiverError(err.message);
84
+ for (const reject of this.rejects) {
85
+ reject(error);
86
+ }
87
+ };
88
+ onClose = () => {
89
+ for (const resolve of this.resolves) {
90
+ resolve(this.tempFile.name);
91
+ }
92
+ };
93
+ }
94
+ exports.ZipArchiver = ZipArchiver;
95
+ class DirectoryArchiver extends Archiver {
96
+ target;
97
+ constructor(target) {
98
+ super();
99
+ this.target = target;
100
+ }
101
+ addContent(fileName, contents) {
102
+ validateArchivePath(fileName);
103
+ try {
104
+ const targetName = path_1.default.join(this.target, fileName);
105
+ (0, fs_1.mkdirSync)(path_1.default.dirname(targetName), { recursive: true });
106
+ (0, fs_1.writeFileSync)(targetName, contents);
107
+ }
108
+ catch (e) {
109
+ throw new ArchiverError(e.message);
110
+ }
111
+ }
112
+ addFrom(fileName, filePath) {
113
+ validateArchivePath(fileName);
114
+ try {
115
+ const targetName = path_1.default.join(this.target, fileName);
116
+ (0, fs_1.cpSync)(filePath, targetName, { recursive: true });
117
+ }
118
+ catch (e) {
119
+ throw new ArchiverError(e.message);
120
+ }
121
+ }
122
+ async finalise() {
123
+ return this.target;
124
+ }
125
+ }
126
+ exports.DirectoryArchiver = DirectoryArchiver;
127
+ class MultiArchiver extends Archiver {
128
+ archivers;
129
+ constructor(archivers) {
130
+ super();
131
+ this.archivers = archivers;
132
+ }
133
+ addContent(fileName, contents) {
134
+ for (const archiver of this.archivers) {
135
+ archiver.addContent(fileName, contents);
136
+ }
137
+ }
138
+ addFrom(fileName, filePath) {
139
+ for (const archiver of this.archivers) {
140
+ archiver.addFrom(fileName, filePath);
141
+ }
142
+ }
143
+ async finalise() {
144
+ const paths = await Promise.all(this.archivers.map((archiver) => archiver.finalise()));
145
+ return paths[0];
146
+ }
147
+ }
148
+ exports.MultiArchiver = MultiArchiver;
@@ -1,5 +1,6 @@
1
1
  export * from './file-system-reader';
2
2
  export * from './file-system-writer';
3
+ export * from './archiver';
3
4
  export * from './util';
4
5
  export * from './zip-accessor';
5
6
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/file-system/index.ts"],"names":[],"mappings":"AAEA,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC;AACrC,cAAc,QAAQ,CAAC;AACvB,cAAc,gBAAgB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/file-system/index.ts"],"names":[],"mappings":"AAEA,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC;AACrC,cAAc,YAAY,CAAC;AAC3B,cAAc,QAAQ,CAAC;AACvB,cAAc,gBAAgB,CAAC"}
@@ -3,5 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
4
  tslib_1.__exportStar(require("./file-system-reader"), exports);
5
5
  tslib_1.__exportStar(require("./file-system-writer"), exports);
6
+ tslib_1.__exportStar(require("./archiver"), exports);
6
7
  tslib_1.__exportStar(require("./util"), exports);
7
8
  tslib_1.__exportStar(require("./zip-accessor"), exports);