Skip to content

Commit

Permalink
feat: build pc schema
Browse files Browse the repository at this point in the history
  • Loading branch information
martyanovandrey authored and 3y3 committed Nov 14, 2024
1 parent f3ed0f6 commit e21c638
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 5 deletions.
7 changes: 4 additions & 3 deletions scripts/build.cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ const esbuild = require('esbuild');
const tsPaths = require('./ts-paths');
const shell = require('shelljs');

const buildPageConstuctorSchema = require('./build.page-constuctor-schema');

const SEARCH_API = require.resolve('@diplodoc/search-extension/worker');
const SEARCH_LANGS = require.resolve('@diplodoc/search-extension/worker/langs');
const CLIENT_PATH = dirname(require.resolve('@diplodoc/client/manifest'));
Expand All @@ -23,7 +25,6 @@ const assets = [
];

const {version, dependencies} = require('../package.json');
const generatePageConstuctorSchema = require('./generate-pc-schema');

const commonConfig = {
tsconfig: './tsconfig.json',
Expand All @@ -43,13 +44,13 @@ const commonConfig = {
},
};

generatePageConstuctorSchema();

const builds = [
[['src/index.ts'], 'build/index.js'],
[['src/workers/linter/index.ts'], 'build/linter.js'],
];

buildPageConstuctorSchema();

Promise.all(builds.map(([entries, outfile]) => {
const currentConfig = {
...commonConfig,
Expand Down
20 changes: 20 additions & 0 deletions scripts/build.page-constuctor-schema.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
const esbuild = require('esbuild');
const shell = require('shelljs');

const SCHEMA_GENERATOR_PATH = 'build/generate-pc-schema.js'

module.exports = () => {
esbuild.buildSync({
platform: 'node',
entryPoints: ['scripts/generate-pc-schema.js'],
bundle: true,
outfile: SCHEMA_GENERATOR_PATH,
loader: {
'.css': 'empty',
},
})

require(`../${SCHEMA_GENERATOR_PATH}`)();

shell.rm('-f', SCHEMA_GENERATOR_PATH);
}
2 changes: 0 additions & 2 deletions scripts/generate-pc-schema.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
const fs = require('fs');

//TODO: server export for generateDefaultSchema in @gravity-ui/page-constructor
const {generateDefaultSchema} = require('@gravity-ui/page-constructor');

function replaceField(obj, oldFieldName, newFieldName, newFieldValue) {
Expand Down

0 comments on commit e21c638

Please sign in to comment.