@travetto/pack 3.4.0-rc.8 → 3.4.0

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@travetto/pack",
3
- "version": "3.4.0-rc.8",
3
+ "version": "3.4.0",
4
4
  "description": "Code packing utilities",
5
5
  "keywords": [
6
6
  "travetto",
@@ -28,11 +28,11 @@
28
28
  "@rollup/plugin-json": "^6.0.1",
29
29
  "@rollup/plugin-node-resolve": "^15.2.3",
30
30
  "@rollup/plugin-terser": "^0.4.4",
31
- "@travetto/base": "^3.4.0-rc.2",
31
+ "@travetto/base": "^3.4.0",
32
32
  "rollup": "^4.3.0"
33
33
  },
34
34
  "peerDependencies": {
35
- "@travetto/cli": "^3.4.0-rc.3"
35
+ "@travetto/cli": "^3.4.0"
36
36
  },
37
37
  "peerDependenciesMeta": {
38
38
  "@travetto/cli": {
@@ -67,14 +67,10 @@ export function getFiles(): string[] {
67
67
  }
68
68
 
69
69
  export function getIgnoredModules(): string[] {
70
- const out = [...RootIndex.getModuleList('all')]
70
+ return [...RootIndex.getModuleList('all')]
71
71
  .map(x => RootIndex.manifest.modules[x])
72
72
  .filter(m => !m.prod)
73
73
  .map(m => m.name);
74
-
75
- out.push('@travetto/pack', '@travetto/compiler');
76
-
77
- return out;
78
74
  }
79
75
 
80
76
  export function getTerserConfig(): Parameters<typeof terser>[0] {
@@ -65,6 +65,8 @@ export class DockerPackOperation {
65
65
  yield ActiveShellCommand.chdir(path.cwd());
66
66
  } else {
67
67
  await PackUtil.runCommand(cmd, { cwd: cfg.workspace, stdio: [0, 'pipe', 2] });
68
+ const [image] = JSON.parse(await PackUtil.runCommand(['docker', 'inspect', cfg.dockerImage]));
69
+ yield [cliTpl`${{ title: 'Built Docker Container ' }} ${{ identifier: 'sizeMb' }}=${{ param: Math.trunc(image.Size / 2 ** 20) }}`];
68
70
  }
69
71
  }
70
72
 
@@ -88,6 +88,8 @@ export class PackOperation {
88
88
  yield ActiveShellCommand.chdir(path.cwd());
89
89
  } else {
90
90
  await PackUtil.runCommand(bundleCommand, { cwd, env });
91
+ const stat = await fs.stat(path.resolve(cfg.workspace, `${cfg.mainName}.js`));
92
+ yield [cliTpl`${{ title: 'Bundled Output ' }} ${{ identifier: 'sizeKb' }}=${{ param: Math.trunc(stat.size / 2 ** 10) }}`];
91
93
  }
92
94
  }
93
95
 
@@ -1,6 +1,6 @@
1
- import { AcornNode, Plugin } from 'rollup';
1
+ import { AstNode, Plugin } from 'rollup';
2
2
  import { walk } from 'estree-walker';
3
- import MagicString from 'magic-string';
3
+ import magicString from 'magic-string';
4
4
 
5
5
  const BRAND = '__imp';
6
6
 
@@ -23,20 +23,20 @@ export function travettoImportPlugin(entry: string, files: string[]): Plugin {
23
23
  transform(code, id) {
24
24
  const parsed = this.parse(code);
25
25
 
26
- let ms: MagicString | undefined;
26
+ let ms: magicString | undefined;
27
27
 
28
28
  if (id.includes(entry)) {
29
- (ms ??= new MagicString(code).append(DYNAMIC_IMPORT(imports)));
29
+ (ms ??= new magicString(code).append(DYNAMIC_IMPORT(imports)));
30
30
  }
31
31
 
32
32
  walk(parsed, {
33
33
  enter: (node) => {
34
34
  // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
35
- const impNode = node as AcornNode & { source?: { type: string } };
35
+ const impNode = node as AstNode & { source?: { type: string } };
36
36
  if (impNode.type !== 'ImportExpression' || impNode.source?.type === 'Literal') {
37
37
  return;
38
38
  }
39
- (ms ??= new MagicString(code)).overwrite(impNode.start, impNode.start + 6, BRAND);
39
+ (ms ??= new magicString(code)).overwrite(impNode.start, impNode.start + 6, BRAND);
40
40
  }
41
41
  });
42
42
 
@@ -66,8 +66,8 @@ export class PackUtil {
66
66
  /**
67
67
  * Track result response
68
68
  */
69
- static async runCommand(cmd: string[], opts: ExecutionOptions = {}): Promise<void> {
70
- const { valid, code, stderr, message } = await ExecUtil.spawn(cmd[0], cmd.slice(1), {
69
+ static async runCommand(cmd: string[], opts: ExecutionOptions = {}): Promise<string> {
70
+ const { valid, code, stderr, message, stdout } = await ExecUtil.spawn(cmd[0], cmd.slice(1), {
71
71
  stdio: [0, 'pipe', 'pipe', 'ipc'],
72
72
  ...opts,
73
73
  catchAsResult: true
@@ -76,5 +76,6 @@ export class PackUtil {
76
76
  process.exitCode = code;
77
77
  throw new AppError(stderr || message || 'An unexpected error has occurred');
78
78
  }
79
+ return stdout;
79
80
  }
80
81
  }
@@ -5,5 +5,5 @@ import { BasePackCommand } from './pack.base';
5
5
  /**
6
6
  * Standard pack support
7
7
  */
8
- @CliCommand({ fields: ['module'] })
8
+ @CliCommand({ addModule: true })
9
9
  export class PackCommand extends BasePackCommand { }
@@ -13,7 +13,7 @@ const DEFAULT_USER = 'app';
13
13
  /**
14
14
  * Standard docker support for pack
15
15
  */
16
- @CliCommand({ fields: ['module'] })
16
+ @CliCommand({ addModule: true })
17
17
  export class PackDockerCommand extends BasePackCommand {
18
18
  @CliFlag({ desc: 'Docker Factory source ', short: 'df', envVars: ['PACK_DOCKER_FACTORY'] })
19
19
  dockerFactory = '@travetto/pack/support/pack.dockerfile';
@@ -6,7 +6,7 @@ import { BasePackCommand, PackOperationShape } from './pack.base';
6
6
  /**
7
7
  * Standard zip support for pack
8
8
  */
9
- @CliCommand({ fields: ['module'] })
9
+ @CliCommand({ addModule: true })
10
10
  export class PackZipCommand extends BasePackCommand {
11
11
 
12
12
  initialize(): void {