Skip to content

Commit

Permalink
fix: demo build
Browse files Browse the repository at this point in the history
  • Loading branch information
phanan committed Apr 29, 2022
1 parent 2fd5ba1 commit c156e73
Show file tree
Hide file tree
Showing 9 changed files with 24 additions and 16 deletions.
1 change: 0 additions & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
],
"globals": {
"KOEL_ENV": "readonly",
"NODE_ENV": "readonly",
"FileReader": "readonly",
"defineProps": "readonly",
"defineEmits": "readonly",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@
"test:e2e": "kill-port 8080 && start-test dev :8080 'cypress open'",
"test:e2e:ci": "kill-port 8080 && start-test 'php artisan serve --port=8080 --quiet' http-get://localhost:8080/api/ping 'cypress run'",
"build": "yarn prod",
"build-demo": "cross-env NODE_ENV=demo npm run production",
"build-demo": "cross-env KOEL_ENV=demo mix --production",
"dev": "start-test 'php artisan serve --port=8000 --quiet' http-get://localhost:8000/api/ping hot",
"development": "mix",
"watch": "mix watch",
Expand Down
3 changes: 1 addition & 2 deletions resources/assets/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ module.exports = {
`node_modules/(?!(${forceTransformModules.join('|')})/)`
],
globals: {
KOEL_ENV: 'web',
NODE_ENV: 'test'
KOEL_ENV: ''
},
setupFilesAfterEnv: ['<rootDir>/js/__tests__/setup.ts'],
verbose: true,
Expand Down
5 changes: 3 additions & 2 deletions resources/assets/js/components/auth/LoginForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
<script lang="ts" setup>
import { defineAsyncComponent, ref } from 'vue'
import { userStore } from '@/stores'
import { isDemo } from '@/utils'
const DEMO_ACCOUNT = {
email: 'demo@koel.dev',
Expand All @@ -21,8 +22,8 @@ const DEMO_ACCOUNT = {
const Btn = defineAsyncComponent(() => import('@/components/ui/Btn.vue'))
const url = ref('')
const email = ref(NODE_ENV === 'demo' ? DEMO_ACCOUNT.email : '')
const password = ref(NODE_ENV === 'demo' ? DEMO_ACCOUNT.password : '')
const email = ref(isDemo ? DEMO_ACCOUNT.email : '')
const password = ref(isDemo ? DEMO_ACCOUNT.password : '')
const failed = ref(false)
const emit = defineEmits(['loggedin'])
Expand Down
5 changes: 2 additions & 3 deletions resources/assets/js/components/meta/AboutKoelModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
<a href="https://github.com/koel/koel/graphs/contributors" rel="noopener" target="_blank">contributors</a>.
</p>

<p v-if="demo" class="demo-credits">
<p v-if="isDemo" class="demo-credits">
Demo music provided by
<a href="https://www.bensound.com" rel="noopener" target="_blank">Bensound</a>.
</p>
Expand All @@ -48,11 +48,10 @@
import compareVersions from 'compare-versions'
import { defineAsyncComponent } from 'vue'
import { commonStore, userStore } from '@/stores'
import { isDemo } from '@/utils'
const Btn = defineAsyncComponent(() => import('@/components/ui/Btn.vue'))
const demo = NODE_ENV === 'demo'
const latestVersionUrl = `https://github.com/phanan/koel/releases/tag/${commonStore.state.latestVersion}`
const shouldDisplayVersionUpdate = userStore.state.current.is_admin
Expand Down
16 changes: 13 additions & 3 deletions resources/assets/js/components/profile-preferences/ProfileForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@

<div class="form-row">
<Btn class="btn-submit" type="submit">Save</Btn>
<span v-if="demo" style="font-size:.95rem; opacity:.7; margin-left:5px">
<span v-if="isDemo" class="demo-notice">
Changes will not be saved in the demo version.
</span>
</div>
Expand All @@ -52,11 +52,10 @@
<script lang="ts" setup>
import { defineAsyncComponent, onMounted, ref } from 'vue'
import { UpdateCurrentProfileData, userStore } from '@/stores'
import { alerts, parseValidationError } from '@/utils'
import { alerts, isDemo, parseValidationError } from '@/utils'
const Btn = defineAsyncComponent(() => import('@/components/ui/Btn.vue'))
const demo = NODE_ENV === 'demo'
const profile = ref<UpdateCurrentProfileData>({} as unknown as UpdateCurrentProfileData)
onMounted(() => {
Expand All @@ -72,6 +71,11 @@ const update = async () => {
throw Error()
}
if (isDemo) {
alerts.success('Profile updated.')
return
}
try {
await userStore.updateProfile(profile.value)
profile.value.current_password = null
Expand Down Expand Up @@ -99,6 +103,12 @@ input {
margin-top: .75rem;
}
.demo-notice {
font-size: .95rem;
opacity: .7;
margin-left: 5px;
}
@media only screen and (max-width: 667px) {
input {
&[type="text"], &[type="email"], &[type="password"] {
Expand Down
3 changes: 1 addition & 2 deletions resources/assets/js/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,7 @@ declare module 'nouislider' {
}): void
}

declare const KOEL_ENV: 'app' | 'web'
declare const NODE_ENV: 'dev' | 'test' | 'prod' | 'demo'
declare const KOEL_ENV: '' | 'demo'

declare module '*.vue' {
import { defineComponent } from 'vue'
Expand Down
2 changes: 2 additions & 0 deletions resources/assets/js/utils/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,3 +109,5 @@ export const startDragging = (event: DragEvent, dragged: Song | Song[] | Album |

createGhostDragImage(event, text)
}

export const isDemo = KOEL_ENV === 'demo'
3 changes: 1 addition & 2 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ module.exports = {
},
plugins: [
new webpack.DefinePlugin({
KOEL_ENV: '"web"',
NODE_ENV: JSON.stringify(process.env.NODE_ENV || 'development')
KOEL_ENV: JSON.stringify(process.env.KOEL_ENV || '""')
})
],
devServer: {
Expand Down

0 comments on commit c156e73

Please sign in to comment.