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

chore(github): add workflow #26

Merged
merged 73 commits into from
Aug 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
73 commits
Select commit Hold shift + click to select a range
17d792b
chore: package update
devlegacy Apr 6, 2022
512755e
chore: package update
devlegacy Apr 9, 2022
2019931
chore: package update
devlegacy Apr 25, 2022
a724c4e
chore: package update
devlegacy Aug 27, 2022
b167e93
chore(deps): bump dependencies
devlegacy Apr 2, 2023
b5dfd77
wip(codebase): improves and tests
devlegacy Apr 3, 2023
63d8acb
wip(cli): temporal local fixes
devlegacy Apr 3, 2023
02dfad0
chore(deps): bump dependencies
devlegacy May 9, 2024
ac785a9
chore(deps): bump dependencies
devlegacy May 9, 2024
bff165d
chore(deps): bump dependencies
devlegacy May 10, 2024
f16d208
chore(settings): Update npm and TypeScript dependencies
devlegacy May 10, 2024
7c0730f
chore: Remove tsconfig.json
devlegacy May 10, 2024
3db9e5b
chore: Update npm and TypeScript dependencies
devlegacy May 11, 2024
aa1348b
feat: Add unit tests for File class and remove unused console helper
devlegacy May 11, 2024
b7d0e88
test: Remove unused test files for File and Notify classes
devlegacy May 11, 2024
f6425ec
feat(command): clean source maps
devlegacy May 11, 2024
f483feb
refactor: Update dependencies and fix import paths in version.ts
devlegacy May 11, 2024
402e1b5
refactor: Update HTMLHint dependencies and fix import paths in html-v…
devlegacy May 11, 2024
c7cb903
chore(deps): bump dependencies
devlegacy May 11, 2024
7ce6c70
refactor(command): image minify
devlegacy May 11, 2024
5dbdd16
refactor(commands): Update image optimization command and dependencies
devlegacy May 11, 2024
abfda62
refactor: Improve getFunctionName helper function
devlegacy May 11, 2024
ea6b85c
refactor: Remove unused helper functions and interfaces
devlegacy May 11, 2024
56f10a3
refactor: Remove unused .vscode settings
devlegacy May 11, 2024
289b887
refactor: Remove unused code and update dependencies
devlegacy May 11, 2024
cb74af7
refactor: Add imagemin-svgo utility for SVG image optimization and em…
devlegacy May 11, 2024
87474ed
refactor: Ignore .vscode folder in gitignore
devlegacy May 11, 2024
14644a7
refactor: Remove ConsoleColorInterface and unused console color defin…
devlegacy May 11, 2024
380ab66
refactor: Update image optimization command and dependencies
devlegacy May 11, 2024
971c747
refactor: Update import path for emptyDirSync function
devlegacy May 11, 2024
d065a97
refactor: Update npm dependency to latest stable version
devlegacy May 11, 2024
3091193
refactor: Update Notify class to use NodeNotifier and improve code st…
devlegacy May 11, 2024
8edc834
refactor: Update color.ts to remove unnecessary semicolons and traili…
devlegacy May 11, 2024
55d897a
chore(deps): bump dependencies
devlegacy May 18, 2024
5b5cbac
refactor: Update clean-sourcemap.command.ts to improve error handling…
devlegacy May 19, 2024
9f422f6
refactor: Add chunkArray utility function for dividing an array into …
devlegacy May 19, 2024
304f58f
refactor: Update DvxCLI class to handle command errors and improve er…
devlegacy May 19, 2024
ff2348d
refactor: Update download URLs for graphics libraries
devlegacy May 19, 2024
b3bdd00
refactor: Optimize image processing commands and dependencies
devlegacy May 20, 2024
7a78322
chore(deps): bump dependencies
devlegacy May 20, 2024
603b8a3
refactor: Update image processing commands to optimize performance an…
devlegacy May 20, 2024
da18cfb
docs(readme): improve readme.md
devlegacy May 20, 2024
abfa350
docs(readme): improve docs
devlegacy May 20, 2024
db5cabb
wip(docs): scaffold test
devlegacy May 20, 2024
c8f3e97
wip(readme): scaffold
devlegacy May 20, 2024
41cff54
chore(deps): update npm dependency to latest stable version
devlegacy Jul 22, 2024
c916385
chore: remove fast-glob dependency
devlegacy Jul 22, 2024
d83f178
chore: update npm dependencies and types versions
devlegacy Jul 29, 2024
21aa031
chore(deps): bump dependencies
devlegacy Jul 30, 2024
112321a
chore: update npm dependencies and types versions
devlegacy Jul 30, 2024
63c6cdb
refactor: update image processing commands to optimize performance an…
devlegacy Jul 30, 2024
2f2e3f7
chore(github): add workflow
devlegacy Jul 30, 2024
cc52e11
chore(github): update push event branch in GitHub workflow
devlegacy Jul 30, 2024
8e2ab70
Update nodejs.yml
devlegacy Jul 30, 2024
3400018
chore(github): add notification to Slack for failed job
devlegacy Jul 30, 2024
0d4a5f0
refactor: remove unused import statements and commented code
devlegacy Jul 30, 2024
ebeb38d
chore(github): update Node.js version and enable corepack and pnpm in…
devlegacy Jul 30, 2024
390d2a3
test: add feature tests to the test script
devlegacy Jul 30, 2024
cd292e7
chore(workflow): install build dependencies for image processing
devlegacy Jul 31, 2024
bc6af8c
chore(settings): update .npmrc to ignore scripts during installation
devlegacy Jul 31, 2024
ff06a22
chore: update Node.js version and use pnpm for running tests
devlegacy Jul 31, 2024
dd9d9bb
chore: update Node.js version and use pnpm for running tests
devlegacy Jul 31, 2024
4717bf2
chore: update infra build dependencies for image processing
devlegacy Jul 31, 2024
eb4f7b0
ci(github): add makefiles
devlegacy Jul 31, 2024
001781f
chore(deps): bump dependencies
devlegacy Aug 1, 2024
63d780f
chore(etc): add executable permissions to .bin directory
devlegacy Aug 1, 2024
8990f2f
ci(github): update Node.js version and use pnpm for running tests
devlegacy Aug 3, 2024
5b347ca
chore: update @swc/core and @types/node dependencies
devlegacy Aug 3, 2024
ecc42ff
gi(github): update build dependencies and remove unused scripts
devlegacy Aug 3, 2024
8cd11bd
ci(github): update ci_install script path in nodejs.yml workflow
devlegacy Aug 3, 2024
11f0c75
chore: Update build dependencies and add executable permissions to .b…
devlegacy Aug 3, 2024
83c4353
chore: update ci_install script path in nodejs.yml workflow
devlegacy Aug 3, 2024
ca1b4f6
ci(github): :building_construction: add Release Workflow and configur…
devlegacy Aug 3, 2024
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
4 changes: 4 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ root = true

[*]
indent_style = space
max_line_length = 100
indent_size = 2
end_of_line = lf
charset = utf-8
Expand All @@ -22,3 +23,6 @@ indent_size = 2

[CHANGELOG.md]
indent_size = false

[{Makefile,*.mk}]
indent_style = tab
8 changes: 8 additions & 0 deletions .etc/bin/ci_install
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/usr/bin/env bash

# sudo apt-get update && \
# sudo apt-get install -y \
# build-essential \
# libpng-dev

chmod +x ./.etc/bin/*
8 changes: 8 additions & 0 deletions .etc/bin/colors
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/usr/bin/env bash

COLOR_RED='\033[0;31m'
COLOR_GREEN='\033[0;36m'
COLOR_YELLOW='\033[1;33m'
COLOR_RESET='\033[0m'

export COLOR_RED COLOR_GREEN COLOR_YELLOW COLOR_RESET
31 changes: 31 additions & 0 deletions .etc/bin/print_message
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/usr/bin/env bash

. "$(dirname "$0")/colors"
. "$(dirname "$0")/timestamp"

function print_message() {
message="$1"
type="$2"

if [ -z "$type" ]; then
type="success"
fi

case "$type" in
"error")
printf "${COLOR_RED}$(timestamp) %s${COLOR_RESET}\n" "$message"
;;
"success")
printf "${COLOR_GREEN}$(timestamp) %s${COLOR_RESET}\n" "$message"
;;
"warn")
printf "${COLOR_YELLOW}$(timestamp) %s${COLOR_RESET}\n" "$message"
;;
esac
}

if [ "${BASH_SOURCE[0]}" = "${0}" ]; then
print_message "$1" "$2"
fi

export -f print_message
7 changes: 7 additions & 0 deletions .etc/bin/timestamp
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/env bash

function timestamp() {
date +'%Y-%m-%d %T';
}

export -f timestamp
50 changes: 50 additions & 0 deletions .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: Node.js ⬢ CI
run-name: Node.js ⬢ CI

on:
push:
branches: [develop]

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [22.x]

name: Node.js ${{ matrix.node-version }} 🚀
steps:
- name: Checkout 📖
uses: actions/checkout@v4

- name: Install infra build dependencies 🛠️
run: sh .etc/bin/ci_install

- name: Enable corepack and pnpm ⚙️
run: |
corepack enable
corepack prepare pnpm@latest --activate
pnpm config set store-dir ~/.pnpm-store

- name: Use Node.js ⚙️ ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: 'pnpm'

- name: Cache dependencies 🔒
id: cache-pnpm-store
uses: actions/cache@v4
with:
path: ~/.pnpm-store
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('package.json') }}-${{ hashFiles('pnpm-lock.yaml') }}-${{ hashFiles('.github/workflows/nodejs.yml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-

- name: Install dependencies 📦
run: |
pnpm install --frozen-lockfile

- name: Run tests 🧪
run: |
make test
78 changes: 78 additions & 0 deletions .github/workflows/release-please.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
name: Release Workflow
on:
push:
branches:
- master

permissions:
contents: write
pull-requests: write

jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: googleapis/release-please-action@v4
id: release
with:
token: ${{ secrets.GITHUB_TOKEN }}

- name: Checkout 📖
if: ${{ steps.release.outputs.release_created }}
uses: actions/checkout@v4

- name: Tag major, minor, and patch versions 🏷️
if: ${{ steps.release.outputs.release_created }}
run: |
git config user.name github-actions[bot]
git config user.email 41898282+github-actions[bot]@users.noreply.github.com

# Extract version components
VERSION=${{ steps.release.outputs.version }}
IFS='.' read -r MAJOR MINOR PATCH <<< "$VERSION"

# Add and push tags for major, minor, and patch versions
git tag -a "v$MAJOR" -m "Release v$MAJOR"
git tag -a "v$MAJOR.$MINOR" -m "Release v$MAJOR.$MINOR"
git tag -a "v$MAJOR.$MINOR.$PATCH" -m "Release v$MAJOR.$MINOR.$PATCH"
git push origin "v$MAJOR"
git push origin "v$MAJOR.$MINOR"
git push origin "v$MAJOR.$MINOR.$PATCH"

# Cleanup old tags if needed (optional)
git tag -d "v$MAJOR" || true
git tag -d "v$MAJOR.$MINOR" || true
git push origin :refs/tags/v$MAJOR || true
git push origin :refs/tags/v$MAJOR.$MINOR || true

- name: Enable corepack and pnpm ⚙️
run: |
corepack enable
corepack prepare pnpm@latest --activate
pnpm config set store-dir ~/.pnpm-store

- name: Use Node.js ⚙️ 22
uses: actions/setup-node@v4
with:
node-version: 22
cache: 'pnpm'
registry-url: 'https://registry.npmjs.org'
- name: Cache dependencies 🔒
id: cache-pnpm-store
uses: actions/cache@v4
with:
path: ~/.pnpm-store
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('package.json') }}-${{ hashFiles('pnpm-lock.yaml') }}-${{ hashFiles('.github/workflows/nodejs.yml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-

- name: Install dependencies 📦
run: |
pnpm install --frozen-lockfile

- name: Publish to npm 🚀
if: ${{ steps.release.outputs.release_created }}
run: |
pnpm publish --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
save-exact=true
legacy-peer-deps=true
ignore-scripts=true #giflossy, zopflipng
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v22.2.0
v22.5.1
3 changes: 3 additions & 0 deletions .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
".": "2.0.4"
}
40 changes: 40 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
MAKEFLAGS += -s

current_work_directory := $(dir $(abspath $(lastword $(MAKEFILE_LIST))))

export current_work_directory

include ./.etc/bin/colors

print_message:=./.etc/bin/print_message

.DEFAULT_GOAL := help

.ONESHELL:

.PHONY: help
.SILENT: help
help: ## 📋 Display help message with descriptions of all available commands.
echo "Recommended usage: make [target]"
echo ""
echo "Targets:"
grep -E '^[a-zA-Z0-9\/_ -]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "} {gsub(/^[^:]*:/, ""); gsub(/^ +| +$$/, "", $$1); printf "'${COLOR_GREEN}'%-10s'${COLOR_RESET}' : %s\n", $$1, $$2}'

.PHONY: deps/update
.SILENT: deps/update
deps/update: ## ⬆️ Update all project dependencies to their latest versions.
$(print_message) "updating dependencies"
ncu -u && ncu --target minor -u && ncu --target patch -u
corepack up
NODE_ENV= pnpm install
NODE_ENV= pnpm audit --fix

.PHONY: test
.SILENT: test
test: ## 🧪 Run project tests.
$(print_message) "running tests"
NODE_ENV=test
# DEBT: this prints the error message to the console, but it doesn't stop the execution of the script, we'll wait node 23.x
if ! node --run test ; then
pnpm run test
fi
66 changes: 34 additions & 32 deletions NOTES.md
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
# Notes
# 📝 Notes

Local test command:
```sh
# Local test command:
npm link
```

- Add permission: `chmod +x ./cli.js`
- Move: `mv ./cli.js /usr/bin/`
- where is?: `where dvx`
- Size on end: `du -sh ./src/img/src/`
- [Read more on stackoverflow:](https://stackoverflow.com/questions/20643470/execute-a-command-line-binary-with-node-js "stackoverflow")
- [Execute a command line binary with Node.JS](https://stackoverflow.com/questions/20643470/execute-a-command-line-binary-with-node-js "stackoverflow")

## Console name

- [Text to ASCII art generator](http://patorjk.com/software/taag/#p=testall&f=3D%20Diagonal&t=Devexteam%20CLI)
- Font Name: Standard
```sh
____ _ ____ _ ___
| _ \ _____ _______ _| |_ ___ __ _ _ __ ___ / ___| | |_ _|
| | | |/ _ \ \ / / _ \ \/ / __/ _ \/ _` | '_ ` _ \ | | | | | |
| |_| | __/\ V / __/> <| || __/ (_| | | | | | | | |___| |___ | |
|____/ \___| \_/ \___/_/\_\\__\___|\__,_|_| |_| |_| \____|_____|___|
# http://patorjk.com/software/taag/#p=testall&f=3D%20Diagonal&t=Devexteam%20CLI
# Font Name: Standard
```

## Node environment
Expand All @@ -30,29 +30,28 @@
* [0] Reserved by Node.js
* [1] Reserved by Node.js
*/
process.argv[3] = 'Estamos aprendiendo Node.JS';
process.argv[4] = 19;
process.argv[5] = null;
process.argv[6] = true;

c('----------------------------------------');
c(' PROCESOS DE NODE.JS ');
c(`ID del proceso............${process.pid}`);
c(`Título....................${process.title}`);
c(`Directorio de Node.JS.....${process.execPath}`);
c(`Directorio actual.........${process.cwd()}`);
c(`Versión de Node.JS........${process.version}`);
c(`Versiones de dependencias.${process.versions}`);
c(`Plataforma (S.O.).........${process.platform}`);
c(`Arquitectura (S.O.).......${process.arch}`);
c(`Tiempo activo de Node.JS..${process.uptime()}`);
c(`Argumento de procesos.....${process.argv}`);
c('----------------------------------------');

for(let i in process.argv){
c(`[${i}] - ${process.argv[i]}`);
}

process.argv[3] = 'Estamos aprendiendo Node.JS';
process.argv[4] = 19;
process.argv[5] = null;
process.argv[6] = true;

c('----------------------------------------');
c(' PROCESOS DE NODE.JS ');
c(`ID del proceso............${process.pid}`);
c(`Título....................${process.title}`);
c(`Directorio de Node.JS.....${process.execPath}`);
c(`Directorio actual.........${process.cwd()}`);
c(`Versión de Node.JS........${process.version}`);
c(`Versiones de dependencias.${process.versions}`);
c(`Plataforma (S.O.).........${process.platform}`);
c(`Arquitectura (S.O.).......${process.arch}`);
c(`Tiempo activo de Node.JS..${process.uptime()}`);
c(`Argumento de procesos.....${process.argv}`);
c('----------------------------------------');

for(let i in process.argv){
c(`[${i}] - ${process.argv[i]}`);
}

c(__dirname);
c(__filename);
Expand Down Expand Up @@ -243,10 +242,6 @@ Promise.resolve().then(() => tslib_1.__importStar(require
npm test -- --updateSnapshot
```

const { default: imagemin } = await import('imagemin');
const { default: imageminMozjpeg } = await import('imagemin-mozjpeg');
const { default: imageminSvgo } = await import('imagemin-svgo');

<h2 id="" align="center">Examples</h2>

### Images
Expand All @@ -268,3 +263,10 @@ Result after run `dvx img:build`
npm publish --dry-run
"bin",
"bin/**/*.js",


https://nodejs.org/api/process.html#processargv0

node ~/src/github.com/devlegacy/dvx-cli html:validate
@squoosh/lib
imagemin-svgo
Loading