Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: make output reflect user's choice of package manager #10811

Merged
merged 29 commits into from
Oct 4, 2023
Merged
Changes from 24 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
449a7b0
create-svelte: dynamic package manager
the-r3aper7 Sep 29, 2023
4d47777
lint
the-r3aper7 Sep 29, 2023
8c76e81
the-r3aper7 Oct 4, 2023
61492a5
🎉
the-r3aper7 Oct 4, 2023
92546cc
Update packages/create-svelte/utils.js
benmccann Oct 4, 2023
e56072c
Update packages/create-svelte/utils.js
benmccann Oct 4, 2023
fa5b10b
Update packages/create-svelte/utils.js
benmccann Oct 4, 2023
7db262a
Update packages/create-svelte/bin.js
benmccann Oct 4, 2023
d8bf507
Update packages/create-svelte/bin.js
benmccann Oct 4, 2023
52920b4
Update packages/create-svelte/bin.js
benmccann Oct 4, 2023
634517a
Update packages/create-svelte/bin.js
benmccann Oct 4, 2023
16785b5
Update packages/create-svelte/utils.js
benmccann Oct 4, 2023
91dee6d
Create gold-radios-argue.md
benmccann Oct 4, 2023
4ef2ad5
Update packages/create-svelte/utils.js
benmccann Oct 4, 2023
f99a8b9
Update packages/create-svelte/utils.js
benmccann Oct 4, 2023
e868353
Update packages/create-svelte/utils.js
benmccann Oct 4, 2023
cd9e798
Update packages/create-svelte/bin.js
benmccann Oct 4, 2023
c4af3be
Update packages/create-svelte/utils.js
benmccann Oct 4, 2023
6828096
Update packages/create-svelte/bin.js
benmccann Oct 4, 2023
35ee899
Update packages/create-svelte/bin.js
benmccann Oct 4, 2023
ed15029
Update packages/create-svelte/utils.js
benmccann Oct 4, 2023
16db722
🎀
the-r3aper7 Oct 4, 2023
1aeea87
🎇
the-r3aper7 Oct 4, 2023
4073b16
Update packages/create-svelte/utils.js
benmccann Oct 4, 2023
76a915f
Update packages/create-svelte/utils.js
benmccann Oct 4, 2023
8b3b2f8
Update packages/create-svelte/utils.js
benmccann Oct 4, 2023
17bdc95
Update packages/create-svelte/bin.js
benmccann Oct 4, 2023
9efab59
Update packages/create-svelte/bin.js
benmccann Oct 4, 2023
2dffc11
Update packages/create-svelte/bin.js
benmccann Oct 4, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/gold-radios-argue.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"create-svelte": patch
---

feat: make output reflect user's choice of package manager
6 changes: 3 additions & 3 deletions packages/create-svelte/bin.js
Original file line number Diff line number Diff line change
@@ -4,7 +4,7 @@ import path from 'node:path';
import * as p from '@clack/prompts';
import { bold, cyan, grey, yellow } from 'kleur/colors';
import { create } from './index.js';
import { dist } from './utils.js';
import { dist, package_manger } from './utils.js';

const { version } = JSON.parse(fs.readFileSync(new URL('package.json', import.meta.url), 'utf-8'));
let cwd = process.argv[2] || '.';
@@ -161,10 +161,10 @@ if (relative !== '') {
console.log(` ${i++}: ${bold(cyan(`cd ${relative}`))}`);
}

console.log(` ${i++}: ${bold(cyan('npm install'))} (or pnpm install, etc)`);
console.log(` ${i++}: ${bold(cyan(`${package_manger} install`))}`);
// prettier-ignore
console.log(` ${i++}: ${bold(cyan('git init && git add -A && git commit -m "Initial commit"'))} (optional)`);
console.log(` ${i++}: ${bold(cyan('npm run dev -- --open'))}`);
console.log(` ${i++}: ${bold(cyan(`${package_manger} run dev -- --open`))}`);

console.log(`\nTo close the dev server, hit ${bold(cyan('Ctrl-C'))}`);
console.log(`\nStuck? Visit us at ${cyan('https://svelte.dev/chat')}`);
14 changes: 14 additions & 0 deletions packages/create-svelte/utils.js
Original file line number Diff line number Diff line change
@@ -49,3 +49,17 @@ export function copy(from, to, rename = identity) {
export function dist(path) {
return fileURLToPath(new URL(`./dist/${path}`, import.meta.url).href);
}

export const package_manger = get_package_manager();

// Thanks to https://github.com/zkochan/packages/tree/main/which-pm-runs for this code!
function get_package_manager() {
if (!process.env.npm_config_user_agent) {
return undefined;
}
const user_agent = process.env.npm_config_user_agent;
const pm_spec = user_agent.split(' ')[0];
const separator_pos = pm_spec.lastIndexOf('/');
const name = pm_spec.substring(0, separator_pos);
return name === 'npminstall' ? 'cnpm' : name;
}