@travetto/pack 8.0.0-alpha.2 → 8.0.0-alpha.21

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 CHANGED
@@ -22,12 +22,18 @@ There are three primary cli commands for packing your code:
22
22
 
23
23
  ## CLI - pack
24
24
 
25
- **Terminal: Pack usage**
25
+ **Terminal: Help for pack**
26
26
  ```bash
27
27
  $ trv pack --help
28
28
 
29
29
  Usage: pack [options] [args...:string]
30
30
 
31
+ Description:
32
+ Build a standard module package artifact.
33
+
34
+ This base command produces the default packaged output and serves as the
35
+ common entry point for module packaging workflows.
36
+
31
37
  Options:
32
38
  -b, --buildDir <string> Workspace for building (default: "/tmp/<temp-folder>")
33
39
  --clean, --no-clean Clean workspace (default: true)
@@ -45,7 +51,9 @@ Options:
45
51
  -wr, --include-workspace-resources Include workspace resources (default: false)
46
52
  -np, --npm-package <string> External NPM Packages (default: [])
47
53
  -m, --module <module> Module to run for
48
- -h, --help display help for command
54
+ --help display help for command
55
+
56
+ Examples:
49
57
  ```
50
58
 
51
59
  This command line operation will compile your project, and produce a ready to use workspace as a deliverable. Additionally, you can pass in a file to the `eject-file` flag that will allow for a script to be produced (base on the host operating system).
@@ -88,12 +96,18 @@ Every [Pack](https://github.com/travetto/travetto/tree/main/module/pack#readme "
88
96
  ## CLI - pack:zip
89
97
  This command is nearly identical to the standard `pack` operation, except for the `output` flag. In this scenario, the `output` flag determines the location and name of the final zip file.
90
98
 
91
- **Terminal: Pack:zip usage**
99
+ **Terminal: Help for pack:zip**
92
100
  ```bash
93
101
  $ trv pack:zip --help
94
102
 
95
103
  Usage: pack:zip [options] [args...:string]
96
104
 
105
+ Description:
106
+ Build a deployable zip artifact using the standard pack pipeline.
107
+
108
+ This command runs base packing operations and then compresses the generated
109
+ output into a single archive file.
110
+
97
111
  Options:
98
112
  -b, --buildDir <string> Workspace for building (default: "/tmp/<temp-folder>")
99
113
  --clean, --no-clean Clean workspace (default: true)
@@ -111,18 +125,26 @@ Options:
111
125
  -wr, --include-workspace-resources Include workspace resources (default: false)
112
126
  -np, --npm-package <string> External NPM Packages (default: [])
113
127
  -m, --module <module> Module to run for
114
- -h, --help display help for command
128
+ --help display help for command
129
+
130
+ Examples:
115
131
  ```
116
132
 
117
133
  ## CLI - pack:docker
118
134
  This command starts off identical to the standard `pack` operation, but it contains a few additional flags, and ultimately a few additional operations to support creating of the final [docker](https://www.docker.com/community-edition) image.
119
135
 
120
- **Terminal: Pack:docker usage**
136
+ **Terminal: Help for pack:docker**
121
137
  ```bash
122
138
  $ trv pack:docker --help
123
139
 
124
140
  Usage: pack:docker [options] [args...:string]
125
141
 
142
+ Description:
143
+ Build container-ready artifacts and optionally publish Docker images.
144
+
145
+ Extends the core pack pipeline with Dockerfile generation and image build/
146
+ push operations, including runtime user and registry customization.
147
+
126
148
  Options:
127
149
  -b, --buildDir <string> Workspace for building (default: "/tmp/<temp-folder>")
128
150
  --clean, --no-clean Clean workspace (default: true)
@@ -141,7 +163,7 @@ Options:
141
163
  -np, --npm-package <string> External NPM Packages (default: [])
142
164
  -m, --module <module> Module to run for
143
165
  -df, --docker-factory <string> Docker Factory source (default: "@travetto/pack/support/pack.dockerfile.ts")
144
- -di, --docker-image <string> Docker Image to extend (default: "node:25-alpine")
166
+ -di, --docker-image <string> Docker Image to extend (default: "node:26-alpine")
145
167
  -dn, --docker-name <string> Docker Image Name (default: "<module>")
146
168
  -ru, --runtime-user <string> Docker Runtime user
147
169
  -rp, --runtime-package <string> Docker Runtime Packages (default: [])
@@ -151,7 +173,9 @@ Options:
151
173
  -dx, --docker-push Docker Push Tags (default: false)
152
174
  -db, --docker-build-platform <string> Docker Build Platform
153
175
  -dr, --docker-registry <string> Docker Registry
154
- -h, --help display help for command
176
+ --help display help for command
177
+
178
+ Examples:
155
179
  ```
156
180
 
157
181
  The additional flags provided are allow for specifying the base image, the final docker image name (and tags), and which registry to push to (if any). Additionally, there are flags for exposing which ports the image should expect to open as well. When using the `--eject-file` flag, the output script will produce the entire Dockerfile output inline, so that it can be easily modified as needed.
@@ -244,21 +268,21 @@ cd $TRV_OUT
244
268
  node $REPO_ROOT/node_modules/.bin/rollup -c $TRV_OUT/node_modules/@travetto/pack/support/rollup/build.js
245
269
  cd $ROOT
246
270
 
247
- # Pulling Docker Base Image node:25-alpine
271
+ # Pulling Docker Base Image node:26-alpine
248
272
 
249
- echo "Pulling Docker Base Image node:25-alpine"
273
+ echo "Pulling Docker Base Image node:26-alpine"
250
274
 
251
- docker pull node:25-alpine
275
+ docker pull node:26-alpine
252
276
 
253
- # Detected Image OS node:25-alpine as alpine
277
+ # Detected Image OS node:26-alpine as alpine
254
278
 
255
- echo "Detected Image OS node:25-alpine as alpine"
279
+ echo "Detected Image OS node:26-alpine as alpine"
256
280
 
257
281
  # Generating Docker File $DIST/Dockerfile @travetto/pack/support/pack.dockerfile.ts
258
282
 
259
283
  echo "Generating Docker File $DIST/Dockerfile @travetto/pack/support/pack.dockerfile.ts"
260
284
 
261
- echo "FROM node:25-alpine" > $DIST/Dockerfile
285
+ echo "FROM node:26-alpine" > $DIST/Dockerfile
262
286
  echo "RUN addgroup -g 2000 app && adduser -D -G app -u 2000 app" >> $DIST/Dockerfile
263
287
  echo "RUN mkdir /app && chown app:app /app" >> $DIST/Dockerfile
264
288
  echo "COPY --chown=\"app:app\" . /app" >> $DIST/Dockerfile
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@travetto/pack",
3
- "version": "8.0.0-alpha.2",
3
+ "version": "8.0.0-alpha.21",
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.2",
29
+ "@rollup/plugin-commonjs": "^29.0.3",
30
30
  "@rollup/plugin-json": "^6.1.0",
31
31
  "@rollup/plugin-node-resolve": "^16.0.3",
32
- "@rollup/plugin-terser": "^0.4.4",
33
- "@travetto/runtime": "^8.0.0-alpha.1",
34
- "@travetto/terminal": "^8.0.0-alpha.1",
35
- "rollup": "^4.59.0"
32
+ "@rollup/plugin-terser": "^1.0.0",
33
+ "@travetto/runtime": "^8.0.0-alpha.18",
34
+ "@travetto/terminal": "^8.0.0-alpha.18",
35
+ "rollup": "^4.61.1"
36
36
  },
37
37
  "peerDependencies": {
38
- "@travetto/cli": "^8.0.0-alpha.2"
38
+ "@travetto/cli": "^8.0.0-alpha.25"
39
39
  },
40
40
  "peerDependenciesMeta": {
41
41
  "@travetto/cli": {
@@ -1,9 +1,12 @@
1
1
  import { CliCommand } from '@travetto/cli';
2
2
 
3
- import { BasePackCommand } from './pack.base';
3
+ import { BasePackCommand } from './pack.base.ts';
4
4
 
5
5
  /**
6
- * Standard pack support
6
+ * Build a standard module package artifact.
7
+ *
8
+ * This base command produces the default packaged output and serves as the
9
+ * common entry point for module packaging workflows.
7
10
  */
8
11
  @CliCommand()
9
12
  export class PackCommand extends BasePackCommand { }
@@ -5,7 +5,7 @@ import { CliCommand, CliFlag, CliUtil } from '@travetto/cli';
5
5
  import { Ignore, Max, Min, Required } from '@travetto/schema';
6
6
 
7
7
  import { DockerPackOperation } from './bin/docker-operation.ts';
8
- import { BasePackCommand, type PackOperationShape } from './pack.base';
8
+ import { BasePackCommand, type PackOperationShape } from './pack.base.ts';
9
9
  import type { DockerPackConfig } from '../src/types.ts';
10
10
 
11
11
  const NODE_MAJOR = process.version.match(/\d+/)?.[0] ?? '22';
@@ -13,7 +13,10 @@ const asNumber = (input?: string): number | undefined => (!input || isNaN(+input
13
13
  const asString = (input?: string): string | undefined => (input && asNumber(input)) ? input : undefined;
14
14
 
15
15
  /**
16
- * Standard docker support for pack
16
+ * Build container-ready artifacts and optionally publish Docker images.
17
+ *
18
+ * Extends the core pack pipeline with Dockerfile generation and image build/
19
+ * push operations, including runtime user and registry customization.
17
20
  */
18
21
  @CliCommand()
19
22
  export class PackDockerCommand extends BasePackCommand {
@@ -24,7 +27,7 @@ export class PackDockerCommand extends BasePackCommand {
24
27
  @CliFlag({ short: 'di', envVars: ['PACK_DOCKER_IMAGE'] })
25
28
  dockerImage = `node:${NODE_MAJOR}-alpine`;
26
29
  /** Docker Image Name */
27
- @CliFlag({ short: 'dn', envVars: ['PACK_DOCKER_IMAGE'] })
30
+ @CliFlag({ short: 'dn', envVars: ['PACK_DOCKER_NAME'] })
28
31
  @Required(false)
29
32
  dockerName: string;
30
33
  /** Docker Runtime user */
@@ -1,10 +1,13 @@
1
1
  import { CliCommand, CliUtil } from '@travetto/cli';
2
2
 
3
3
  import { PackOperation } from './bin/operation.ts';
4
- import { BasePackCommand, type PackOperationShape } from './pack.base';
4
+ import { BasePackCommand, type PackOperationShape } from './pack.base.ts';
5
5
 
6
6
  /**
7
- * Standard zip support for pack
7
+ * Build a deployable zip artifact using the standard pack pipeline.
8
+ *
9
+ * This command runs base packing operations and then compresses the generated
10
+ * output into a single archive file.
8
11
  */
9
12
  @CliCommand()
10
13
  export class PackZipCommand extends BasePackCommand {
@@ -5,7 +5,7 @@ import { type CliCommandShape, CliFlag, CliModuleFlag, CliParseUtil, cliTpl } fr
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';
8
- import { PackageUtil } from '@travetto/manifest';
8
+ import { PackageUtil, type IndexedModule } from '@travetto/manifest';
9
9
 
10
10
  import { PackOperation } from './bin/operation.ts';
11
11
  import { PackUtil } from './bin/util.ts';
@@ -114,22 +114,21 @@ export abstract class BasePackCommand implements CliCommandShape {
114
114
  */
115
115
  async * runOperations(): AsyncIterable<string> {
116
116
  for (const operation of this.getOperations()) {
117
- for await (const msg of operation(this)) {
118
- yield msg.join(' ');
117
+ for await (const message of operation(this)) {
118
+ yield message.join(' ');
119
119
  }
120
120
  }
121
121
  }
122
122
 
123
123
  /**
124
- * Get all binary dependencies
124
+ * Get all external dependencies
125
125
  */
126
- getBinaryDependencies(): string[] {
126
+ getModuleExternalDependencies(): string[] {
127
127
  return [...RuntimeIndex.getModuleList('all')]
128
128
  .map(name => RuntimeIndex.getModule(name))
129
- .filter(module => !!module)
130
- .filter(module => module.production)
129
+ .filter((module): module is IndexedModule => !!module?.production)
131
130
  .map(module => PackageUtil.readPackage(module?.sourcePath))
132
- .map(pkg => pkg?.travetto?.build?.binaryDependencies ?? [])
131
+ .map(pkg => pkg?.travetto?.build?.externalDependencies ?? [])
133
132
  .flat();
134
133
  }
135
134
 
@@ -147,8 +146,8 @@ export abstract class BasePackCommand implements CliCommandShape {
147
146
  this.mainName ??= path.basename(this.module);
148
147
  this.mainFile = `${this.mainName}.js`;
149
148
 
150
- // Collect binary dependencies
151
- const dependencies = this.getBinaryDependencies();
149
+ // Collect unmanaged dependencies
150
+ const dependencies = this.getModuleExternalDependencies();
152
151
  this.externalDependencies = [...this.externalDependencies, ...dependencies];
153
152
 
154
153
  const stream = this.runOperations();
@@ -162,11 +161,11 @@ export abstract class BasePackCommand implements CliCommandShape {
162
161
 
163
162
  await term.streamLines(stream);
164
163
 
165
- let msg = cliTpl`${{ success: 'Success' }} (${{ identifier: TimeUtil.asClock(Date.now() - start) }}) ${{ subtitle: 'module' }}=${{ param: this.module }}`;
164
+ let message = cliTpl`${{ success: 'Success' }} (${{ identifier: TimeUtil.asClock(Date.now() - start) }}) ${{ subtitle: 'module' }}=${{ param: this.module }}`;
166
165
  if (this.output) {
167
- msg = cliTpl`${msg} ${{ subtitle: 'output' }}=${{ path: this.output }}`;
166
+ message = cliTpl`${message} ${{ subtitle: 'output' }}=${{ path: this.output }}`;
168
167
  }
169
- await term.writer.writeLine(msg).commit();
168
+ await term.writer.writeLine(message).commit();
170
169
  }
171
170
  }
172
171
  }
@@ -1,4 +1,5 @@
1
1
  import type { AstNode, Plugin } from 'rollup';
2
+ // @ts-expect-error - This module lacks types
2
3
  import { walk } from 'estree-walker';
3
4
  import magicString from 'magic-string';
4
5
 
@@ -33,16 +34,14 @@ export function travettoImportPlugin(config: CoreRollupConfig): Plugin {
33
34
  let ms: magicString | undefined;
34
35
 
35
36
  walk(parsed, {
36
- enter: (node) => {
37
- // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
38
- const impNode = node as TNode;
39
- if (impNode.type === 'ImportExpression' && impNode.source?.type !== 'Literal') {
40
- if (!/["']/.test(code.substring(impNode.start, impNode.end))) {
41
- (ms ??= new magicString(code)).overwrite(impNode.start, impNode.start + 6, GLOBAL_IMPORT);
37
+ enter: (node: TNode) => {
38
+ if (node.type === 'ImportExpression' && node.source?.type !== 'Literal') {
39
+ if (!/["']/.test(code.substring(node.start, node.end))) {
40
+ (ms ??= new magicString(code)).overwrite(node.start, node.start + 6, GLOBAL_IMPORT);
42
41
  }
43
- } else if (impNode.type === 'CallExpression' && impNode.callee?.type === 'Identifier' && impNode.callee.name === 'require') {
44
- if (!/["']/.test(code.substring(impNode.start, impNode.end))) {
45
- (ms ??= new magicString(code)).overwrite(impNode.start, impNode.start + 7, GLOBAL_IMPORT);
42
+ } else if (node.type === 'CallExpression' && node.callee?.type === 'Identifier' && node.callee.name === 'require') {
43
+ if (!/["']/.test(code.substring(node.start, node.end))) {
44
+ (ms ??= new magicString(code)).overwrite(node.start, node.start + 7, GLOBAL_IMPORT);
46
45
  }
47
46
  }
48
47
  }
@@ -18,7 +18,7 @@ export function travettoSourcemaps(config: CoreRollupConfig): Plugin {
18
18
  return {
19
19
  name: 'travetto-source-maps',
20
20
  async load(this: PluginContext, id: string): Promise<LoadResult> {
21
- if (!id.endsWith('.js')) {
21
+ if (!id.endsWith('.js') || id.endsWith('@travetto/runtime/support/patch.js')) {
22
22
  return null;
23
23
  }
24
24
  try {
@@ -30,8 +30,11 @@ export function travettoSourcemaps(config: CoreRollupConfig): Plugin {
30
30
  return null;
31
31
  }
32
32
  const loader = new FileLoader([path.dirname(id)]);
33
- const map = await loader.readText(mapPath)
34
- .then(JSONUtil.fromBase64<SourceMapInput>);
33
+ const map = await loader.readUTF8(mapPath)
34
+ .then(value => value.startsWith('{') ?
35
+ JSONUtil.fromUTF8<SourceMapInput>(value) :
36
+ JSONUtil.fromBase64<SourceMapInput>(value)
37
+ );
35
38
  return { code, map };
36
39
  }
37
40
  return { code, map: null };