@travetto/pack 7.0.2 → 7.0.4
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/src/config-util.ts +1 -1
- package/support/bin/docker-operation.ts +3 -3
- package/support/bin/operation.ts +3 -3
- package/support/bin/shell.ts +1 -1
- package/support/bin/util.ts +2 -2
- package/support/cli.pack_docker.ts +3 -3
- package/support/cli.pack_zip.ts +1 -1
- package/support/pack.base.ts +5 -5
- package/support/pack.dockerfile.ts +1 -1
- package/support/rollup/config.ts +10 -10
- package/support/rollup/rollup-travetto-entry.ts +2 -2
- package/support/rollup/rollup-travetto-import.ts +2 -2
- package/support/rollup/rollup-travetto-sourcemaps.ts +2 -2
package/README.md
CHANGED
|
@@ -173,7 +173,7 @@ $ trv pack:docker -x /dev/stdout web:http
|
|
|
173
173
|
export DIST=/tmp/<temp-folder>
|
|
174
174
|
export TRV_OUT=<workspace-root>/.trv/output
|
|
175
175
|
export ROOT=<workspace-root>/related/todo-app
|
|
176
|
-
export
|
|
176
|
+
export MODULE=@travetto/todo-app
|
|
177
177
|
|
|
178
178
|
# Cleaning Output $DIST
|
|
179
179
|
|
|
@@ -188,7 +188,7 @@ echo "Writing $DIST/.env"
|
|
|
188
188
|
|
|
189
189
|
echo "NODE_ENV=production" > $DIST/.env
|
|
190
190
|
echo "TRV_MANIFEST=manifest.json" >> $DIST/.env
|
|
191
|
-
echo "TRV_MODULE=$
|
|
191
|
+
echo "TRV_MODULE=$MODULE" >> $DIST/.env
|
|
192
192
|
echo "TRV_CLI_IPC=" >> $DIST/.env
|
|
193
193
|
echo "TRV_RESOURCE_OVERRIDES=@#resources=@@#resources" >> $DIST/.env
|
|
194
194
|
|
|
@@ -225,7 +225,7 @@ cp -r -p $ROOT/resources/* $DIST/resources
|
|
|
225
225
|
|
|
226
226
|
echo "Writing Manifest manifest.json"
|
|
227
227
|
|
|
228
|
-
TRV_MODULE=$
|
|
228
|
+
TRV_MODULE=$MODULE npx trvc manifest:production $DIST/manifest.json
|
|
229
229
|
|
|
230
230
|
# Bundling Output minify=true sourcemap=false entryPoint=@travetto/cli/support/entry.trv.ts
|
|
231
231
|
|
|
@@ -238,7 +238,7 @@ export BUNDLE_SOURCEMAP=false
|
|
|
238
238
|
export BUNDLE_SOURCES=false
|
|
239
239
|
export BUNDLE_OUTPUT=$DIST
|
|
240
240
|
export BUNDLE_ENV_FILE=.env
|
|
241
|
-
export TRV_MANIFEST=$TRV_OUT/node_modules/$
|
|
241
|
+
export TRV_MANIFEST=$TRV_OUT/node_modules/$MODULE
|
|
242
242
|
cd $TRV_OUT
|
|
243
243
|
npx rollup -c $TRV_OUT/node_modules/@travetto/pack/support/rollup/build.js
|
|
244
244
|
cd $ROOT
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@travetto/pack",
|
|
3
|
-
"version": "7.0.
|
|
3
|
+
"version": "7.0.4",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Code packing utilities",
|
|
6
6
|
"keywords": [
|
|
@@ -30,12 +30,12 @@
|
|
|
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": "^7.0.
|
|
34
|
-
"@travetto/terminal": "^7.0.
|
|
35
|
-
"rollup": "^4.
|
|
33
|
+
"@travetto/runtime": "^7.0.4",
|
|
34
|
+
"@travetto/terminal": "^7.0.4",
|
|
35
|
+
"rollup": "^4.55.1"
|
|
36
36
|
},
|
|
37
37
|
"peerDependencies": {
|
|
38
|
-
"@travetto/cli": "^7.0.
|
|
38
|
+
"@travetto/cli": "^7.0.6"
|
|
39
39
|
},
|
|
40
40
|
"peerDependenciesMeta": {
|
|
41
41
|
"@travetto/cli": {
|
package/src/config-util.ts
CHANGED
|
@@ -5,7 +5,7 @@ import { JSONUtil, Runtime } from '@travetto/runtime';
|
|
|
5
5
|
import { cliTpl } from '@travetto/cli';
|
|
6
6
|
|
|
7
7
|
import { ActiveShellCommand } from './shell.ts';
|
|
8
|
-
import { DockerPackConfig, DockerPackFactoryModule } from '../../src/types.ts';
|
|
8
|
+
import type { DockerPackConfig, DockerPackFactoryModule } from '../../src/types.ts';
|
|
9
9
|
import { PackOperation } from './operation.ts';
|
|
10
10
|
import { PackUtil } from './util.ts';
|
|
11
11
|
|
|
@@ -37,8 +37,8 @@ export class DockerPackOperation {
|
|
|
37
37
|
*/
|
|
38
38
|
static async* writeDockerFile(config: DockerPackConfig): AsyncIterable<string[]> {
|
|
39
39
|
const dockerFile = path.resolve(config.buildDirectory, 'Dockerfile');
|
|
40
|
-
const
|
|
41
|
-
const content = (await
|
|
40
|
+
const { factory } = await Runtime.importFrom<DockerPackFactoryModule>(config.dockerFactory);
|
|
41
|
+
const content = (await factory(config)).trim();
|
|
42
42
|
|
|
43
43
|
yield* PackOperation.title(config, cliTpl`${{ title: 'Generating Docker File' }} ${{ path: dockerFile }} ${{ param: config.dockerFactory }}`);
|
|
44
44
|
|
package/support/bin/operation.ts
CHANGED
|
@@ -4,7 +4,7 @@ import path from 'node:path';
|
|
|
4
4
|
import { cliTpl } from '@travetto/cli';
|
|
5
5
|
import { Env, Runtime, RuntimeIndex } from '@travetto/runtime';
|
|
6
6
|
|
|
7
|
-
import { CommonPackConfig } from '../../src/types.ts';
|
|
7
|
+
import type { CommonPackConfig } from '../../src/types.ts';
|
|
8
8
|
import { PackUtil } from './util.ts';
|
|
9
9
|
import { ActiveShellCommand, ShellCommands } from './shell.ts';
|
|
10
10
|
|
|
@@ -67,7 +67,7 @@ export class PackOperation {
|
|
|
67
67
|
['BUNDLE_SOURCES', config.includeSources],
|
|
68
68
|
['BUNDLE_OUTPUT', config.buildDirectory],
|
|
69
69
|
['BUNDLE_ENV_FILE', config.envFile],
|
|
70
|
-
['BUNDLE_EXTERNAL', config.externalDependencies.map(
|
|
70
|
+
['BUNDLE_EXTERNAL', config.externalDependencies.map(module => module.split(':')[0]).join(',')]
|
|
71
71
|
] as const)
|
|
72
72
|
.filter(pair => pair[1] === false || pair[1])
|
|
73
73
|
.map(pair => [pair[0], `${pair[1]}`])
|
|
@@ -225,7 +225,7 @@ export class PackOperation {
|
|
|
225
225
|
*/
|
|
226
226
|
static async * writeManifest(config: CommonPackConfig): AsyncIterable<string[]> {
|
|
227
227
|
const out = path.resolve(config.buildDirectory, config.manifestFile);
|
|
228
|
-
const cmd = ['npx', 'trvc', 'manifest',
|
|
228
|
+
const cmd = ['npx', 'trvc', 'manifest:production', out];
|
|
229
229
|
const env = { ...Env.TRV_MODULE.export(config.module) };
|
|
230
230
|
|
|
231
231
|
yield* PackOperation.title(config, cliTpl`${{ title: 'Writing Manifest' }} ${{ path: config.manifestFile }}`);
|
package/support/bin/shell.ts
CHANGED
package/support/bin/util.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import fs from 'node:fs/promises';
|
|
2
|
-
import { spawn, SpawnOptions } from 'node:child_process';
|
|
2
|
+
import { spawn, type SpawnOptions } from 'node:child_process';
|
|
3
3
|
import path from 'node:path';
|
|
4
4
|
|
|
5
5
|
import { AppError, ExecUtil, RuntimeIndex } from '@travetto/runtime';
|
|
@@ -40,7 +40,7 @@ export class PackUtil {
|
|
|
40
40
|
* Finalize eject output
|
|
41
41
|
*/
|
|
42
42
|
static async writeEjectOutput(workspace: string, module: string, output: AsyncIterable<string>, file: string): Promise<void> {
|
|
43
|
-
const vars = { DIST: workspace, TRV_OUT: RuntimeIndex.outputRoot, ROOT: path.resolve(),
|
|
43
|
+
const vars = { DIST: workspace, TRV_OUT: RuntimeIndex.outputRoot, ROOT: path.resolve(), MODULE: module };
|
|
44
44
|
|
|
45
45
|
const replaceArgs = (text: string): string => Object.entries(vars)
|
|
46
46
|
.reduce((result, [key, value]) => result.replaceAll(value, ActiveShellCommand.var(key)), text);
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import path from 'node:path';
|
|
2
2
|
|
|
3
3
|
import { RuntimeIndex } from '@travetto/runtime';
|
|
4
|
-
import { CliCommand, CliFlag, CliUtil, CliValidationError } from '@travetto/cli';
|
|
4
|
+
import { CliCommand, CliFlag, CliUtil, type CliValidationError } from '@travetto/cli';
|
|
5
5
|
import { Ignore, Required } from '@travetto/schema';
|
|
6
6
|
|
|
7
7
|
import { DockerPackOperation } from './bin/docker-operation.ts';
|
|
8
|
-
import { BasePackCommand, PackOperationShape } from './pack.base';
|
|
9
|
-
import { DockerPackConfig } from '../src/types.ts';
|
|
8
|
+
import { BasePackCommand, type PackOperationShape } from './pack.base';
|
|
9
|
+
import type { DockerPackConfig } from '../src/types.ts';
|
|
10
10
|
|
|
11
11
|
const NODE_MAJOR = process.version.match(/\d+/)?.[0] ?? '22';
|
|
12
12
|
|
package/support/cli.pack_zip.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { CliCommand, CliUtil } from '@travetto/cli';
|
|
2
2
|
|
|
3
3
|
import { PackOperation } from './bin/operation.ts';
|
|
4
|
-
import { BasePackCommand, PackOperationShape } from './pack.base';
|
|
4
|
+
import { BasePackCommand, type PackOperationShape } from './pack.base';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Standard zip support for pack
|
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 { CliCommandShape, CliFlag, ParsedState, cliTpl } from '@travetto/cli';
|
|
4
|
+
import { type CliCommandShape, CliFlag, type ParsedState, 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';
|
|
@@ -17,7 +17,7 @@ export abstract class BasePackCommand implements CliCommandShape {
|
|
|
17
17
|
|
|
18
18
|
static get entryPoints(): string[] {
|
|
19
19
|
return RuntimeIndex.find({
|
|
20
|
-
module:
|
|
20
|
+
module: module => module.prod,
|
|
21
21
|
folder: folder => folder === 'support',
|
|
22
22
|
file: file => file.sourceFile.includes('entry.')
|
|
23
23
|
})
|
|
@@ -129,9 +129,9 @@ export abstract class BasePackCommand implements CliCommandShape {
|
|
|
129
129
|
getBinaryDependencies(): string[] {
|
|
130
130
|
return [...RuntimeIndex.getModuleList('all')]
|
|
131
131
|
.map(name => RuntimeIndex.getModule(name))
|
|
132
|
-
.filter(
|
|
133
|
-
.filter(
|
|
134
|
-
.map(
|
|
132
|
+
.filter(module => !!module)
|
|
133
|
+
.filter(module => module.prod)
|
|
134
|
+
.map(module => PackageUtil.readPackage(module?.sourcePath))
|
|
135
135
|
.map(pkg => pkg?.travetto?.build?.binaryDependencies ?? [])
|
|
136
136
|
.flat();
|
|
137
137
|
}
|
package/support/rollup/config.ts
CHANGED
|
@@ -6,19 +6,19 @@ import type terser from '@rollup/plugin-terser';
|
|
|
6
6
|
import { type ManifestModule, ManifestModuleUtil } from '@travetto/manifest';
|
|
7
7
|
import { EnvProp, Runtime, RuntimeIndex } from '@travetto/runtime';
|
|
8
8
|
|
|
9
|
-
import { CoreRollupConfig } from '../../src/types.ts';
|
|
9
|
+
import type { CoreRollupConfig } from '../../src/types.ts';
|
|
10
10
|
|
|
11
|
-
function getFilesFromModule(
|
|
11
|
+
function getFilesFromModule(module: ManifestModule): string[] {
|
|
12
12
|
return [
|
|
13
|
-
...
|
|
14
|
-
...
|
|
15
|
-
...(
|
|
16
|
-
...(
|
|
13
|
+
...module.files.$index ?? [],
|
|
14
|
+
...module.files.src ?? [],
|
|
15
|
+
...(module.files.bin ?? []).filter(file => !(/bin\/trv[.]js$/.test(file[0]) && module.name === '@travetto/cli')),
|
|
16
|
+
...(module.files.support ?? [])
|
|
17
17
|
.filter(file => !/support\/(test|doc|pack)/.test(file[0]))
|
|
18
18
|
]
|
|
19
19
|
.filter(([, type]) => type === 'ts' || type === 'js' || type === 'json')
|
|
20
20
|
.filter(([, , , role]) => (role ?? 'std') === 'std') // Only include standard files
|
|
21
|
-
.map(([file]) => ManifestModuleUtil.withOutputExtension(path.resolve(
|
|
21
|
+
.map(([file]) => ManifestModuleUtil.withOutputExtension(path.resolve(module.outputFolder, file)));
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
export function getOutput(): OutputOptions {
|
|
@@ -43,7 +43,7 @@ export function getEntry(): string {
|
|
|
43
43
|
export function getFiles(entry?: string): string[] {
|
|
44
44
|
return [...RuntimeIndex.getModuleList('all')]
|
|
45
45
|
.map(name => RuntimeIndex.getManifestModule(name))
|
|
46
|
-
.filter(
|
|
46
|
+
.filter(module => module.prod)
|
|
47
47
|
.flatMap(getFilesFromModule)
|
|
48
48
|
.filter(file => (!entry || !file.endsWith(entry)) && !file.includes('@travetto/pack/support/'));
|
|
49
49
|
}
|
|
@@ -51,7 +51,7 @@ export function getFiles(entry?: string): string[] {
|
|
|
51
51
|
export function getIgnoredModules(): ManifestModule[] {
|
|
52
52
|
return [...RuntimeIndex.getModuleList('all')]
|
|
53
53
|
.map(name => RuntimeIndex.getManifestModule(name))
|
|
54
|
-
.filter(
|
|
54
|
+
.filter(module => !module.prod);
|
|
55
55
|
}
|
|
56
56
|
|
|
57
57
|
export function getMinifyConfig(): Parameters<typeof terser>[0] {
|
|
@@ -80,6 +80,6 @@ export function getCoreConfig(): CoreRollupConfig {
|
|
|
80
80
|
|
|
81
81
|
return {
|
|
82
82
|
output, entry, files, envFile, minify, external,
|
|
83
|
-
ignore: new Set([...ignoreModules.map(
|
|
83
|
+
ignore: new Set([...ignoreModules.map(module => module.name), ...ignoreFiles]),
|
|
84
84
|
};
|
|
85
85
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { readFileSync } from 'node:fs';
|
|
2
|
-
import { Plugin } from 'rollup';
|
|
2
|
+
import type { Plugin } from 'rollup';
|
|
3
3
|
|
|
4
4
|
import { RuntimeIndex } from '@travetto/runtime';
|
|
5
5
|
|
|
6
|
-
import { CoreRollupConfig } from '../../src/types.ts';
|
|
6
|
+
import type { CoreRollupConfig } from '../../src/types.ts';
|
|
7
7
|
|
|
8
8
|
export const GLOBAL_IMPORT = '__trv_imp';
|
|
9
9
|
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { AstNode, Plugin } from 'rollup';
|
|
1
|
+
import type { AstNode, Plugin } from 'rollup';
|
|
2
2
|
import { walk } from 'estree-walker';
|
|
3
3
|
import magicString from 'magic-string';
|
|
4
4
|
|
|
5
5
|
import { GLOBAL_IMPORT } from './rollup-travetto-entry.ts';
|
|
6
|
-
import { CoreRollupConfig } from '../../src/types.ts';
|
|
6
|
+
import type { CoreRollupConfig } from '../../src/types.ts';
|
|
7
7
|
|
|
8
8
|
type TNode = AstNode & { source?: { type: string }, callee?: TNode & { name?: string }, args?: TNode[] };
|
|
9
9
|
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import path from 'node:path';
|
|
2
2
|
import fs from 'node:fs/promises';
|
|
3
3
|
|
|
4
|
-
import { LoadResult, Plugin, PluginContext,
|
|
4
|
+
import type { LoadResult, Plugin, PluginContext, SourceMapInput } from 'rollup';
|
|
5
5
|
|
|
6
6
|
import { FileLoader } from '@travetto/runtime';
|
|
7
7
|
|
|
8
|
-
import { CoreRollupConfig } from '../../src/types.ts';
|
|
8
|
+
import type { CoreRollupConfig } from '../../src/types.ts';
|
|
9
9
|
|
|
10
10
|
function toString(error: unknown): string {
|
|
11
11
|
return error instanceof Error ? error.stack ?? error.toString() : JSON.stringify(error);
|