@travetto/pack 8.0.0-alpha.0 → 8.0.0-alpha.1
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 +1 -1
- package/package.json +5 -5
- package/support/cli.pack.ts +1 -1
- package/support/cli.pack_docker.ts +11 -23
- package/support/cli.pack_zip.ts +7 -7
- package/support/pack.base.ts +4 -6
package/README.md
CHANGED
|
@@ -139,6 +139,7 @@ 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
145
|
-dn, --docker-name <string> Docker Image Name (default: "travetto_pack")
|
|
@@ -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
|
|
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.1",
|
|
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.1"
|
|
39
39
|
},
|
|
40
40
|
"peerDependenciesMeta": {
|
|
41
41
|
"@travetto/cli": {
|
package/support/cli.pack.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
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';
|
|
@@ -13,7 +13,7 @@ const NODE_MAJOR = process.version.match(/\d+/)?.[0] ?? '22';
|
|
|
13
13
|
/**
|
|
14
14
|
* Standard docker support for pack
|
|
15
15
|
*/
|
|
16
|
-
@CliCommand(
|
|
16
|
+
@CliCommand()
|
|
17
17
|
export class PackDockerCommand extends BasePackCommand {
|
|
18
18
|
/** Docker Factory source */
|
|
19
19
|
@CliFlag({ short: 'df', envVars: ['PACK_DOCKER_FACTORY'] })
|
|
@@ -33,6 +33,7 @@ export class PackDockerCommand extends BasePackCommand {
|
|
|
33
33
|
dockerRuntimePackages: string[] = [];
|
|
34
34
|
/** Docker Image Port */
|
|
35
35
|
@CliFlag({ short: 'dp', envVars: ['PACK_DOCKER_PORT'] })
|
|
36
|
+
@Min(1) @Max(65536)
|
|
36
37
|
dockerPort: number[] = [];
|
|
37
38
|
|
|
38
39
|
// Publish flags
|
|
@@ -64,25 +65,16 @@ export class PackDockerCommand extends BasePackCommand {
|
|
|
64
65
|
@Ignore()
|
|
65
66
|
defaultUserId = 2000;
|
|
66
67
|
|
|
67
|
-
|
|
68
|
-
const errs: CliValidationError[] = [];
|
|
69
|
-
if (this.dockerPort?.length) {
|
|
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
|
-
}
|
|
77
|
-
}
|
|
78
|
-
return errs;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
preMain(): void {
|
|
68
|
+
finalize(forHelp?: boolean): void {
|
|
82
69
|
if (this.dockerFactory.startsWith('.')) {
|
|
83
70
|
this.dockerFactory = RuntimeIndex.getFromSource(path.resolve(this.dockerFactory))?.import ?? this.dockerFactory;
|
|
84
71
|
}
|
|
85
|
-
|
|
72
|
+
|
|
73
|
+
if (forHelp) {
|
|
74
|
+
this.dockerName = CliUtil.getSimpleModuleName('<module>');
|
|
75
|
+
} else {
|
|
76
|
+
this.dockerName ??= CliUtil.getSimpleModuleName('<module>', this.module || undefined);
|
|
77
|
+
}
|
|
86
78
|
|
|
87
79
|
// Finalize user/group and ids
|
|
88
80
|
const [userOrUserId, groupOrGroupId = userOrUserId] = (this.dockerRuntimeUser ?? '').split(':');
|
|
@@ -111,10 +103,6 @@ export class PackDockerCommand extends BasePackCommand {
|
|
|
111
103
|
}
|
|
112
104
|
}
|
|
113
105
|
|
|
114
|
-
preHelp(): void {
|
|
115
|
-
this.dockerName = CliUtil.getSimpleModuleName('<module>');
|
|
116
|
-
}
|
|
117
|
-
|
|
118
106
|
getOperations(): PackOperationShape<this>[] {
|
|
119
107
|
return [
|
|
120
108
|
...super.getOperations(),
|
package/support/cli.pack_zip.ts
CHANGED
|
@@ -6,15 +6,15 @@ 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
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
12
|
+
finalize(forHelp?: boolean): void {
|
|
13
|
+
if (forHelp) {
|
|
14
|
+
this.output = CliUtil.getSimpleModuleName('<module>.zip');
|
|
15
|
+
} else {
|
|
16
|
+
this.output ??= CliUtil.getSimpleModuleName('<module>.zip', this.module);
|
|
17
|
+
}
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
getOperations(): PackOperationShape<this>[] {
|
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`;
|