Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Node.js 18, pnpm 8, jest 29, linting/formatting updates, and webpack fixes #4462

Draft
wants to merge 26 commits into
base: unstable
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
bcccc40
Update github workflows to nodejs 18
bjester Feb 20, 2024
443cfe4
upgrade docker images to nodejs 18
bjester Feb 20, 2024
510011a
Update kolibri-tools and other packages for nodejs 18
bjester Feb 20, 2024
b5ab79f
Remove custom JS DOM declaration
bjester Feb 20, 2024
e34f2a5
Update developer documentation for nodejs 18
bjester Feb 20, 2024
3abfcf2
Update configuration for nodejs 18 + jest 29
bjester Feb 20, 2024
8e8d698
Update for nodejs 18
bjester Feb 20, 2024
024dc4d
Pin wrap-ansi b/c yarn is hoisting incompatible version
bjester Feb 20, 2024
f2c9720
Finalize jest fixes for node.js 18 and jest 29, and linting updates
bjester Feb 29, 2024
abbff8d
Linting updates
bjester Feb 29, 2024
7ec0f77
Update requirements for python 3.10
bjester Mar 22, 2024
a8d5428
Update docs to use pnpm
bjester Mar 22, 2024
7cb779f
Update docker stuff to use pnpm
bjester Mar 22, 2024
c36d32f
Update github workflows to use pnpm
bjester Mar 22, 2024
f7fc170
Update misc usages of yarn to pnpm
bjester Mar 22, 2024
ea03e64
Switch to pnpm, pre-commit, and linting updates
bjester Mar 22, 2024
eae69c8
Sort out webpack issues
bjester Apr 4, 2024
cbcd35a
Fix jest tests again
bjester Apr 5, 2024
cfb6d40
Cleanup GH workflows using pnpm and caching
bjester Apr 5, 2024
3ff32fe
Update deploy test workflow
bjester Apr 5, 2024
84a32ee
Fix missing install command in deploy test workflow
bjester Apr 5, 2024
e8dda66
Add missing dev dependencies when removing pnpm from webpack resolve …
bjester Apr 5, 2024
95ebd89
[pre-commit.ci lite] apply automatic fixes
pre-commit-ci-lite[bot] Jan 14, 2025
cadf8a1
Add kolibri-format, upgrade vue, remove composition API, fix dep conf…
bjester Jan 14, 2025
cc0ab73
Merge branch 'nodejs-18' of github.com:bjester/studio into nodejs-18
bjester Jan 14, 2025
7edf4e8
[pre-commit.ci lite] apply automatic fixes
pre-commit-ci-lite[bot] Jan 14, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion .docker/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ This directory is a space for mounting directories to docker containers, allowin
### postgres
The `postgres` directory is mounted to `/docker-entrypoint-initdb.d`. Any `.sh` or `.sql` files will be executed when the container is first started with a new data volume. You may read more regarding this functionality on the [Docker Hub page](https://hub.docker.com/_/postgres), under _Initialization scripts_.

When running docker services through the Makefile commands, it specifies a docker-compose project name that depends on the name of the current git branch. This causes the volumes to change when the branch changes, which is helpful when switching between many branches that might have incompatible database schema changes. The downside is that whenever you start a new branch, you'll have to re-initialize the database again, like with `yarn run devsetup`. Creating a SQL dump from an existing, initialized database and placing it in this directory will allow you to skip this step.
When running docker services through the Makefile commands, it specifies a docker-compose project name that depends on the name of the current git branch. This causes the volumes to change when the branch changes, which is helpful when switching between many branches that might have incompatible database schema changes. The downside is that whenever you start a new branch, you'll have to re-initialize the database again, like with `pnpm run devsetup`. Creating a SQL dump from an existing, initialized database and placing it in this directory will allow you to skip this step.

To create a SQL dump of your preferred database data useful for local testing, run `make .docker/postgres/init.sql` while the docker postgres container is running.

Expand Down
2 changes: 1 addition & 1 deletion .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ updates:
time: "00:00"

# Maintain dependencies for Javascript
- package-ecosystem: "npm"
- package-ecosystem: "pnpm"
directory: "/"
schedule:
interval: "weekly"
Expand Down
32 changes: 12 additions & 20 deletions .github/workflows/deploytest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,38 +20,36 @@ jobs:
uses: fkirc/skip-duplicate-actions@master
with:
github_token: ${{ github.token }}
paths: '["**.py", "requirements.txt", ".github/workflows/deploytest.yml", "**.vue", "**.js", "yarn.lock", "package.json"]'
paths: '["**.py", "requirements.txt", ".github/workflows/deploytest.yml", "**.vue", "**.js", "pnpm-lock.yaml", "package.json"]'
build_assets:
name: Build frontend assets
needs: pre_job
if: ${{ needs.pre_job.outputs.should_skip != 'true' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Use pnpm
uses: pnpm/action-setup@v2
- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: '16.x'
- name: Cache Node.js modules
uses: actions/cache@v4
with:
path: '**/node_modules'
key: ${{ runner.OS }}-node-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.OS }}-node-
node-version: '18.x'
cache: 'pnpm'
- name: Install dependencies
run: |
yarn --frozen-lockfile
pnpm install --frozen-lockfile
npm rebuild node-sass
- name: Build frontend
run: yarn run build
run: pnpm run build
make_messages:
name: Build all message files
needs: pre_job
if: ${{ needs.pre_job.outputs.should_skip != 'true' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Use pnpm
uses: pnpm/action-setup@v2
- name: Set up Python 3.10
uses: actions/setup-python@v5
with:
Expand All @@ -71,17 +69,11 @@ jobs:
- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: '16.x'
- name: Cache Node.js modules
uses: actions/cache@v4
with:
path: '**/node_modules'
key: ${{ runner.OS }}-node-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.OS }}-node-
node-version: '18.x'
cache: 'pnpm'
- name: Install node dependencies
run: |
yarn --frozen-lockfile
pnpm install --frozen-lockfile
npm rebuild node-sass
- name: Install gettext
run: |
Expand Down
18 changes: 7 additions & 11 deletions .github/workflows/frontendlint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,31 +20,27 @@ jobs:
uses: fkirc/skip-duplicate-actions@master
with:
github_token: ${{ github.token }}
paths: '["**.vue", "**.js", "yarn.lock", ".github/workflows/frontendlint.yml"]'
paths: '["**.vue", "**.js", "pnpm-lock.yaml", ".github/workflows/frontendlint.yml"]'
test:
name: Frontend linting
needs: pre_job
if: ${{ needs.pre_job.outputs.should_skip != 'true' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Use pnpm
uses: pnpm/action-setup@v2
- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: '16.x'
- name: Cache Node.js modules
uses: actions/cache@v4
with:
path: '**/node_modules'
key: ${{ runner.OS }}-node-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.OS }}-node-
node-version: '18.x'
cache: 'pnpm'
- name: Install dependencies
run: |
yarn --frozen-lockfile
pnpm install --frozen-lockfile
npm rebuild node-sass
- name: Run tests
run: yarn run lint-frontend:format
run: pnpm run lint-frontend:format
- name: Run pre-commit-ci-lite
uses: pre-commit-ci/[email protected]
if: always()
18 changes: 7 additions & 11 deletions .github/workflows/frontendtest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,28 +20,24 @@ jobs:
uses: fkirc/skip-duplicate-actions@master
with:
github_token: ${{ github.token }}
paths: '["**.vue", "**.js", "yarn.lock"]'
paths: '["**.vue", "**.js", "pnpm-lock.yaml"]'
test:
name: Frontend tests
needs: pre_job
if: ${{ needs.pre_job.outputs.should_skip != 'true' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Use pnpm
uses: pnpm/action-setup@v2
- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: '16.x'
- name: Cache Node.js modules
uses: actions/cache@v4
with:
path: '**/node_modules'
key: ${{ runner.OS }}-node-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.OS }}-node-
node-version: '18.x'
cache: 'pnpm'
- name: Install dependencies
run: |
yarn --frozen-lockfile
pnpm install --frozen-lockfile
npm rebuild node-sass
- name: Run tests
run: yarn run test
run: pnpm run test
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@ repos:
- id: frontend-lint
name: Linting of JS, Vue, SCSS and CSS files
description: This hook handles all frontend linting for Kolibri Studio
entry: yarn run lint-frontend:format
entry: pnpm run lint-frontend:format
language: system
files: \.(js|vue|scss|less|css)$
1 change: 0 additions & 1 deletion .prettierrc.js

This file was deleted.

1 change: 1 addition & 0 deletions .prettierrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = require('kolibri-tools/.prettierrc');
8 changes: 4 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ reconcile:
###############################################################
i18n-extract-frontend:
# generate frontend messages
yarn makemessages
pnpm makemessages

i18n-extract-backend:
# generate backend messages
Expand All @@ -75,7 +75,7 @@ i18n-extract-backend:
i18n-extract: i18n-extract-frontend i18n-extract-backend

i18n-transfer-context:
yarn transfercontext
pnpm transfercontext

i18n-django-compilemessages:
# Change working directory to contentcuration/ such that compilemessages
Expand All @@ -94,9 +94,9 @@ i18n-pretranslate-approve-all:
i18n-download-translations:
python node_modules/kolibri-tools/lib/i18n/crowdin.py rebuild-translations ${branch}
python node_modules/kolibri-tools/lib/i18n/crowdin.py download-translations ${branch}
yarn exec kolibri-tools i18n-code-gen -- --output-dir ./contentcuration/contentcuration/frontend/shared/i18n
pnpm exec kolibri-tools i18n-code-gen -- --output-dir ./contentcuration/contentcuration/frontend/shared/i18n
$(MAKE) i18n-django-compilemessages
yarn exec kolibri-tools i18n-create-message-files -- --namespace contentcuration --searchPath ./contentcuration/contentcuration/frontend
pnpm exec kolibri-tools i18n-create-message-files -- --namespace contentcuration --searchPath ./contentcuration/contentcuration/frontend

i18n-download: i18n-download-translations

Expand Down
2 changes: 1 addition & 1 deletion contentcuration/contentcuration/frontend/accounts/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import startApp from 'shared/app';
import store from './store';
import router from './router';
import startApp from 'shared/app';

startApp({ store, router });
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,6 @@
<script>

import { mapActions, mapGetters, mapState } from 'vuex';
import { uses, sources } from '../constants';
import TextField from 'shared/views/form/TextField';
import EmailField from 'shared/views/form/EmailField';
import PasswordField from 'shared/views/form/PasswordField';
Expand All @@ -210,6 +209,7 @@
import { policies } from 'shared/constants';
import DropdownWrapper from 'shared/views/form/DropdownWrapper';
import commonStrings from 'shared/translator';
import { uses, sources } from '../constants';

export default {
name: 'Create',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ function makeWrapper(formData) {
},
});
wrapper.setMethods({
register: data => {
return new Promise(resolve => {
register: (data) => {
return new Promise((resolve) => {
register(data);
resolve();
});
Expand Down Expand Up @@ -97,7 +97,11 @@ describe('create', () => {
});
it('should automatically fill the email if provided in the query param', () => {
router.push({ name: 'Create', query: { email: '[email protected]' } });
const wrapper = mount(Create, { router, stubs: ['PolicyModals'], mocks: connectionStateMocks });
const wrapper = mount(Create, {
router,
stubs: ['PolicyModals'],
mocks: connectionStateMocks,
});
expect(wrapper.vm.form.email).toBe('[email protected]');
});
describe('validation', () => {
Expand All @@ -120,7 +124,7 @@ describe('create', () => {
accepted_tos: false,
};

Object.keys(form).forEach(field => {
Object.keys(form).forEach((field) => {
const wrapper = makeWrapper({ [field]: form[field] });
wrapper.vm.submit();
expect(register).not.toHaveBeenCalled();
Expand All @@ -137,14 +141,14 @@ describe('create', () => {
expect(register).not.toHaveBeenCalled();
});
it('should fail if uses field is set to fields that require more input that is not provided', () => {
[uses.STORING, uses.OTHER].forEach(use => {
[uses.STORING, uses.OTHER].forEach((use) => {
const wrapper = makeWrapper({ uses: [use] });
wrapper.vm.submit();
expect(register).not.toHaveBeenCalled();
});
});
it('should fail if source field is set to an option that requires more input that is not provided', () => {
[sources.ORGANIZATION, sources.CONFERENCE, sources.OTHER].forEach(source => {
[sources.ORGANIZATION, sources.CONFERENCE, sources.OTHER].forEach((source) => {
const wrapper = makeWrapper({ source });
wrapper.vm.submit();
expect(register).not.toHaveBeenCalled();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ describe('forgotPassword', () => {
wrapper = makeWrapper();
wrapper.setMethods({
sendPasswordResetLink: () => {
return new Promise(resolve => {
return new Promise((resolve) => {
sendPasswordResetLink();
resolve();
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ function makeWrapper() {
},
});
wrapper.setMethods({
login: data => {
return new Promise(resolve => {
login: (data) => {
return new Promise((resolve) => {
login(data);
resolve();
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ describe('requestNewActivationLink', () => {
wrapper = makeWrapper();
wrapper.setMethods({
sendActivationLink: () => {
return new Promise(resolve => {
return new Promise((resolve) => {
sendActivationLink();
resolve();
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ describe('resetPassword', () => {
beforeEach(() => {
wrapper = makeWrapper();
wrapper.setMethods({
setPassword: data => {
return new Promise(resolve => {
setPassword: (data) => {
return new Promise((resolve) => {
setPassword(data);
resolve();
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@
<script>

import { mapActions } from 'vuex';
import MessageLayout from '../../components/MessageLayout';
import EmailField from 'shared/views/form/EmailField';
import Banner from 'shared/views/Banner';
import MessageLayout from '../../components/MessageLayout';

export default {
name: 'RequestNewActivationLink',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@
<script>

import { mapActions } from 'vuex';
import MessageLayout from '../../components/MessageLayout';
import EmailField from 'shared/views/form/EmailField';
import Banner from 'shared/views/Banner';
import MessageLayout from '../../components/MessageLayout';

export default {
name: 'ForgotPassword',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@
<script>

import { mapActions } from 'vuex';
import MessageLayout from '../../components/MessageLayout';
import PasswordField from 'shared/views/form/PasswordField';
import Banner from 'shared/views/Banner';
import MessageLayout from '../../components/MessageLayout';

export default {
name: 'ResetPassword',
Expand Down
2 changes: 1 addition & 1 deletion contentcuration/contentcuration/frontend/accounts/store.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import account from './vuex';
import storeFactory from 'shared/vuex/baseStore';

Check failure on line 1 in contentcuration/contentcuration/frontend/accounts/store.js

View workflow job for this annotation

GitHub Actions / Frontend linting

Definition for rule 'kolibri/vue-filename-and-component-name-match' was not found

Check failure on line 1 in contentcuration/contentcuration/frontend/accounts/store.js

View workflow job for this annotation

GitHub Actions / Frontend linting

Definition for rule 'kolibri/vue-component-registration-casing' was not found

Check failure on line 1 in contentcuration/contentcuration/frontend/accounts/store.js

View workflow job for this annotation

GitHub Actions / Frontend linting

Definition for rule 'kolibri/vue-no-unused-properties' was not found
import account from './vuex';

export function factory() {
return storeFactory({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import account from '../index';
import storeFactory from 'shared/vuex/baseStore';
import client from 'shared/client';
import account from '../index';

jest.mock('shared/client');
jest.mock('shared/vuex/connectionPlugin');
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import startApp from 'shared/app';

Check failure on line 1 in contentcuration/contentcuration/frontend/administration/index.js

View workflow job for this annotation

GitHub Actions / Frontend linting

Definition for rule 'kolibri/vue-filename-and-component-name-match' was not found
import AdministrationIndex from './pages/AdministrationIndex.vue';
import store from './store';
import router from './router';
import startApp from 'shared/app';

startApp({
store,
Expand Down
Loading
Loading