Some checks failed
App Prod-Parity E2E Dispatch / dispatch (push) Failing after 10s
CD Storybook UI / build (push) Failing after 3m25s
CD Storybook UI / dispatch (push) Has been skipped
CD deploy main / website-changed-files (push) Successful in 18m8s
CI Agent Skills / changed-files-check (push) Successful in 18m9s
CI Create App E2E minimal / changed-files-check (push) Successful in 24s
CI Create App / changed-files-check (push) Successful in 26s
CI Docs / changed-files-check (push) Successful in 26s
CI Emails / changed-files-check (push) Successful in 28s
CI Example App Hello World / changed-files-check (push) Successful in 23s
CI Front / changed-files-check (push) Has been skipped
CI Example App Postcard / changed-files-check (push) Successful in 27s
CI UI / changed-files-check (push) Has been skipped
CI Utils Test / changed-files-check (push) Successful in 45s
CI Twenty Apps / discover (push) Successful in 1m3s
CD deploy main / deploy-main (push) Failing after 3s
CI Agent Skills / agent-skills-validate (push) Has been skipped
CI Create App / create-app-test (lint) (push) Has been skipped
CI Emails / emails-test (push) Has been skipped
CI Front / front-task (lingui:compile) (push) Has been skipped
CI Front / front-task (lint) (push) Has been skipped
CI Example App Postcard / example-app-postcard (push) Has been skipped
CI UI / ui-task (lint) (push) Has been skipped
CI UI / ui-task (pack-size) (push) Has been skipped
CI UI / ui-task (size) (push) Has been skipped
CI UI / ui-task (test) (push) Has been skipped
CI UI / ui-task (typecheck) (push) Has been skipped
CI Utils Test / utils-test (push) Has been skipped
CI Twenty Apps / ${{ matrix.app.name }} (push) Has been skipped
CI Emails / ci-emails-status-check (push) Successful in 2s
CI Example App Hello World / ci-example-app-hello-world-status-check (push) Successful in 2s
CI Example App Postcard / ci-example-app-postcard-status-check (push) Successful in 3s
CI UI / ui-sb-test (push) Has been skipped
CI Utils Test / ci-utils-test-status-check (push) Successful in 2s
CI Twenty Apps / ci-twenty-apps-status-check (push) Successful in 2s
CI UI / ci-ui-status-check (push) Successful in 2s
CI Desktop / desktop (push) Failing after 1m8s
Push docs to Crowdin / Push documentation to Crowdin (push) Failing after 55s
Push translations to Crowdin / Extract and upload translations (push) Failing after 5s
Push website translations to Crowdin / Extract and upload website translations (push) Failing after 5s
CI Create App / create-app-test (test) (push) Has been skipped
CI Create App / create-app-test (typecheck) (push) Has been skipped
CI Docs / docs-lint (push) Has been skipped
CI Example App Hello World / example-app-hello-world (push) Has been skipped
CI Front / front-task (lingui:extract) (push) Has been skipped
CI Front / front-task (test) (push) Has been skipped
CI Front / front-task (typecheck) (push) Has been skipped
CI UI / ui-sb-build (push) Failing after 1m32s
CI Twenty Apps / ${{ matrix.app.name }} (${{ matrix.server-source }}) (push) Has been skipped
CI Agent Skills / agent-skills-publish (push) Has been skipped
CI Create App / ci-create-app-status-check (push) Successful in 2s
CI Agent Skills / agent-skills-remote-source (push) Has been skipped
CI Create App E2E minimal / create-app-e2e-minimal (push) Has been cancelled
CI E2E Main / e2e-test (push) Has been cancelled
CI Front / front-sb-build (push) Has been cancelled
CI Front / front-build (push) Has been cancelled
CI Create App E2E minimal / ci-create-app-e2e-minimal-status-check (push) Has been cancelled
CI E2E Main / ci-e2e-main-status-check (push) Has been cancelled
CI E2E Main / notify-main-ci-failure (push) Has been cancelled
CI E2E Main / qa-scout-comment (push) Has been cancelled
CI Front / front-sb-test (push) Has been cancelled
CI Front / front-sb-screenshots (push) Has been cancelled
CI Front / ci-front-status-check (push) Has been cancelled
DPA Sub-Processor Sync / sync-subprocessors (push) Failing after 3s
AI Catalog Sync / sync-catalog (push) Failing after 2s
245 lines
6.0 KiB
TypeScript
245 lines
6.0 KiB
TypeScript
import * as esbuild from 'esbuild';
|
|
import * as fs from 'node:fs';
|
|
import * as path from 'node:path';
|
|
import { fileURLToPath } from 'node:url';
|
|
|
|
import { getFrontComponentBuildPlugins } from 'twenty-sdk/front-component-renderer/build';
|
|
|
|
const dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
const storiesDir = path.resolve(dirname, '../../src/__stories__');
|
|
const exampleSourcesBuiltDir = path.resolve(
|
|
dirname,
|
|
'../../src/__stories__/example-sources-built',
|
|
);
|
|
const exampleSourcesBuiltPreactDir = path.resolve(
|
|
dirname,
|
|
'../../src/__stories__/example-sources-built-preact',
|
|
);
|
|
|
|
const SOURCE_SCAN_ROOTS = [
|
|
'html-tag',
|
|
'host-api',
|
|
'media',
|
|
'showcase',
|
|
'twenty-ui-gallery',
|
|
];
|
|
|
|
const rootNodeModules = path.resolve(dirname, '../../../../node_modules');
|
|
|
|
const twentyUiIndividualIndex = path.resolve(
|
|
dirname,
|
|
'../../../twenty-ui/dist/individual/individual-entry.js',
|
|
);
|
|
|
|
const sdkDefineIndex = path.resolve(
|
|
dirname,
|
|
'../../../twenty-sdk/dist/define/index.mjs',
|
|
);
|
|
|
|
const sdkFrontComponentIndex = path.resolve(
|
|
dirname,
|
|
'../../../twenty-sdk/dist/front-component/index.mjs',
|
|
);
|
|
|
|
const twentySharedIndividualDir = path.resolve(
|
|
dirname,
|
|
'../../../twenty-shared/dist/individual',
|
|
);
|
|
|
|
const TWENTY_SHARED_SUBMODULES = [
|
|
'ai',
|
|
'application',
|
|
'constants',
|
|
'database-events',
|
|
'metadata',
|
|
'testing',
|
|
'translations',
|
|
'types',
|
|
'utils',
|
|
'workflow',
|
|
'workspace',
|
|
];
|
|
|
|
const twentySharedAliases = Object.fromEntries(
|
|
TWENTY_SHARED_SUBMODULES.map((submodule) => [
|
|
`twenty-shared/${submodule}`,
|
|
path.join(twentySharedIndividualDir, submodule, 'index.js'),
|
|
]),
|
|
);
|
|
|
|
const TWENTY_UI_SUBMODULES = [
|
|
'components',
|
|
'icon',
|
|
'primitives',
|
|
'primitives/accessibility',
|
|
'primitives/data-display',
|
|
'primitives/feedback',
|
|
'primitives/input',
|
|
'primitives/json-visualizer',
|
|
'primitives/layout',
|
|
'primitives/navigation',
|
|
'primitives/surfaces',
|
|
'primitives/typography',
|
|
'theme-constants',
|
|
'utilities',
|
|
];
|
|
|
|
const twentyUiAliases = {
|
|
'twenty-ui/style.css': path.join(
|
|
path.dirname(twentyUiIndividualIndex),
|
|
'twenty-ui.css',
|
|
),
|
|
'twenty-ui': twentyUiIndividualIndex,
|
|
...Object.fromEntries(
|
|
TWENTY_UI_SUBMODULES.map((submodule) => [
|
|
`twenty-ui/${submodule}`,
|
|
twentyUiIndividualIndex,
|
|
]),
|
|
),
|
|
};
|
|
|
|
const storyAlias = {
|
|
react: path.join(rootNodeModules, 'react'),
|
|
'react-dom': path.join(rootNodeModules, 'react-dom'),
|
|
'twenty-sdk/define': sdkDefineIndex,
|
|
'twenty-sdk/front-component': sdkFrontComponentIndex,
|
|
...twentyUiAliases,
|
|
...twentySharedAliases,
|
|
};
|
|
|
|
const ENTRY_POINT_PATTERN = /\.front-component\.tsx$/;
|
|
|
|
const findEntryPointFiles = (directory: string): string[] => {
|
|
const result: string[] = [];
|
|
|
|
if (!fs.existsSync(directory)) {
|
|
return result;
|
|
}
|
|
|
|
for (const dirent of fs.readdirSync(directory, { withFileTypes: true })) {
|
|
const absolutePath = path.join(directory, dirent.name);
|
|
|
|
if (dirent.isDirectory()) {
|
|
if (dirent.name === 'shared') {
|
|
continue;
|
|
}
|
|
|
|
result.push(...findEntryPointFiles(absolutePath));
|
|
continue;
|
|
}
|
|
|
|
if (!dirent.isFile()) {
|
|
continue;
|
|
}
|
|
|
|
if (ENTRY_POINT_PATTERN.test(dirent.name)) {
|
|
result.push(absolutePath);
|
|
}
|
|
}
|
|
|
|
return result;
|
|
};
|
|
|
|
const resolveEntryPoints = (): Record<string, string> => {
|
|
const files = SOURCE_SCAN_ROOTS.flatMap((root) =>
|
|
findEntryPointFiles(path.join(storiesDir, root)),
|
|
);
|
|
|
|
const entryPoints: Record<string, string> = {};
|
|
|
|
for (const filePath of files) {
|
|
const basename = path.basename(filePath).replace(/\.tsx$/, '');
|
|
|
|
if (entryPoints[basename] !== undefined) {
|
|
throw new Error(
|
|
`Duplicate front-component basename "${basename}" found at ${filePath} and ${entryPoints[basename]}`,
|
|
);
|
|
}
|
|
|
|
entryPoints[basename] = filePath;
|
|
}
|
|
|
|
if (Object.keys(entryPoints).length === 0) {
|
|
throw new Error(
|
|
`No front-component source files found under ${storiesDir} (scanned: ${SOURCE_SCAN_ROOTS.join(', ')})`,
|
|
);
|
|
}
|
|
|
|
return entryPoints;
|
|
};
|
|
|
|
const STORY_COMPONENTS = Object.keys(resolveEntryPoints());
|
|
|
|
type BundleSizeEntry = {
|
|
name: string;
|
|
reactBytes: number;
|
|
preactBytes: number;
|
|
};
|
|
|
|
const collectBundleSizes = (): BundleSizeEntry[] =>
|
|
STORY_COMPONENTS.map((name) => {
|
|
const reactFile = path.join(exampleSourcesBuiltDir, `${name}.mjs`);
|
|
const preactFile = path.join(exampleSourcesBuiltPreactDir, `${name}.mjs`);
|
|
|
|
return {
|
|
name,
|
|
reactBytes: fs.existsSync(reactFile) ? fs.statSync(reactFile).size : 0,
|
|
preactBytes: fs.existsSync(preactFile) ? fs.statSync(preactFile).size : 0,
|
|
};
|
|
});
|
|
|
|
const buildSourceExamples = async (): Promise<void> => {
|
|
const entryPoints = resolveEntryPoints();
|
|
const tsconfigPath = path.join(dirname, '../../tsconfig.json');
|
|
|
|
const commonOptions: esbuild.BuildOptions = {
|
|
entryPoints,
|
|
bundle: true,
|
|
splitting: false,
|
|
format: 'esm',
|
|
outExtension: { '.js': '.mjs' },
|
|
tsconfig: tsconfigPath,
|
|
jsx: 'automatic',
|
|
sourcemap: true,
|
|
metafile: true,
|
|
logLevel: 'silent',
|
|
minify: true,
|
|
alias: storyAlias,
|
|
};
|
|
|
|
fs.mkdirSync(exampleSourcesBuiltDir, { recursive: true });
|
|
|
|
await esbuild.build({
|
|
...commonOptions,
|
|
outdir: exampleSourcesBuiltDir,
|
|
plugins: getFrontComponentBuildPlugins(),
|
|
});
|
|
|
|
console.log(
|
|
`Built ${STORY_COMPONENTS.length} React story components to ${exampleSourcesBuiltDir}`,
|
|
);
|
|
|
|
fs.mkdirSync(exampleSourcesBuiltPreactDir, { recursive: true });
|
|
|
|
await esbuild.build({
|
|
...commonOptions,
|
|
outdir: exampleSourcesBuiltPreactDir,
|
|
plugins: getFrontComponentBuildPlugins({ usePreact: true }),
|
|
});
|
|
|
|
console.log(
|
|
`Built ${STORY_COMPONENTS.length} Preact story components to ${exampleSourcesBuiltPreactDir}`,
|
|
);
|
|
|
|
const sizes = collectBundleSizes();
|
|
const manifestPath = path.join(exampleSourcesBuiltDir, 'bundle-sizes.json');
|
|
|
|
fs.writeFileSync(manifestPath, JSON.stringify(sizes, null, 2));
|
|
console.log(`Wrote bundle size manifest to ${manifestPath}`);
|
|
};
|
|
|
|
buildSourceExamples().catch((error) => {
|
|
console.error('Failed to build mock components:', error);
|
|
process.exit(1);
|
|
});
|