Skip to content

Commit

Permalink
[mate-scripts] add homepage support
Browse files Browse the repository at this point in the history
  • Loading branch information
mgrinko committed Jul 14, 2024
1 parent 1b4e275 commit bc9d217
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 4 deletions.
2 changes: 1 addition & 1 deletion mate-scripts/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@mate-academy/scripts",
"version": "1.8.2",
"version": "1.8.3",
"description": "Scripts to init, run, test, deploy Mate academy homework projects",
"main": "bin/mateScripts.js",
"scripts": {
Expand Down
6 changes: 5 additions & 1 deletion mate-scripts/src/commands/Build.command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,11 @@ export class BuildCommand extends Command {
console.log('START react-scripts build');
}

this.reactScripts.build(DESTINATION_DIR, options.shouldShowInternalLogs);
this.reactScripts.build(
DESTINATION_DIR,
options.shouldShowInternalLogs,
this.config.homepage,
);
};

protected reactTypescript = (options: BuildOptions) => {
Expand Down
8 changes: 7 additions & 1 deletion mate-scripts/src/services/Vite.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,17 @@ export class ViteService {
build(
buildPath?: string,
showLogs = true,
homepage?: string,
) {
const BUILD_PATH = buildPath
? ` --out-dir ${buildPath}`
: '';
const command = `cross-env ${this.binDir}vite build${BUILD_PATH}`;

const BASE = homepage
? ` --base=${homepage}`
: '';

const command = `cross-env ${this.binDir}vite build${BUILD_PATH}${BASE}`;

if (showLogs) {
console.log(`Execute command: ${command}`);
Expand Down
3 changes: 2 additions & 1 deletion mate-scripts/src/tools/fileSystem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ function isSystemRoot(rootDir: string) {
}

export function getConfig(rootDir: string): Config {
const { mateAcademy } = JSON.parse(
const { mateAcademy, homepage } = JSON.parse(
fs.readFileSync(
path.join(rootDir, 'package.json'),
{ encoding: 'utf-8' },
Expand All @@ -80,6 +80,7 @@ export function getConfig(rootDir: string): Config {

return {
...defaultConfig,
homepage,
...config,
linters: {
...defaultConfig.linters,
Expand Down
1 change: 1 addition & 0 deletions mate-scripts/src/tools/getDefaultConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export const getDefaultConfig = (
projectType = ProjectTypes.None,
): Config => ({
projectType,
homepage: '',
nodejsMajorVersion: NodeJsVersions.v14,
linters: {
...getDefaultLintersConfig(projectType),
Expand Down
1 change: 1 addition & 0 deletions mate-scripts/src/typedefs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export interface Tests {
export interface Config {
projectType: ProjectTypes;
nodejsMajorVersion: NodeJsVersions;
homepage: string;
linters: Linters;
tests: Tests;
}

0 comments on commit bc9d217

Please sign in to comment.