From 34790c2b0c08cd78cfcda4195da67b0339127914 Mon Sep 17 00:00:00 2001 From: Keith Irwin Date: Mon, 6 Mar 2023 16:06:52 -0700 Subject: [PATCH] Move sold items to own dir --- .eleventyignore | 3 --- .gitignore | 1 + api.js | 3 ++- hooks/remove_sid | 17 +++++++++++++---- 4 files changed, 16 insertions(+), 8 deletions(-) diff --git a/.eleventyignore b/.eleventyignore index c2e2fb6..d6ba449 100644 --- a/.eleventyignore +++ b/.eleventyignore @@ -4,8 +4,5 @@ README.md # Drafts **/_draft.* -# Sold products -**/_sold.* - # Aspell backups **/*.bak \ No newline at end of file diff --git a/.gitignore b/.gitignore index e036a85..0780cd0 100644 --- a/.gitignore +++ b/.gitignore @@ -5,6 +5,7 @@ node_modules/ .env docker-compose.yml orders/*.json +sold/ # frontend build _site/* diff --git a/api.js b/api.js index 44a28ca..521d40f 100644 --- a/api.js +++ b/api.js @@ -15,6 +15,7 @@ const jsonBodyParser = express.json() app.listen(process.env.API_PORT||80) const DATA_DIR = `${__dirname}/_src/_data` const SHOP_DIR = `${__dirname}/_src/shop` +const SOLD_DIR = `${__dirname}/sold` const ORDERS_DIR = `${__dirname}/orders` // TODO: Use an eleventy hook to save this outside the public _site dir const PRODUCTS_FILE = `${__dirname}/_site/assets/data/products.json` @@ -272,7 +273,7 @@ app.options('/paid', cors) order.items.forEach((item) => { if (item.sid) { console.log(`Removing product with sid ${item.sid} from store`) - run(`./hooks/remove_sid ${item.sid} ${SHOP_DIR}`) + run(`./hooks/remove_sid ${item.sid} ${SHOP_DIR} ${SOLD_DIR}`) } }) diff --git a/hooks/remove_sid b/hooks/remove_sid index 9be3caa..4507349 100755 --- a/hooks/remove_sid +++ b/hooks/remove_sid @@ -1,10 +1,19 @@ #!/bin/bash # remove_sid # -# USAGE: remove_sid sid dir +# USAGE: remove_sid sid shop_dir sold_dir + +find "${2}" -type d -name "${1}" -exec mv {} "${3}" # https://stackoverflow.com/a/6329624/ -find "${2}" -type f \( -path "*/${1}/index.*" -o -name "${1}.*" \) \ - -printf "cp '%h/%f' '%h/_sold.%f'\nrm '%h/%f'" |bash -s +#find "${2}" -type f \( -path "*/${1}/index.*" -o -name "${1}.*" \) \ +# -printf "cp '%h/%f' '%h/_sold.%f'\nrm '%h/%f'" |bash -s -npm run build \ No newline at end of file +# Update website +npm run build & ( + git status + git remote -v + #git add "${2}" && \ + #git commit -m "Products sold" && \ + #git push +)