diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 00000000..46154788 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,19 @@ +# Modified from .gitignore +node_modules +*.log +dist +.output +.nuxt +#.env # Not ignoring this file because it can contain build-related settings. +.DS_Store +.idea/ +.vite-inspect +.netlify/ +.eslintcache + +public/shiki +public/emojis + +*~ +*swp +*swo diff --git a/.env.example b/.env.example index a21e7f83..c3cc17d0 100644 --- a/.env.example +++ b/.env.example @@ -10,6 +10,8 @@ NUXT_CLOUDFLARE_API_TOKEN= NUXT_STORAGE_DRIVER= NUXT_STORAGE_FS_BASE= +NUXT_ADMIN_KEY= + NUXT_PUBLIC_DISABLE_VERSION_CHECK= NUXT_GITHUB_CLIENT_ID= diff --git a/.eslintignore b/.eslintignore index a5104c82..78bdfaee 100644 --- a/.eslintignore +++ b/.eslintignore @@ -3,5 +3,8 @@ *.ico *.toml *.patch +*.txt +public/ https-dev-config/localhost.crt https-dev-config/localhost.key +Dockerfile diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml index 8abe4458..4ef6738c 100644 --- a/.github/FUNDING.yml +++ b/.github/FUNDING.yml @@ -1 +1,2 @@ -github: [antfu, patak-dev, sxzz, danielroe] +github: [elk-zone] +open_collective: elk diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 00000000..2189ced5 --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,26 @@ + + +### Description + + + +### Additional context + + + +--- + +### What is the purpose of this pull request? + +- [ ] Bug fix +- [ ] New Feature +- [ ] Documentation update +- [ ] Translations update +- [ ] Other + +### Before submitting the PR, please make sure you do the following + +- [ ] Read the [Contributing Guidelines](https://github.com/elk-zone/elk/blob/main/CONTRIBUTING.md). +- [ ] Check that there isn't already a PR that solves the problem the same way to avoid creating a duplicate. +- [ ] Provide related snapshots or videos. +- [ ] Provide a description in this PR that addresses **what** the PR is solving, or reference the issue that it solves (e.g. `fixes #123`). diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a554d46f..3ed97488 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,5 +1,7 @@ name: ci +permissions: {} + on: push: branches: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index e302c364..be309421 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,5 +1,8 @@ name: Release +permissions: + contents: write + on: push: tags: diff --git a/.npmrc b/.npmrc index e2ad808f..e4a0f0b7 100644 --- a/.npmrc +++ b/.npmrc @@ -1,3 +1,4 @@ shamefully-hoist=true strict-peer-dependencies=false shell-emulator=true +ignore-workspace-root-check=true diff --git a/.stackblitz/codeflow.json b/.stackblitz/codeflow.json new file mode 100644 index 00000000..21acb9d4 --- /dev/null +++ b/.stackblitz/codeflow.json @@ -0,0 +1,7 @@ +{ + "bot": { + "issues": { + "trigger": "all-issues" + } + } +} diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 20a36e2a..31e43a9d 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -4,9 +4,13 @@ Hi! We are really excited that you are interested in contributing to Elk. Before Refer also to https://github.com/antfu/contribute. -## Set up your local development environment +### Online -The package manager used to install and link dependencies must be [pnpm](https://pnpm.io/) (Note: on Linux in a standard Node 16+ environment, you should follow the instructions to install via Node's `corepack` rather than using the `curl` command). +You can use [StackBlitz Codeflow](https://stackblitz.com/codeflow) to fix bugs or implement features. You'll also see a Codeflow button on PRs to review them without a local setup. Once the elk repo has been cloned in Codeflow, the dev server will start automatically and print the URL to open the App. You should receive a prompt in the bottom-right suggesting to open it in the Editor or in another Tab. To learn more, check out the [Codeflow docs](https://developer.stackblitz.com/codeflow/what-is-codeflow). + +[](https://pr.new/elk-zone/elk) + +### Local Setup To develop and test the Elk package: @@ -14,22 +18,37 @@ To develop and test the Elk package: 2. Ensure using the latest Node.js (16.x) -3. Elk uses pnpm v7, you must enable [Corepack](https://github.com/nodejs/corepack) by running `corepack enable`. +3. The package manager used to install and link dependencies must be [pnpm](https://pnpm.io/) v7. To use it you must first enable [Corepack](https://github.com/nodejs/corepack) by running `corepack enable`. (Note: on Linux in a standard Node 16+ environment, you should follow the instructions to install via Node's `corepack` rather than using the `curl` command) 4. Check out a branch where you can work and commit your changes: ```shell git checkout -b my-new-branch ``` -5. Run `pnpm i` in Elk's root folder +1. Run `pnpm i` in Elk's root folder -6. Run `pnpm nuxi prepare` in Elk's root folder +2. Run `pnpm nuxi prepare` in Elk's root folder -7. Run `pnpm dev` in Elk's root folder to start dev server or `pnpm dev:mocked` to start dev server with `@elkdev@universeodon.com` user. +3. Run `pnpm dev` in Elk's root folder to start dev server or `pnpm dev:mocked` to start dev server with `@elkdev@universeodon.com` user. + +We recommend installing [ni](https://github.com/antfu/ni#ni), that will use the right package manager in each of your projects. If `ni` is installed, you can instead run: + +``` +ni +nr dev +``` + +### Testing + +Elk uses [Vitest](https://vitest.dev). You can run the test suite with: + +``` +nr test +``` ### Running PWA on dev server -In order to run Elk with PWA enabled, run `pnpm run dev:pwa` in Elk's root folder to start dev server or `pnpm dev:mocked:pwa` to start dev server with `@elkdev@universeodon.com` user. +In order to run Elk with PWA enabled, run `pnpm dev:pwa` in Elk's root folder to start dev server or `pnpm dev:mocked:pwa` to start dev server with `@elkdev@universeodon.com` user. You should test the Elk PWA application on private browsing mode on any Chromium based browser: will not work on Firefox and Safari. @@ -44,7 +63,11 @@ If not using private browsing mode, you will need to uninstall the PWA applicati ## CI errors -Sometimes when you push your changes, the CI can fail, but we cannot check the logs to see what went wrong, run the following commands on your local environment: +Sometimes when you push your changes to create a new pull request (PR), the CI can fail, but we cannot check the logs to see what went wrong. + +If you are getting **Semantic Pull Request** error, please check the [Semantic Pull Request](https://www.conventionalcommits.org/en/v1.0.0/#summary) documentation. + +You can run the following commands on your local environment to fix CI errors: - `pnpm test:unit` to run unit tests, maybe you also need to update snapshots - `pnpm test:typecheck` to run TypeScript checks run on CI @@ -68,11 +91,11 @@ We are using [vue-i18n](https://vue-i18n.intlify.dev/) via [nuxt-i18n](https://i ### Adding a new language -1. Add a new file in [locales](../locales) folder with the language code as the filename. -2. Copy [en-US](../locales/en-US.json) and translate the strings. -3. Add the language to the `locales` array in [config/i18n.ts](../config/i18n.ts#L13) -4. If the language is `right-to-left`, add `dir` option with `rtl` value, for example, for [ar-EG](../config/i18n.ts#L63) -5. If the language requires special pluralization rules, add `pluralRule` callback option, for example, for [ar-EG](../config/i18n.ts#L64) +1. Add a new file in [locales](./locales) folder with the language code as the filename. +2. Copy [en-US](./locales/en-US.json) and translate the strings. +3. Add the language to the `locales` array in [config/i18n.ts](./config/i18n.ts#L12), below `en` variants and `ar-EG`. +4. If the language is `right-to-left`, add `dir` option with `rtl` value, for example, for [ar-EG](./config/i18n.ts#L27) +5. If the language requires special pluralization rules, add `pluralRule` callback option, for example, for [ar-EG](./config/i18n.ts#L27) Check [Pluralization rule callback](https://vue-i18n.intlify.dev/guide/essentials/pluralization.html#custom-pluralization) for more info. @@ -135,14 +158,14 @@ You can run this code in your browser console to see how it works: Either **{0}** or **{v}** should be used with the exception being custom plurals entries using the `{n}` placeholder. This is the full list of entries that will be available for number formatting in Elk: -- `action.boost_count` (no need to be included, we should use always `en-US` entry): `{0}` for formatted number and `{n}` for raw number - **{0} should be use** -- `action.favourite_count` (no need to be included, we should use always `en-US` entry): `{0}` for formatted number and `{n}` for raw number - **{0} should be use** -- `action.reply_count` (no need to be included, we should use always `en-US` entry): `{0}` for formatted number and `{n}` for raw number - **{0} should be use** -- `account.followers_count`: `{0}` for formatted number and `{n}` for raw number - **{0} should be use** -- `account.following_count`: `{0}` for formatted number and `{n}` for raw number - **{0} should be use** -- `account.posts_count`: `{0}` for formatted number and `{n}` for raw number - **{0} should be use** -- `compose.drafts`: `{v}` for formatted number and `{n}` for raw number - **{v} should be use** -- `notification.followed_you_count`: `{0}` for formatted number and `{n}` for raw number - **{0} should be use** -- `status.poll.count`: `{0}` for formatted number and `{n}` for raw number - **{0} should be use** -- `time_ago_options.*`: `{0}` for formatted number and `{n}` for raw number - **{0} should be use**: since numbers will be always small, we can also use `{n}` -- `timeline.show_new_items`: `{v}` for formatted number and `{n}` for raw number - **{v} should be use** +- `action.boost_count` (no need to be included, we should use always `en-US` entry): `{0}` for formatted number and `{n}` for raw number - **{0} should be used** +- `action.favourite_count` (no need to be included, we should use always `en-US` entry): `{0}` for formatted number and `{n}` for raw number - **{0} should be used** +- `action.reply_count` (no need to be included, we should use always `en-US` entry): `{0}` for formatted number and `{n}` for raw number - **{0} should be used** +- `account.followers_count`: `{0}` for formatted number and `{n}` for raw number - **{0} should be used** +- `account.following_count`: `{0}` for formatted number and `{n}` for raw number - **{0} should be used** +- `account.posts_count`: `{0}` for formatted number and `{n}` for raw number - **{0} should be used** +- `compose.drafts`: `{v}` for formatted number and `{n}` for raw number - **{v} should be used** +- `notification.followed_you_count`: `{0}` for formatted number and `{n}` for raw number - **{0} should be used** +- `status.poll.count`: `{0}` for formatted number and `{n}` for raw number - **{0} should be used** +- `time_ago_options.*`: `{0}` for formatted number and `{n}` for raw number - **{0} should be used**: since numbers will be always small, we can also use `{n}` +- `timeline.show_new_items`: `{v}` for formatted number and `{n}` for raw number - **{v} should be used** diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..f45aaf26 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,46 @@ +FROM docker.io/library/node:lts-alpine AS base + +# Prepare work directory +WORKDIR /elk + +FROM base AS builder + +# Prepare pnpm https://pnpm.io/installation#using-corepack +RUN corepack enable + +# Prepare deps +RUN apk update +RUN apk add git --no-cache + +# Prepare build deps ( ignore postinstall scripts for now ) +COPY package.json ./ +COPY pnpm-lock.yaml ./ +COPY patches ./patches +RUN pnpm i --frozen-lockfile --ignore-scripts + +# Copy all source files +COPY . ./ + +# Run full install with every postinstall script ( This needs project file ) +RUN pnpm i --frozen-lockfile + +# Build +RUN pnpm build + +FROM base AS runner + +ENV NODE_ENV=production + +COPY --from=builder /elk/.output ./.output + +EXPOSE 5314/tcp + +ENV PORT=5314 + +# Specify container only environment variables ( can be overwritten by runtime env ) +ENV NUXT_STORAGE_FS_BASE='/elk/data' + +# Persistent storage data +VOLUME [ "/elk/data" ] + +CMD ["node", ".output/server/index.mjs"] diff --git a/README.md b/README.md index 6693a9d6..7fb26c97 100644 --- a/README.md +++ b/README.md @@ -1,32 +1,55 @@ -# Elk -*A nimble Mastodon web client* -
+ +Elk alpha + ++A nimble Mastodon web client +
+
+
+
+
+
{{ $t('state.publish_failed') }}
+
+
{{ attachment.description }}
{{ `${$t('status.filter_hidden_phrase')}: ${filterPhrase}` }} {{ status.spoilerText }}