@travetto/pack 3.0.2 → 3.0.3
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 +11 -16
- package/package.json +3 -3
- package/support/bin/config.ts +2 -2
package/README.md
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
<!-- This file was generated by @travetto/doc and should not be modified directly -->
|
|
2
|
-
<!-- Please modify https://github.com/travetto/travetto/tree/main/module/pack/DOC.
|
|
2
|
+
<!-- Please modify https://github.com/travetto/travetto/tree/main/module/pack/DOC.tsx and execute "npx trv doc" to rebuild -->
|
|
3
3
|
# Pack
|
|
4
|
+
|
|
4
5
|
## Code packing utilities
|
|
5
6
|
|
|
6
7
|
**Install: @travetto/pack**
|
|
@@ -12,15 +13,14 @@ npm install @travetto/pack
|
|
|
12
13
|
yarn add @travetto/pack
|
|
13
14
|
```
|
|
14
15
|
|
|
15
|
-
This module provides the necessary tools to produce deliverable output for [Travetto](https://travetto.dev) based projects. The main interaction with this module is through the command line interface, and the operations it provides. Under the covers, the code bundling is performed by [Rollup](https://rollupjs.org/), with specific configuration to support the frameworks runtime expectations.
|
|
16
|
+
This module provides the necessary tools to produce deliverable output for [Travetto](https://travetto.dev) based projects. The main interaction with this module is through the command line interface, and the operations it provides. Under the covers, the code bundling is performed by [Rollup](https://rollupjs.org/), with specific configuration to support the frameworks runtime expectations.
|
|
16
17
|
|
|
17
18
|
There are three primary cli commands for packing your code:
|
|
18
|
-
|
|
19
19
|
* pack
|
|
20
20
|
* pack:zip
|
|
21
21
|
* pack:docker
|
|
22
22
|
|
|
23
|
-
## CLI - pack
|
|
23
|
+
## CLI - pack
|
|
24
24
|
|
|
25
25
|
**Terminal: Pack usage**
|
|
26
26
|
```bash
|
|
@@ -42,14 +42,14 @@ Options:
|
|
|
42
42
|
-h, --help display help for command
|
|
43
43
|
```
|
|
44
44
|
|
|
45
|
-
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).
|
|
45
|
+
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).
|
|
46
46
|
|
|
47
|
-
Specific to this CLI command, the `output` field determines where the final folder is written that contains all the compiled source.
|
|
47
|
+
Specific to this CLI command, the `output` field determines where the final folder is written that contains all the compiled source.
|
|
48
48
|
|
|
49
49
|
### Entry Point Configuration
|
|
50
|
-
Every application requires an entry point to determine execution flow (and in [Rollup](https://rollupjs.org/)'s case, tree-shaking as well.). By default the [Command Line Interface](https://github.com/travetto/travetto/tree/main/module/cli#readme "CLI infrastructure for Travetto framework") acts as the entry point. This bypasses the [Compiler](https://github.com/travetto/travetto/tree/main/module/compiler#readme "The compiler infrastructure for the Travetto framework") intentionally, as the compiler is not available at runtime.
|
|
50
|
+
Every application requires an entry point to determine execution flow (and in [Rollup](https://rollupjs.org/)'s case, tree-shaking as well.). By default the [Command Line Interface](https://github.com/travetto/travetto/tree/main/module/cli#readme "CLI infrastructure for Travetto framework") acts as the entry point. This bypasses the [Compiler](https://github.com/travetto/travetto/tree/main/module/compiler#readme "The compiler infrastructure for the Travetto framework") intentionally, as the compiler is not available at runtime.
|
|
51
51
|
|
|
52
|
-
Within the command line, the `args` are positional arguments that will be passed to the entry point on application run.
|
|
52
|
+
Within the command line, the `args` are positional arguments that will be passed to the entry point on application run.
|
|
53
53
|
|
|
54
54
|
**Code: Packing an application run**
|
|
55
55
|
```typescript
|
|
@@ -60,6 +60,7 @@ Would then produce an executable script, in the output folder, that would look l
|
|
|
60
60
|
|
|
61
61
|
**Code: Entry script for Packed application**
|
|
62
62
|
```typescript
|
|
63
|
+
|
|
63
64
|
#!/bin/sh
|
|
64
65
|
cd $(dirname "$0")
|
|
65
66
|
node cli run myapp
|
|
@@ -69,8 +70,6 @@ And this entry point would be what is executed by [docker](https://www.docker.co
|
|
|
69
70
|
|
|
70
71
|
### General Packing Operations
|
|
71
72
|
Every [Pack](https://github.com/travetto/travetto/tree/main/module/pack#readme "Code packing utilities") operation extends from the base command, and that provides some consistent operations that run on every packing command.
|
|
72
|
-
|
|
73
|
-
|
|
74
73
|
* `clean` - Empties workspace before beginning, controlled by the `--clean` flag, defaults to on
|
|
75
74
|
* `writeEnv` - Writes the .env.js files that includes the necessary details to start the application. This is primarily to identify the location of the manifest file needed to run.
|
|
76
75
|
* `writePackageJson` - Generates the [Package JSON](https://docs.npmjs.com/cli/v9/configuring-npm/package-json) with the appropriate module type ([CommonJS](https://nodejs.org/api/modules.html) or [Ecmascript Module](https://nodejs.org/api/esm.html)) for interpreting plain `.js` files
|
|
@@ -81,8 +80,7 @@ Every [Pack](https://github.com/travetto/travetto/tree/main/module/pack#readme "
|
|
|
81
80
|
* `bundle` - Invokes [Rollup](https://rollupjs.org/) with the appropriate file set to produce a single output .js file. Depending on the module type ([CommonJS](https://nodejs.org/api/modules.html) or [Ecmascript Module](https://nodejs.org/api/esm.html)) the build process differs to handle the dynamic loading that application does at runtime.
|
|
82
81
|
|
|
83
82
|
## CLI - pack:zip
|
|
84
|
-
|
|
85
|
-
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.
|
|
83
|
+
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.
|
|
86
84
|
|
|
87
85
|
**Terminal: Pack:zip usage**
|
|
88
86
|
```bash
|
|
@@ -105,7 +103,6 @@ Options:
|
|
|
105
103
|
```
|
|
106
104
|
|
|
107
105
|
## CLI - pack:docker
|
|
108
|
-
|
|
109
106
|
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.
|
|
110
107
|
|
|
111
108
|
**Terminal: Pack:docker usage**
|
|
@@ -135,17 +132,15 @@ Options:
|
|
|
135
132
|
-h, --help display help for command
|
|
136
133
|
```
|
|
137
134
|
|
|
138
|
-
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.
|
|
135
|
+
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.
|
|
139
136
|
|
|
140
137
|
In addition to the standard operations, this command adds the following steps:
|
|
141
|
-
|
|
142
138
|
* `writeDockerFile` - Generate the docker file contents
|
|
143
139
|
* `pullDockerBaseImage` - Pull base image, to ensure its available and primed
|
|
144
140
|
* `buildDockerContainer` - Build final container
|
|
145
141
|
* `pushDockerContainer` - Push container with appropriate tags. Only applies if `--docker-push` is specified
|
|
146
142
|
|
|
147
143
|
## Ejected File
|
|
148
|
-
|
|
149
144
|
As indicated, any of the pack operations can be ejected, and produce an output that can be run independent of the pack command. This is helpful when integrating with more complicated build processes.
|
|
150
145
|
|
|
151
146
|
**Terminal: Sample Ejected File**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@travetto/pack",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.3",
|
|
4
4
|
"description": "Code packing utilities",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"travetto",
|
|
@@ -28,12 +28,12 @@
|
|
|
28
28
|
"@rollup/plugin-json": "^6.0.0",
|
|
29
29
|
"@rollup/plugin-node-resolve": "^15.0.1",
|
|
30
30
|
"@rollup/plugin-terser": "^0.4.0",
|
|
31
|
-
"@travetto/base": "^3.0.
|
|
31
|
+
"@travetto/base": "^3.0.3",
|
|
32
32
|
"rollup": "^3.17.2",
|
|
33
33
|
"rollup-plugin-sourcemaps": "^0.6.3"
|
|
34
34
|
},
|
|
35
35
|
"peerDependencies": {
|
|
36
|
-
"@travetto/cli": "^3.0.
|
|
36
|
+
"@travetto/cli": "^3.0.3"
|
|
37
37
|
},
|
|
38
38
|
"peerDependenciesMeta": {
|
|
39
39
|
"@travetto/cli": {
|
package/support/bin/config.ts
CHANGED
|
@@ -2,7 +2,7 @@ import type { OutputOptions } from 'rollup';
|
|
|
2
2
|
import type terser from '@rollup/plugin-terser';
|
|
3
3
|
|
|
4
4
|
import { Env } from '@travetto/base';
|
|
5
|
-
import { ManifestModule, Package, path, RootIndex } from '@travetto/manifest';
|
|
5
|
+
import { ManifestModule, ManifestModuleUtil, Package, path, RootIndex } from '@travetto/manifest';
|
|
6
6
|
|
|
7
7
|
const INTRO = {
|
|
8
8
|
commonjs: `
|
|
@@ -32,7 +32,7 @@ function getFilesFromModule(m: ManifestModule): string[] {
|
|
|
32
32
|
.filter(f => !/support\/(test|doc)/.test(f[0]))
|
|
33
33
|
]
|
|
34
34
|
.filter(([, t]) => t === 'ts' || t === 'js' || t === 'json')
|
|
35
|
-
.map(([f]) => path.resolve(m.outputFolder, f
|
|
35
|
+
.map(([f]) => ManifestModuleUtil.sourceToOutputExt(path.resolve(m.outputFolder, f)));
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
export function getOutput(): OutputOptions {
|