@travetto/pack 2.0.8 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +20 -20
- package/bin/cli-pack_docker-export.ts +4 -3
- package/bin/lib/util.ts +0 -12
- package/bin/operation/pack.ts +3 -4
- package/bin/pack-base.ts +14 -15
- package/package.json +5 -5
- package/support/pack.config.ts +19 -17
package/README.md
CHANGED
|
@@ -17,7 +17,7 @@ $ trv pack --help
|
|
|
17
17
|
Usage: pack [options] [mode]
|
|
18
18
|
|
|
19
19
|
Options:
|
|
20
|
-
-w, --workspace <workspace> Working directory
|
|
20
|
+
-w, --workspace <workspace> Working directory
|
|
21
21
|
-h, --help display help for command
|
|
22
22
|
|
|
23
23
|
Available Pack Modes:
|
|
@@ -61,13 +61,13 @@ assemble: {
|
|
|
61
61
|
TRV_DYNAMIC: '0'
|
|
62
62
|
},
|
|
63
63
|
add: [
|
|
64
|
-
{ '
|
|
65
|
-
{ '
|
|
64
|
+
{ [mod('@travetto/cli/bin/trv.js')]: mod('.bin/trv') },
|
|
65
|
+
{ [mod('lodash/lodash.min.js')]: mod('lodash/lodash.js') },
|
|
66
66
|
],
|
|
67
67
|
excludeCompile: [
|
|
68
|
-
'
|
|
69
|
-
'
|
|
70
|
-
'
|
|
68
|
+
mod('@travetto/*/doc/'),
|
|
69
|
+
mod('@travetto/*/e2e/'),
|
|
70
|
+
mod('@travetto/*/test/'),
|
|
71
71
|
],
|
|
72
72
|
exclude: [
|
|
73
73
|
'bower.json',
|
|
@@ -78,7 +78,7 @@ assemble: {
|
|
|
78
78
|
'*.lock',
|
|
79
79
|
'*.html',
|
|
80
80
|
'*.mjs',
|
|
81
|
-
'
|
|
81
|
+
mod('**/*.ts'),
|
|
82
82
|
'*.d.ts',
|
|
83
83
|
```
|
|
84
84
|
|
|
@@ -89,10 +89,10 @@ $ trv pack:assemble --help
|
|
|
89
89
|
Usage: pack:assemble [options] [mode]
|
|
90
90
|
|
|
91
91
|
Options:
|
|
92
|
-
-w, --workspace <workspace>
|
|
93
|
-
-k, --keep-source
|
|
94
|
-
-r, --readonly
|
|
95
|
-
-h, --help
|
|
92
|
+
-w, --workspace <workspace> Working directory
|
|
93
|
+
-k, --keep-source Should source be preserved
|
|
94
|
+
-r, --readonly Build a readonly deployable
|
|
95
|
+
-h, --help display help for command
|
|
96
96
|
|
|
97
97
|
Available Pack Modes:
|
|
98
98
|
* default [support/pack.config.ts]
|
|
@@ -119,8 +119,8 @@ $ trv pack:zip --help
|
|
|
119
119
|
Usage: pack:zip [options] [mode]
|
|
120
120
|
|
|
121
121
|
Options:
|
|
122
|
-
-w, --workspace <workspace> Working directory
|
|
123
|
-
-o, --output <output> Output File
|
|
122
|
+
-w, --workspace <workspace> Working directory
|
|
123
|
+
-o, --output <output> Output File
|
|
124
124
|
-h, --help display help for command
|
|
125
125
|
|
|
126
126
|
Available Pack Modes:
|
|
@@ -148,12 +148,12 @@ $ trv pack:docker --help
|
|
|
148
148
|
Usage: pack:docker [options] [mode]
|
|
149
149
|
|
|
150
150
|
Options:
|
|
151
|
-
-w, --workspace <workspace> Working directory
|
|
152
|
-
-i, --image <image> Docker Image to extend
|
|
153
|
-
-n, --name <name> Image Name
|
|
154
|
-
-t, --tag <tag> Image Tag (default: [
|
|
151
|
+
-w, --workspace <workspace> Working directory
|
|
152
|
+
-i, --image <image> Docker Image to extend
|
|
153
|
+
-n, --name <name> Image Name
|
|
154
|
+
-t, --tag <tag> Image Tag (default: [])
|
|
155
155
|
-p, --port <port> Image Port (default: [])
|
|
156
|
-
-x, --push
|
|
156
|
+
-x, --push Push Tags
|
|
157
157
|
-r, --registry <registry> Registry
|
|
158
158
|
-h, --help display help for command
|
|
159
159
|
|
|
@@ -171,7 +171,7 @@ Various modules may provide customizations to the default `pack.config.ts` to al
|
|
|
171
171
|
import * as fs from 'fs';
|
|
172
172
|
|
|
173
173
|
import { PathUtil } from '@travetto/boot';
|
|
174
|
-
import type { AllConfigPartial
|
|
174
|
+
import type { AllConfigPartial } from '@travetto/pack';
|
|
175
175
|
|
|
176
176
|
export const config: AllConfigPartial = {
|
|
177
177
|
name: 'rest/aws-lambda',
|
|
@@ -185,7 +185,7 @@ export const config: AllConfigPartial = {
|
|
|
185
185
|
NO_COLOR: '1'
|
|
186
186
|
},
|
|
187
187
|
postProcess: [{
|
|
188
|
-
'Lambda Entrypoint':
|
|
188
|
+
['Lambda Entrypoint']: cfg =>
|
|
189
189
|
fs.promises.copyFile(
|
|
190
190
|
PathUtil.resolveUnix(__dirname, 'aws-lambda.handler.js'),
|
|
191
191
|
PathUtil.resolveUnix(cfg.workspace, 'index.js')
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { FsUtil, PathUtil } from '@travetto/boot/src';
|
|
2
|
-
import { BasePlugin } from '@travetto/cli/src/plugin-base';
|
|
3
1
|
import * as fs from 'fs';
|
|
4
2
|
|
|
3
|
+
import { FsUtil, PathUtil } from '@travetto/boot';
|
|
4
|
+
import { BasePlugin } from '@travetto/cli/src/plugin-base';
|
|
5
|
+
|
|
5
6
|
export class PackDockerExportPlugin extends BasePlugin {
|
|
6
7
|
|
|
7
8
|
name = 'pack:docker-export';
|
|
@@ -16,7 +17,7 @@ export class PackDockerExportPlugin extends BasePlugin {
|
|
|
16
17
|
};
|
|
17
18
|
}
|
|
18
19
|
|
|
19
|
-
async action(...args:
|
|
20
|
+
async action(...args: unknown[]) {
|
|
20
21
|
const files = ['src', 'bin', 'support', 'resources', 'package.json', 'package-lock.json', ...this.cmd.add]
|
|
21
22
|
.filter(x => FsUtil.existsSync(PathUtil.resolveUnix(x)));
|
|
22
23
|
|
package/bin/lib/util.ts
CHANGED
|
@@ -15,7 +15,6 @@ import { CommonConfig, PackOperation } from './types';
|
|
|
15
15
|
*/
|
|
16
16
|
export class PackUtil {
|
|
17
17
|
|
|
18
|
-
static #defaultConfigs: Partial<CommonConfig>[];
|
|
19
18
|
static #modes: Partial<CommonConfig>[];
|
|
20
19
|
|
|
21
20
|
static commonExtend<T extends CommonConfig>(a: T, b: Partial<T>): T {
|
|
@@ -44,17 +43,6 @@ export class PackUtil {
|
|
|
44
43
|
return this.#modes;
|
|
45
44
|
}
|
|
46
45
|
|
|
47
|
-
/**
|
|
48
|
-
* Get Config
|
|
49
|
-
*/
|
|
50
|
-
static async getConfigs(): Promise<Partial<CommonConfig>[]> {
|
|
51
|
-
if (!this.#defaultConfigs) {
|
|
52
|
-
const allModes = await this.modeList();
|
|
53
|
-
const mode = allModes.find(x => process.argv.find(a => a === x.name))!;
|
|
54
|
-
this.#defaultConfigs = [allModes.find(x => x.name === 'default')!, mode!];
|
|
55
|
-
}
|
|
56
|
-
return this.#defaultConfigs;
|
|
57
|
-
}
|
|
58
46
|
|
|
59
47
|
/**
|
|
60
48
|
* Build file include/exclude lists/checker
|
package/bin/operation/pack.ts
CHANGED
|
@@ -9,6 +9,7 @@ import { Zip, ZipConfig } from './zip';
|
|
|
9
9
|
type DeepPartial<T> = {
|
|
10
10
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
11
11
|
[P in keyof T]?: (T[P] extends (number | string | boolean | undefined | RegExp | ((...args: any[]) => any)) ?
|
|
12
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
12
13
|
(T[P] | undefined) : (T[P] extends any[] ? DeepPartial<T[P][number]>[] : DeepPartial<T[P]>));
|
|
13
14
|
};
|
|
14
15
|
|
|
@@ -33,11 +34,8 @@ export const Pack: PackOperation<AllConfig> = {
|
|
|
33
34
|
workspace: b.workspace ?? a.workspace,
|
|
34
35
|
};
|
|
35
36
|
for (const [k, op] of Object.entries(ops) as ['assemble', typeof Assemble][]) {
|
|
36
|
-
|
|
37
|
-
ret[k] = op.extend(a[k] ?? {}, op.extend(b[k] ?? {}, op.overrides ?? {}));
|
|
38
|
-
ret[k]!.workspace = ret.workspace!;
|
|
37
|
+
ret[k] = op.extend(op.extend(a[k] ?? {}, b[k] ?? {}), op.overrides ?? {});
|
|
39
38
|
}
|
|
40
|
-
|
|
41
39
|
return ret as AllConfig;
|
|
42
40
|
},
|
|
43
41
|
async context(cfg: AllConfig) {
|
|
@@ -50,6 +48,7 @@ export const Pack: PackOperation<AllConfig> = {
|
|
|
50
48
|
}
|
|
51
49
|
for (const [step, op] of steps) {
|
|
52
50
|
process.stdout.write('\n');
|
|
51
|
+
cfg[step as 'assemble'].workspace = cfg.workspace;
|
|
53
52
|
await PackUtil.runOperation(op as typeof Assemble, cfg[step as 'assemble'], 2);
|
|
54
53
|
}
|
|
55
54
|
process.stdout.write('\n');
|
package/bin/pack-base.ts
CHANGED
|
@@ -30,10 +30,20 @@ export abstract class BasePackPlugin<C extends CommonConfig> extends BasePlugin
|
|
|
30
30
|
return { workspace: this.option({ desc: 'Working directory' }) } as const;
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
-
async resolveConfigs(
|
|
34
|
-
const
|
|
33
|
+
async resolveConfigs(): Promise<C> {
|
|
34
|
+
const extra = this.operation.key ? { [this.operation.key]: this.cmd } : this.cmd;
|
|
35
|
+
const list = (await PackUtil.modeList());
|
|
36
|
+
if (!this.args[0]) {
|
|
37
|
+
this.showHelp('Missing config mode');
|
|
38
|
+
}
|
|
39
|
+
const cfg = list.find(c => c.name === this.args[0]);
|
|
40
|
+
if (!cfg) {
|
|
41
|
+
this.showHelp(`Unknown config mode: ${this.args[0]}`);
|
|
42
|
+
}
|
|
43
|
+
const def = list.find(c => c.name === 'default');
|
|
44
|
+
const out: C = [def, cfg, extra]
|
|
35
45
|
.map(x => this.operation.key && this.operation.key in (x ?? {}) ? ((x as Record<string, C>)[this.operation.key] as C) : x as C)
|
|
36
|
-
.reduce((acc, l) => this.operation.extend(acc, l ?? {}),
|
|
46
|
+
.reduce((acc, l) => this.operation.extend(acc, l ?? {}), (this.operation.overrides ?? {}) as C);
|
|
37
47
|
out.workspace ??= PathUtil.resolveUnix(os.tmpdir(), packName);
|
|
38
48
|
out.active = true;
|
|
39
49
|
return out;
|
|
@@ -43,17 +53,6 @@ export abstract class BasePackPlugin<C extends CommonConfig> extends BasePlugin
|
|
|
43
53
|
return '[mode]';
|
|
44
54
|
}
|
|
45
55
|
|
|
46
|
-
override async finalizeOptions() {
|
|
47
|
-
const flags = await this.resolveConfigs();
|
|
48
|
-
const opts = await super.finalizeOptions();
|
|
49
|
-
for (const el of opts) {
|
|
50
|
-
if (el.key! in flags) {
|
|
51
|
-
el.def = flags[el.key! as keyof C];
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
return opts;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
56
|
async help() {
|
|
58
57
|
const lines = await PackUtil.modeList();
|
|
59
58
|
|
|
@@ -73,7 +72,7 @@ export abstract class BasePackPlugin<C extends CommonConfig> extends BasePlugin
|
|
|
73
72
|
}
|
|
74
73
|
|
|
75
74
|
async action() {
|
|
76
|
-
const resolved = await this.resolveConfigs(
|
|
75
|
+
const resolved = await this.resolveConfigs();
|
|
77
76
|
if (await FsUtil.exists(PathUtil.resolveUnix(resolved.workspace, '.git'))) {
|
|
78
77
|
throw new Error('Refusing to use workspace with a .git directory');
|
|
79
78
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@travetto/pack",
|
|
3
3
|
"displayName": "Pack",
|
|
4
|
-
"version": "2.0
|
|
4
|
+
"version": "2.1.0",
|
|
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.0
|
|
29
|
-
"@types/picomatch": "^2.
|
|
30
|
-
"picomatch": "^2.3.
|
|
28
|
+
"@travetto/base": "^2.1.0",
|
|
29
|
+
"@types/picomatch": "^2.3.0",
|
|
30
|
+
"picomatch": "^2.3.1"
|
|
31
31
|
},
|
|
32
32
|
"optionalPeerDependencies": {
|
|
33
|
-
"@travetto/cli": "^2.0
|
|
33
|
+
"@travetto/cli": "^2.1.0"
|
|
34
34
|
},
|
|
35
35
|
"docDependencies": {
|
|
36
36
|
"@travetto/rest": true
|
package/support/pack.config.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { AllConfigPartial } from '../bin/operation/pack';
|
|
2
2
|
|
|
3
|
+
const mod = (f: string) => `node_modules/${f}`;
|
|
4
|
+
|
|
3
5
|
export const config: AllConfigPartial = {
|
|
4
6
|
name: 'default',
|
|
5
7
|
assemble: {
|
|
@@ -11,13 +13,13 @@ export const config: AllConfigPartial = {
|
|
|
11
13
|
TRV_DYNAMIC: '0'
|
|
12
14
|
},
|
|
13
15
|
add: [
|
|
14
|
-
{ '
|
|
15
|
-
{ '
|
|
16
|
+
{ [mod('@travetto/cli/bin/trv.js')]: mod('.bin/trv') },
|
|
17
|
+
{ [mod('lodash/lodash.min.js')]: mod('lodash/lodash.js') },
|
|
16
18
|
],
|
|
17
19
|
excludeCompile: [
|
|
18
|
-
'
|
|
19
|
-
'
|
|
20
|
-
'
|
|
20
|
+
mod('@travetto/*/doc/'),
|
|
21
|
+
mod('@travetto/*/e2e/'),
|
|
22
|
+
mod('@travetto/*/test/'),
|
|
21
23
|
],
|
|
22
24
|
exclude: [
|
|
23
25
|
'bower.json',
|
|
@@ -28,7 +30,7 @@ export const config: AllConfigPartial = {
|
|
|
28
30
|
'*.lock',
|
|
29
31
|
'*.html',
|
|
30
32
|
'*.mjs',
|
|
31
|
-
'
|
|
33
|
+
mod('**/*.ts'),
|
|
32
34
|
'*.d.ts',
|
|
33
35
|
'*.tsbuildinfo',
|
|
34
36
|
'*.java',
|
|
@@ -37,17 +39,17 @@ export const config: AllConfigPartial = {
|
|
|
37
39
|
'.npmignore',
|
|
38
40
|
'.*.yml',
|
|
39
41
|
'cache/compiler.*.log',
|
|
40
|
-
'
|
|
41
|
-
'
|
|
42
|
-
'
|
|
43
|
-
'
|
|
44
|
-
'
|
|
45
|
-
'
|
|
46
|
-
'
|
|
47
|
-
'
|
|
48
|
-
'
|
|
49
|
-
'
|
|
50
|
-
'
|
|
42
|
+
mod('lodash/lodash.min.js'),
|
|
43
|
+
mod('source-map-support/node_modules/source-map'),
|
|
44
|
+
mod('source-map-support/browser-source-map-support.js'),
|
|
45
|
+
mod('bson/browser_build/'),
|
|
46
|
+
mod('**/tsconfig.json'),
|
|
47
|
+
mod('**/tsconfig.*.json'),
|
|
48
|
+
mod('@travetto/*/doc.ts'),
|
|
49
|
+
mod('typescript/'),
|
|
50
|
+
mod('@types/'),
|
|
51
|
+
`^./${mod('@travetto/**/*.ts')}`,
|
|
52
|
+
`^./${mod('@travetto/boot/tsconfig.trv.json')}`,
|
|
51
53
|
'^./resources/',
|
|
52
54
|
'^./src/',
|
|
53
55
|
]
|