@contrast/cli 1.31.0 → 1.33.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.
@@ -20,6 +20,7 @@ const fs = require('fs');
20
20
  const { EOL } = require('os');
21
21
  const path = require('path');
22
22
  const { name: agentName, version: agentVersion } = require('../package.json');
23
+ const { primordials: { JSONStringify } } = require('@contrast/common');
23
24
 
24
25
  if (require.main === module) {
25
26
  commander.program
@@ -33,7 +34,7 @@ if (require.main === module) {
33
34
  }
34
35
 
35
36
  async function action(entrypoint, options) {
36
- const core = { agentName, agentVersion };
37
+ const core = { agentName, agentVersion, Perf: require('@contrast/perf') };
37
38
  require('@contrast/core/lib/messages')(core);
38
39
  require('@contrast/config')(core);
39
40
  require('@contrast/logger').default(core);
@@ -58,7 +59,7 @@ async function action(entrypoint, options) {
58
59
  Status = `Unable to connect to TeamServer. Remote settings are not included in output. Error: ${err.message}`;
59
60
  }
60
61
 
61
- const content = JSON.stringify({ ...core.config.getReport({ redact: true }), Status }, null, 2) + EOL;
62
+ const content = JSONStringify({ ...core.config.getReport({ redact: true }), Status }, null, 2) + EOL;
62
63
 
63
64
  if (!options.quiet) {
64
65
  fs.writeFileSync(1, content, 'utf8');
package/lib/rewrite.js CHANGED
@@ -24,11 +24,12 @@ const { Visitor } = require('@swc/core/Visitor');
24
24
  const { findPackageJson } = require('@contrast/find-package-json');
25
25
  const { program } = require('commander');
26
26
  const { version } = require('../package.json');
27
+ const { primordials: { RegExpPrototypeTest, JSONParse } } = require('@contrast/common');
27
28
 
28
29
  const JS_FILE_REGEX = /\.[cm]?js$/;
29
30
 
30
31
  /** @type {any} */
31
- const core = {};
32
+ const core = { Perf: require('@contrast/perf') };
32
33
  require('@contrast/core/lib/messages')(core);
33
34
  const config = require('@contrast/config')(core);
34
35
  if (core.config._errors?.length) throw core.config._errors[0];
@@ -66,7 +67,7 @@ async function isModuleFile(filename) {
66
67
  // check for type: 'module' in a file's package json, otherwise assume CJS.
67
68
  try {
68
69
  const pkg = await findPackageJson({ cwd: filename });
69
- if (pkg && JSON.parse((await readFile(pkg)).toString()).type === 'module') {
70
+ if (pkg && JSONParse((await readFile(pkg)).toString()).type === 'module') {
70
71
  return true;
71
72
  }
72
73
  } catch {
@@ -134,7 +135,7 @@ class RewriteVisitor extends Visitor {
134
135
 
135
136
  /** @param {string} filename */
136
137
  async function rewriteFile(filename) {
137
- if (!JS_FILE_REGEX.test(filename) || visited.has(filename)) return;
138
+ if (!RegExpPrototypeTest.call(JS_FILE_REGEX, filename) || visited.has(filename)) return;
138
139
 
139
140
  try {
140
141
  const content = (await readFile(filename)).toString();
@@ -145,7 +146,6 @@ async function rewriteFile(filename) {
145
146
  isModule,
146
147
  inject: true,
147
148
  wrap: !isModule,
148
- trim: false,
149
149
  });
150
150
  rewriter.cache.write(filename, result);
151
151
 
@@ -20,6 +20,7 @@ const fs = require('fs');
20
20
  const { EOL } = require('os');
21
21
  const path = require('path');
22
22
  const { name: agentName, version: agentVersion } = require('../package.json');
23
+ const { primordials: { JSONStringify } } = require('@contrast/common');
23
24
 
24
25
  if (require.main === module) {
25
26
  commander.program
@@ -32,7 +33,7 @@ if (require.main === module) {
32
33
  }
33
34
 
34
35
  async function action(options) {
35
- const core = { agentName, agentVersion };
36
+ const core = { agentName, agentVersion, Perf: require('@contrast/perf') };
36
37
  require('@contrast/config')(core);
37
38
  require('@contrast/logger').default(core, { level: 'silent' });
38
39
  require('@contrast/core/lib/app-info')(core);
@@ -43,7 +44,7 @@ async function action(options) {
43
44
  }
44
45
 
45
46
  const systemInfo = await core.getSystemInfo();
46
- const content = JSON.stringify(systemInfo, null, 2) + EOL;
47
+ const content = JSONStringify(systemInfo, null, 2) + EOL;
47
48
 
48
49
  if (!options.quiet) {
49
50
  fs.writeFileSync(1, content, 'utf8');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contrast/cli",
3
- "version": "1.31.0",
3
+ "version": "1.33.0",
4
4
  "description": "A collection of agent related CLI utilities",
5
5
  "license": "SEE LICENSE IN LICENSE",
6
6
  "author": "Contrast Security <nodejs@contrastsecurity.com> (https://www.contrastsecurity.com)",
@@ -21,12 +21,14 @@
21
21
  },
22
22
  "dependencies": {
23
23
  "@contrast/find-package-json": "^1.1.0",
24
- "@contrast/rewriter": "1.12.0",
25
- "@contrast/config": "1.32.0",
26
- "@contrast/core": "1.36.0",
27
- "@contrast/logger": "1.9.0",
28
- "@contrast/reporter": "1.31.0",
29
- "@contrast/scopes": "1.5.0",
24
+ "@contrast/rewriter": "1.14.0",
25
+ "@contrast/common": "1.26.0",
26
+ "@contrast/config": "1.34.0",
27
+ "@contrast/core": "1.38.0",
28
+ "@contrast/logger": "1.11.0",
29
+ "@contrast/perf": "1.1.0",
30
+ "@contrast/reporter": "1.33.0",
31
+ "@contrast/scopes": "1.7.0",
30
32
  "@swc/core": "1.5.29",
31
33
  "commander": "^9.4.1"
32
34
  }