diff --git a/.github/workflows/install.yml b/.github/workflows/install.yml index 70de3e6..6815e08 100644 --- a/.github/workflows/install.yml +++ b/.github/workflows/install.yml @@ -14,7 +14,7 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - os: [ ubuntu-latest, windows-latest, macos-latest ] + os: [ ubuntu-20.04, ubuntu-22.04, ubuntu-24.04, windows-latest, macos-latest ] node-version: [18, 20, 22] fail-fast: false @@ -28,10 +28,10 @@ jobs: node-version: ${{ matrix.node-version }} - name: Generate package.json file - run: npm init -y + run: cd html && npm init -y - - name: Install ndc package - run: npm install @remotemerge/nepali-date-converter + - name: Install Nepali Date Converter + run: cd html && npm install @remotemerge/nepali-date-converter - name: List installed packages - run: npm list --depth=0 + run: cd html && npm list --depth=0 diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 8f0c69f..21c0492 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -23,12 +23,15 @@ jobs: registry-url: 'https://registry.npmjs.org' - name: Install dependencies - run: npm install + run: cd html && npm install - name: Build project - run: npm run build + run: cd html && npm run build + + - name: Copy Documentation and License + run: cp README.md LICENSE html/dist - name: Publish the package to npm - run: npm publish ./dist --access public + run: cd html && npm publish ./dist --access public env: NODE_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 6a50534..44003c2 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,7 +1,7 @@ name: Test # Trigger the workflow on pull requests -on: [pull_request] +on: [ pull_request ] jobs: test: @@ -9,8 +9,8 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - os: [ubuntu-latest, windows-latest, macos-latest] - node-version: [18, 20, 22] + os: [ ubuntu-24.04, windows-latest, macos-latest ] + node-version: [ 18, 20, 22 ] fail-fast: false steps: @@ -23,13 +23,13 @@ jobs: node-version: ${{ matrix.node-version }} - name: Install dependencies - run: npm install + run: cd html && npm install - name: Build project - run: npm run build + run: cd html && npm run build - name: Create data file - run: npx shx cp __tests__/data.dist.json __tests__/data.json + run: cd html && npx shx cp __tests__/data.dist.json __tests__/data.json - name: Run Tests - run: npm run test + run: cd html && npm run test diff --git a/.gitignore b/.gitignore index 3461baa..41b0c9b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,12 +1,12 @@ ### Vendor directories -/.yarn/ -/node_modules/ -/vendor/ +/html/.yarn/ +/html/node_modules/ +/html/vendor/ ### Build directories -/build/ -/bundle/ -/dist/ +/html/build/ +/html/bundle/ +/html/dist/ ### JetBrains /.idea/* @@ -56,4 +56,4 @@ pnpm-lock.yaml yarn.lock ## Data Files -/__tests__/data.json +/html/__tests__/data.json diff --git a/README.md b/README.md index 59e26a1..71e2f15 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ [![Package](https://img.shields.io/npm/v/@remotemerge/nepali-date-converter?logo=npm)](https://www.npmjs.com/package/@remotemerge/nepali-date-converter) ![Build](https://img.shields.io/github/actions/workflow/status/remotemerge/nepali-date-converter/publish.yml?logo=github) -![Tests](https://img.shields.io/github/actions/workflow/status/remotemerge/nepali-date-converter/test.yml?style=flat&logo=counterstrike&label=test) +![Tests](https://img.shields.io/github/actions/workflow/status/remotemerge/nepali-date-converter/test.yml?&logo=jest&label=test) ![Downloads](https://img.shields.io/npm/dt/@remotemerge/nepali-date-converter?logo=spreadshirt) [![Size](https://img.shields.io/bundlephobia/minzip/@remotemerge/nepali-date-converter?logo=ipfs&label=size)](https://bundlephobia.com/result?p=@remotemerge/nepali-date-converter) ![License](https://img.shields.io/github/license/remotemerge/nepali-date-converter?logo=opensourceinitiative) diff --git a/app-cli.sh b/app-cli.sh new file mode 100644 index 0000000..6490335 --- /dev/null +++ b/app-cli.sh @@ -0,0 +1,4 @@ +#!/bin/bash + +# Login to the app container +docker compose --file ducker-compose.yml exec --user node npm-dev-server bash diff --git a/ducker-compose.yml b/ducker-compose.yml new file mode 100644 index 0000000..e8ee387 --- /dev/null +++ b/ducker-compose.yml @@ -0,0 +1,30 @@ +# Docker Compose configuration for NPM package deployment +# If you read this file, start docker compose with the following command: +# bash start-docker.sh + +# Define network +networks: + npm-dev-network: + name: npm-dev-network + driver: bridge + external: false + +# Define services +services: + npm-dev-server: + image: node:22 + user: node + working_dir: /app + volumes: + - ./html/:/app + ports: + - "3000:3000" + networks: + - npm-dev-network + entrypoint: [ "/bin/bash", "/app/entrypoint.sh" ] + healthcheck: + test: [ "CMD", "curl", "-f", "http://localhost:3000" ] + interval: 30s + timeout: 10s + retries: 3 + restart: unless-stopped diff --git a/.npmrc b/html/.npmrc similarity index 100% rename from .npmrc rename to html/.npmrc diff --git a/__tests__/ad.spec.ts b/html/__tests__/ad.spec.ts similarity index 92% rename from __tests__/ad.spec.ts rename to html/__tests__/ad.spec.ts index f15ec9c..516a06b 100644 --- a/__tests__/ad.spec.ts +++ b/html/__tests__/ad.spec.ts @@ -1,4 +1,4 @@ -import DateConverter from '../src/index'; +import DateConverter from '../src'; import records from './data.json'; diff --git a/__tests__/bs.spec.ts b/html/__tests__/bs.spec.ts similarity index 92% rename from __tests__/bs.spec.ts rename to html/__tests__/bs.spec.ts index d588c43..62bac60 100644 --- a/__tests__/bs.spec.ts +++ b/html/__tests__/bs.spec.ts @@ -1,4 +1,4 @@ -import DateConverter from '../src/index'; +import DateConverter from '../src'; import records from './data.json'; diff --git a/__tests__/data.dist.json b/html/__tests__/data.dist.json similarity index 100% rename from __tests__/data.dist.json rename to html/__tests__/data.dist.json diff --git a/html/entrypoint.sh b/html/entrypoint.sh new file mode 100644 index 0000000..53393d7 --- /dev/null +++ b/html/entrypoint.sh @@ -0,0 +1,13 @@ +#!/bin/bash + +# Exit on error +set -e + +# Change to the app directory +cd /app + +# Install dependencies +npm install + +# Start the app +npm run dev diff --git a/eslint.config.js b/html/eslint.config.js similarity index 100% rename from eslint.config.js rename to html/eslint.config.js diff --git a/index.html b/html/index.html similarity index 72% rename from index.html rename to html/index.html index 7f28fdb..5efd41d 100644 --- a/index.html +++ b/html/index.html @@ -1,4 +1,4 @@ - + @@ -6,6 +6,6 @@ Console - + diff --git a/jest.config.ts b/html/jest.config.ts similarity index 100% rename from jest.config.ts rename to html/jest.config.ts diff --git a/maker/package-manager.ts b/html/maker/package-manager.ts similarity index 93% rename from maker/package-manager.ts rename to html/maker/package-manager.ts index 14c739f..ad1f637 100644 --- a/maker/package-manager.ts +++ b/html/maker/package-manager.ts @@ -64,5 +64,3 @@ await writeFile( // Copy static files to the dist folder await copyFile('.npmrc', join(distPath, '.npmrc')); -await copyFile('README.md', join(distPath, 'README.md')); -await copyFile('LICENSE', join(distPath, 'LICENSE')); diff --git a/package-lock.json b/html/package-lock.json similarity index 99% rename from package-lock.json rename to html/package-lock.json index 92a635d..5809db0 100644 --- a/package-lock.json +++ b/html/package-lock.json @@ -1,12 +1,12 @@ { "name": "@remotemerge/nepali-date-converter", - "version": "1.0.0", + "version": "1.0.1", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@remotemerge/nepali-date-converter", - "version": "1.0.0", + "version": "1.0.1", "license": "MIT", "dependencies": { "date-fns": "^4.1.0" diff --git a/package.json b/html/package.json similarity index 93% rename from package.json rename to html/package.json index b33c4da..12568f8 100644 --- a/package.json +++ b/html/package.json @@ -1,6 +1,6 @@ { "name": "@remotemerge/nepali-date-converter", - "version": "1.0.0", + "version": "1.0.1", "description": "A modern JavaScript library for seamless conversion between Bikram Sambat (BS) and Gregorian (AD) dates. Easily convert Nepali dates to English dates and vice versa with support for years 1975 BS to 2099 BS.", "homepage": "https://madansapkota.com", "license": "MIT", @@ -44,9 +44,9 @@ "lint": "eslint **/*.ts", "lint:fix": "eslint **/*.ts --fix", "test": "jest", - "dev": "vite", + "dev": "vite --host 0.0.0.0 --port 3000", "preview": "vite preview", - "build": "vite build && npx tsx maker/package-manager.ts" + "build": "vite build && npx tsx ./maker/package-manager.ts" }, "dependencies": { "date-fns": "^4.1.0" diff --git a/src/index.ts b/html/src/index.ts similarity index 100% rename from src/index.ts rename to html/src/index.ts diff --git a/src/years.ts b/html/src/years.ts similarity index 100% rename from src/years.ts rename to html/src/years.ts diff --git a/tsconfig.json b/html/tsconfig.json similarity index 100% rename from tsconfig.json rename to html/tsconfig.json diff --git a/vite.config.ts b/html/vite.config.ts similarity index 100% rename from vite.config.ts rename to html/vite.config.ts diff --git a/start-docker.sh b/start-docker.sh new file mode 100644 index 0000000..9c85e71 --- /dev/null +++ b/start-docker.sh @@ -0,0 +1,14 @@ +#!/bin/bash + +# Stop and remove orphan services +docker compose --file ducker-compose.yml down --remove-orphans + +# Remove dangling services +docker container prune -f +docker network prune -f +docker builder prune -f +docker image prune -f +docker volume prune -f + +# Start services +docker compose --file ducker-compose.yml up