Skip to content

Commit

Permalink
Prepare internal packages (DevExpress#26052)
Browse files Browse the repository at this point in the history
Co-authored-by: ilyakhd <14272298+IlyaKhD@users.noreply.github.com>
  • Loading branch information
Lykoi18 and IlyaKhD committed Nov 22, 2023
1 parent 5564408 commit de463c1
Show file tree
Hide file tree
Showing 13 changed files with 344 additions and 90 deletions.
53 changes: 36 additions & 17 deletions build/build-all.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,17 @@ const INTERNAL_TOOLS_ARTIFACTS = path.join(MONOREPO_ROOT, 'artifacts', 'internal

const OUTPUT_DIR = path.join(MONOREPO_ROOT, 'artifacts');
const NPM_OUTPUT_DIR = path.join(OUTPUT_DIR, 'npm');
const DEVEXTREME_NPM_DIR = path.join(MONOREPO_ROOT, 'packages/devextreme/artifacts/npm');

sh.set('-e');

sh.mkdir('-p', NPM_OUTPUT_DIR);

const packAndCopy = (outputDir: string) => {
sh.exec('npm pack', { silent: true });
sh.cp('*.tgz', outputDir);
}

const monorepoVersion = sh.exec('npm pkg get version', { silent: true }).stdout.replaceAll('"', '');
const MAJOR_VERSION = monorepoVersion.split('.').slice(0, 2).join('_');

Expand All @@ -24,22 +30,27 @@ const DOCUMENTATION_TEMP_DIR = path.join(OUTPUT_DIR, 'doc_tmp');
sh.exec(`git clone -b ${MAJOR_VERSION} --depth 1 --config core.longpaths=true https://github.com/DevExpress/devextreme-documentation.git ${DOCUMENTATION_TEMP_DIR}`);

sh.pushd(DOCUMENTATION_TEMP_DIR);
sh.exec('npm i');
sh.exec(`npm run update-topics -- --artifacts ${INTERNAL_TOOLS_ARTIFACTS}`);
sh.exec('npm i');
sh.exec(`npm run update-topics -- --artifacts ${INTERNAL_TOOLS_ARTIFACTS}`);
sh.popd();

sh.rm('-rf', DOCUMENTATION_TEMP_DIR);

sh.exec('npm run devextreme:inject-descriptions');

sh.exec('npm run build-dist -w devextreme-main');
sh.exec('npm run build-dist -w devextreme-main', {
env: {
...sh.env,
BUILD_INTERNAL_PACKAGE: 'false'
}
});
sh.exec('npm run build -w devextreme-themebuilder');

// Copy artifacts for DXBuild (Installation)
sh.pushd(path.join(MONOREPO_ROOT, 'packages/devextreme/artifacts'));
sh.cp('-r', 'ts', OUTPUT_DIR);
sh.cp('-r', 'js', OUTPUT_DIR);
sh.cp('-r', 'css', OUTPUT_DIR);
sh.cp('-r', 'ts', OUTPUT_DIR);
sh.cp('-r', 'js', OUTPUT_DIR);
sh.cp('-r', 'css', OUTPUT_DIR);
sh.popd();

// TODO: maybe we should add bootstrap to vendors
Expand All @@ -54,26 +65,34 @@ if (devextremeVersion !== devextremeNpmVersion) {
sh.exec(`npm run all:update-version -- ${devextremeNpmVersion}`);
}

const DEVEXTREME_NPM_DIR = path.join(MONOREPO_ROOT, 'packages/devextreme/artifacts/npm');

sh.pushd(path.join(DEVEXTREME_NPM_DIR, 'devextreme'))
sh.exec('npm pack', { silent: true });
sh.cp('*.tgz', NPM_OUTPUT_DIR);
sh.pushd(path.join(DEVEXTREME_NPM_DIR, 'devextreme'));
packAndCopy(NPM_OUTPUT_DIR);
sh.popd();

sh.pushd(path.join(DEVEXTREME_NPM_DIR, 'devextreme-dist'))
sh.exec('npm pack', { silent: true });
sh.cp('*.tgz', NPM_OUTPUT_DIR);
sh.pushd(path.join(DEVEXTREME_NPM_DIR, 'devextreme-dist'));
packAndCopy(NPM_OUTPUT_DIR);
sh.popd();

sh.pushd(path.join(MONOREPO_ROOT, 'packages', 'devextreme-themebuilder', 'dist'));
sh.exec(`npm pkg set version="${devextremeNpmVersion}"`);
sh.exec('npm pack', { silent: true });
sh.cp('*.tgz', NPM_OUTPUT_DIR);
sh.exec(`npm pkg set version="${devextremeNpmVersion}"`);
packAndCopy(NPM_OUTPUT_DIR);
sh.popd();

sh.exec('npm run pack -w devextreme-angular -w devextreme-react -w devextreme-vue', { silent: true });

sh.cp(path.join(MONOREPO_ROOT, 'packages', 'devextreme-angular', 'npm', 'dist', '*.tgz'), NPM_OUTPUT_DIR);
sh.cp(path.join(MONOREPO_ROOT, 'packages', 'devextreme-react', 'npm', '*.tgz'), NPM_OUTPUT_DIR);
sh.cp(path.join(MONOREPO_ROOT, 'packages', 'devextreme-vue', 'npm', '*.tgz'), NPM_OUTPUT_DIR);

if (sh.env.BUILD_INTERNAL_PACKAGE === 'true') {
sh.exec('npm run build-dist -w devextreme-main');

sh.pushd(path.join(DEVEXTREME_NPM_DIR, 'devextreme-internal'));
sh.exec(`npm pkg set version="${devextremeNpmVersion}"`);
packAndCopy(NPM_OUTPUT_DIR);
sh.popd();

sh.pushd(path.join(DEVEXTREME_NPM_DIR, 'devextreme-dist-internal'));
packAndCopy(NPM_OUTPUT_DIR);
sh.popd();
}
183 changes: 183 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions packages/devextreme/build/gulp/env-variables.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
'use strict';

function readFlag(variableName) {
return String(process.env[variableName]).toLowerCase() ==='true'
return String(process.env[variableName]).toLowerCase() === 'true';
}

module.exports = {
TEST_CI: readFlag('DEVEXTREME_TEST_CI'),
BUILD_ESM_PACKAGE: readFlag('BUILD_ESM_PACKAGE') && !readFlag('DEVEXTREME_TEST_CI'),
BUILD_INPROGRESS_RENOVATION: readFlag('BUILD_INPROGRESS_RENOVATION'),
BUILD_TESTCAFE: readFlag('BUILD_TESTCAFE')
BUILD_TESTCAFE: readFlag('BUILD_TESTCAFE'),
BUILD_INTERNAL_PACKAGE: readFlag('BUILD_INTERNAL_PACKAGE')
};
16 changes: 13 additions & 3 deletions packages/devextreme/build/gulp/js-bundles.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const compressionPipes = require('./compression-pipes.js');
const ctx = require('./context.js');
const headerPipes = require('./header-pipes.js');
const webpackConfig = require('../../webpack.config.js');
const env = require('./env-variables.js');

const namedDebug = lazyPipe()
.pipe(named, (file) => path.basename(file.path, path.extname(file.path)) + '.debug');
Expand All @@ -28,10 +29,19 @@ const DEBUG_BUNDLES = BUNDLES.concat([ '/bundles/dx.custom.js' ]);

const processBundles = (bundles, pathPrefix) => bundles.map((bundle) => pathPrefix + bundle);
const muteWebPack = () => undefined;
const getWebpackConfig = () => env.BUILD_INTERNAL_PACKAGE ?
Object.assign({
plugins: [
new webpack.NormalModuleReplacementPlugin(/(.*)\/license_validation/, resource => {
resource.request = resource.request.replace('license_validation', 'license_validation_internal');
})
]
}, webpackConfig) :
webpackConfig;

const bundleProdPipe = lazyPipe()
.pipe(named)
.pipe(() => webpackStream(webpackConfig, webpack, muteWebPack))
.pipe(() => webpackStream(getWebpackConfig(), webpack, muteWebPack))
.pipe(headerPipes.useStrict)
.pipe(headerPipes.bangLicense)
.pipe(compressionPipes.minify);
Expand All @@ -49,14 +59,14 @@ gulp.task('js-bundles-prod',
);

function prepareDebugMeta(watch) {
const debugConfig = Object.assign({ watch }, webpackConfig);
const debugConfig = Object.assign({ watch }, getWebpackConfig());
const bundlesPath = ctx.TRANSPILED_PROD_RENOVATION_PATH;

const bundles = processBundles(DEBUG_BUNDLES, bundlesPath);

debugConfig.output = Object.assign({}, webpackConfig.output);
debugConfig.output['pathinfo'] = true;
debugConfig.mode = watch ? "development" : "production";
debugConfig.mode = watch ? 'development' : 'production';
debugConfig.optimization.minimize = false;

if(!ctx.uglify) {
Expand Down
Loading

0 comments on commit de463c1

Please sign in to comment.