@travetto/pack 3.0.2-rc.0 → 3.0.2-rc.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 +39 -33
- package/package.json +3 -3
- package/support/bin/config.ts +2 -2
- package/support/bin/operation.ts +8 -4
- package/support/bin/types.ts +4 -1
- package/support/pack.base.ts +7 -6
- package/support/pack.dockerfile.ts +1 -1
package/README.md
CHANGED
|
@@ -29,15 +29,17 @@ $ trv pack --help
|
|
|
29
29
|
Usage: pack [options] [args...]
|
|
30
30
|
|
|
31
31
|
Options:
|
|
32
|
-
-w, --workspace <workspace>
|
|
33
|
-
-c, --no-clean
|
|
34
|
-
-o, --output <output>
|
|
35
|
-
-
|
|
36
|
-
-
|
|
37
|
-
-
|
|
38
|
-
-
|
|
39
|
-
-
|
|
40
|
-
-
|
|
32
|
+
-w, --workspace <workspace> Workspace for building
|
|
33
|
+
-c, --no-clean Disables: Clean workspace
|
|
34
|
+
-o, --output <output> Output location
|
|
35
|
+
-es, --main-scripts <main-scripts> Create entry scripts
|
|
36
|
+
-f, --main-name <main-name> Main name for build artifact
|
|
37
|
+
-e, --entry-point <entry-point> Entry point (default: "@travetto/cli/support/entry.cli")
|
|
38
|
+
-m, --no-minify Disables: Minify output
|
|
39
|
+
-sm, --sourcemap Bundle source maps
|
|
40
|
+
-is, --include-sources Include source with source maps
|
|
41
|
+
-x, --eject-file <eject-file> Eject commands to file
|
|
42
|
+
-h, --help display help for command
|
|
41
43
|
```
|
|
42
44
|
|
|
43
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).
|
|
@@ -89,15 +91,17 @@ $ trv pack:zip --help
|
|
|
89
91
|
Usage: pack:zip [options] [args...]
|
|
90
92
|
|
|
91
93
|
Options:
|
|
92
|
-
-w, --workspace <workspace>
|
|
93
|
-
-c, --no-clean
|
|
94
|
-
-o, --output <output>
|
|
95
|
-
-
|
|
96
|
-
-
|
|
97
|
-
-
|
|
98
|
-
-
|
|
99
|
-
-
|
|
100
|
-
-
|
|
94
|
+
-w, --workspace <workspace> Workspace for building
|
|
95
|
+
-c, --no-clean Disables: Clean workspace
|
|
96
|
+
-o, --output <output> Output location (default: "travetto_pack.zip")
|
|
97
|
+
-es, --main-scripts <main-scripts> Create entry scripts
|
|
98
|
+
-f, --main-name <main-name> Main name for build artifact
|
|
99
|
+
-e, --entry-point <entry-point> Entry point (default: "@travetto/cli/support/entry.cli")
|
|
100
|
+
-m, --no-minify Disables: Minify output
|
|
101
|
+
-sm, --sourcemap Bundle source maps
|
|
102
|
+
-is, --include-sources Include source with source maps
|
|
103
|
+
-x, --eject-file <eject-file> Eject commands to file
|
|
104
|
+
-h, --help display help for command
|
|
101
105
|
```
|
|
102
106
|
|
|
103
107
|
## CLI - pack:docker
|
|
@@ -113,7 +117,9 @@ Usage: pack:docker [options] [args...]
|
|
|
113
117
|
Options:
|
|
114
118
|
-w, --workspace <workspace> Workspace for building
|
|
115
119
|
-c, --no-clean Disables: Clean workspace
|
|
116
|
-
-o, --output <output> Output
|
|
120
|
+
-o, --output <output> Output location
|
|
121
|
+
-es, --main-scripts <main-scripts> Create entry scripts
|
|
122
|
+
-f, --main-name <main-name> Main name for build artifact
|
|
117
123
|
-e, --entry-point <entry-point> Entry point (default: "@travetto/cli/support/entry.cli")
|
|
118
124
|
-m, --no-minify Disables: Minify output
|
|
119
125
|
-sm, --sourcemap Bundle source maps
|
|
@@ -172,23 +178,23 @@ echo "Writing package.json
|
|
|
172
178
|
"
|
|
173
179
|
echo "{\"type\":\"commonjs\"}" > $DIST/package.json
|
|
174
180
|
|
|
175
|
-
# Writing entry scripts cli.sh args=(run rest)
|
|
181
|
+
# Writing entry scripts entry.cli.sh args=(run rest)
|
|
176
182
|
|
|
177
|
-
echo "Writing entry scripts cli.sh args=(run rest)
|
|
183
|
+
echo "Writing entry scripts entry.cli.sh args=(run rest)
|
|
178
184
|
"
|
|
179
|
-
echo "#!/bin/sh" > $DIST/cli.sh
|
|
180
|
-
echo "cd \$(dirname \"\$0\")" >> $DIST/cli.sh
|
|
181
|
-
echo "node cli.js run rest \$@" >> $DIST/cli.sh
|
|
182
|
-
chmod 755 $DIST/cli.sh
|
|
185
|
+
echo "#!/bin/sh" > $DIST/entry.cli.sh
|
|
186
|
+
echo "cd \$(dirname \"\$0\")" >> $DIST/entry.cli.sh
|
|
187
|
+
echo "node entry.cli.js run rest \$@" >> $DIST/entry.cli.sh
|
|
188
|
+
chmod 755 $DIST/entry.cli.sh
|
|
183
189
|
|
|
184
|
-
# Writing entry scripts cli.cmd args=(run rest)
|
|
190
|
+
# Writing entry scripts entry.cli.cmd args=(run rest)
|
|
185
191
|
|
|
186
|
-
echo "Writing entry scripts cli.cmd args=(run rest)
|
|
192
|
+
echo "Writing entry scripts entry.cli.cmd args=(run rest)
|
|
187
193
|
"
|
|
188
|
-
echo "" > $DIST/cli.cmd
|
|
189
|
-
echo "cd %~p0" >> $DIST/cli.cmd
|
|
190
|
-
echo "node cli.js run rest %*" >> $DIST/cli.cmd
|
|
191
|
-
chmod 755 $DIST/cli.cmd
|
|
194
|
+
echo "" > $DIST/entry.cli.cmd
|
|
195
|
+
echo "cd %~p0" >> $DIST/entry.cli.cmd
|
|
196
|
+
echo "node entry.cli.js run rest %*" >> $DIST/entry.cli.cmd
|
|
197
|
+
chmod 755 $DIST/entry.cli.cmd
|
|
192
198
|
|
|
193
199
|
# Copying over resources
|
|
194
200
|
|
|
@@ -218,7 +224,7 @@ TRV_MODULE=$MOD npx trv manifest $DIST/node_modules/$MOD prod
|
|
|
218
224
|
echo "Bundling Output minify=true sourcemap= entryPoint=@travetto/cli/support/entry.cli
|
|
219
225
|
"
|
|
220
226
|
export BUNDLE_ENTRY=node_modules/@travetto/cli/support/entry.cli.js
|
|
221
|
-
export
|
|
227
|
+
export BUNDLE_MAIN_FILE=entry.cli.js
|
|
222
228
|
export BUNDLE_COMPRESS=true
|
|
223
229
|
export BUNDLE_OUTPUT=$DIST
|
|
224
230
|
export BUNDLE_FORMAT=commonjs
|
|
@@ -235,7 +241,7 @@ echo "FROM node:18-alpine3.16" > $DIST/Dockerfile
|
|
|
235
241
|
echo "WORKDIR /app" >> $DIST/Dockerfile
|
|
236
242
|
echo "COPY . ." >> $DIST/Dockerfile
|
|
237
243
|
echo "" >> $DIST/Dockerfile
|
|
238
|
-
echo "ENTRYPOINT [\"/app/cli.sh\"]" >> $DIST/Dockerfile
|
|
244
|
+
echo "ENTRYPOINT [\"/app/entry.cli.sh\"]" >> $DIST/Dockerfile
|
|
239
245
|
|
|
240
246
|
# Pulling Docker Base Image node:18-alpine3.16
|
|
241
247
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@travetto/pack",
|
|
3
|
-
"version": "3.0.2-rc.
|
|
3
|
+
"version": "3.0.2-rc.2",
|
|
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.2-rc.
|
|
31
|
+
"@travetto/base": "^3.0.2-rc.1",
|
|
32
32
|
"rollup": "^3.17.2",
|
|
33
33
|
"rollup-plugin-sourcemaps": "^0.6.3"
|
|
34
34
|
},
|
|
35
35
|
"peerDependencies": {
|
|
36
|
-
"@travetto/cli": "^3.0.2-rc.
|
|
36
|
+
"@travetto/cli": "^3.0.2-rc.1"
|
|
37
37
|
},
|
|
38
38
|
"peerDependenciesMeta": {
|
|
39
39
|
"@travetto/cli": {
|
package/support/bin/config.ts
CHANGED
|
@@ -38,7 +38,7 @@ function getFilesFromModule(m: ManifestModule): string[] {
|
|
|
38
38
|
export function getOutput(): OutputOptions {
|
|
39
39
|
const format: Package['type'] = Env.get('BUNDLE_FORMAT', 'commonjs');
|
|
40
40
|
const dir = Env.get('BUNDLE_OUTPUT')!;
|
|
41
|
-
const
|
|
41
|
+
const mainFile = Env.get('BUNDLE_MAIN_FILE')!;
|
|
42
42
|
return {
|
|
43
43
|
format,
|
|
44
44
|
intro: INTRO[format],
|
|
@@ -50,7 +50,7 @@ export function getOutput(): OutputOptions {
|
|
|
50
50
|
!(Env.getBoolean('BUNDLE_SOURCES') ?? false),
|
|
51
51
|
compact:
|
|
52
52
|
Env.getBoolean('BUNDLE_COMPRESS') ?? true,
|
|
53
|
-
file: path.resolve(dir,
|
|
53
|
+
file: path.resolve(dir, mainFile),
|
|
54
54
|
...(format === 'commonjs' ? {} : {
|
|
55
55
|
inlineDynamicImports: true
|
|
56
56
|
}),
|
package/support/bin/operation.ts
CHANGED
|
@@ -60,7 +60,7 @@ export class PackOperation {
|
|
|
60
60
|
|
|
61
61
|
const env = Object.fromEntries(([
|
|
62
62
|
['BUNDLE_ENTRY', entryPointFile],
|
|
63
|
-
['
|
|
63
|
+
['BUNDLE_MAIN_FILE', `${cfg.mainName}.js`],
|
|
64
64
|
['BUNDLE_COMPRESS', cfg.minify],
|
|
65
65
|
['BUNDLE_SOURCEMAP', cfg.sourcemap],
|
|
66
66
|
['BUNDLE_SOURCES', cfg.includeSources],
|
|
@@ -140,16 +140,20 @@ export class PackOperation {
|
|
|
140
140
|
* Create launcher scripts (.sh, .cmd) to run output
|
|
141
141
|
*/
|
|
142
142
|
static async * writeEntryScript(cfg: CommonPackConfig): AsyncIterable<string[]> {
|
|
143
|
+
if (!cfg.mainScripts && !cfg.entryPoint.includes('@travetto/cli')) {
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
146
|
+
|
|
143
147
|
const title = 'Writing entry scripts';
|
|
144
148
|
|
|
145
149
|
const files = ([['posix', 'sh'], ['win32', 'cmd']] as const)
|
|
146
150
|
.map(([type, ext]) => ({
|
|
147
|
-
fileTitle: cliTpl`${{ title }} ${{ path: `${cfg.
|
|
148
|
-
file: `${cfg.
|
|
151
|
+
fileTitle: cliTpl`${{ title }} ${{ path: `${cfg.mainName}.${ext}` }} args=(${{ param: cfg.entryArguments.join(' ') }})`,
|
|
152
|
+
file: `${cfg.mainName}.${ext}`,
|
|
149
153
|
text: [
|
|
150
154
|
ShellCommands[type].scriptOpen(),
|
|
151
155
|
ShellCommands[type].chdirScript(),
|
|
152
|
-
ShellCommands[type].callCommandWithAllArgs('node', `${cfg.
|
|
156
|
+
ShellCommands[type].callCommandWithAllArgs('node', `${cfg.mainName}.js`, ...cfg.entryArguments),
|
|
153
157
|
].map(x => x.join(' '))
|
|
154
158
|
}));
|
|
155
159
|
|
package/support/bin/types.ts
CHANGED
|
@@ -5,11 +5,12 @@ export type CommonPackConfig = {
|
|
|
5
5
|
output: string;
|
|
6
6
|
clean: boolean;
|
|
7
7
|
ejectFile: string;
|
|
8
|
+
mainName: string;
|
|
9
|
+
mainScripts: boolean;
|
|
8
10
|
module: string;
|
|
9
11
|
|
|
10
12
|
// Bundle
|
|
11
13
|
entryPoint: string;
|
|
12
|
-
entryCommand: string;
|
|
13
14
|
entryArguments: string[];
|
|
14
15
|
minify: boolean;
|
|
15
16
|
sourcemap: boolean;
|
|
@@ -21,6 +22,8 @@ export type CommonPackOptions = {
|
|
|
21
22
|
output: OptionConfig<string>;
|
|
22
23
|
clean: OptionConfig<boolean>;
|
|
23
24
|
ejectFile: OptionConfig<string>;
|
|
25
|
+
mainName: OptionConfig<string>;
|
|
26
|
+
mainScripts: OptionConfig<boolean>;
|
|
24
27
|
|
|
25
28
|
// Bundle
|
|
26
29
|
entryPoint: OptionConfig<string>;
|
package/support/pack.base.ts
CHANGED
|
@@ -28,7 +28,7 @@ export abstract class BasePackCommand<T extends CommonPackOptions, S extends Com
|
|
|
28
28
|
return !!RootIndex.manifest.monoRepo && path.cwd() === RootIndex.manifest.workspacePath;
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
-
get
|
|
31
|
+
get entryPoints(): string[] {
|
|
32
32
|
return RootIndex.findSupport({ filter: x => x.includes('entry.') })
|
|
33
33
|
.map(x => x.import.replace(/[.][^.]+s$/, ''));
|
|
34
34
|
}
|
|
@@ -38,13 +38,14 @@ export abstract class BasePackCommand<T extends CommonPackOptions, S extends Com
|
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
getCommonOptions(): CommonPackOptions {
|
|
41
|
-
const
|
|
42
|
-
const mainEntry = this.entries.find(x => x.startsWith('@travetto/cli'))!;
|
|
41
|
+
const mainEntry = this.entryPoints.find(x => x.startsWith('@travetto/cli'))!;
|
|
43
42
|
return {
|
|
44
43
|
workspace: this.option({ short: 'w', desc: 'Workspace for building' }),
|
|
45
44
|
clean: this.boolOption({ short: 'c', desc: 'Clean workspace', def: true }),
|
|
46
|
-
output: this.option({ short: 'o', desc: 'Output
|
|
47
|
-
|
|
45
|
+
output: this.option({ short: 'o', desc: 'Output location' }),
|
|
46
|
+
mainScripts: this.option({ short: 'es', desc: 'Create entry scripts' }),
|
|
47
|
+
mainName: this.option({ short: 'f', desc: 'Main name for build artifact' }),
|
|
48
|
+
entryPoint: this.option({ short: 'e', desc: 'Entry point', def: mainEntry }),
|
|
48
49
|
minify: this.boolOption({ short: 'm', desc: 'Minify output', def: true }),
|
|
49
50
|
sourcemap: this.boolOption({ short: 'sm', desc: 'Bundle source maps' }),
|
|
50
51
|
includeSources: this.boolOption({ short: 'is', desc: 'Include source with source maps' }),
|
|
@@ -94,8 +95,8 @@ export abstract class BasePackCommand<T extends CommonPackOptions, S extends Com
|
|
|
94
95
|
|
|
95
96
|
async buildConfig(): Promise<S> {
|
|
96
97
|
this.cmd.workspace ??= path.resolve(os.tmpdir(), RootIndex.mainModule.sourcePath.replace(/[\/\\: ]/g, '_'));
|
|
97
|
-
this.cmd.entryCommand = path.basename(this.cmd.entryPoint).replace(/entry[.]/, '');
|
|
98
98
|
this.cmd.module = RootIndex.mainModule.name;
|
|
99
|
+
this.cmd.mainName ??= path.basename(this.cmd.entryPoint);
|
|
99
100
|
return this.cmd;
|
|
100
101
|
}
|
|
101
102
|
|