Skip to content

Commit 70f2f9d

Browse files
authored
Merge branch 'main' into pf-3928
2 parents 33e2dd6 + 2762694 commit 70f2f9d

3 files changed

Lines changed: 53 additions & 6 deletions

File tree

scripts/install.sh

Lines changed: 48 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22
# Install Node (via nvm + Node.js 24 when Node is missing), enable Corepack,
33
# install GitHub CLI when missing, and install @patternfly/patternfly-cli globally.
44

5+
# Ensure this script runs in bash, even if invoked with zsh
6+
if [ -z "${BASH_VERSION:-}" ]; then
7+
exec bash "$0" "$@"
8+
fi
9+
510
set -euo pipefail
611

712
if [ -z "${HOME:-}" ]; then
@@ -48,6 +53,40 @@ ensure_nvm_loaded() {
4853
return 1
4954
}
5055

56+
setup_nvm_for_zsh() {
57+
# Add nvm to .zshrc only if zsh is the user's default shell
58+
if [ -z "${SHELL:-}" ]; then
59+
return 0
60+
fi
61+
62+
case "$SHELL" in
63+
*/zsh)
64+
;;
65+
*)
66+
return 0
67+
;;
68+
esac
69+
70+
local zshrc="${HOME}/.zshrc"
71+
if [ ! -f "$zshrc" ]; then
72+
touch "$zshrc"
73+
fi
74+
75+
if grep -q 'NVM_DIR' "$zshrc" 2>/dev/null; then
76+
info "nvm is already configured in ${zshrc}"
77+
return 0
78+
fi
79+
80+
info "Adding nvm to ${zshrc} for zsh compatibility."
81+
cat >> "$zshrc" << 'EOF'
82+
83+
# Load nvm (Node Version Manager)
84+
export NVM_DIR="$HOME/.nvm"
85+
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
86+
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"
87+
EOF
88+
}
89+
5190
install_node_via_nvm() {
5291
info "Node.js not found. Installing nvm (${NVM_VERSION}) and Node.js 24."
5392
if ! require_cmd curl && ! require_cmd wget; then
@@ -71,6 +110,8 @@ install_node_via_nvm() {
71110
nvm use 24 || error "nvm failed to activate Node.js 24."
72111
nvm alias default 24 2>/dev/null || true
73112

113+
setup_nvm_for_zsh
114+
74115
info "Node.js $(node --version) and npm $(npm --version) are ready (npm ships with this Node release)."
75116
}
76117

@@ -245,16 +286,21 @@ main() {
245286
ensure_gh
246287
install_patternfly_cli
247288

289+
printf '\n'
290+
printf 'SUCCESS: PatternFly CLI is installed.\n'
291+
printf '\n'
248292
printf 'To see available commands, run the CLI with:\n'
249293
printf ' patternfly-cli --help\n'
250294
printf '\n'
251295
printf 'Alternatively, you can use the alias "pfcli" instead of "patternfly-cli"\n'
252296
printf '\n'
253297
printf ' pfcli --help\n'
254298
printf '\n'
255-
printf 'SUCCESS: PatternFly CLI is installed.\n'
299+
printf 'NOTE: If the command is not found, restart your terminal or run:\n'
300+
printf ' source ~/.zshrc # for zsh users\n'
301+
printf ' source ~/.bashrc # for bash users\n'
256302
printf '\n'
257-
303+
258304
}
259305

260306
main "$@"

src/__tests__/create.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ describe('runCreate', () => {
152152
expect(mockExeca).toHaveBeenNthCalledWith(
153153
1,
154154
'git',
155-
['clone', starter!.repo, projectPath],
155+
['clone', ...(starter!.options ?? []), starter!.repo, projectPath],
156156
expect.objectContaining({ stdio: 'inherit' })
157157
);
158158
});
@@ -166,7 +166,7 @@ describe('runCreate', () => {
166166
expect(mockExeca).toHaveBeenNthCalledWith(
167167
1,
168168
'git',
169-
['clone', starter!.repoSSH, projectPath],
169+
['clone', ...(starter!.options ?? []), starter!.repoSSH, projectPath],
170170
expect.objectContaining({ stdio: 'inherit' })
171171
);
172172
});
@@ -225,7 +225,7 @@ describe('runCreate', () => {
225225

226226
expect(mockExeca).toHaveBeenNthCalledWith(
227227
2,
228-
'yarn',
228+
'npm',
229229
['install'],
230230
expect.objectContaining({ cwd: projectPath, stdio: 'inherit' })
231231
);

src/templates.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ export const defaultTemplates: Template[] = [
1919
description: "A starter template for Patternfly react typescript project",
2020
repo: "https://github.com/patternfly/patternfly-react-seed.git",
2121
repoSSH: "git@github.com:patternfly/patternfly-react-seed.git",
22-
packageManager: "yarn"
22+
options: ["--single-branch", "--branch", "main"],
23+
packageManager: "npm"
2324
},
2425
{
2526
name: "compass-starter",

0 commit comments

Comments
 (0)