commit 2cc054f9892a9c44da470ba403da4ae7ecf199fd Author: Jérémy Dufraisse Date: Tue Jan 24 10:21:02 2023 +0100 feat(pico): forked from picocms/Pico diff --git a/.build/clean.sh b/.build/clean.sh new file mode 100644 index 0000000..a816cb8 --- /dev/null +++ b/.build/clean.sh @@ -0,0 +1,25 @@ +#!/usr/bin/env bash +set -e + +[ -n "$PICO_BUILD_ENV" ] || { echo "No Pico build environment specified" >&2; exit 1; } + +# parameters +ARCHIVE_DIR="${1:-$PICO_PROJECT_DIR}" # directory to create release archives in + +# print parameters +echo "Cleaning up build environment..." +printf 'PICO_DEPLOY_DIR="%s"\n' "$PICO_DEPLOY_DIR" +printf 'PICO_BUILD_DIR="%s"\n' "$PICO_BUILD_DIR" +printf 'ARCHIVE_DIR="%s"\n' "$ARCHIVE_DIR" +echo + +echo "Removing deployment directory..." +[ ! -d "$PICO_DEPLOY_DIR" ] || rm -rf "$PICO_DEPLOY_DIR" + +echo "Removing build directory..." +[ ! -d "$PICO_BUILD_DIR" ] || rm -rf "$PICO_BUILD_DIR" + +echo "Removing release archives..." +find "$ARCHIVE_DIR" -mindepth 1 -maxdepth 1 \ + \( -name 'pico-release-*.tar.gz' -o -name 'pico-release-*.zip' \) \ + -delete diff --git a/.build/deploy-branch.sh b/.build/deploy-branch.sh new file mode 100644 index 0000000..d8284a7 --- /dev/null +++ b/.build/deploy-branch.sh @@ -0,0 +1,44 @@ +#!/usr/bin/env bash +set -e + +[ -n "$PICO_BUILD_ENV" ] || { echo "No Pico build environment specified" >&2; exit 1; } + +# get current Pico milestone +VERSION="$(php -r "require_once('$PICO_PROJECT_DIR/lib/Pico.php'); echo Pico::VERSION;")" +MILESTONE="Pico$([[ "$VERSION" =~ ^([0-9]+\.[0-9]+)\. ]] && echo " ${BASH_REMATCH[1]}")" + +echo "Deploying $PROJECT_REPO_BRANCH branch ($MILESTONE)..." +echo + +# clone repo +github-clone.sh "$PICO_DEPLOY_DIR" "https://github.com/$DEPLOY_REPO_SLUG.git" "$DEPLOY_REPO_BRANCH" + +cd "$PICO_DEPLOY_DIR" + +# setup repo +github-setup.sh + +# generate phpDocs +generate-phpdoc.sh \ + "$PICO_PROJECT_DIR/.phpdoc.xml" \ + "$PICO_DEPLOY_DIR/phpDoc/$PICO_DEPLOYMENT.cache" "$PICO_DEPLOY_DIR/phpDoc/$PICO_DEPLOYMENT" \ + "$MILESTONE API Documentation ($PROJECT_REPO_BRANCH branch)" + +if [ -z "$(git status --porcelain "$PICO_DEPLOY_DIR/phpDoc/$PICO_DEPLOYMENT.cache")" ]; then + # nothing to do + exit 0 +fi + +# update phpDoc list +update-phpdoc-list.sh \ + "$PICO_DEPLOY_DIR/_data/phpDoc.yml" \ + "$PICO_DEPLOYMENT" "branch" "$PROJECT_REPO_BRANCH branch" "$(date +%s)" + +# commit phpDocs +github-commit.sh \ + "Update phpDocumentor class docs for $PROJECT_REPO_BRANCH branch @ $PROJECT_REPO_COMMIT" \ + "$PICO_DEPLOY_DIR/phpDoc/$PICO_DEPLOYMENT.cache" "$PICO_DEPLOY_DIR/phpDoc/$PICO_DEPLOYMENT" \ + "$PICO_DEPLOY_DIR/_data/phpDoc.yml" + +# deploy phpDocs +github-deploy.sh "$PROJECT_REPO_SLUG" "heads/$PROJECT_REPO_BRANCH" "$PROJECT_REPO_COMMIT" diff --git a/.build/deploy-release.sh b/.build/deploy-release.sh new file mode 100644 index 0000000..eef5d70 --- /dev/null +++ b/.build/deploy-release.sh @@ -0,0 +1,119 @@ +#!/usr/bin/env bash +set -e + +[ -n "$PICO_BUILD_ENV" ] || { echo "No Pico build environment specified" >&2; exit 1; } + +DEPLOY_FULL="true" +if [ "$DEPLOY_PHPDOC_RELEASES" != "true" ]; then + echo "Skipping phpDoc release deployment because it has been disabled" + DEPLOY_FULL="false" +fi +if [ "$DEPLOY_VERSION_BADGE" != "true" ]; then + echo "Skipping version badge deployment because it has been disabled" + DEPLOY_FULL="false" +fi +if [ "$DEPLOY_VERSION_FILE" != "true" ]; then + echo "Skipping version file deployment because it has been disabled" + DEPLOY_FULL="false" +fi +if [ "$DEPLOY_CLOC_STATS" != "true" ]; then + echo "Skipping cloc statistics deployment because it has been disabled" + DEPLOY_FULL="false" +fi + +if [ "$DEPLOY_FULL" != "true" ]; then + if [ "$DEPLOY_PHPDOC_RELEASES" != "true" ] \ + && [ "$DEPLOY_VERSION_BADGE" != "true" ] \ + && [ "$DEPLOY_VERSION_FILE" != "true" ] \ + && [ "$DEPLOY_CLOC_STATS" != "true" ] + then + # nothing to do + exit 0 + fi + echo +fi + +# parse version +. "$PICO_TOOLS_DIR/functions/parse-version.sh.inc" + +if ! parse_version "$PROJECT_REPO_TAG"; then + echo "Invalid version '$PROJECT_REPO_TAG'; aborting..." >&2 + exit 1 +fi + +echo "Deploying Pico $VERSION_MILESTONE ($VERSION_STABILITY)..." +printf 'VERSION_FULL="%s"\n' "$VERSION_FULL" +printf 'VERSION_NAME="%s"\n' "$VERSION_NAME" +printf 'VERSION_ID="%s"\n' "$VERSION_ID" +echo + +# clone repo +github-clone.sh "$PICO_DEPLOY_DIR" "https://github.com/$DEPLOY_REPO_SLUG.git" "$DEPLOY_REPO_BRANCH" + +cd "$PICO_DEPLOY_DIR" + +# setup repo +github-setup.sh + +# generate phpDocs +if [ "$DEPLOY_PHPDOC_RELEASES" == "true" ]; then + # generate phpDocs + generate-phpdoc.sh \ + "$PICO_PROJECT_DIR/.phpdoc.xml" \ + "-" "$PICO_DEPLOY_DIR/phpDoc/$PICO_DEPLOYMENT" \ + "Pico $VERSION_MILESTONE API Documentation (v$VERSION_FULL)" + + if [ -n "$(git status --porcelain "$PICO_DEPLOY_DIR/phpDoc/$PICO_DEPLOYMENT")" ]; then + # update phpDoc list + update-phpdoc-list.sh \ + "$PICO_DEPLOY_DIR/_data/phpDoc.yml" \ + "$PICO_DEPLOYMENT" "version" "Pico $VERSION_FULL" "$(date +%s)" + + # commit phpDocs + github-commit.sh \ + "Update phpDocumentor class docs for v$VERSION_FULL" \ + "$PICO_DEPLOY_DIR/phpDoc/$PICO_DEPLOYMENT" "$PICO_DEPLOY_DIR/_data/phpDoc.yml" + fi +fi + +# don't update version badge, version file and cloc statistics for pre-releases +if [ "$VERSION_STABILITY" == "stable" ]; then + # update version badge + if [ "$DEPLOY_VERSION_BADGE" == "true" ]; then + generate-badge.sh \ + "$PICO_DEPLOY_DIR/badges/pico-version.svg" \ + "release" "$VERSION_FULL" "blue" + + # commit version badge + github-commit.sh \ + "Update version badge for v$VERSION_FULL" \ + "$PICO_DEPLOY_DIR/badges/pico-version.svg" + fi + + # update version file + if [ "$DEPLOY_VERSION_FILE" == "true" ]; then + update-version-file.sh \ + "$PICO_DEPLOY_DIR/_data/version.yml" \ + "$VERSION_FULL" + + # commit version file + github-commit.sh \ + "Update version file for v$VERSION_FULL" \ + "$PICO_DEPLOY_DIR/_data/version.yml" + fi + + # update cloc statistics + if [ "$DEPLOY_CLOC_STATS" == "true" ]; then + update-cloc-stats.sh \ + "$PICO_PROJECT_DIR" \ + "$PICO_DEPLOY_DIR/_data/cloc.yml" + + # commit cloc statistics + github-commit.sh \ + "Update cloc statistics for v$VERSION_FULL" \ + "$PICO_DEPLOY_DIR/_data/cloc.yml" + fi +fi + +# deploy +github-deploy.sh "$PROJECT_REPO_SLUG" "tags/$PROJECT_REPO_TAG" "$PROJECT_REPO_COMMIT" diff --git a/.build/init.sh.inc b/.build/init.sh.inc new file mode 100644 index 0000000..e9cee44 --- /dev/null +++ b/.build/init.sh.inc @@ -0,0 +1,19 @@ +if [ -z "$PICO_BUILD_ENV" ]; then + echo "No Pico build environment specified" >&2 + exit 1 +fi + +# add project build dir to $PATH +export PATH="$PICO_PROJECT_DIR/.build:$PATH" + +# set environment variables +__picocms_cmd export RELEASE_REPO_SLUG="${RELEASE_REPO_SLUG:-picocms/pico-composer}" +__picocms_cmd export RELEASE_REPO_BRANCH="${RELEASE_REPO_BRANCH:-master}" + +if [ "$PROJECT_REPO_SLUG" != "picocms/Pico" ]; then + __picocms_cmd export DEPLOY_REPO_SLUG="${DEPLOY_REPO_SLUG:-$PROJECT_REPO_SLUG}" + __picocms_cmd export DEPLOY_REPO_BRANCH="${DEPLOY_REPO_BRANCH:-gh-pages}" +else + __picocms_cmd export DEPLOY_REPO_SLUG="${DEPLOY_REPO_SLUG:-picocms.github.io}" + __picocms_cmd export DEPLOY_REPO_BRANCH="${DEPLOY_REPO_BRANCH:-master}" +fi diff --git a/.build/install.sh b/.build/install.sh new file mode 100644 index 0000000..dff079c --- /dev/null +++ b/.build/install.sh @@ -0,0 +1,40 @@ +#!/usr/bin/env bash +set -e + +[ -n "$PICO_BUILD_ENV" ] || { echo "No Pico build environment specified" >&2; exit 1; } + +# setup build system +BUILD_REQUIREMENTS=( --phpcs ) +[ "$1" != "--deploy" ] || BUILD_REQUIREMENTS+=( --cloc --phpdoc ) +"$PICO_TOOLS_DIR/setup/$PICO_BUILD_ENV.sh" "${BUILD_REQUIREMENTS[@]}" + +# set COMPOSER_ROOT_VERSION when necessary +if [ -z "$COMPOSER_ROOT_VERSION" ] && [ -n "$PROJECT_REPO_BRANCH" ]; then + echo "Setting up Composer..." + + PICO_VERSION_PATTERN="$(php -r " + \$json = json_decode(file_get_contents('$PICO_PROJECT_DIR/composer.json'), true); + if (\$json !== null) { + if (isset(\$json['extra']['branch-alias']['dev-$PROJECT_REPO_BRANCH'])) { + echo 'dev-$PROJECT_REPO_BRANCH'; + } + } + ")" + + if [ -z "$PICO_VERSION_PATTERN" ]; then + PICO_VERSION_PATTERN="$(php -r " + require_once('$PICO_PROJECT_DIR/lib/Pico.php'); + echo preg_replace('/\.[0-9]+-dev$/', '.x-dev', Pico::VERSION); + ")" + fi + + if [ -n "$PICO_VERSION_PATTERN" ]; then + export COMPOSER_ROOT_VERSION="$PICO_VERSION_PATTERN" + fi + + echo +fi + +# install dependencies +echo "Running \`composer install\`$([ -n "$COMPOSER_ROOT_VERSION" ] && echo -n " ($COMPOSER_ROOT_VERSION)")..." +composer install --no-suggest diff --git a/.build/release.sh b/.build/release.sh new file mode 100644 index 0000000..7a2cc1d --- /dev/null +++ b/.build/release.sh @@ -0,0 +1,91 @@ +#!/usr/bin/env bash +set -e + +[ -n "$PICO_BUILD_ENV" ] || { echo "No Pico build environment specified" >&2; exit 1; } + +# parameters +VERSION="${1:-$PROJECT_REPO_TAG}" # version to create a release for +ARCHIVE_DIR="${2:-$PICO_PROJECT_DIR}" # directory to create release archives in + +# print parameters +echo "Creating new release..." +printf 'VERSION="%s"\n' "$VERSION" +echo + +# guess version string +if [ -z "$VERSION" ]; then + PICO_VERSION="$(php -r " + require_once('$PICO_PROJECT_DIR/lib/Pico.php'); + echo preg_replace('/-(?:dev|n|nightly)(?:[.-]?[0-9]+)?(?:[.-]dev)?$/', '', Pico::VERSION); + ")" + + VERSION="v$PICO_VERSION-dev+${PROJECT_REPO_BRANCH:-master}" + echo "Creating development release of Pico v$PICO_VERSION ($VERSION)..." + echo +fi + +# parse version +. "$PICO_TOOLS_DIR/functions/parse-version.sh.inc" + +if ! parse_version "$VERSION"; then + echo "Unable to create release archive: Invalid version '$VERSION'" >&2 + exit 1 +fi + +DEPENDENCY_VERSION="$VERSION_FULL@$VERSION_STABILITY" +if [ "$VERSION_STABILITY" == "dev" ] && [ -n "$VERSION_BUILD" ]; then + DEPENDENCY_VERSION="dev-$VERSION_BUILD" +fi + +# clone repo +github-clone.sh "$PICO_BUILD_DIR" "https://github.com/$RELEASE_REPO_SLUG.git" "$RELEASE_REPO_BRANCH" + +cd "$PICO_BUILD_DIR" + +# force Pico version +echo "Updating composer dependencies..." +composer require --no-update \ + "picocms/pico $DEPENDENCY_VERSION" \ + "picocms/pico-theme $DEPENDENCY_VERSION" \ + "picocms/pico-deprecated $DEPENDENCY_VERSION" +echo + +# force minimum stability <= beta due to Parsedown 1.8 currently being in beta +if [ "$VERSION_STABILITY" == "stable" ] || [ "$VERSION_STABILITY" == "rc" ]; then + VERSION_STABILITY="beta" +fi + +# set minimum stability +if [ "$VERSION_STABILITY" != "stable" ]; then + echo "Setting minimum stability to '$VERSION_STABILITY'..." + composer config "minimum-stability" "$VERSION_STABILITY" + composer config "prefer-stable" "true" + echo +fi + +# install dependencies +echo "Running \`composer install\`..." +composer install --no-suggest --prefer-dist --no-dev --optimize-autoloader +echo + +# prepare release +echo "Replacing 'index.php'..." +cp vendor/picocms/pico/index.php.dist index.php + +echo "Adding 'README.md', 'CONTRIBUTING.md', 'CHANGELOG.md'..." +cp vendor/picocms/pico/README.md README.md +cp vendor/picocms/pico/CONTRIBUTING.md CONTRIBUTING.md +cp vendor/picocms/pico/CHANGELOG.md CHANGELOG.md + +echo "Removing '.git' directories of plugins and themes..." +find themes/ -type d -path 'themes/*/.git' -print0 | xargs -0 rm -rf +find plugins/ -type d -path 'plugins/*/.git' -print0 | xargs -0 rm -rf + +echo "Preparing 'composer.json' for release..." +composer require --no-update \ + "picocms/pico ^$VERSION_MILESTONE" \ + "picocms/pico-theme ^$VERSION_MILESTONE" \ + "picocms/pico-deprecated ^$VERSION_MILESTONE" + +# create release archives +create-release.sh "$PICO_BUILD_DIR" "$ARCHIVE_DIR" "pico-release-v$VERSION_FULL" diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..bc9dbf2 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,12 @@ +/.build export-ignore +/.github export-ignore +/assets/.gitignore export-ignore +/config/.gitignore export-ignore +/content/.gitignore export-ignore +/plugins/.gitignore export-ignore +/themes/.gitignore export-ignore +/.gitattributes export-ignore +/.gitignore export-ignore +/.phpcs.xml export-ignore +/.phpdoc.xml export-ignore +/.travis.yml export-ignore diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml new file mode 100644 index 0000000..0679ce7 --- /dev/null +++ b/.github/FUNDING.yml @@ -0,0 +1 @@ +custom: https://www.bountysource.com/teams/picocms diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 0000000..ec08db4 --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,48 @@ + diff --git a/.github/workflows/stale.yml b/.github/workflows/stale.yml new file mode 100644 index 0000000..878d942 --- /dev/null +++ b/.github/workflows/stale.yml @@ -0,0 +1,28 @@ +name: "Mark or close stale issues and PRs" +on: + schedule: + - cron: "0 12 * * *" + +jobs: + stale: + runs-on: ubuntu-latest + steps: + - uses: actions/stale@v3 + with: + repo-token: ${{ secrets.GITHUB_TOKEN }} + days-before-stale: 7 + days-before-close: 2 + stale-issue-message: > + This issue has been automatically marked as stale because it has not had + recent activity. It will be closed in two days if no further activity + occurs. Thank you for your contributions! :+1: + stale-pr-message: > + This pull request has been automatically marked as stale because it has not had + recent activity. It will be closed in two days if no further activity + occurs. Thank you for your contributions! :+1: + stale-pr-label: "info: Stale" + stale-issue-label: "info: Stale" + exempt-issue-labels: "type: Bug,type: Enhancement,type: Feature,type: Idea,type: Release,info: Pinned" + exempt-pr-labels: "type: Bug,type: Enhancement,type: Feature,type: Idea,type: Release,info: Pinned" + remove-stale-when-updated: true + diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..490151f --- /dev/null +++ b/.gitignore @@ -0,0 +1,26 @@ +# Linux +*~ +*.swp + +# Windows +Thumbs.db +desktop.ini + +# Mac OS X +.DS_Store +._* + +# Composer +/composer.lock +/vendor + +# Build system +/.build/build +/.build/deploy +/.build/ci-tools +/pico-release-*.tar.gz +/pico-release-*.zip + +# phpDocumentor +/.build/phpdoc +/.build/phpdoc.cache diff --git a/.htaccess b/.htaccess new file mode 100644 index 0000000..b3e7685 --- /dev/null +++ b/.htaccess @@ -0,0 +1,23 @@ + + RewriteEngine On + # May be required to access sub directories + #RewriteBase / + + # Deny access to internal dirs and files by passing the URL to Pico + RewriteRule ^(config|content|content-sample|lib|vendor)(/|$) index.php [L] + RewriteRule ^(CHANGELOG\.md|composer\.(json|lock|phar))(/|$) index.php [L] + RewriteRule (^\.|/\.)(?!well-known(/|$)) index.php [L] + + # Enable URL rewriting + RewriteCond %{REQUEST_FILENAME} !-f + RewriteCond %{REQUEST_FILENAME} !-d + RewriteRule ^ index.php [L] + + + # Let Pico know about available URL rewriting + SetEnv PICO_URL_REWRITING 1 + + + +# Prevent file browsing +Options -Indexes -MultiViews diff --git a/.phpcs.xml b/.phpcs.xml new file mode 100644 index 0000000..2592313 --- /dev/null +++ b/.phpcs.xml @@ -0,0 +1,56 @@ + + + + Pico's coding standards mainly base on the PHP-FIG PSR-2 standard, + but without the MissingNamespace sniff. + + + + . + + + ^.build/ + ^.github/ + ^vendor/ + *.min.js + + + + + + + + + + + + + + + + + + + *.js + + + *.js + + diff --git a/.phpdoc.xml b/.phpdoc.xml new file mode 100644 index 0000000..8f6456e --- /dev/null +++ b/.phpdoc.xml @@ -0,0 +1,33 @@ + + + <![CDATA[Pico API Documentation]]> + + .build/phpdoc.cache + + + .build/phpdoc + + +