Skip to content

Commit

Permalink
fix: build
Browse files Browse the repository at this point in the history
fix: release

build(core): handle the prestart
  • Loading branch information
alecarn committed May 30, 2024
1 parent bc4e61e commit edec59d
Show file tree
Hide file tree
Showing 7 changed files with 59 additions and 60 deletions.
1 change: 0 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ jobs:
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
persist-credentials: false

- name: Use Node.js
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"packages/*",
"projects/*"
],
"version": "17.0.0-next.7",
"version": "17.0.0-next.2",
"description": "IGO Library",
"author": "IGO Community",
"license": "MIT",
Expand Down
4 changes: 2 additions & 2 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
"url": "https://github.com/infra-geo-ouverte/igo2-lib/issues"
},
"scripts": {
"prestart": "npm run postbuild",
"prestart": "node --import tsx ../../scripts/src/core/prestart.mts",
"build": "ng build core --configuration production",
"postbuild": "node --import tsx ../../scripts/src/core/postbuild-core.mts",
"postbuild": "node --import tsx ../../scripts/src/core/postbuild.mts",
"format": "prettier --write ./src/**/*.{ts,js,html,scss,css,json}",
"lint": "ng lint core",
"lint.fix": "ng lint core --fix",
Expand Down
26 changes: 26 additions & 0 deletions scripts/src/core/postbuild.mts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { cleanPackageExports } from '../config/packages.mts';
import { executor } from '../utils/executor.mts';
import * as log from '../utils/log.mts';
import { copyAssets, copyExternalAssets } from './utils/assets.mts';
import {
compileAllBaseStyle,
compileBaseStyle,
prebuiltThemes
} from './utils/core-style.utils.mts';
import { bundleLocalization } from './utils/localization.mts';

executor(`Postbuild @igo2/core`, async () => {
await cleanPackageExports('core');
log.success(`✔ Cleaning package.json exports`);

await prebuiltThemes();

await compileBaseStyle();

await compileAllBaseStyle();

await bundleLocalization();

await copyExternalAssets();
await copyAssets();
});
23 changes: 0 additions & 23 deletions scripts/src/core/prestart-core.mts

This file was deleted.

22 changes: 22 additions & 0 deletions scripts/src/core/prestart.mts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { executor } from '../utils/executor.mts';
import { copyAssets, copyExternalAssets } from './utils/assets.mts';
import {
compileAllBaseStyle,
compileBaseStyle,
prebuiltThemes
} from './utils/core-style.utils.mts';
import { bundleLocalization } from './utils/localization.mts';

executor(`Prepare the base for @igo2/core`, async () => {
await prebuiltThemes();

await compileBaseStyle();

await compileAllBaseStyle();

await bundleLocalization();

await copyExternalAssets();

await copyAssets();
});
Original file line number Diff line number Diff line change
Expand Up @@ -2,44 +2,19 @@ import { readdir } from 'fs/promises';
import { join } from 'path';
import { performance } from 'perf_hooks';

import { PackageName, cleanPackageExports } from '../config/packages.mts';
import { resolveDist, resolvePackage } from '../config/paths.mts';
import * as log from '../utils/log.mts';
import { getDuration } from '../utils/performance.utils.mts';
import { compileStyle } from '../utils/style.utils.mts';
import { copyAssets, copyExternalAssets } from './utils/assets.mts';
import { bundleLocalization } from './utils/localization.mts';
import { PackageName } from '../../config/packages.mts';
import { resolveDist, resolvePackage } from '../../config/paths.mts';
import * as log from '../../utils/log.mts';
import { getDuration } from '../../utils/performance.utils.mts';
import { compileStyle } from '../../utils/style.utils.mts';

const packageName: PackageName = 'core';
const distPath = resolveDist(packageName);
const distStylePath = join(distPath, 'style');
const packagePath = resolvePackage(packageName);
const srcPath = join(packagePath, 'src');
const baseCmdName = `Postbuild @igo2/${packageName}`;

(async () => {
const startTime = performance.now();
log.startMsg(baseCmdName);

await cleanPackageExports('core');
log.success(`✔ Cleaning package.json exports`);

await prebuiltThemes();

await compileBaseStyle();

await compileAllBaseStyle();

await bundleLocalization();

await copyExternalAssets();
await copyAssets();

const duration = getDuration(startTime);
log.info(`${baseCmdName} excuted in ${duration}`);
})();

async function compileBaseStyle(): Promise<void> {
export async function compileBaseStyle(): Promise<void> {
const startTime = performance.now();
const input = join(srcPath, '/style/style.scss');
await compileStyle(input, distStylePath, 'style.css');
Expand All @@ -48,7 +23,7 @@ async function compileBaseStyle(): Promise<void> {
log.success(`✔ Compile base style in ${duration}`);
}

async function compileAllBaseStyle(): Promise<void> {
export async function compileAllBaseStyle(): Promise<void> {
const startTime = performance.now();
const input = join(srcPath, '/style/all-style.scss');
await compileStyle(input, distStylePath, 'all-style.css');
Expand All @@ -57,7 +32,7 @@ async function compileAllBaseStyle(): Promise<void> {
log.success(`✔ Compile all base style in ${duration}`);
}

async function prebuiltThemes(): Promise<void> {
export async function prebuiltThemes(): Promise<void> {
const startTime = performance.now();
const destination = join(distPath, '/theming/prebuilt-themes');
const themeFolder = join(srcPath, '/theming/prebuilt-themes');
Expand Down

0 comments on commit edec59d

Please sign in to comment.