build: replace npm with pnpm + add Dockerfile for ci

update php and js dependencies to latest
This commit is contained in:
Yassine Doghri 2023-02-21 17:27:45 +00:00
parent 1b037a7adf
commit 34777598dd
26 changed files with 13895 additions and 30537 deletions

View File

@ -5,7 +5,7 @@
"dockerComposeFile": ["../docker-compose.yml", "./docker-compose.yml"],
"service": "app",
"workspaceFolder": "/castopod",
"postCreateCommand": "composer install && npm install && npm run build:static",
"postCreateCommand": "composer install && pnpm install && pnpm run build:static",
"postStartCommand": "crontab ./crontab && cron && php spark serve --host 0.0.0.0",
"postAttachCommand": "crontab ./crontab && service cron reload",
"shutdownAction": "stopCompose",
@ -44,5 +44,11 @@
"stylelint.vscode-stylelint",
"wayou.vscode-todo-highlight",
"yzhang.markdown-all-in-one"
]
],
"features": {
"ghcr.io/devcontainers/features/git:1": {},
"ghcr.io/guiyomh/features/vim:0": {},
"ghcr.io/NicoVIII/devcontainer-features/pnpm:2": {}
}
}

4
.gitignore vendored
View File

@ -85,6 +85,7 @@ tests/coverage*
# Don't save phpunit under version control.
phpunit
.phpunit.cache
#-------------------------
# Composer
@ -132,9 +133,10 @@ tmp/
/phpunit*.xml
/.phpunit.*.cache
# npm
# js package manager
yarn.lock
node_modules
.pnpm-store
# JS
.cache

View File

@ -1,4 +1,4 @@
image: code.castopod.org:5050/adaures/castopod:php8.1
image: code.castopod.org:5050/adaures/castopod:ci
stages:
- prepare
@ -13,20 +13,32 @@ php-dependencies:
script:
# Install all php dependencies
- composer install --prefer-dist --no-ansi --no-interaction --no-progress --ignore-platform-reqs
cache:
key:
files:
- composer.lock
paths:
- .composer-cache
artifacts:
expire_in: 30 mins
paths:
- vendor/
expire_in: 30 mins
js-dependencies:
stage: prepare
script:
# Install all npm dependencies
- npm ci
# Install all js dependencies
- pnpm install
cache:
key:
files:
- pnpm-lock.yaml
paths:
- .pnpm-store
artifacts:
expire_in: 30 mins
paths:
- node_modules/
expire_in: 30 mins
lint-commit-msg:
stage: quality
@ -49,19 +61,18 @@ lint-php:
- vendor/bin/ecs check --ansi
# phpstan - increase memory limit to 1GB to prevent script failure
- php -d memory_limit=1G vendor/bin/phpstan analyse --ansi
# FIXME: rector keeps failing in CI
# run rector to check for php errors
# - vendor/bin/rector process --dry-run --ansi
- vendor/bin/rector process --dry-run --ansi
dependencies:
- php-dependencies
lint-js:
stage: quality
script:
- npm run prettier
- npm run typecheck
- npm run lint
- npm run lint:css
- pnpm run prettier
- pnpm run typecheck
- pnpm run lint
- pnpm run lint:css
dependencies:
- js-dependencies
@ -74,10 +85,7 @@ tests:
MYSQL_DATABASE: "test"
MYSQL_USER: "castopod"
MYSQL_PASSWORD: "castopod"
script:
- apt-get update && apt-get install -y mariadb-client libmariadb-dev
- echo "SHOW DATABASES;" | mysql --user=root --password="$MYSQL_ROOT_PASSWORD" --host=mariadb "$MYSQL_DATABASE"
# run phpunit without code coverage
@ -128,7 +136,7 @@ release:
- chmod +x ./scripts/package.sh
# run semantic-release script (configured in `.releaserc.json` file)
- npm run release
- pnpm run release
dependencies:
- php-dependencies
- js-dependencies

View File

@ -0,0 +1 @@
{"version":1,"defects":[],"times":{"Tests\\Database\\ExampleDatabaseTest::testModelFindAll":0.003,"Tests\\Database\\ExampleDatabaseTest::testSoftDeleteLeavesRow":0.004,"modules\\Api\\Rest\\V1\\PodcastTest::testList":0.033,"modules\\Api\\Rest\\V1\\PodcastTest::testView":0.004,"modules\\Api\\Rest\\V1\\PodcastTest::testViewNotFound":0.01,"modules\\Api\\Rest\\V1\\PodcastTest::testListEmpty":4.313,"Tests\\Session\\ExampleSessionTest::testSessionSimple":0,"HealthTest::testIsDefinedAppPath":0,"HealthTest::testBaseUrlHasBeenSet":0.005}}

View File

@ -10,7 +10,7 @@ class Vite extends BaseConfig
{
public string $environment = 'production';
public string $baseUrl = 'http://localhost:3000/';
public string $baseUrl = 'http://localhost:5173/';
public string $assetsRoot = 'assets';

View File

@ -34,36 +34,6 @@ class Vite
private function loadProd(string $path, string $type): string
{
if ($type === 'css') {
if ($this->manifestCSSData === null) {
$cacheName = 'vite-manifest-css';
if (! ($cachedManifestCSS = cache($cacheName))) {
$manifestCSSPath = config('Vite')
->assetsRoot . '/' . config('Vite')
->manifestCSSFile;
try {
if (($manifestCSSContent = file_get_contents($manifestCSSPath)) !== false) {
$cachedManifestCSS = json_decode($manifestCSSContent, true);
cache()
->save($cacheName, $cachedManifestCSS, DECADE);
}
} catch (ErrorException) {
// ERROR when getting the manifest-css file
die("Could not load css manifest: <strong>{$manifestCSSPath}</strong> file not found!");
}
}
$this->manifestCSSData = $cachedManifestCSS;
}
if (array_key_exists($path, $this->manifestCSSData)) {
return $this->getHtmlTag(
'/' . config('Vite')->assetsRoot . '/' . $this->manifestCSSData[$path]['file'],
'css'
);
}
}
if ($this->manifestData === null) {
$cacheName = 'vite-manifest';
if (! ($cachedManifest = cache($cacheName))) {
@ -100,6 +70,14 @@ class Vite
if (array_key_exists('imports', $manifestElement)) {
foreach ($manifestElement['imports'] as $importPath) {
if (array_key_exists($importPath, $this->manifestData)) {
// import css dependencies if any
if (array_key_exists('css', $this->manifestData[$importPath])) {
foreach ($this->manifestData[$importPath]['css'] as $cssFile) {
$html .= $this->getHtmlTag('/' . config('Vite')->assetsRoot . '/' . $cssFile, 'css');
}
}
$html .= $this->getHtmlTag(
'/' . config('Vite')->assetsRoot . '/' . $this->manifestData[$importPath]['file'],
'js'

View File

@ -1,4 +1,3 @@
import "core-js";
import DrawCharts from "./modules/Charts";
DrawCharts();

View File

@ -1,4 +1,3 @@
import "core-js";
import DrawEpisodesMaps from "./modules/EpisodesMap";
DrawEpisodesMaps();

View File

@ -1,4 +1,3 @@
import { Coords } from "@floating-ui/core";
import {
arrow,
computePosition,
@ -47,7 +46,7 @@ const Tooltip = (): void => {
});
// Accessing the data
const { x: arrowX, y: arrowY } = middlewareData.arrow as Coords;
const { x: arrowX, y: arrowY } = middlewareData.arrow as any;
const staticSide = {
top: "bottom",

View File

@ -1,5 +1,5 @@
{
"name": "podlibre/castopod-host",
"name": "adaures/castopod",
"version": "1.1.2",
"type": "project",
"description": "Castopod is an open-source hosting platform made for podcasters who want engage and interact with their audience.",
@ -8,16 +8,16 @@
"require": {
"php": "^8.1",
"codeigniter4/framework": "v4.2.7",
"james-heinrich/getid3": "^2.0.x-dev",
"james-heinrich/getid3": "^2.0.0-beta5",
"whichbrowser/parser": "^v2.1.7",
"geoip2/geoip2": "v2.13.0",
"league/commonmark": "^2.3.7",
"league/commonmark": "^2.3.9",
"vlucas/phpdotenv": "v5.5.0",
"league/html-to-markdown": "^v5.1.0",
"opawg/user-agents-php": "^v1.0",
"adaures/ipcat-php": "^v1.0.0",
"adaures/podcast-persons-taxonomy": "^v1.0.0",
"phpseclib/phpseclib": "~2.0.39",
"phpseclib/phpseclib": "~2.0.41",
"michalsn/codeigniter4-uuid": "dev-develop",
"essence/essence": "^3.5.4",
"codeigniter4/settings": "^v2.1.0",
@ -27,12 +27,12 @@
},
"require-dev": {
"mikey179/vfsstream": "^v1.6.11",
"phpunit/phpunit": "^9.5.26",
"captainhook/captainhook": "^5.11.1",
"symplify/easy-coding-standard": "^10.3.3",
"phpstan/phpstan": "^1.9.2",
"rector/rector": "^0.14.8",
"symplify/coding-standard": "^10.3.3"
"phpunit/phpunit": "^10.0.11",
"captainhook/captainhook": "^5.14.4",
"symplify/easy-coding-standard": "^11.2.9",
"phpstan/phpstan": "^1.10.0",
"rector/rector": "^0.15.17",
"symplify/coding-standard": "^11.3.0"
},
"autoload": {
"exclude-from-classmap": [
@ -45,7 +45,7 @@
}
},
"scripts": {
"test": "vendor/bin/phpunit",
"test": "vendor/bin/phpunit --no-coverage",
"analyse": "vendor/bin/phpstan analyse --ansi",
"rector": "vendor/bin/rector process --dry-run --ansi --memory-limit=2G",
"rector:fix": "vendor/bin/rector process --ansi --memory-limit=2G",

1919
composer.lock generated

File diff suppressed because it is too large Load Diff

34
docker/ci/Dockerfile Normal file
View File

@ -0,0 +1,34 @@
####################################################
# Castopod CI/CD docker file
####################################################
# ⚠️ NOT optimized for production
# should be used only for continuous integration
#---------------------------------------------------
FROM php:8.1-fpm-alpine3.17
LABEL maintainer="Yassine Doghri <yassine@doghri.fr>"
RUN \
# install composer
curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/bin --filename=composer \
# install ci requirements
&& apk add --no-cache \
nodejs \
git \
unzip \
wget \
jq \
zip \
rsync \
mysql \
mysql-client \
&& docker-php-ext-install \
mysqli \
# install pnpm
&& wget -qO- https://get.pnpm.io/install.sh | ENV="~/.shrc" SHELL="$(which sh)" sh - \
&& mv ~/.local/share/pnpm/pnpm /usr/bin/pnpm \
&& rm -rf ~/.local \
# set pnpm store directory
&& pnpm config set store-dir .pnpm-store \
# set composer cache directory
&& composer config -g cache-dir .composer-cache

View File

@ -15,20 +15,12 @@ WORKDIR /castopod
COPY --from=composer:2 /usr/bin/composer /usr/bin/composer
# Install server requirements
RUN apt-get update \
# gnupg to sign commits with gpg
&& apt-get install --yes --no-install-recommends gnupg \
# npm through the nodejs package
&& curl -fsSL https://deb.nodesource.com/setup_16.x | bash - \
RUN curl -fsSL https://deb.nodesource.com/setup_16.x | bash - \
&& apt-get update \
&& apt-get install --yes --no-install-recommends nodejs \
# update npm
&& npm install --global npm@8 \
&& apt-get update \
&& apt-get install --yes --no-install-recommends \
git \
# gnupg to sign commits with gpg
gnupg \
openssh-client \
vim \
# cron for scheduled tasks
cron \
# unzip used by composer

View File

@ -1,4 +1,4 @@
FROM docker.io/php:8.1-fpm-alpine3.16
FROM docker.io/php:8.1-fpm-alpine3.17
COPY docker/production/app/entrypoint.sh /entrypoint.sh

View File

@ -34,7 +34,7 @@ to help you kickstart your contribution.
```ini
CI_ENVIRONMENT="development"
# If set to development, you must run `npm run dev` to start the static assets server
# If set to development, you must run `pnpm run dev` to start the static assets server
vite.environment="development"
# By default, this is set to true in the app config.
@ -90,7 +90,7 @@ required services will be loaded automagically! 🪄
```bash
# run Vite dev server
npm run dev
pnpm run dev
```
If there is any issue with the php server not running, you can restart them
@ -113,8 +113,8 @@ required services will be loaded automagically! 🪄
# Composer is installed
composer -V
# npm is installed
npm -v
# pnpm is installed
pnpm -v
# git is installed
git version
@ -181,8 +181,8 @@ You do not wish to use the VSCode devcontainer? No problem!
# use Composer
docker-compose run --rm app composer -V
# use npm
docker-compose run --rm app npm -v
# use pnpm
docker-compose run --rm app pnpm -v
# use git
docker-compose run --rm app git version
@ -210,18 +210,19 @@ You do not wish to use the VSCode devcontainer? No problem!
:::
2. Install javascript dependencies with [npm](https://www.npmjs.com/)
2. Install javascript dependencies with [pnpm](https://pnpm.io/)
```bash
npm install
pnpm install
```
::: info Note
The javascript dependencies aren't included in the repository. Npm will check
the `package.json` and `package.lock` files to download the packages with the
right versions. The dependencies will live under the `node_module` folder.
For more info, check out the [NPM documentation](https://docs.npmjs.com/).
The javascript dependencies aren't included in the repository. pnPM will
check the `package.json` and `pnpm-lock.yaml` files to download the packages
with the right versions. The dependencies will live under the `node_module`
folder. For more info, check out the
[pnPM documentation](https://pnpm.io/motivation).
:::
@ -229,11 +230,11 @@ You do not wish to use the VSCode devcontainer? No problem!
```bash
# build all static assets at once
npm run build:static
pnpm run build:static
# build specific assets
npm run build:icons
npm run build:svg
pnpm run build:icons
pnpm run build:svg
```
::: info Note
@ -372,10 +373,10 @@ more insights.
### Allocation failed - JavaScript heap out of memory
This happens when running `npm install`.
This happens when running `pnpm install`.
👉 By default, docker might not have access to enough RAM. Allocate more memory
and run `npm install` again.
and run `pnpm install` again.
### (Linux) Files created inside container are attributed to root locally

28902
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -1,5 +1,5 @@
{
"name": "castopod-host",
"name": "castopod",
"version": "1.1.2",
"description": "Castopod Host is an open-source hosting platform made for podcasters who want engage and interact with their audience.",
"private": true,
@ -12,7 +12,7 @@
"dev": "vite",
"build": "tsc && vite build",
"serve": "vite preview",
"build:static": "npm run build:icons && npm run build:svg",
"build:static": "pnpm run build:icons && pnpm run build:svg",
"build:icons": "svgo -f app/Resources/icons -o public/assets/icons -r --config=./.svgo.icons.js",
"build:svg": "svgo -f app/Resources/images -o public/assets/images -r --config=./.svgo.js",
"lint": "eslint --ext js,ts app/Resources",
@ -27,68 +27,71 @@
"prepare": "is-ci || husky install"
},
"dependencies": {
"@amcharts/amcharts4": "^4.10.29",
"@amcharts/amcharts4-geodata": "^4.1.23",
"@codemirror/commands": "^6.1.2",
"@codemirror/lang-xml": "^6.0.0",
"@codemirror/language": "^6.2.1",
"@codemirror/state": "^6.1.2",
"@floating-ui/dom": "^1.0.2",
"@amcharts/amcharts4": "^4.10.34",
"@amcharts/amcharts4-geodata": "^4.1.26",
"@codemirror/commands": "^6.2.1",
"@codemirror/lang-xml": "^6.0.2",
"@codemirror/language": "^6.6.0",
"@codemirror/state": "^6.2.0",
"@codemirror/view": "^6.9.1",
"@floating-ui/dom": "^1.2.1",
"@github/clipboard-copy-element": "^1.1.2",
"@github/hotkey": "^2.0.1",
"@github/markdown-toolbar-element": "^2.1.1",
"@github/time-elements": "^3.1.4",
"@tailwindcss/nesting": "^0.0.0-insiders.565cd3e",
"@vime/core": "^5.3.3",
"choices.js": "^10.1.0",
"@github/time-elements": "^4.0.0",
"@tailwindcss/nesting": "0.0.0-insiders.565cd3e",
"@vime/core": "^5.4.0",
"choices.js": "^10.2.0",
"codemirror": "^6.0.1",
"flatpickr": "^4.6.13",
"leaflet": "^1.9.2",
"leaflet": "^1.9.3",
"leaflet.markercluster": "^1.5.3",
"lit": "^2.4.0",
"marked": "^4.1.1",
"wavesurfer.js": "^6.3.0",
"xml-formatter": "^2.6.1"
"lit": "^2.6.1",
"marked": "^4.2.12",
"wavesurfer.js": "^6.4.0",
"xml-formatter": "^3.2.0"
},
"devDependencies": {
"@commitlint/cli": "^17.1.2",
"@commitlint/config-conventional": "^17.1.0",
"@semantic-release/changelog": "^6.0.1",
"@commitlint/cli": "^17.4.4",
"@commitlint/config-conventional": "^17.4.4",
"@semantic-release/changelog": "^6.0.2",
"@semantic-release/exec": "^6.0.3",
"@semantic-release/git": "^10.0.1",
"@semantic-release/gitlab": "^9.4.2",
"@semantic-release/gitlab": "^11.0.1",
"@tailwindcss/forms": "^0.5.3",
"@tailwindcss/line-clamp": "^0.4.2",
"@tailwindcss/typography": "^0.5.7",
"@types/leaflet": "^1.9.0",
"@types/marked": "^4.0.7",
"@tailwindcss/typography": "^0.5.9",
"@types/leaflet": "^1.9.1",
"@types/marked": "^4.0.8",
"@types/wavesurfer.js": "^6.0.3",
"@typescript-eslint/eslint-plugin": "^5.40.0",
"@typescript-eslint/parser": "^5.40.0",
"@typescript-eslint/eslint-plugin": "^5.53.0",
"@typescript-eslint/parser": "^5.53.0",
"all-contributors-cli": "^6.24.0",
"commitizen": "^4.3.0",
"cross-env": "^7.0.3",
"cssnano": "^5.1.13",
"cssnano": "^5.1.15",
"cz-conventional-changelog": "^3.3.0",
"eslint": "^8.25.0",
"eslint-config-prettier": "^8.5.0",
"eslint": "^8.34.0",
"eslint-config-prettier": "^8.6.0",
"eslint-plugin-prettier": "^4.2.1",
"husky": "^8.0.1",
"husky": "^8.0.3",
"is-ci": "^3.0.1",
"lint-staged": "^13.0.3",
"postcss-import": "^15.0.0",
"postcss-nesting": "^10.2.0",
"postcss-preset-env": "^7.8.2",
"lint-staged": "^13.1.2",
"postcss": "^8.4.21",
"postcss-import": "^15.1.0",
"postcss-nesting": "^11.2.1",
"postcss-preset-env": "^8.0.1",
"postcss-reporter": "^7.0.5",
"prettier": "2.7.1",
"prettier-plugin-organize-imports": "^3.1.1",
"semantic-release": "^19.0.5",
"stylelint": "^14.14.0",
"stylelint-config-standard": "^29.0.0",
"svgo": "^2.8.0",
"tailwindcss": "^3.1.8",
"typescript": "^4.8.4",
"vite": "2.8.6",
"vite-plugin-pwa": "^0.12.8",
"prettier": "2.8.4",
"prettier-plugin-organize-imports": "^3.2.2",
"semantic-release": "^20.1.0",
"stylelint": "^15.2.0",
"stylelint-config-standard": "^30.0.1",
"svgo": "^3.0.2",
"tailwindcss": "^3.2.7",
"typescript": "^4.9.5",
"vite": "4.1.3",
"vite-plugin-pwa": "^0.14.4",
"workbox-build": "^6.5.4",
"workbox-core": "^6.5.4",
"workbox-routing": "^6.5.4",

View File

@ -1,56 +1,45 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
bootstrap="vendor/codeigniter4/framework/system/Test/bootstrap.php"
backupGlobals="false"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
stopOnError="false"
stopOnFailure="false"
stopOnIncomplete="false"
stopOnSkipped="false"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
<coverage includeUncoveredFiles="true" processUncoveredFiles="true">
<include>
<directory suffix=".php">./app</directory>
</include>
<exclude>
<directory suffix=".php">./app/Views</directory>
<file>./app/Config/Routes.php</file>
</exclude>
<report>
<clover outputFile="build/logs/clover.xml"/>
<html outputDirectory="build/logs/html"/>
<php outputFile="build/logs/coverage.serialized"/>
<text outputFile="php://stdout" showUncoveredFiles="false"/>
</report>
</coverage>
<testsuites>
<testsuite name="App">
<directory>./tests</directory>
</testsuite>
</testsuites>
<logging>
<testdoxHtml outputFile="build/logs/testdox.html"/>
<testdoxText outputFile="build/logs/testdox.txt"/>
<junit outputFile="build/logs/logfile.xml"/>
</logging>
<php>
<server name="app.baseURL" value="http://example.com/"/>
<!-- Directory containing phpunit.xml -->
<const name="HOMEPATH" value="./"/>
<!-- Directory containing the Paths config file -->
<const name="CONFIGPATH" value="./app/Config/"/>
<!-- Directory containing the front controller (index.php) -->
<const name="PUBLICPATH" value="./public/"/>
<!-- Database configuration -->
<env name="database.tests.hostname" value="mariadb"/>
<env name="database.tests.database" value="test"/>
<env name="database.tests.username" value="castopod"/>
<env name="database.tests.password" value="castopod"/>
<env name="database.tests.DBDriver" value="MySQLi"/>
<env name="database.tests.DBPrefix" value="tests_"/>
<env name="restapi.enabled" value="true"/>
</php>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" bootstrap="vendor/codeigniter4/framework/system/Test/bootstrap.php" backupGlobals="false" colors="true" stopOnError="false" stopOnFailure="false" stopOnIncomplete="false" stopOnSkipped="false" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.0/phpunit.xsd" cacheDirectory=".phpunit.cache">
<coverage includeUncoveredFiles="true">
<include>
<directory suffix=".php">./app</directory>
</include>
<exclude>
<directory suffix=".php">./app/Views</directory>
<file>./app/Config/Routes.php</file>
</exclude>
<report>
<clover outputFile="build/logs/clover.xml"/>
<html outputDirectory="build/logs/html"/>
<php outputFile="build/logs/coverage.serialized"/>
<text outputFile="php://stdout" showUncoveredFiles="false"/>
</report>
</coverage>
<testsuites>
<testsuite name="App">
<directory>./tests</directory>
</testsuite>
</testsuites>
<logging>
<testdoxHtml outputFile="build/logs/testdox.html"/>
<testdoxText outputFile="build/logs/testdox.txt"/>
<junit outputFile="build/logs/logfile.xml"/>
</logging>
<php>
<server name="app.baseURL" value="http://example.com/"/>
<!-- Directory containing phpunit.xml -->
<const name="HOMEPATH" value="./"/>
<!-- Directory containing the Paths config file -->
<const name="CONFIGPATH" value="./app/Config/"/>
<!-- Directory containing the front controller (index.php) -->
<const name="PUBLICPATH" value="./public/"/>
<!-- Database configuration -->
<env name="database.tests.hostname" value="mariadb"/>
<env name="database.tests.database" value="test"/>
<env name="database.tests.username" value="castopod"/>
<env name="database.tests.password" value="castopod"/>
<env name="database.tests.DBDriver" value="MySQLi"/>
<env name="database.tests.DBPrefix" value="tests_"/>
<env name="restapi.enabled" value="true"/>
</php>
</phpunit>

13125
pnpm-lock.yaml Normal file

File diff suppressed because it is too large Load Diff

View File

@ -27,7 +27,6 @@ return static function (RectorConfig $rectorConfig): void {
$rectorConfig->sets([
SetList::PHP_81,
SetList::TYPE_DECLARATION,
SetList::TYPE_DECLARATION_STRICT,
SetList::CODE_QUALITY,
SetList::CODING_STYLE,
SetList::EARLY_RETURN,

View File

@ -1,9 +1,9 @@
#!/bin/bash
#!/bin/sh
set -e
# install only production dependencies using the --no-dev option
composer install --no-dev --prefer-dist --no-ansi --no-interaction --no-progress --ignore-platform-reqs
# build all production static assets (css, js, images, icons, fonts, etc.)
npm run build
npm run build:static
pnpm run build
pnpm run build:static

View File

@ -1,11 +1,10 @@
#!/bin/bash
#!/bin/sh
set -e
VERSION=$1
COMPOSER_VERSION=$(echo "$VERSION" | perl -pe 's/(?<=[alpha|beta])\.//g')
# replace composer.json version using jq
apt-get install jq -y
echo "$( jq '.version = "'$COMPOSER_VERSION'"' composer.json )" > composer.json
# replace CP_VERSION constant in app/config/constants
@ -14,17 +13,11 @@ sed -i "s/^defined('CP_VERSION').*/defined('CP_VERSION') || define('CP_VERSION',
# fill CP_VERSION.env for docker build
echo "$VERSION" > ./CP_VERSION.env
# install wget to download archives
apt-get install wget
# download GeoLite2-City archive and extract it to writable/uploads
wget -c "https://download.maxmind.com/app/geoip_download?edition_id=GeoLite2-City&license_key=$MAXMIND_LICENCE_KEY&suffix=tar.gz" -O - | tar -xz -C ./writable/uploads/
# rename extracted archives' folders
mv ./writable/uploads/GeoLite2-City* ./writable/uploads/GeoLite2-City
# install rsync for file transfers
apt-get install rsync -y
# create castopod folder bundle: uses .rsync-filter (-F) file to copy only needed files
rsync -aF --progress . ./castopod

View File

@ -1,4 +1,4 @@
#!/bin/bash
#!/bin/sh
set -e
# see https://github.com/conventional-changelog/commitlint/issues/885

View File

@ -1,10 +1,8 @@
#!/bin/bash
#!/bin/sh
set -e
VERSION=$1
apt-get install zip -y
# create zip and tar.gz packages for release upload
zip -r castopod-$VERSION.zip castopod
tar -zcvf castopod-$VERSION.tar.gz castopod

View File

@ -1,67 +0,0 @@
// This plugin adds a `manifest-css.json` file for css assets to help reference them from the backend
// Adapted from https://github.com/ElMassimo/vite_ruby/blob/main/vite-plugin-ruby/src/manifest.ts
import path from "path";
import { OutputBundle } from "rollup";
import type { Plugin, ResolvedConfig } from "vite";
interface AssetsManifestChunk {
src?: string;
file: string;
}
type AssetsManifest = Map<string, AssetsManifestChunk>;
// Internal: Returns the filename without the last extension.
function withoutExtension(filename: string) {
return filename.substr(0, filename.lastIndexOf("."));
}
// Internal: Writes a manifest file that allows to map an entrypoint asset file
// name to the corresponding output file name.
export function ManifestCSS(): Plugin {
let config: ResolvedConfig;
// Internal: For stylesheets Vite does not output the result to the manifest,
// so we extract the file name of the processed asset from the Rollup bundle.
function extractChunkStylesheets(
bundle: OutputBundle,
manifest: AssetsManifest
) {
const cssFiles = new Set(
Object.values(config.build.rollupOptions.input as Record<string, string>)
.filter((file) => new RegExp(`\\.css$`).test(file))
.map((file) => path.relative(config.root, file))
);
Object.values(bundle)
.filter((chunk) => chunk.type === "asset" && chunk.name)
.forEach((chunk) => {
// NOTE: Rollup appends `.css` to the file so it's removed before matching.
// See `resolveEntrypointsForRollup`.
const src = withoutExtension(chunk.name!);
if (cssFiles.has(src)) {
manifest.set(src, { file: chunk.fileName, src });
}
});
}
return {
name: "vite-assets-manifest",
apply: "build",
enforce: "post",
configResolved(resolvedConfig: ResolvedConfig) {
config = resolvedConfig;
},
async generateBundle(_options, bundle) {
const manifest: AssetsManifest = new Map();
extractChunkStylesheets(bundle, manifest);
this.emitFile({
fileName: "manifest-css.json",
type: "asset",
source: JSON.stringify(Object.fromEntries(manifest), null, 2),
});
},
};
}

View File

@ -1,6 +1,5 @@
import { defineConfig } from "vite";
import { VitePWA } from "vite-plugin-pwa";
import { ManifestCSS } from "./vite-manifest-css";
// https://vitejs.dev/config/
export default defineConfig({
@ -28,7 +27,6 @@ export default defineConfig({
},
},
plugins: [
ManifestCSS(),
VitePWA({
manifest: false,
outDir: "../../public",