@genexus/mercury 0.12.8 → 0.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bundles/css/all.css +1 -1
- package/dist/bundles/css/base/base.css +1 -1
- package/dist/bundles/css/base/icons.css +1 -1
- package/dist/bundles/css/chameleon/scrollbar.css +1 -1
- package/dist/bundles/css/components/accordion.css +1 -1
- package/dist/bundles/css/components/button.css +1 -1
- package/dist/bundles/css/components/chat.css +1 -1
- package/dist/bundles/css/components/checkbox.css +1 -1
- package/dist/bundles/css/components/code.css +1 -1
- package/dist/bundles/css/components/combo-box.css +1 -1
- package/dist/bundles/css/components/dialog.css +1 -1
- package/dist/bundles/css/components/dropdown.css +1 -1
- package/dist/bundles/css/components/edit.css +1 -1
- package/dist/bundles/css/components/flexible-layout.css +1 -1
- package/dist/bundles/css/components/icon.css +1 -1
- package/dist/bundles/css/components/layout-splitter.css +1 -1
- package/dist/bundles/css/components/list-box.css +1 -1
- package/dist/bundles/css/components/markdown-viewer.css +1 -1
- package/dist/bundles/css/components/navigation-list.css +1 -1
- package/dist/bundles/css/components/pills.css +1 -1
- package/dist/bundles/css/components/radio-group.css +1 -1
- package/dist/bundles/css/components/segmented-control.css +1 -1
- package/dist/bundles/css/components/sidebar.css +1 -1
- package/dist/bundles/css/components/slider.css +1 -1
- package/dist/bundles/css/components/switch.css +1 -0
- package/dist/bundles/css/components/tab.css +1 -1
- package/dist/bundles/css/components/tabular-grid.css +1 -1
- package/dist/bundles/css/components/ticket-list.css +1 -1
- package/dist/bundles/css/components/tooltip.css +1 -1
- package/dist/bundles/css/components/tree-view.css +1 -1
- package/dist/bundles/css/components/widget.css +1 -1
- package/dist/bundles/css/resets/box-sizing.css +1 -1
- package/dist/bundles/css/utils/elevation.css +1 -1
- package/dist/bundles/css/utils/form--full.css +1 -1
- package/dist/bundles/css/utils/form.css +1 -1
- package/dist/bundles/css/utils/layout.css +1 -1
- package/dist/bundles/css/utils/spacing.css +1 -1
- package/dist/bundles/css/utils/typography.css +1 -1
- package/dist/bundles/js/all.js +1 -0
- package/dist/bundles/js/base/base.js +1 -0
- package/dist/bundles/js/base/icons.js +1 -0
- package/dist/bundles/js/bundle-mappings.js +231 -0
- package/dist/bundles/js/chameleon/scrollbar.js +1 -0
- package/dist/bundles/js/components/accordion.js +1 -0
- package/dist/bundles/js/components/button.js +1 -0
- package/dist/bundles/js/components/chat.js +1 -0
- package/dist/bundles/js/components/checkbox.js +1 -0
- package/dist/bundles/js/components/code.js +1 -0
- package/dist/bundles/js/components/combo-box.js +1 -0
- package/dist/bundles/js/components/dialog.js +1 -0
- package/dist/bundles/js/components/dropdown.js +1 -0
- package/dist/bundles/js/components/edit.js +1 -0
- package/dist/bundles/js/components/flexible-layout.js +1 -0
- package/dist/bundles/js/components/icon.js +1 -0
- package/dist/bundles/js/components/layout-splitter.js +1 -0
- package/dist/bundles/js/components/list-box.js +1 -0
- package/dist/bundles/js/components/markdown-viewer.js +1 -0
- package/dist/bundles/js/components/navigation-list.js +1 -0
- package/dist/bundles/js/components/pills.js +1 -0
- package/dist/bundles/js/components/radio-group.js +1 -0
- package/dist/bundles/js/components/segmented-control.js +1 -0
- package/dist/bundles/js/components/sidebar.js +1 -0
- package/dist/bundles/js/components/slider.js +1 -0
- package/dist/bundles/js/components/switch.js +1 -0
- package/dist/bundles/js/components/tab.js +1 -0
- package/dist/bundles/js/components/tabular-grid.js +1 -0
- package/dist/bundles/js/components/ticket-list.js +1 -0
- package/dist/bundles/js/components/tooltip.js +1 -0
- package/dist/bundles/js/components/tree-view.js +1 -0
- package/dist/bundles/js/components/widget.js +1 -0
- package/dist/bundles/js/resets/box-sizing.js +1 -0
- package/dist/bundles/js/utils/elevation.js +1 -0
- package/dist/bundles/js/utils/form--full.js +1 -0
- package/dist/bundles/js/utils/form.js +1 -0
- package/dist/bundles/js/utils/layout.js +1 -0
- package/dist/bundles/js/utils/spacing.js +1 -0
- package/dist/bundles/js/utils/typography.js +1 -0
- package/dist/bundles/scss/components/switch.scss +3 -0
- package/dist/bundles.d.ts +153 -146
- package/dist/bundles.js +1 -1
- package/dist/cli/bundle.d.ts +2 -0
- package/dist/cli/bundle.js +20 -0
- package/dist/cli/internal/constants.d.ts +28 -0
- package/dist/cli/internal/constants.js +33 -0
- package/dist/cli/internal/create-bundles-with-custom-paths.d.ts +2 -0
- package/dist/cli/internal/create-bundles-with-custom-paths.js +67 -0
- package/dist/cli/internal/file-management.d.ts +4 -0
- package/dist/cli/internal/file-management.js +20 -0
- package/dist/cli/internal/print-utils.d.ts +18 -0
- package/dist/cli/internal/print-utils.js +33 -0
- package/dist/cli/internal/transpile-bundle-and-create-mappings.d.ts +3 -0
- package/dist/cli/internal/transpile-bundle-and-create-mappings.js +80 -0
- package/dist/cli/internal/types.d.ts +21 -0
- package/dist/cli/internal/types.js +1 -0
- package/dist/cli/internal/utils.d.ts +12 -0
- package/dist/cli/internal/utils.js +47 -0
- package/dist/cli/internal/validate-args.d.ts +2 -0
- package/dist/cli/internal/validate-args.js +119 -0
- package/dist/cli/mercury.d.ts +2 -0
- package/dist/cli/mercury.js +14 -0
- package/dist/mercury.scss +44 -41
- package/dist/types.d.ts +4 -1
- package/package.json +13 -3
- package/dist/bundles/css/components/toggle.css +0 -1
- package/dist/bundles/scss/components/toggle.scss +0 -3
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
// @ts-expect-error: This file does exists after the bundle transpilation process
|
|
4
|
+
import { bundleMappings } from "../../bundles/js/bundle-mappings.js";
|
|
5
|
+
import { BASE_BUNDLE, BASE_GLOBANT_BUNDLE, BUNDLE_MAPPING_TO_HASH_FILE } from "./constants.js";
|
|
6
|
+
import { getBundleNameWithHash, getHash, replacePlaceholdersInBundle } from "./utils.js";
|
|
7
|
+
import { printBundleToHashMappingsWasCreated, printBundleWasCreated } from "./print-utils.js";
|
|
8
|
+
const findLargestPath = () => {
|
|
9
|
+
let largestBundleLength = 0;
|
|
10
|
+
bundleMappings.forEach(entry => {
|
|
11
|
+
largestBundleLength = Math.max(largestBundleLength, entry.bundleName.length);
|
|
12
|
+
});
|
|
13
|
+
return largestBundleLength;
|
|
14
|
+
};
|
|
15
|
+
const getActualBundleName = (bundleName) => bundleName === BASE_BUNDLE || bundleName === BASE_GLOBANT_BUNDLE
|
|
16
|
+
? BASE_BUNDLE
|
|
17
|
+
: bundleName;
|
|
18
|
+
const shouldSkipBundleCreation = (bundleName, globant) => (bundleName === BASE_BUNDLE && globant) ||
|
|
19
|
+
(bundleName === BASE_GLOBANT_BUNDLE && !globant);
|
|
20
|
+
export const createBundlesWithCustomPaths = (args) => {
|
|
21
|
+
const { avoidHash, fontFacePath, iconsPath, globant } = args;
|
|
22
|
+
const outDir = path.join(args.outDirPath);
|
|
23
|
+
const CREATED_DIRS = new Set();
|
|
24
|
+
const largestBundleLength = findLargestPath();
|
|
25
|
+
let bundleMappingToHashObjectEntries = "";
|
|
26
|
+
bundleMappings.forEach(entry => {
|
|
27
|
+
const { bundleName, fileDir, transpiledBundle } = entry;
|
|
28
|
+
if (shouldSkipBundleCreation(bundleName, globant)) {
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
const actualBundleName = getActualBundleName(bundleName);
|
|
32
|
+
const compiledBundleWithoutPlaceholders = replacePlaceholdersInBundle(transpiledBundle, fontFacePath, iconsPath);
|
|
33
|
+
const hash = getHash(compiledBundleWithoutPlaceholders);
|
|
34
|
+
if (fileDir && !CREATED_DIRS.has(fileDir)) {
|
|
35
|
+
fs.mkdirSync(path.join(outDir, fileDir), { recursive: true });
|
|
36
|
+
CREATED_DIRS.add(fileDir);
|
|
37
|
+
}
|
|
38
|
+
const bundleNameWithHash = avoidHash.has(actualBundleName)
|
|
39
|
+
? actualBundleName
|
|
40
|
+
: getBundleNameWithHash(actualBundleName, hash);
|
|
41
|
+
const filePathToCreateBundle = path.join(outDir, `${bundleNameWithHash}.css`);
|
|
42
|
+
fs.writeFileSync(filePathToCreateBundle, compiledBundleWithoutPlaceholders);
|
|
43
|
+
printBundleWasCreated({
|
|
44
|
+
outDir,
|
|
45
|
+
bundleName: actualBundleName,
|
|
46
|
+
compiledBundleWithoutPlaceholders,
|
|
47
|
+
filePathToCreateBundle,
|
|
48
|
+
// WA to improve style
|
|
49
|
+
largestBundleLength: largestBundleLength + (avoidHash.has(actualBundleName) ? 17 : 0)
|
|
50
|
+
});
|
|
51
|
+
// Store the bundle mapping.
|
|
52
|
+
// For example: "components/button" --> "components/button-9f82641938b85445"
|
|
53
|
+
const bundleToHashEntry = ` "${actualBundleName}": "${bundleNameWithHash}"`;
|
|
54
|
+
// Concat entries in the object
|
|
55
|
+
bundleMappingToHashObjectEntries +=
|
|
56
|
+
bundleMappingToHashObjectEntries === ""
|
|
57
|
+
? bundleToHashEntry
|
|
58
|
+
: ",\n" + bundleToHashEntry;
|
|
59
|
+
});
|
|
60
|
+
bundleMappingToHashObjectEntries = `export const bundleToHashMappings = {\n${bundleMappingToHashObjectEntries}\n} as const;\n`;
|
|
61
|
+
const bundleMappingFilePath = path.join(outDir, BUNDLE_MAPPING_TO_HASH_FILE);
|
|
62
|
+
fs.writeFileSync(bundleMappingFilePath, bundleMappingToHashObjectEntries);
|
|
63
|
+
printBundleToHashMappingsWasCreated({
|
|
64
|
+
outDir,
|
|
65
|
+
filePath: bundleMappingFilePath
|
|
66
|
+
});
|
|
67
|
+
};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { FileMetadata } from "./types";
|
|
2
|
+
export declare const ensureDirectoryExistsAndItsClear: (dirPath: string) => void;
|
|
3
|
+
export declare function walkSync(dir: string): Generator<FileMetadata>;
|
|
4
|
+
export declare const copyDirectories: (srcDir: string, outDir: string) => void;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
export const ensureDirectoryExistsAndItsClear = (dirPath) => {
|
|
4
|
+
if (fs.existsSync(dirPath)) {
|
|
5
|
+
fs.rmSync(dirPath, { recursive: true });
|
|
6
|
+
}
|
|
7
|
+
fs.mkdirSync(dirPath);
|
|
8
|
+
};
|
|
9
|
+
export function* walkSync(dir) {
|
|
10
|
+
const files = fs.readdirSync(dir, { withFileTypes: true });
|
|
11
|
+
for (const file of files) {
|
|
12
|
+
if (file.isDirectory()) {
|
|
13
|
+
yield* walkSync(path.join(dir, file.name));
|
|
14
|
+
}
|
|
15
|
+
else {
|
|
16
|
+
yield { dir, fileName: file.name, filePath: path.join(dir, file.name) };
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
export const copyDirectories = (srcDir, outDir) => fs.cpSync(srcDir, outDir, { recursive: true });
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export declare const printBundleWasCreated: (args: {
|
|
2
|
+
outDir: string;
|
|
3
|
+
bundleName: string;
|
|
4
|
+
largestBundleLength: number;
|
|
5
|
+
filePathToCreateBundle: string;
|
|
6
|
+
compiledBundleWithoutPlaceholders: string;
|
|
7
|
+
}) => void;
|
|
8
|
+
export declare const printBundleToHashMappingsWasCreated: (args: {
|
|
9
|
+
outDir: string;
|
|
10
|
+
filePath: string;
|
|
11
|
+
}) => void;
|
|
12
|
+
export declare const printBundleWasTranspiled: (filePath: string) => void;
|
|
13
|
+
export declare const printArgumentDoesNotExistsError: (arg: string) => void;
|
|
14
|
+
export declare const printDuplicatedArgumentError: (arg: string) => void;
|
|
15
|
+
export declare const printInvalidArgumentError: (arg: string) => void;
|
|
16
|
+
export declare const printMissingFontPathArgumentWarning: () => void;
|
|
17
|
+
export declare const printMissingIconsPathArgumentWarning: () => void;
|
|
18
|
+
export declare const printMissingOutDirPathArgumentWarning: () => void;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { styleText } from "node:util";
|
|
2
|
+
import { getFileSize } from "./utils.js";
|
|
3
|
+
import { DEFAULT_FONT_FACE_PATH, DEFAULT_ICONS_PATH, DEFAULT_OUT_DIR_PATH, SCSS_BUNDLES_OUT_DIR } from "./constants.js";
|
|
4
|
+
export const printBundleWasCreated = (args) => console.log(styleText("greenBright", " Created: ") +
|
|
5
|
+
styleText("white", args.outDir) +
|
|
6
|
+
styleText("whiteBright", args.filePathToCreateBundle.replace(args.outDir, "")) +
|
|
7
|
+
styleText("cyan", " ".repeat(1 + args.largestBundleLength - args.bundleName.length) +
|
|
8
|
+
getFileSize(args.compiledBundleWithoutPlaceholders)));
|
|
9
|
+
export const printBundleToHashMappingsWasCreated = (args) => console.log("\n" +
|
|
10
|
+
styleText("greenBright", " Created: ") +
|
|
11
|
+
styleText("white", args.outDir) +
|
|
12
|
+
styleText("whiteBright", args.filePath.replace(args.outDir, "")));
|
|
13
|
+
export const printBundleWasTranspiled = (filePath) => console.log(styleText("greenBright", " Transpiled: ") +
|
|
14
|
+
styleText("white", SCSS_BUNDLES_OUT_DIR) +
|
|
15
|
+
styleText("whiteBright", filePath.replace(SCSS_BUNDLES_OUT_DIR, "")));
|
|
16
|
+
export const printArgumentDoesNotExistsError = (arg) => console.log(styleText("red", " error ") +
|
|
17
|
+
styleText("gray", "Argument does not exists: ") +
|
|
18
|
+
`'${arg}'`);
|
|
19
|
+
export const printDuplicatedArgumentError = (arg) => console.log(styleText("red", " error ") +
|
|
20
|
+
styleText("gray", "Duplicated argument type: ") +
|
|
21
|
+
`'${arg}'`);
|
|
22
|
+
export const printInvalidArgumentError = (arg) => console.log(styleText("red", " error ") +
|
|
23
|
+
styleText("gray", "Invalid argument: ") +
|
|
24
|
+
`'${arg}'`);
|
|
25
|
+
export const printMissingFontPathArgumentWarning = () => console.log(styleText("yellow", " [warning]: Missing --font-face-path argument. The path ") +
|
|
26
|
+
styleText("cyan", `'${DEFAULT_FONT_FACE_PATH}'`) +
|
|
27
|
+
styleText("yellow", " will be used as default."));
|
|
28
|
+
export const printMissingIconsPathArgumentWarning = () => console.log(styleText("yellow", " [warning]: Missing --icons-path argument. The path ") +
|
|
29
|
+
styleText("cyan", `'${DEFAULT_ICONS_PATH}'`) +
|
|
30
|
+
styleText("yellow", " will be used as default."));
|
|
31
|
+
export const printMissingOutDirPathArgumentWarning = () => console.log(styleText("yellow", " [warning]: Missing --outDir argument. The path ") +
|
|
32
|
+
styleText("cyan", `'${DEFAULT_OUT_DIR_PATH}'`) +
|
|
33
|
+
styleText("yellow", " will be used as default."));
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { BASE_BUNDLE_WITH_BACK_SLASH, BASE_GLOBANT_CSS_FILE, BASE_GLOBANT_FILE, BASE_GLOBANT_JS_FILE, BASE_GLOBANT_SCSS_FILE, BASE_SCSS_FILE, BUNDLE_MAPPING_ENTRIES, BUNDLE_MAPPING_FILE, CSS_BUNDLES_OUT_DIR, DEFAULT_FONT_FACE_PATH, DEFAULT_ICONS_PATH, JS_BUNDLES_OUT_DIR, SCSS_BUNDLES_OUT_DIR } from "./constants.js";
|
|
4
|
+
import { getBundleNameWithoutSpecialChars, replacePlaceholdersInBundle, transpileBundle } from "./utils.js";
|
|
5
|
+
import { printBundleWasTranspiled } from "./print-utils.js";
|
|
6
|
+
const CSS_CREATED_DIRS = new Set();
|
|
7
|
+
const JS_CREATED_DIRS = new Set();
|
|
8
|
+
const BUNDLES = [];
|
|
9
|
+
const addBaseGlobantFile = (fileMetadata, cssOutDir, jsOutDir) => {
|
|
10
|
+
const { filePath } = fileMetadata;
|
|
11
|
+
BUNDLES.push({
|
|
12
|
+
fileDir: fileMetadata.dir
|
|
13
|
+
.replace(SCSS_BUNDLES_OUT_DIR, "")
|
|
14
|
+
.replace("\\", "/"),
|
|
15
|
+
bundleNameWithBackSlash: filePath
|
|
16
|
+
.replace(SCSS_BUNDLES_OUT_DIR, "")
|
|
17
|
+
.replace(BASE_SCSS_FILE, BASE_GLOBANT_FILE)
|
|
18
|
+
});
|
|
19
|
+
const transpiledBundle = transpileBundle(filePath, true);
|
|
20
|
+
// Store the CSS file with its default values
|
|
21
|
+
fs.writeFileSync(path.join(cssOutDir, BASE_GLOBANT_CSS_FILE), replacePlaceholdersInBundle(transpiledBundle, DEFAULT_FONT_FACE_PATH, DEFAULT_ICONS_PATH));
|
|
22
|
+
// Store the CSS file in a JS file with placeholders for the values
|
|
23
|
+
fs.writeFileSync(path.join(jsOutDir, BASE_GLOBANT_JS_FILE), `export const bundle = \`${transpiledBundle}\`;`);
|
|
24
|
+
printBundleWasTranspiled(filePath.replace(BASE_SCSS_FILE, BASE_GLOBANT_SCSS_FILE));
|
|
25
|
+
};
|
|
26
|
+
export const transpileCssBundleWithPlaceholder = (fileMetadata) => {
|
|
27
|
+
const { fileName, filePath } = fileMetadata;
|
|
28
|
+
const cssOutDir = fileMetadata.dir.replace(SCSS_BUNDLES_OUT_DIR, CSS_BUNDLES_OUT_DIR);
|
|
29
|
+
const jsOutDir = fileMetadata.dir.replace(SCSS_BUNDLES_OUT_DIR, JS_BUNDLES_OUT_DIR);
|
|
30
|
+
const fileNameCssExt = fileName.replace(".scss", ".css");
|
|
31
|
+
const fileNameJsExt = fileName.replace(".scss", ".js");
|
|
32
|
+
const bundleNameWithBackSlash = filePath
|
|
33
|
+
.replace(SCSS_BUNDLES_OUT_DIR, "")
|
|
34
|
+
.replace(".scss", "");
|
|
35
|
+
BUNDLES.push({
|
|
36
|
+
fileDir: fileMetadata.dir
|
|
37
|
+
.replace(SCSS_BUNDLES_OUT_DIR, "")
|
|
38
|
+
.replace("\\", "/"),
|
|
39
|
+
bundleNameWithBackSlash
|
|
40
|
+
});
|
|
41
|
+
// Create the file directory if it does not exists
|
|
42
|
+
if (!CSS_CREATED_DIRS.has(cssOutDir)) {
|
|
43
|
+
fs.mkdirSync(cssOutDir, { recursive: true });
|
|
44
|
+
fs.mkdirSync(jsOutDir, { recursive: true });
|
|
45
|
+
CSS_CREATED_DIRS.add(cssOutDir);
|
|
46
|
+
JS_CREATED_DIRS.add(jsOutDir);
|
|
47
|
+
}
|
|
48
|
+
const transpiledBundle = transpileBundle(filePath, false);
|
|
49
|
+
// Store the CSS file with its default values
|
|
50
|
+
fs.writeFileSync(path.join(cssOutDir, fileNameCssExt), replacePlaceholdersInBundle(transpiledBundle, DEFAULT_FONT_FACE_PATH, DEFAULT_ICONS_PATH));
|
|
51
|
+
// Store the CSS file in a JS file with placeholders for the values
|
|
52
|
+
fs.writeFileSync(path.join(jsOutDir, fileNameJsExt), `export const bundle = \`${transpiledBundle}\`;`);
|
|
53
|
+
printBundleWasTranspiled(filePath);
|
|
54
|
+
if (bundleNameWithBackSlash === BASE_BUNDLE_WITH_BACK_SLASH) {
|
|
55
|
+
addBaseGlobantFile(fileMetadata, cssOutDir, jsOutDir);
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
const createBundleEntryInMappingFile = (bundleName, fileDir, transpiledBundleRef) => ` {
|
|
59
|
+
${BUNDLE_MAPPING_ENTRIES.BUNDLE_NAME}: "${bundleName}",
|
|
60
|
+
${BUNDLE_MAPPING_ENTRIES.FILE_DIR}: "${fileDir}",
|
|
61
|
+
${BUNDLE_MAPPING_ENTRIES.TRANSPILED_BUNDLE}: ${transpiledBundleRef}
|
|
62
|
+
}`;
|
|
63
|
+
export const createBundleMappingsFile = () => {
|
|
64
|
+
let bundleAssociationImports = "";
|
|
65
|
+
let bundleMappingObjectEntries = "";
|
|
66
|
+
BUNDLES.forEach(bundleMetadata => {
|
|
67
|
+
const bundleName = bundleMetadata.bundleNameWithBackSlash
|
|
68
|
+
.replaceAll("\\", "/")
|
|
69
|
+
.substring(1);
|
|
70
|
+
const transpiledBundleRef = getBundleNameWithoutSpecialChars(bundleName);
|
|
71
|
+
const bundleEntry = createBundleEntryInMappingFile(bundleName, bundleMetadata.fileDir, transpiledBundleRef);
|
|
72
|
+
bundleAssociationImports += `import { bundle as ${transpiledBundleRef} } from "./${bundleName}.js";\n`;
|
|
73
|
+
// Concat entries in the object
|
|
74
|
+
bundleMappingObjectEntries +=
|
|
75
|
+
bundleMappingObjectEntries === "" ? bundleEntry : ",\n" + bundleEntry;
|
|
76
|
+
});
|
|
77
|
+
bundleMappingObjectEntries = `\nexport const bundleMappings = [\n${bundleMappingObjectEntries}\n];`;
|
|
78
|
+
// Create the JS file that contains all mappings for the bundle
|
|
79
|
+
fs.writeFileSync(path.join(JS_BUNDLES_OUT_DIR, BUNDLE_MAPPING_FILE), bundleAssociationImports + bundleMappingObjectEntries);
|
|
80
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export type BundleMetadata = {
|
|
2
|
+
fileDir: string;
|
|
3
|
+
bundleNameWithBackSlash: string;
|
|
4
|
+
};
|
|
5
|
+
export type BundleAssociationMetadata = {
|
|
6
|
+
bundleName: string;
|
|
7
|
+
fileDir: string;
|
|
8
|
+
transpiledBundle: string;
|
|
9
|
+
};
|
|
10
|
+
export type FileMetadata = {
|
|
11
|
+
dir: string;
|
|
12
|
+
fileName: string;
|
|
13
|
+
filePath: string;
|
|
14
|
+
};
|
|
15
|
+
export type CLIArguments = {
|
|
16
|
+
avoidHash: Set<string>;
|
|
17
|
+
globant: boolean;
|
|
18
|
+
iconsPath: string;
|
|
19
|
+
fontFacePath: string;
|
|
20
|
+
outDirPath: string;
|
|
21
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export declare const getFileSize: (fileContent: string) => string;
|
|
2
|
+
export declare const transpileBundle: (filePath: string, globant: boolean) => string;
|
|
3
|
+
export declare const getHash: (fileContent: string) => string;
|
|
4
|
+
export declare const getBundleNameWithHash: <B extends string, H extends string>(bundleName: B, hash: H) => `${B}-${H}`;
|
|
5
|
+
export declare const replacePlaceholdersInBundle: (transpiledBundle: string, fontFaceValue: string, iconsValue: string) => string;
|
|
6
|
+
/**
|
|
7
|
+
* @example
|
|
8
|
+
* "base/icons" --> "baseIcons"
|
|
9
|
+
* "utils/form--full" --> "utilsFormFull"
|
|
10
|
+
*/
|
|
11
|
+
export declare const getBundleNameWithoutSpecialChars: (bundleName: string) => string;
|
|
12
|
+
export declare const measureTime: (callback: () => void) => void;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import crypto from "node:crypto";
|
|
2
|
+
import { styleText } from "node:util";
|
|
3
|
+
import * as sass from "sass";
|
|
4
|
+
import { FONT_FACE_PATH_PLACEHOLDER, ICONS_PATH_PLACEHOLDER, KB, SPECIAL_CHARS_IN_BUNDLE_NAME_REGEX } from "./constants.js";
|
|
5
|
+
export const getFileSize = (fileContent) => {
|
|
6
|
+
const fileLength = fileContent.length;
|
|
7
|
+
if (fileLength < KB) {
|
|
8
|
+
return fileLength + "B";
|
|
9
|
+
}
|
|
10
|
+
const fileLengthInKB = fileLength / KB;
|
|
11
|
+
if (fileLengthInKB < KB) {
|
|
12
|
+
return fileLengthInKB + "KB";
|
|
13
|
+
}
|
|
14
|
+
const fileLengthInMB = fileLengthInKB / KB;
|
|
15
|
+
if (fileLengthInMB < KB) {
|
|
16
|
+
return fileLengthInMB.toFixed(3) + "MB";
|
|
17
|
+
}
|
|
18
|
+
const fileLengthInGB = fileLengthInMB / KB;
|
|
19
|
+
return fileLengthInGB.toFixed(3) + "GB";
|
|
20
|
+
};
|
|
21
|
+
export const transpileBundle = (filePath, globant) => sass.compile(filePath, {
|
|
22
|
+
loadPaths: [globant ? "src/config/globant" : "src/config/default"],
|
|
23
|
+
style: "compressed"
|
|
24
|
+
}).css;
|
|
25
|
+
export const getHash = (fileContent) => crypto.createHash("md5").update(fileContent).digest("hex").substring(16);
|
|
26
|
+
export const getBundleNameWithHash = (bundleName, hash) => `${bundleName}-${hash}`;
|
|
27
|
+
export const replacePlaceholdersInBundle = (transpiledBundle, fontFaceValue, iconsValue) => transpiledBundle
|
|
28
|
+
.replaceAll(ICONS_PATH_PLACEHOLDER, iconsValue)
|
|
29
|
+
.replaceAll(FONT_FACE_PATH_PLACEHOLDER, fontFaceValue);
|
|
30
|
+
/**
|
|
31
|
+
* @example
|
|
32
|
+
* "base/icons" --> "baseIcons"
|
|
33
|
+
* "utils/form--full" --> "utilsFormFull"
|
|
34
|
+
*/
|
|
35
|
+
export const getBundleNameWithoutSpecialChars = (bundleName) => {
|
|
36
|
+
const bundleNameNoSpecialChars = bundleName
|
|
37
|
+
.split(SPECIAL_CHARS_IN_BUNDLE_NAME_REGEX)
|
|
38
|
+
.map(subPath => subPath.charAt(0).toUpperCase() + subPath.slice(1))
|
|
39
|
+
.join("");
|
|
40
|
+
return (bundleNameNoSpecialChars.charAt(0).toLowerCase() +
|
|
41
|
+
bundleNameNoSpecialChars.slice(1));
|
|
42
|
+
};
|
|
43
|
+
export const measureTime = (callback) => {
|
|
44
|
+
console.time(styleText("green", "Done in"));
|
|
45
|
+
callback();
|
|
46
|
+
console.timeEnd(styleText("green", "Done in"));
|
|
47
|
+
};
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { DEFAULT_FONT_FACE_PATH, DEFAULT_ICONS_PATH, DEFAULT_OUT_DIR_PATH, SEPARATE_BY_COMMA_REGEX } from "./constants.js";
|
|
2
|
+
import { printArgumentDoesNotExistsError, printDuplicatedArgumentError, printInvalidArgumentError, printMissingFontPathArgumentWarning, printMissingIconsPathArgumentWarning, printMissingOutDirPathArgumentWarning } from "./print-utils.js";
|
|
3
|
+
const ARGUMENT_VALUE_AND_NAME_SEPARATOR_REGEX = /\s*=\s*/g;
|
|
4
|
+
const ERROR_IN_CHECK = false;
|
|
5
|
+
const SUCCESS_CHECK = true;
|
|
6
|
+
const [, , ...args] = process.argv;
|
|
7
|
+
const AVOID_HASH_ARGUMENTS = new Set(["--avoid-hash", "--ah", "-ah"]);
|
|
8
|
+
const ICONS_PATH_ARGUMENTS = new Set(["--icons-path", "--icons", "--i", "-i"]);
|
|
9
|
+
const FONT_FACE_PATH_ARGUMENTS = new Set([
|
|
10
|
+
"--font-face-path",
|
|
11
|
+
"--font-face",
|
|
12
|
+
"--f",
|
|
13
|
+
"-f"
|
|
14
|
+
]);
|
|
15
|
+
const OUT_DIR_ARGUMENTS = new Set(["--outdir", "--o", "-o"]);
|
|
16
|
+
const GLOBANT_ARGUMENTS = new Set(["--globant", "--gl", "-gl"]);
|
|
17
|
+
const isAvoidHashArgument = (arg) => AVOID_HASH_ARGUMENTS.has(arg.toLowerCase());
|
|
18
|
+
const isFontFaceArgument = (arg) => FONT_FACE_PATH_ARGUMENTS.has(arg.toLowerCase());
|
|
19
|
+
const isGlobantArgument = (arg) => GLOBANT_ARGUMENTS.has(arg.toLowerCase());
|
|
20
|
+
const isIconsArgument = (arg) => ICONS_PATH_ARGUMENTS.has(arg.toLowerCase());
|
|
21
|
+
const isOutDirArgument = (arg) => OUT_DIR_ARGUMENTS.has(arg.toLowerCase());
|
|
22
|
+
let hasAvoidHash = false;
|
|
23
|
+
let hasGlobant = false;
|
|
24
|
+
let hasFontFacePath = false;
|
|
25
|
+
let hasIconsPath = false;
|
|
26
|
+
let hasOutDirPath = false;
|
|
27
|
+
let anyWarning = false;
|
|
28
|
+
let avoidHash = [];
|
|
29
|
+
let fontFacePath = "";
|
|
30
|
+
let iconsPath = "";
|
|
31
|
+
let outDirPath = "";
|
|
32
|
+
const checkArgument = (argument) => {
|
|
33
|
+
if (isGlobantArgument(argument)) {
|
|
34
|
+
if (hasGlobant) {
|
|
35
|
+
printDuplicatedArgumentError(argument);
|
|
36
|
+
return ERROR_IN_CHECK;
|
|
37
|
+
}
|
|
38
|
+
hasGlobant = true;
|
|
39
|
+
return SUCCESS_CHECK;
|
|
40
|
+
}
|
|
41
|
+
const argNameWithValue = argument.split(ARGUMENT_VALUE_AND_NAME_SEPARATOR_REGEX);
|
|
42
|
+
if (argNameWithValue.length !== 2) {
|
|
43
|
+
printInvalidArgumentError(argument);
|
|
44
|
+
return ERROR_IN_CHECK;
|
|
45
|
+
}
|
|
46
|
+
const argName = argNameWithValue[0];
|
|
47
|
+
const argValue = argNameWithValue[1];
|
|
48
|
+
if (isAvoidHashArgument(argName)) {
|
|
49
|
+
if (hasAvoidHash) {
|
|
50
|
+
printDuplicatedArgumentError(argument);
|
|
51
|
+
return ERROR_IN_CHECK;
|
|
52
|
+
}
|
|
53
|
+
avoidHash = argValue.split(SEPARATE_BY_COMMA_REGEX);
|
|
54
|
+
hasAvoidHash = true;
|
|
55
|
+
return SUCCESS_CHECK;
|
|
56
|
+
}
|
|
57
|
+
if (isFontFaceArgument(argName)) {
|
|
58
|
+
if (hasFontFacePath) {
|
|
59
|
+
printDuplicatedArgumentError(argument);
|
|
60
|
+
return ERROR_IN_CHECK;
|
|
61
|
+
}
|
|
62
|
+
fontFacePath = argValue;
|
|
63
|
+
hasFontFacePath = true;
|
|
64
|
+
return SUCCESS_CHECK;
|
|
65
|
+
}
|
|
66
|
+
if (isIconsArgument(argName)) {
|
|
67
|
+
if (hasIconsPath) {
|
|
68
|
+
printDuplicatedArgumentError(argument);
|
|
69
|
+
return ERROR_IN_CHECK;
|
|
70
|
+
}
|
|
71
|
+
iconsPath = argValue;
|
|
72
|
+
hasIconsPath = true;
|
|
73
|
+
return SUCCESS_CHECK;
|
|
74
|
+
}
|
|
75
|
+
if (isOutDirArgument(argName)) {
|
|
76
|
+
if (hasOutDirPath) {
|
|
77
|
+
printDuplicatedArgumentError(argument);
|
|
78
|
+
return ERROR_IN_CHECK;
|
|
79
|
+
}
|
|
80
|
+
outDirPath = argValue;
|
|
81
|
+
hasOutDirPath = true;
|
|
82
|
+
return SUCCESS_CHECK;
|
|
83
|
+
}
|
|
84
|
+
printArgumentDoesNotExistsError(argument);
|
|
85
|
+
return ERROR_IN_CHECK;
|
|
86
|
+
};
|
|
87
|
+
export const getArguments = () => {
|
|
88
|
+
for (let index = 0; index < args.length; index++) {
|
|
89
|
+
if (checkArgument(args[index]) === ERROR_IN_CHECK) {
|
|
90
|
+
return undefined;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
if (!fontFacePath) {
|
|
94
|
+
printMissingFontPathArgumentWarning();
|
|
95
|
+
fontFacePath = DEFAULT_FONT_FACE_PATH;
|
|
96
|
+
anyWarning = true;
|
|
97
|
+
}
|
|
98
|
+
if (!iconsPath) {
|
|
99
|
+
printMissingIconsPathArgumentWarning();
|
|
100
|
+
iconsPath = DEFAULT_ICONS_PATH;
|
|
101
|
+
anyWarning = true;
|
|
102
|
+
}
|
|
103
|
+
if (!outDirPath) {
|
|
104
|
+
printMissingOutDirPathArgumentWarning();
|
|
105
|
+
outDirPath = DEFAULT_OUT_DIR_PATH;
|
|
106
|
+
anyWarning = true;
|
|
107
|
+
}
|
|
108
|
+
// Print a line break to better visualize warnings
|
|
109
|
+
if (anyWarning) {
|
|
110
|
+
console.log("");
|
|
111
|
+
}
|
|
112
|
+
return {
|
|
113
|
+
avoidHash: new Set(avoidHash),
|
|
114
|
+
globant: hasGlobant,
|
|
115
|
+
fontFacePath,
|
|
116
|
+
iconsPath,
|
|
117
|
+
outDirPath
|
|
118
|
+
};
|
|
119
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { createBundlesWithCustomPaths } from "./internal/create-bundles-with-custom-paths.js";
|
|
3
|
+
import { ensureDirectoryExistsAndItsClear } from "./internal/file-management.js";
|
|
4
|
+
import { getArguments } from "./internal/validate-args.js";
|
|
5
|
+
import { measureTime } from "./internal/utils.js";
|
|
6
|
+
measureTime(() => {
|
|
7
|
+
// Improve process visualization
|
|
8
|
+
console.log("");
|
|
9
|
+
const args = getArguments();
|
|
10
|
+
if (args) {
|
|
11
|
+
ensureDirectoryExistsAndItsClear(args.outDirPath);
|
|
12
|
+
createBundlesWithCustomPaths(args);
|
|
13
|
+
}
|
|
14
|
+
});
|
package/dist/mercury.scss
CHANGED
|
@@ -4309,6 +4309,8 @@
|
|
|
4309
4309
|
--code__border: var(--mer-border__width--sm) solid
|
|
4310
4310
|
var(--mer-surface__elevation--03);
|
|
4311
4311
|
--code__border-radius: var(--mer-border__radius--sm);
|
|
4312
|
+
|
|
4313
|
+
// TODO: Fix this. It MUST be two separated properties (padding-block and padding-inline)
|
|
4312
4314
|
--code__padding: var(--mer-spacing--xs) var(--mer-spacing--sm);
|
|
4313
4315
|
|
|
4314
4316
|
--ch-code__doctag: var(--code__color-blue);
|
|
@@ -10611,7 +10613,7 @@
|
|
|
10611
10613
|
}
|
|
10612
10614
|
}
|
|
10613
10615
|
|
|
10614
|
-
%
|
|
10616
|
+
%switch-basic {
|
|
10615
10617
|
--ch-switch-track__unchecked-background-color: var(
|
|
10616
10618
|
--mer-color__neutral-gray--650
|
|
10617
10619
|
);
|
|
@@ -10621,7 +10623,8 @@
|
|
|
10621
10623
|
--ch-switch-thumb__unchecked-background-color: var(--mer-icon__neutral);
|
|
10622
10624
|
--ch-switch-thumb__checked-background-color: var(--mer-icon__neutral);
|
|
10623
10625
|
--ch-switch-thumb__state-transition-duration: 150ms;
|
|
10624
|
-
font-weight:
|
|
10626
|
+
font-weight: var(--mer-font__weight--regular);
|
|
10627
|
+
line-height: var(--mer-line-height--regular);
|
|
10625
10628
|
|
|
10626
10629
|
&__track {
|
|
10627
10630
|
border-radius: var(--ch-switch-track-block-size);
|
|
@@ -10643,12 +10646,12 @@
|
|
|
10643
10646
|
|
|
10644
10647
|
&__caption {
|
|
10645
10648
|
&--checked {
|
|
10646
|
-
|
|
10649
|
+
// Font weight shouldn't change, since it causes a subtle inline-size shift, moving surrounding elements.
|
|
10647
10650
|
}
|
|
10648
10651
|
}
|
|
10649
10652
|
}
|
|
10650
10653
|
|
|
10651
|
-
%
|
|
10654
|
+
%switch-small {
|
|
10652
10655
|
--ch-switch-track-block-size: 16px;
|
|
10653
10656
|
--ch-switch-track-inline-size: 31px;
|
|
10654
10657
|
--ch-switch-thumb-size: 9px;
|
|
@@ -10664,7 +10667,7 @@
|
|
|
10664
10667
|
}
|
|
10665
10668
|
}
|
|
10666
10669
|
|
|
10667
|
-
%
|
|
10670
|
+
%switch-large {
|
|
10668
10671
|
--ch-switch-track-block-size: 26px;
|
|
10669
10672
|
--ch-switch-track-inline-size: 50px;
|
|
10670
10673
|
--ch-switch-thumb-size: 16px;
|
|
@@ -10680,77 +10683,77 @@
|
|
|
10680
10683
|
}
|
|
10681
10684
|
}
|
|
10682
10685
|
|
|
10683
|
-
@mixin
|
|
10684
|
-
$
|
|
10685
|
-
$track-selector: ".
|
|
10686
|
-
$track--disabled-selector: ".
|
|
10687
|
-
$thumb--unchecked-selector: ".
|
|
10688
|
-
$thumb--checked-selector: ".
|
|
10689
|
-
$caption--checked-selector: ".
|
|
10686
|
+
@mixin switch-small(
|
|
10687
|
+
$switch-selector: ".switch-small",
|
|
10688
|
+
$track-selector: ".switch-small::part(track)",
|
|
10689
|
+
$track--disabled-selector: ".switch-small::part(track disabled)",
|
|
10690
|
+
$thumb--unchecked-selector: ".switch-small::part(thumb unchecked)",
|
|
10691
|
+
$thumb--checked-selector: ".switch-small::part(thumb checked)",
|
|
10692
|
+
$caption--checked-selector: ".switch-small::part(caption checked)",
|
|
10690
10693
|
$add--disabled: true
|
|
10691
10694
|
) {
|
|
10692
|
-
#{$
|
|
10693
|
-
@extend %
|
|
10694
|
-
@extend %
|
|
10695
|
+
#{$switch-selector} {
|
|
10696
|
+
@extend %switch-basic;
|
|
10697
|
+
@extend %switch-small;
|
|
10695
10698
|
}
|
|
10696
10699
|
|
|
10697
10700
|
#{$track-selector} {
|
|
10698
|
-
@extend %
|
|
10701
|
+
@extend %switch-basic__track;
|
|
10699
10702
|
}
|
|
10700
10703
|
|
|
10701
10704
|
@if $add--disabled {
|
|
10702
10705
|
#{$track--disabled-selector} {
|
|
10703
|
-
@extend %
|
|
10706
|
+
@extend %switch-basic__track--disabled;
|
|
10704
10707
|
}
|
|
10705
10708
|
}
|
|
10706
10709
|
|
|
10707
10710
|
#{$thumb--unchecked-selector} {
|
|
10708
|
-
@extend %
|
|
10711
|
+
@extend %switch-small__thumb--unchecked;
|
|
10709
10712
|
}
|
|
10710
10713
|
|
|
10711
10714
|
#{$thumb--checked-selector} {
|
|
10712
|
-
@extend %
|
|
10715
|
+
@extend %switch-small__thumb--checked;
|
|
10713
10716
|
}
|
|
10714
10717
|
|
|
10715
10718
|
#{$caption--checked-selector} {
|
|
10716
|
-
@extend %
|
|
10719
|
+
@extend %switch-basic__caption--checked;
|
|
10717
10720
|
}
|
|
10718
10721
|
}
|
|
10719
10722
|
|
|
10720
|
-
@mixin
|
|
10721
|
-
$
|
|
10722
|
-
$track-selector: ".
|
|
10723
|
-
$track--disabled-selector: ".
|
|
10724
|
-
$thumb--unchecked-selector: ".
|
|
10725
|
-
$thumb--checked-selector: ".
|
|
10726
|
-
$caption--checked-selector: ".
|
|
10723
|
+
@mixin switch-large(
|
|
10724
|
+
$switch-selector: ".switch-large",
|
|
10725
|
+
$track-selector: ".switch-large::part(track)",
|
|
10726
|
+
$track--disabled-selector: ".switch-large::part(track disabled)",
|
|
10727
|
+
$thumb--unchecked-selector: ".switch-large::part(thumb unchecked)",
|
|
10728
|
+
$thumb--checked-selector: ".switch-large::part(thumb checked)",
|
|
10729
|
+
$caption--checked-selector: ".switch-large::part(caption checked)",
|
|
10727
10730
|
$add--disabled: true
|
|
10728
10731
|
) {
|
|
10729
|
-
#{$
|
|
10730
|
-
@extend %
|
|
10731
|
-
@extend %
|
|
10732
|
+
#{$switch-selector} {
|
|
10733
|
+
@extend %switch-basic;
|
|
10734
|
+
@extend %switch-large;
|
|
10732
10735
|
}
|
|
10733
10736
|
|
|
10734
10737
|
#{$track-selector} {
|
|
10735
|
-
@extend %
|
|
10738
|
+
@extend %switch-basic__track;
|
|
10736
10739
|
}
|
|
10737
10740
|
|
|
10738
10741
|
@if $add--disabled {
|
|
10739
10742
|
#{$track--disabled-selector} {
|
|
10740
|
-
@extend %
|
|
10743
|
+
@extend %switch-basic__track--disabled;
|
|
10741
10744
|
}
|
|
10742
10745
|
}
|
|
10743
10746
|
|
|
10744
10747
|
#{$thumb--unchecked-selector} {
|
|
10745
|
-
@extend %
|
|
10748
|
+
@extend %switch-large__thumb--unchecked;
|
|
10746
10749
|
}
|
|
10747
10750
|
|
|
10748
10751
|
#{$thumb--checked-selector} {
|
|
10749
|
-
@extend %
|
|
10752
|
+
@extend %switch-large__thumb--checked;
|
|
10750
10753
|
}
|
|
10751
10754
|
|
|
10752
10755
|
#{$caption--checked-selector} {
|
|
10753
|
-
@extend %
|
|
10756
|
+
@extend %switch-basic__caption--checked;
|
|
10754
10757
|
}
|
|
10755
10758
|
}
|
|
10756
10759
|
|
|
@@ -11195,7 +11198,7 @@
|
|
|
11195
11198
|
$tab: true,
|
|
11196
11199
|
$tabular-grid: true,
|
|
11197
11200
|
$ticket-list: true,
|
|
11198
|
-
$
|
|
11201
|
+
$switch: true,
|
|
11199
11202
|
$tooltip: true,
|
|
11200
11203
|
$tree-view: true,
|
|
11201
11204
|
$widget: true
|
|
@@ -22974,9 +22977,9 @@
|
|
|
22974
22977
|
@include ticket-list();
|
|
22975
22978
|
}
|
|
22976
22979
|
|
|
22977
|
-
@if $
|
|
22978
|
-
@include
|
|
22979
|
-
@include
|
|
22980
|
+
@if $switch {
|
|
22981
|
+
@include switch-small();
|
|
22982
|
+
@include switch-large();
|
|
22980
22983
|
}
|
|
22981
22984
|
|
|
22982
22985
|
@if $tooltip {
|
|
@@ -23062,7 +23065,7 @@
|
|
|
23062
23065
|
$tab: false,
|
|
23063
23066
|
$tabular-grid: false,
|
|
23064
23067
|
$ticket-list: false,
|
|
23065
|
-
$
|
|
23068
|
+
$switch: false,
|
|
23066
23069
|
$tooltip: false,
|
|
23067
23070
|
$tree-view: false,
|
|
23068
23071
|
$widget: false
|
|
@@ -23137,7 +23140,7 @@
|
|
|
23137
23140
|
$tab: $tab,
|
|
23138
23141
|
$tabular-grid: $tabular-grid,
|
|
23139
23142
|
$ticket-list: $ticket-list,
|
|
23140
|
-
$
|
|
23143
|
+
$switch: $switch,
|
|
23141
23144
|
$tooltip: $tooltip,
|
|
23142
23145
|
$tree-view: $tree-view,
|
|
23143
23146
|
$widget: $widget
|