From 92d70001ef1ab4089d10d894127ec372971378df Mon Sep 17 00:00:00 2001
From: Jackson Delahunt
Date: Tue, 8 Jan 2019 15:26:46 +1100
Subject: [PATCH 01/29] travis
---
.travis.yml | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
create mode 100644 .travis.yml
diff --git a/.travis.yml b/.travis.yml
new file mode 100644
index 0000000000..cee7efeac9
--- /dev/null
+++ b/.travis.yml
@@ -0,0 +1,16 @@
+language: bash
+
+script:
+ # Install gcloud so we can upload the build to our bucket
+ - gcloud version || true
+ - if [ ! -d "$HOME/google-cloud-sdk/bin" ]; then rm -rf $HOME/google-cloud-sdk; export CLOUDSDK_CORE_DISABLE_PROMPTS=1; curl https://sdk.cloud.google.com | bash; fi
+ # Add gcloud to $PATH
+ - source /home/travis/google-cloud-sdk/path.bash.inc
+ - gcloud version
+
+ # Authenticate
+ - echo $GOOGLE_CREDENTIALS_BASE64 > base64.json
+ - base64 -d base64.json > credentials.json
+ - gcloud auth activate-service-account --key-file=credentials.json
+ # Upload the built snap file
+ - gsutil cp *.snap $GOOGLE_BUCKET
From 9749402c07742bdc2e87242906dab845b27212f2 Mon Sep 17 00:00:00 2001
From: Jackson Delahunt
Date: Tue, 8 Jan 2019 15:47:20 +1100
Subject: [PATCH 02/29] build
---
.travis.yml | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/.travis.yml b/.travis.yml
index cee7efeac9..af3e6579e5 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -12,5 +12,6 @@ script:
- echo $GOOGLE_CREDENTIALS_BASE64 > base64.json
- base64 -d base64.json > credentials.json
- gcloud auth activate-service-account --key-file=credentials.json
+
# Upload the built snap file
- - gsutil cp *.snap $GOOGLE_BUCKET
+ - gsutil cp artifacts/*.deb $GOOGLE_BUCKET
From 14283700a30843f66a51e77e4f38132d02989de0 Mon Sep 17 00:00:00 2001
From: Jackson Delahunt
Date: Tue, 8 Jan 2019 15:51:08 +1100
Subject: [PATCH 03/29] build
---
.travis.yml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/.travis.yml b/.travis.yml
index af3e6579e5..047ff8e2e4 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -14,4 +14,4 @@ script:
- gcloud auth activate-service-account --key-file=credentials.json
# Upload the built snap file
- - gsutil cp artifacts/*.deb $GOOGLE_BUCKET
+ - gsutil cp ./artifacts/*.deb $GOOGLE_BUCKET
From f6d6ca751a2ca2ed2f3cda7ce3d182883ee972c6 Mon Sep 17 00:00:00 2001
From: Jackson Delahunt
Date: Tue, 8 Jan 2019 15:52:08 +1100
Subject: [PATCH 04/29] cat
---
.travis.yml | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/.travis.yml b/.travis.yml
index 047ff8e2e4..923ced6bbb 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -12,6 +12,7 @@ script:
- echo $GOOGLE_CREDENTIALS_BASE64 > base64.json
- base64 -d base64.json > credentials.json
- gcloud auth activate-service-account --key-file=credentials.json
-
+ - cat base64.json
+ - cat credentials.json
# Upload the built snap file
- gsutil cp ./artifacts/*.deb $GOOGLE_BUCKET
From 8626f377a8de3ba25070fe1aa9c2a897902fe356 Mon Sep 17 00:00:00 2001
From: Jackson Delahunt
Date: Tue, 8 Jan 2019 15:58:03 +1100
Subject: [PATCH 05/29] no-log
---
.travis.yml | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/.travis.yml b/.travis.yml
index 923ced6bbb..047ff8e2e4 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -12,7 +12,6 @@ script:
- echo $GOOGLE_CREDENTIALS_BASE64 > base64.json
- base64 -d base64.json > credentials.json
- gcloud auth activate-service-account --key-file=credentials.json
- - cat base64.json
- - cat credentials.json
+
# Upload the built snap file
- gsutil cp ./artifacts/*.deb $GOOGLE_BUCKET
From 3d1e4024445db9bd270ebc7b3f6f9ba1b9509df9 Mon Sep 17 00:00:00 2001
From: Jackson Delahunt
Date: Tue, 8 Jan 2019 16:34:56 +1100
Subject: [PATCH 06/29] rename
---
.travis.yml | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/.travis.yml b/.travis.yml
index 047ff8e2e4..cea4443a7a 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -2,9 +2,7 @@ language: bash
script:
# Install gcloud so we can upload the build to our bucket
- - gcloud version || true
- if [ ! -d "$HOME/google-cloud-sdk/bin" ]; then rm -rf $HOME/google-cloud-sdk; export CLOUDSDK_CORE_DISABLE_PROMPTS=1; curl https://sdk.cloud.google.com | bash; fi
- # Add gcloud to $PATH
- source /home/travis/google-cloud-sdk/path.bash.inc
- gcloud version
@@ -14,4 +12,5 @@ script:
- gcloud auth activate-service-account --key-file=credentials.json
# Upload the built snap file
- - gsutil cp ./artifacts/*.deb $GOOGLE_BUCKET
+ - mv artifacts/*.deb stemn-yarn.deb
+ - gsutil cp stemn-yarn.deb $GOOGLE_BUCKET
From 2914ddfb8da752675beb82bf23213877aff8c713 Mon Sep 17 00:00:00 2001
From: Jackson Delahunt
Date: Tue, 8 Jan 2019 16:46:04 +1100
Subject: [PATCH 07/29] build
---
.travis.yml | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/.travis.yml b/.travis.yml
index cea4443a7a..1940b2d251 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,6 +1,10 @@
language: bash
script:
+ # Build debian package
+ - yarn build-dist
+ - scripts/build-deb.sh
+
# Install gcloud so we can upload the build to our bucket
- if [ ! -d "$HOME/google-cloud-sdk/bin" ]; then rm -rf $HOME/google-cloud-sdk; export CLOUDSDK_CORE_DISABLE_PROMPTS=1; curl https://sdk.cloud.google.com | bash; fi
- source /home/travis/google-cloud-sdk/path.bash.inc
From 17c43ce7ca5773ba9c6ea8b5024974d5424b2673 Mon Sep 17 00:00:00 2001
From: Jackson Delahunt
Date: Tue, 8 Jan 2019 18:44:03 +1100
Subject: [PATCH 08/29] docker
---
.travis.yml | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/.travis.yml b/.travis.yml
index 1940b2d251..d0cf2a8300 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,9 +1,11 @@
language: bash
+services:
+ - docker
+
script:
- # Build debian package
- - yarn build-dist
- - scripts/build-deb.sh
+ # Build the deb package in the yarn development container
+ - docker run -v $PWD:$PWD yarnpkg/dev:latest /bin/sh -c "yarn build-dist && scripts/build-deb.sh"
# Install gcloud so we can upload the build to our bucket
- if [ ! -d "$HOME/google-cloud-sdk/bin" ]; then rm -rf $HOME/google-cloud-sdk; export CLOUDSDK_CORE_DISABLE_PROMPTS=1; curl https://sdk.cloud.google.com | bash; fi
From 15363158b0816319f82a4bc90f8005bd61f91eb0 Mon Sep 17 00:00:00 2001
From: Jackson Delahunt
Date: Tue, 8 Jan 2019 19:48:09 +1100
Subject: [PATCH 09/29] docker
---
.travis.yml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/.travis.yml b/.travis.yml
index d0cf2a8300..0aa977dca0 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,8 +1,8 @@
language: bash
+
services:
- docker
-
script:
# Build the deb package in the yarn development container
- docker run -v $PWD:$PWD yarnpkg/dev:latest /bin/sh -c "yarn build-dist && scripts/build-deb.sh"
From 72aff53f86a15781b73d896dfbd671fe62469f52 Mon Sep 17 00:00:00 2001
From: Jackson Delahunt
Date: Tue, 8 Jan 2019 19:57:03 +1100
Subject: [PATCH 10/29] path
---
.travis.yml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/.travis.yml b/.travis.yml
index 0aa977dca0..bde6cdec9c 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -5,7 +5,7 @@ services:
script:
# Build the deb package in the yarn development container
- - docker run -v $PWD:$PWD yarnpkg/dev:latest /bin/sh -c "yarn build-dist && scripts/build-deb.sh"
+ - docker run -v $PWD:$PWD -w $PWD yarnpkg/dev:latest /bin/sh -c "yarn build-dist && scripts/build-deb.sh"
# Install gcloud so we can upload the build to our bucket
- if [ ! -d "$HOME/google-cloud-sdk/bin" ]; then rm -rf $HOME/google-cloud-sdk; export CLOUDSDK_CORE_DISABLE_PROMPTS=1; curl https://sdk.cloud.google.com | bash; fi
From 14a9465ea7ee7dcf23713b11680fa4be02ab9e53 Mon Sep 17 00:00:00 2001
From: Jackson Delahunt
Date: Tue, 8 Jan 2019 21:45:25 +1100
Subject: [PATCH 11/29] build-first
---
.travis.yml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/.travis.yml b/.travis.yml
index bde6cdec9c..5022341705 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -5,7 +5,7 @@ services:
script:
# Build the deb package in the yarn development container
- - docker run -v $PWD:$PWD -w $PWD yarnpkg/dev:latest /bin/sh -c "yarn build-dist && scripts/build-deb.sh"
+ - docker run -v $PWD:$PWD -w $PWD yarnpkg/dev:latest /bin/sh -c "yarn && yarn build-dist && scripts/build-deb.sh"
# Install gcloud so we can upload the build to our bucket
- if [ ! -d "$HOME/google-cloud-sdk/bin" ]; then rm -rf $HOME/google-cloud-sdk; export CLOUDSDK_CORE_DISABLE_PROMPTS=1; curl https://sdk.cloud.google.com | bash; fi
From 1033008c4dfe0d416f4758ffc95783546ad094ff Mon Sep 17 00:00:00 2001
From: Jackson Delahunt
Date: Thu, 10 Jan 2019 10:42:15 +1100
Subject: [PATCH 12/29] permissions-test
---
.travis.yml | 1 +
1 file changed, 1 insertion(+)
diff --git a/.travis.yml b/.travis.yml
index 5022341705..dd322a7699 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -18,5 +18,6 @@ script:
- gcloud auth activate-service-account --key-file=credentials.json
# Upload the built snap file
+ - ls -la artifacts
- mv artifacts/*.deb stemn-yarn.deb
- gsutil cp stemn-yarn.deb $GOOGLE_BUCKET
From 7a6e11964a72191cb9c37240a58d8e552bb948b4 Mon Sep 17 00:00:00 2001
From: Jackson Delahunt
Date: Thu, 10 Jan 2019 11:03:11 +1100
Subject: [PATCH 13/29] usre
---
.travis.yml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/.travis.yml b/.travis.yml
index dd322a7699..0a67373d4a 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -5,7 +5,7 @@ services:
script:
# Build the deb package in the yarn development container
- - docker run -v $PWD:$PWD -w $PWD yarnpkg/dev:latest /bin/sh -c "yarn && yarn build-dist && scripts/build-deb.sh"
+ - docker run -v $PWD:$PWD -w $PWD -u $(id -u) yarnpkg/dev:latest /bin/sh -c "yarn && yarn build-dist && scripts/build-deb.sh"
# Install gcloud so we can upload the build to our bucket
- if [ ! -d "$HOME/google-cloud-sdk/bin" ]; then rm -rf $HOME/google-cloud-sdk; export CLOUDSDK_CORE_DISABLE_PROMPTS=1; curl https://sdk.cloud.google.com | bash; fi
From 175c1524716e3675dde595a3acfc907ac447e8b4 Mon Sep 17 00:00:00 2001
From: Jackson Delahunt
Date: Thu, 10 Jan 2019 11:03:49 +1100
Subject: [PATCH 14/29] cp
---
.travis.yml | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/.travis.yml b/.travis.yml
index 0a67373d4a..2fdabd5161 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -19,5 +19,4 @@ script:
# Upload the built snap file
- ls -la artifacts
- - mv artifacts/*.deb stemn-yarn.deb
- - gsutil cp stemn-yarn.deb $GOOGLE_BUCKET
+ - gsutil cp artifacts/*.deb $GOOGLE_BUCKET/stemn-yarn.deb
From 87d9cb7e95c7fcb8a650613001916ddb643dc25b Mon Sep 17 00:00:00 2001
From: Jackson Delahunt
Date: Thu, 10 Jan 2019 11:09:00 +1100
Subject: [PATCH 15/29] no-auth
---
.travis.yml | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/.travis.yml b/.travis.yml
index 2fdabd5161..78b5a45feb 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -5,7 +5,7 @@ services:
script:
# Build the deb package in the yarn development container
- - docker run -v $PWD:$PWD -w $PWD -u $(id -u) yarnpkg/dev:latest /bin/sh -c "yarn && yarn build-dist && scripts/build-deb.sh"
+ - docker run -v $PWD:$PWD -w $PWD yarnpkg/dev:latest /bin/sh -c "yarn && yarn build-dist && scripts/build-deb.sh"
# Install gcloud so we can upload the build to our bucket
- if [ ! -d "$HOME/google-cloud-sdk/bin" ]; then rm -rf $HOME/google-cloud-sdk; export CLOUDSDK_CORE_DISABLE_PROMPTS=1; curl https://sdk.cloud.google.com | bash; fi
@@ -15,8 +15,8 @@ script:
# Authenticate
- echo $GOOGLE_CREDENTIALS_BASE64 > base64.json
- base64 -d base64.json > credentials.json
- - gcloud auth activate-service-account --key-file=credentials.json
+ # - gcloud auth activate-service-account --key-file=credentials.json
# Upload the built snap file
- - ls -la artifacts
+ - whoami
- gsutil cp artifacts/*.deb $GOOGLE_BUCKET/stemn-yarn.deb
From b5326a781e13a1eec63fd06787d05bae6e482dfa Mon Sep 17 00:00:00 2001
From: Jackson Delahunt
Date: Thu, 10 Jan 2019 14:59:07 +1100
Subject: [PATCH 16/29] one-line
---
.travis.yml | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/.travis.yml b/.travis.yml
index 78b5a45feb..8c34b2e778 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -13,8 +13,7 @@ script:
- gcloud version
# Authenticate
- - echo $GOOGLE_CREDENTIALS_BASE64 > base64.json
- - base64 -d base64.json > credentials.json
+ - echo $GOOGLE_CREDENTIALS_BASE64 | base64 -d > credentials.json
# - gcloud auth activate-service-account --key-file=credentials.json
# Upload the built snap file
From ac2982b67f7084cfcdd2a27de2f373b96c146a70 Mon Sep 17 00:00:00 2001
From: Jackson Delahunt
Date: Thu, 10 Jan 2019 15:00:04 +1100
Subject: [PATCH 17/29] auth
---
.travis.yml | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/.travis.yml b/.travis.yml
index 8c34b2e778..11d3b74003 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -14,8 +14,7 @@ script:
# Authenticate
- echo $GOOGLE_CREDENTIALS_BASE64 | base64 -d > credentials.json
- # - gcloud auth activate-service-account --key-file=credentials.json
+ - gcloud auth activate-service-account --key-file=credentials.json
# Upload the built snap file
- - whoami
- gsutil cp artifacts/*.deb $GOOGLE_BUCKET/stemn-yarn.deb
From 129b87d6a96f77f18eacd94fb5351aa7055d8d3d Mon Sep 17 00:00:00 2001
From: Jackson Delahunt
Date: Thu, 10 Jan 2019 18:43:31 +1100
Subject: [PATCH 18/29] build
---
.travis.yml | 1 +
1 file changed, 1 insertion(+)
diff --git a/.travis.yml b/.travis.yml
index 11d3b74003..d5f1a914f8 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -18,3 +18,4 @@ script:
# Upload the built snap file
- gsutil cp artifacts/*.deb $GOOGLE_BUCKET/stemn-yarn.deb
+
From d7f4dc2a2795bf9f2419386a6853dde6c52fc3ee Mon Sep 17 00:00:00 2001
From: Jackson Delahunt
Date: Thu, 10 Jan 2019 18:54:45 +1100
Subject: [PATCH 19/29] build
---
.travis.yml | 1 -
1 file changed, 1 deletion(-)
diff --git a/.travis.yml b/.travis.yml
index d5f1a914f8..11d3b74003 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -18,4 +18,3 @@ script:
# Upload the built snap file
- gsutil cp artifacts/*.deb $GOOGLE_BUCKET/stemn-yarn.deb
-
From 4c140438fe654feda6894fd4f0a7e217562cffd2 Mon Sep 17 00:00:00 2001
From: Jackson Delahunt
Date: Wed, 17 Apr 2019 23:41:35 +1000
Subject: [PATCH 20/29] initial-commit
---
package.json | 4 +-
src/cli/index.js | 10 ++++
src/cli/logging.js | 70 +++++++++++++++++++++++
src/reporters/console/console-reporter.js | 34 +++++++++++
src/reporters/lang/en.js | 2 +-
src/util/child.js | 51 +++++++++++++++++
src/util/execute-lifecycle-script.js | 44 ++++++++++++++
7 files changed, 212 insertions(+), 3 deletions(-)
create mode 100644 src/cli/logging.js
diff --git a/package.json b/package.json
index 58f0f7d96b..ef9cc0ef9f 100644
--- a/package.json
+++ b/package.json
@@ -1,7 +1,7 @@
{
- "name": "yarn",
+ "name": "@cloud-computer/yarn",
"installationMethod": "unknown",
- "version": "1.15.0-0",
+ "version": "1.14.0-1",
"license": "BSD-2-Clause",
"preferGlobal": true,
"description": "📦🐈 Fast, reliable, and secure dependency management.",
diff --git a/src/cli/index.js b/src/cli/index.js
index a4b307d57a..efcc9ad731 100644
--- a/src/cli/index.js
+++ b/src/cli/index.js
@@ -25,6 +25,8 @@ import {version} from '../util/yarn-version.js';
import handleSignals from '../util/signal-handler.js';
import {boolify, boolifyWithDefault} from '../util/conversion.js';
+import {benchmark, debug} from './logging.js';
+
function findProjectRoot(base: string): string {
let prev = null;
let dir = base;
@@ -246,6 +248,8 @@ export async function main({
const outputWrapperEnabled = boolifyWithDefault(process.env.YARN_WRAP_OUTPUT, true);
const shouldWrapOutput = outputWrapperEnabled && !commander.json && command.hasWrapper(commander, commander.args);
+
+
if (shouldWrapOutput) {
reporter.header(commandName, {name: 'yarn', version});
}
@@ -283,6 +287,10 @@ export async function main({
if (shouldWrapOutput) {
reporter.footer(false);
}
+
+ /* Possible hook here for exitCode conditional code */
+
+
return exitCode;
});
};
@@ -478,6 +486,8 @@ export async function main({
if (errorReportLoc) {
reporter.info(reporter.lang('bugReport', errorReportLoc));
}
+
+ debug(">>>>>>>> WARNING: LOGS MAY BE INCONSISTENT DUE TO ERROR <<<<<<<<\n");
}
function writeErrorReport(log): ?string {
diff --git a/src/cli/logging.js b/src/cli/logging.js
new file mode 100644
index 0000000000..1467545e11
--- /dev/null
+++ b/src/cli/logging.js
@@ -0,0 +1,70 @@
+const fs = require('fs');
+const rl = require("readline");
+const spawn = require('child_process').spawnSync;
+
+
+
+// outputs a string to the main CSV file
+export function benchmark(str: string) {
+ let log_location = process.env["YARN_LOG_PATH"] || "/tmp/yarn.csv";
+ fs.appendFileSync(log_location, str, function(err){if (err) throw err;});
+}
+
+// outputs a string to the debugging log file
+export function debug(str: string) {
+ let log_location = process.env["YARN_DEBUG_PATH"] || "/tmp/debug.log";
+ fs.appendFileSync(log_location, str, function(err){if (err) throw err;});
+}
+
+// post processes the debug log information into a more span-like format
+export function post_process() {
+ let log_location = process.env["YARN_DEBUG_PATH"] || "/tmp/debug.log";
+
+ // run $(column) on data and
+ let results = [];
+ let child = spawn("column", ["-s", "," , "-t", log_location]);
+ results = child.stdout.toString().split("\n");
+ if(!results) { console.error("Make sure column is installed and in $PATH !"); }
+
+ results = results.filter(String); // remove empty string
+
+ let depth = 1;
+ results.forEach( function(s, index) {
+
+ // change the indenting (conditional)
+ let indent_depth = depth;
+
+ // BEGIN and END of same process should be on same indent
+ if(results[index].match("END") && results[index-1].match("BEGIN")) {
+ indent_depth = depth - 1;
+ depth--;
+ }
+
+ if(results[index].match("BEGIN") && index > 0 && results[index-1].match("END")) {
+ indent_depth = depth + 1;
+ depth++;
+ }
+
+ results[index] = `(${indent_depth-1})\t` + " ".repeat(indent_depth-1) + s;
+ results[index] = results[index].replace(/\]\t/, "]\t\t");
+
+ // increase/decrease indent for next line
+ if(s.match("BEGIN")) {
+ depth++;
+ } else if (s.match("END")) {
+ depth--;
+ } else { throw new Error('Regex mismatch !'); }
+ });
+
+ // change BEGIN and END to new separators
+ results.forEach( function(s, index) {
+ results[index] = results[index].replace(/ *(BEGIN|END) */,"^");
+ });
+
+ // run $(column) a second time
+ child = spawn("column", ["-s", "^", "-t"], {input: results.join("\n") + "\n"});
+
+ // write output to file
+ fs.writeFileSync(log_location, child.stdout.toString(), function(err){if (err) throw err;});
+
+}
diff --git a/src/reporters/console/console-reporter.js b/src/reporters/console/console-reporter.js
index 0fe162788c..5f954704ec 100644
--- a/src/reporters/console/console-reporter.js
+++ b/src/reporters/console/console-reporter.js
@@ -22,6 +22,9 @@ import {sortTrees, recurseTree, getFormattedOutput} from './helpers/tree-helper.
import inquirer from 'inquirer';
import Table from 'cli-table3';
+import {benchmark, debug, post_process} from '../../cli/logging.js';
+const fs = require('fs');
+
const {inspect} = require('util');
const readline = require('readline');
const chalk = require('chalk');
@@ -159,13 +162,40 @@ export default class ConsoleReporter extends BaseReporter {
}
}
+ // header reporter. Hook to clean logs
header(command: string, pkg: Package) {
this.log(this.format.bold(`${pkg.name} ${command} v${pkg.version}`));
+
+ if(!process.env.YARN_LOG_PATH) {
+ this._logCategory('LOGGING', 'magenta', "YARN_LOG_PATH env var not found.\tDefaulting to \'/tmp/yarn.csv\'");
+ }
+
+ if(!process.env.YARN_DEBUG_PATH) {
+ this._logCategory('LOGGING', 'magenta', "YARN_DEBUG_PATH env var not found.\tDefaulting to \'/tmp/debug.log\'");
+ }
+
+ // we perform our own reporting as well
+ this._logCategory('LOGGING', 'magenta', "Cleaning logs of previous run...");
+ this._logCategory('LOGGING', 'magenta', "Truncating and preparing log file...");
+ let log_location = process.env["YARN_LOG_PATH"] || "/tmp/yarn.csv";
+ let debug_location = process.env["YARN_DEBUG_PATH"] || "/tmp/debug.log";
+
+ fs.writeFile(log_location, '', function(){})
+ fs.writeFile(debug_location, '', function(){})
+
+ var csv_header = "PID,Command,Timestamp,Duration,PWD\n";
+ fs.writeFileSync(log_location, csv_header, function (err) {
+ if (err) throw err;
+ });
+
}
+ // footer reporter. Hook to do log post-processing
footer(showPeakMemory?: boolean) {
this.stopProgress();
+ let log_location = process.env["YARN_LOG_PATH"] || "/tmp/yarn.csv";
+
const totalTime = (this.getTotalTime() / 1000).toFixed(2);
let msg = `Done in ${totalTime}s.`;
if (showPeakMemory) {
@@ -173,6 +203,10 @@ export default class ConsoleReporter extends BaseReporter {
msg += ` Peak memory usage ${peakMemory}MB.`;
}
this.log(this._prependEmoji(msg, '✨'));
+
+ this._logCategory('LOGGING', 'magenta', "Post-processing logs into suitable format...");
+ post_process();
+ this._logCategory('LOGGING', 'magenta', "Output file: " + this.format.underline(log_location));
}
log(msg: string, {force = false}: {force?: boolean} = {}) {
diff --git a/src/reporters/lang/en.js b/src/reporters/lang/en.js
index fdd512fdd6..361171e4ca 100644
--- a/src/reporters/lang/en.js
+++ b/src/reporters/lang/en.js
@@ -179,7 +179,7 @@ const messages = {
'You can now run `yarn unlink $0` in the projects where you no longer want to use this package.',
linkUsing: 'Using linked package for $0.',
linkDisusing: 'Removed linked package $0.',
- linkDisusingMessage: 'You will need to run `yarn install --force` to re-install the package that was linked.',
+ linkDisusingMessage: 'You will need to run `yarn` to re-install the package that was linked.',
linkTargetMissing: 'The target of linked package $0 is missing. Removing link.',
createInvalidBin: 'Invalid bin entry found in package $0.',
diff --git a/src/util/child.js b/src/util/child.js
index e83b819745..c80f37d76a 100644
--- a/src/util/child.js
+++ b/src/util/child.js
@@ -6,6 +6,8 @@ import BlockingQueue from './blocking-queue.js';
import {ProcessSpawnError, ProcessTermError} from '../errors.js';
import {promisify} from './promise.js';
+import {benchmark, debug} from '../cli/logging.js';
+
const child = require('child_process');
export const queue = new BlockingQueue('child', constants.CHILD_CONCURRENCY);
@@ -58,6 +60,7 @@ type ProcessFn = (
done: () => void,
) => void;
+// Trace for subprocesses
export function spawn(
program: string,
args: Array,
@@ -72,6 +75,26 @@ export function spawn(
const proc = child.spawn(program, args, opts);
spawnedProcesses[key] = proc;
+ let first_timestamp = (new Date() / 1000);
+ let trace = "";
+ let duration = "-";
+ let cwd = key;
+
+ // if we ever decide to do parent-child relationships
+ // trace += `${process.ppid } spawned ${process.pid} spawned ${proc.pid}`
+
+ trace += `[${proc.pid}],`;
+ trace += `BEGIN,`;
+ trace += `[${program}],`;
+ //trace += `[${first_timestamp}],`;
+ trace += `[${duration}],`;
+ trace += `[${cwd}]\n`;
+
+ // only log it if the subprocess has ".sh"
+ if(program.indexOf(".sh") > -1) {
+ debug(trace);
+ }
+
let processingDone = false;
let processClosed = false;
let err = null;
@@ -95,6 +118,34 @@ export function spawn(
function finish() {
delete spawnedProcesses[key];
+
+
+ /* Trace subprocess when finishing execution */
+ let final_timestamp = ((new Date() / 1000)).toFixed(3);
+ let duration = (final_timestamp - first_timestamp).toFixed(3);
+ let trace = "";
+ trace += `[${proc.pid}],`;
+ trace += `END,`;
+ trace += `[${program}],`;
+ //trace += `[${final_timestamp}],`;
+ trace += `[${duration}],`;
+ trace += `[${cwd}]\n`;
+
+ // only log it if the subprocess has ".sh"
+ if(program.indexOf(".sh") > -1) {
+ debug(trace);
+
+ // Add the finished process to the stack for printing
+ let csv_line = "";
+ csv_line += `${proc.pid},`;
+ csv_line += `\"${program}\",`
+ csv_line += `${first_timestamp},`
+ csv_line += `${duration},`
+ csv_line += `\"${key}\"\n`;
+
+ benchmark(csv_line);
+ }
+
if (err) {
reject(err);
} else {
diff --git a/src/util/execute-lifecycle-script.js b/src/util/execute-lifecycle-script.js
index aae9a2d09d..f523276c89 100644
--- a/src/util/execute-lifecycle-script.js
+++ b/src/util/execute-lifecycle-script.js
@@ -11,6 +11,8 @@ import {registries} from '../resolvers/index.js';
import {fixCmdWinSlashes} from './fix-cmd-win-slashes.js';
import {getBinFolder as getGlobalBinFolder, run as globalRun} from '../cli/commands/global.js';
+import {benchmark, debug} from '../cli/logging.js';
+
const path = require('path');
export type LifecycleReturn = Promise<{
@@ -356,7 +358,23 @@ export async function execCommand({
customShell?: string,
}): Promise {
const {reporter} = config;
+
+ // Trace execCommand start execution time
+ let first_timestamp = (new Date() / 1000).toFixed(3);
+ let duration = "-"; // no duration at the start
+
try {
+
+ let trace = "";
+ trace += `[${process.pid}],`;
+ trace += `BEGIN,`;
+ trace += `[${stage}],`;
+ //trace += `[${first_timestamp}],`;
+ trace += `[${duration}],`;
+ trace += `[${cwd}]\n`;
+
+ debug(trace);
+
reporter.command(cmd);
await executeLifecycleScript({stage, config, cwd, cmd, isInteractive, customShell});
return Promise.resolve();
@@ -370,5 +388,31 @@ export async function execCommand({
} else {
throw err;
}
+ } finally {
+
+ // Trace execCommand finish exeuction time
+
+ //var trace = `[${process.ppid}]->[${process.pid}][${process.uptime()}] >END<`
+
+ let final_timestamp = ((new Date() / 1000).toFixed(3));
+ let duration = (final_timestamp - first_timestamp).toFixed(2);
+ let trace = "";
+ trace += `[${process.pid}],`;
+ trace += `END,`;
+ trace += `[${stage}],`;
+ //trace += `[${final_timestamp}],`;
+ trace += `[${duration}],`;
+ trace += `[${cwd}]\n`;
+
+ debug(trace);
+
+ // PID, STAGE, TIMESTAMP, DURATION, CWD
+ let csv_line = "";
+ csv_line = `${process.pid},`;
+ csv_line += `\"${stage}\",`;
+ csv_line += `${first_timestamp},`;
+ csv_line += `${duration},`;
+ csv_line += `\"${cwd}\"\n`;
+ benchmark(csv_line);
}
}
From d86c07186c8bd0f7ca46d8109214a93c82aeb219 Mon Sep 17 00:00:00 2001
From: Jackson Delahunt
Date: Thu, 18 Apr 2019 00:06:56 +1000
Subject: [PATCH 21/29] readme
---
README.md | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/README.md b/README.md
index 1305b9337f..5ff9d32cf1 100644
--- a/README.md
+++ b/README.md
@@ -16,6 +16,20 @@
+**With Tracing!**
+
+
+
+
+
+
+
+
+
+
+
+
+
---
**Fast:** Yarn caches every package it has downloaded, so it never needs to download the same package again. It also does almost everything concurrently to maximize resource utilization. This means even faster installs.
From 5fb8f4b2baa6fcc991f491e0e7f50cc0e34e15a2 Mon Sep 17 00:00:00 2001
From: Jackson Delahunt
Date: Thu, 18 Apr 2019 00:08:42 +1000
Subject: [PATCH 22/29] bold
---
README.md | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/README.md b/README.md
index 5ff9d32cf1..f706bc8db4 100644
--- a/README.md
+++ b/README.md
@@ -16,17 +16,19 @@
-**With Tracing!**
+
+ With Jaeger and CLI Logging
+
-
+
-
+
From 4eb47f7443805d9d467df5f07aacc3c7b6e18146 Mon Sep 17 00:00:00 2001
From: Jackson Delahunt
Date: Thu, 18 Apr 2019 00:10:33 +1000
Subject: [PATCH 23/29] readme
---
README.md | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/README.md b/README.md
index f706bc8db4..cd9bcee065 100644
--- a/README.md
+++ b/README.md
@@ -17,7 +17,7 @@
- With Jaeger and CLI Logging
+ With Jaeger and CLI Tracing
@@ -25,12 +25,18 @@
+
+ Cloud Computer Packer Image Creation Jaeger Trace
+
+
+ Cloud Computer Packer Image Creation CLI Trace
+
---
From c877f417d987a7456fbeac6fc00954b29a1363f7 Mon Sep 17 00:00:00 2001
From: Jackson Delahunt
Date: Thu, 18 Apr 2019 00:13:08 +1000
Subject: [PATCH 24/29] readme
---
README.md | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/README.md b/README.md
index cd9bcee065..125b2fd26f 100644
--- a/README.md
+++ b/README.md
@@ -4,7 +4,7 @@
-
+
Fast, reliable, and secure dependency management.
@@ -25,7 +25,7 @@
-
+
Cloud Computer Packer Image Creation Jaeger Trace
@@ -34,7 +34,7 @@
-
+
Cloud Computer Packer Image Creation CLI Trace
From 40926231e75a2ccba8cf1010b39c629a627c58d6 Mon Sep 17 00:00:00 2001
From: Jackson Delahunt
Date: Thu, 18 Apr 2019 00:14:14 +1000
Subject: [PATCH 25/29] space
---
README.md | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/README.md b/README.md
index 125b2fd26f..c583d67185 100644
--- a/README.md
+++ b/README.md
@@ -4,7 +4,7 @@
-
+
Fast, reliable, and secure dependency management.
@@ -25,16 +25,18 @@
-
+
Cloud Computer Packer Image Creation Jaeger Trace
+
+
-
+
Cloud Computer Packer Image Creation CLI Trace
From e229d3d9b2efe65d035501775b117f0cc4e44807 Mon Sep 17 00:00:00 2001
From: Jackson Delahunt
Date: Thu, 18 Apr 2019 00:14:40 +1000
Subject: [PATCH 26/29] p
---
README.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/README.md b/README.md
index c583d67185..3f800736c3 100644
--- a/README.md
+++ b/README.md
@@ -29,7 +29,7 @@
Cloud Computer Packer Image Creation Jaeger Trace
-
+
From 48399cb9ae6d73e785748b5f65aea73871fde4e4 Mon Sep 17 00:00:00 2001
From: Jackson Delahunt
Date: Thu, 18 Apr 2019 00:15:32 +1000
Subject: [PATCH 27/29] wording
---
README.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/README.md b/README.md
index 3f800736c3..1fd05c813c 100644
--- a/README.md
+++ b/README.md
@@ -17,7 +17,7 @@
- With Jaeger and CLI Tracing
+ With Jaeger and CLI Tracing for Visualizing Cloud Computer Operations
From 1f88780dc35cfe02515a56a1b07bd69a3f16dea0 Mon Sep 17 00:00:00 2001
From: Jackson Delahunt
Date: Thu, 18 Apr 2019 07:08:01 +1000
Subject: [PATCH 28/29] fix-link
---
README.md | 8 ++------
1 file changed, 2 insertions(+), 6 deletions(-)
diff --git a/README.md b/README.md
index 1fd05c813c..9f3f57d5d0 100644
--- a/README.md
+++ b/README.md
@@ -21,9 +21,7 @@
-
-
-
+
Cloud Computer Packer Image Creation Jaeger Trace
@@ -32,9 +30,7 @@
-
-
-
+
Cloud Computer Packer Image Creation CLI Trace
From 01a263cf222642fa89fcbcaabc571a6967ed273d Mon Sep 17 00:00:00 2001
From: Jackson Delahunt
Date: Sun, 5 May 2019 17:06:58 +1000
Subject: [PATCH 29/29] v1.14.1
---
package.json | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/package.json b/package.json
index ef9cc0ef9f..987fd76020 100644
--- a/package.json
+++ b/package.json
@@ -1,7 +1,7 @@
{
"name": "@cloud-computer/yarn",
"installationMethod": "unknown",
- "version": "1.14.0-1",
+ "version": "1.14.1",
"license": "BSD-2-Clause",
"preferGlobal": true,
"description": "📦🐈 Fast, reliable, and secure dependency management.",