Skip to content

Commit

Permalink
Update run.fish so it is more interactive
Browse files Browse the repository at this point in the history
Ask the user if they would like to run npm serve docs/
after the new site is done building
  • Loading branch information
nazmulidris committed Feb 13, 2024
1 parent eefb866 commit 2bf9d1e
Show file tree
Hide file tree
Showing 6 changed files with 153 additions and 75 deletions.
4 changes: 2 additions & 2 deletions docs/authors/nadiaidris/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@
<meta property="og:url" content="http://developerlife.com/authors/nadiaidris/" />
<meta property="og:site_name" content="developerlife.com" />
<meta property="og:type" content="article" />
<meta property="article:published_time" content="2024-02-11T10:36:08-06:00" />
<meta property="article:published_time" content="2024-02-13T16:51:51-06:00" />
<meta name="twitter:card" content="summary" />
<meta property="twitter:title" content="Nadiaidris" />
<script type="application/ld+json">
{"@context":"https://schema.org","@type":"BlogPosting","author":{"@type":"Person","name":"Nazmul Idris"},"dateModified":"2024-02-11T10:36:08-06:00","datePublished":"2024-02-11T10:36:08-06:00","description":"Nadia is a product designer turned web engineer specializing in TypeScript and React.","headline":"Nadiaidris","mainEntityOfPage":{"@type":"WebPage","@id":"http://developerlife.com/authors/nadiaidris/"},"url":"http://developerlife.com/authors/nadiaidris/"}</script>
{"@context":"https://schema.org","@type":"BlogPosting","author":{"@type":"Person","name":"Nazmul Idris"},"dateModified":"2024-02-13T16:51:51-06:00","datePublished":"2024-02-13T16:51:51-06:00","description":"Nadia is a product designer turned web engineer specializing in TypeScript and React.","headline":"Nadiaidris","mainEntityOfPage":{"@type":"WebPage","@id":"http://developerlife.com/authors/nadiaidris/"},"url":"http://developerlife.com/authors/nadiaidris/"}</script>
<!-- End Jekyll SEO tag -->
<link rel="stylesheet" href="/assets/main.css" />

Expand Down
4 changes: 2 additions & 2 deletions docs/authors/nazmulidris/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@
<meta property="og:url" content="http://developerlife.com/authors/nazmulidris/" />
<meta property="og:site_name" content="developerlife.com" />
<meta property="og:type" content="article" />
<meta property="article:published_time" content="2024-02-11T10:36:08-06:00" />
<meta property="article:published_time" content="2024-02-13T16:51:51-06:00" />
<meta name="twitter:card" content="summary" />
<meta property="twitter:title" content="Nazmulidris" />
<script type="application/ld+json">
{"@context":"https://schema.org","@type":"BlogPosting","author":{"@type":"Person","name":"Nazmul Idris"},"dateModified":"2024-02-11T10:36:08-06:00","datePublished":"2024-02-11T10:36:08-06:00","description":"Nazmul is a software engineer focused on Rust, TUI, Web, and Android technologies.","headline":"Nazmulidris","mainEntityOfPage":{"@type":"WebPage","@id":"http://developerlife.com/authors/nazmulidris/"},"url":"http://developerlife.com/authors/nazmulidris/"}</script>
{"@context":"https://schema.org","@type":"BlogPosting","author":{"@type":"Person","name":"Nazmul Idris"},"dateModified":"2024-02-13T16:51:51-06:00","datePublished":"2024-02-13T16:51:51-06:00","description":"Nazmul is a software engineer focused on Rust, TUI, Web, and Android technologies.","headline":"Nazmulidris","mainEntityOfPage":{"@type":"WebPage","@id":"http://developerlife.com/authors/nazmulidris/"},"url":"http://developerlife.com/authors/nazmulidris/"}</script>
<!-- End Jekyll SEO tag -->
<link rel="stylesheet" href="/assets/main.css" />

Expand Down
2 changes: 1 addition & 1 deletion docs/feed.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom" ><generator uri="https://jekyllrb.com/" version="4.3.3">Jekyll</generator><link href="http://developerlife.com/feed.xml" rel="self" type="application/atom+xml" /><link href="http://developerlife.com/" rel="alternate" type="text/html" /><updated>2024-02-11T10:36:08-06:00</updated><id>http://developerlife.com/feed.xml</id><title type="html">developerlife.com</title><subtitle>Rust, TUI, Android, Web, Desktop, Cloud technologies, and UX engineering and design tutorials.</subtitle><author><name>Nazmul Idris</name></author><entry><title type="html">Write a simple netcat client and server in Rust</title><link href="http://developerlife.com/2024/01/13/write-simple-netcat-in-rust/" rel="alternate" type="text/html" title="Write a simple netcat client and server in Rust" /><published>2024-01-13T09:00:00-06:00</published><updated>2024-01-13T09:00:00-06:00</updated><id>http://developerlife.com/2024/01/13/write-simple-netcat-in-rust</id><content type="html" xml:base="http://developerlife.com/2024/01/13/write-simple-netcat-in-rust/"><![CDATA[<p><img class="post-hero-image" src="/assets/netcat-hero.svg" /></p>
<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom" ><generator uri="https://jekyllrb.com/" version="4.3.3">Jekyll</generator><link href="http://developerlife.com/feed.xml" rel="self" type="application/atom+xml" /><link href="http://developerlife.com/" rel="alternate" type="text/html" /><updated>2024-02-13T16:51:51-06:00</updated><id>http://developerlife.com/feed.xml</id><title type="html">developerlife.com</title><subtitle>Rust, TUI, Android, Web, Desktop, Cloud technologies, and UX engineering and design tutorials.</subtitle><author><name>Nazmul Idris</name></author><entry><title type="html">Write a simple netcat client and server in Rust</title><link href="http://developerlife.com/2024/01/13/write-simple-netcat-in-rust/" rel="alternate" type="text/html" title="Write a simple netcat client and server in Rust" /><published>2024-01-13T09:00:00-06:00</published><updated>2024-01-13T09:00:00-06:00</updated><id>http://developerlife.com/2024/01/13/write-simple-netcat-in-rust</id><content type="html" xml:base="http://developerlife.com/2024/01/13/write-simple-netcat-in-rust/"><![CDATA[<p><img class="post-hero-image" src="/assets/netcat-hero.svg" /></p>

<!-- TOC -->

Expand Down
107 changes: 73 additions & 34 deletions docs/run.fish
Original file line number Diff line number Diff line change
Expand Up @@ -18,50 +18,89 @@ function isPackageInstalled -a packageName
echo $packageIsInstalled
end

if test -e Gemfile.lock
rm Gemfile.lock
# More info on prompting a user for confirmation using fish read function: https://stackoverflow.com/a/16673745/2085356
# More info about fish `read` function: https://fishshell.com/docs/current/cmds/read.html
function _promptUserForConfirmation -a message
if not test -z "$message"
echo (set_color brmagenta)"🤔 $message?"
end

while true
# read -l -P '🔴 Do you want to continue? [y/N] ' confirm
read -l -p "set_color brcyan; echo '🔴 Do you want to continue? [y/N] ' ; set_color normal; echo '> '" confirm
switch $confirm
case Y y
return 0
case '' N n
return 1
end
end
end

# More info to find if a package is installed: https://askubuntu.com/a/823630/872482
if test (uname) = Linux
function main
if test -e Gemfile.lock
rm Gemfile.lock
end

if string match -q false (isPackageInstalled ruby-dev);
or string match -q false (isPackageInstalled ruby-bundler)
echo "Install ruby"
echo "ruby-bundler or ruby-dev are not installed; installing now..."
sudo apt install -y ruby-bundler ruby-dev
# On Linux.
if test (uname) = Linux
# More info to find if a package is installed: https://askubuntu.com/a/823630/872482
if string match -q false (isPackageInstalled ruby-dev);
or string match -q false (isPackageInstalled ruby-bundler)
echo "Install ruby"
echo "ruby-bundler or ruby-dev are not installed; installing now..."
sudo apt install -y ruby-bundler ruby-dev
end
end

end
# On macOS.
if test (uname) = Darwin
brew install ruby
fish_add_path /opt/homebrew/opt/ruby/bin
echo Ruby version: (ruby -v)
end

if test (uname) = Darwin
fish_add_path /opt/homebrew/opt/ruby/bin
end
echo "Install Jekyll and dependencies."
bundle install
bundle update

echo "Run the server"
bundle install
bundle update
if test -d _site/
rm -rf _site/
end

if test -d _site/
rm -rf _site/
end
if test -d docs/
rm -rf docs/
end

if test -d docs/
rm -rf docs/
end
echo "Build the site."
# Generate the site (in the _site/ folder)
bundle exec jekyll build

# Move _site folder to docs/ folder
mv _site/ docs/

# Copy CNAME file to docs/ folder.
cp CNAME docs/

# Generate the site (in the _site folder)
bundle exec jekyll build
if _promptUserForConfirmation "Do you want to run the local dev server"
npm install -g serve
serve docs/
else
echo "Ok, bye!"
return
end

# Move _site folder to /docs folder
mv _site/ docs/

# Run the local dev server (this will hardcode all the links to be localhost:4000)
# bundle exec jekyll serve
# Run the local dev server (this will hardcode all the links to be localhost:4000)
# bundle exec jekyll serve

# Old stuff.
# Jekyll install instructions: http://tinyurl.com/y2vbgyqz
# jekyll serve --config _config_dev.yml
# More info: http://tinyurl.com/yytw8hus
# gem install bundler
# bundle update --bundler
end

# Old stuff.
# Jekyll install instructions: http://tinyurl.com/y2vbgyqz
# jekyll serve --config _config_dev.yml
# More info: http://tinyurl.com/yytw8hus
# gem install bundler
# bundle update --bundler
# Actually call the main function.
main
4 changes: 2 additions & 2 deletions docs/sitemap.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
<urlset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd" xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<url>
<loc>http://developerlife.com/authors/nadiaidris/</loc>
<lastmod>2024-02-11T10:36:08-06:00</lastmod>
<lastmod>2024-02-13T16:51:51-06:00</lastmod>
</url>
<url>
<loc>http://developerlife.com/authors/nazmulidris/</loc>
<lastmod>2024-02-11T10:36:08-06:00</lastmod>
<lastmod>2024-02-13T16:51:51-06:00</lastmod>
</url>
<url>
<loc>http://developerlife.com/1998/12/01/xml-and-java-tutorial-part-1/</loc>
Expand Down
107 changes: 73 additions & 34 deletions run.fish
Original file line number Diff line number Diff line change
Expand Up @@ -18,50 +18,89 @@ function isPackageInstalled -a packageName
echo $packageIsInstalled
end

if test -e Gemfile.lock
rm Gemfile.lock
# More info on prompting a user for confirmation using fish read function: https://stackoverflow.com/a/16673745/2085356
# More info about fish `read` function: https://fishshell.com/docs/current/cmds/read.html
function _promptUserForConfirmation -a message
if not test -z "$message"
echo (set_color brmagenta)"🤔 $message?"
end

while true
# read -l -P '🔴 Do you want to continue? [y/N] ' confirm
read -l -p "set_color brcyan; echo '🔴 Do you want to continue? [y/N] ' ; set_color normal; echo '> '" confirm
switch $confirm
case Y y
return 0
case '' N n
return 1
end
end
end

# More info to find if a package is installed: https://askubuntu.com/a/823630/872482
if test (uname) = Linux
function main
if test -e Gemfile.lock
rm Gemfile.lock
end

if string match -q false (isPackageInstalled ruby-dev);
or string match -q false (isPackageInstalled ruby-bundler)
echo "Install ruby"
echo "ruby-bundler or ruby-dev are not installed; installing now..."
sudo apt install -y ruby-bundler ruby-dev
# On Linux.
if test (uname) = Linux
# More info to find if a package is installed: https://askubuntu.com/a/823630/872482
if string match -q false (isPackageInstalled ruby-dev);
or string match -q false (isPackageInstalled ruby-bundler)
echo "Install ruby"
echo "ruby-bundler or ruby-dev are not installed; installing now..."
sudo apt install -y ruby-bundler ruby-dev
end
end

end
# On macOS.
if test (uname) = Darwin
brew install ruby
fish_add_path /opt/homebrew/opt/ruby/bin
echo Ruby version: (ruby -v)
end

if test (uname) = Darwin
fish_add_path /opt/homebrew/opt/ruby/bin
end
echo "Install Jekyll and dependencies."
bundle install
bundle update

echo "Run the server"
bundle install
bundle update
if test -d _site/
rm -rf _site/
end

if test -d _site/
rm -rf _site/
end
if test -d docs/
rm -rf docs/
end

if test -d docs/
rm -rf docs/
end
echo "Build the site."
# Generate the site (in the _site/ folder)
bundle exec jekyll build

# Move _site folder to docs/ folder
mv _site/ docs/

# Copy CNAME file to docs/ folder.
cp CNAME docs/

# Generate the site (in the _site folder)
bundle exec jekyll build
if _promptUserForConfirmation "Do you want to run the local dev server"
npm install -g serve
serve docs/
else
echo "Ok, bye!"
return
end

# Move _site folder to /docs folder
mv _site/ docs/

# Run the local dev server (this will hardcode all the links to be localhost:4000)
# bundle exec jekyll serve
# Run the local dev server (this will hardcode all the links to be localhost:4000)
# bundle exec jekyll serve

# Old stuff.
# Jekyll install instructions: http://tinyurl.com/y2vbgyqz
# jekyll serve --config _config_dev.yml
# More info: http://tinyurl.com/yytw8hus
# gem install bundler
# bundle update --bundler
end

# Old stuff.
# Jekyll install instructions: http://tinyurl.com/y2vbgyqz
# jekyll serve --config _config_dev.yml
# More info: http://tinyurl.com/yytw8hus
# gem install bundler
# bundle update --bundler
# Actually call the main function.
main

0 comments on commit 2bf9d1e

Please sign in to comment.