Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
23 changes: 4 additions & 19 deletions .github/workflows/sbg-utility.yml
Original file line number Diff line number Diff line change
Expand Up @@ -158,29 +158,14 @@ jobs:
npm run pack -- --commit
npm run pack

- name: 🛠️ Configure Git user
run: |
git config --global user.email "dimaslanjaka@gmail.com"
git config --global user.name "dimaslanjaka"

- name: ➕ Git Add Changes
working-directory: packages/sbg-utility
run: |
git add -A

# --- original commit step backup ---
# - name: 📤 Commit and Push Changes
# working-directory: packages/sbg-utility
# run: |
# if [ $(git status --porcelain | wc -l) -gt "0" ]; then
# git commit -m "chore: update build from ${{ env.GITHUB_COMMIT_URL }}" -m "commit hash: ${{ env.GITHUB_SHA_SHORT }}" -m "commit url: ${{ env.GITHUB_COMMIT_URL }}" -m "runner: ${{ env.GITHUB_RUNNER_URL }}"
# git push
# fi

- name: 📤 Commit and Push Changes (only sbg-utility)
run: git add .

- name: 📤 Commit and Push Changes
working-directory: packages/sbg-utility
run: |
if [ $(git status --porcelain -- . | wc -l) -gt "0" ]; then
if [ $(git status --porcelain | wc -l) -gt "0" ]; then
git commit -m "chore: update build from ${{ env.GITHUB_COMMIT_URL }}" -m "commit hash: ${{ env.GITHUB_SHA_SHORT }}" -m "commit url: ${{ env.GITHUB_COMMIT_URL }}" -m "runner: ${{ env.GITHUB_RUNNER_URL }}"
git push
fi
2 changes: 1 addition & 1 deletion .husky/post-checkout
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env sh

command -v git-lfs >/dev/null 2>&1 || { echo >&2 "\nThis repository is configured for Git LFS but 'git-lfs' was not found on your path. If you no longer wish to use Git LFS, remove this hook by deleting '.git/hooks/post-checkout'.\n"; exit 2; }
git lfs post-checkout "$@" || true
git lfs post-checkout "$@"
2 changes: 1 addition & 1 deletion .husky/post-commit
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ case `uname` in
esac

command -v git-lfs >/dev/null 2>&1 || { echo >&2 "\nThis repository is configured for Git LFS but 'git-lfs' was not found on your path. If you no longer wish to use Git LFS, remove this hook by deleting '.git/hooks/post-commit'.\n"; exit 2; }
git lfs post-commit "$@" || true
git lfs post-commit "$@"
2 changes: 1 addition & 1 deletion .husky/post-merge
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env sh

command -v git-lfs >/dev/null 2>&1 || { echo >&2 "\nThis repository is configured for Git LFS but 'git-lfs' was not found on your path. If you no longer wish to use Git LFS, remove this hook by deleting '.git/hooks/post-merge'.\n"; exit 2; }
git lfs post-merge "$@" || true
git lfs post-merge "$@"
12 changes: 4 additions & 8 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
#!/usr/bin/env sh

set -e

ROOT_GIT=$(git rev-parse --show-toplevel)

STATIC_BLOG_README="${ROOT_GIT}/packages/static-blog-generator/readme.md"
if [ -f "$STATIC_BLOG_README" ]; then
cp "${ROOT_GIT}/readme.md" "$STATIC_BLOG_README" 2>/dev/null
git add "$STATIC_BLOG_README" 2>/dev/null
fi
cp "${ROOT_GIT}/readme.md" "${ROOT_GIT}/packages/static-blog-generator/readme.md" 2>/dev/null

git add "${ROOT_GIT}/packages/static-blog-generator/readme.md" 2>/dev/null

npx lint-staged

command -v git-lfs >/dev/null 2>&1 || { echo >&2 "\nThis repository is configured for Git LFS but 'git-lfs' was not found on your path. If you no longer wish to use Git LFS, remove this hook by deleting '.git/hooks/pre-push'.\n"; exit 2; }
git lfs pre-commit "$@" || true
git lfs pre-commit "$@"
2 changes: 1 addition & 1 deletion .husky/pre-push
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env sh

command -v git-lfs >/dev/null 2>&1 || { echo >&2 "\nThis repository is configured for Git LFS but 'git-lfs' was not found on your path. If you no longer wish to use Git LFS, remove this hook by deleting '.git/hooks/pre-push'.\n"; exit 2; }
git lfs pre-push "$@" || true
git lfs pre-push "$@"
942 changes: 0 additions & 942 deletions .yarn/releases/yarn-4.9.2.cjs

This file was deleted.

2 changes: 1 addition & 1 deletion .yarnrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@ nodeLinker: node-modules

patchFolder: ./.yarn/patches

yarnPath: .yarn/releases/yarn-4.9.2.cjs
yarnPath: .yarn/releases/yarn-4.5.1.cjs
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@
"test"
]
},
"packageManager": "yarn@4.9.2",
"packageManager": "yarn@4.5.1",
"engines": {
"node": ">=16"
},
Expand Down

This file was deleted.

1 change: 0 additions & 1 deletion packages/sbg-utility/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,3 @@ node_modules/
yarn.lock
tmp/
.yarn*
src/config/_config.json
52 changes: 39 additions & 13 deletions packages/sbg-utility/.vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@
"icon": "terminal-powershell"
},
"Command Prompt": {
"path": ["${env:windir}\\Sysnative\\cmd.exe", "${env:windir}\\System32\\cmd.exe"],
"path": [
"${env:windir}\\Sysnative\\cmd.exe",
"${env:windir}\\System32\\cmd.exe"
],
"args": [],
"icon": "terminal-cmd"
},
Expand All @@ -26,7 +29,10 @@
},
"Cygwin": {
"path": "C:\\cygwin64\\bin\\bash.exe",
"args": ["--login", "-i"],
"args": [
"--login",
"-i"
],
"env": {
"CHERE_INVOKING": "1"
}
Expand All @@ -47,10 +53,10 @@
"code-runner.executorMapByGlob": {
"pom.xml": "cd $dir && mvn clean package",
"*.{test,spec}.ts": "yarn test -- $fileNameWithoutExt",
"*.{test,spec}.{js,cjs,mjs}": "yarn test -- $fileNameWithoutExt",
"*.{test,spec}.{js,cjs,mjs}": "npm run build && yarn test -- $fileNameWithoutExt",
"*.{explicit}.ts": "cross-env-shell DEBUG=sbg-* node --no-warnings --experimental-specifier-resolution=node --loader ts-node/esm -r dotenv/config",
"*.{explicit,runner}.{mjs,cjs,js}": "cross-env-shell DEBUG=sbg-* node --no-warnings --experimental-specifier-resolution=node -r dotenv/config",
"*.runner.ts": "cross-env-shell DEBUG=sbg-* node --no-warnings --experimental-specifier-resolution=node --loader ts-node/esm -r dotenv/config",
"*.{explicit,runner}.{mjs,cjs,js}": "yarn build && cross-env-shell DEBUG=sbg-* node --no-warnings --experimental-specifier-resolution=node -r dotenv/config",
"*.runner.ts": "yarn build && cross-env-shell DEBUG=sbg-* node --no-warnings --experimental-specifier-resolution=node --loader ts-node/esm -r dotenv/config",
"electron-*.ts": "cross-env-shell NODE_ENV=development electron -r ts-node/register",
"*.py": "python -u",
"*.electron.js": "cross-env-shell NODE_ENV=development electron -r ts-node/register",
Expand Down Expand Up @@ -101,10 +107,25 @@
"source.fixAll": "never"
}
},
"autopep8.args": ["--ignore", "E401,E402,E211,E501"],
"autopep8.args": [
"--ignore",
"E401,E402,E211,E501"
],
"intelephense.maxMemory": 1028,
"intelephense.rename.exclude": ["**/vendor/**", "**/node_modules/**", "**/tmp/**", "**/dist/**", "**/.cache/**"],
"intelephense.references.exclude": ["**/vendor/**", "**/node_modules/**", "**/tmp/**", "**/dist/**", "**/.cache/**"],
"intelephense.rename.exclude": [
"**/vendor/**",
"**/node_modules/**",
"**/tmp/**",
"**/dist/**",
"**/.cache/**"
],
"intelephense.references.exclude": [
"**/vendor/**",
"**/node_modules/**",
"**/tmp/**",
"**/dist/**",
"**/.cache/**"
],
"intelephense.trace.server": "messages",
"intelephense.completion.maxItems": 100,
"intelephense.diagnostics.run": "onSave",
Expand All @@ -130,7 +151,10 @@
"**/assets/**",
"**/*.sqlite"
],
"intelephense.files.associations": ["*.php", "*.phtml"],
"intelephense.files.associations": [
"*.php",
"*.phtml"
],
"intelephense.telemetry.enabled": true,
"eslint.debug": true,
"eslint.useFlatConfig": true,
Expand All @@ -149,7 +173,10 @@
"src/database.sqlite*": true
},
"intelephense.environment.documentRoot": "${workspaceFolder}",
"intelephense.environment.includePaths": ["${workspaceFolder}/src", "${workspaceFolder}/vendor"],
"intelephense.environment.includePaths": [
"${workspaceFolder}/src",
"${workspaceFolder}/vendor"
],
"files.exclude": {
"*.php": true,
"**/.cache/**": true,
Expand All @@ -176,6 +203,5 @@
},
"typescript.tsdk": "./node_modules/typescript/lib",
"typescript.enablePromptUseWorkspaceTsdk": false,
"editor.formatOnType": false,
"git.autoStash": true
}
"editor.formatOnType": false
}
23 changes: 23 additions & 0 deletions packages/sbg-utility/bin/git-diff.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
@echo off
setlocal

:: Check if file argument is provided
if "%~1"=="" (
echo [X] Error: No file specified
echo Usage: git-diff filename
exit /b 1
)

set "FILE=%~1"
set "OUTPUT=.cache\git\diff.txt"

:: Create output directory if it doesn't exist
if not exist .cache\git (
mkdir .cache\git
)

:: Save the staged diff to file
git --no-pager diff --cached "%FILE%" > "%OUTPUT%"

echo [✓] Staged diff of "%FILE%" saved to "%OUTPUT%"
endlocal
76 changes: 14 additions & 62 deletions packages/sbg-utility/gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,13 @@ import * as glob from 'glob';
import gulp from 'gulp';
import path from 'node:path';
import { fileURLToPath } from 'url';
import YAML from 'yaml';
import { compileDeclarations } from './rollup-preserve.js';
import { generateExports } from './src/utils/generate-exports.js';
import { buildAll, compileCJS, compileDeclarations, compileESM } from './rollup-build.js';

const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);

function get_binary_path(commandName) {
/** resolve cmd binary */
const cmd = (commandName) => {
const cmdPath = [
__dirname,
process.cwd(),
Expand All @@ -29,7 +28,7 @@ function get_binary_path(commandName) {
}

return process.platform === 'win32' ? `${cmdPath}.cmd` : cmdPath;
}
};

// copy non-javascript assets from src folder
const copy = async function () {
Expand Down Expand Up @@ -63,55 +62,24 @@ gulp.task('copy', copy);
// rollup -c

async function tsc() {
await crossSpawn.spawnAsync(get_binary_path('tsc'), ['--build', 'tsconfig.docs.json'], {
await crossSpawn.spawnAsync(cmd('tsc'), ['--build', 'tsconfig.docs.json'], {
cwd: __dirname,
shell: true,
stdio: 'inherit'
});
// await crossSpawn.spawnAsync(cmd('rollup'), ['-c'], {
// cwd: __dirname,
// shell: true,
// stdio: 'inherit'
// });
}

gulp.task('tsc', tsc);
gulp.task(
'rollup',
gulp.series(async function () {
await crossSpawn.spawnAsync('node', [path.join(__dirname, 'rollup-preserve.js')], {
cwd: __dirname,
shell: true,
stdio: 'inherit'
});
})
);
gulp.task('rollup', gulp.series(buildAll));
gulp.task('rollup-dts', gulp.series(compileDeclarations));

function generateExportsTask() {
generateExports({
pkgPath: path.join(process.cwd(), 'package.json'),
exportValues: {
'.': {
require: {
default: './dist/index.cjs',
types: './dist/index.d.cts'
},
import: {
default: './dist/index.mjs',
types: './dist/index.d.mts'
}
},
'./package.json': './package.json'
},
folders: [
{ dir: `${process.cwd()}/dist/utils`, prefix: './dist/utils/' },
{ dir: `${process.cwd()}/dist/sitemap-crawler`, prefix: './dist/sitemap-crawler/' },
{ dir: `${process.cwd()}/dist/gulp-utils`, prefix: './dist/gulp-utils/' }
].map((folder) => ({
dir: path.resolve(folder.dir),
prefix: folder.prefix
}))
});
return Promise.resolve();
}
gulp.task('generate-exports', gulp.series(generateExportsTask));
gulp.task('build', gulp.series('tsc', 'copy', 'rollup', 'rollup-dts', 'generate-exports'));
gulp.task('rollup-esm', gulp.series(compileESM));
gulp.task('rollup-cjs', gulp.series(compileCJS));
gulp.task('build', gulp.series('tsc', 'copy', 'rollup'));

async function clean() {
await fs.rm(path.join(__dirname, 'dist'), { recursive: true, force: true });
Expand All @@ -120,19 +88,3 @@ async function clean() {
gulp.task('clean', gulp.series(clean));

gulp.task('default', gulp.series('build'));

gulp.task('populate-config', async function () {
const configYmlPath = path.join(__dirname, 'test', '_config.yml');
const configJsonPath = path.join(__dirname, 'src', 'config', '_config.json');

if (!fs.existsSync(configYmlPath)) {
console.error('YAML config not found at', configYmlPath);
return;
}

const ymlContent = fs.readFileSync(configYmlPath, 'utf8');
const configObj = YAML.parse(ymlContent);
fs.ensureDirSync(path.dirname(configJsonPath));
fs.writeFileSync(configJsonPath, JSON.stringify(configObj, null, 2));
console.log('Created _config.json at', configJsonPath);
});
18 changes: 5 additions & 13 deletions packages/sbg-utility/jest.config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import fs from 'fs';
import { existsSync, mkdirSync } from 'fs';
import { defaults } from 'jest-config';
import path from 'path';
import path, { join } from 'path';
import type { JestConfigWithTsJest } from 'ts-jest';

/**
Expand All @@ -13,7 +13,7 @@ const config: JestConfigWithTsJest = {
moduleFileExtensions: [...defaults.moduleFileExtensions, 'mts'],
verbose: true,
cache: true,
cacheDirectory: path.join(__dirname, 'tmp/jest'),
cacheDirectory: join(__dirname, 'tmp/jest'),
collectCoverageFrom: [
'src/*.{js,ts}',
'!**/node_modules/**',
Expand All @@ -28,8 +28,7 @@ const config: JestConfigWithTsJest = {
testMatch: [
'**/__tests__/**/*.+(ts|tsx|[cm]js)',
'**/?(*.)+(spec|test).+(ts|tsx|[cm]js)',
'**/test/*.test.{js,ts,cjs,mjs}',
'**/test/*.spec.{js,ts,cjs,mjs}',
'**/test/*.test.ts',
'!**/.deploy_git/**'
],
extensionsToTreatAsEsm: ['.ts'],
Expand Down Expand Up @@ -70,13 +69,6 @@ const config: JestConfigWithTsJest = {
coverageProvider: 'v8'
};

// Ensure the 'tmp' directory exists before using it for Jest cache
const tmpDir = path.join(__dirname, 'tmp');
if (!fs.existsSync(tmpDir)) {
fs.mkdirSync(tmpDir, { recursive: true });
}
if (!fs.existsSync(<string>config.cacheDirectory)) {
fs.mkdirSync(<string>config.cacheDirectory, { recursive: true });
}
if (!existsSync(<string>config.cacheDirectory)) mkdirSync(<string>config.cacheDirectory, { recursive: true });

export default config;
Loading
Loading