Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
</template>

<script>
import translate from '../../plugins/translate.es6';
import navigable from '../../mixins/navigable.es6';

export default {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@
<script>
import * as types from '../../../store/mutation-types.es6';
import api from '../../../app/Api.es6';
import translate from '../../../plugins/translate.es6'

import MediaBrowserActionItemEdit from './edit.vue';
import MediaBrowserActionItemDelete from './delete.vue';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
</template>

<script>
import translate from '../../../plugins/translate.es6'

export default {
name: 'MediaBrowserActionItemDelete',
props: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
</template>

<script>
import translate from '../../../plugins/translate.es6'

export default {
name: 'MediaBrowserActionItemDownload',
props: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
</template>

<script>
import translate from '../../../plugins/translate.es6'

export default {
name: 'MediaBrowserActionItemEdit',
props: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
</template>

<script>
import translate from '../../../plugins/translate.es6'

export default {
name: 'MediaBrowserActionItemPreview',
props: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
</template>

<script>
import translate from '../../../plugins/translate.es6'

export default {
name: 'MediaBrowserActionItemRename',
props: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
</template>

<script>
import translate from '../../../plugins/translate.es6'

export default {
name: 'MediaBrowserActionItemShare',
props: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ import * as types from '../../store/mutation-types.es6';
import MediaBrowserTable from './table/table.vue';
import MediaBrowserItem from './items/item.es6';
import MediaInfobar from '../infobar/infobar.vue';
import translate from '../../plugins/translate.es6'

function sortArray(array, by, direction) {
return array.sort((a, b) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
</template>

<script>
import translate from '../../../plugins/translate.es6'
import MediaBrowserActionItemsContainer from '../actionItems/actionItemsContainer.vue';

export default {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
</template>

<script>
import translate from '../../../plugins/translate.es6'
import MediaBrowserActionItemsContainer from '../actionItems/actionItemsContainer.vue';

export default {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@

<script>
import api from '../../../app/Api.es6';
import translate from '../../../plugins/translate.es6'

import MediaBrowserActionItemsContainer from '../actionItems/actionItemsContainer.vue';

export default {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@

<script>
import * as types from '../../../store/mutation-types.es6';
import translate from '../../../plugins/translate.es6'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does the import order matter?

In this file it is before the mediabrowser... but in the next file it is after the mediabrowser...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not in this case, the exports from each module is executed at a particular part of this file but not in series. The modules themselves are just delivering the callbacks so it doesn't matter if these are alphanumerically organized or not. The benefits of the dynamic languages (PHP, JS, Python).
There are cases that the import is important ie import './something.js';

import MediaBrowserItemRow from './row.vue';
export default {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@

<script>
import * as types from '../../store/mutation-types.es6';
import translate from '../../plugins/translate.es6'

export default {
name: 'MediaInfobar',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@

<script>
import * as types from '../../store/mutation-types.es6';
import translate from '../../plugins/translate.es6'
import MediaModal from './modal.vue';

export default {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@

<script>
import * as types from '../../store/mutation-types.es6';
import translate from '../../plugins/translate.es6'
import MediaModal from './modal.vue';

export default {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@

<script>
import * as types from '../../store/mutation-types.es6';
import translate from '../../plugins/translate.es6'
import MediaModal from './modal.vue';

export default {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@

<script>
import * as types from '../../store/mutation-types.es6';
import translate from '../../plugins/translate.es6'
import MediaBreadcrumb from '../breadcrumb/breadcrumb.vue';

export default {
Expand Down
59 changes: 29 additions & 30 deletions build/build-modules-js/compilecss.mjs
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
import { sep } from 'node:path';

import recursive from 'recursive-readdir';
import pkg from 'fs-extra';
import { join, sep } from 'node:path';
import { stat } from 'node:fs/promises';
import { readdirSync } from 'node:fs';

import { handleScssFile } from './stylesheets/handle-scss.mjs';
import { handleCssFile } from './stylesheets/handle-css.mjs';

const { stat } = pkg;
const RootPath = process.cwd();

/**
Expand All @@ -19,23 +17,25 @@ const RootPath = process.cwd();
* css files to have ext: .css
* Ignores scss files that their filename starts with `_`
*
* @param {object} options The options
* @param {string} path The folder that needs to be compiled, optional
* @param {string|Array} path The folder that needs to be compiled, optional
*
* @returns {Promise}
*/
export const stylesheets = async (options, path) => {
const files = [];
export const stylesheets = async (path) => {
let files = [];
let folders = [];

if (path) {
if (Array.isArray(path)) {
path.filter((file) => file.endsWith('.css') || file.endsWith('.scss')).forEach((file) => files.push(file));
} else if (path) {
const stats = await stat(`${RootPath}/${path}`);

if (stats.isDirectory()) {
folders.push(`${RootPath}/${path}`);
} else if (stats.isFile()) {
files.push(`${RootPath}/${path}`);
} else {
console.error(`Unknown path ${path}`);
process.exitCode = 1;
throw new Error(`Unknown path ${path}`);
}
} else {
folders = [
Expand All @@ -47,20 +47,23 @@ export const stylesheets = async (options, path) => {
];
}

const folderPromises = [];

// Loop to get the files that should be compiled via parameter
for (const folder of folders) {
folderPromises.push(recursive(folder, ['!*.+(scss|css)']));
if (folders.length) {
// Loop to get the files that should be compiled via parameter
for (const folder of folders) {
const filesLocal = readdirSync(folder, { recursive: true })
.filter((file) => file.endsWith('.scss') || file.endsWith('.css'))
.map((file) => join(folder, file));
for (const file of filesLocal) {
files.push(file);
}
}
}

const computedFiles = await Promise.all(folderPromises);

const cssFilesPromises = [];
const scssFilesPromises = [];

// Loop to get the files that should be compiled via parameter
[].concat(...computedFiles).forEach((file) => {
files.forEach((file) => {
if (file.endsWith('.css') && !file.endsWith('.min.css')) {
cssFilesPromises.push(handleCssFile(file));
}
Expand All @@ -72,17 +75,13 @@ export const stylesheets = async (options, path) => {
return;
}

files.push(file);
const outputFile = file.replace(`${sep}scss${sep}`, `${sep}css${sep}`)
.replace(`${sep}build${sep}media_source${sep}`, `${sep}media${sep}`)
.replace('.scss', '.css');

scssFilesPromises.push(handleScssFile(file, outputFile));
}
});

for (const file of files) {
const outputFile = file.replace(`${sep}scss${sep}`, `${sep}css${sep}`)
.replace(`${sep}build${sep}media_source${sep}`, `${sep}media${sep}`)
.replace('.scss', '.css');

scssFilesPromises.push(handleScssFile(file, outputFile));
}

return Promise.all([...cssFilesPromises, ...scssFilesPromises]);
return Promise.all([...cssFilesPromises, ...scssFilesPromises]).catch((err) => { throw new Error(err); });
};
44 changes: 23 additions & 21 deletions build/build-modules-js/compilejs.mjs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import { stat } from 'node:fs/promises';
import { sep } from 'node:path';

import recursive from 'recursive-readdir';

import { join, sep } from 'node:path';
import { readdirSync } from 'node:fs';
import { handleES5File } from './javascript/handle-es5.mjs';
import { handleESMFile } from './javascript/compile-to-es2017.mjs';

Expand All @@ -19,24 +17,25 @@ const RootPath = process.cwd();
* ES5 files to have ext: .es5.js
* WC/CE files to have ext: .w-c.es6.js
*
* @param { object } options The options from settings.json
* @param { string } path The folder that needs to be compiled, optional
* @param { string } mode esm for ES2017, es5 for ES5, both for both
* @param {string|Array} path The folder that needs to be compiled, optional
*
* @returns {Promise}
*/
export const scripts = async (options, path) => {
const files = [];
export const scripts = async (path) => {
let files = [];
let folders = [];

if (path) {
if (Array.isArray(path)) {
path.filter((file) => file.endsWith('.mjs') || file.endsWith('.js')).forEach((file) => files.push(file));
} else if (path) {
const stats = await stat(`${RootPath}/${path}`);

if (stats.isDirectory()) {
folders.push(`${RootPath}/${path}`);
} else if (stats.isFile()) {
files.push(`${RootPath}/${path}`);
} else {
console.error(`Unknown path ${path}`);
process.exitCode = 1;
throw new Error(`Unknown path ${path}`);
}
} else {
folders = [
Expand All @@ -45,20 +44,23 @@ export const scripts = async (options, path) => {
];
}

const folderPromises = [];

// Loop to get the files that should be compiled via parameter
for (const folder of folders) {
folderPromises.push(recursive(folder, ['!*.+(m|js)']));
if (folders.length) {
// Loop to get the files that should be compiled via parameter
for (const folder of folders) {
const filesLocal = readdirSync(folder, { recursive: true })
.filter((file) => file.endsWith('.mjs') || file.endsWith('.js'))
.map((fileName) => join(folder, fileName))
for (const file of filesLocal) {
files.push(file);
}
}
}

const computedFiles = await Promise.all(folderPromises);
const computedFilesFlat = [].concat(...computedFiles);
const jsFilesPromises = [];
const esmFilesPromises = [];

// Loop to get the files that should be compiled via parameter
computedFilesFlat.forEach((file) => {
files.forEach((file) => {
if (file.includes(`build${sep}media_source${sep}vendor${sep}bootstrap${sep}js`)) {
return;
}
Expand All @@ -70,5 +72,5 @@ export const scripts = async (options, path) => {
}
});

Promise.all([...jsFilesPromises, ...esmFilesPromises]);
return Promise.all([...jsFilesPromises, ...esmFilesPromises]).catch((err) => { throw new Error(err); });
};
2 changes: 1 addition & 1 deletion build/build-modules-js/compress.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export const compressFiles = async (enableBrotli = false) => {
const files = await Promise.all(paths.map((path) => getFiles(`${path}`)));
[].concat(...files).map((file) => compressTasks.push(compressFile(file, enableBrotli)));

await Promise.all(compressTasks);
await Promise.all(compressTasks).catch((err) => { throw new Error(err); });
console.log('✅ Done 👍');
bench.stop();
};
21 changes: 8 additions & 13 deletions build/build-modules-js/error-pages.mjs
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import {
access, mkdir, readFile, writeFile,
} from 'node:fs/promises';
import { readdirSync } from 'node:fs';
import { join } from 'node:path';
import { dirname } from 'node:path';

import Ini from 'ini';
import Recurs from 'recursive-readdir';
import { transform } from 'esbuild';
import { transform as transformCss } from 'lightningcss';

Expand Down Expand Up @@ -102,18 +103,15 @@ export const createErrorPages = async (options) => {
}
};

const files = await Recurs(dir);
const files = readdirSync(dir, { recursive: true })
.filter((file) => !file.endsWith('langmetadata.xml') && file.endsWith('.ini'))
.map((file) => join(dir, file));

files.sort().forEach((file) => {
if (file.endsWith('langmetadata.xml')) {
return;
}
iniFilesProcess.push(processIni(file));
});

await Promise.all(iniFilesProcess).catch((err) => {
console.error(err);
process.exitCode = -1;
});
await Promise.all(iniFilesProcess).catch((err) => { throw new Error(err); });

const processPage = async (name) => {
const sortedJson = Object.fromEntries(Object.entries(global[`${name}Obj`]).sort());
Expand Down Expand Up @@ -157,8 +155,5 @@ export const createErrorPages = async (options) => {

Object.keys(options.settings.errorPages).forEach((name) => processPages.push(processPage(name)));

return Promise.all(processPages).catch((err) => {
console.error(err);
process.exitCode = -1;
});
return Promise.all(processPages).catch((err) => { throw new Error(err); })
};
Loading