Skip to content

Commit

Permalink
Merge pull request #3173 from aleksandrychev/ENT-9758
Browse files Browse the repository at this point in the history
Moved build commands from main.sh to npm scripts
  • Loading branch information
olehermanse authored Jan 5, 2024
2 parents 8fc3f7c + 5d54b8c commit a254ffa
Show file tree
Hide file tree
Showing 5 changed files with 337 additions and 10 deletions.
8 changes: 1 addition & 7 deletions generator/build/main.sh
Original file line number Diff line number Diff line change
Expand Up @@ -119,11 +119,5 @@ export LC_ALL=C.UTF-8
echo "+ bash -x ./_scripts/_run_jekyll.sh $BRANCH || exit 6"
bash -x ./_scripts/_run_jekyll.sh $BRANCH || exit 6

cd $WRKDIR/documentation/generator/build/search
$(which npm) i
$(which node) createIndex.js
cp -rf ./searchIndex ./../../_site/assets/
npm ci --prefix $WRKDIR/documentation/generator/_assets/styles
cd $WRKDIR/documentation/generator
npm ci
node_modules/.bin/webpack-cli --config webpack.config.js --mode production
npm run build
6 changes: 3 additions & 3 deletions generator/build/search/createIndex.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const FlexSearch = require("flexsearch");
const fs = require('fs');
const {readdir} = require('fs').promises;

const htmlFilesDir = '../../_site';
const htmlFilesDir = `${__dirname}/../../_site`;

String.prototype.stripHtmlTags = function () {
return this.replace(/<\/?[^>]+(>|$)/g, " ");
Expand Down Expand Up @@ -63,13 +63,13 @@ const getHtmlFiles = async (dir) =>
breadCrumbs = breadCrumbsMatch[0].replace(/\s\s+/g, ' ').replace(/\n/g, " ");
}

fs.writeFileSync(`searchIndex/documents/${key}.json`, JSON.stringify({
fs.writeFileSync(`${__dirname}/searchIndex/documents/${key}.json`, JSON.stringify({
...document,
uri: (htmlFiles[key]),
breadCrumbs
}));
index.add(document)
}

index.export((key, data) => fs.writeFileSync(`searchIndex/${key}.json`, data || ''));
index.export((key, data) => fs.writeFileSync(`${__dirname}/searchIndex/${key}.json`, data || ''));
})();
Loading

0 comments on commit a254ffa

Please sign in to comment.