@travetto/pack 8.0.0-alpha.0 → 8.0.0-alpha.2
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 +4 -4
- package/package.json +5 -5
- package/support/cli.pack.ts +1 -1
- package/support/cli.pack_docker.ts +18 -29
- package/support/cli.pack_zip.ts +5 -6
- package/support/pack.base.ts +4 -6
package/README.md
CHANGED
|
@@ -97,7 +97,7 @@ Usage: pack:zip [options] [args...:string]
|
|
|
97
97
|
Options:
|
|
98
98
|
-b, --buildDir <string> Workspace for building (default: "/tmp/<temp-folder>")
|
|
99
99
|
--clean, --no-clean Clean workspace (default: true)
|
|
100
|
-
-o, --output <string> Output location (default: "
|
|
100
|
+
-o, --output <string> Output location (default: "<module>.zip")
|
|
101
101
|
--main-scripts, --no-main-scripts Create entry scripts (default: true)
|
|
102
102
|
-f, --main-name <string> Main name for build artifact
|
|
103
103
|
-e, --entry-point <string> Entry point (default: "@travetto/cli/support/entry.trv.ts")
|
|
@@ -139,9 +139,10 @@ Options:
|
|
|
139
139
|
--manifest-file <string> Manifest File Name (default: "manifest.json")
|
|
140
140
|
-wr, --include-workspace-resources Include workspace resources (default: false)
|
|
141
141
|
-np, --npm-package <string> External NPM Packages (default: [])
|
|
142
|
+
-m, --module <module> Module to run for
|
|
142
143
|
-df, --docker-factory <string> Docker Factory source (default: "@travetto/pack/support/pack.dockerfile.ts")
|
|
143
144
|
-di, --docker-image <string> Docker Image to extend (default: "node:25-alpine")
|
|
144
|
-
-dn, --docker-name <string> Docker Image Name (default: "
|
|
145
|
+
-dn, --docker-name <string> Docker Image Name (default: "<module>")
|
|
145
146
|
-ru, --runtime-user <string> Docker Runtime user
|
|
146
147
|
-rp, --runtime-package <string> Docker Runtime Packages (default: [])
|
|
147
148
|
-dp, --docker-port <number> Docker Image Port (default: [])
|
|
@@ -150,7 +151,6 @@ Options:
|
|
|
150
151
|
-dx, --docker-push Docker Push Tags (default: false)
|
|
151
152
|
-db, --docker-build-platform <string> Docker Build Platform
|
|
152
153
|
-dr, --docker-registry <string> Docker Registry
|
|
153
|
-
-m, --module <module> Module to run for
|
|
154
154
|
-h, --help display help for command
|
|
155
155
|
```
|
|
156
156
|
|
|
@@ -273,6 +273,6 @@ echo "ENTRYPOINT [\"/app/todo-app.sh\"]" >> $DIST/Dockerfile
|
|
|
273
273
|
echo "Building Docker Container latest"
|
|
274
274
|
|
|
275
275
|
cd $DIST
|
|
276
|
-
docker build -t
|
|
276
|
+
docker build -t <module>:latest .
|
|
277
277
|
cd $ROOT
|
|
278
278
|
```
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@travetto/pack",
|
|
3
|
-
"version": "8.0.0-alpha.
|
|
3
|
+
"version": "8.0.0-alpha.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Code packing utilities",
|
|
6
6
|
"keywords": [
|
|
@@ -26,16 +26,16 @@
|
|
|
26
26
|
"directory": "module/pack"
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@rollup/plugin-commonjs": "^29.0.
|
|
29
|
+
"@rollup/plugin-commonjs": "^29.0.2",
|
|
30
30
|
"@rollup/plugin-json": "^6.1.0",
|
|
31
31
|
"@rollup/plugin-node-resolve": "^16.0.3",
|
|
32
32
|
"@rollup/plugin-terser": "^0.4.4",
|
|
33
|
-
"@travetto/runtime": "^8.0.0-alpha.
|
|
34
|
-
"@travetto/terminal": "^8.0.0-alpha.
|
|
33
|
+
"@travetto/runtime": "^8.0.0-alpha.1",
|
|
34
|
+
"@travetto/terminal": "^8.0.0-alpha.1",
|
|
35
35
|
"rollup": "^4.59.0"
|
|
36
36
|
},
|
|
37
37
|
"peerDependencies": {
|
|
38
|
-
"@travetto/cli": "^8.0.0-alpha.
|
|
38
|
+
"@travetto/cli": "^8.0.0-alpha.2"
|
|
39
39
|
},
|
|
40
40
|
"peerDependenciesMeta": {
|
|
41
41
|
"@travetto/cli": {
|
package/support/cli.pack.ts
CHANGED
|
@@ -1,19 +1,21 @@
|
|
|
1
1
|
import path from 'node:path';
|
|
2
2
|
|
|
3
3
|
import { RuntimeIndex } from '@travetto/runtime';
|
|
4
|
-
import { CliCommand, CliFlag, CliUtil
|
|
5
|
-
import { Ignore, Required } from '@travetto/schema';
|
|
4
|
+
import { CliCommand, CliFlag, CliUtil } from '@travetto/cli';
|
|
5
|
+
import { Ignore, Max, Min, Required } from '@travetto/schema';
|
|
6
6
|
|
|
7
7
|
import { DockerPackOperation } from './bin/docker-operation.ts';
|
|
8
8
|
import { BasePackCommand, type PackOperationShape } from './pack.base';
|
|
9
9
|
import type { DockerPackConfig } from '../src/types.ts';
|
|
10
10
|
|
|
11
11
|
const NODE_MAJOR = process.version.match(/\d+/)?.[0] ?? '22';
|
|
12
|
+
const asNumber = (input?: string): number | undefined => (!input || isNaN(+input)) ? undefined : +input;
|
|
13
|
+
const asString = (input?: string): string | undefined => (input && asNumber(input)) ? input : undefined;
|
|
12
14
|
|
|
13
15
|
/**
|
|
14
16
|
* Standard docker support for pack
|
|
15
17
|
*/
|
|
16
|
-
@CliCommand(
|
|
18
|
+
@CliCommand()
|
|
17
19
|
export class PackDockerCommand extends BasePackCommand {
|
|
18
20
|
/** Docker Factory source */
|
|
19
21
|
@CliFlag({ short: 'df', envVars: ['PACK_DOCKER_FACTORY'] })
|
|
@@ -33,6 +35,7 @@ export class PackDockerCommand extends BasePackCommand {
|
|
|
33
35
|
dockerRuntimePackages: string[] = [];
|
|
34
36
|
/** Docker Image Port */
|
|
35
37
|
@CliFlag({ short: 'dp', envVars: ['PACK_DOCKER_PORT'] })
|
|
38
|
+
@Min(1) @Max(65536)
|
|
36
39
|
dockerPort: number[] = [];
|
|
37
40
|
|
|
38
41
|
// Publish flags
|
|
@@ -64,36 +67,26 @@ export class PackDockerCommand extends BasePackCommand {
|
|
|
64
67
|
@Ignore()
|
|
65
68
|
defaultUserId = 2000;
|
|
66
69
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
for (let i = 0; i < this.dockerPort.length; i++) {
|
|
71
|
-
if (this.dockerPort[i] < 1) {
|
|
72
|
-
errs.push({ source: 'flag', message: `dockerPort[${i}] is less than (1)` });
|
|
73
|
-
} else if (this.dockerPort[i] > 65536) {
|
|
74
|
-
errs.push({ source: 'flag', message: `dockerPort[${i}] is greater than (65536)` });
|
|
75
|
-
}
|
|
76
|
-
}
|
|
70
|
+
finalize(forHelp?: boolean): void {
|
|
71
|
+
if (forHelp) {
|
|
72
|
+
this.dockerName = '<module>';
|
|
77
73
|
}
|
|
78
|
-
return errs;
|
|
79
|
-
}
|
|
80
74
|
|
|
81
|
-
preMain(): void {
|
|
82
75
|
if (this.dockerFactory.startsWith('.')) {
|
|
83
76
|
this.dockerFactory = RuntimeIndex.getFromSource(path.resolve(this.dockerFactory))?.import ?? this.dockerFactory;
|
|
84
77
|
}
|
|
85
|
-
this.dockerName ??= CliUtil.getSimpleModuleName('<module>', this.module
|
|
78
|
+
this.dockerName ??= CliUtil.getSimpleModuleName('<module>', this.module);
|
|
86
79
|
|
|
87
80
|
// Finalize user/group and ids
|
|
88
81
|
const [userOrUserId, groupOrGroupId = userOrUserId] = (this.dockerRuntimeUser ?? '').split(':');
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
82
|
+
this.dockerRuntime = {
|
|
83
|
+
user: asString(userOrUserId) ?? this.defaultUser,
|
|
84
|
+
userId: asNumber(userOrUserId) ?? this.defaultUserId,
|
|
85
|
+
group: asString(groupOrGroupId) ?? this.defaultUser,
|
|
86
|
+
groupId: asNumber(groupOrGroupId) ?? this.defaultUserId,
|
|
87
|
+
folder: `/${this.appFolder}`,
|
|
88
|
+
packages: this.dockerRuntimePackages
|
|
89
|
+
};
|
|
97
90
|
|
|
98
91
|
if (this.dockerStageOnly) {
|
|
99
92
|
if (this.dockerRegistry) {
|
|
@@ -111,10 +104,6 @@ export class PackDockerCommand extends BasePackCommand {
|
|
|
111
104
|
}
|
|
112
105
|
}
|
|
113
106
|
|
|
114
|
-
preHelp(): void {
|
|
115
|
-
this.dockerName = CliUtil.getSimpleModuleName('<module>');
|
|
116
|
-
}
|
|
117
|
-
|
|
118
107
|
getOperations(): PackOperationShape<this>[] {
|
|
119
108
|
return [
|
|
120
109
|
...super.getOperations(),
|
package/support/cli.pack_zip.ts
CHANGED
|
@@ -6,17 +6,16 @@ import { BasePackCommand, type PackOperationShape } from './pack.base';
|
|
|
6
6
|
/**
|
|
7
7
|
* Standard zip support for pack
|
|
8
8
|
*/
|
|
9
|
-
@CliCommand(
|
|
9
|
+
@CliCommand()
|
|
10
10
|
export class PackZipCommand extends BasePackCommand {
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
finalize(forHelp?: boolean): void {
|
|
13
|
+
if (forHelp) {
|
|
14
|
+
this.output = '<module>.zip';
|
|
15
|
+
}
|
|
13
16
|
this.output ??= CliUtil.getSimpleModuleName('<module>.zip', this.module);
|
|
14
17
|
}
|
|
15
18
|
|
|
16
|
-
preHelp(): void {
|
|
17
|
-
this.output = CliUtil.getSimpleModuleName('<module>.zip');
|
|
18
|
-
}
|
|
19
|
-
|
|
20
19
|
getOperations(): PackOperationShape<this>[] {
|
|
21
20
|
return [
|
|
22
21
|
...super.getOperations(),
|
package/support/pack.base.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import os from 'node:os';
|
|
2
2
|
import path from 'node:path';
|
|
3
3
|
|
|
4
|
-
import { type CliCommandShape, CliFlag,
|
|
4
|
+
import { type CliCommandShape, CliFlag, CliModuleFlag, CliParseUtil, cliTpl } from '@travetto/cli';
|
|
5
5
|
import { TimeUtil, Runtime, RuntimeIndex } from '@travetto/runtime';
|
|
6
6
|
import { Terminal } from '@travetto/terminal';
|
|
7
7
|
import { Ignore, Method, Required, Schema } from '@travetto/schema';
|
|
@@ -24,9 +24,6 @@ export abstract class BasePackCommand implements CliCommandShape {
|
|
|
24
24
|
.map(file => file.import.replace(/[.][^.]+s$/, ''));
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
-
@Ignore()
|
|
28
|
-
_parsed: ParsedState;
|
|
29
|
-
|
|
30
27
|
/** Workspace for building */
|
|
31
28
|
@CliFlag({ short: 'b', full: 'buildDir' })
|
|
32
29
|
buildDirectory: string = path.resolve(os.tmpdir(), Runtime.mainSourcePath.replace(/[\/\\: ]/g, '_'));
|
|
@@ -86,7 +83,7 @@ export abstract class BasePackCommand implements CliCommandShape {
|
|
|
86
83
|
@CliFlag({ short: 'np', full: 'npm-package', envVars: ['PACK_EXTERNAL_PACKAGES'] })
|
|
87
84
|
externalDependencies: string[] = [];
|
|
88
85
|
|
|
89
|
-
@
|
|
86
|
+
@CliModuleFlag({ short: 'm' })
|
|
90
87
|
module: string;
|
|
91
88
|
|
|
92
89
|
@Ignore()
|
|
@@ -144,7 +141,8 @@ export abstract class BasePackCommand implements CliCommandShape {
|
|
|
144
141
|
this.buildDirectory = path.resolve(this.buildDirectory);
|
|
145
142
|
|
|
146
143
|
// Update entry points
|
|
147
|
-
|
|
144
|
+
const parsed = CliParseUtil.getState(this);
|
|
145
|
+
this.entryArguments = [...this.entryArguments ?? [], ...args, ...parsed?.unknown ?? []];
|
|
148
146
|
this.module ||= Runtime.main.name;
|
|
149
147
|
this.mainName ??= path.basename(this.module);
|
|
150
148
|
this.mainFile = `${this.mainName}.js`;
|