@travetto/pack 2.2.1 → 2.2.4
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/bin/cli-pack.ts +3 -3
- package/bin/cli-pack_assemble.ts +4 -4
- package/bin/cli-pack_docker-export.ts +3 -3
- package/bin/cli-pack_docker.ts +6 -6
- package/bin/cli-pack_zip.ts +4 -4
- package/bin/lib/assemble.ts +18 -1
- package/bin/lib/types.ts +3 -1
- package/bin/lib/util.ts +29 -9
- package/bin/operation/assemble.ts +14 -11
- package/bin/operation/docker.ts +19 -11
- package/bin/operation/pack.ts +3 -3
- package/bin/operation/zip.ts +10 -8
- package/bin/pack-base.ts +14 -11
- package/package.json +3 -3
- package/support/pack.config.ts +1 -0
package/bin/cli-pack.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { BaseOptions,
|
|
1
|
+
import { BaseOptions, BasePackCommand } from './pack-base';
|
|
2
2
|
import { Pack, AllConfig } from './operation/pack';
|
|
3
3
|
|
|
4
|
-
export class
|
|
4
|
+
export class PackCommand extends BasePackCommand<BaseOptions, AllConfig> {
|
|
5
5
|
operation = Pack;
|
|
6
6
|
|
|
7
7
|
getOptions(): BaseOptions {
|
|
8
|
-
return this.
|
|
8
|
+
return this.commonOptions();
|
|
9
9
|
}
|
|
10
10
|
}
|
package/bin/cli-pack_assemble.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { OptionConfig } from '@travetto/cli/src/
|
|
1
|
+
import { OptionConfig } from '@travetto/cli/src/command';
|
|
2
2
|
|
|
3
|
-
import { BaseOptions,
|
|
3
|
+
import { BaseOptions, BasePackCommand } from './pack-base';
|
|
4
4
|
import { Assemble, AssembleConfig } from './operation/assemble';
|
|
5
5
|
|
|
6
6
|
type Options = BaseOptions & {
|
|
@@ -8,12 +8,12 @@ type Options = BaseOptions & {
|
|
|
8
8
|
readonly: OptionConfig<boolean>;
|
|
9
9
|
};
|
|
10
10
|
|
|
11
|
-
export class
|
|
11
|
+
export class PackAssembleCommand extends BasePackCommand<Options, AssembleConfig> {
|
|
12
12
|
operation = Assemble;
|
|
13
13
|
|
|
14
14
|
getOptions(): Options {
|
|
15
15
|
return {
|
|
16
|
-
...this.
|
|
16
|
+
...this.commonOptions(),
|
|
17
17
|
keepSource: this.boolOption({ desc: 'Should source be preserved' }),
|
|
18
18
|
readonly: this.boolOption({ desc: 'Build a readonly deployable' })
|
|
19
19
|
};
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import * as fs from 'fs/promises';
|
|
2
2
|
|
|
3
3
|
import { FsUtil, PathUtil } from '@travetto/boot';
|
|
4
|
-
import {
|
|
4
|
+
import { CliCommand, OptionConfig, ListOptionConfig } from '@travetto/cli/src/command';
|
|
5
5
|
|
|
6
6
|
type Options = {
|
|
7
7
|
app: OptionConfig<string>;
|
|
8
8
|
image: OptionConfig<string>;
|
|
9
9
|
port: OptionConfig<number>;
|
|
10
|
-
add:
|
|
10
|
+
add: ListOptionConfig<string>;
|
|
11
11
|
output: OptionConfig<string>;
|
|
12
12
|
};
|
|
13
13
|
|
|
14
|
-
export class
|
|
14
|
+
export class PackDockerExportCommand extends CliCommand<Options> {
|
|
15
15
|
|
|
16
16
|
name = 'pack:docker-export';
|
|
17
17
|
|
package/bin/cli-pack_docker.ts
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
import { OptionConfig } from '@travetto/cli/src/
|
|
1
|
+
import { OptionConfig, ListOptionConfig } from '@travetto/cli/src/command';
|
|
2
2
|
|
|
3
|
-
import { BaseOptions,
|
|
3
|
+
import { BaseOptions, BasePackCommand } from './pack-base';
|
|
4
4
|
import { Docker, DockerConfig } from './operation/docker';
|
|
5
5
|
|
|
6
6
|
type Options = BaseOptions & {
|
|
7
7
|
image: OptionConfig<string>;
|
|
8
8
|
name: OptionConfig<string>;
|
|
9
|
-
tag:
|
|
10
|
-
port:
|
|
9
|
+
tag: ListOptionConfig<string>;
|
|
10
|
+
port: ListOptionConfig<string>;
|
|
11
11
|
push: OptionConfig<boolean>;
|
|
12
12
|
registry: OptionConfig<string>;
|
|
13
13
|
};
|
|
14
14
|
|
|
15
|
-
export class
|
|
15
|
+
export class PackDockerCommand extends BasePackCommand<Options, DockerConfig> {
|
|
16
16
|
operation = Docker;
|
|
17
17
|
|
|
18
18
|
getOptions(): Options {
|
|
19
19
|
return {
|
|
20
|
-
...this.
|
|
20
|
+
...this.commonOptions(),
|
|
21
21
|
image: this.option({ desc: 'Docker Image to extend' }),
|
|
22
22
|
name: this.option({ desc: 'Image Name' }),
|
|
23
23
|
tag: this.listOption({ desc: 'Image Tag' }),
|
package/bin/cli-pack_zip.ts
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import { OptionConfig } from '@travetto/cli/src/
|
|
1
|
+
import { OptionConfig } from '@travetto/cli/src/command';
|
|
2
2
|
|
|
3
|
-
import { BaseOptions,
|
|
3
|
+
import { BaseOptions, BasePackCommand } from './pack-base';
|
|
4
4
|
import { Zip, ZipConfig } from './operation/zip';
|
|
5
5
|
|
|
6
6
|
type Options = BaseOptions & {
|
|
7
7
|
output: OptionConfig<string>;
|
|
8
8
|
};
|
|
9
9
|
|
|
10
|
-
export class
|
|
10
|
+
export class PackZipCommand extends BasePackCommand<Options, ZipConfig> {
|
|
11
11
|
operation = Zip;
|
|
12
12
|
|
|
13
13
|
getOptions(): Options {
|
|
14
14
|
return {
|
|
15
|
-
...this.
|
|
15
|
+
...this.commonOptions(),
|
|
16
16
|
output: this.option({ desc: 'Output File' })
|
|
17
17
|
};
|
|
18
18
|
}
|
package/bin/lib/assemble.ts
CHANGED
|
@@ -18,13 +18,30 @@ export class AssembleUtil {
|
|
|
18
18
|
*/
|
|
19
19
|
static async cleanCache(cache: string): Promise<void> {
|
|
20
20
|
for (const el of await fs.readdir(cache)) {
|
|
21
|
-
if (el.endsWith('.ts')) {
|
|
21
|
+
if (el.endsWith('.ts') || el.endsWith('.js')) {
|
|
22
22
|
const content = (await fs.readFile(`${cache}/${el}`, 'utf8')).replace(/\/\/# sourceMap.*/g, '');
|
|
23
23
|
await fs.writeFile(`${cache}/${el}`, content);
|
|
24
24
|
}
|
|
25
25
|
}
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
+
/**
|
|
29
|
+
* Minimize cached source files, by removing source mapping info
|
|
30
|
+
*/
|
|
31
|
+
static async cleanBoot(ws: string): Promise<void> {
|
|
32
|
+
for (const el of await ScanFs.scanDir({
|
|
33
|
+
testFile: f => f.endsWith('.js') || f.endsWith('.d.ts'),
|
|
34
|
+
testDir: x => true
|
|
35
|
+
}, `${ws}/node_modules/@travetto/boot`)) {
|
|
36
|
+
if (el.file.endsWith('.d.ts')) {
|
|
37
|
+
await fs.writeFile(el.file, '');
|
|
38
|
+
} else if (el.file.endsWith('.js')) {
|
|
39
|
+
const content = (await fs.readFile(el.file, 'utf8')).replace(/\/\/# sourceMap.*/g, '');
|
|
40
|
+
await fs.writeFile(el.file, content);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
28
45
|
/**
|
|
29
46
|
* Truncate all app source files, and framework source files
|
|
30
47
|
*/
|
package/bin/lib/types.ts
CHANGED
|
@@ -10,8 +10,10 @@ export type CommonConfig = {
|
|
|
10
10
|
export type PackOperation<T extends CommonConfig> = {
|
|
11
11
|
key: string;
|
|
12
12
|
title: string;
|
|
13
|
+
defaults?: Partial<T>;
|
|
13
14
|
overrides?: Partial<T>;
|
|
14
|
-
extend(
|
|
15
|
+
extend?(src: Partial<T>, dest: Partial<T>): Partial<T>;
|
|
15
16
|
context(cfg: T): Promise<string> | string;
|
|
16
17
|
exec(cfg: T): AsyncGenerator<string>;
|
|
18
|
+
buildConfig(configs: Partial<T>[]): T;
|
|
17
19
|
};
|
package/bin/lib/util.ts
CHANGED
|
@@ -17,15 +17,34 @@ export class PackUtil {
|
|
|
17
17
|
|
|
18
18
|
static #modes: Partial<CommonConfig>[];
|
|
19
19
|
|
|
20
|
-
|
|
20
|
+
/**
|
|
21
|
+
* Build configuration object for an operation with a set of configs
|
|
22
|
+
*/
|
|
23
|
+
static buildConfig<T extends CommonConfig>(
|
|
24
|
+
op: { defaults?: Partial<T>, overrides?: Partial<T>, extend?(src: Partial<T>, dest: Partial<T>): Partial<T> },
|
|
25
|
+
configs: Partial<T>[]
|
|
26
|
+
): T {
|
|
27
|
+
const inputs = [
|
|
28
|
+
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
29
|
+
op.defaults ?? {} as Partial<T>,
|
|
30
|
+
...configs,
|
|
31
|
+
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
32
|
+
op.overrides ?? {} as Partial<T>
|
|
33
|
+
].filter(x => Object.keys(x).length > 0);
|
|
34
|
+
|
|
35
|
+
const res = inputs.reduce((out: Partial<T>, config: Partial<T>): Partial<T> => {
|
|
36
|
+
const final = {
|
|
37
|
+
active: config.active ?? out.active,
|
|
38
|
+
workspace: config.workspace ?? out.workspace,
|
|
39
|
+
preProcess: [...(config.preProcess ?? []), ...(out.preProcess ?? [])],
|
|
40
|
+
postProcess: [...(config.postProcess ?? []), ...(out.postProcess ?? [])],
|
|
41
|
+
...op.extend?.(config, out)
|
|
42
|
+
};
|
|
43
|
+
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
44
|
+
return final as Partial<T>;
|
|
45
|
+
}, {});
|
|
21
46
|
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
22
|
-
|
|
23
|
-
active: b.active ?? a.active,
|
|
24
|
-
workspace: b.workspace ?? a.workspace,
|
|
25
|
-
preProcess: [...(b.preProcess ?? []), ...(a.preProcess ?? [])],
|
|
26
|
-
postProcess: [...(b.postProcess ?? []), ...(a.postProcess ?? [])],
|
|
27
|
-
} as unknown as T;
|
|
28
|
-
return out;
|
|
47
|
+
return res as T;
|
|
29
48
|
}
|
|
30
49
|
|
|
31
50
|
/**
|
|
@@ -123,7 +142,8 @@ export class PackUtil {
|
|
|
123
142
|
async function runPhase(phase: 'preProcess' | 'postProcess'): Promise<void> {
|
|
124
143
|
for (const el of cfg[phase] ?? []) {
|
|
125
144
|
const [name, fn] = Object.entries(el)[0];
|
|
126
|
-
|
|
145
|
+
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
146
|
+
await stdout(name as string);
|
|
127
147
|
await fn(cfg);
|
|
128
148
|
}
|
|
129
149
|
}
|
|
@@ -23,28 +23,30 @@ export const Assemble: PackOperation<AssembleConfig> = {
|
|
|
23
23
|
key: 'assemble',
|
|
24
24
|
title: 'Assembling',
|
|
25
25
|
context(cfg: AssembleConfig) {
|
|
26
|
-
return `[readonly=${cfg.readonly},cache=${cfg.cacheDir}]`;
|
|
26
|
+
return `[readonly=${cfg.readonly},cache=${cfg.cacheDir},source=${cfg.keepSource}]`;
|
|
27
27
|
},
|
|
28
28
|
overrides: {
|
|
29
29
|
keepSource: CliUtil.toBool(process.env.PACK_ASSEMBLE_KEEP_SOURCE),
|
|
30
30
|
readonly: CliUtil.toBool(process.env.PACK_ASSEMBLE_READONLY)
|
|
31
31
|
},
|
|
32
|
-
extend(
|
|
32
|
+
extend(src: Partial<AssembleConfig>, dest: Partial<AssembleConfig>): Partial<AssembleConfig> {
|
|
33
33
|
return {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
env: { ...(b.env ?? {}), ...(a.env ?? {}) },
|
|
34
|
+
keepSource: src.keepSource ?? dest.keepSource,
|
|
35
|
+
readonly: src.readonly ?? dest.readonly,
|
|
36
|
+
cacheDir: src.cacheDir ?? dest.cacheDir,
|
|
37
|
+
add: [...(src.add ?? []), ...(dest.add ?? [])],
|
|
38
|
+
exclude: [...(src.exclude ?? []), ...(dest.exclude ?? [])],
|
|
39
|
+
excludeCompile: [...(src.excludeCompile ?? []), ...(dest.excludeCompile ?? [])],
|
|
40
|
+
env: { ...(src.env ?? {}), ...(dest.env ?? {}) },
|
|
42
41
|
};
|
|
43
42
|
},
|
|
43
|
+
buildConfig(configs: Partial<AssembleConfig>[]): AssembleConfig {
|
|
44
|
+
return PackUtil.buildConfig(this, configs);
|
|
45
|
+
},
|
|
44
46
|
/**
|
|
45
47
|
* Assemble the project into a workspace directory, optimized for space and runtime
|
|
46
48
|
*/
|
|
47
|
-
async* exec({ workspace, cacheDir, add, exclude, excludeCompile, env, keepSource, readonly }: AssembleConfig) {
|
|
49
|
+
async * exec({ workspace, cacheDir, add, exclude, excludeCompile, env, keepSource, readonly }: AssembleConfig) {
|
|
48
50
|
const fullCacheDir = PathUtil.resolveUnix(workspace!, cacheDir);
|
|
49
51
|
const ws = PathUtil.resolveUnix(workspace!);
|
|
50
52
|
|
|
@@ -63,6 +65,7 @@ export const Assemble: PackOperation<AssembleConfig> = {
|
|
|
63
65
|
});
|
|
64
66
|
|
|
65
67
|
if (!keepSource) {
|
|
68
|
+
yield 'Clean Boot'; await AssembleUtil.cleanBoot(ws);
|
|
66
69
|
yield 'Remove Source Maps'; await AssembleUtil.cleanCache(fullCacheDir);
|
|
67
70
|
yield 'Emptying .ts Files'; await AssembleUtil.purgeSource([`${ws}/node_modules/@travetto`, `${ws}/src`]);
|
|
68
71
|
}
|
package/bin/operation/docker.ts
CHANGED
|
@@ -34,6 +34,12 @@ export const Docker: PackOperation<DockerConfig> = {
|
|
|
34
34
|
context(cfg: DockerConfig) {
|
|
35
35
|
return `[image=${cfg.image}, port=${cfg.port}]`;
|
|
36
36
|
},
|
|
37
|
+
defaults: {
|
|
38
|
+
name: Package.name.replace('@', ''),
|
|
39
|
+
builder: dockerFileBuilder,
|
|
40
|
+
port: [],
|
|
41
|
+
tag: ['latest']
|
|
42
|
+
},
|
|
37
43
|
overrides: {
|
|
38
44
|
image: process.env.PACK_DOCKER_IMAGE || undefined,
|
|
39
45
|
name: process.env.PACK_DOCKER_NAME || undefined,
|
|
@@ -43,20 +49,22 @@ export const Docker: PackOperation<DockerConfig> = {
|
|
|
43
49
|
push: CliUtil.toBool(process.env.PACK_DOCKER_PUSH),
|
|
44
50
|
tag: process.env.PACK_DOCKER_TAG ? [process.env.PACK_DOCKER_TAG] : undefined
|
|
45
51
|
},
|
|
46
|
-
extend(
|
|
52
|
+
extend(src: Partial<DockerConfig>, dest: Partial<DockerConfig>): Partial<DockerConfig> {
|
|
47
53
|
return {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
push: b.push ?? a.push
|
|
54
|
+
image: src.image ?? dest.image,
|
|
55
|
+
app: src.app ?? dest.app,
|
|
56
|
+
name: src.name ?? dest.name,
|
|
57
|
+
builder: src.builder ?? dest.builder,
|
|
58
|
+
tag: src.tag ?? dest.tag,
|
|
59
|
+
port: src.port ?? dest.port,
|
|
60
|
+
registry: src.registry ?? dest.registry,
|
|
61
|
+
env: { ...(src.env ?? {}), ...(dest.env ?? {}) },
|
|
62
|
+
push: src.push ?? dest.push
|
|
58
63
|
};
|
|
59
64
|
},
|
|
65
|
+
buildConfig(configs: Partial<DockerConfig>[]): DockerConfig {
|
|
66
|
+
return PackUtil.buildConfig(this, configs);
|
|
67
|
+
},
|
|
60
68
|
/**
|
|
61
69
|
* Dockerize workspace with flags
|
|
62
70
|
*/
|
package/bin/operation/pack.ts
CHANGED
|
@@ -31,13 +31,13 @@ type DefaultOpType = ['assemble', typeof Assemble];
|
|
|
31
31
|
export const Pack: PackOperation<AllConfig> = {
|
|
32
32
|
key: '',
|
|
33
33
|
title: 'Packing',
|
|
34
|
-
|
|
34
|
+
buildConfig(configs: Partial<AllConfig>[]): AllConfig {
|
|
35
35
|
const ret: Partial<AllConfig> = {
|
|
36
|
-
workspace:
|
|
36
|
+
workspace: configs[0].workspace,
|
|
37
37
|
};
|
|
38
38
|
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
39
39
|
for (const [k, op] of (Object.entries(ops) as DefaultOpType[])) {
|
|
40
|
-
ret[k] = op.
|
|
40
|
+
ret[k] = op.buildConfig(configs.map(config => config[k] ?? {}));
|
|
41
41
|
}
|
|
42
42
|
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
43
43
|
return ret as AllConfig;
|
package/bin/operation/zip.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as path from 'path';
|
|
2
2
|
import * as fs from 'fs/promises';
|
|
3
3
|
|
|
4
|
-
import { ExecUtil, PathUtil } from '@travetto/boot';
|
|
4
|
+
import { ExecUtil, FsUtil, PathUtil } from '@travetto/boot';
|
|
5
5
|
import { color } from '@travetto/cli/src/color';
|
|
6
6
|
|
|
7
7
|
import { CommonConfig, PackOperation } from '../lib/types';
|
|
@@ -20,22 +20,24 @@ export const Zip: PackOperation<ZipConfig> = {
|
|
|
20
20
|
overrides: {
|
|
21
21
|
output: process.env.PACK_ZIP_OUTPUT || undefined
|
|
22
22
|
},
|
|
23
|
-
extend(
|
|
24
|
-
return {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
23
|
+
extend(src: Partial<ZipConfig>, dest: Partial<ZipConfig>): Partial<ZipConfig> {
|
|
24
|
+
return { output: src.output ?? dest.output };
|
|
25
|
+
},
|
|
26
|
+
buildConfig(configs: Partial<ZipConfig>[]): ZipConfig {
|
|
27
|
+
return PackUtil.buildConfig(this, configs);
|
|
28
28
|
},
|
|
29
29
|
/**
|
|
30
30
|
* Zip workspace with flags
|
|
31
31
|
*/
|
|
32
|
-
async* exec({ workspace, output }: ZipConfig) {
|
|
32
|
+
async * exec({ workspace, output }: ZipConfig) {
|
|
33
33
|
const ws = PathUtil.resolveUnix(workspace);
|
|
34
34
|
const zipFile = PathUtil.resolveUnix(output);
|
|
35
35
|
|
|
36
36
|
yield 'Preparing Target';
|
|
37
37
|
await fs.mkdir(path.dirname(zipFile), { recursive: true });
|
|
38
|
-
await
|
|
38
|
+
if (await FsUtil.exists(zipFile)) {
|
|
39
|
+
await fs.unlink(zipFile); // Unlink
|
|
40
|
+
}
|
|
39
41
|
|
|
40
42
|
yield 'Compressing';
|
|
41
43
|
if (/win/i.test(process.platform)) {
|
package/bin/pack-base.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as os from 'os';
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import { CliCommand, OptionConfig } from '@travetto/cli/src/command';
|
|
4
4
|
import { color } from '@travetto/cli/src/color';
|
|
5
5
|
import { PathUtil, Package, FsUtil } from '@travetto/boot';
|
|
6
6
|
|
|
@@ -19,7 +19,7 @@ export type BaseOptions = {
|
|
|
19
19
|
/**
|
|
20
20
|
* Supports packing a project into a directory, ready for archiving
|
|
21
21
|
*/
|
|
22
|
-
export abstract class
|
|
22
|
+
export abstract class BasePackCommand<V extends BaseOptions, C extends CommonConfig> extends CliCommand<V> {
|
|
23
23
|
|
|
24
24
|
/**
|
|
25
25
|
* Package stage name
|
|
@@ -30,7 +30,7 @@ export abstract class BasePackPlugin<V extends BaseOptions, C extends CommonConf
|
|
|
30
30
|
return this.operation.key ? `pack:${this.operation.key}` : 'pack';
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
-
|
|
33
|
+
commonOptions(): BaseOptions {
|
|
34
34
|
return { workspace: this.option({ desc: 'Working directory' }) } as const;
|
|
35
35
|
}
|
|
36
36
|
|
|
@@ -45,14 +45,17 @@ export abstract class BasePackPlugin<V extends BaseOptions, C extends CommonConf
|
|
|
45
45
|
this.showHelp(`Unknown config mode: ${this.args[0]}`);
|
|
46
46
|
}
|
|
47
47
|
const def = list.find(c => c.name === 'default');
|
|
48
|
-
const
|
|
48
|
+
const configs = [def, cfg, extra]
|
|
49
49
|
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
50
|
-
.map(x => this.operation.key && this.operation.key in (x ?? {}) ? ((x as Record<string, C>)[this.operation.key] as C) : x as C)
|
|
50
|
+
.map(x => this.operation.key && this.operation.key in (x ?? {}) ? ((x as Record<string, C>)[this.operation.key] as C) : x as C);
|
|
51
|
+
|
|
52
|
+
return this.operation.buildConfig([
|
|
53
|
+
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
54
|
+
{ workspace: PathUtil.resolveUnix(os.tmpdir(), packName) } as C,
|
|
55
|
+
...configs,
|
|
51
56
|
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
out.active = true;
|
|
55
|
-
return out;
|
|
57
|
+
{ active: true } as C
|
|
58
|
+
]);
|
|
56
59
|
}
|
|
57
60
|
|
|
58
61
|
getArgs(): string {
|
|
@@ -62,7 +65,7 @@ export abstract class BasePackPlugin<V extends BaseOptions, C extends CommonConf
|
|
|
62
65
|
async help(): Promise<string> {
|
|
63
66
|
const lines = await PackUtil.modeList();
|
|
64
67
|
|
|
65
|
-
const out = [];
|
|
68
|
+
const out: string[] = [];
|
|
66
69
|
if (lines.length) {
|
|
67
70
|
out.push('', color`${{ title: 'Available Pack Modes:' }}`);
|
|
68
71
|
for (const { name, file } of lines) {
|
|
@@ -78,7 +81,7 @@ export abstract class BasePackPlugin<V extends BaseOptions, C extends CommonConf
|
|
|
78
81
|
}
|
|
79
82
|
|
|
80
83
|
async action(): Promise<void> {
|
|
81
|
-
const resolved
|
|
84
|
+
const resolved = await this.resolveConfigs();
|
|
82
85
|
if (await FsUtil.exists(PathUtil.resolveUnix(resolved.workspace, '.git'))) {
|
|
83
86
|
throw new Error('Refusing to use workspace with a .git directory');
|
|
84
87
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@travetto/pack",
|
|
3
3
|
"displayName": "Pack",
|
|
4
|
-
"version": "2.2.
|
|
4
|
+
"version": "2.2.4",
|
|
5
5
|
"description": "Code packing utilities",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"travetto",
|
|
@@ -25,12 +25,12 @@
|
|
|
25
25
|
"directory": "module/pack"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@travetto/base": "^2.2.
|
|
28
|
+
"@travetto/base": "^2.2.4",
|
|
29
29
|
"@types/picomatch": "^2.3.0",
|
|
30
30
|
"picomatch": "^2.3.1"
|
|
31
31
|
},
|
|
32
32
|
"optionalPeerDependencies": {
|
|
33
|
-
"@travetto/cli": "^2.2.
|
|
33
|
+
"@travetto/cli": "^2.2.4"
|
|
34
34
|
},
|
|
35
35
|
"docDependencies": {
|
|
36
36
|
"@travetto/rest": true
|
package/support/pack.config.ts
CHANGED