Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: add option to force rebuild of extensions #4830

Merged
merged 3 commits into from
Nov 16, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions Composer/scripts/compileExtensions.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,17 @@ const path = require('path');
// eslint-disable-next-line security/detect-child-process
const { execSync } = require('child_process');

const FORCE_BUILD = process.argv.includes('--force') || process.argv.includes('-f');

const extensionsDir = process.env.COMPOSER_BUILTIN_EXTENSIONS_DIR || path.resolve(__dirname, '../../extensions');
const buildCachePath = path.resolve(extensionsDir, '.build-cache.json');

console.log('Compiling extensions in %s', extensionsDir);

if (FORCE_BUILD) {
console.log('--force is true. Forcing a rebuild of all extensions.');
}

const allExtensions = fs.readdirSync(extensionsDir, { withFileTypes: true });

const checkComposerLibs = () => {
Expand Down Expand Up @@ -87,7 +93,7 @@ const compile = (name, extPath) => {

console.log('[%s] compiling', name);
console.log('[%s] yarn install', name);
execSync('yarn --force --production=false', { cwd: extPath, stdio: 'inherit' });
execSync('yarn --force --production=false --frozen-lockfile', { cwd: extPath, stdio: 'inherit' });

if (hasBuild) {
console.log('[%s] yarn build', name);
Expand All @@ -108,11 +114,11 @@ for (const entry of allExtensions) {
if (!fs.existsSync(packageJSONPath)) {
console.warn(`Ignore directory ${extPath} which is not a npm module.`);
continue;
};
}

const packageJSON = JSON.parse(fs.readFileSync(packageJSONPath));
const lastModified = getLastModified(extPath);
if (missingMain(extPath, packageJSON) || hasChanges(entry.name, lastModified)) {
if (FORCE_BUILD || missingMain(extPath, packageJSON) || hasChanges(entry.name, lastModified)) {
try {
compile(entry.name, extPath);
writeToCache(entry.name, lastModified);
Expand Down