diff --git a/.changeset/khaki-carpets-brush.md b/.changeset/khaki-carpets-brush.md new file mode 100644 index 000000000..178da4994 --- /dev/null +++ b/.changeset/khaki-carpets-brush.md @@ -0,0 +1,5 @@ +--- +"create-eth": patch +--- + +cli: show yarn install ouput diff --git a/package.json b/package.json index 95aceb80e..397f30d52 100644 --- a/package.json +++ b/package.json @@ -56,8 +56,7 @@ "inquirer": "9.2.0", "listr2": "^8.2.1", "merge-packages": "^0.1.6", - "ncp": "2.0.0", - "pkg-install": "1.0.0" + "ncp": "2.0.0" }, "packageManager": "yarn@3.5.0" } diff --git a/src/main.ts b/src/main.ts index e746b91ce..6e182d247 100644 --- a/src/main.ts +++ b/src/main.ts @@ -1,9 +1,9 @@ import { copyTemplateFiles, createProjectDirectory, - installPackages, createFirstGitCommit, prettierFormat, + installPackages, } from "./tasks"; import type { Options } from "./types"; import { renderOutroMessage } from "./utils/render-outro-message"; @@ -36,14 +36,18 @@ export async function createProject(options: Options) { task: () => copyTemplateFiles(options, templateDirectory, targetDirectory), }, { - title: `📦 Installing dependencies with yarn, this could take a while`, - task: () => installPackages(targetDirectory), + title: "📦 Installing dependencies with yarn, this could take a while", + task: (_, task) => installPackages(targetDirectory, task), skip: () => { if (!options.install) { return "Manually skipped, since `--skip-install` flag was passed"; } return false; }, + rendererOptions: { + outputBar: 8, + persistentOutput: false, + }, }, { title: "🪄 Formatting files", diff --git a/src/tasks/install-packages.ts b/src/tasks/install-packages.ts index b0add8152..393024d4a 100644 --- a/src/tasks/install-packages.ts +++ b/src/tasks/install-packages.ts @@ -1,8 +1,52 @@ -import { projectInstall } from "pkg-install"; +import { DefaultRenderer, ListrTaskWrapper, SimpleRenderer } from "listr2"; +import { execaCommand } from "execa"; +import chalk from "chalk"; -export function installPackages(targetDir: string) { - return projectInstall({ - cwd: targetDir, - prefer: "yarn", +export async function installPackages( + targetDir: string, + task: ListrTaskWrapper, +) { + const execute = execaCommand("yarn install", { cwd: targetDir }); + + let outputBuffer: string = ""; + + const chunkSize = 1024; + execute?.stdout?.on("data", (data: Buffer) => { + outputBuffer += data.toString(); + + if (outputBuffer.length > chunkSize) { + outputBuffer = outputBuffer.slice(-1 * chunkSize); + } + + const visibleOutput = + outputBuffer + .match(new RegExp(`.{1,${chunkSize}}`, "g")) + ?.slice(-1) + .map(chunk => chunk.trimEnd() + "\n") + .join("") ?? outputBuffer; + + task.output = visibleOutput; + if (visibleOutput.includes("Link step")) { + task.output = chalk.yellow(`starting link step, this might take a little time...`); + } }); + + execute?.stderr?.on("data", (data: Buffer) => { + outputBuffer += data.toString(); + + if (outputBuffer.length > chunkSize) { + outputBuffer = outputBuffer.slice(-1 * chunkSize); + } + + const visibleOutput = + outputBuffer + .match(new RegExp(`.{1,${chunkSize}}`, "g")) + ?.slice(-1) + .map(chunk => chunk.trimEnd() + "\n") + .join("") ?? outputBuffer; + + task.output = visibleOutput; + }); + + await execute; } diff --git a/yarn.lock b/yarn.lock index e0b9f4186..7d12195cc 100644 --- a/yarn.lock +++ b/yarn.lock @@ -488,15 +488,6 @@ __metadata: languageName: node linkType: hard -"@types/execa@npm:^0.9.0": - version: 0.9.0 - resolution: "@types/execa@npm:0.9.0" - dependencies: - "@types/node": "*" - checksum: 4f12e2aec1a2140c33ae9fdda5a12ab0eb6665b20a9ce8e6914db11986f6f5c2ad62d82b207e31dff6b9b071c78e02da6581acc45e2fd0a31e9717a03638ddbd - languageName: node - linkType: hard - "@types/glob@npm:^7.1.1": version: 7.2.0 resolution: "@types/glob@npm:7.2.0" @@ -556,13 +547,6 @@ __metadata: languageName: node linkType: hard -"@types/node@npm:^11.9.4": - version: 11.15.54 - resolution: "@types/node@npm:11.15.54" - checksum: d65c15001070c5df893876bb7637024a1a412d8ccfd803c61b4ee3293aafb85d69e278cd27dc28f66c8d21018d85fa50f93ade0937a187c16c8dad23fb1598d8 - languageName: node - linkType: hard - "@types/node@npm:^12.7.1": version: 12.20.55 resolution: "@types/node@npm:12.20.55" @@ -1312,7 +1296,6 @@ __metadata: listr2: ^8.2.1 merge-packages: ^0.1.6 ncp: 2.0.0 - pkg-install: 1.0.0 prettier: 3.3.2 rollup: 3.21.0 rollup-plugin-auto-external: 2.0.0 @@ -1335,19 +1318,6 @@ __metadata: languageName: node linkType: hard -"cross-spawn@npm:^6.0.0": - version: 6.0.5 - resolution: "cross-spawn@npm:6.0.5" - dependencies: - nice-try: ^1.0.4 - path-key: ^2.0.1 - semver: ^5.5.0 - shebang-command: ^1.2.0 - which: ^1.2.9 - checksum: f893bb0d96cd3d5751d04e67145bdddf25f99449531a72e82dcbbd42796bbc8268c1076c6b3ea51d4d455839902804b94bc45dfb37ecbb32ea8e54a6741c3ab9 - languageName: node - linkType: hard - "cross-spawn@npm:^7.0.2, cross-spawn@npm:^7.0.3": version: 7.0.3 resolution: "cross-spawn@npm:7.0.3" @@ -1521,15 +1491,6 @@ __metadata: languageName: node linkType: hard -"end-of-stream@npm:^1.1.0": - version: 1.4.4 - resolution: "end-of-stream@npm:1.4.4" - dependencies: - once: ^1.4.0 - checksum: 530a5a5a1e517e962854a31693dbb5c0b2fc40b46dad2a56a2deec656ca040631124f4795823acc68238147805f8b021abbe221f4afed5ef3c8e8efc2024908b - languageName: node - linkType: hard - "enquirer@npm:^2.3.0": version: 2.4.1 resolution: "enquirer@npm:2.4.1" @@ -1852,21 +1813,6 @@ __metadata: languageName: node linkType: hard -"execa@npm:^1.0.0": - version: 1.0.0 - resolution: "execa@npm:1.0.0" - dependencies: - cross-spawn: ^6.0.0 - get-stream: ^4.0.0 - is-stream: ^1.1.0 - npm-run-path: ^2.0.0 - p-finally: ^1.0.0 - signal-exit: ^3.0.0 - strip-eof: ^1.0.0 - checksum: ddf1342c1c7d02dd93b41364cd847640f6163350d9439071abf70bf4ceb1b9b2b2e37f54babb1d8dc1df8e0d8def32d0e81e74a2e62c3e1d70c303eb4c306bc4 - languageName: node - linkType: hard - "extendable-error@npm:^0.1.5": version: 0.1.7 resolution: "extendable-error@npm:0.1.7" @@ -2169,15 +2115,6 @@ __metadata: languageName: node linkType: hard -"get-stream@npm:^4.0.0": - version: 4.1.0 - resolution: "get-stream@npm:4.1.0" - dependencies: - pump: ^3.0.0 - checksum: 443e1914170c15bd52ff8ea6eff6dfc6d712b031303e36302d2778e3de2506af9ee964d6124010f7818736dcfde05c04ba7ca6cc26883106e084357a17ae7d73 - languageName: node - linkType: hard - "get-stream@npm:^6.0.1": version: 6.0.1 resolution: "get-stream@npm:6.0.1" @@ -2774,13 +2711,6 @@ __metadata: languageName: node linkType: hard -"is-stream@npm:^1.1.0": - version: 1.1.0 - resolution: "is-stream@npm:1.1.0" - checksum: 063c6bec9d5647aa6d42108d4c59723d2bd4ae42135a2d4db6eadbd49b7ea05b750fd69d279e5c7c45cf9da753ad2c00d8978be354d65aa9f6bb434969c6a2ae - languageName: node - linkType: hard - "is-stream@npm:^3.0.0": version: 3.0.0 resolution: "is-stream@npm:3.0.0" @@ -3510,13 +3440,6 @@ __metadata: languageName: node linkType: hard -"nice-try@npm:^1.0.4": - version: 1.0.5 - resolution: "nice-try@npm:1.0.5" - checksum: 0b4af3b5bb5d86c289f7a026303d192a7eb4417231fe47245c460baeabae7277bcd8fd9c728fb6bd62c30b3e15cd6620373e2cf33353b095d8b403d3e8a15aff - languageName: node - linkType: hard - "node-gyp@npm:latest": version: 9.3.1 resolution: "node-gyp@npm:9.3.1" @@ -3560,15 +3483,6 @@ __metadata: languageName: node linkType: hard -"npm-run-path@npm:^2.0.0": - version: 2.0.2 - resolution: "npm-run-path@npm:2.0.2" - dependencies: - path-key: ^2.0.0 - checksum: acd5ad81648ba4588ba5a8effb1d98d2b339d31be16826a118d50f182a134ac523172101b82eab1d01cb4c2ba358e857d54cfafd8163a1ffe7bd52100b741125 - languageName: node - linkType: hard - "npm-run-path@npm:^5.1.0": version: 5.1.0 resolution: "npm-run-path@npm:5.1.0" @@ -3616,7 +3530,7 @@ __metadata: languageName: node linkType: hard -"once@npm:^1.3.0, once@npm:^1.3.1, once@npm:^1.4.0": +"once@npm:^1.3.0": version: 1.4.0 resolution: "once@npm:1.4.0" dependencies: @@ -3697,13 +3611,6 @@ __metadata: languageName: node linkType: hard -"p-finally@npm:^1.0.0": - version: 1.0.0 - resolution: "p-finally@npm:1.0.0" - checksum: 93a654c53dc805dd5b5891bab16eb0ea46db8f66c4bfd99336ae929323b1af2b70a8b0654f8f1eae924b2b73d037031366d645f1fd18b3d30cbd15950cc4b1d4 - languageName: node - linkType: hard - "p-limit@npm:^2.2.0": version: 2.3.0 resolution: "p-limit@npm:2.3.0" @@ -3808,13 +3715,6 @@ __metadata: languageName: node linkType: hard -"path-key@npm:^2.0.0, path-key@npm:^2.0.1": - version: 2.0.1 - resolution: "path-key@npm:2.0.1" - checksum: f7ab0ad42fe3fb8c7f11d0c4f849871e28fbd8e1add65c370e422512fc5887097b9cf34d09c1747d45c942a8c1e26468d6356e2df3f740bf177ab8ca7301ebfd - languageName: node - linkType: hard - "path-key@npm:^3.1.0": version: 3.1.1 resolution: "path-key@npm:3.1.1" @@ -3882,17 +3782,6 @@ __metadata: languageName: node linkType: hard -"pkg-install@npm:1.0.0": - version: 1.0.0 - resolution: "pkg-install@npm:1.0.0" - dependencies: - "@types/execa": ^0.9.0 - "@types/node": ^11.9.4 - execa: ^1.0.0 - checksum: b23cb477760e76795b3e27f61235c08c0c7ff7a215d2fac89540eaf49ff8573177fd76e684a10e7ab417c528e5d50da445c20cbf1fee4143302315366f23fe8d - languageName: node - linkType: hard - "preferred-pm@npm:^3.0.0": version: 3.0.3 resolution: "preferred-pm@npm:3.0.3" @@ -3963,16 +3852,6 @@ __metadata: languageName: node linkType: hard -"pump@npm:^3.0.0": - version: 3.0.0 - resolution: "pump@npm:3.0.0" - dependencies: - end-of-stream: ^1.1.0 - once: ^1.3.1 - checksum: e42e9229fba14732593a718b04cb5e1cfef8254544870997e0ecd9732b189a48e1256e4e5478148ecb47c8511dca2b09eae56b4d0aad8009e6fac8072923cfc9 - languageName: node - linkType: hard - "punycode@npm:^2.1.0": version: 2.3.1 resolution: "punycode@npm:2.3.1" @@ -4367,7 +4246,7 @@ __metadata: languageName: node linkType: hard -"signal-exit@npm:^3.0.0, signal-exit@npm:^3.0.2, signal-exit@npm:^3.0.7": +"signal-exit@npm:^3.0.2, signal-exit@npm:^3.0.7": version: 3.0.7 resolution: "signal-exit@npm:3.0.7" checksum: a2f098f247adc367dffc27845853e9959b9e88b01cb301658cfe4194352d8d2bb32e18467c786a7fe15f1d44b233ea35633d076d5e737870b7139949d1ab6318 @@ -4655,13 +4534,6 @@ __metadata: languageName: node linkType: hard -"strip-eof@npm:^1.0.0": - version: 1.0.0 - resolution: "strip-eof@npm:1.0.0" - checksum: 40bc8ddd7e072f8ba0c2d6d05267b4e0a4800898c3435b5fb5f5a21e6e47dfaff18467e7aa0d1844bb5d6274c3097246595841fbfeb317e541974ee992cac506 - languageName: node - linkType: hard - "strip-final-newline@npm:^3.0.0": version: 3.0.0 resolution: "strip-final-newline@npm:3.0.0"