From 33d3a7ee39bb31b60e9f16f87e0167cc772d9488 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nenad=20Vi=C4=87enti=C4=87?= Date: Fri, 25 Nov 2022 18:16:12 +0100 Subject: [PATCH 1/3] Switch yarn 2+ to backward compatibility mode, to avoid IDE and package manager issue with Yarn PnP mode. --- common/.yarnrc.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/common/.yarnrc.yml b/common/.yarnrc.yml index 279aafe..b571dc0 100644 --- a/common/.yarnrc.yml +++ b/common/.yarnrc.yml @@ -1,3 +1,2 @@ -# For compatibility in yarn 2 -pnpMode: loose -pnpFallbackMode: all +# For compatibility in yarn 2+ +nodeLinker: node-modules From 6d719e9c5a5e52531ee18a0590808b38b732b68d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nenad=20Vi=C4=87enti=C4=87?= Date: Fri, 25 Nov 2022 18:20:31 +0100 Subject: [PATCH 2/3] Display name of a correct package manager (npm, yarn or pnpm - the one that has previously been choosen to install packages) in `Get Started` instruction. --- __test__/after-task.spec.js | 86 +++++++++++++++++++++++++++++++++++-- after.js | 19 +++++--- 2 files changed, 95 insertions(+), 10 deletions(-) diff --git a/__test__/after-task.spec.js b/__test__/after-task.spec.js index a77cdb2..7bff727 100644 --- a/__test__/after-task.spec.js +++ b/__test__/after-task.spec.js @@ -6,7 +6,7 @@ ansiColors.inverse = ansiColors; ansiColors.underline = ansiColors; ansiColors.bold = ansiColors; -const isAvailable = bin => bin === 'yarn'; +const isAvailable = bin => bin === 'yarn' || bin === 'pnpm'; test('"after" task only prints summary in unattended mode', async t => { const prompts = { @@ -79,10 +79,49 @@ test('"after" task only prints summary in unattended mode and here mode', async ); }); -test('"after" task installs deps, and prints summary', async t => { +test('"after" task installs deps with npm, and prints summary', async t => { const prompts = { select(opts) { - t.deepEqual(opts.choices.map(c => c.value), [undefined, 'npm', 'yarn']); + t.deepEqual(opts.choices.map(c => c.value), [undefined, 'npm', 'yarn', 'pnpm']); + return 'npm'; + } + }; + + function run(cmd, args) { + t.is(cmd, 'npm'); + t.deepEqual(args, ['install']); + } + + let printOut = ''; + await after({ + unattended: false, + here: false, + prompts, + run, + properties: {name: 'my-app'}, + features: ['a', 'b'], + notDefaultFeatures: ['a', 'b-c'], + ansiColors + }, { + _isAvailable: isAvailable, + _log(m) { + printOut += m + '\n'; + } + }); + + t.is(printOut, + '\nNext time, you can try to create similar project in silent mode:\n' + + ' npx makes aurelia new-project-name -s a,b-c \n\n' + + 'Get Started\n' + + 'cd my-app\n' + + 'npm start\n\n' + ); +}); + +test('"after" task installs deps with yarn, and prints summary', async t => { + const prompts = { + select(opts) { + t.deepEqual(opts.choices.map(c => c.value), [undefined, 'npm', 'yarn', 'pnpm']); return 'yarn'; } }; @@ -114,7 +153,46 @@ test('"after" task installs deps, and prints summary', async t => { ' npx makes aurelia new-project-name -s a,b-c \n\n' + 'Get Started\n' + 'cd my-app\n' + - 'npm start\n\n' + 'yarn start\n\n' + ); +}); + +test('"after" task installs deps with pnpm, and prints summary', async t => { + const prompts = { + select(opts) { + t.deepEqual(opts.choices.map(c => c.value), [undefined, 'npm', 'yarn', 'pnpm']); + return 'pnpm'; + } + }; + + function run(cmd, args) { + t.is(cmd, 'pnpm'); + t.deepEqual(args, ['install']); + } + + let printOut = ''; + await after({ + unattended: false, + here: false, + prompts, + run, + properties: {name: 'my-app'}, + features: ['a', 'b'], + notDefaultFeatures: ['a', 'b-c'], + ansiColors + }, { + _isAvailable: isAvailable, + _log(m) { + printOut += m + '\n'; + } + }); + + t.is(printOut, + '\nNext time, you can try to create similar project in silent mode:\n' + + ' npx makes aurelia new-project-name -s a,b-c \n\n' + + 'Get Started\n' + + 'cd my-app\n' + + 'pnpm start\n\n' ); }); diff --git a/after.js b/after.js index d5ce50b..1f4a740 100644 --- a/after.js +++ b/after.js @@ -20,6 +20,7 @@ module.exports = async function({ } = {}) { const c = ansiColors; let depsInstalled = false; + let packageManager = undefined; if (!unattended) { const choices = [ @@ -28,22 +29,27 @@ module.exports = async function({ ]; if (_isAvailable('yarn')) { - choices.push({value: 'yarn', title: 'Yes, use yarn'}); + choices.push({value: 'yarn', title: 'Yes, use yarn (node-modules)'}); } if (_isAvailable('pnpm')) { choices.push({value: 'pnpm', title: 'Yes, use pnpm'}); } - const result = await prompts.select({ + packageManager = await prompts.select({ message: 'Do you want to install npm dependencies now?', choices }); - if (result) { - await run(result, ['install']); + if (packageManager) { + await run(packageManager, ['install']); + if (features.includes('playwright')) { - await run('npx', ['playwright', 'install', '--with-deps']); + if (packageManager === 'npm') { + await run('npx', ['playwright', 'install', '--with-deps']); + } else { + await run(packageManager, ['dlx', 'playwright', 'install', '--with-deps']); + } } depsInstalled = true; } @@ -54,9 +60,10 @@ module.exports = async function({ _log(`\n${c.underline.bold('Get Started')}`); if (!here) _log('cd ' + properties.name); + if (!depsInstalled) { _log('npm install'); if (features.includes('playwright')) _log('npx playwright install --with-deps'); } - _log('npm start\n'); + _log((packageManager ?? 'npm') + ' start\n'); }; From 11164d8e4ca53403aaa260d3f9993de0e8eca8ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nenad=20Vi=C4=87enti=C4=87?= Date: Fri, 25 Nov 2022 18:27:56 +0100 Subject: [PATCH 3/3] Turn pnpm error "ERR_PNPM_PEER_DEP_ISSUES" into warning "Issues with peer dependencies found". (Due to "missing peer @parcel/core@^2.8.0") --- common/.npmrc | 1 + 1 file changed, 1 insertion(+) diff --git a/common/.npmrc b/common/.npmrc index ec497bf..8d0e516 100644 --- a/common/.npmrc +++ b/common/.npmrc @@ -1,2 +1,3 @@ # for pnpm, use flat node_modules shamefully-hoist=true +strict-peer-dependencies=false