Skip to content

Commit

Permalink
chore: Cleanup repository
Browse files Browse the repository at this point in the history
* Remove unneeded handlebars scrips
* Fix stylelint config and add CI workflow for it
* Move JS mocks so they are located next to the tests

Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
  • Loading branch information
susnux committed Nov 14, 2023
1 parent a5147ac commit 3c7f4c7
Show file tree
Hide file tree
Showing 24 changed files with 91 additions and 79 deletions.
48 changes: 48 additions & 0 deletions .github/workflows/lint-stylelint.yml
@@ -0,0 +1,48 @@
# This workflow is provided via the organization template repository
#
# https://github.com/nextcloud/.github
# https://docs.github.com/en/actions/learn-github-actions/sharing-workflows-with-your-organization

name: Lint stylelint

on: pull_request

permissions:
contents: read

concurrency:
group: lint-stylelint-${{ github.head_ref || github.run_id }}
cancel-in-progress: true

jobs:
lint:
runs-on: ubuntu-latest

name: stylelint

steps:
- name: Checkout
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1

- name: Read package.json node and npm engines version
uses: skjnldsv/read-package-engines-version-actions@8205673bab74a63eb9b8093402fd9e0e018663a1 # v2.2
id: versions
with:
fallbackNode: '^20'
fallbackNpm: '^9'

- name: Set up node ${{ steps.versions.outputs.nodeVersion }}
uses: actions/setup-node@8f152de45cc393bb48ce5d89d36b731f54556e65 # v3
with:
node-version: ${{ steps.versions.outputs.nodeVersion }}

- name: Set up npm ${{ steps.versions.outputs.npmVersion }}
run: npm i -g npm@"${{ steps.versions.outputs.npmVersion }}"

- name: Install dependencies
env:
CYPRESS_INSTALL_BINARY: 0
run: npm ci

- name: Lint
run: npm run stylelint
14 changes: 0 additions & 14 deletions .scrutinizer.yml

This file was deleted.

17 changes: 0 additions & 17 deletions check-handlebars-templates.sh

This file was deleted.

6 changes: 0 additions & 6 deletions compile-handlebars-templates.sh

This file was deleted.

File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions src/tests/Activity.test.ts → src/__tests__/Activity.test.ts
Expand Up @@ -24,9 +24,9 @@ import { afterAll, beforeAll, expect, test, vi } from 'vitest'
import { nextTick } from 'vue'

import Activity from '../components/Activity.vue'
import ActivityModel from '../models/ActivityModel.ts'
import ActivityModel from '../models/ActivityModel.js'

import wsData from '../../__mocks__/@nextcloud/activity_ws.json'
import wsData from '../__mocks__/@nextcloud/activity_ws.json'

const currentDate = new Date('2021-05-10T12:00:00+00:00')
const realDateNow = Date.now
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion src/components/Activity.vue
Expand Up @@ -72,7 +72,7 @@ import CalendarRichArgument from './richArgumentsTypes/CalendarRichArgument.vue'
import CalendarEventRichArgument from './richArgumentsTypes/CalendarEventRichArgument.vue'
import OpenGraphRichArgument from './richArgumentsTypes/OpenGraphRichArgument.vue'
import AddressBookRichArgument from './richArgumentsTypes/AddressBookRichArgument.vue'
import logger from '../logger'
import logger from '../utils/logger'
declare global {
interface Window {
Expand Down
2 changes: 1 addition & 1 deletion src/components/ActivityGrid.vue
Expand Up @@ -57,7 +57,7 @@
<script>
import { mapActions, mapGetters, mapState } from 'vuex'
import Checkbox from './Checkbox.vue'
import { isActivityEnabled } from '../helpers/settings.js'
import { isActivityEnabled } from '../utils/settings.ts'
export default {
name: 'ActivityGrid',
Expand Down
26 changes: 14 additions & 12 deletions src/models/ActivitySettings.js → src/models/ActivitySettings.ts
Expand Up @@ -20,16 +20,18 @@
*
*/

/**
*
* @typedef {object} ActivityGroup
* @property {string} name - The name of the activity group
* @property {Object<string, ActivityType>} activities - List off activities
*/
export interface IActivityType {
/** The activity's description */
desc: string
/** List of available methods to send a notification */
methods: string[]
/** Enabled state of a method */
[key: string]: boolean | string | string[]
}

/**
*
* @typedef {object} ActivityType
* @property {string} desc - The activity's description
* @property {Array<string>} methods - List of available methods to send a notification
*/
export interface IActivityGroup {
/** The name of the activity group */
name: string
/** List of activities */
activities: IActivityType[]
}
2 changes: 1 addition & 1 deletion src/settings-admin.js
Expand Up @@ -24,7 +24,7 @@ import Vuex from 'vuex'
import AdminSettings from './views/AdminSettings.vue'
import DefaultActivitySettings from './views/DefaultActivitySettings.vue'
import { translate as t, translatePlural as n } from '@nextcloud/l10n'
import store from './settings-store.js'
import store from './store/settings-store.js'

Vue.prototype.t = t
Vue.prototype.n = n
Expand Down
2 changes: 1 addition & 1 deletion src/settings-personal.js
Expand Up @@ -24,7 +24,7 @@ import Vuex from 'vuex'
import UserSettings from './views/UserSettings.vue'
import DailySummary from './views/DailySummary.vue'
import { translate as t, translatePlural as n } from '@nextcloud/l10n'
import store from './settings-store.js'
import store from './store/settings-store.js'

Vue.prototype.t = t
Vue.prototype.n = n
Expand Down
4 changes: 2 additions & 2 deletions src/settings-store.js → src/store/settings-store.js
Expand Up @@ -29,8 +29,8 @@ import { generateUrl } from '@nextcloud/router'
import { loadState } from '@nextcloud/initial-state'
import { showSuccess, showError } from '@nextcloud/dialogs'

import { isActivityEnabled, isOneInputUnChecked } from './helpers/settings.js'
import logger from './logger.js'
import { isActivityEnabled, isOneInputUnChecked } from '../utils/settings.ts'
import logger from '../utils/logger.ts'

Vue.use(Vuex)

Expand Down
5 changes: 0 additions & 5 deletions src/tests/.eslintrc.json

This file was deleted.

File renamed without changes.
21 changes: 9 additions & 12 deletions src/helpers/settings.js → src/utils/settings.ts
Expand Up @@ -20,23 +20,25 @@
*
*/

import type { IActivityType } from '../models/ActivitySettings.js'

/**
* Return wether the notification method can be checked for the activity
*
* @param {ActivityType} activity - the concerned activity
* @param {string} methodKey - the concerned method
* @param activity - the concerned activity
* @param methodKey - the concerned method
* @return {boolean}
*/
function isActivityEnabled(activity, methodKey) {
export function isActivityEnabled(activity: IActivityType, methodKey: string) {
return activity.methods.includes(methodKey)
}

/**
* @param {Array<ActivityType>} activities - List of the activities to check
* @param {string} methodKey - the method key for which to verify the checked value
* @return {boolean} wether at least one input is checked for the given set of activities
* @param activities - List of the activities to check
* @param methodKey - the method key for which to verify the checked value
* @return {boolean} Wether at least one input is checked for the given set of activities
*/
function isOneInputUnChecked(activities, methodKey) {
export function isOneInputUnChecked(activities: IActivityType[], methodKey: string) {
for (const activity of activities) {
if (isActivityEnabled(activity, methodKey) && !activity[methodKey]) {
return true
Expand All @@ -45,8 +47,3 @@ function isOneInputUnChecked(activities, methodKey) {

return false
}

export {
isActivityEnabled,
isOneInputUnChecked,
}
2 changes: 1 addition & 1 deletion src/views/ActivityAppFeed.vue
Expand Up @@ -67,7 +67,7 @@ import ActivityModel from '../models/ActivityModel'
import ActivityGroup from '../components/ActivityGroup.vue'
import appIconSVG from '../../img/activity-dark.svg?raw'
import logger from '../logger'
import logger from '../utils/logger'
import { showError } from '@nextcloud/dialogs'
import { translate as t } from '@nextcloud/l10n'
Expand Down
2 changes: 1 addition & 1 deletion src/views/ActivityAppNavigation.vue
Expand Up @@ -59,7 +59,7 @@ import {
import NcInputField from '@nextcloud/vue/dist/Components/NcInputField.js'
import IconContentCopy from 'vue-material-design-icons/ContentCopy.vue'
import logger from '../logger'
import logger from '../utils/logger'
// Types
interface INavigationEntry {
Expand Down
2 changes: 1 addition & 1 deletion src/views/ActivityTab.vue
Expand Up @@ -63,7 +63,7 @@ import ActivityModel from '../models/ActivityModel.ts'
import lightningBoltSVG from '@mdi/svg/svg/lightning-bolt.svg?raw'
import logger from '../logger.js'
import logger from '../utils/logger.ts'
export default {
name: 'ActivityTab',
Expand Down
File renamed without changes.
11 changes: 9 additions & 2 deletions vite.config.ts
@@ -1,3 +1,4 @@
import type { UserConfig } from 'vitest'
import { createAppConfig } from '@nextcloud/vite-config'
import { join } from 'path'

Expand Down Expand Up @@ -29,12 +30,18 @@ export default createAppConfig({
extension: ['.js', '.ts', '.vue'],
provider: 'v8',
},
dir: 'src/',
root: 'src/',
deps: {
moduleDirectories: ['node_modules', '../node_modules'],
},
cache: {
dir: '../node_modules/.vitest',
},
server: {
deps: {
inline: [/@nextcloud\/vue/, /@mdi\/svg/],
},
},
},
} as UserConfig,
},
})

0 comments on commit 3c7f4c7

Please sign in to comment.