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
4 changes: 3 additions & 1 deletion angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,9 @@
"cypress/**/*.ts",
"lint/**/*.ts",
"src/**/*.html",
"src/**/*.json5"
"src/**/*.json5",
"scripts/*.ts",
"webpack/*.ts"
Comment on lines +275 to +276

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is /*.ts (instead of /**/*.ts) intentional? In this shape, it misses *.ts files in e.g. webpack/plugins/ and scripts/config/ (where we already have some ts files)

]
}
}
Expand Down
2 changes: 1 addition & 1 deletion scripts/base-href.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ try {

const baseHref = `${appConfig.ui.nameSpace}${appConfig.ui.nameSpace.endsWith('/') ? '' : '/'}`;

console.log(`Setting baseHref to ${baseHref} in angular.json`);
console.info(`Setting baseHref to ${baseHref} in angular.json`);

angularJson.projects['dspace-angular'].architect.build.options.baseHref = baseHref;

Expand Down
15 changes: 10 additions & 5 deletions scripts/env-to-yaml.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@
import { existsSync, writeFileSync } from 'fs';
import {
existsSync,
writeFileSync,
} from 'node:fs';
import { join } from 'node:path';

import { dump } from 'js-yaml';
import { join } from 'path';

/**
* Script to help convert previous version environment.*.ts to yaml.
*
* Usage (see package.json):
*
*
* yarn env:yaml [relative path to environment.ts file] (optional relative path to write yaml file) *
*/

const args = process.argv.slice(2);
if (args[0] === undefined) {
console.log(`Usage:\n\tyarn env:yaml [relative path to environment.ts file] (optional relative path to write yaml file)\n`);
console.info(`Usage:\n\tyarn env:yaml [relative path to environment.ts file] (optional relative path to write yaml file)\n`);
process.exit(0);
}

Expand All @@ -24,14 +28,15 @@ if (!existsSync(envFullPath)) {
}

try {
// eslint-disable-next-line @typescript-eslint/no-require-imports
const env = require(envFullPath).environment;

const config = dump(env);
if (args[1]) {
const ymlFullPath = join(process.cwd(), args[1]);
writeFileSync(ymlFullPath, config);
} else {
console.log(config);
console.info(config);
}
} catch (e) {
console.error(e);
Expand Down
55 changes: 34 additions & 21 deletions scripts/merge-i18n-files.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,24 @@
import { projectRoot} from '../webpack/helpers';
const commander = require('commander');
const fs = require('fs');
const JSON5 = require('json5');
const _cliProgress = require('cli-progress');
const _ = require('lodash');
import {
existsSync,
lstatSync,
readdirSync,
readFileSync,
writeFileSync,
} from 'node:fs';

const program = new commander.Command();
import {
Presets,
SingleBar,
} from 'cli-progress';
import { Command } from 'commander';
import {
parse,
stringify,
} from 'json5';

import { projectRoot } from '../webpack/helpers';

const program = new Command();
program.version('1.0.0', '-v, --version');

const LANGUAGE_FILES_LOCATION = 'src/assets/i18n';
Expand Down Expand Up @@ -46,26 +59,26 @@ function parseCliInput() {
const destination = program.opts().outputDir;

if (destination && source) {
if (!fs.existsSync(destination) || !fs.lstatSync(destination).isDirectory() ) {
if (!existsSync(destination) || !lstatSync(destination).isDirectory() ) {
console.error('Output does not exist or is not a directory.');
console.log(program.outputHelp());
console.info(program.outputHelp());
process.exit(1);
}
if (!fs.existsSync(source) || !fs.lstatSync(source).isDirectory() ) {
if (!existsSync(source) || !lstatSync(source).isDirectory() ) {
console.error('Source does not exist or is not a directory.');
console.log(program.outputHelp());
console.info(program.outputHelp());
process.exit(1);
}

fs.readdirSync(projectRoot(source)).forEach(file => {
if (fs.existsSync(destination + '/' + file) ) {
console.log('Merging: ' + destination + '/' + file + ' with ' + source + '/' + file);
readdirSync(projectRoot(source)).forEach(file => {
if (existsSync(destination + '/' + file) ) {
console.info('Merging: ' + destination + '/' + file + ' with ' + source + '/' + file);
mergeFileWithSource(source + '/' + file, destination + '/' + file);
}
});
} else {
console.error('Source or Output parameter is missing.');
console.log(program.outputHelp());
console.info(program.outputHelp());
process.exit(1);
}
}
Expand All @@ -79,24 +92,24 @@ function parseCliInput() {
* @param pathToOutputFile Valid path to merge and write output
*/
function mergeFileWithSource(pathToSourceFile, pathToOutputFile) {
const progressBar = new _cliProgress.SingleBar({}, _cliProgress.Presets.shades_classic);
const progressBar = new SingleBar({}, Presets.shades_classic);
progressBar.start(100, 0);

const sourceFile = fs.readFileSync(pathToSourceFile, 'utf8');
const sourceFile = readFileSync(pathToSourceFile, 'utf8');
progressBar.update(10);
const outputFile = fs.readFileSync(pathToOutputFile, 'utf8');
const outputFile = readFileSync(pathToOutputFile, 'utf8');
progressBar.update(20);

const parsedSource = JSON5.parse(sourceFile);
const parsedSource = parse(sourceFile);
progressBar.update(30);
const parsedOutput = JSON5.parse(outputFile);
const parsedOutput = parse(outputFile);
progressBar.update(40);

for (const key of Object.keys(parsedSource)) {
parsedOutput[key] = parsedSource[key];
}
progressBar.update(80);
fs.writeFileSync(pathToOutputFile,JSON5.stringify(parsedOutput,{ space:'\n ', quote: '"' }), { encoding:'utf8' });
writeFileSync(pathToOutputFile,stringify(parsedOutput,{ space:'\n ', quote: '"' }), { encoding:'utf8' });

progressBar.update(100);
progressBar.stop();
Expand Down
4 changes: 2 additions & 2 deletions scripts/serve.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { spawn } from 'child_process';
import { spawn } from 'node:child_process';

import { AppConfig } from '../src/config/app-config.interface';
import { buildAppConfig } from '../src/config/config.server';
Expand All @@ -11,5 +11,5 @@ const appConfig: AppConfig = buildAppConfig();
*/
spawn(
`ng serve --host ${appConfig.ui.host} --port ${appConfig.ui.port} --serve-path ${appConfig.ui.nameSpace} --ssl ${appConfig.ui.ssl} ${process.argv.slice(2).join(' ')} --configuration development`,
{ stdio: 'inherit', shell: true }
{ stdio: 'inherit', shell: true },
);
Loading
Loading